Repository navigation
Description
Tier: mechanical Found: 2026-09-30, QA of #1223 (PR #1240) and #1233 (PR #1239); tracker #1236 (closed). Revised the same day after a root-cause investigation: a third site was found and the impact statement was corrected.
Root cause. Two lists record one entry per attempt with no iteration index: phaseResults in runIssueWithLogging (every phaseResults.push: batch-executor.ts:1198, :1745, :2042) and the run log's issues[].phases[] (log-writer.ts:172; PhaseResult has no iteration field, types.ts:403-467). A quality-loop iteration re-runs the whole phase list (while at batch-executor.ts:1554), so a looped run holds [spec, exec, qa, loop, exec, qa]. Each consumer picks "first" or "latest" for itself. Several were already fixed one at a time with a hand-rolled reverse scan: deriveFailureCategory (batch-executor.ts:628-630), #1223's exec output (:2368-2370) and #766's scan in src/commands/run-display.ts. Three consumers still take the first match.
The three stale sites:
batch-executor.ts:2235:const qaVerdict = phaseResults.find((p) => p.phase === "qa")?.verdict;decides the terminal status.batch-executor.ts:2363: the same expression, feeding the PR-body QA note (fix(run): AC_MET_BUT_NOT_A_PLUS QA verdict misrouted into quality loop → fails with no PR (should break to PR) #749).src/mcp/tools/run.ts:253:issue.phases.find((p) => p.phase === "qa")in the run log feeds the MCPsequant_runresult'sverdict,acMet/acTotal,gapsandfindings(feat(mcp): sequant_run result carries each issue's QA summary and findings #1200).
Impact, which is worse than "stale". AC_NOT_MET fails the qa phase and triggers the loop. NEEDS_VERIFICATION counts as success (phase-executor.ts:1251-1269) and ends it (batch-executor.ts:2177-2179). So the sequence qa AC_NOT_MET → loop → qa NEEDS_VERIFICATION is reachable, and it:
- records
ready_for_merge(the first verdict isn't NEEDS_VERIFICATION), skipping NEEDS_VERIFICATION maps to ready_for_merge, blocking QA re-runs; MCP sequant_run ignores force #972'sawaiting_verificationhold for human verification; - puts a
QA verdict: AC_NOT_METnote in the PR body; - makes the MCP result report
AC_NOT_METwith the first pass's gaps and findings.
No real log on this machine has a looped run with two qa entries, so reachability rests on reading the code. The ACs below prove it with fixtures.
AC
- AC-1: A shared accessor (for example
latestPhaseResult(results, phase); ES2022 target, so nofindLast) returns the last result for a phase, and all three sites use it. In a[qa AC_NOT_MET, loop, qa NEEDS_VERIFICATION]run the issue recordsawaiting_verification. Evidence:npx vitest run src/lib/workflow/batch-executor.test.ts - AC-2: In the same loop fixture, the PR body's QA note carries the latest verdict (
NEEDS_VERIFICATION). Evidence:npx vitest run src/lib/workflow/batch-executor.test.ts, assertingcreatePR's qaVerdict argument - AC-3: Given a run log whose issue has two qa entries (
AC_NOT_METthenNEEDS_VERIFICATION), the MCP result reports the latest verdict and that entry's summary. Evidence:npx vitest run src/mcp/tools/run.test.ts - AC-4: The existing hand-rolled reverse scans (
deriveFailureCategory, fix(pr): sequant run PRs double the conventional prefix in the title and ship a placeholder body #1223's exec output, the fix: recovered phase failure still reports failed — live card, summary, and log disagree #766 display) use the same accessor, and single-pass behaviour is unchanged (the NEEDS_VERIFICATION maps to ready_for_merge, blocking QA re-runs; MCP sequant_run ignores force #972, fix(run): AC_MET_BUT_NOT_A_PLUS QA verdict misrouted into quality loop → fails with no PR (should break to PR) #749 and feat(mcp): sequant_run result carries each issue's QA summary and findings #1200 tests stay green). Evidence:npx vitest run src/lib/workflow/batch-executor.test.ts src/lib/workflow/ready-gate-run.test.ts src/mcp/tools/run.test.ts
Deliberately unchanged: stats.ts:894 measures the first-pass qa rate on purpose, and ready-gate.ts:811-833 tracks its own final verdict.
Optional: tag PhaseResult/PhaseLog with iteration, so readers of the run log (for example jq '.issues[].phases[]|select(.phase=="qa")') stop inferring it from position.
Graph metadata
- No dependency edges. It touches the same
batch-executor.tsregion as decision(run): a sequant run where no qa ran still ends with a PR — draft+note, require qa, or unchanged (blocked by #1247) #1246, so don't run the two in parallel.
May touch
src/lib/workflow/batch-executor.ts,src/lib/workflow/batch-executor.test.tssrc/mcp/tools/run.ts,src/mcp/tools/run.test.tssrc/commands/run-display.ts(the fix: recovered phase failure still reports failed — live card, summary, and log disagree #766 latest-attempt scan) and its test- a small shared helper module for the accessor, with its own test
Activity
[-]fix(run): status and PR-body QA note use the first qa verdict, stale after a quality-loop iteration[/-][+]fix(run): status, PR-body QA note and MCP result use the first qa verdict — a looped AC_NOT_MET→NEEDS_VERIFICATION records ready_for_merge[/+]admarble commentedon Oct 3, 2026
Runner context (2026-10-03, main @ 52395ca)
The line numbers moved after #1247 and #1249 merged. Current sites:
export function latestPhaseResult(phaseResults: PhaseResult[], phase: Phase)tosrc/lib/workflow/batch-executor.ts, just abovederiveFailureCategory.openOrUpdatePRand the post-QAfollowupsargument already use it.PhaseLog[](needed forsrc/mcp/tools/run.ts), and re-export or update the import.batch-executor.ts:2394: terminal status (qaVerdict).batch-executor.ts:2513:qaVerdictpassed toopenOrUpdatePRfor the PR-body QA note.src/mcp/tools/run.ts:253: the MCP result.deriveFailureCategory(batch-executor.ts, just below the accessor) and the fix: recovered phase failure still reports failed — live card, summary, and log disagree #766 scan insrc/commands/run-display.ts.createPRcall'sqaVerdictargument (the after-exec call passes none).batch-executor.test.tsalready models the two-call shape in its "AC-5" (fix(run): sequant run has two PR producers — exec opens the PR itself and createPR returns it untouched, dropping the QA note, ready-gate report and summary #1247) describe block.Prior fixes / producers: the issue already names the class (three hand-rolled fixes plus three stale sites) and the one-accessor owner. That is the right scope. The optional
iterationfield stays optional; if you add it, say so in the PR.Launch constraints:
npm testin exec or QA, since it hits the 30-minute phase wall and CI runs it. Run the AC's test files,npm run buildandnpx tsc --noEmit.batch-executor.test.ts/run.test.tsqueuechild_processmocks in order. A new git call shifts them.Refs, with no closing keyword, even in examples.failedTeststarts with the test file path.admarble commentedon Oct 4, 2026
Complexity: Standard (4 ACs, 4 directories)
AC Quality Check
All four ACs are single-line with an
Evidence:clause. Two notes:mainand pass only after the fix. The[qa AC_NOT_MET, loop, qa NEEDS_VERIFICATION]run recordsready_for_mergetoday, so that part is non-vacuous.Scope Assessment
Non-Goals:⚠️ No
## Non-Goalsheading. "Deliberately unchanged" (stats.ts:894,ready-gate.ts:811-833) serves as the boundary. The optionaliterationfield is out of scope unless added deliberately.lib/workflow,mcp/tools,commands, shared helper)Verdict: ✅ SCOPE_OK
Acceptance Criteria
AC-1: Shared accessor; terminal status uses the latest qa verdict
Verification: Unit + Integration Test (
batch-executor.test.ts)Scenario: Given phaseResults
[qa AC_NOT_MET, loop, qa NEEDS_VERIFICATION]→ When the issue finishes → Then status isawaiting_verification.Assumptions:
latestPhaseResultalready exists (#1249,batch-executor.ts:660). The work is to move and generalize it, not to write a second one.AC-2: PR-body QA note carries the latest verdict
Verification: Integration Test
Scenario: Same fixture → Then the post-QA
createPRcall'sqaVerdictargument isNEEDS_VERIFICATION. The after-exec call passes none.batch-executor.test.tsalready models the two-call shape in its #1247 AC-5 block.AC-3: MCP result uses the latest qa entry
Verification: Unit Test (
run.test.ts)Scenario: Given a RunLog issue with two qa
PhaseLogs → Thenverdict,acMet/acTotal,gapsandfindingscome from the second entry.AC-4: Hand-rolled reverse scans use the shared helper
Verification: Regression Test (existing suites) plus a structural grep
Scenario:
deriveFailureCategory, therun-display.tsfailed-phase scan (~:105), andbuildRateLimitHaltNotice(~:160) call the shared helper. #972, #749 and #1200 tests stay green.Implementation Plan
Phase 1: Shared helper
src/lib/workflow/latest-phase.ts) holding a genericlatestPhaseResult<T extends { phase: string }>(items: readonly T[], phase). Add alatestWhere(items, predicate)sibling for the "last failing non-loop" scans. Both use a reverse scan, sincefindLastis ES2023 and the tsconfig pins ES2022.batch-executor.ts: import it and re-exportlatestPhaseResultso the feat(qa): enforce the follow-up ledger — every deferred item resolves to filed/fixed/dropped; sibling scans search the defect class #1249 call sites and tests keep working. Add a unit test file for the helper.Phase 2: Switch the stale readers (order matters,
batch-executor.tsregions overlap #1246)batch-executor.ts:2394(terminal status) and:2513(PR-body QA note) use the latest qa result.src/mcp/tools/run.ts:253uses the helper onissue.phases, soverdictand summary come from one entry.deriveFailureCategoryand inrun-display.ts(both sites).Phase 3: Tests
batch-executor.test.ts(AC-1 and AC-2). Do not add git calls, becausechild_processmocks are queued in order.run.test.ts(AC-3).npx vitest runon the AC files,npm run buildandnpx tsc --noEmit. Skip the fullnpm test(30-minute wall; CI runs it).Design Review
src/lib/workflow/, imported bybatch-executor,mcp/toolsandcommands. It must not live inbatch-executor.ts, becauserun.tsimporting the whole orchestrator is the wrong dependency direction.iteration(the issue marks it optional, and positional "latest" is enough for all consumers).deriveFailureCategory. That is ≥2 prior fixes, so this issue fixes the class with one helper rather than adding another local patch. This matches the issue's scope. The leftover class members,stats.ts:894andready-gate.ts, are deliberate and named.findLast?" ES2022 target. "Why does AC-4 need a predicate form?" See Open Questions.phaseResults.pushsites inbatch-executor.tsandlog-writer.ts:172, which maps one to the other. Consumers: the three stale sites plus the four scans above. A whole-repo grep for.find((p) => p.phase ===should be re-run in exec to catch stragglers outside the listed files.Feature Quality Planning
Standard checks pass. Notable items:
Mutation-verified:marker withfailedTeststarting with the test file path.PhaseResultshapes.Derived ACs
phaseResults.find((p) => p.phase === "qa")orphases.find(... "qa")remains insrc/outside the "deliberately unchanged" files. Evidence:grep -rn 'find((p) => p.phase === "qa")' src/ --include=*.tsreturns onlystats.tsOpen Questions
latestWhere) next tolatestPhaseResultin the same module, and treat that as satisfying AC-4. Impact if wrong: forcing them through a per-phase accessor changes behaviour.iterationfield onPhaseResult/PhaseLog. Recommendation: skip it. It changes the run-log schema for no consumer in this fix. Impact: none for the ACs.Recommended Workflow
Phases: exec → qa
Quality Loop: disabled
Reasoning: Mechanical bug fix with unit and integration ACs. There is no UI, and testgen adds little because the fixtures are specified in the ACs. The #1249 accessor already exists, so the change is small. Tell exec to skip the full suite.
Label Review
Current: bug
Recommended: bug (no change)
Reason: Matches the plan.
Quality Loop: Won't auto-enable.
admarble commentedon Oct 4, 2026
QA Verdict: NEEDS_VERIFICATION
AC coverage: 5/5 met
Gaps:
Needs human review:
admarble commentedon Oct 4, 2026
Runner verification and follow-up ledger (PR #1294)
tscis clean..find()fails exactly that AC's new test. Details are in the PR body.testcheck still running at review time (see the CI result on the PR).Ledger
iterationfield: dropped, as the spec recommended. Position order holds today.latestPhaseResult'sphaseis now typedstring, notPhase: dropped. It's polish with no runtime effect, and the generic type has to accept the run log'sPhaseLog.## Summary, which dropped exec's AC table and mutation markers. Filed fix(run): PR body falls back to the placeholder when exec writes no "## Summary" heading, dropping exec's mutation markers and AC table #1297.chore(#1351): merge main after v2.20.0