Repository navigation
test(#647): AC-1 re-analysed — Mechanism #1 was wire traffic; deterministic repro via out-of-band write harness - #663
Merged
admarble merged 1 commit intoMay 18, 2026
Conversation
…ollback Forensic VT replay of `docs/incidents/647/captures/2026-05-17/terminal.typescript` shows PR #661's "Mechanism #1 confirmed at 2181× over 36m" was reading the wire traffic count (`grep -c`), not actual scrollback occurrences. log-update's eraseLines escapes appear in the typescript file but don't delete prior bytes — those bytes only disappear in a real terminal. When the raw bytes are replayed through a 213×31 VirtualTerminal: - WITHOUT the embedded SEQUANT_DEBUG_RENDERER stderr lines: 1 scrollback header - WITH them (script(1) merged them into the same pty): 2171 scrollback headers - Amplification: 2171× The "Mechanism #1 at scale" was an instrumentation artifact. In a real user terminal without `SEQUANT_DEBUG_RENDERER=1`, log-update's eraseLines works correctly. The underlying bug is Mechanism #2-class: any out-of-band writer (stderr instrumentation, subprocess output landing outside a paused window) breaks log-update's cursor model and strands prior frames in scrollback. Deliverables in this commit: - `docs/incidents/647/captures/2026-05-17/analyze-trace.ts`: reproducible forensic script. Extracts SEQUANT_DEBUG_RENDERER JSON from the typescript, bucket-counts header occurrences by trigger pattern, replays raw bytes through VirtualTerminal both with and without stderr interleaving. - `docs/incidents/647/captures/2026-05-17/analysis.md`: human-readable writeup of the finding with TL;DR, sanity checks (width-mismatch and wrap-mismatch both confirmed at 0/2210), and recommended next steps. - `src/lib/cli-ui/scrollback-harness.ts`: minimal `stderrWrite` injection on `TerminalHarness` so the test renderer's stderr can be routed into the same VT (mirrors how a real pty merges stdout/stderr when both share a tty). - `src/lib/cli-ui/scrollback-harness.test.ts`: lifts the prior `.skip` on the Mechanism #1 reproduction. New test exercises out-of-band writes between log-update redraws and asserts `headerCount === 1` in (visible + scrollback). Marked `it.fails` per the AC-2 contract: test reproduces the bug on main (currently produces 7 occurrences instead of 1), passes once AC-3 lands. Also includes the AC-C Symptom 2 byte-integrity assertion bundled from #662. No production renderer code changed — fix lands in a separate iteration once the diagnosis is socialised. Refs #647, #662.
admarble
deleted the
feature/647-fix-cli-624-s-duplicate-header-fix-doesn-t-cat
branch
May 18, 2026 20:18
This was referenced May 18, 2026
6 tasks
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Resumes #647 after PR #653 (foundation) and PR #661 (AC-1 capture). Conservative scope: investigation + reproduction, no fix in this PR.
Forensic VT replay of the AC-1 capture (
docs/incidents/647/captures/2026-05-17/terminal.typescript) shows PR #661's "Mechanism #1 at 2181× over 36m" was reading the wire-traffic byte count, not actual scrollback. log-update'seraseLinesescapes appear in the typescript file but don't delete prior bytes — those bytes only disappear in a real terminal.SEQUANT_DEBUG_RENDERERlinesscript(1)recorded)Amplification: 2171×. The "scale" was the
SEQUANT_DEBUG_RENDERER=1instrumentation writing to the same pty as stdout. In a real user terminal without that flag, log-update'seraseLinesworks correctly. The underlying bug is Mechanism #2-class — any out-of-band writer (stderr instrumentation, subprocess output landing outside a paused window) breaks log-update's cursor model. Seedocs/incidents/647/captures/2026-05-17/analysis.mdfor the full writeup.What this PR adds
docs/incidents/647/captures/2026-05-17/analyze-trace.ts— reproducible forensic script that extracts the SEQUANT_DEBUG_RENDERER trace from the typescript file, bucket-counts header occurrences by trigger pattern, and replays raw bytes throughVirtualTerminalboth with and without stderr interleaving.docs/incidents/647/captures/2026-05-17/analysis.md— human-readable writeup with sanity checks (width-mismatch = 0/2210, wrap-mismatch = 0/2210), the differential finding, and recommended next steps (clean-baseline HITL capture, instrumentation fix to use a file sink).src/lib/cli-ui/scrollback-harness.ts— minimalstderrWriteinjection onTerminalHarness(test-only file;+11 -0) so the test renderer's stderr writes route into the same VT.src/lib/cli-ui/scrollback-harness.test.ts— lifts the prior.skipon the Mechanism feat: Complete remaining v1.0 features (AC-10, AC-13, AC-14) #1 reproduction. New test exercises out-of-band writes between log-update redraws and assertsheaderCount === 1in(visible + scrollback). Markedit.failsper the AC-2 contract: test reproduces the bug onmain(produces 7 occurrences instead of 1), passes once AC-3 lands.AC status
analysis.md+analyze-trace.tsit.failstest inscrollback-harness.test.ts:206Out of scope (deferred to next iteration)
run-renderer.tsproduction code — fix direction now clear (handle out-of-band writes), but a clean-baseline HITL capture is recommended before committing to a specific approach.SEQUANT_DEBUG_RENDERERoutput to a file sink so future investigations don't suffer the same amplification.Test plan
npx vitest run src/lib/cli-ui/→ 92 passed, 1 expected fail (the new test, as required)npm run build→ cleannpx tsx docs/incidents/647/captures/2026-05-17/analyze-trace.ts→ outputs the differential reportSEQUANT_DEBUG_RENDERER=1Refs #647, #662.