Skip to content

feat(#624): run renderer follow-ups — frame stability, attempt counter, summary teardown, failure dedup - #627

Merged
admarble merged 2 commits into
mainfrom
feature/624-feat-cli-run-renderer-follow-ups-frame-stability-a
May 11, 2026
Merged

admarble merged 2 commits into
mainfrom
feature/624-feat-cli-run-renderer-follow-ups-frame-stability-a

Conversation

@admarble

Copy link
Copy Markdown
Contributor

Summary

Four post-launch fixes to the unified RunRenderer (#618 / PR #620) surfaced by a real npx sequant run 608 604 -q transcript:

  • Item 1 — live-zone height cap: TTYRenderer bounds the live frame at max(8, rows − 5) so log-update never loses cursor tracking and stacks duplicate SEQUANT WORKFLOW · headers.
  • Item 2 — summary teardown + width clamp: NonTTYRenderer.renderSummary no longer hardcodes columns: 80; SUMMARY_COLUMN_CAP = 110 applied uniformly across both render paths to eliminate the ├───────�ing: corruption.
  • Item 3 — exec attempt counter: events log shows (attempt N/M) on retried non-loop phases; TTY status cell shows loop N/M · last fail: <short reason> while the loop phase is running. Shared formatRetrySuffix() helper eliminates drift between three sibling sites.
  • Item 4 — failure dedup: consecutive identical failures fold into (same failure as attempt K); full text re-emitted on divergent or final-iteration failures.
  • Derived AC-D1: test-mode log-update stub tracks replacementCount and lastFrame; exposed via TTYRenderer.getTestStub().

Pre-PR AC Verification

AC Source Description Status Evidence
AC-1.1 Original Live zone height ≤ max(8, rows − 5) ✅ clampFrameHeight() + effectiveRowCap() in run-renderer.ts
AC-1.2 Original rows=20 + 5 issues + 10 events: 1 header per state ✅ Test run-renderer-624.test.ts AC-1.2 via getTestStub()
AC-1.3 Original Motivating transcript ≤ 1 header per state ✅ Test AC-1.3 across (24,50) × (70,100) matrix
AC-2.1 Original Repro matrix (no box/U+FFFD garble) ✅ Test AC-2.1
AC-2.2 Original renderSummary flushes log-update before handoff ✅ logUpdateClear() + logUpdateDone() before renderSummaryBlock
AC-2.3 Original Columns clamped to 110 across both render paths ✅ SUMMARY_COLUMN_CAP in TTYRenderer.renderSummary + NonTTYRenderer.renderSummary + renderRunSummary
AC-2.4 Original Motivating-transcript stdout clean (no \x1b[K, no U+FFFD) ✅ Test AC-2.4
AC-2.5 Original Matrix {1,2,4 issues} × {70,100,140 cols} × {24,50 rows} ✅ Test AC-2.5 (18 matrix cases)
AC-3.1 Original TTY events log shows (attempt N/M) from 2nd exec ✅ formatRetrySuffix() in appendEventLine
AC-3.2 Original NonTTY events log emits same (attempt N/M) suffix ✅ formatRetrySuffix() in emitEventLine
AC-3.3 Original TTY status cell shows loop N/M · last fail: <reason> ✅ statusHeader() loop branch
AC-3.4 Original Both render paths emit (attempt 2/3) and (attempt 3/3) ✅ Test AC-3.4
AC-4.1 Original Matching failureSignature abbreviates subsequent ✅ decideDedup() in run-renderer.ts
AC-4.2 Original Full text re-emitted on final attempt before giving up ✅ decideDedup returns full when currentAttempt >= maxIterations
AC-4.3 Original 3 identical + 1 divergent: full / abbr / full / final-full ✅ Test AC-4.3
Derived ACs
AC-D1 Foundational Test-mode log-update stub tracks frame replacement ✅ TTYRenderer._testStub + getTestStub()
AC-D2 Polish maxLoopIterations threaded through all 3 retry sites ✅ RenderOptions.maxLoopIterations + formatRetrySuffix
AC-D3 Polish Box-char assertions use Unicode property escapes ✅ Test AC-D3 uses [─-╿] range

Files Changed

  • src/lib/cli-ui/run-renderer-types.ts — new fields on ProgressEvent, IssueState, RenderOptions
  • src/lib/cli-ui/run-renderer.ts — height cap, attempt counter, dedup, test stub
  • src/lib/cli-ui/run-renderer-624.test.ts — 51 new test cases (new file)
  • src/lib/cli-ui/__snapshots__/run-renderer.test.ts.snap — snapshot updates for wider NonTTY summary
  • src/lib/workflow/batch-executor.ts — thread iteration on every phase event
  • src/lib/workflow/types.ts — ProgressCallback extra now includes iteration
  • src/commands/run-progress.ts — pass rows: process.stdout.rows + maxLoopIterations to renderer
  • src/commands/run.ts — read maxLoopIterations from resolved config
  • CHANGELOG.md — Unreleased entry under Added

Test Results

  • npx vitest run: 130 files, 3,059 tests pass (51 new in run-renderer-624.test.ts + 2 snapshot updates)
  • npm run build: clean
  • npm run lint: clean

Quality Plan Alignment

Quality Dimension Items Addressed Notes
Test harness Test stub + replay helper getTestStub(), replayTranscript()
Sibling-site dedup Shared formatRetrySuffix Replaces 3 hardcoded /3 literals
Cross-platform \p{Block=Box_Drawing} regex compatibility AC-D3
Back-compat Missing iteration falls through Tests cover undefined-iteration path

Test plan

  • npm run build passes
  • npm run lint passes
  • Full test suite (3,059 tests) passes
  • Manual: npx sequant run 608 604 -q against the motivating transcript reproduces clean output (no duplicate headers, no ├───────� corruption, (attempt N/M) suffixes on retried exec)

Closes #624

…r, summary teardown, failure dedup

Four post-launch fixes to the unified RunRenderer (#618 / PR #620) surfaced
by a real `npx sequant run 608 604 -q` transcript on 2026-05-10.

Item 1 — live-zone height cap (TTYRenderer):
  - Bound the live frame at `max(8, rows - 5)` (rows - 7 with banner).
  - New `RenderOptions.rows`, `getRows()`/`getMaxLiveRows()` helpers,
    dynamic `effectiveRowCap()` derived from terminal height, and a
    belt-and-braces `clampFrameHeight()` truncation with overflow
    indicator. Dynamic cap only engages when `rows` is explicitly
    provided so existing tests / detached stdout keep pre-#624 behavior.

Item 2 — summary teardown / width clamp:
  - `NonTTYRenderer.renderSummary` no longer hardcodes columns=80; it
    shares the same column source as the TTY path.
  - New `SUMMARY_COLUMN_CAP = 110` applied in `TTYRenderer.renderSummary`,
    `NonTTYRenderer.renderSummary`, and `renderRunSummary` so wide
    terminals can't produce grids that overflow narrower readers.

Item 3 — exec attempt counter:
  - Events log on retried non-loop phases shows `(attempt N/M)`
    (replacing the `(loop N/3)` literal).
  - TTY status cell shows `loop N/M · last fail: <short reason>` while
    the loop phase is running.
  - Shared `formatRetrySuffix(iteration, maxIterations, kind)` helper
    used by all three retry-suffix sites — eliminates drift.
  - `RenderOptions.maxLoopIterations` threaded from settings through
    `run-progress.ts` so the M denominator is data-driven, not /3.
  - `ProgressEvent.iteration`, `emitProgressLine` `extra.iteration`,
    and `ProgressCallback`'s extra all extended; `batch-executor`
    populates `iteration` on every phase event + surrounding loop events.

Item 4 — failure dedup:
  - `IssueState.lastFailureSignature` + `firstAttemptForSignature`
    track first occurrence of each normalized error.
  - New `failureSignature(error)` helper strips ANSI escapes,
    lowercases, trims, truncates to 80 chars.
  - 3-state machine (`first-seen → abbreviated → final-full`) folds
    repeated identical failures; final allowed iteration re-emits the
    full text so divergent failures stay visible at max-iter.

Derived AC-D1: test-mode `log-update` stub tracks `replacementCount`
and `lastFrame`; exposed via `TTYRenderer.getTestStub()` so frame-
stability tests assert on replacement count instead of parsing buf.out.

Tests: 51 new cases in `run-renderer-624.test.ts` covering all 15 ACs
+ 3 derived ACs, including a `replayTranscript()` helper that replays
the verbatim #624 motivating transcript across both render paths at the
AC-2.5 (columns × rows × issue count) matrix.

All 3,059 existing tests pass; 51 new tests added → 3,110 total.
…stronger AC assertions

Address 9 gaps surfaced during the QA re-read pass on PR #627:

- Per-phase failure dedup: move lastFailureSignature + firstAttemptForSignature
  from IssueState to PhaseState so cross-phase signature collisions don't
  produce misleading "same failure as attempt N" text.
- clampFrameHeight + effectiveRowCap: remove rowsOverride-undefined short-circuits,
  bump DEFAULT_TERMINAL_ROWS from 24 to 100. AC-1.1 "regardless of issue count"
  is now literally enforced; the generous default keeps existing tests passing
  with no over-constraint.
- TTYTestStub: add clearCalls + doneCalls counters; AC-2.2 now verifies the
  renderer actually invokes logUpdate.clear() + logUpdate.done() rather than
  trusting the stub's local state reset.
- AC-2.3 (TTY + NonTTY): assert summary widths are identical at cols=110 and
  cols=200 (pins the 110 cap rather than relying on 115-char slack).
- AC-2.1 + AC-2.4: add box-char/alphanumeric-adjacency assertions catching the
  verbatim `├───────�ing:` corruption from the motivating transcript.
- AC-4.3 split: new literal "3 identical with maxIter=3" test alongside a
  renamed "(divergence)" test.
- Per-phase dedup positive test: exec-fail then qa-fail with same string emits
  full qa text (never abbreviates across phases).
- emitProgressLine iteration propagation: 5 new cases covering payload
  contents on start/complete/failed and the SEQUANT_ORCHESTRATOR-unset no-op.
- @tautology-skip pragma on run-renderer-624.test.ts with a documented reason
  (helper-wrapped construction false positive in the detector's body scan).
- D3 doc: V8 does not support \p{Block=Box_Drawing} property escape. The
  codepoint range `[─-╿]/u` IS the canonical JS equivalent — platform-agnostic,
  no Windows CI runner needed.
- AC-1.2 doc comment explaining why `stub.lastFrame` is the right assertion
  target (not `buf.joined()`).

3066 tests pass (3059 + 7 new), build clean.
@admarble
admarble merged commit c429f50 into main May 11, 2026
5 checks passed
admarble added a commit that referenced this pull request Sep 9, 2026
…stronger AC assertions

Address 9 gaps surfaced during the QA re-read pass on PR #627:

- Per-phase failure dedup: move lastFailureSignature + firstAttemptForSignature
  from IssueState to PhaseState so cross-phase signature collisions don't
  produce misleading "same failure as attempt N" text.
- clampFrameHeight + effectiveRowCap: remove rowsOverride-undefined short-circuits,
  bump DEFAULT_TERMINAL_ROWS from 24 to 100. AC-1.1 "regardless of issue count"
  is now literally enforced; the generous default keeps existing tests passing
  with no over-constraint.
- TTYTestStub: add clearCalls + doneCalls counters; AC-2.2 now verifies the
  renderer actually invokes logUpdate.clear() + logUpdate.done() rather than
  trusting the stub's local state reset.
- AC-2.3 (TTY + NonTTY): assert summary widths are identical at cols=110 and
  cols=200 (pins the 110 cap rather than relying on 115-char slack).
- AC-2.1 + AC-2.4: add box-char/alphanumeric-adjacency assertions catching the
  verbatim `├───────�ing:` corruption from the motivating transcript.
- AC-4.3 split: new literal "3 identical with maxIter=3" test alongside a
  renamed "(divergence)" test.
- Per-phase dedup positive test: exec-fail then qa-fail with same string emits
  full qa text (never abbreviates across phases).
- emitProgressLine iteration propagation: 5 new cases covering payload
  contents on start/complete/failed and the SEQUANT_ORCHESTRATOR-unset no-op.
- @tautology-skip pragma on run-renderer-624.test.ts with a documented reason
  (helper-wrapped construction false positive in the detector's body scan).
- D3 doc: V8 does not support \p{Block=Box_Drawing} property escape. The
  codepoint range `[─-╿]/u` IS the canonical JS equivalent — platform-agnostic,
  no Windows CI runner needed.
- AC-1.2 doc comment explaining why `stub.lastFrame` is the right assertion
  target (not `buf.joined()`).

3066 tests pass (3059 + 7 new), build clean.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

feat(cli): run renderer follow-ups — frame stability, attempt counter, summary teardown (#618 follow-up)

1 participant