Skip to content

investigate(cli): #652 renderer corruption — column-mismatch hypothesis refuted, real cause unknown #655

Closed

Description

@admarble

Context

Spun out from #652 / closed PR #654. Issue #652 documents two production rendering symptoms:

  • Symptom A: event-line characters vanish mid-string (✔ #505 loop → ✔ #5loop — chars 05 dropped from cols 6/7/8)
  • Symptom B: U+FFFD + row overlap in summary table

PR #654 shipped a defensive column-binding fix on top of #647 (PR #653). Post-merge of #647, eight parallel agents (four adversarial reviewers + four diagnostic investigators) collectively ruled out every hypothesis the PR was built on. The byte-level pattern remains real but unexplained.

The unexplained pattern

✘ #505 qa  QA verdict: AC_MET_BUT_NOT_A_PLUS         ← event log
▸ #505 loop                                           ← event log
✔ #5loop  Claude Code returned an error result: ...  ← corrupted

The corrupted line is mathematically equal to:

complete_line[0:8 bytes] + failed_line[col 9 onward]

Where:

  • complete_line = ✔ #505 loop 60s\n (a "complete" event-line write from appendEventLine)
  • failed_line = ✘ #505 loop Claude Code returned an error result: ETIMEDOUT\n (a "failed" event-line write)
  • The first 8 bytes (" ✔ #5" — 6 visible cols) of the complete line are preserved
  • The text starting at col 9 of the failed line ("loop Claude Code returned an error result: ETIMEDOUT") appears after

The green ✔ (from the complete event) and the error text (only present on failed events) appearing on the same row are internally inconsistent — they cannot come from a single appendEventLine emission.

Ruled-out hypotheses (do NOT relitigate these)

# Hypothesis Refutation
1 log-update v7 produces mid-string overwrites via internal diff renderer False. Source dive confirmed line-level diff with full ESC[2K erase per changed line. No partial-overwrite code path.
2 claude subprocess writes interleave with renderer stdout writes Inapplicable in non-verbose mode. Sequant uses @anthropic-ai/claude-agent-sdk in-process; SDK output is captured and never touches process.stdout unless --verbose. The motivating transcript was -q (quiet) mode.
3 Column-mismatch under npx causes previousLineCount desync → eraseLines over/under-clears → mid-string overwrite Empirically refuted. wrapAnsi (used by log-update) inserts actual \n characters into the output string, so the terminal's row count always matches previousLineCount regardless of stream.columns value. Verified with 4 reproduction variants in real PTYs.
4 SIGWINCH race Programmatic process.emit("SIGWINCH") during writes did not reproduce the pattern in real PTY testing.
5 wrap-ansi splitting #505 loop across two lines mid-token wrap-ansi inserts \n; terminal sees two separate rows, not a single corrupted row.
6 renderSummary teardown order race (Symptom B specifically) JS is single-threaded; setInterval macrotasks cannot preempt synchronous code.

What we don't know

  • What single-process mechanism produces the complete[0:8] + failed[9:] overlay pattern?
    • No cursor positioning escape in log-update can place the cursor at col 6 of an already-written row (only ESC[G = col 1)
    • No subprocess shares the TTY fd
    • No partial-byte split is possible (UTF-8 boundaries don't apply mid-write at the syscall level)

Possible next steps

1. Production replay (highest signal)

Run SEQUANT_DEBUG_RENDERER=1 against a scenario known to produce Symptom A. The instrumentation already exists (from #647). Capture:

  • Exact byte sequence written to stdout
  • previousLineCount value at each frame
  • Cursor row/col before/after each write
  • Whether appendEventLine was called twice for the same (issue, phase) tuple

If repro happens in real terminal but not synthetic harness, the diff is the cause.

2. PTY-based test harness

Build a harness that wraps real process.stdout and a real PTY (via node-pty or script-style FIFO) so the synchronous-VT limitation of scrollback-harness.ts is removed. Then attempt deterministic reproduction.

3. Static analysis of all stdout writers in non-verbose mode

Audit every process.stdout.write, console.log, and similar call reachable during npx sequant run ... -q. Catalog what each writes. The forensic pattern implies a second writer exists; identify it.

4. Different mechanism entirely

The forensic pattern matches the byte math of an interleaved write, but there's no proven mechanism. Possibilities to test:

  • Node's process.stdout write queue under backpressure (unlikely — TTY writes are sync, not buffered)
  • Terminal-emulator-side rendering bug (test in multiple terminals: iTerm2, Apple Terminal, gnome-terminal, etc.)
  • An unhandledRejection or error handler writing to stdout out-of-band

Investigation artifacts

Acceptance criteria

  • Capture a real SEQUANT_DEBUG_RENDERER=1 trace from a corrupted run
  • Identify the responsible code path with byte-level evidence
  • Produce a regression test that fails on the current main and passes after the fix
  • Ship a targeted fix (not defensive cleanup)

Out of scope

  • Defensive renderer refactors that aren't motivated by reproduced evidence
  • The pause/resume dead-code bug — filed separately (sub batch-executor never passes spinner to executePhaseWithRetry)

Activity

  1. added
    bug
    cli
    complex
    on May 16, 2026
  2. admarble commented on May 16, 2026

    @admarble
    ContributorAuthor

    /spec: Implementation Plan

    Complexity: Complex — 4 ACs, diagnose-first investigation. complex label honored.

    AC Checklist

    • AC-1 — Capture SEQUANT_DEBUG_RENDERER=1 trace from a corrupted run.
      • Verification: Manual (artifact). Commit trace + stdout under docs/incidents/655/ with a README on how to reproduce.
      • Assumption: corruption is repeatable. If not, fall through to AC-D1.
    • AC-2 — Identify responsible code path with byte-level evidence.
      • Verification: Forensic write-up (PR description or docs/incidents/655/forensic.md) naming file:line, the offending byte sequence, and reconciling with the issue body's ruled-out hypotheses.
    • AC-3 — Regression test fails on origin/main and passes after AC-4.
      • Verification: Integration test (RED→GREEN). Likely scrollback-harness.test.ts extension, or new pty-harness.test.ts if AC-2 mechanism is timing-dependent.
    • AC-4 — Ship a targeted fix (not defensive cleanup).
      • Verification: AC-3 GREEN + AC-1 replay shows no corruption. Diff must comment-reference the AC-2 mechanism.
    • AC-D1 (derived) — If reproduction fails, commit docs/incidents/655/negative-result.md and leave instrumentation in place rather than shipping a speculative fix.
    • AC-D2 (derived, conditional) — If AC-2 implicates logUpdateClear-adjacent state, audit all six logUpdateClear callsites in run-renderer.ts (747, 791, 804, 822, 839, 880).

    Plan (4 phases, hard-sequential)

    1. Reproduce + capture. Try synthetic event-feed against TTYRenderer first (deterministic, fast). Escalate to live npx sequant run -q replay only if synthetic doesn't trigger the symptom.
    2. Forensic analysis. Audit every stdout writer reachable in -q mode (renderer's stdoutWrite, phase-executor.ts:675 — gated on verbose, heartbeat.ts:97, any console.*). Reconcile AC-1 trace with byte math complete[0:8] + failed[9:]. Run an adversarial pass against confirmation bias.
    3. Failing test. Pick harness based on AC-2 mechanism (sync → existing scrollback-harness, timing-dependent → new PTY harness).
    4. Targeted fix. Single minimal change, comment-tied to AC-2 mechanism. No defensive refactors (per issue body).

    Decision branches

    • AC-1 doesn't reproduce → AC-D1 path (negative-result + leave instrumentation).
    • AC-2 names a dependency bug → AC-4 pivots to upstream report + workaround.
    • Mechanism is timing-dependent → PTY harness becomes mandatory; consider splitting AC-3/AC-4 into a separate PR.

    Open questions (need user confirmation before /exec)

    1. Is AC-1 human-in-the-loop? Recommended: yes. /exec can't usefully gate on corruption in its own stdout.
    2. Does the PTY harness belong in this PR or its own issue? Defer until after AC-2.
    3. Is needs-repro label OK to add?

    Non-goals (from issue body)

    Workflow

    /exec 655 → /qa 655. Quality loop auto-enabled. No testgen / no browser test / no security-review. Existing feature/655-… worktree is ready.

  3. added
    planned
    on May 16, 2026
  4. admarble commented on May 16, 2026

    @admarble
    ContributorAuthor

    /exec: AC-D1 path (no reproduction; awaiting real-run trace)

    Per spec phase 1 (synthetic first), /exec confirmed the #647 scrollback harness does not reproduce Symptom A and added one further lock-in test against the motivating issue's exact complete→failed event sequence. Per spec phase 2 (static analysis), every stdout writer reachable from npx sequant run … -q was audited; the renderer owns stdout end-to-end (phase-executor:675 is verbose-gated, heartbeat is NonTTY-only, no global handlers write). The forensic byte math therefore implicates terminal-emulator behavior, a missed writer, or a measurement artifact — discriminating between these requires AC-1 evidence from a real corrupted run, which /exec cannot drive autonomously.

    AC coverage

    AC Status Evidence
    AC-1 🔄 Deferred HITL real-run capture required; instrumentation in place
    AC-2 🔄 Deferred Requires AC-1
    AC-3 🔄 Deferred Requires AC-2
    AC-4 🔄 Deferred Requires AC-2
    AC-D1 ✅ Implemented Negative-result write-up + synthetic lock-in test
    AC-D2 ⏭️ N/A Conditional on AC-2 path

    Files changed

    • docs/incidents/655/negative-result.md (new) — static-analysis audit, what was tried, capture instructions
    • src/lib/cli-ui/scrollback-harness.test.ts — added complete→failed overlay-detector test

    Checks

    • npm test -- --run src/lib/cli-ui/ — 92 passed, 1 skipped
    • npm run build — clean
    • npm run lint — clean

    PR

    #657 — opens against main. Satisfies AC-D1 only; #655 should remain open until a real-run trace lands.

    Recommended next step (HITL)

    SEQUANT_DEBUG_RENDERER=1 \
      script -q docs/incidents/655/captures/$(date +%F)/terminal.typescript \
      npx sequant run <issues> -q \
      2> docs/incidents/655/captures/$(date +%F)/debug.jsonl

    Run against a scenario known to produce Symptom A. Commit both artifacts and re-invoke /spec 655 or /exec 655 to advance from AC-1.

    Quality Plan Alignment

    N/A — No quality plan in issue (/spec did not emit a Feature Quality Planning section; spec is a 4-phase plan with derived ACs).

  5. admarble commented on May 16, 2026

    @admarble
    ContributorAuthor

    QA Review for Issue #655 (AC-D1 partial scope)

    This PR (#657) implements only AC-D1 (negative-result path). AC-1..4 remain deferred per the spec phase's decision branch (AC-1 doesn't reproduce → AC-D1 path), pending HITL real-run capture. The issue should remain open.

    AC Coverage

    AC Source Description Status Notes
    AC-1 Original Capture SEQUANT_DEBUG_RENDERER=1 trace from a corrupted run DEFERRED HITL-only; instrumentation in place at run-renderer.ts:557-606; capture instructions in docs/incidents/655/negative-result.md §"How to capture AC-1"
    AC-2 Original Identify responsible code path with byte-level evidence DEFERRED Requires AC-1
    AC-3 Original Regression test fails on main, passes after fix DEFERRED Requires AC-2 mechanism to know which harness shape to write
    AC-4 Original Ship a targeted fix (not defensive cleanup) DEFERRED Requires AC-2
    AC-D1 Derived If reproduction fails, commit docs/incidents/655/negative-result.md and leave instrumentation in place MET Doc committed; instrumentation unchanged; lock-in test added
    AC-D2 Derived Audit logUpdateClear callsites if AC-2 implicates them N/A Conditional on AC-2 path

    Coverage: 1/1 in-scope AC met (AC-D1). Out-of-scope ACs explicitly deferred per spec decision matrix — not blockers for this PR.


    CI Status

    Check State Conclusion
    build (20.x) completed ✅ pass
    build (22.x) completed ✅ pass
    typecheck completed ✅ pass
    validate-plugin completed ✅ pass
    validate-skills completed ✅ pass

    All checks green.


    Quality Metrics

    Metric Value Status
    Type issues (any) 0 OK
    Deleted tests 0 OK
    Files changed 2 (1 docs + 1 test) OK
    Lines added +161 OK
    Lines deleted 0 OK
    Production code touched None OK

    Test Coverage Analysis

    The PR adds tests but does not change production code. The new lock-in test:

    • src/lib/cli-ui/scrollback-harness.test.ts — adds "#655 negative-result lock-in: complete→failed event sequence does not produce an overlay row"
    • Local run: npx vitest run src/lib/cli-ui/scrollback-harness.test.ts → 5 passed, 1 skipped ✅

    Test asserts the overlay regex never appears in any synthetic harness row (scrollback + visible) when driving the motivating issue's exact complete→failed loop event sequence at a 100-col stream × 80-col physical mismatch with a pause/resume cycle between events.

    Coverage: N/A — no production code added; test locks in the negative-result invariant for future regression detection.


    Code Review

    Strengths:

    • Scope discipline: zero production code changes, matching the issue body's explicit anti-goal of "defensive renderer refactors that aren't motivated by reproduced evidence."
    • Lock-in test design is clean: drives the issue's literal motivating sequence (complete-loop then failed-loop for the same #505) through the existing fix(cli): #624's duplicate-header fix doesn't catch real log-update/scrollback bug (v2.3.0 regression confirmed) #647 harness, including the pause/resume cycle that mimics verbose subprocess streaming. The overlay-detector assertion (✔ AND "Claude Code returned" on a single row) is well-anchored to the issue's forensic byte math.
    • The negative-result doc is well-structured: TL;DR, what-was-tried table, ruled-out reconfirmation, what-couldn't-be-established, and explicit AC-1 capture instructions. Future-investigator-friendly.
    • Cited line ranges in the doc are accurate against the current source (run-renderer.ts:131-132, run-renderer.ts:557-606, run-renderer.ts:664-676, phase-executor.ts:675).

    Issues:

    1. Minor precision gap — "heartbeat is NonTTY-mode only" is inaccurate. The doc's static-analysis table (line 34) and TL;DR (line 10) characterize LivenessHeartbeat as "NonTTY-mode only," but the actual wiring in src/commands/run-progress.ts:46-49 is quiet && !tuiEnabled — i.e. -q mode (which may be TTY or non-TTY). The substantive claim (heartbeat is not a competing stdout writer when the renderer is the active path) still holds because heartbeat and renderer are mutually exclusive in run-progress.ts, but the mode characterization should read "quiet-mode only" not "NonTTY-mode only." Worth one-line fix in the doc so the next investigator isn't confused.

    2. Open contradiction in the static analysis worth surfacing. The issue body claims "the motivating transcript was -q (quiet) mode." But appendEventLine (which produces the ✔/✘/▸ glyphs in the corrupted transcript) is a TTYRenderer method, and the renderer is not wired in quiet mode (run-progress.ts:59-60 constructs the renderer only when !quiet). Either (a) the original transcript was actually default mode, not -q, or (b) the wiring has changed since feat(cli): unified run renderer — two-zone live grid + events #618 introduced the renderer, or (c) the heartbeat path produces something that looks like renderer output. The negative-result doc doesn't acknowledge this contradiction. The AC-1 capture in -q mode against current wiring would not exercise appendEventLine at all — so the AC-1 capture instructions in the doc should clarify which mode is intended. Recommendation: add a sentence to the doc noting this discrepancy so the HITL capture is run in the correct mode.

    Suggestions:

    • In the test, harness.stdoutWrite(" [verbose] streamed line between events\n") simulates verbose subprocess streaming, but in production the verbose write goes through process.stdout.write(chalk.gray(text)) at phase-executor.ts:675. The direct harness.stdoutWrite exercises the VT but bypasses the chalk wrapping. This is acceptable for a pause/resume cycle exerciser, but worth a one-line comment noting the simplification.

    Anti-Pattern Detection

    N/A — only docs and a test file changed.


    CHANGELOG Verification

    Check Status
    CHANGELOG.md exists ✅ Yes
    [Unreleased] section present ✅ Yes
    docs(#655): commit triggers the gate ⚠️ Yes (conventional-commit prefix matches)
    Entry for #655 in [Unreleased] ❌ Not present

    Note: The §10a gate fires because the commit is conventional-commit-prefixed (docs(...)). However, the content is internal investigation documentation (docs/incidents/...) plus a lock-in test — not user-facing behavior. Existing [Unreleased] entries are feature-level (Typed workflow event system, Phase definitions consolidated). Reviewer call: either skip (incident docs aren't user-visible) or add a one-line Documentation subsection entry like - #655 incident investigation: documented negative-result for synthetic Symptom A reproduction (#657).


    Risk Assessment

    • Likely failure mode: None for this PR — no production code changes. The risk this PR carries forward is that the negative-result doc, if read in isolation, could mislead the next investigator into running the AC-1 capture in the wrong mode (see Issue docs: Add pre-release checklist #2 above). The fix is a one-line clarification in the doc.
    • Not tested: The lock-in test only exercises the synthetic harness; it cannot reproduce Symptom A by construction (that's the whole point — Symptom A is not reachable synthetically). The "regression detection" value of the test is real but narrow: it catches future renderer changes that would make Symptom A synthetically reachable, not the real cause.
    • Sibling sites considered: N/A — cross-file sibling-site scan does not apply (this is documentation + a single test addition, no production root-cause pattern to scan for).
    • Sibling-line audit: N/A — no production code modified.

    Adversarial Re-Read

    Findings:

    1. Motivating-example fixture check: The issue body's literal motivating transcript (✔ #5loop Claude Code returned an error result: ETIMEDOUT) is the exact pattern the lock-in test's overlay detector asserts against. The test's harness.vt.scrollback + getVisibleLines() is run through the verbatim complete loop → failed loop sequence on issue arch: phase plugin registry — user-extensible workflow phases #505 at the configured width mismatch. The detector regex matches against ✔ and "Claude Code returned" substrings — both present in the issue's literal example. Fixture wired correctly.

    2. Evidence vs. claim audit: The doc presents a negative result honestly. It does not claim AC-1..4 are met — it explicitly defers them with a "Deferred" status and provides capture instructions for the next iteration. No "post-fix validation" claims are made because no fix is shipped. This is the correct posture for the AC-D1 path.

    3. Process state: Branch is clean (git status empty), 1 commit ahead of origin/main, no uncommitted work. Tests pass locally and in CI.

    4. Sibling sites: N/A as noted above. No code patterns to scan.

    5. Non-Goals check: Issue body's two Non-Goals are "Defensive renderer refactors that aren't motivated by reproduced evidence" and "the pause/resume dead-code bug — filed separately." Neither is violated — this PR adds zero defensive cleanup and does not touch pause/resume wiring.

    Gaps surfaced (non-blocking):

    Status: Gaps Found (non-blocking — both are doc precision fixes, not load-bearing logic errors)


    Verdict: AC_MET_BUT_NOT_A_PLUS

    AC-D1 is fully met: negative-result doc committed, instrumentation unchanged, no speculative fix, regression-detection lock-in test added and passing. AC-1..4 are explicitly deferred per the spec's decision matrix and are appropriate for follow-up HITL work — they do not block this PR.

    The verdict is not READY_FOR_MERGE because of two non-blocking doc precision gaps:

    1. The "heartbeat is NonTTY-mode only" mischaracterization in the static-analysis table.
    2. The unacknowledged contradiction between the issue body's -q-mode claim and the renderer being unwired in quiet mode — material for the next investigator's AC-1 capture.

    These are 1-2 line fixes to docs/incidents/655/negative-result.md. Either fix-and-merge, or merge-and-fix-in-followup.

    Documentation

    • N/A — bin/cli.ts unchanged, no new user-facing flags or commands
    • CHANGELOG: see §"CHANGELOG Verification" above — reviewer judgment call (incident docs are not user-facing in the typical CHANGELOG sense)

    Next Steps

    1. Recommended: apply two one-line fixes to docs/incidents/655/negative-result.md:
      • Replace "NonTTY-mode only" → "quiet-mode only (mutually exclusive with renderer; see run-progress.ts:46-49)"
      • Add one sentence in §"How to capture AC-1" noting that the renderer is not wired in -q mode, so AC-1 capture should be run in default (non-quiet) mode unless the original transcript's mode is reconfirmed.
    2. Follow-up (HITL): Run SEQUANT_DEBUG_RENDERER=1 script -q artifact/terminal.typescript npx sequant run ... 2> artifact/debug.jsonl against a Symptom A-producing scenario; commit captures under docs/incidents/655/captures/<date>/ and re-invoke /spec 655 or /exec 655 to advance from AC-1.
    3. Issue lifecycle: Issue investigate(cli): #652 renderer corruption — column-mismatch hypothesis refuted, real cause unknown #655 should remain OPEN after PR docs(#655): AC-D1 negative result — synthetic harness does not reproduce #657 merges (only AC-D1 closed; AC-1..4 pending real-run trace).
  6. added
    needs-improvement
    and removed
    planned
    on May 16, 2026
  7. added a commit that references this issue on May 16, 2026
  8. admarble commented on May 16, 2026

    @admarble
    ContributorAuthor

    /exec: applied QA doc precision fixes (PR #657 follow-up commit)

    QA review returned AC_MET_BUT_NOT_A_PLUS with two non-blocking doc precision gaps. Per "fix-and-merge vs. merge-and-fix-in-followup", took the fix-and-merge path and pushed ba35122 to PR #657. AC-D1 status is unchanged; AC-1..4 remain deferred awaiting HITL real-run capture.

    What changed

    Fix Site Status
    QA #1: LivenessHeartbeat row "NonTTY-mode only" → corrected to "quiet-mode only" with run-progress.ts:46-49 reference docs/incidents/655/negative-result.md table ✅ Applied
    QA #2: §"How to capture AC-1" now leads with a mode-discrepancy callout (renderer not wired in -q; original transcript's mode label is suspect) and the example command drops -q docs/incidents/655/negative-result.md capture section ✅ Applied
    Bonus consistency fix: TTYRenderer.stdoutWrite row in the same table also had the inverse error ("Yes, sole intended writer" for -q — but the renderer isn't wired in -q). Corrected to "No in -q — sole writer in default mode and emits all ✔/✘/▸ glyphs" docs/incidents/655/negative-result.md table ✅ Applied

    Additional finding worth recording

    LivenessHeartbeat writes ▸ #N phase (elapsed, …) heartbeat lines to stdout but never ✔/✘/▸ #N phase event glyphs. This means the ✔ in the corrupted transcript can only come from TTYRenderer. The renderer is mutually exclusive with -q mode in current wiring (run-progress.ts:59-60). One of: (a) original transcript was default mode, not -q; (b) wiring changed since capture; (c) original mode label is wrong. The next HITL capture should re-confirm mode before running.

    AC coverage (unchanged from prior /exec)

    AC Status
    AC-1..4 🔄 Deferred (HITL real-run capture required)
    AC-D1 ✅ Met (negative-result write-up + lock-in test)
    AC-D2 ⏭️ N/A (conditional on AC-2)

    Checks

    • No production code or test changes; CI just re-dispatched on the doc-only push (PR status: MERGEABLE, awaiting fresh check results).
    • Build/lint/test not re-run locally — markdown-only diff.

    PR

    #657 — head now at ba35122. Ready for re-merge once new CI completes.

    Files changed in this iteration

    • docs/incidents/655/negative-result.md (+9 / -7)

    Quality Plan Alignment

    N/A — no quality plan in spec.

    Next steps

    1. Wait for new CI on ba35122 to go green (expected — markdown-only change against the same green baseline).
    2. Merge PR docs(#655): AC-D1 negative result — synthetic harness does not reproduce #657. Keep issue investigate(cli): #652 renderer corruption — column-mismatch hypothesis refuted, real cause unknown #655 OPEN (AC-1..4 still deferred).
    3. Follow-up (HITL): run the corrected capture command (default mode, no -q) against a Symptom A-producing scenario; commit terminal.typescript + debug.jsonl under docs/incidents/655/captures/<date>/; re-invoke /spec 655 or /exec 655.
  9. admarble commented on May 17, 2026

    @admarble
    ContributorAuthor

    QA Review for Issue #655 (Simple Fix — doc precision follow-up to prior QA)

    Re-QA of commit ba35122 against prior QA verdict at d57dd20 (AC_MET_BUT_NOT_A_PLUS with two doc-precision gaps recommended).

    Size Gate

    Check Value
    Diff size 16 lines (9+/7−) in 1 file (threshold: 100)
    package.json changed No
    Security-sensitive paths No
    Decision Inline checks (Simple Fix mode)

    AC Coverage (unchanged from prior QA)

    AC Status Notes
    AC-1..4 DEFERRED HITL real-run capture required; no change
    AC-D1 MET Negative-result doc + lock-in test still present
    AC-D2 N/A Conditional on AC-2

    Coverage: 1/1 in-scope AC met. No regression.


    QA Fix Verification

    Prior QA recommended two fixes. Verification of each:

    Prior QA Gap Fix Applied Verification
    #1: LivenessHeartbeat row says "NonTTY-mode only" — actual gating is quiet && !tuiEnabled Row corrected to "sole stdout writer in -q mode (see run-progress.ts:46-49)... never ✔/✘" ✅ run-progress.ts:46-49 reads quiet && !tuiEnabled ? new LivenessHeartbeat(...) : null — match. heartbeat.ts:226 only emits ▸ glyph, never ✔/✘ — match.
    #2: §"How to capture AC-1" doesn't acknowledge renderer-not-wired-in--q contradiction Section now leads with a blockquote callout enumerating possibilities (a/b/c) and the example command drops -q ✅ run-progress.ts:59-60 reads !tuiEnabled && !quiet ? createRunRenderer(...) : null — confirms renderer is NOT wired in -q. Callout is accurate.
    Bonus self-found fix: renderer row had inverse error ("Yes, sole intended writer" for -q) Row corrected to "No in -q — sole writer in default mode" ✅ Consistent with the gating verified above.

    Both prior gaps substantively addressed; bonus consistency fix is correct.


    Quality Metrics

    Metric Value Status
    Type issues (any) 0 OK
    Deleted tests 0 OK
    Files changed 1 (docs only) OK
    Lines added +9 -
    Lines deleted -7 -
    Production code touched None OK

    Code Review

    Strengths:

    • Targeted fix — only the doc file changed, no production code or test churn.
    • Self-found the inverse error in the renderer row (good adversarial pass).
    • The new blockquote callout in §"How to capture AC-1" is high signal for the next investigator: enumerates the three possible resolutions of the mode-discrepancy and instructs to re-confirm the original transcript's mode before capture.
    • Heartbeat-glyph claim is precise: "writes only ▸ #N phase (elapsed, …) heartbeat lines, never ✔/✘" — verified at heartbeat.ts:225-226.
    • Line references all check out against current source (heartbeat.ts:100, :226, run-progress.ts:46-49, run-progress.ts:59-60).

    Issues:

    1. Residual sibling-prose: TL;DR (line 10) still says "the renderer is the sole stdout writer in non-verbose mode." The corrected §2 table now establishes that in -q mode (which IS non-verbose), the heartbeat — not the renderer — is the sole writer. The TL;DR's framing therefore contradicts the corrected analysis directly below it. A future reader skimming the TL;DR could conclude the renderer writes in -q mode, which is exactly the false claim the commit was meant to retire from the doc. Worth a one-line edit:

      • confirms the renderer is the sole stdout writer in non-verbose mode. → confirms there is no second stdout writer in either run mode (renderer in default, heartbeat in -q).

      This is the feedback_sibling_scan_includes_prose.md / feedback_grep_as_checklist.md pattern: after a substantive correction, grep for the old framing to verify it's fully retired across the file. The substantive correction here was thorough in §2 and §"How to capture AC-1", but the TL;DR was missed.

    Suggestions:

    • None beyond the above.

    Test Coverage Analysis

    Changed File Tier Has Tests? Test File
    docs/incidents/655/negative-result.md Optional (docs) N/A -

    Coverage: N/A — docs-only change.


    Anti-Pattern Detection

    N/A — no code changed.


    CI Status (PR #657 at ba35122)

    Check State Bucket Impact
    build (20.x) SUCCESS pass ✅ MET
    build (22.x) SUCCESS pass ✅ MET
    typecheck SUCCESS pass ✅ MET
    validate-plugin SUCCESS pass ✅ MET
    validate-skills SUCCESS pass ✅ MET

    CI Summary: 5 passed, 0 pending, 0 failed.


    Risk Assessment

    • Likely failure mode: None for this PR. Worst-case is the residual TL;DR-vs-table inconsistency misleading a skimming reader, but the §2 table and §"How to capture AC-1" callout are authoritative and will be read before any HITL capture.
    • Not tested: N/A — docs-only.
    • Sibling sites considered: Yes — checked the doc for other occurrences of the "renderer is the sole writer" framing. Found one residual at line 10 (TL;DR), flagged above as Issue feat: Complete remaining v1.0 features (AC-10, AC-13, AC-14) #1. No other surviving instances of the corrected claim.
    • Sibling-line audit: N/A — no code modified.

    Verdict: AC_MET_BUT_NOT_A_PLUS

    Both prior QA gaps were substantively addressed with verified-correct edits; bonus consistency fix is right. The PR is mergeable.

    Verdict is not READY_FOR_MERGE because of one residual sibling-prose gap: TL;DR line 10 still says "the renderer is the sole stdout writer in non-verbose mode," which contradicts the corrected §2 table (in -q mode, heartbeat is the writer). This is the same class of bug the commit was meant to fix, just at a different site in the same file. One-line fix.

    Reviewer call: either fix-and-merge (one-line edit to line 10) or merge-and-fix-in-followup. Given this is the second iteration of "doc precision" gaps on the same file, fix-and-merge is preferred to avoid a third round.

    Documentation

    • N/A — incident docs only, no user-facing flag or behavior change.

    Next Steps

    1. Recommended: apply the one-line TL;DR fix above (line 10 of docs/incidents/655/negative-result.md).
    2. Merge PR docs(#655): AC-D1 negative result — synthetic harness does not reproduce #657. Keep issue investigate(cli): #652 renderer corruption — column-mismatch hypothesis refuted, real cause unknown #655 OPEN — AC-1..4 still deferred awaiting HITL real-run capture in default mode (per the now-corrected §"How to capture AC-1").
    3. Follow-up (HITL, unchanged from prior QA): run the corrected capture command against a Symptom A-producing scenario; commit captures under docs/incidents/655/captures/<date>/; re-invoke /spec 655 or /exec 655 to advance from AC-1.
  10. removed
    needs-improvement
    on May 17, 2026
  11. admarble commented on May 17, 2026

    @admarble
    ContributorAuthor

    HITL capture checklist — unblocks both #647 (Mechanism #1 + AC-1 replay) and #655 (AC-1..2)

    PR #653 shipped SEQUANT_DEBUG_RENDERER=1. PR #657 confirmed the synthetic harness cannot reproduce Symptom A. Both issues' remaining ACs are now blocked on the same artifact.

    Capture command:

    DAY=$(date +%Y-%m-%d)
    DIR=docs/incidents/655/captures/$DAY
    mkdir -p $DIR
    SEQUANT_DEBUG_RENDERER=1 script -q $DIR/terminal.typescript \
      npx sequant run <issue-pair> -q \
      2> $DIR/debug.jsonl

    Target scenarios (try in order until a symptom fires):

    1. Parallel pair where one issue retries — mirrors the arch: typed workflow event system for decoupled progress, logging, and MCP streaming #504/arch: phase plugin registry — user-extensible workflow phases #505 motivating transcript.
    2. Same pair with terminal resized mid-run (SIGWINCH stress).
    3. Single issue with forced loop iterations.

    Artifacts to commit:

    • terminal.typescript — raw byte stream from script
    • debug.jsonl — instrumentation log
    • notes.md — terminal app, $COLUMNS × $LINES, Node version, which symptom fired

    What each unblocks:

    Symptom captured Unblocks
    SEQUANT WORKFLOW · … ≥2× in scrollback #647 Mechanism #1; un-skip AC-2 scaffold; AC-3 follow-up fix
    ✔ #5loop / mid-string char drop / U+FFFD overlay #655 AC-2 (mechanism), AC-3 (harness), AC-4 (fix)
    Both Shared root cause; bundle the fix
    Neither Add scenario to "non-reproducing conditions" in #647 AC-1; iterate

    Sanity before /assess:

    • wc -l debug.jsonl ≥ ~10
    • jq -s 'group_by(.callsite) | map({callsite: .[0].callsite, count: length})' debug.jsonl
    • Eyeball terminal.typescript for the symptom

    Do NOT rerun /fullsolve on either issue until a capture lands — autonomous loops without new evidence will reproduce the negative-result deferral pattern (#657) or relitigate static analysis. The blocker is real-terminal evidence; once debug.jsonl is committed, /assess and /fullsolve become productive again because byte-level mechanism ID moves into scope.

  12. added 2 commits that reference this issue on May 17, 2026
  13. admarble commented on May 17, 2026

    @admarble
    ContributorAuthor

    Update — -q flag finding changes the interpretation, not the static analysis

    Live run of npx sequant run 656 -q in a separate session showed renderer output (table grid + SEQUANT WORKFLOW · #N · …elapsed). That text is only emitted by run-renderer.ts:929/955/995, gated behind !quiet.

    Root cause: -q is the short form for --quality-loop, not --quiet (bin/cli.ts:234 vs :250). Filed as #658.

    What this changes for #655:

    The static analysis in docs/incidents/655/negative-result.md is correct in the abstract — default mode → renderer, --quiet mode → heartbeat, mutually exclusive. What changes is the interpretation of the motivating transcript: every "in -q mode" reference in #647/#652/#654/#655 was actually renderer mode, because -q doesn't set quiet=true. The corruption symptoms (✔ #5loop, U+FFFD overlay) were produced by the renderer, not the heartbeat.

    Practical consequence: #647's Mechanism #1 hypothesis (scrollback erasure from event-line scrolling with renderer active) is the right hypothesis after all. The detour through "heartbeat is the writer" was based on a wrong premise about what -q does.

    Recommended doc amendment in a follow-up commit:

    1. Drop the "re-confirm the original transcript's mode" callout in §"How to capture AC-1" — we now know it was renderer mode.
    2. The capture command for renderer evidence is npx sequant run … (default — no flag) or npx sequant run … -q (current -q happens to enable renderer + quality-loop, which is fine for renderer evidence).
    3. For heartbeat baseline: npx sequant run … --quiet (long form).

    AC-1 evidence already in hand: the live scrollback from the running -q session shows two SEQUANT WORKFLOW · #656 · …elapsed headers — Mechanism #1 reproducing. Saving under docs/incidents/647/captures/2026-05-17/ is the first concrete AC-1 artifact for #647.

  14. added a commit that references this issue on May 17, 2026
  15. admarble commented on May 18, 2026

    @admarble
    ContributorAuthor

    Cross-reference — #647's #663 finding may be the unified suspect

    PR #663 (merged 2026-05-18) closed the diagnosis loop on #647 with a finding that's directly relevant here:

    The underlying bug behind #647 Mechanism #1 is Mechanism #2-class: any out-of-band writer that touches the same pty as process.stdout breaks log-update's cursor model. Forensic VT replay showed log-update's eraseLines(previousLineCount) undershoots after out-of-band writes because previousLineCount only tracks log-update's own writes — anything that scrolls the terminal externally (stderr instrumentation, subprocess output landing outside a paused window, future feature) leaves the cursor at an unknown offset.

    Why this is interesting for #655 Symptom A

    The complete[0:8] + failed[9:] byte math has always required something to position the cursor mid-row of the previously-written complete line before the failed line writes. Mechanism #2 supplies a candidate:

    1. appendEventLine (complete): logUpdateClear() → writes complete line via stdoutWrite → redraw() writes live zone. Cursor at end-of-frame.
    2. Out-of-band write happens (subprocess output in non-quiet renderer mode — see the 2026-05-17 finding above that the motivating transcripts were renderer mode, not --quiet).
    3. Cursor is now somewhere log-update doesn't know about.
    4. appendEventLine (failed): logUpdateClear() issues eraseLines(previousLineCount) going UP from the wrong cursor — lands the cursor mid-row of the prior complete line (col 8 if the geometry works out).
    5. Failed line text writes starting at col 8 → complete[0:8] + failed[9:].

    This is consistent with the byte math, but not yet proven for #655. Mechanism #1 (scrollback duplication) and Symptom A (mid-row overlay) would share a root cause — Mechanism #2 — if confirmed.

    Cheapest discriminator: the HITL capture already queued for #647

    The clean-baseline capture I asked for in #647 (run npx sequant run X Y parallel, default mode, WITHOUT SEQUANT_DEBUG_RENDERER=1, save scrollback) is also the cheapest #655 reproducer. If that capture shows:

    Synthetic harness status

    The #655 negative-result lock-in test in scrollback-harness.test.ts (preserved through PR #663) still passes — synthetic doesn't reproduce Symptom A. That's expected: the synthetic harness models a clean pty without subprocess output interleaving. If the HITL capture confirms Mechanism #2 for #655 too, a fuller harness with subprocess-output simulation would be needed for a regression test (extending the stderrWrite pattern PR #663 added).

    Suggested status

    Keep #655 open until the HITL capture lands. If the unified-suspect hypothesis is confirmed, the AC-3 fix iteration on #647 should bundle #655 (same fix). If not, #655 needs independent diagnosis using the leftover options from this issue's "Possible next steps" section (PTY-based harness, static analysis of all stdout writers).

  16. admarble commented on May 20, 2026

    @admarble
    ContributorAuthor

    Capture task spun out → #668

    The 2026-05-17 HITL capture in this issue is no longer diagnostic — both wire-amplifiers it captured have since been removed:

    A fresh capture is needed to isolate Symptom A from the eliminated noise. Tracked separately in #668 so the capture is a discrete unit of work that can be assigned/scheduled independently of this investigation's analysis ACs.

    This issue stays open as the investigation parent. Once #668 lands a capture, AC-1..4 here become actionable.

  17. admarble commented on May 30, 2026

    @admarble
    ContributorAuthor

    Capture landed (#668) — renderer exonerated with byte-level evidence

    A real HITL capture was run from matcha-maps (sequant run 593 627) on two terminal emulators — a stale long-running VS Code integrated terminal and a freshly-opened iTerm2. Artifacts + full notes.md: docs/incidents/655/captures/2026-05-28/ (PR incoming).

    Findings

    script records exactly the bytes sequant wrote to the pty. Both captures are clean:

    Metric vscode iterm2
    U+FFFD (�) in stream 0 0
    coatcha / (no commi─ overlay in stream 0 0
    whole-file UTF-8 validity valid valid
    ESC[?2026h/l sync pairs 500/500 224/224

    Renderer self-instrumentation is internally consistent on every frame:

    Metric vscode iterm2
    frames 503 228
    rendererCols != stdoutCols 0 0
    logicalLines > rendererRows 0 0

    Conclusion

    sequant's renderer is not corrupting output. It emitted clean, valid, column-correct, atomically sync-framed bytes on two independent emulators. The corruption is downstream of the byte stream, from two distinct causes that both leave script clean:

    1. Stale terminal-emulator paint (VS Code, not restarted in a long time) — correct bytes mis-painted on screen; an environmental defect, not a code bug.
    2. Clipboard flattening of an in-place TUI (the iTerm2 (no commi───┐ fragment came from pasting scrollback of a redraw-in-place UI — 5927 cursor-ups in that capture — not a live glitch).

    This refutes the issue's core premise. Column-mismatch was already refuted (#654/#657); the renderer-emits-bad-bytes hypothesis is now refuted too, with evidence.

    Disposition

  18. added a commit that references this issue on May 30, 2026
  19. admarble commented on May 30, 2026

    @admarble
    ContributorAuthor

    Closing as environmental — renderer exonerated with byte-level evidence

    Per the disposition above and the merged capture (PR #673, artifacts under docs/incidents/655/captures/2026-05-28/), closing this as an environmental terminal-emulator defect, not a sequant code bug.

    Why

    script records exactly the bytes sequant wrote to the pty. Across two independent emulators (stale long-running VS Code xterm.js + freshly-opened iTerm2), the byte stream was conclusively clean — independently re-verified during QA of #673:

    • 0 U+FFFD and 0 (no commi─ / coatcha overlay fragments in either stream
    • whole-file UTF-8 valid on both
    • ESC[?2026h/l sync pairs balanced (500/500 vscode, 224/224 iterm2)
    • renderer self-instrumentation internally consistent on every frame (503 / 228): 0 rendererCols != stdoutCols, 0 logicalLines > rendererRows

    The on-screen corruption is downstream of the clean bytes — (1) stale VS Code paint state on a long-uptime integrated terminal, and (2) clipboard flattening of an in-place-redrawing TUI. Both leave script clean. This refutes the issue's core premise; the column-mismatch hypothesis was already refuted (#654/#657), and the renderer-emits-bad-bytes hypothesis is now refuted too.

    The original ACs (identify the code path, regression test, ship a targeted fix) were premised on a renderer code defect that the evidence shows does not exist, so they are moot.

    Follow-up

  20. added 3 commits that reference this issue on Sep 9, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugclicomplex

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions