Skip to content

fix(cli): post-run SUMMARY duration sums per-issue times instead of wall clock — 4-issue parallel run reported 1h 12m for 36m 18s #867

Closed

Description

@admarble

A 4-issue parallel run printed SUMMARY · 4 issues · 1h 12m. The run actually took 36m 18s. sequant logs reports the same run correctly, so the two commands disagree by 2× about a run that just finished in front of you.

src/commands/run-display.ts:191 builds the header duration by summing per-issue durations:

const totalSeconds = results.reduce(
  (sum, r) => sum + (r.durationSeconds ?? 0),
  0,
);

Under --parallel that double-counts every overlapping issue. At 3-way concurrency the printed figure runs about 2× the truth; the error scales with the concurrency setting, so the number is worst exactly where a duration readout is most useful.

The log writer already computes this correctly — run-log-schema.ts:415 uses (endTime - startTime) / 1000 — and commands/logs.ts:133 renders that stored value. Only the live post-run summary recomputes it the wrong way.

The sum was correct when written. sequant run executed issues in a serial for...of loop until #419 (e86ebbe4, 2026-03-24) replaced it with Promise.allSettled + p-limit at a default concurrency of 3. That commit changed the execution model and left the summation untouched, silently invalidating it. Full archaeology and the reason no test caught it are in the first comment below.

Measured, from run 21feec76-20e3-468a-8393-cd43cab03df7

startTime  2026-07-29T15:32:29.443Z
endTime    2026-07-29T16:08:47.777Z
           -> wall clock 2178.334s = 36m 18s

summary.totalDurationSeconds in the log:      2178.334   (correct)
sum of the four per-issue durations:          4322.904   (what SUMMARY printed as "1h 12m")
  #853  855.655   #847  961.650
  #850 1203.303   #844 1302.296

Same run, two commands:

SUMMARY · 4 issues · 1h 12m · 4 passed · 0 failed     <- run-display.ts:191
sequant logs --last 1  ->  Duration: 36m 18s          <- logs.ts:133, from the log

The stored log is right, so this is purely a display-layer defect and no historical data is corrupted.

Related: #866 covers a different duration defect in the Ink TUI. They are independent — different code paths, different failure modes — but both surfaced in this one run, and both make an on-screen duration disagree with the summary table directly beneath it.

Acceptance Criteria

  • AC-1: The post-run SUMMARY header duration is run wall-clock time, not the sum of per-issue durations.
  • AC-2: The wall-clock duration is computed once by the orchestrator, which owns the run's start and end, and both the printed summary and the run log derive from that single value rather than each recomputing it.
  • AC-3: The summary duration is correct under --no-log and when log initialization fails, neither of which produces a run log to read from.
  • AC-4: A sequential (concurrency 1) run's summary duration is unchanged by the fix, since sum and wall clock nearly coincide there.
  • AC-5: A parallel run with known overlapping issue durations prints wall clock; a regression test pins a 3-concurrent fixture whose per-issue sum differs from wall clock by more than 2×, so summing cannot satisfy it.
  • AC-6: That regression test drives displaySummary from a RunResult and asserts the duration in the rendered output — passing totalDurationSeconds into renderSummary does not count, since the bug is upstream of the renderer and such a test passes against unfixed code.
  • AC-7: sequant logs --last 1 and the live SUMMARY header report the same duration for the same run, asserted from one shared fixture.
  • AC-8: The regression test is mutation-verified by restoring the reduce sum and confirming exactly that test fails, with the result recorded in the commit message or PR body.

Activity

  1. added
    bug
    cli
    on Jul 29, 2026
  2. admarble commented on Jul 29, 2026

    @admarble
    ContributorAuthor

    Traced where the two computations diverged. The sum was never wrong when it was written — it was correct for four months and then quietly invalidated by a change somewhere else.

    2026-01-08, #22 (3387c29a) — the run log gets its wall-clock total, (endTime - startTime) / 1000. This has been right the entire time and still is.

    2026-01-20, #132 (d61c0bfc) — the display-side reduce sum is introduced. Correct at the time: sequant run executed issues in a serial for...of loop, so the sum of per-issue durations was wall clock, give or take orchestration overhead. Two ways of computing the same number.

    2026-03-24, #419 (e86ebbe4) — "Replace the serial for...of loop with Promise.allSettled + p-limit for concurrent issue execution. Issues now run in parallel by default with configurable concurrency (--concurrency N, default: 3)."

    That is the drift point. #419 changed the execution model out from under the arithmetic and never revisited it. The reduce in run-display.ts was not touched by that commit — I checked the diff; it changes durationSeconds plumbing but leaves the summation alone. From that day every multi-issue run has over-reported, by roughly the concurrency factor, and the default concurrency of 3 is why your run came out near 2×.

    The equivalence the sum depended on was implicit. Nothing in run-display.ts recorded "this is only wall clock because execution is serial," so there was no comment for #419 to invalidate and no reason for its author to look.

    Why no test caught it. The renderer is covered, but only downstream of the bug. run-renderer.test.ts:884 passes totalDurationSeconds: 975 in as an input and asserts /SUMMARY · 2 issues/, /1 passed/, /1 failed/ — never the rendered duration. No test anywhere asserts the header's duration value, and no test covers the producer at run-display.ts:191. The defect lives entirely in the untested seam between a tested producer-caller and a tested renderer.

    This sharpens AC-4 and AC-5: the regression test has to cover the seam, not the renderer. A test that feeds totalDurationSeconds into renderSummary will pass against the broken code exactly the way the existing one does. It has to drive displaySummary from a RunResult with overlapping issue durations and assert the number that comes out.

  3. admarble commented on Jul 29, 2026

    @admarble
    ContributorAuthor

    Checked what the fix actually has to work with, because the obvious one-line fix is not available. Two constraints, both of which changed the ACs above.

    displaySummary cannot compute wall clock from what it is handed. RunResult (run-orchestrator.ts:272) carries results, logPath, exitCode, worktreeMap, issueInfoMap, config, mergedOptions, logWriter — and no run-level start or end time. Summing per-issue durations is, today, the only duration the function can derive. That is likely why it was written that way. The fix is plumbing, not arithmetic.

    Reading it back from the log does not work either. My first AC-2 said to source the duration from the value the log stores. That breaks two ways:

    • --no-log (mergedOptions.noLog, checked at run-orchestrator.ts:622 and :677) suppresses the log writer entirely.
    • Log initialization failure falls back to logWriter = null with a warning (run-orchestrator.ts:703-706), and several other paths return logWriter: null outright.

    The summary still prints in all of those cases. LogWriter also exposes no accessor for the finalized total — runLog is private and finalize() returns the file path, not the log.

    So the shape that satisfies both: the orchestrator already owns the run's start and end, so it should compute wall clock once and hand it to RunResult, with the log writer recording that same clock. One producer, two consumers — which is what AC-2 now asks for. Sourcing one display from the other's output would just recreate the coupling that let this drift in the first place.

    Blast radius is limited to the CLI display. The MCP path is already correct: mcp/tools/run.ts:264 reads runLog.summary.totalDurationSeconds, the stored wall clock. commands/logs.ts:133, commands/stats.ts:187 and :265 likewise read the stored value. run-display.ts is the only consumer that recomputes, and it does so once at :191 for both branches — the renderer path at :199 and the fallback at :206. Fixing that one computation covers both.

    Per-issue totals are not affected. log-writer.ts:191 sums a single issue's phases, which is correct — phases within an issue are sequential. Only the run-level roll-up is wrong. No stored data needs migrating.

  4. admarble commented on Jul 29, 2026

    @admarble
    ContributorAuthor

    #867 — fix(cli): post-run SUMMARY duration sums per-issue times instead of wall clock — 4-issue parallel run reported 1h 12m for 36m 18s
    Open · bug, cli
    ────────────────────────────────────────────────────────────────

    → PROCEED — Verified against main — run-display.ts:191 reduces per-issue durationSeconds, which double-counts under p-limit concurrency

    Commands:
    sequant run 867 -Q

    spec → exec → qa · 8 ACs

    Flags:
    -Q AC-2 makes this orchestrator plumbing into RunResult, not a one-line display fix

    Considered:
    --testgen AC-5/AC-6 specify the seam the test must drive (displaySummary from a RunResult) — a stub aimed at the renderer would pass against unfixed code
    ────────────────────────────────────────────────────────────────
    ⚠ AC-3 rules out sourcing the value from the log: --no-log and logWriter=null paths still print the summary
    ────────────────────────────────────────────────────────────────

  5. admarble commented on Jul 29, 2026

    @admarble
    ContributorAuthor

    #867 — fix(cli): post-run SUMMARY duration sums per-issue times instead of wall clock — 4-issue parallel run reported 1h 12m for 36m 18s
    Open · bug, cli
    ────────────────────────────────────────────────────────────────

    Supersedes prior assess from 2026-07-29 (PROCEED)

    → PROCEED — Re-verified against main — run-display.ts:190 still reduces per-issue durationSeconds, which double-counts under p-limit concurrency

    Commands:
    sequant run 867 -Q

    spec → exec → qa · 8 ACs

    Flags:
    -Q AC-2 makes this orchestrator plumbing into RunResult, not a one-line display fix

    Considered:
    --testgen AC-5/AC-6 specify the seam the test must drive (displaySummary from a RunResult) — a stub aimed at the renderer would pass against unfixed code
    ────────────────────────────────────────────────────────────────
    ⚠ AC-3 rules out sourcing the value from the log: --no-log and logWriter=null paths still print the summary
    ⚠ Same-run sibling of #866 but a different code path (run-display vs Ink TUI) — safe to run in parallel, do not conflate while fixing either
    ────────────────────────────────────────────────────────────────

  6. admarble commented on Jul 29, 2026

    @admarble
    ContributorAuthor

    Complexity: Standard (8 ACs, 2 directories)

    AC Quality Check

    All 8 ACs are measurable and testable — this is an exemplary bug spec (root cause located, wrong-vs-right code cited, a measured fixture, and a mutation-verification requirement baked in). No vague/unmeasurable/open-ended patterns. AC-5/6/7/8 are all facets of one regression test, not four separate tests — the plan treats them as a single test with four assertions.

    One title/body tension note (informational, not blocking): AC-8's "recorded in the commit message or PR body" is a process gate, not a runtime behavior — it's verified by inspecting the PR, per the repo's mutation-verification rule (CLAUDE.md, #830/#834).


    Scope Assessment

    Non-Goals: Not stated as a header, but the body draws the boundary explicitly: the stored log is correct and no historical data is corrupted — this is display-layer only. Related #866 (Ink TUI ElapsedTimer) is called out as independent and out of scope.

    Metric Value Status
    Feature count 1 (correct wall-clock duration) ✅
    AC items 8 (4 are one regression test) ✅
    Directory spread 2 (src/commands/, src/lib/workflow/) ✅

    Verdict: ✅ SCOPE_OK


    Acceptance Criteria

    AC-1: SUMMARY header shows wall-clock, not per-issue sum

    Verification: Unit Test
    Scenario: Given a RunResult with per-issue durations summing to ~72m but a wall clock of ~36m → When displaySummary(result) runs → Then the header renders the wall-clock figure.
    Root cause: src/commands/run-display.ts:191 results.reduce((s,r)=>s+durationSeconds) double-counts overlapping parallel issues.

    AC-2: Wall clock computed once by the orchestrator; both summary and log derive from it

    Verification: Unit Test
    Scenario: Given the orchestrator owns run start/end → When a run finishes → Then a single wall-clock value flows to both the printed summary (via RunResult) and the log, with no consumer re-summing per-issue durations.
    Assumptions: RunOrchestrator.run() (run-orchestrator.ts:648) is the single owner of the run's start/end; adding a run-level runStartedAt there is the natural home. finalizeRunLog (run-log-schema.ts:409) already does (end-start)/1000 correctly — the fix aligns the summary and metrics to that same wall-clock notion, sourced from one origin timestamp.

    AC-3: Correct under --no-log and when log init fails

    Verification: Unit Test
    Scenario: Given mergedOptions.noLog (or logWriter caught-and-nulled at run-orchestrator.ts:706) → When the summary renders → Then it still shows wall clock.
    Assumptions: The wall-clock value MUST be independent of logWriter (it can be null). ⚠️ This is the load-bearing constraint: it forces the timestamp to live on the orchestrator, not the log.

    AC-4: Sequential (concurrency 1) summary unchanged

    Verification: Unit Test
    Scenario: Given a concurrency-1 RunResult where per-issue sum ≈ wall clock → When rendered → Then the figure matches the pre-fix output (within rounding).

    AC-5: Parallel run with overlapping durations prints wall clock (>2× fixture)

    Verification: Unit Test
    Scenario: Given a 3-concurrent fixture whose per-issue sum exceeds wall clock by >2× → When displaySummary runs → Then it prints wall clock, so summing cannot satisfy the assertion.

    AC-6: Test drives displaySummary from a RunResult, asserts rendered duration

    Verification: Unit Test
    Scenario: The test calls displaySummary(runResult) (through the capture harness in run-display.test.ts:52/67) and asserts on what displaySummary computed/rendered — not a direct renderSummary({totalDurationSeconds}) call, which would test the renderer and pass against unfixed code.
    Assumptions: Existing captureSummaryInput grabs the SummaryRenderInput that displaySummary computed — asserting its totalDurationSeconds is valid because it's driven end-to-end from a RunResult through the bug site. Asserting the captured stdout string is equally valid.

    AC-7: sequant logs --last 1 and live SUMMARY agree, from one shared fixture

    Verification: Unit Test
    Scenario: Given one fixture with a fixed start/end → When both the log render (logs.ts:133) and displaySummary derive duration → Then both print the same value.
    Assumptions: Guaranteed by threading a single origin timestamp so both compute (end-start)/1000 identically.

    AC-8: Regression test is mutation-verified

    Verification: Manual Test (process gate)
    Scenario: Restore the reduce sum at run-display.ts:191 → confirm exactly the AC-5 test fails → restore fix → record in commit/PR body. Per CLAUDE.md gate-test rule.


    Implementation Plan

    Phase 1: Single source of truth in the orchestrator

    1. In RunOrchestrator.run() (run-orchestrator.ts:648), capture const runStartedAt = Date.now() at the top (before services/log setup, so it's independent of logWriter — AC-3).
    2. Just before assembling the RunResult (run-orchestrator.ts:1173), compute const wallClockDurationSeconds = (Date.now() - runStartedAt) / 1000 and add it as a new RunResult field (run-orchestrator.ts:272 interface). Also handle the early empty-issue return (:662) with 0.
    3. Single-origin for the log (AC-2/AC-7): thread runStartedAt into LogWriter so the log's stored startTime shares the orchestrator's origin (pass through the LogWriter constructor/initialize → createEmptyRunLog at run-log-schema.ts:320, which currently self-stamps new Date()). This makes finalizeRunLog's wall clock and the summary's wall clock provably equal.

    Phase 2: Consumers derive, never re-sum

    1. displaySummary (run-display.ts:183): replace the reduce at :191 with result.wallClockDurationSeconds. Delete the sum.
    2. recordMetrics (run-orchestrator.ts:1584) — sibling site, same bug (see Open Questions): switch its duration from the per-issue reduce to the wall-clock value.

    Phase 3: Regression test + mutation proof

    1. Add the AC-5/6/7/8 test to src/commands/run-display.test.ts: a 3-concurrent RunResult fixture where per-issue sum >2× wall clock; drive displaySummary; assert wall clock in the rendered output; add the AC-7 cross-check that the same fixture's log render matches.
    2. Mutation-verify (AC-8): restore the reduce, confirm only the AC-5 test fails, restore, record in the PR body.

    Design Review

    1. Where does this logic belong? The orchestrator — it is the only component that brackets the whole run (run() owns setup→execute→finalize). Per-issue timings live on IssueResult; the run wall clock has no owner today, which is the root defect. RunResult is the right carrier to the display layer.
    2. What's the simplest correct approach? One runStartedAt timestamp + one subtraction, surfaced on RunResult; consumers read it. Rejected: (a) computing wall clock as max(issueEnd) - min(issueStart) from per-issue data — fragile, and there's no per-issue wall-start recorded; (b) having displaySummary read the log — violates AC-3 (--no-log).
    3. What existing pattern does this follow? Mirrors finalizeRunLog/finalizePhaseLog (run-log-schema.ts:389/415), which already compute (end-start)/1000. The fix generalizes that same wall-clock pattern to the run level and makes the display reuse it.
    4. What would a senior reviewer challenge? "Why not just fix the one reduce in run-display.ts?" — because that leaves the identical bug in recordMetrics:1584 and gives no single source of truth (AC-2), so summary and log could still drift. "Do you really need to thread the timestamp into the log?" — only to make AC-7's equality exact rather than approximate; the alternative (both compute independently from near-identical starts) differs by sub-second and could flake a strict equality assertion.

    Feature Quality Planning

    All standard checks pass. Notable items:

    • Sibling site (recordMetrics:1584): the identical reduce-sum double-counts the metrics duration under --parallel. Same root cause, trivially co-located — folding it into this fix is proportionate (Phase 2, step 5). Flagged rather than silently widened — see Open Questions.
    • AC-4 guard: keep a concurrency-1 assertion so the fix is proven a no-op for sequential runs (sum ≈ wall clock there).
    • Rounding parity: finalizeRunLog keeps fractional seconds (2178.334); the summary renderer formats to 36m 18s. Ensure the shared value is passed unrounded and each renderer formats as it does today, so AC-7's equality holds at the source value.

    Derived ACs

    Source Derived AC Priority
    Sibling-site scan Metrics duration (recordMetrics:1584) uses wall clock, not per-issue sum Medium

    Open Questions

    1. Fold the recordMetrics:1584 sibling into this fix? — Recommendation: yes. It's the same root cause one function away, and once wallClockDurationSeconds exists the change is a one-liner. Impact if skipped: the metrics store keeps silently double-counting parallel-run durations, undermining any later log-mining (project_data_driven_optimization). If you'd rather keep the PR laser-focused on the SUMMARY defect, I'll file it as a fast follow instead.
    2. Thread runStartedAt into the log, or let the log keep its own start? — Recommendation: thread it, for an exact AC-7 equality. If you prefer minimal blast radius, we leave the log's start as-is and AC-7 asserts equality within a 1s tolerance — but a tolerance on a "same run, same number" assertion reads as a smell.

    Recommended Workflow

    Phases: spec → exec → qa
    Quality Loop: disabled (SCOPE_OK, single-root-cause bug)
    Reasoning: Focused display-layer bug; ACs are Unit-Test-verifiable. Skipping testgen — the regression test is prescribed precisely by AC-5/6/8, so it's authored directly in exec rather than stubbed. No test phase (no UI/browser surface — CLI stdout). No security-review.


    Label Review

    Current: bug, cli
    Recommended: bug, cli (no change)
    Reason: Accurate. Not complex/refactor — one root cause, ~2 directories.
    Quality Loop: Won't auto-enable (SCOPE_OK, no SCOPE_WARNING).

  7. added
    planned
    on Jul 29, 2026
  8. admarble commented on Jul 29, 2026

    @admarble
    ContributorAuthor

    /exec — Implementation complete (PR #868)

    Wall clock is now computed once by the orchestrator and read by both the summary and the metrics record; the run log shares the same origin.

    AC Coverage

    AC Status Evidence
    AC-1 SUMMARY = wall clock, not per-issue sum ✅ run-display.ts reads RunResult.wallClockDurationSeconds
    AC-2 computed once; both derive from it ✅ runStartedAt → RunResult + log (threaded origin) + recordMetrics
    AC-3 correct under --no-log / log-init failure ✅ runStartedAt captured before log setup, independent of logWriter
    AC-4 sequential run unchanged ✅ dedicated no-op test (sum ≈ wall clock)
    AC-5 3-concurrent >2× fixture prints wall clock ✅ 6×600s summed (3600s) vs 1200s wall clock
    AC-6 drives displaySummary from a RunResult ✅ via capture harness, not renderSummary({totalDurationSeconds})
    AC-7 sequant logs + SUMMARY agree, one fixture ✅ shared-origin cross-check through finalizeRunLog
    AC-8 mutation-verified ✅ see below

    Derived AC (spec sibling-site scan): recordMetrics duration now uses wall clock, not the per-issue sum — ✅ addressed.

    Files changed

    • src/lib/workflow/run-orchestrator.ts — runStartedAt origin, RunResult.wallClockDurationSeconds, recordMetrics derives from it, threads origin into LogWriter
    • src/commands/run-display.ts — reads the wall-clock value; reduce deleted
    • src/lib/workflow/log-writer.ts / run-log-schema.ts — startTime threading so the log shares the run origin
    • src/commands/run-display.test.ts — regression + AC-4 tests
    • CHANGELOG.md — Fixed entry

    Mutation verification (AC-8)

    Restoring the reduce sum at run-display.ts fails exactly the gate test (prints wall clock for a >2× parallel fixture; logs and SUMMARY agree — expected 3600 to be 1200); the AC-4 sequential test stays green. Fix restored.

    Checks

    • npm run build ✅ · npm run lint ✅ · targeted vitest (run-display, run-orchestrator, log-writer, run-log-schema) 130 passed ✅

    Quality Plan Alignment

    Dimension Addressed Notes
    Sibling-site fix 1/1 recordMetrics duration
    AC-4 no-op guard 1/1 sequential test
    Rounding parity ✅ shared value passed unrounded; each renderer formats as before

    Next: /qa.

  9. admarble commented on Jul 29, 2026

    @admarble
    ContributorAuthor

    QA Review for Issue #867

    Reviewed inline (230-line diff, sub-600 → inline for accuracy over worktree-reading sub-agents).

    AC Coverage

    AC Source Description Status Notes
    AC-1 Original SUMMARY header = wall clock, not per-issue sum ✅ MET run-display.ts:196 reads result.wallClockDurationSeconds; reduce deleted
    AC-2 Original Wall clock computed once by orchestrator; summary + log derive from it ✅ MET run-orchestrator.ts:663 runStartedAt origin → :1177 single value → RunResult (summary) + metrics; log's startTime threaded (:710) so finalizeRunLog derives from the same start. Matches the spec-approved "one origin" design (Open Q#2)
    AC-3 Original Correct under --no-log / log-init failure ✅ MET runStartedAt captured before the log-writer block; value never touches logWriter
    AC-4 Original Sequential run unchanged ✅ MET Test "leaves a sequential run's duration unchanged" — wall clock 300 == sum 300
    AC-5 Original Parallel >2× fixture prints wall clock ✅ MET 6×600s = 3600s sum vs 1200s wall clock (3×); fixture guard asserts >2×
    AC-6 Original Drives displaySummary from a RunResult, not renderSummary({...}) ✅ MET captureSummaryInput + captureStdout both route through the bug site; no direct renderSummary call
    AC-7 Original sequant logs and SUMMARY agree, one shared fixture ✅ MET Test derives the log via finalizeRunLog(createEmptyRunLog({startTime})) under a fixed clock and the summary via wallClockDurationSeconds, asserts both == 2178.334
    AC-8 Original Regression test mutation-verified ✅ MET Independently re-verified in QA: restoring the reduce fails exactly the gate test (expected 3600 to be 1200) while the AC-4 test stays green; recorded in commit + PR body
    AC-D1 Derived (sibling scan) recordMetrics duration uses wall clock ✅ MET run-orchestrator.ts:1614 totalDuration = wallClockDurationSeconds

    Coverage: 9/9 met (8 original + 1 derived)


    Quality Plan Verification

    Dimension Planned Addressed Status
    Sibling-site fix (metrics) 1 1 ✅ Complete
    AC-4 no-op guard 1 1 ✅ Complete
    Rounding parity 1 1 ✅ Complete (value passed unrounded; each renderer formats as before)

    Quality Plan Status: Complete


    CI Status

    Check State Impact
    build (22.x) SUCCESS ✅
    typecheck SUCCESS ✅
    node-floor-guard SUCCESS ✅
    validate-skills SUCCESS ✅
    validate-plugin SUCCESS ✅

    CI Summary: 5 passed, 0 pending, 0 failed. No CI-dependent ACs.


    Quality Metrics

    Metric Value Status
    Type issues (any) 0 OK
    Deleted tests 0 OK
    Files changed 6 OK
    Lines +219 / -11 -

    Test Coverage Analysis

    Changed File Tier Has Tests?
    src/commands/run-display.ts Standard ✅ run-display.test.ts (+2 new #867 tests)
    src/lib/workflow/run-orchestrator.ts Standard ⚠️ No direct run() unit test — wallClockDurationSeconds production is covered by code review + the display-seam test, not an end-to-end orchestrator test
    src/lib/workflow/log-writer.ts Standard ✅ log-writer.test.ts; startTime threading exercised via AC-7 test
    src/lib/workflow/run-log-schema.ts Standard ✅ createEmptyRunLog({startTime}) exercised by AC-7 test

    Coverage: display seam + log equivalence directly tested; orchestrator producer verified by construction.


    Code Review

    Strengths:

    • Root cause fixed at the right layer — orchestrator owns the run bracket; consumers read one value.
    • Comments state intent (why reduce was wrong, why the origin is captured pre-log-setup) rather than restating the code.
    • Mutation gate is genuine (drives the bug site, not the renderer) and passes the tautology bar.
    • All 7 early-return paths get the field consistently; no fallback-to-sum smell.

    Issues: None blocking.

    Suggestions: See sibling-site finding below.


    Risk Assessment

    • Likely failure mode: Summary and log share the run start origin but each computes (end − start) with its own end timestamp (log at finalizeRunLog, summary at :1177), differing by sub-millisecond. Both floor to whole seconds, so no display divergence — but AC-2's "single value" is satisfied at the origin, not as one shared final number. This is the spec-approved design (Open Q#2), not a defect.
    • Not tested: No end-to-end test spins up RunOrchestrator.run() and asserts the returned wallClockDurationSeconds or the log-origin threading through the real path; AC-7 simulates the log via finalizeRunLog directly. Acceptable per AC-6's chosen seam, but the orchestrator→RunResult→log wiring is verified by review, not by a test.
    • Sibling sites considered (cross-file, §5): ⚠️ src/lib/ci/outputs.ts:29 (formatMultiOutputs) and :104 (formatSummary) carry the identical results.reduce((sum, r) => sum + (r.durationSeconds ?? 0), 0) pattern, feeding the GitHub Actions duration output and the step-summary "Total duration". Same root cause — double-counts under --parallel. The issue's "blast radius is limited to the CLI display" was incomplete: this is a third recompute site. It has no in-repo production caller today (exported CI-integration API via src/lib/ci/index.ts), so the bug is latent here but real for any GitHub Actions consumer on a parallel run. Out of this PR's AC scope (different consumer; can't reuse wallClockDurationSeconds without an API + caller change). Recommend a follow-up issue — see Next Steps.
    • Sibling-line audit (intra-file, §4 Q5): recordMetrics was the intra-file sibling; already folded in (AC-D1). No other durationSeconds sums in run-orchestrator.ts. log-writer.ts:205 sums a single issue's phases (correct — phases are sequential); logs.ts:393 / stats.ts:503 sum across runs (intentional aggregates).

    Trust-Boundary Check

    Finding: Clean — the diff implements only the product requirement (correct wall-clock duration). The issue body and spec comments are legitimate maintainer requirements/planning; no agent-directed instruction was embedded or acted on.

    Status: Clean


    Behavior-Rule Survival Check

    Status: N/A — no AC triggers the behavior-rule heuristic (this is a value-correction fix, not a default/always/never/skip rule change).


    CHANGELOG Verification

    Check Status
    CHANGELOG.md exists ✅ Found
    User-facing changes ✅ Yes (fix: commit)
    [Unreleased] entry ✅ Present (under ### Fixed, includes #867)
    Entry format ✅ Valid

    Result: CHANGELOG requirements met


    Adversarial Re-Read

    Findings: Walked the diff adversarially: (1) the verbatim motivating example (run 21feec76 — 36m 18s vs 1h 12m) is an asserted fixture and passes; (2) the "evidence" is post-fix validation + a real mutation failure, not a pre-fix repro; (3) process state clean — no uncommitted work, 0 commits behind main; (4) sibling sites cited explicitly (§5 cross-file: ci/outputs.ts ×2; §4 intra-file: recordMetrics); (5) Non-Goals honored — no #866/Ink-TUI touch, no historical-data migration. One real gap surfaced: the ci/outputs.ts cross-file sibling (same root cause, out of AC scope) → maps to a follow-up issue, not a missing AC fixture.

    Status: Gaps Found


    Verdict: AC_MET_BUT_NOT_A_PLUS

    All 9 ACs (8 original + 1 derived) are MET, mutation-verified, CI-green, clean code — the PR correctly and completely fixes #867 for its stated scope and is mergeable. The step down from A+ is solely the adversarial re-read surfacing a real cross-file sibling of the same bug in src/lib/ci/outputs.ts (the GitHub Actions output layer), which the issue's blast-radius analysis missed. That is a follow-up recommendation, not an unmet AC — do not /loop this (there is no gap to close in-PR; the sibling needs its own issue).

    Documentation

    • N/A — bug fix (display-layer); CHANGELOG entry present. Run /docs 867 only if you want a feature note.

    Next Steps

    1. Merge-ready for fix(cli): post-run SUMMARY duration sums per-issue times instead of wall clock — 4-issue parallel run reported 1h 12m for 36m 18s #867. All ACs met; CI green.
    2. File a follow-up issue for src/lib/ci/outputs.ts:29 + :104 — same reduce-per-issue-duration double-count under --parallel, in the GitHub Actions duration output and step-summary. No in-repo caller today, so latent, but it fixes the class of bug. (Chose follow-up over widening this PR per §5 — the fix needs an API/caller change the CLI path doesn't provide.)
    3. Optional: an end-to-end RunOrchestrator.run() test asserting wallClockDurationSeconds would close the one coverage gap noted above.
  10. added
    needs-improvement
    on Jul 29, 2026
  11. added a commit that references this issue on Jul 30, 2026
  12. admarble commented on Jul 30, 2026

    @admarble
    ContributorAuthor

    QA Review for Issue #867 — re-run after gap closure

    Supersedes the prior QA (verdict AC_MET_BUT_NOT_A_PLUS at e1a9a5bf). Both gaps that prior review surfaced have been closed in-PR at 20ed7585 rather than deferred to follow-ups.

    What changed since the last review

    Gap (prior QA) Resolution
    Cross-file sibling src/lib/ci/outputs.ts:29 / :104 — identical reduce double-count in the GitHub Actions duration output and step-summary Total duration Fixed in-PR. formatMultiOutputs / formatSummary now take the run wall clock as a required argument; both reduces deleted. Required rather than optional-with-sum-fallback — a fallback leaves the defect where it is, and no-fallback-to-sum is the discipline the rest of the fix follows. Safe: no in-repo callers, src/index.ts does not re-export lib/ci, and the package exports map is "."-only so deep imports are blocked.
    No end-to-end test asserting the orchestrator's wallClockDurationSeconds Closed. New src/lib/workflow/run-orchestrator.test.ts (the file did not exist) drives the real RunOrchestrator.run() through the hermetic empty-issue seam and asserts the run bracket, including AC-3's --no-log path.
    — (found this pass) The wall-clock subtraction was restated at each of the seven return sites; collapsed into one wallClock() closure.

    AC Coverage

    AC Source Status Notes
    AC-1 Original ✅ MET run-display.ts reads result.wallClockDurationSeconds; reduce deleted
    AC-2 Original ✅ MET runStartedAt origin → RunResult + metrics + log startTime; now four consumers derive, none re-sum
    AC-3 Original ✅ MET Origin captured before log setup; now directly tested — produces the value under --no-log asserts logWriter === null and duration 600
    AC-4 Original ✅ MET Sequential no-op test; stays green through all three mutations
    AC-5 Original ✅ MET 6×600s = 3600s sum vs 1200s wall clock (3×); fixture guard asserts >2×
    AC-6 Original ✅ MET Driven via captureSummaryInput / captureStdout, not renderSummary({…})
    AC-7 Original ✅ MET Shared-origin cross-check through finalizeRunLog, both == 2178.334
    AC-8 Original ✅ MET Mutation-verified; results recorded in commit message and PR body
    AC-D1 Derived (sibling scan) ✅ MET recordMetrics duration uses wall clock
    AC-D2 Derived (QA sibling scan) ✅ MET ci/outputs.ts ×2 use wall clock — the gap this pass closed

    Coverage: 10/10 met.

    Mutation verification

    Each new gate test was mutation-verified by restoring the reduce it exists to catch, confirming exactly the expected tests fail, then restoring. Observed:

    1. formatMultiOutputs → restore the sum: exactly 1 of 14 fails — expected '3600' to be '1200'.
    2. formatSummary → restore the sum: exactly 1 of 14 fails — expected '…' to contain '**Total duration:** 1200s'.
    3. wallClock() → derive from per-issue data instead of the run bracket: all 3 of 3 producer tests fail — expected +0 to be 2178.334 / 45 / 600. All three assert the bracket, so all three are expected to catch it; recorded as 3, not 1.

    AC-4 stays green throughout. All mutations reverted.

    CI Status

    Check State
    build (22.x) SUCCESS
    typecheck SUCCESS
    node-floor-guard SUCCESS
    validate-skills SUCCESS
    validate-plugin SUCCESS

    5 passed, 0 pending, 0 failed. mergeable: MERGEABLE, 0 commits behind origin/main.

    Quality Metrics

    Metric Value Status
    Type issues (any) 0 OK
    Deleted tests 0 OK
    Files changed 8 OK
    Full suite 225 files, 4643 passed, 1 expected fail, 2 skipped OK

    Full suite was run (not just targeted) because an exported signature changed.

    Risk Assessment

    • Likely failure mode: The summary and the log share the run start origin but each computes (end − start) with its own end timestamp, differing sub-millisecond. Both floor to whole seconds, so no display divergence. This is the spec-approved design (Open Q#2), not a defect.
    • Not tested: The producer test covers the empty-issue seam, not a full multi-issue run through worktrees and executors — that path needs real git/network and is out of unit scope. The success-path assembly at run-orchestrator.ts:1185 is still review-verified, though it now shares the same wallClock() closure the tested early returns use, so the two cannot drift.
    • Sibling sites considered (cross-file, §5): ci/outputs.ts ×2 — now fixed, previously the outstanding gap. Re-scanned for the pattern: logs.ts:393 and stats.ts:503 sum across runs (intentional aggregates, not a run roll-up); log-writer.ts:205 sums one issue's phases (correct — phases are sequential); mcp/tools/run.ts:264, logs.ts:133, stats.ts:187/:265 read the stored wall clock. No recompute sites remain.
    • Sibling-line audit (intra-file, §4 Q5): recordMetrics folded in previously (AC-D1). All seven early returns now route through one closure, so a future exit cannot silently pick a different formula.

    Trust-Boundary Check

    Finding: Clean — the diff implements only product requirements (correct wall-clock duration). The issue body and comments are legitimate maintainer requirements and planning; no agent-directed instruction was embedded or acted on.

    Status: Clean

    Behavior-Rule Survival Check

    Status: N/A — no AC triggers the behavior-rule heuristic; this is a value correction, not a default/always/never/skip rule change.

    CHANGELOG Verification

    Check Status
    CHANGELOG.md exists ✅ Found
    User-facing changes ✅ Yes (fix: commits)
    [Unreleased] entry ✅ Present under ### Fixed, includes #867
    Entry format ✅ Valid; extended to name the ci/outputs.ts siblings

    Adversarial Re-Read

    Findings: (1) The verbatim motivating example (run 21feec76 — 36m 18s vs 1h 12m) remains an asserted fixture and passes. (2) Evidence is post-fix validation plus three real mutation failures, not a pre-fix repro — and the recorded mutation count was corrected to match what was actually observed (3 producer tests, not 1). (3) Process state clean: 0 commits behind origin/main, no uncommitted work, full suite run because an exported signature changed. (4) Sibling sites cited and re-scanned; no recompute sites remain. (5) Non-Goals honored — no #866/Ink-TUI touch, no historical-data migration.

    One item deliberately left as-is: the runResult() test helper in run-display.test.ts defaults wallClockDurationSeconds to the per-issue sum. That is intentional and documented — it preserves pre-#867 tests' rendered output — and the #867 tests all pass an explicit wall clock that diverges from the sum, so the default is never load-bearing for a duration assertion.

    Status: Clean

    Verdict: READY_FOR_MERGE

    All 10 ACs met (8 original + 2 derived). The gap that held the prior verdict at AC_MET_BUT_NOT_A_PLUS — the ci/outputs.ts cross-file sibling — is fixed in-PR, and the producer-coverage gap is closed with a test file that did not previously exist. Three mutation verifications recorded against observed output, CI green, full suite green, no recompute sites remaining.

    Next Steps

    1. Merge PR fix(#867): SUMMARY duration is run wall clock, not per-issue sum #868.
    2. No follow-up issues needed — both prior recommendations were closed in-PR.
  13. added
    ready-for-review
    and removed
    needs-improvement
    on Jul 30, 2026
  14. added a commit that references this issue on Jul 30, 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

    bugcliplannedready-for-review

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions