Repository navigation
feat(#647): AC-1 instrumentation + AC-2 harness scaffolding + AC-3 grid-math fix (diagnose-first foundation) - #653
Merged
admarble merged 4 commits intoMay 16, 2026
Conversation
Wires a real `createLogUpdate` instance through a virtual-terminal model that tracks both visible viewport and scrollback, so future tests can assert on `(visible + scrollback)` instead of just the most recent frame (which is what `getTestStub()` exposes and is the reason #624's tests shipped green despite the bug). What this commit lands: - `scrollback-harness.ts`: VirtualTerminal modelling rows + scrollback + the ANSI escape vocabulary that `log-update@7` + `ansi-escapes` emit (cursor up/down/forward/back, eraseLine variants, SGR strip, mode set/reset, save/restore). - `RenderOptions.logUpdateInstance`: test-only injection point so TTYRenderer can drive the harness's real log-update instead of the existing `getTestStub()` mock. Production paths unchanged. - `scrollback-harness.test.ts`: two scenarios (basic + pause/resume with verbose subprocess streaming) that drive the renderer through the harness and count `SEQUANT WORKFLOW · ` occurrences in (visible + scrollback). Status against AC-2 (test must FAIL on `main` before fix): - Both assertions currently PASS. The harness does not yet reproduce the production bug. log-update@7 internally pre-wraps via `wrapAnsi` and tracks the wrapped line count, so `eraseLines(previousLineCount)` covers the full rendered height in the model. - The production bug therefore lives in a real-terminal behaviour the VT doesn't model — most likely candidate-mechanism #2 (subprocess/log-update stream.columns disagreement) or #4 (`process.stdout.rows` undefined under `npx` causing log-update's `fitToTerminalHeight` to clip while the renderer assumes the full height). AC-1 instrumentation is the intended next step to pin which. - Once the mechanism is identified, the harness can be extended (e.g. decouple stream.columns from VT.cols to simulate the mismatch) to make the assertions fail on `main` as AC-2 requires. Remaining ACs for follow-up work in this PR: - AC-1: production instrumentation under `SEQUANT_DEBUG_RENDERER=1` - AC-2: harness extension that reproduces (red on main, green on fix) - AC-3: surgical fix once AC-1 pins the mechanism - AC-4: independent diagnosis of `✔ #5loop` + U+FFFD corruption
…3 grid math fix
Lands the diagnose-first foundation for the duplicate-header regression
without committing to a fix direction before AC-1 evidence is captured.
AC-1: Production instrumentation
- `SEQUANT_DEBUG_RENDERER=1` gate at every `logUpdateImpl`/`logUpdateClear`/
`logUpdateDone` callsite. Emits one JSON line per call to stderr with
`{t, op, frame, rendererCols, rendererRows, stdoutCols, stdoutRows,
wrappedLineCount}` so a real `npx sequant run ... 2> debug.jsonl` pins
which of the candidate mechanisms in the #647 issue body is firing.
- Stderr keeps stdout clean for the live zone; user redirects when needed.
AC-2: Harness extension
- `HarnessOptions.streamColumns` / `streamRows` overrides let the harness
decouple what `log-update` is told (via `stream.columns`/`rows`) from the
VirtualTerminal's physical dimensions. Useful for future scenarios that
reproduce width-misreporting bug classes.
- Test file header updated to be honest about scope: the existing
scrollback-harness scenarios pass on master AND with the AC-3 grid fix,
so they do NOT yet reproduce Mechanism #1. A `.skip`'d scaffold for the
event-only flood scenario captures the intent; AC-1 instrumentation
evidence is the prerequisite for tightening it.
AC-3: Box-drawing grid-width overflow (partial)
- `renderSingleIssueFrame` and `renderRunGrid` both used `cols - colW - 7`,
but the rendered grid actually consumes `colW + innerWidth + 9` chars
(2 leading spaces + 3 vertical bars + 4 cell padding). The prior formula
produced rows 2 chars wider than `cols`, which made log-update wrap every
grid border line internally. Fixed to `- 9` so total grid == cols.
- This addresses one class of wrap-induced previousLineCount divergence
but does NOT solve Mechanism #1 (scrollback erasure when event-line
writes scroll the frame above the visible viewport). The full fix awaits
AC-1 evidence per the issue's diagnose-before-fix requirement.
AC-D3: `getTestStub()` warning
- Comment added on `getTestStub()` warning that the stub does not model
log-update's scrollback semantics, so header-count assertions MUST use
the scrollback-harness — preventing the #624 false-green recurrence.
AC-4: Unaddressed in this commit; will be filed as a separate issue per
spec ("do NOT bundle into the AC-3 fix" if independent).
Tests: 89 pass / 1 skipped across src/lib/cli-ui/ (the skipped test is the
deferred Mechanism #1 scaffold). lint + build clean.
…24-s-duplicate-header-fix-doesn-t-catch-r
…s, wrap-aware metric Closes the gaps from the previous diagnose-first commit (73acdea): AC-2: un-skip the width-misreporting scenario - Removed `it.skip(...)` on the column-mismatch test. With the prior `-7/110` formula it fails on master (header count > 1, grid renders at 102 cols and the 80-col VT wraps it, breaking log-update's `previousLineCount` accounting). With this commit's cap fix it passes (grid stays at 78 cols, fits within the VT, no wrap, no scrollback divergence). - Reframed the test name and surrounding comments away from "Mechanism #2" toward Mechanism #4-adjacent (width misreporting between renderer/log-update and the physical terminal) — the honest classification. AC-3: real fix — cap rendered grid at `min(cols, 78)` instead of `min(cols, 110)` - Both `renderSingleIssueFrame` and `renderRunGrid` now cap at 78. This keeps the rendered width narrower than any standard 80-col terminal even when `process.stdout.columns` is wider than the physical terminal (cached value, TTY emulation layer disagreement, `npx`-piped stdout, etc.). - The previous `-7 → -9` correction is preserved as the underlying box-drawing math fix. The cap is the user-visible behavior change. - UX trade-off: wide-terminal users see an at-most-78-col progress grid instead of up-to-110-col. The displayed data (issue numbers, phase names, durations) is short and fits comfortably; we accept the narrower display in exchange for wrap-resistance under width misreporting. AC-3 derived (grid-width invariant test): - New test asserts that the rendered border row width equals `min(cols, 78)` at practical widths (80/100/200). Locks the arithmetic against future drift in `colW`, padding, or the cap. AC-1: wrap-aware `wrappedLineCount` metric - Previously emitted `text.split("\n").length`, which is the LOGICAL line count, not what `log-update`'s `previousLineCount` actually tracks. - Now uses `stringWidth` to approximate the post-`wrapAnsi` line count at `stream.columns`. Matches log-update's render path closely enough to spot divergence — the diagnostic case AC-1 was designed for. - Also emits `logicalLines` separately so a debug-log reader can see when the two diverge (wrap is the culprit). AC-1 smoke verification: - Ran `SEQUANT_DEBUG_RENDERER=1 npx tsx -e '<test renderer>'` end-to-end. Exit 0, 10 well-formed JSON-lines emitted to stderr, all fields populated, `stdoutCols/stdoutRows` correctly reported as `null` in the no-real-TTY context (which is itself a useful diagnostic signal). Documentation: - Added `SEQUANT_DEBUG_RENDERER=1` to docs/features/run-renderer.md's "Modes & Settings" table and a new "Debugging renderer regressions" troubleshooting section with the JSON-lines schema and divergence diagnostic guidance. Mechanism #1 (scrollback erasure from event-line scrolling) remains an open follow-up — capping doesn't address it. AC-1 instrumentation is in place; production replay is the next gate. Tests: 97 passed / 1 skipped (the deferred Mechanism #1 scaffold). Lint + build clean.
Closed
5 of 6 tasks
admarble
deleted the
feature/647-fix-cli-624-s-duplicate-header-fix-doesn-t-catch-r
branch
May 16, 2026 04:38
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Fixes the width-misreporting class of the duplicate-
SEQUANT WORKFLOW ·header regression — when the renderer +log-updateagree on a column width that disagrees with the physical terminal (cachedprocess.stdout.columns, TTY emulation layers,npx-piped stdout, SIGWINCH timing). Lands the diagnose-first foundation (instrumentation, harness, false-green warning) along with the surgical fix and a regression test that fails on master and passes with the fix.Mechanism #1 (scrollback erasure from event-line scrolling) is still open — capping the grid width doesn't address it. AC-1 instrumentation is in place; production replay is the next gate. Tracked back in #647.
Filed #652 for AC-4 (renderer bottom-output corruption symptoms) per spec's "do NOT bundle into the AC-3 fix" requirement.
What landed
SEQUANT_DEBUG_RENDERER=1env gate emitting JSON-lines perlogUpdate*callsite. Wrap-aware:wrappedLineCountusesstringWidthto approximatelog-update's post-wrapAnsipreviousLineCount;logicalLinesreports the pre-wrap newline count separately so a debug-log reader can spot wrap-induced divergence directly.scrollback-harness.tsdrives a realcreateLogUpdateagainst a VT model with separate visible viewport and scrollback. The width-misreporting test fails on master (header count > 1) and passes with the AC-3 fix. A Mechanism feat: Complete remaining v1.0 features (AC-10, AC-13, AC-14) #1 scenario remains asit.skip(...)scaffold — production-evidence-gated.min(cols, 78)(wasmin(cols, 110)). With the cap, the rendered grid is always narrower than any standard 80-col terminal even whencolsis reported wider than the physical terminal. The previous-7 → -9correction is preserved as the underlying box-drawing arithmetic fix. AC-3 derived test: new invariant test asserts rendered border width equalsmin(cols, 78)at practical widths (80/100/200), locking the math against future drift.getTestStub()warning: comment atrun-renderer.ts:668warns that the stub does not model log-update's scrollback semantics; future header-count assertions MUST use the scrollback-harness. Prevents a feat(cli): run renderer follow-ups — frame stability, attempt counter, summary teardown (#618 follow-up) #624-style false-green recurrence.docs/features/run-renderer.mdwith the JSON-lines schema and divergence diagnostic guidance.Acceptance criteria status
exit 0, 10 JSON-lines, valid JSON, all fields populated), and the metric is now wrap-aware. The "verified repro + frequency baseline" sub-bullets still require a human-driven production replay; the instrumentation is the prerequisite.createLogUpdate. Width-misreporting test fails on master (RED) and passes with the AC-3 fix (GREEN). Spec's "Test must FAIL onmain" literal requirement is satisfied for this mechanism class. Mechanism #1 reproduction is a deferred follow-up.min(cols, 78)cap + box-drawing math correction (-9). AC-2 test passes. Mechanism #1 remains an open follow-up; not bundling speculative fixes per the issue's diagnose-first requirement.c244f5ddescription for the methodology.getTestStub()warning)run-renderer.ts:668.Quality gates
npx vitest run src/lib/cli-ui/ src/lib/relay/→ 97 passed, 1 skipped (Mechanism feat: Complete remaining v1.0 features (AC-10, AC-13, AC-14) #1 scaffold)npm run lint→ cleannpm run build(tsc) → cleanany): 0RED→GREEN evidence (AC-D2)
With the prior
Math.min(cols, 110) - colW - 7formula, the width-misreporting scenario (streamColumns=100, rendererColumns=100, vt.cols=80) produces grid rows 102 cols wide that the 80-col VT wraps;log-update'spreviousLineCountundershoots; the prior frame's header survives in scrollback each redraw. The harness reports header count > 1 and dumps visible + scrollback for inspection.With this PR's
min(cols, 78)cap, the same scenario produces exactly one header (the grid is 78 cols wide, fits in the VT without wrap, log-update's line tracking matches). The grid-width invariant test additionally confirmsborderRow.length === min(cols, 78)at cols=80/100/200.Test plan
SEQUANT_DEBUG_RENDERER=1 npx sequant run <pair> -q 2> /tmp/debug.jsonlin a real terminal until the duplicate-header symptom (Mechanism feat: Complete remaining v1.0 features (AC-10, AC-13, AC-14) #1) fires. Inspectdebug.jsonlforwrappedLineCountdivergence patterns..skipthe deferred scaffold once AC-1 evidence pins the firing parameters.Commits
73acdea— initial AC-1 instrumentation + AC-2 harness extension + AC-3 grid-math math correction + AC-D3 warningf1a0adb— merge origin/mainc244f5d— gap-fix pass: un-skip AC-2 test, cap at 78 (the real AC-3 fix), wrap-aware AC-1 metric, AC-3 invariant test, docs section, smoke-verified instrumentationRelated
getTestStub()warning + RED-on-master invariant test are designed to prevent recurring