Repository navigation
Closed
Labels
bugSomething isn't working
Description
Tier: judgment Found: 2026-10-01, QA of #1250 (PR #1253), finding 2: "A spec-divergence halt with a successful spec exit is persisted as spec completed in state, run log and progress."
Problem. A ladder halt (SPEC_DIVERGENCE, DIVERGENCE_SUSPECT, TOP_OF_LADDER) stops the run, but none of the places a reader checks afterwards records why.
- The halting phase's row says
completed/successwhen the agent exited cleanly.updatePhaseStatusruns before the halt check, and the run log and progress events copyresult.success. - The issue result is
success: falsewithfailureCategory: undefined, becausederiveFailureCategorylooks for a failed phase and finds none. - The evidence bundle only goes to
log()(stdout). It reaches the MCP caller only throughrawOutput, which the caller may truncate.
So sequant status and the MCP result show "failed, every phase succeeded", with no reason. That is the same shape as the uncommitted-exec case (#879), where only the issue-level status gave it away.
Prior fixes / producers
- Producers of a halt (
batch-executor.tson main after feat(spec): Design Review stops on recurrence and lists producers; spec can halt before exec when the AC's lever is wrong #1250 lands):- the spec path (feat(spec): Design Review stops on recurrence and lists producers; spec can halt before exec when the AC's lever is wrong #1250);
- the loop path's
SPEC_DIVERGENCEcheck (feat(run): SPEC_DIVERGENCE escape hatch, ladder halts with evidence bundles, docs, rigged real run (#971 part B) #995); DIVERGENCE_SUSPECTandTOP_OF_LADDER(feat(run): SPEC_DIVERGENCE escape hatch, ladder halts with evidence bundles, docs, rigged real run (#971 part B) #995 / feat(run): model escalation ladder on capability-bound non-convergence #971).
All four build anEvidenceBundlethrough onebuildBundleand print it. None returns or persists it.
- Consumers:
IssueResult, the run log (run-log-schema.ts), state (state-schema.ts:outcome/divergenceAcsalready exist on phase markers), the MCPsequant_runresult andsequant status. - Prior fixes: feat(run): SPEC_DIVERGENCE escape hatch, ladder halts with evidence bundles, docs, rigged real run (#971 part B) #995 built the bundle and printed it; nothing recorded it. One producer function feeds every halt, so this is one change at that owner, not four.
AC
- AC-1: Every ladder halt (spec path, loop SPEC_DIVERGENCE, DIVERGENCE_SUSPECT, TOP_OF_LADDER) returns an IssueResult with failureCategory "ladder_halt", an abortReason naming the LadderHaltReason, phase and declared ACs, and the EvidenceBundle; the run log's issue entry records status "failure", the abortReason and the bundle. No new top-level haltReason field on IssueResult (owner decision 2026-10-04: reuse abortReason, the fifth recurrence after feat(orchestrator): preserve partial output for turn-capped phases in phase-executor #739/Nested phase claude that hangs after its turn is killed at ~106s, taking down the parent sequant run #856/fix(run): exec that leaves work uncommitted reports success and the run passes with no PR — #534's empty-branch escape, reopened via a new route #879/fix(run): phase-restricted runs without an implementing phase must skip PR creation — spec-only batches always report failed #920 is fixed at the class). Evidence: npx vitest run src/lib/workflow/batch-executor.test.ts with one case per halt path
- AC-2: A phase that declared SPEC_DIVERGENCE is recorded as failed, whatever its exit status, through one decision shared by every writer: state stores status "failed" with outcome "SPEC_DIVERGENCE" and divergenceAcs, and the run log's phase row and the progress event for that phase also read failure, so sequant status, the run log and progress agree. Evidence: npx vitest run src/lib/workflow/batch-executor.test.ts
- AC-3: The MCP
sequant_runper-issue result carrieshaltReasonand the declared ACs. Evidence:npx vitest run src/mcp/tools/run.test.ts
Graph metadata
- Blocked by: feat(spec): Design Review stops on recurrence and lists producers; spec can halt before exec when the AC's lever is wrong #1250 (its spec-path halt is one of the producers)
May touch
src/lib/workflow/batch-executor.ts,batch-executor.test.ts,run-log-schema.ts,state-manager.ts,src/mcp/tools/run.ts(+ test)
Metadata
Metadata
Assignees
Labels
bugSomething isn't working
Activity
admarble commentedon Oct 4, 2026
Upstream cause (research note)
Same root cause as earlier issues. An issue's outcome is worked out from its phase results.
deriveFailureCategory(batch-executor.ts:639) finds a failed phase or nothing. A ladder halt is the orchestrator's decision, not a phase failure, so the data model has no place for it.Earlier stops outside a phase hit the same gap and each got its own field:
cappedflagsuccess; it got an additive flag in the run logpr_creationfallback categoryExisting field.
IssueResult.abortReason(types.ts:508) and the run log'sabortReason(run-log-schema.ts:328) already exist.run-orchestrator.tsfills them in (chain-resume abort, skills pre-flight, rebase conflict) andci/outputs.tsrenders them. None of the four halt paths sets them.Suggested shape for AC-1. At the single
buildBundleowner, setabortReasonand a typed reason code. Better: one terminal-reason field onIssueResultthat the next stop outside a phase can reuse, instead of a fifth one-off field. Spec should treat this as a recurrence (#1250's Design Review rule).admarble commentedon Oct 4, 2026
Runner context (before
sequant run)abortReasonalready exists onIssueResultand in the run log, unused by any halt path. Spec: run the Design Review with that history. If the right owner is the issue-outcome model (one terminal-reason field), not four halt sites, say so. Don't add a fifth one-off field because the AC text nameshaltReason. If the AC wording blocks the right fix, stop and surface it.timeout, and only after a WIP commit. Run targeted vitest files otherwise (batch-executor.test.tsandrun.test.tsqueue git mocks in order; memory bug(exec): sequant run worktrees never record sequantBase, so the zero-diff/uncommitted guard compares against origin/main and a --base ahead of main disables it #1234). CI runs the full suite. QA: this note applies to you too. Put everySEQUANT_MUTATIONmarker and the AC table inside exec's final## Summary.admarble commentedon Oct 4, 2026
Complexity: Standard (3 ACs, 2 directories)
AC Quality Check
Evidence:clause. ✅haltReasononIssueResult. That is the fifth one-off "stop outside a phase" field (see Design Review Q3), and it would hold the same value twice: once ashaltReasonand again asbundle.reason. This is the divergence below.main. No halt path sets anything onIssueResult.PhaseStateSchemahas nooutcomeordivergenceAcs; they exist only onPhaseMarkerSchema(state-schema.ts:132,140).RunToolIssueSummary(src/mcp/tools/run.ts:46) has no halt field.Scope Assessment
Non-Goals:⚠️ No
## Non-Goalssection. Suggested: do not change halt behavior (thresholds, when the run stops). Do not refactor the existingcapped,prCreationErrorandlockedfields into the new shape.src/lib/workflow,src/mcp/tools)Verdict: ✅ SCOPE_OK
Dependencies: #1250 is closed, so its spec-path halt is on
main(batch-executor.ts:1474). Conflict risk: none. The worktrees that touchbatch-executor.tsorrun.ts(#1222, #1223, #1233, #1247, #1248, #1250) all belong to closed issues.Acceptance Criteria
AC-1: every ladder halt is recorded on⚠️ DIVERGENCE (wording)
IssueResultand in the run-log issue entry —Verification: Unit Test (
batch-executor.test.ts, one case per halt path: spec, loopSPEC_DIVERGENCE,DIVERGENCE_SUSPECT,TOP_OF_LADDER)Scenario: Given a phase declares
SPEC_DIVERGENCEand exits 0 → WhenrunIssueWithLoggingreturns → ThenIssueResultcarries the reason and the bundle, and the run-log issue entry hasstatus: "failure"and records both.Note: On
main, the run-log issue status is also wrong for a halt.deriveIssueLogStatusderives it from the phases, andrecordIssueCompletion(batch-executor.ts:539) only forcesfailurewhen there is aprCreationError. So a halt where every phase passed is logged assuccess. That is the #879 status drift again.AC-2: a phase that declared
SPEC_DIVERGENCEis stored in state asfailed, withoutcomeanddivergenceAcsVerification: Unit Test
Scenario: Given exec (or spec) returns
success: true, specDivergence: {acs:"AC-2"}→ Thenstate.issues[N].phases.exec={status:"failed", outcome:"SPEC_DIVERGENCE", divergenceAcs:"AC-2"}.Assumptions:
sequant statusalready draws the failed symbol forfailed. MCPsequant_statusreturnsissueState.phasesverbatim (src/mcp/tools/status.ts:130), so the new fields reach it without extra work.AC-3: the MCP
sequant_runper-issue result carrieshaltReasonand the declared ACsVerification: Unit Test (
run.test.ts→buildStructuredResponse)Scenario: Given a run-log issue entry with a halt bundle → Then the summary has
haltReason: "SPEC_DIVERGENCE"anddeclaredAcs: "AC-2". These are read from the bundle in the run log, not stored as a separate field. This works because MCP reads the run log, notIssueResult.Implementation Plan (once AC-1 is reworded)
Phase 1: one terminal record at the halt owner
"ladder_halt"to the bounded failure enum. It is mirrored in three places, as fix(run): phase-restricted runs without an implementing phase must skip PR creation — spec-only batches always report failed #920 did forpr_creation:ERROR_CATEGORIES(error-classifier.ts:29), the run-logcategoryenum (run-log-schema.ts:142) andFailureCategorySchema(metrics-schema.ts).batch-executor.ts, add one localhaltOutcome(bundle)next tobuildBundle. It returns{ failureCategory: "ladder_halt", abortReason: "ladder halt: <reason> in <phase>[ (<ACs>)]", evidenceBundle }. Spread it into both returns: the spec-path early return (:1505, which needs the bundle kept in a variable instead of built inline) and the final return (:2584, whendivergenceBundleis set). This is one owner and all four producers.evidenceBundle?: EvidenceBundletoIssueResult(types.ts). It reuses the existingabortReason?: string(types.ts:508) instead of adding a new reason field.Phase 2: run log + state
recordIssueCompletion, callmarkIssueFailedwhenever!result.success, not only onprCreationError. That closes the class: any failure outside a phase now logsfailure. PassabortReasonandevidenceBundlethrough tocompleteIssue. InIssueLogSchema, writeabortReasonwithout requiringaborted: true(abortedstays signal-only), and addevidenceBundle(zod schema mirroringEvidenceBundle; optional and additive atversion: 1).outcome(the samez.enum(["SPEC_DIVERGENCE"])) anddivergenceAcstoPhaseStateSchema, and to theupdatePhaseStatusoptions. Add onephaseStateFor(result)helper used by both state writers: spec at:1457and the phase loop at:2051. A declared divergence givesfailedwhatever the exit status.Phase 3: MCP
abortReason,haltReasonanddeclaredAcstoRunToolIssueSummary, read fromissue.evidenceBundle/issue.abortReasoninbuildStructuredResponse.Design Review
runIssueWithLogging, at the tworeturnsites, fed by the singlebuildBundle. Not at the four halt sites.abortReason(already shown byrun-display.ts:124andci/outputs.ts:113) and the existing boundedfailureCategory, and add one structured payload. Rejected: a top-levelhaltReasononIssueResult(it repeatsbundle.reasonand is a fifth one-off field). Also rejected: a genericterminal: {kind, detail}that rewritescapped,prCreationErrorandlocked(too much scope; it belongs in a Non-Goal or a follow-up). ADR: not required. The plan extends existing fields rather than choosing between designs.capped), Nested phase claude that hangs after its turn is killed at ~106s, taking down the parent sequant run #856 (aborted/abortReason), fix(run): exec that leaves work uncommitted reports success and the run passes with no PR — #534's empty-branch escape, reopened via a new route #879 (markIssueFailedfor a PR-only failure), fix(run): phase-restricted runs without an implementing phase must skip PR creation — spec-only batches always report failed #920 (pr_creationcategory). That is 4 prior fixes, which is ≥2, so stop: fix the class. The class fix is steps 1–4. Use the existing generic reason string and the bounded category, and makerecordIssueCompletionhonor!result.successfor every failure outside a phase, so the next one needs no new field. AC-1's wording prescribes the opposite lever: a newhaltReasonfield. That is the divergence.haltReasonas the AC says?" Because it would be the fifth field and would holdbundle.reasontwice. "Why does MCP havehaltReasonthen?" It is read from the bundle when the response is built, so it is never stored on its own.buildBundleis called atbatch-executor.ts:1483(spec),:1824(TOP_OF_LADDER),:1886(loopSPEC_DIVERGENCE) and:2350(DIVERGENCE_SUSPECT). There is one builder and tworeturnsites. The state write for a phase happens in two places (:1457,:2051), and step 5 merges them behind one helper. Consumers:IssueResult→recordIssueCompletion→LogWriter.completeIssue→IssueLogSchema→ MCPbuildStructuredResponse. Alsorun-display.toIssueSummary(abortReasonfallback),ci/outputs.ts,run-orchestrator.recordMetrics(failureCategory), and state →sequant status/ MCPsequant_status.Feature Quality Planning
versionbump is needed (Nested phase claude that hangs after its turn is killed at ~106s, taking down the parent sequant run #856 / fix(run): phase-restricted runs without an implementing phase must skip PR creation — spec-only batches always report failed #920 precedent). Check thatmetrics-schemaround-trips the new value.batch-executor.test.tsqueues its git mocks in order (bug(exec): sequant run worktrees never record sequantBase, so the zero-diff/uncommitted guard compares against origin/main and a --base ahead of main disables it #1234). A new git call shifts them, and this plan adds none.result.success. See Open Question 2.Open Questions
- [ ] AC-1: Every ladder halt (spec path, loop SPEC_DIVERGENCE, DIVERGENCE_SUSPECT, TOP_OF_LADDER) returns an IssueResult with failureCategory "ladder_halt", an abortReason naming the LadderHaltReason, phase and declared ACs, and the EvidenceBundle; the run log's issue entry records status "failure", the abortReason and the bundle. Evidence: npx vitest run src/lib/workflow/batch-executor.test.ts with one case per halt pathImpact if declined: exec adds
haltReasonas written, and the next stop outside a phase adds a sixth field.failuretoo? Recommendation: yes, forSPEC_DIVERGENCEonly, through the samephaseStateFordecision. That keeps the state, the log and the progress output in agreement. Impact if skipped: the run log says "phase success, issue failure (ladder_halt)". That is honest now thatabortReasonis present, but it is inconsistent with state.Recommended Workflow
Phases: spec → exec → qa (after AC-1 is reworded)
Quality Loop: disabled
Reasoning: A bug with a narrow, well-located change. The tests are targeted vitest files, so testgen adds little.
Label Review
Current: bug. Recommended: bug. No change. The
plannedlabel is held until AC-1 is resolved.admarble commentedon Oct 4, 2026
Owner decision (2026-10-04), on spec's Open Questions: (1) AC-1 is replaced with spec's wording: reuse
abortReason, add theladder_haltcategory and theEvidenceBundle, and add no new top-levelhaltReason. (2) Yes: the halting phase's run-log row and progress event read failure too, through the same decision as state; this is folded into AC-2. AC-3 is unchanged: MCP'shaltReasonanddeclaredAcsare read from the bundle, not stored. Re-running exec → qa.admarble commentedon Oct 4, 2026
QA Verdict: AC_MET_BUT_NOT_A_PLUS
AC coverage: 3/3 met
Gaps:
Evidence:command runs onlybatch-executor.test.ts, which covers two of the four halt paths. The other two need a configured ladder and are inbatch-executor.model-ladder.test.ts. Behavior is covered; the command named in the AC just doesn't reach it.## Summary.admarble commentedon Oct 4, 2026
Runner verification and follow-up ledger (PR #1304)
Verified by the runner:
tscis clean and CI is green.phaseRecordFormade to ignorespecDivergence, 3 tests fail. Restored afterwards.ladderHaltOutcomeat both return sites,recordIssueCompletionforcingfailurefor any failure not explained by a phase, and onephaseRecordFordecision for state, the run-log row and progress.Ledger:
DIVERGENCE_SUSPECTandTOP_OF_LADDERcases need the configured-ladder harness inbatch-executor.model-ladder.test.ts. The runner ran that file too, and the PR body records it.terminal: {kind, detail}rewrite ofcapped,prCreationErrorandlocked: dropped.recordIssueCompletionnow records every failure not explained by a phase, using the existingabortReasonandfailureCategory. The next stop of that kind needs a category value, not a new field, so the rewrite would buy nothing.