Skip to content

docs(#647): AC-1 capture — Mechanism #1 confirmed at 2181× over 36m - #661

Merged
admarble merged 1 commit into
mainfrom
docs/647-ac1-capture-2026-05-17
May 17, 2026
Merged

admarble merged 1 commit into
mainfrom
docs/647-ac1-capture-2026-05-17

Conversation

@admarble

Copy link
Copy Markdown
Contributor

Summary

First production-replay AC-1 capture for #647. Run was npx sequant run 658 -q with SEQUANT_DEBUG_RENDERER=1 and script(1) recording the pty. Run completed successfully (PR #660), so this is a "clean" run that nonetheless reproduces Mechanism #1 at scale.

Headline: terminal.typescript contains 2,181 SEQUANT WORKFLOW · #N · Xs elapsed header lines persisted in scrollback over a ~36-minute run. That's one new header per second leaked into scrollback — every renderer redraw fails to erase the previous frame. Mechanism #1 (scrollback erasure from event-line scrolling) is confirmed reproducing.

What's here

  • docs/incidents/647/captures/2026-05-17/terminal.typescript — 3.1 MB script(1) byte-stream (authoritative)
  • docs/incidents/647/captures/2026-05-17/scrollback.txt — 2.4 KB earlier manual save from a #656 run (smaller sample of same pattern)
  • docs/incidents/647/captures/2026-05-17/notes.md — run command, counts, symptom summary, script(1) caveat

What this unblocks for #647

  • AC-1 production-replay sub-bullet — met.
  • AC-3 fix direction — designable from this evidence. The mechanism is now empirically grounded: every renderer redraw at 1Hz leaks the prior frame's header into scrollback when the live zone is scrolled by event-line writes.
  • AC-2 deferred Mechanism feat: Complete remaining v1.0 features (AC-10, AC-13, AC-14) #1 scaffold (it.skip in scrollback-harness.test.ts) — can be un-skipped using the parameters from this capture.

What this does NOT close

Caveat

script(1) records both stdout and stderr to the typescript file, so the AC-1 instrumentation's stderr output appears mixed with renderer stdout in the capture. The 2> debug.jsonl redirect therefore got nothing (debug.jsonl was 0 bytes, removed from this PR). The instrumentation itself correctly writes to stderr (src/lib/cli-ui/run-renderer.ts:605); the artifact-interleaving is a script wrapping property. Discriminating "renderer alone vs. exacerbated by stderr co-writer" for the mid-string-drop symptom requires a follow-up capture without script.

Not closing #647

This PR adds evidence; it does not implement the fix. #647 remains open and is ready to move from "investigate" to "fix" with this evidence in hand.

…es over 36m

Captures the `npx sequant run 658 -q` session that produced PR #660, with
SEQUANT_DEBUG_RENDERER=1 instrumentation enabled. This is the AC-1 evidence
#647 has been waiting for.

Headline finding:
- terminal.typescript contains 2,181 `SEQUANT WORKFLOW · #N · Xs elapsed`
  header lines persisted in scrollback (~1 per second over a 36-minute run).
  Every renderer redraw fails to erase the previous frame from scrollback.
  Mechanism #1 confirmed at scale.

Also captured:
- Mid-string char drops + U+FFFD overlay (distinct from #655 Symptom A's
  byte-math pattern). Cause undetermined — see notes.md for the
  script(1)-wrapper caveat that prevents discriminating "renderer alone"
  vs "exacerbated by stderr co-writer."

Artifacts:
- terminal.typescript: 3.1 MB script(1) byte-stream capture (authoritative)
- scrollback.txt: 2.4 KB manual pbpaste from an earlier #656 run
- notes.md: run command, counts, symptom summary, caveats

Entire-Checkpoint: 45ec46202785
@admarble
admarble merged commit 006764f into main May 17, 2026
5 checks passed
@admarble
admarble deleted the docs/647-ac1-capture-2026-05-17 branch May 17, 2026 16:49
admarble added a commit that referenced this pull request May 18, 2026
…ollback (#663)

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.
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