Repository navigation
Description
Epic: M3 Blocked by: #971 Tier: judgment Doc: docs/internal/graph-2026-09/PLAN.md §2 D-ladder, §5 I-4, §7 D4, issue-graph anti-gap 5 (fixture issue)
Why
The ladder is only safe if divergence goes to a human and never to a stronger
model. Carries #971 AC-3 (halt half), 4, 9, 10 (verbose half), 12, plus the
graph's "first real use" rule: one rigged run on this repo.
Scope
- may touch:
src/lib/workflow/state-schema.ts(append theSPEC_DIVERGENCEoutcome), the halt sites insrc/lib/workflow/batch-executor.ts/ready-gate.ts(through feat(run): model escalation ladder on capability-bound non-convergence #971 (node 11)'s resolver output), verbose logging insrc/lib/workflow/phase-executor.ts,templates/skills/exec/SKILL.md+templates/skills/loop/SKILL.mdand their.claude/skillsandskillsmirrors,README.md,docs/reference/run-command.md(or a newdocs/reference/model-ladder.md), tests beside each, one throwaway fixture issue on this repo (closed after) - not in scope: verify-failure trigger (OQ-4); pre-escalation probe; downgrades.
Acceptance criteria
- AC-3 (halt half): divergence-suspect pattern halts and surfaces evidence — Verify:
npx vitest run src/lib/workflow/model-ladder.test.ts -t "971 AC-3 halt"→ the loop stops after the stagnation detector's divergence signal with a bundle containing SHAs tried, verdicts, and escalation history (empty). - AC-4:
SPEC_DIVERGENCEmarker halts without escalating, and the skills say when to emit it — Verify:-t "971 AC-4"for the halt;grep -c 'SPEC_DIVERGENCE' templates/skills/exec/SKILL.md templates/skills/loop/SKILL.md→ both ≥ 1;md5 -q templates/skills/exec/SKILL.md .claude/skills/exec/SKILL.md skills/exec/SKILL.md | uniq | wc -l→1(same forloop). - AC-9: top-of-ladder halt — Verify:
-t "971 AC-9": with feat(run): model escalation ladder on capability-bound non-convergence #971 (node 11)'stopOfLadderflag set and a further trigger, the run halts with the evidence bundle instead of looping. - AC-10 (verbose half):
model: sonnet → opus (no-progress retry)appears in verbose output — Verify:-t "971 AC-10 verbose"asserts the exact line format. - AC-12: docs — Verify:
grep -c 'modelLadder\|model-ladder' README.md docs/reference/*.md≥ 2, and the docs section names the capability-vs-spec-bound distinction andSPEC_DIVERGENCE(grep -c 'SPEC_DIVERGENCE' docs/reference/*.md≥ 1). - AC-14 (real run): a fixture issue on this repo whose single AC is impossible as written (e.g. asserts a file both exists and does not), run with
run.modelLadderconfigured, halts withSPEC_DIVERGENCEand no escalation — Verify: after the run,jq '[.. | objects | select(has("phaseUsage")) | .phaseUsage[]? | select(.escalatedModel != null)] | length' .sequant/metrics.json→0for that run, and the run's halt output names the AC; the fixture issue is closed with a comment linking the run. Honest SKIP is not allowed here: the rig is deterministic.
Done when
A contradiction in the spec stops the run at the cheapest rung with a packaged handoff, the skills tell agents when to declare one, and the docs explain the ladder — proven once on a rigged real run.
Part of #971. Planned by /graph-plan 2026-09-06; run with /graph-run. Plan: docs/internal/graph-2026-09/PLAN.md, graph: docs/internal/graph-2026-09/issue-graph.md, node file: docs/internal/graph-2026-09/issues/14-*.md.
Activity
admarble commentedon Sep 8, 2026
Runner context — wave 4 launch (2026-09-08, main at 3400a1c). The blocker is merged: #971 (PR #1012) landed the ladder mechanism —
src/lib/workflow/model-ladder.tsresolver,run.modelLadder/--model-ladder, the four retry-dispatch sites, thetopOfLadderflag, escalation facts in the phase marker andphaseUsagerows (requestedModel,escalatedModel, trigger reason), andphase-executor.model-ladder.test.ts. Build on those; read the plan and your node file frommain:docs/internal/graph-2026-09/PLAN.md(§2 D-ladder, §5 I-4, §7 D4/D16–D24) anddocs/internal/graph-2026-09/issues/14-971B-spec-divergence-halts-docs.md.AC-14's fixture issue is pre-approved scope (issue-graph.md "Wave 4 … 14 AC names the fixture issue creation as part of scope"): file exactly one throwaway issue on this repo titled with a
fixture:prefix, with a single AC that is impossible as written, run it withrun.modelLadderconfigured, and close it with a comment linking the run. Do not file any other issue (I-7). Run the rigged run in the foreground with a short phase timeout and only the phases needed to trigger the halt; it is deterministic, so it must not take long — if it approaches 20 minutes, abort it, commit, and record what happened rather than letting the launcher kill this phase.Launch discipline: the launcher kills any phase silent for 30 minutes — commit a WIP within 5 minutes and every ~10 minutes; run only the node file's targeted
-t "971 …"commands in the foreground; never the full suite inside the phase. Skill edits (AC-4) must land in all three mirrored copies (templates/skills,.claude/skills,skills) byte-identical. Open the PR yourself with every AC's verify output and the gate-testMutation-verified:records; the owner merges after runner verification.admarble commentedon Sep 8, 2026
Plan — #995 (
/spec)Complexity: Standard (6 ACs, 5 directories) · main at
3400a1c9(#971/PR #1012 merged)AC Quality Check
Ran
extractAcceptanceCriteria+ the behavior-rule detector against the body. All 6 ACs carry an executableVerify:clause — no vague/unmeasurable/open-ended patterns. No AC triggers the behavior-rule heuristic, so there is no Rule Touchpoints section./execand/qa. The AC lines lead withAC-3 (halt half):rather than**AC-3:**, soac-parser.tsassigns sequential IDs and the stored IDs do not match the issue's labels:AC-1AC-4AC-9AC-2AC-12AC-3sequant state update … ac AC-3therefore marks AC-14, not the halt AC. Use the issue's labels in the PR body and this table when touching state.Scope Assessment
Non-Goals: present — verify-failure trigger (OQ-4), pre-escalation probe, downgrades. Plus PLAN §3: semantic QA-finding comparison, speculative downgrades.
src/lib/workflow/,templates/skills/{exec,loop}(+2 mirrors),docs/reference/,README.md, testsVerdict:⚠️ SCOPE_WARNING — the spread is mirror-copies and docs, not independent features. Do not split.
Acceptance Criteria
AC-3 (halt half) — divergence-suspect halts with an evidence bundle
Verification: Unit Test —
npx vitest run src/lib/workflow/model-ladder.test.ts -t "971 AC-3 halt"Scenario: Given a ladder configured and two consecutive iterations that each produced a new SHA at a still-failing verdict → When the next iteration would dispatch → Then the loop halts with a bundle carrying the SHAs tried, the verdicts, and an empty escalation history, and the model option never changed.
Assumptions: the halt is gated on a configured ladder and needs ≥2 consecutive divergence-suspect iterations (see Open Question 1) — halting on the first would gut the ordinary
AC_NOT_MET → /loop → re-QApath.AC-4 —
SPEC_DIVERGENCEhalts without escalating; skills say when to emit itVerification: Unit Test + file gate —
-t "971 AC-4";grep -c 'SPEC_DIVERGENCE' templates/skills/{exec,loop}/SKILL.md≥ 1 each;md5 -q templates/skills/<s>/SKILL.md .claude/skills/<s>/SKILL.md skills/<s>/SKILL.md | uniq | wc -l→1for both skills.Scenario: Given a phase whose output carries
<!-- SEQUANT_PHASE: {…,"outcome":"SPEC_DIVERGENCE",…} -->→ When the run processes that result → Then no retry is dispatched, no rung is spent, the run halts, and the bundle names the AC the agent declared impossible.Assumptions: the declaration channel is the existing
SEQUANT_PHASEmarker (flat scalars only — the\{[^}]+\}parser cannot cross a nested brace).AC-9 — top-of-ladder halt
Verification: Unit Test —
-t "971 AC-9"Scenario: Given a phase already on the ladder's last rung → When a further capability-bound trigger arrives (
withEscalatedModelreturnstopOfLadder: true) → Then the run halts with the evidence bundle (escalation history non-empty, ending at the top rung) instead of looping.Assumptions:
ModelEscalationOutcome.topOfLadderis today produced but consumed by nothing except the phase env var — this AC is its first real consumer.AC-10 (verbose half) — exact line format
Verification: Unit Test —
-t "971 AC-10 verbose"Scenario: Given
--verboseand aLOOP_NO_DIFFescalation fromsonnettoopus→ When the escalated dispatch is logged → Then the output contains exactlymodel: sonnet → opus (no-progress retry).Assumptions: today all four print sites emit the raw code —
(LOOP_NO_DIFF retry)— so this is a wording change, not new plumbing. No existing test asserts the current wording (verified).AC-12 — docs
Verification: Manual (grep-gated) —
grep -c 'modelLadder\|model-ladder' README.md docs/reference/*.md≥ 2 andgrep -c 'SPEC_DIVERGENCE' docs/reference/*.md≥ 1Scenario: Given a reader of
README.md/docs/reference/model-ladder.md→ When they look for the ladder → Then they find triggers, the capability-vs-spec-bound distinction, the cost implication, and theSPEC_DIVERGENCEescape hatch.Assumptions: neither
README.mdnor anydocs/reference/*.mdmentions the ladder today — this is net-new prose, not an edit.AC-14 — rigged real run
Verification: Integration (live run) —
jq '[.. | objects | select(has("phaseUsage")) | .phaseUsage[]? | select(.escalatedModel != null)] | length' .sequant/metrics.json→0for that run; the halt output names the AC; the fixture issue is closed with a comment linking the run.Scenario: Given a
fixture:-prefixed throwaway issue on this repo whose single AC asserts a file both exists and does not → When it runs withrun.modelLadderconfigured → Then the run halts withSPEC_DIVERGENCE, spends zero rungs, and names the AC.Assumptions: the fixture issue is pre-approved scope (issue-graph "Wave 4"); no other issue may be filed (I-7). Honest SKIP is not allowed.
Implementation Plan
Phase 1 — one classification, one bundle (the shared spine)
src/lib/workflow/model-ladder.ts: widenCapabilityTriggerDecisionwithclassification: "capability-bound" | "divergence-suspect" | "none". The divergence case is already computed there (thereturn { trigger: null, reason: "progress observed since the last attempt — divergence-suspect…" }branch) but is only distinguishable by prose — no halt site may read a reason string.src/lib/workflow/divergence-halt.ts:LadderHaltReason = "SPEC_DIVERGENCE" | "DIVERGENCE_SUSPECT" | "TOP_OF_LADDER", anEvidenceBundle(issue, phase, reason, SHAs tried, verdicts per iteration, escalation history, declared ACs, next step), andformatEvidenceBundle(). Its own module rather than insidemodel-ladder.ts: the resolver is a pure config function with two dispatch callers, and the bundle is human-facing formatting with two different callers (batch-executor,ready-gate).src/lib/workflow/state-schema.ts: append optional flatoutcome: z.enum(["SPEC_DIVERGENCE"]).optional()anddivergenceAcs: z.string().optional()toPhaseMarkerSchema. Append-only (I-2) — pre-feat(run): SPEC_DIVERGENCE escape hatch, ladder halts with evidence bundles, docs, rigged real run (#971 part B) #995 markers keep parsing. Flat scalars only, for the\{[^}]+\}reason already documented in that file.Phase 2 — the three halts
4.
phase-executor.ts: parse the phase's own output with the existingparsePhaseMarkers(same pattern as the QA-verdict scrape at:506and the spec-recommendation scrape) → set newPhaseResult.specDivergence?: { acs?: string; message?: string }. Additive/optional, same shape contract ascapped?/escalatedModel?.5.
phase-executor.ts:executePhaseWithRetry: early-return onspecDivergence, exactly ascappeddoes at theskipColdStartRetrybranch — a retry cannot un-contradict a spec (AC-4's "without escalating" must hold against the retry path too, not just the ladder).6.
batch-executor.ts: addhaltedByDivergencebesidehaltedByCap/haltedByBilling(:1400) — it suppresses the/loopspawn (:1769), breaks the outer iteration loop (:1934), and prints + persists the bundle. Feed the AC-3 halt from the iteration-close assessment at:1900(adivergence-suspectclassification twice consecutively) and the AC-9 halt fromwithEscalatedModel's already-returnedtopOfLadderat:1525/:1802.7.
ready-gate.ts: addSPEC_DIVERGENCE,DIVERGENCE_SUSPECT,TOP_OF_LADDERtoReadyTerminalReason+reasonText(:75,:436), reached throughfinish(...)beside the existingLOOP_NO_DIFF/LOOP_FAILEDguards. Without this the gate has no way to name a ladder halt and would mislabel itMAX_ITERATIONS.Phase 3 — verbose wording (AC-10) + sibling sites
8. Add
formatEscalationTriggerLabel(trigger)tomodel-ladder.tsmappingLOOP_NO_DIFF/SAME_SHA_NO_PROGRESS→no-progress(andSTICKY→sticky), then apply it at all four print sites:batch-executor.ts:1529,batch-executor.ts:1811,commands/ready.ts:344,run-orchestrator.ts:1947. See Sibling-site Scan below — the AC only names one, but four sites print the raw code today and leaving three behind is the drift this repo keeps paying for.Phase 4 — skills (AC-4) + docs (AC-12)
9.
templates/skills/exec/SKILL.mdandtemplates/skills/loop/SKILL.md: a short "When the spec is impossible as written" block next to the existingSEQUANT_PHASEemission block (exec:104-109) — when an AC is self-contradictory or contradicts the repo as it exists, emit the marker with"outcome":"SPEC_DIVERGENCE"and the AC ID, and stop; do not implement a guess. Thennpm run sync:skillsand verify themd5triple (all six copies are byte-identical today — keep them that way, I-4).10. New
docs/reference/model-ladder.md(triggers, capability-vs-spec-bound, cost,SPEC_DIVERGENCE, the three halts), a README section, and a link fromdocs/reference/run-command.md. Put ≥2modelLaddermentions in README and ≥2 in the new doc, so AC-12'sgrep -cpasses under both the per-file and aggregate readings (Open Question 2).Phase 5 — AC-14 rigged run (last, after everything else is green)
11. File exactly one issue:
fixture: impossible AC — ladder divergence rig (#995 AC-14), single AC asserting a file both exists and does not.12. Run foreground, from the CLI, never backgrounded (#856 kills a backgrounded
sequant runat ~106 s) and not through MCP (hard 30-minPHASE_TIMEOUT):sequant run <N> --phases exec,qa --model-ladder sonnet,opus --max-iterations 2 --timeout 900 --verbose.13. Capture the halt output, run the AC-14
jq, copy the evidence out of.sequant/immediately (gitignored + rotates at 100 files), close the fixture issue with a comment linking the run.Design Review
model-ladder.ts(it already computes it); the bundle and halt reason go in a newdivergence-halt.tswith two consumers; the halt flags live wherecapped/billingalready live, so there is one halt idiom inbatch-executor.tsrather than two.parsePhaseMarkersfor the escape hatch, thecapped-style early return for "never retry this", and thehaltedBy*flag for "stop the outer loop". Rejected: a new stdout marker family (SEQUANT_SPEC_DIVERGENCE) — the issue scope namesstate-schema.ts, and a second marker family means a second parser to keep in sync. Rejected: readingdecision.reasonprose at the halt sites.#739(turn cap) and#799(billing window) are the precedent: surface + halt, skip the loop, preserve partial work. This is a third member of that family, and it should look like one.Sibling-site Scan
(${trigger} retry)prints the raw reason code at four sites:batch-executor.ts:1529(phase dispatch),batch-executor.ts:1811(loop dispatch),commands/ready.ts:344,run-orchestrator.ts:1947. AC-10 names only the verbose run-path line. The sites are one-liners around the same record type, so the fix is trivially co-located → recommended in scope via a single shared label helper.commands/ready.tsandrun-orchestrator.tskeep their extra context (rung N,ready-gate,#issue); only the trigger token changes.Feature Quality Planning
compareLoopProgress) are already snapshot-gated onisLadderConfigured.metrics.jsonmust still parse..sequant/metrics.jsonis 108 KB of real records — use it as the fixture corpus.SPEC_DIVERGENCEhalts the outer loop but a cold-start retry or the MCP fallback still re-dispatches the phase. Assert the dispatch count, not just the final status.md5gates and AC-12's doc greps are exactly the class that passes vacuously. Commit before mutating (git checkout <file>wipes uncommitted edits).Derived ACs
modelLadderconfigured, none of the three halts can fire and the run path is unchangedmetrics.jsonstill parse after the schema appendSPEC_DIVERGENCEresult is dispatched exactly once — no cold-start retry, no MCP fallbackOpen Questions
AC_NOT_MET → /loop → re-QAcycle — a severe regression for every user, ladder or not.grep -c … README.md docs/reference/*.md ≥ 2is ambiguous between per-file and aggregate counts (grep -cover multiple files prints per-file). — Recommendation: satisfy the strict reading (≥2 in README, ≥2 in the new doc). Impact if wrong: a literal-reading QA marks AC-12 not met on a formatting technicality.SPEC_DIVERGENCEand the run instead halts via the AC-3 divergence-suspect path, "no escalation" holds but "halts withSPEC_DIVERGENCE" does not. — Recommendation: sharpen the exec skill prose and re-run once; if it still does not emit, record the run honestly and hand the wording call to the owner. Impact if wrong: a rewritten AC-14 quietly lowers the bar the graph's "first real use" rule exists to set.sequant readyneed all three new terminal reasons, or justSPEC_DIVERGENCE? — Recommendation: all three; a gate that mislabels a top-of-ladder halt asMAX_ITERATIONSsends the human to the wrong remedy. Impact if wrong: a slightly widerReadyTerminalReasonunion than the ACs strictly require.Conflict Risk Analysis
PR #1013 (#996, open) also edits
src/lib/workflow/phase-executor.ts. #995's edits there are localized (marker parse near the verdict scrape ~:506, onePhaseResultfield, one early return inexecutePhaseWithRetry), so a textual conflict is unlikely but possible. Mergeorigin/maininto the #995 branch before opening the PR if #1013 lands first — merge, never rebase a pushed branch.No other in-flight worktree touches
batch-executor.ts,ready-gate.ts,model-ladder.ts,state-schema.ts, or theexec/loopskills.Dependencies: #971 (blocker) is merged — PR #1012 at
3400a1c9. No open blockers.Risks
sequant run— the watchdog SIGKILLs the tree at ~106 s. AC-14 runs in the foreground.PHASE_TIMEOUTinsrc/mcp/tools/run.tskills an MCP-launched phase silent for 30 minutes and the cleanup can destroy an uncommitted worktree. Commit a WIP within 5 minutes and every ~10 minutes; run only the targeted-t "971 …"commands in the foreground, never the full suite inside the phase..sequant/is gitignored and rotates at 100 files — copy the AC-14 run log and metrics slice out before doing anything else.model-ladder.test.ts(no.integration.infix ⇒ 5 s per test). Keep executions mocked, asbatch-executor.model-ladder.test.tsalready does.Test Placement
Every AC's declared verify command targets
src/lib/workflow/model-ladder.test.tswith a-tfilter, so the gate tests go there, named971 AC-3 halt …,971 AC-4 …,971 AC-9 …,971 AC-10 verbose …. Extra depth may live inbatch-executor.model-ladder.test.ts, but the AC-named test must match the verbatim command (I-9).Recommended Workflow
Phases: exec → qa
Quality Loop: disabled
Reasoning: The blocker is merged and the plan is concrete, so no
testgenpass is warranted — the AC-named test file already exists and the verify commands pin the test names, which is what testgen would otherwise be inventing. The quality loop stays off to keep the exec phase inside the launcher's 30-minute no-progress ceiling (D16); QA runs as its own dispatch, and the owner merges after runner verification (I-6 — stop at PR).Label Review
Current:
graph-2026-09Recommended:
graph-2026-09,enhancement,plannedReason: No
.tsx/.jsxsurface and no browser-testable behavior, so nouilabel and notestphase. Notbug— this is new halt behavior on top of #971's mechanism.Quality Loop: won't auto-enable — SCOPE_WARNING is driven by mirror-copy spread, not by feature count, and the launcher's phase ceiling argues against it.
fix(#995): restore SEQUANT_PHASE marker name in the skills; gate test…
admarble commentedon Sep 8, 2026
Runner context — exec was killed by the launcher's 30-minute no-progress ceiling at 09:13Z; the clean worktree was removed by design (#935) and is re-provisioned from the branch. All 9 commits are pushed (
feature/995-…atbbc1df80, "restore SEQUANT_PHASE marker name in the skills; gate test now parses"). The dead session's last step was AC-14: it had fixed the rig and was about to re-run it once (the spec's OQ-3 allowance) after clearing the fixture's stale worktree/state. Resume exactly there: clear any leftover#1015worktree, pid or state entry, re-run the rig in the foreground with a short phase timeout, capture the halt output naming the AC, run the AC-14jqover.sequant/metrics.json, close #1015 with a comment linking the run, then run the remaining node-14 verify commands, open the PR with every AC's output and the gate-testMutation-verified:records, and stop. Commit within 5 minutes and every ~10 minutes; if the rig approaches 20 minutes, abort it and record what happened instead of letting this phase be killed again. Do not file any further issue.fix(#995): SPEC_DIVERGENCE marker must go in the agent's final message
test(#995): cover the driver -> parseSpecDivergence channel, gate the…
docs(#995): CHANGELOG names the marker's required channel
test(#995): direct unit coverage for formatEvidenceBundle; document q…
admarble commentedon Sep 8, 2026
QA Verdict: READY_FOR_MERGE
admarble commentedon Sep 8, 2026
Runner verification — node 14 (PR #1016, QA verdict READY_FOR_MERGE, loop iteration 2 at
5bac217d)Verify commands from
issues/14-971B-spec-divergence-halts-docs.md, run verbatim in the worktree at5bac217d(= PR head = origin; CI green, mergeable):model-ladder.test.ts -t "971 AC-3 halt"-t "971 AC-4";grep -c 'SPEC_DIVERGENCE'in exec/loop skills; md5 over the three mirrors-t "971 AC-9"-t "971 AC-10 verbose"model: sonnet → opus (no-progress retry)linegrep -c 'modelLadder|model-ladder' README.md docs/reference/*.md;grep -c 'SPEC_DIVERGENCE' docs/reference/*.mddocs/reference/model-ladder.mdnames the capability-vs-spec-bound distinctionjq '[.. | objects | select(has("phaseUsage")) | .phaseUsage[]? | select(.escalatedModel != null)] | length' .sequant/metrics.jsonSPEC_DIVERGENCEnaming its AC and is closed with the run linkedRun history: exec killed once by the launcher's 30-minute ceiling mid-AC-14 (all 9 commits pushed; clean worktree removed by design), re-dispatched, loop round 2 reached READY_FOR_MERGE. Merging on the owner's standing instruction.
feat(#995): SPEC_DIVERGENCE escape hatch, ladder halts with evidence …