Skip to content

fix: enforce bounded TUI capture contract - #6

Merged
rustfuture merged 3 commits into
mainfrom
fix/tui-capture-contract
Sep 12, 2026
Merged

rustfuture merged 3 commits into
mainfrom
fix/tui-capture-contract

Conversation

@rustfuture

Copy link
Copy Markdown
Owner

Problem

The capture helper could stop on a quiet PTY, close the master before proving child exit, block while reaping, and report success when pyte was unavailable. That allowed incomplete or hung monitor captures to look successful.

New contract

  • Use one monotonic, deadline-bounded PTY lifecycle with select and waitpid(..., WNOHANG).
  • Send q once at the capture deadline and require a normal child exit 0 during the quit grace period.
  • Validate nonempty pre-q output and at least five strictly increasing Frame: N markers.
  • Verify the child PID/PGID before signaling only its owned process group; bound TERM and KILL cleanup and keep every timeout or forced cleanup nonzero.
  • Preserve complete raw bytes, render only the pre-q dashboard snapshot, support explicit - raw-only mode, and fail requested text rendering when pyte cannot import or render.
  • Emit a final machine-readable JSON summary with lifecycle, child status, byte, and frame evidence.

Tests

  • python3 -m py_compile demos/capture_tui.py demos/test_capture_tui.py
  • python3 -m unittest -v demos.test_capture_tui (11 passed)
  • Explicit /usr/bin/false capture returned capture exit 1, child exit 1, q_sent=false, and child_reaped=true.
  • git diff --check
  • Post-suite process scan found no capture-tui-fixture-test.py fixture or sentinel leaks.

Fixtures cover success, exit 23, empty output, repeated frames, early exit, TERM cleanup with child exit 0, KILL cleanup, unrelated-process survival, required pyte failure, and pre-q rendering.

Remaining dependency

Real product capture remains intentionally deferred until task A merges the monitor Frame: N marker into main. This PR does not produce or claim a final live product capture.

@rustfuture
rustfuture merged commit 6728b64 into main Sep 12, 2026
3 checks passed
@rustfuture
rustfuture deleted the fix/tui-capture-contract branch September 14, 2026 09:05
Repository owner deleted a comment from coderabbitai Bot Sep 14, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant