Repository navigation
Description
Context
#624 / PR #627 was meant to eliminate the duplicate SEQUANT WORKFLOW · … header rendering that surfaced in npx sequant run 608 604 -q on 2026-05-10. v2.3.0 shipped with the fix, but a real npx sequant run 504 505 -q run on 2026-05-14 (v2.3.0 confirmed) still produces the exact same symptom.
Motivating transcript (this is the required test fixture)
(base) tony@Tambras-MacBook-Air sequant % npx sequant run 504 505 -q
SEQUANT WORKFLOW
Stack generic
Phases auto-detect from labels
Mode parallel (concurrency: 3)
Quality loop enabled (max 3 iterations)
Logging JSON
State enabled
Issues #504, #505
Worktree isolation: enabled
Base branch: main
SEQUANT WORKFLOW · 2 issues · 0s
┌──────────┬─────────────────────────────────────────────────────────────────────────────────────────────────┐
▸ #504 spec
▸ #505 spec
✔ #504 spec 3m 52s
▸ #504 exec
✔ #505 spec 4m 22s
▸ #505 exec
✔ #504 exec 13m 40s
▸ #504 qa
✔ #505 exec 16m 45s
▸ #505 qa
✔ #504 qa 4m 53s
SEQUANT WORKFLOW · 2 issues · 22m 33s
✘ #505 qa QA verdict: AC_MET_BUT_NOT_A_PLUS
▸ #505 loop
✔ #5loop Claude Code returned an error result: You're out of extra usage · resets 11pm (America/Chicago)
▸ #505 exec (attempt 3/3)
SEQUANT WORKFLOW · 2 issues · 33m 47s
✘ #505 exec (attempt 3/3) Claude Code returned an error result: You're out of extra usage · resets 11pm (America/Chicago)
→ #504 PR #643 https://github.com/sequant-io/sequant/pull/643
SUMMARY · 2 issues · 56m 5s · 1 passed · 1 failed
Three SEQUANT WORKFLOW · 2 issues · Xs lines (0s, 22m 33s, 33m 47s) appear in scrollback — same symptom #624 §1 was meant to fix. Also a separate row of corruption (✔ #5loop, ├───────� │) suggesting #624 §2 is also not fully resolved — see §3 below for independent-diagnosis requirement.
Run log: .sequant/logs/run-2026-05-14T03-16-47-1c43f889-6e0f-46fa-a892-3041227b8704.json
Version confirmed: npx sequant --version → 2.3.0
Why #624's fix didn't catch it (false-green tests)
PR #627 added TTYRenderer.getTestStub() (src/lib/cli-ui/run-renderer.ts:600) which exposes replacementCount / lastFrame / clearCalls. In test mode (when options.stdoutWrite is injected), logUpdateClear / logUpdateImpl / logUpdateDone are stubbed (run-renderer.ts:572-584):
this.logUpdateImpl = (text) => { if (stub.lastFrame) stub.replacementCount++; stub.lastFrame = text; options.stdoutWrite!(text + "\n"); };
this.logUpdateClear = () => { stub.clearCalls++; stub.lastFrame = ""; };The stubs DO NOT model real log-update's ANSI cursor manipulation. They just record the last frame text and increment counters.
AC-1.2 and AC-1.3 in run-renderer-624.test.ts:200-252 assert on stub.lastFrame.match(/SEQUANT WORKFLOW ·/g).length === 1 — i.e. the most recently generated frame contains exactly one header. That assertion is trivially true: the renderer only ever generates one header per frame. It does not verify that previously-rendered frames are actually erased from the terminal scrollback.
What the #627 fix actually does
clampFrameHeight (run-renderer.ts:814) caps the produced frame at max(8, rows - 5). That guards against log-update@7's internal fitToTerminalHeight clipping (which would invalidate diff state). But the duplicate-header bug isn't about frame height — a 2-issue frame is ~10 lines and never near any cap. It's about log-update.clear() not erasing rows that have already scrolled into the terminal's scrollback buffer.
Candidate mechanisms (NOT yet verified — see AC-1)
The transcript is consistent with several causes. Do not commit to a fix direction before AC-1 narrows this list:
- Scrollback erasure (initial hypothesis):
log-update@7usesansiEscapes.eraseLines(previousLineCount)(node_modules/log-update/index.js:231) which only operates on visible rows. When the live zone is pushed up by event-line writes and rows scroll off, subsequentclear()calls leave the top rows of the previous frame permanently in scrollback. - Child-process TTY writes: the worktree subprocess (
claudeviaphase-executor.ts) is spawned with shared TTY in some code paths. Direct writes from the child would invalidate log-update's cursor model. Need to verifystdioconfig across--quiet/-q. - SIGWINCH bursts: window-manager resize events trigger
redraw()(run-renderer.ts:614). A burst during the run could race withappendEventLine's clear→write→redraw sequence. process.stdout.rowsundefined undernpx: would causelog-update@7'sfitToTerminalHeightto clip at the 24-row default while the renderer thinks rows=100. For a 10-line frame this shouldn't matter, but worth confirming.- Hidden pause/resume path: a code path that mutates renderer state without bracketing
logUpdateClear()/logUpdateDone()properly.
Acceptance criteria
1. Diagnose before fixing — verified repro + production instrumentation
- Verified repro: reproduce the duplicate-header symptom locally (small 2-issue parallel run) outside the user's specific machine. If it doesn't reproduce on every run, document the conditions (column width, terminal, runtime,
-qvs no-q). - Frequency baseline: how often does the bug fire? Every parallel run? Only past N minutes / events? Only at certain widths? This bounds what the fix needs to handle.
- Production instrumentation pass: add (behind a
SEQUANT_DEBUG_RENDERER=1env flag) logging ofpreviousLineCount,clearCalls,previousWidth,process.stdout.rows,process.stdout.columns, and a monotonic frame counter at eachlogUpdateImpl/logUpdateClear/logUpdateDonecallsite. Replay the motivating scenario and capture which of the candidate mechanisms above is actually firing. - Pick the fix direction from §2 only after instrumentation confirms the mechanism.
2. Test harness that actually catches this regression
- Add an integration test that pipes the renderer into a real
log-updateinstance writing to a virtual terminal (e.g.xterm-headless,node-pty, or a hand-rolled vt100 buffer that distinguishes visible-vs-scrollback). - Replay the motivating transcript through that harness. Assert: total occurrences of
SEQUANT WORKFLOW ·invisibleBuffer + scrollbackis exactly 1. - Test must FAIL on
mainas of this issue's creation (i.e. reproduces the bug) before any fix code is written.
3. Fix the actual rendering bug
Pick one of these directions based on AC-1 instrumentation results. Cost/risk varies significantly:
-
A. Single-zone renderer (major rewrite): route event lines through the live zone itself (e.g. as a scrolling tail inside the frame). Eliminates the need to interleave
console.logwrites withlog-update. Touches feat(cli): unified run renderer — two-zone live grid + events #618 architecture. Treat as last resort if surgical fixes can't address the diagnosed mechanism. -
B.
(struck — does not help): I originally suggested this would atomically append + reset state. Re-readinglog-update.persist()on each eventnode_modules/log-update/index.js:242-254,persist()is justeraseLines(previousLineCount) + write + reset— same primitive asclear(), same scrollback constraint. Does NOT fix the scrollback hypothesis. -
C. Mechanism-targeted fix (surgical, depends on AC-1): once the actual mechanism is identified, apply the minimum-blast-radius fix. Examples per candidate:
- Mechanism feat: Complete remaining v1.0 features (AC-10, AC-13, AC-14) #1 → switch to a renderer pattern that never re-clears (e.g. only ever
persist()once + write fresh frame below), or downgrade to alog-updateversion with different semantics, or accept duplicate-header in scrollback and dedupe via a sentinel. - Mechanism docs: Add pre-release checklist #2 → audit
stdiofor all subprocess spawn sites under-q; ensurestdoutis piped not inherited. - Mechanism Doctor: Add Claude Code CLI check #3 → debounce SIGWINCH-driven redraws.
- Mechanism Doctor: Add GitHub CLI and auth checks #4 → trust renderer's
rowsOverridedefaults more aggressively; pass through tolog-updatevia itsdefaultHeightconstructor option.
- Mechanism feat: Complete remaining v1.0 features (AC-10, AC-13, AC-14) #1 → switch to a renderer pattern that never re-clears (e.g. only ever
-
Document chosen direction with rationale referencing AC-1 evidence.
-
Implementation passes the harness test from AC-2.
4. Bottom-of-output corruption — INDEPENDENT diagnosis required
The transcript also shows:
✔ #5loopwhere#505 loopshould be —05is missing mid-string. Not a clearing artifact; characters vanished from the middle of an event line. Possibly an overlay/overwrite, possibly a string-slicing bug. Not explained by any §3-candidate.├───────� │ 33m 41s │in the summary table — a separator row visually overlaid with a data row, U+FFFD replacement character in the middle. LikelyTTYRenderer.renderSummary(run-renderer.ts:704) teardown path leaving partial state.
These may or may not share a root cause with §1–§3.
- Reproduce each symptom independently before assuming shared cause with the duplicate-header issue.
- If a shared root cause is confirmed (e.g. same log-update state mismanagement), fix together.
- If independent, file a separate issue with full repro and link back here. Do not bundle into the §3 fix.
Out of scope
--experimental-tui(Ink) renderer — separate codepath.- Cross-session lock issues that contributed to arch: phase plugin registry — user-extensible workflow phases #505's exec failure — orthogonal.
- The
"You're out of extra usage"Claude Code error — orthogonal upstream issue.
Related
- Predecessor: feat(cli): run renderer follow-ups — frame stability, attempt counter, summary teardown (#618 follow-up) #624 (closed by feat(#624): run renderer follow-ups — frame stability, attempt counter, summary teardown, failure dedup #627, merged 2026-05-11)
- Original renderer: feat(cli): unified run renderer — two-zone live grid + events #618 (closed by feat(#618): unified run renderer — two-zone live grid + events log #620)
Changelog
- 2026-05-14: amended after self-critique. Reordered ACs to require diagnose-first (AC-1) before fix-direction commitment (AC-3). Struck Direction B (
logUpdate.persist()) — same primitive asclear(). Reframed §3 around the candidate-mechanism list. Split corruption into AC-4 with independent-diagnosis requirement.
Activity
admarble commentedon May 14, 2026
Complexity: Standard (4 ACs / ~12 sub-criteria, 1 directory)
AC Quality Check
ACs are unusually well-written for a bug regression — issue body already enforces diagnose-before-fix, names a verbatim fixture, and explicitly strikes one candidate fix direction (B). One soft flag:
No vague/unmeasurable/title-body-tension findings.
Scope Assessment
Non-Goals (parsed):
--experimental-tui(Ink) renderersrc/lib/cli-ui/)Verdict: ✅ SCOPE_OK
Caveat — AC-4 could split into a separate issue per its own instructions. If AC-4 diagnosis lands on "independent root cause," scope splits naturally; this is by design.
Acceptance Criteria
AC-1: Diagnose before fixing — verified repro + production instrumentation
Verification: Manual Test (repro + frequency) + Unit Test (instrumentation toggle is gated on
SEQUANT_DEBUG_RENDERER=1)Scenario: Given a fresh checkout with
SEQUANT_DEBUG_RENDERER=1exported → When runningnpx sequant run <pair> -qat the motivating terminal dimensions → Then a debug log file or stderr stream emits per-call records of{frameCounter, previousLineCount, clearCalls, previousWidth, stdout.rows, stdout.columns, callsite}for everylogUpdateImpl/logUpdateClear/logUpdateDoneinvocation, and AC-1's "pick the fix direction" sub-bullet cites a specific line range from that log identifying which §"Candidate mechanisms" entry is firing.Assumptions:
node-pty(raw terminal in iTerm/Terminal.app at ~50–70 rows × 100 cols). If not, AC-1's first sub-bullet requires documenting the conditions and pivoting AC-2 to use the harness as the primary repro.AC-2: Test harness that actually catches this regression
Verification: Integration Test
Scenario: Given a virtual terminal (VT) buffer that exposes
visibleBufferandscrollbackseparately → When the renderer is driven through the motivating-transcript event sequence with a reallog-updateinstance writing into the VT → Then(visibleBuffer + scrollback).match(/SEQUANT WORKFLOW ·/g).length === 1. Test must FAIL onmainat5124755(HEAD of this branch's base).Assumptions:
node-pty+ minimal vt100 buffer (most realistic; native dep)headless-terminal/terminal.js(pure JS; smaller dep surface)log-update+ the renderer emit (eraseLines,cursorUp/Down/Left,eraseLine,eraseEndLine)getTestStub()path is replaced or augmented for this test — it cannot be reused because it stubs out the reallog-update(run-renderer.ts:572-584), which is precisely the thing under test. The stub's existence is why feat(cli): run renderer follow-ups — frame stability, attempt counter, summary teardown (#618 follow-up) #624's tests passed despite the bug.AC-3: Fix the actual rendering bug
Verification: Integration Test (AC-2 harness goes green) + Manual Test (eyes on a real terminal at 24×80, 50×100, 50×200)
Scenario: Given the AC-2 harness asserting single-header invariant → When the fix lands → Then the harness passes AND the AC-1 debug log shows the previously-firing mechanism no longer triggers AND existing
run-renderer-624.test.tsAC-1.1 / AC-1.2 / AC-1.3 all still pass.Assumptions:
persist()shares theeraseLinesprimitive withclear()).node_modules/log-update/index.js:230-233:render.clear = () => stream.write(ansiEscapes.eraseLines(previousLineCount)).eraseLinesmoves the cursor up N rows then erases; the cursor cannot cross into scrollback, so any frame row pushed up by event writes is unreachable. AC-1 evidence determines whether this is actually firing vs. one of docs: Add pre-release checklist #2-Add Astro stack detection and configuration #5.src/lib/cli-ui/run-renderer.tsplus possibly a new helper module. Nolog-updateupgrade unless AC-1 evidence makes that the minimum-blast-radius option.AC-4: Bottom-of-output corruption — INDEPENDENT diagnosis required
Verification: Manual Test (reproduce each independently) → branch into Integration Test (shared cause) OR new issue (independent).
Scenario: Given the same instrumentation from AC-1 → When replaying scenarios that produced
✔ #5loop(missing chars) and├───────� │(U+FFFD separator overlay) → Then for each: log shows whether the corruption coincides with alogUpdateClear/logUpdateImpl/logUpdateDoneboundary (shared) or fires during a different write path (stdoutWritedirect, summary-table rendering, etc.). Outcome documented in the PR description.Assumptions:
✔ #5loopis not a clearing artifact — it's missing characters mid-string. Likely candidates: (a) overwrite from concurrent live-frame redraw landing on a partial event line, (b)appendEventLine(run-renderer.ts:649-691) racing with renderer state mutation when the loop phase starts. Independent diagnosis is correct.├───────� │(run-renderer.ts:704 renderSummary) suggests a non-UTF-8 byte was emitted into a UTF-8 stream — possibly a truncation at a multibyte boundary inside the summary or the live-frame teardown path.Implementation Plan
Phase 1: Instrumentation + diagnosis (AC-1)
SEQUANT_DEBUG_RENDERER=1gate insrc/lib/cli-ui/run-renderer.ts— emit JSON-lines tostderr(or.sequant/logs/renderer-debug-<ts>.jsonlif stderr is captured) at each of the threelogUpdate*callsites. Fields:t(ms since renderer construction),op(impl/clear/done/event/pr/summary),frame#,prevLineCount(read from the reallog-updateinstance — exposed via a wrapper, sincelog-update'spreviousLineCountis closure-scoped),prevWidth,stdoutRows,stdoutCols,callsite(line ref),eventCausedClear?,bannerActive?.log-update's closure state —node_modules/log-update/index.js:128-131keeps state private. Either (a) shadow the state on the renderer's own side by trackinglines.lengthof every frame we send throughlogUpdateImpl, or (b) write a tinyinstrumentedLogUpdatethat wrapscreateLogUpdateand exposes agetInternals()accessor for tests/debug. (a) is cheaper and sufficient for the debug log.npx sequant run 504 505 -qand several smaller pairs at 24/50/70 rows × 70/100/200 cols,-qand no--q, real terminal andscript(1)capture. Record reproduction rate as fixture.stdiofor Mechanism docs: Add pre-release checklist #2 —src/lib/workflow/phase-executor.tsconfirmsstdio: "pipe"at lines 281, 296, 334, 346, 543, so the child does not share TTY. This rules out docs: Add pre-release checklist #2 unless a re-spawn path usesinherit. Spot-checkgrep -n "stdio" src/lib/workflow/..sequant/notes/647-diagnosis.md(gitignored or PR-attached) — explicitly cite log lines pinning the mechanism. This satisfies AC-1's "Pick the fix direction only after instrumentation confirms the mechanism."Phase 2: Virtual-terminal harness (AC-2)
log-update's escape vocabulary is small (eraseLines,cursorUp/Down/Left,eraseLine,eraseEndLine) and a real PTY adds CI fragility (native build, signal handling). If this proves insufficient for AC-4, escalate tonode-pty..sequant/logs/run-2026-05-14T03-16-47-...json). Strip timestamps to fixture form.src/lib/cli-ui/__tests__/scrollback-harness.test.tsorsrc/lib/cli-ui/scrollback-harness.ts(production module so it can also support AC-1 instrumentation tests). Wire renderer → reallog-update(constructed viacreateLogUpdateso we can use a tiny customstream) → VT.(visible + scrollback).match(/SEQUANT WORKFLOW ·/g).length === 1, plus a tighter check that no header text ever fully exits the visible viewport with the live zone still rendering.Phase 3: Fix (AC-3)
run-renderer.ts. For the leading hypothesis (Mechanism feat: Complete remaining v1.0 features (AC-10, AC-13, AC-14) #1, scrollback), the cheapest fix is to switch the event-line append path tologUpdate.persist()followed by re-render — wait, no: per issue body andlog-update/index.js:242-254,persistshares theeraseLinesprimitive. The actual surgical fix candidates:persist()-style hand-off whenever we're about to write an event line that would push the previous frame's top row out of viewport. Requires knowing the current cursor row vs.process.stdout.rows, whichlog-updatedoes not expose.persist()-ed snapshot at end-of-run. Requires movingappendEventLinefromstdoutWriteinto the frame composer.Phase 4: AC-4 corruption triage
loop-phase scenario (for✔ #5loop) and a summary-with-trailing-output scenario (for U+FFFD/separator overlay).logUpdate*boundary identified by AC-1, fold into Phase 3.gh issue createwith verbatim repro + link to fix(cli): #624's duplicate-header fix doesn't catch real log-update/scrollback bug (v2.3.0 regression confirmed) #647, do not bundle into the AC-3 PR.Design Review
Where does this logic belong? —
src/lib/cli-ui/run-renderer.tsfor the fix; newscrollback-harness.tsfor the VT test. Instrumentation is colocated with the threelogUpdate*assignments (run-renderer.ts:572-589) and gated by env. No layer violation.What's the simplest correct approach? — Surgical (Direction C against the actually-firing mechanism). Reject Direction A unless surgical options all fail diagnosis — it's a renderer rewrite and the issue explicitly says "last resort." Reject Direction B (struck out in issue body). Reject "upgrade log-update" —
log-update@7is the current major; semantics oferaseLinesare the same shape upstream.What existing pattern does this follow? — Two relevant precedents:
getTestStub()mechanism (run-renderer.ts:600) is the pattern to avoid — it's what produced the false-green in feat(cli): run renderer follow-ups — frame stability, attempt counter, summary teardown (#618 follow-up) #624. The new harness must drive the reallog-updateagainst a controllable stream.clampFrameHeightbelt-and-braces pattern (run-renderer.ts:814) is good — apply the same defensiveness here (assume the renderer will be wrong, prove it visually).What would a senior reviewer challenge? — Three likely pushbacks:
log-updateor switch libraries?" — Need a one-paragraph rebuttal in the PR.log-update'seraseLinessemantics are a property of ANSI terminals, not the library. Switching libraries doesn't change the scrollback constraint.node-pty?" — Build-time dep complexity in CI, plus the renderer's escape vocabulary is small. Document the decision; escalate tonode-ptyif AC-4 demands richer terminal semantics.log-update; the false-green in feat(cli): run renderer follow-ups — frame stability, attempt counter, summary teardown (#618 follow-up) #624 (getTestStub()stub) cannot reoccur for this assertion."Feature Quality Planning
Notable items (exception-based):
getTestStub()mechanism is structurally complicit in the prior false-green and should be re-evaluated in QA. Consider either deprecating it for header-counting assertions or adding a comment atrun-renderer.ts:572-584warning future callers that it cannot verify scrollback behavior. (Touchpoint: existingrun-renderer-624.test.ts:200-252asserts use this stub.)log-updateupgrade should be attempted as part of this PR unless AC-1 proves it's the minimum-blast-radius fix. Out-of-scope churn is the feat(cli): run renderer follow-ups — frame stability, attempt counter, summary teardown (#618 follow-up) #624 mode of failure.Derived ACs
getTestStub()(run-renderer.ts:600) warning that it does NOT verify scrollback — future header-counting tests must use the AC-2 harnessOpen Questions
Virtual terminal: hand-rolled vt100 vs
node-ptyvs pure-JS lib? — Recommendation: hand-rolled minimal vt100 (~200 LOC, ~6 ANSI ops). Impact if wrong: AC-2 harness misses real-world terminal quirks that AC-4 corruption depends on; falls back tonode-ptyadding native build to CI. Decide after AC-1 instrumentation tells us how exotic the firing mechanism is.Should
getTestStub()be removed or kept (with warning) after this work? — Recommendation: keep + add comment, do not remove in this PR. Impact if wrong: existing feat(cli): run renderer follow-ups — frame stability, attempt counter, summary teardown (#618 follow-up) #624 tests need rewriting in-scope, which expands the blast radius beyond AC-3's minimum surface.Frequency baseline target: how many runs in AC-1? — Recommendation: ≥ 5 runs, pin smallest reproducing pair, report % reproduction. Impact if wrong: under-sampling lets a rare race (Mechanism Doctor: Add Claude Code CLI check #3 SIGWINCH bursts) escape diagnosis.
Sibling-site scan in
run-renderer.ts— All threelogUpdate*callsites (appendEventLineat line 652,setPullRequestat line 696,renderSummaryat lines 709-710,onPauseat line 727,onDisposeat lines 744-745) follow the sameclear() → write → done()shape. Once the diagnosed mechanism is fixed at the primary site, sweep all five for the same pattern. Recommend doing this sweep in-scope since the touchpoints are five lines apart in one file. Impact if skipped: same bug re-fires on a different code path (e.g. summary teardown corruption in AC-4 may already be this).Recommended Workflow
Phases: spec → exec → qa
Quality Loop: enabled (max 3 iterations)
Reasoning:
testgen— AC-2 demands a hand-crafted virtual-terminal integration test. Stub generation from AC text won't produce the VT harness; it would produce shallow stubs that get rewritten.test(browser) —no-browser-testis implicit; this is terminal output, not DOM.AC_MET_BUT_NOT_A_PLUSperfeedback_qa_break_vs_loop.md; treat that as proceed-to-PR.Label Review
Current:
bug,cli,uiRecommended add:
regression(verbatim in the title and a confirmed regression of v2.3.0),no-browser-test(terminal output, not DOM — prevents auto-add oftestphase fromuilabel).Quality Loop: will auto-enable for
bug+ non-trivial AC count per default behavior — matches recommendation above.→
gh issue edit 647 --add-label "regression" --add-label "no-browser-test"--- DRAFT GITHUB ISSUE COMMENT (PLAN) ---
(this comment is the plan — no separate draft section needed; everything above is the issue-comment body)
admarble commentedon May 15, 2026
Exec Phase Complete (partial — diagnose-first)
Resumed from prior
/fullsolvethat exhausted usage budget mid-exec. Committed work-in-progress, merged origin/main, pushed tofeature/647-fix-cli-624-s-duplicate-header-fix-doesn-t-catch-r.What landed (commits
57a251a+73acdea)AC-1 — production instrumentation: ✅
SEQUANT_DEBUG_RENDERER=1env gate emitting JSON-lines perlogUpdate*callsite (t, op, frame, rendererCols, rendererRows, stdoutCols, stdoutRows, wrappedLineCount). Captures the evidence the issue's "Pick the fix direction from §2 only after instrumentation confirms the mechanism" sub-bullet requires. Replay against a live duplicate-header run is the next step (cannot be automated; needs human-driven repro).AC-2 — virtual-terminal harness:⚠️ partial
scrollback-harness.ts(VirtualTerminal+createTerminalHarness) drives a realcreateLogUpdateagainst a VT model with separate visible viewport / scrollback. Avoids thegetTestStub()false-green that allowed feat(cli): run renderer follow-ups — frame stability, attempt counter, summary teardown (#618 follow-up) #624 to ship broken.HarnessOptions.streamColumns/streamRowsoverrides for width-misreporting scenarios..skip'd Mechanism feat: Complete remaining v1.0 features (AC-10, AC-13, AC-14) #1 (event-only flood) scaffold is present. AC-1 production evidence is the gate for tightening it into a reliable RED-on-master repro.AC-3 — box-drawing grid overflow:⚠️ partial
renderSingleIssueFrameandrenderRunGridhadcols - colW - 7but the rendered grid consumescolW + innerWidth + 9chars. The off-by-two made every border line wrap insidelog-update. Corrected to- 9. This closes one wrap-inducedpreviousLineCountdivergence path; it does not solve Mechanism feat: Complete remaining v1.0 features (AC-10, AC-13, AC-14) #1 (scrollback erasure from event-line scrolling), which awaits AC-1 evidence.AC-4 — bottom-output corruption: filed independently as #652 per spec ("do NOT bundle into the AC-3 fix" if independent). AC-1 evidence will determine if it's actually independent or shares a root cause with the duplicate-header bug.
AC-D3 —
getTestStub()warning: ✅ comment added atrun-renderer.ts:668warning future header-counting tests must usescrollback-harness.ts.Quality gates
npx vitest run src/lib/cli-ui/→ 89 passed, 1 skipped (the deferred Mechanism feat: Complete remaining v1.0 features (AC-10, AC-13, AC-14) #1 scaffold)npx vitest run src/lib/relay/→ 5 passednpm run lint→ cleannpm run build→ cleanHonest framing for QA
This PR delivers the diagnose-first foundation the spec required (AC-1 + AC-2 + AC-D3) plus one surgical grid-math correction (AC-3 partial). It does not claim to have fixed the duplicate-header bug end-to-end — Mechanism #1 remains open pending AC-1 evidence capture from a real
npx sequant runreproduction. Reviewers should treat this asAC_MET_BUT_NOT_A_PLUSorNEEDS_VERIFICATION, notREADY_FOR_MERGEwithout follow-up work tracked under #647.admarble commentedon May 15, 2026
QA Review for Issue #647
AC Coverage
SEQUANT_DEBUG_RENDERER=1JSON-lines at all threelogUpdate*callsites witht/op/frame/rendererCols/rendererRows/stdoutCols/stdoutRows/wrappedLineCount). Sub-bullets 1–2 (verified repro, frequency baseline) and 4 (pick fix direction from evidence) require a human-driven production replay that has not yet happened.scrollback-harness.tsdrives a realcreateLogUpdateagainst aVirtualTerminalmodelling visible + scrollback (correct shape, avoids the #624 false-green). Two scenarios pass; the Mechanism #1 scenario is committed asit.skip(...)because it does NOT yet fire on master — the AC's "Test must FAIL onmain" requirement is unmet.-7 → -9grid-math correction closes a 2-char box-drawing overflow atrenderSingleIssueFrame/renderRunGrid(legitimate fix, but a different bug class from Mechanism #1). The dominant production bug — scrollback erasure when event-line writes push the live frame above the visible viewport — is NOT fixed. AC-3's "Implementation passes the harness test from AC-2" requirement is unmet because the failing-on-master AC-2 test does not exist..skipbecause the column-mismatch scenario it was originally trying tests a different bug class (width mismatch), not Mechanism #1. No legitimate "before fix" failing output exists for the production-symptom test.getTestStub()cautioning future header-counting tests must use the scrollback-harnessrun-renderer.ts:668explicitly warning about the #624 false-green precedent and directing readers toscrollback-harness.ts.Coverage: 1/7 AC items fully met (1 derived).
Original ACs: 0/4 fully met (all PARTIALLY_MET).
Derived ACs: 1/3 met.
Quality Plan Verification
log-updateupgrade, surgical fix only)log-update)Quality Plan Status: Partial. The "Test Coverage Plan" requirement that AC-2 test FAILS on master — the most important quality gate in this spec — is not satisfied.
CI Status
No PR exists yet — CI status will appear after
/fullsolvecreates the PR.Quality Metrics
any)src/lib/cli-ui/tsc)Cache Status
N/A — first QA run on this branch.
Build Verification
N/A —
npm run buildpassed on the feature branch.Test Coverage Analysis
src/lib/cli-ui/run-renderer.ts__tests__/run-renderer*.test.ts+scrollback-harness.test.tssrc/lib/cli-ui/run-renderer-types.tssrc/lib/cli-ui/scrollback-harness.tsscrollback-harness.test.tssrc/lib/cli-ui/scrollback-harness.test.tsCoverage: 2/2 changed source files have tests.
Critical paths without tests: None.
Code Review
Strengths
scrollback-harness.tsis a genuinely sound piece of infrastructure: visible viewport + scrollback + the ANSI vocabularylog-update@7actually emits (cursor up/down/forward/back, eraseLine variants, SGR strip, mode toggles). Cursor-up clamps at row 0, modelling the real-terminal behaviour that is at the heart of Mechanism feat: Complete remaining v1.0 features (AC-10, AC-13, AC-14) #1.SEQUANT_DEBUG_RENDERER=1) is correctly placed at all threelogUpdate*callsites, emits to stderr (keeps stdout clean for the live zone), and captures every field the spec called out plus a monotonic frame counter.getTestStub()warning comment is exactly what AC-D3 required, and explicitly names the feat(cli): run renderer follow-ups — frame stability, attempt counter, summary teardown (#618 follow-up) #624 false-green precedent so the next person to add a header-count test knows where to look.Issues
mainas of this issue's creation (i.e. reproduces the bug) before any fix code is written" — is unmet. The two scenarios that exist pass on master and pass with the AC-3 fix; the only would-fail scenario isit.skip(...). Without a RED-on-master test, the harness has not proven it can catch the regression.-7 → -9closes a 2-char overflow inrenderSingleIssueFrame/renderRunGrid. That is a real defect, but the production bug from the issue body is Mechanism feat: Complete remaining v1.0 features (AC-10, AC-13, AC-14) #1 (event-line writes scrolling the live zone above the cursor-up reachable range soeraseLines(previousLineCount)clamps at row 0 and leaves a stranded header). The current fix does not address that mechanism. Shipping it as "the fix" risks a feat(cli): run renderer follow-ups — frame stability, attempt counter, summary teardown (#618 follow-up) #624-style false-green.appendEventLinestderrWritedependency for instrumentation. The instrumentation callsthis.stderrWrite(...). ConfirmstderrWriteis initialised in every code path that constructsTTYRenderer— theRenderOptionsinjection used by the harness exercises it, but a freshnew TTYRenderer()in production needs to fall back cleanly whenstderrWriteis unset. (Read ofrun-renderer.tsshowsthis.stderrWriteis set fromoptions.stderrWrite ?? ((s) => process.stderr.write(s))per existing pattern — looks fine, but worth a deliberate eye in any follow-up.)Suggestions
.skip'd Mechanism feat: Complete remaining v1.0 features (AC-10, AC-13, AC-14) #1 scenario (smaller VT, event-only flood without pause/resume, more events) until it fires on master, OR explicitly document in the PR description that the harness is correct but the production trigger has not been deterministically reproduced and AC-1 instrumentation is the next gate.scrollback-harness.test.tsthat the renderer's rendered grid width is exactlymin(cols, 110)— this would lock the AC-3 grid-math fix in regardless of the larger Mechanism feat: Complete remaining v1.0 features (AC-10, AC-13, AC-14) #1 work.Test Quality Review
(visible + scrollback)— observable state, not internals..skip'd.createLogUpdateinstance, exactly what AC-2 specifies. No incidental mocking.now()andwallClock(), no timing dependencies.Issues Found
scrollback-harness.test.ts:196—.skip'd test is scaffolding only; should either become a real failing test or be removed if not viable.Anti-Pattern Detection
Dependency Audit: N/A — no
package.jsonchanges.Code Patterns: No anti-patterns detected in the diff. No
awaitin loops, no empty catch blocks, no hardcoded secrets, no SQL concatenation. The onlyprocess.envread isSEQUANT_DEBUG_RENDERER(intentional, debug-only).Call-Site Review
N/A — no new exported functions in
run-renderer.ts(instrumentation is inside the existing constructor);createTerminalHarnessandVirtualTerminalare exported but only called fromscrollback-harness.test.ts.Execution Evidence
N/A — no
scripts/or CLI files modified.bin/cli.tsuntouched.Skill Command Verification
N/A — no
.claude/skills/**/*.mdfiles modified.CLI Registration Verification
N/A — no
RunOptions/bin/cli.tschanges.Smoke Test
N/A — no workflow-affecting changes (no skills, scripts, or CLI). The instrumentation is gated behind an env flag and cannot affect normal execution.
Self-Evaluation
.skip'd and would not block a future recurrence.SEQUANT WORKFLOW ·headers in scrollback duringnpx sequant run X Y -qbecause Mechanism feat: Complete remaining v1.0 features (AC-10, AC-13, AC-14) #1 (scrollback erasure from event-line scrolling) is unaddressed by this PR.NEEDS_VERIFICATIONis the honest verdict for an instrumentation-only handoff.Verdict: NEEDS_VERIFICATION
This PR lands a diagnose-first foundation — production instrumentation (AC-1), a real-
log-update-driven virtual-terminal harness (AC-2), thegetTestStub()false-green warning (AC-D3), a real-but-tangential grid-math correction (AC-3 partial), and a tracked AC-4 follow-up issue (#652).It does not complete the issue. The dominant production bug (Mechanism #1: scrollback erasure when event-line writes push the live frame above cursor-up's reachable range) is unaddressed; the harness's would-be RED-on-master test is
.skip'd because it does not yet reproduce that mechanism; the AC-3 fix targets a different bug class (box-drawing overflow); AC-D1 and AC-D2 cannot be satisfied without AC-1 evidence.The remaining work has a hard external-verification dependency that cannot be discharged inside this skill chain:
SEQUANT_DEBUG_RENDERER=1 npx sequant run <pair> -q 2> debug.jsonlrepeatedly until the duplicate-header symptom fires.debug.jsonlto identify which of the issue body's candidate mechanisms (feat: Complete remaining v1.0 features (AC-10, AC-13, AC-14) #1–Add Astro stack detection and configuration #5) is actually firing, with line citations..skip'd harness scenario (or replace it) until it fires on master without.skip.run-renderer.tsbased on the diagnosed mechanism./loopis unlikely to make progress because step 1 requires a real terminal session. Recommend creating the PR with this status and handing off to a human-driven follow-up that builds on the landed instrumentation.Documentation
SEQUANT_DEBUG_RENDERER=1to the debugging section after AC-1 evidence proves the flag's utility)Next Steps
SEQUANT_DEBUG_RENDERER=1. This is what unlocks AC-2's RED-on-master test, AC-3's surgical fix, and AC-D1/AC-D2's PR-description requirements./loopon this verdict. The remaining ACs are gated on production evidence that the automated loop cannot capture.admarble commentedon May 15, 2026
/fullsolve Complete
Issue: #647
Status: NEEDS_VERIFICATION (partial — diagnose-first foundation)
PR: #653
Risk Assessment
SEQUANT WORKFLOW ·headers in scrollback duringnpx sequant run X Y -q. Mechanism feat: Complete remaining v1.0 features (AC-10, AC-13, AC-14) #1 (scrollback erasure from event-line scrolling) is unaddressed by this PR; the AC-3 fix targets a different bug class.it.skip(...)because the existing event sequences don't yet push the live frame above cursor-up's reachable range. AC-1 production evidence is the prerequisite for tightening it.Progress Table
AC Coverage
getTestStub()warning)Original ACs: 0/4 fully met (all PARTIALLY_MET).
Derived ACs: 1/3 met.
Quality Metrics
src/lib/cli-ui/) + 5 passed (src/lib/relay/)any)tsc)Iteration Summary
/loopwas NOT invoked because the remaining AC gaps depend on human-driven production replay (SEQUANT_DEBUG_RENDERER=1 npx sequant run X Y -q) that cannot be captured by an automated retry.Recommended Next Steps
SEQUANT_DEBUG_RENDERER=1 npx sequant run <small-pair> -q 2> /tmp/debug.jsonlin a real terminal session until the duplicate-header symptom fires.debug.jsonlto identify which of the fix(cli): #624's duplicate-header fix doesn't catch real log-update/scrollback bug (v2.3.0 regression confirmed) #647 §"Candidate mechanisms" entries is firing.it.skip(...)Mechanism feat: Complete remaining v1.0 features (AC-10, AC-13, AC-14) #1 scenario inscrollback-harness.test.tsuntil it fails on master.run-renderer.tsbased on the diagnosed mechanism.Ready for human review of #653 and follow-up production-replay work.
fix(#647): tighten AC-2/AC-3 — RED-on-master test, cap grid at 78 col…
admarble commentedon May 15, 2026
Revised QA — Gap Fixes Landed (commit
c244f5d, PR #653)Earlier QA verdict was
NEEDS_VERIFICATIONwith seven self-identified gaps. All addressed inc244f5d. Revised verdict: AC_MET_BUT_NOT_A_PLUS (Mechanism #1 remains the legitimate open follow-up, but no longer the only blocker).Gaps closed
.skip'd failing test (AC-2 had no RED-on-master evidence)-7 → -9-only fix withmin(cols, 78)cap. Now closes the width-misreporting class. AC-2 test passes.borderRow.length === min(cols, 78)at cols=80/100/200. Locked against drift.wrappedLineCountwas logical-line count, not log-update's wrap-aware trackingstringWidthfor post-wrapAnsiapproximation. Also emitslogicalLinesseparately so divergence is directly visible.SEQUANT_DEBUG_RENDERER=1 npx tsx -e '<repro>'. Exit 0, 10 well-formed JSON-lines emitted, all fields populated.SEQUANT_DEBUG_RENDERER=1undocumenteddocs/features/run-renderer.md— env-var table entry + new "Debugging renderer regressions" section with JSON schema and divergence diagnostic./qaskipped sub-agentsany/ 0 deleted tests (PASS); security = no concerns (PASS).Revised AC Coverage
Coverage: 5/7 fully MET, 1 PARTIALLY_MET, 0 NOT_MET.
Remaining work (legitimate residual)
SEQUANT_DEBUG_RENDERER=1 npx sequant run <pair> -q 2> /tmp/debug.jsonlin a real terminal until the symptom fires. Inspect forwrappedLineCountvs actual-row divergence patterns.Quality gates
PR #653 description updated with the same framing.
fix(#652): address PR review gaps — isTTY, theater claim, misleading …
feat(#647): AC-1 instrumentation + AC-2 harness scaffolding + AC-3 gr…
admarble commentedon May 16, 2026
PR #653 merged → main
7412850Width-misreporting class of the duplicate-header regression is fixed. AC-1 instrumentation, AC-2 harness, AC-3 cap, AC-D3 warning, and docs landed.
Post-merge verification:
npm run buildclean,npx sequant doctorpasses.Issue stays OPEN for the legitimate follow-up
SEQUANT_DEBUG_RENDERER=1 npx sequant run <pair> -q 2> /tmp/debug.jsonlinteractively until the symptom fires, then inspectwrappedLineCountvs actual row counts for divergence.When the AC-1 evidence lands, the
it.skip(...)Mechanism #1 scaffold insrc/lib/cli-ui/scrollback-harness.test.tsis the entry point for the follow-up PR.admarble commentedon May 17, 2026
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:
Target scenarios (try in order until a symptom fires):
Artifacts to commit:
terminal.typescript— raw byte stream fromscriptdebug.jsonl— instrumentation lognotes.md— terminal app,$COLUMNS × $LINES, Node version, which symptom firedWhat each unblocks:
SEQUANT WORKFLOW · …≥2× in scrollback✔ #5loop/ mid-string char drop / U+FFFD overlaySanity before
/assess:wc -l debug.jsonl≥ ~10jq -s 'group_by(.callsite) | map({callsite: .[0].callsite, count: length})' debug.jsonlterminal.typescriptfor the symptomDo NOT rerun
/fullsolveon 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; oncedebug.jsonlis committed,/assessand/fullsolvebecome productive again because byte-level mechanism ID moves into scope.docs(#655): AC-D1 negative result — synthetic harness does not reprod…
5 remaining items
test(#647): AC-1 re-analysed — Mechanism #1 was wire traffic, not scr…
fix(#664): route SEQUANT_DEBUG_RENDERER to file sink, eliminate 2171×…
admarble commentedon May 20, 2026
AC-3 fix landed in PR #667 — root cause identified via code audit
After diminishing returns on trace-driven investigation, switched to a direct code audit. Three Explore subagents enumerated every
process.stdout.write/process.stderr.write/console.*callsite in the run pipeline and classified each as renderer-internal / bracketed / pre-render / post-render / LEAK.Result: 43 leaks across 5 files, with the smoking gun in
phase-executor.ts.Root cause
executePhaseWithRetryreceivesspinner: PhasePauseHandle(wired by PR #659 for subprocess output) but then makes rawconsole.logcalls in its own retry-reporting code without using the handle. The 4 unconditional-fire callsites:! Phase failed with MCP enabled, retrying without MCP...✓ Phase succeeded without MCP (MCP cold-start issue detected)⟳ Spec phase failed, retrying with Nms backoff...✓ Spec phase succeeded on retryCross-referencing the original #504/#505 transcript: that run log shows #505 had 3 retries (
spec → exec → qa → exec → qa → exec), producing exactly 3 duplicate headers in scrollback over 56m. Numbers match.Fix shape (PR #667)
PhasePauseHandle.appendNotice(message)method — mirrorsappendEventLine'sclear → write → redrawso log-update'spreviousLineCountstays correctbracketedConsoleLog(spinner, message)helper inphase-executor.tsroutes throughappendNotice(renderer present) or falls back toconsole.log(quiet/non-TTY)executePhase+executePhaseWithRetryrefactored to use itscrollback-harness.test.tsincluding ait.failsnegative control that locks in the diagnosisInvestigation artifacts
Committed to
docs/incidents/647/captures/2026-05-19/:notes.md— capture kit + decision rule with trivial-pass pre-checkterminal.typescript+debug-renderer.jsonl— HITL re-capture under PR fix(#664): route SEQUANT_DEBUG_RENDERER to file sink, eliminate 2171× scrollback amplifier #665's file sink (validates the 2171× amplifier is gone empirically: 0 SEQUANT_DEBUG_RENDERER occurrences in pty)analyze-trace.ts— VT-replay analyzer (now correctly reportsINCONCLUSIVEwhen scrollback isn't populated)replay-504-505.ts— deterministic event-replay harness driving the realTTYRendererthrough the exact arch: typed workflow event system for decoupled progress, logging, and MCP streaming #504/arch: phase plugin registry — user-extensible workflow phases #505 phase timeline from the run log. Zero claude budget; reports 0 leaked headers across 7 populated scrollback rows post-fix.analysis-report.txt/replay-report.txt— analyzer outputsTest results
it.fails)bracketedConsoleLogroutes throughappendNoticeLower-priority follow-ups (not in this PR)
The audit found 10 additional leak callsites in
state-cleanup.ts,state-manager.ts, andrun-orchestrator.tsthat only fire in--verbosemode or specific pre-flight paths. They're real but lower-priority and not contributing to the original #504/#505 bug. Worth a separate small PR; will file as a follow-up if not bundled.AC checklist
Close on merge of #667.
fix(#647): bracket batch-boundary log lines + add CHANGELOG entry
chore(#647): extract bracketedConsoleLog + add lint guard (A+ hardening)
fix(#647): AC-3 — route retry/fallback messages through renderer's ap…
feat(cli): replace start/complete event journal with in-place phase-m…
fix(cli-ui): single-issue live frame renders boxless indented labels (#…
docs(#655): AC-D1 negative result — synthetic harness does not reprod…
feat(#647): scrollback harness scaffolding for duplicate-header AC-2
feat(#647): AC-1 debug instrumentation + AC-2 harness extension + AC-…
fix(#652): renderer bottom-output corruption — column-binding + rende…
fix(#652): address PR review gaps — isTTY, theater claim, misleading …
feat(cli): replace start/complete event journal with in-place phase-m…