Skip to content

chore(cli)!: remove the model ladder and effort escalation — modules, --model-ladder and --escalate-effort on run and ready, their settings and docs; old logs and settings still load #1647

Closed

Description

@admarble

Epic: graph-2026-11-simplify (F-10 cluster of #1501) Tier: judgment Execution: sequant_run Blocked by: #1646 (the repeat halt must stand on its own before the ladder that feeds the divergence halt goes; both edit the quality loop in batch-executor.ts)

Problem

D-1. In 453 recorded runs (2026-01-21 to 2026-10-28) --model-ladder and --escalate-effort were used 0 times and neither setting is on in this repo. They are 605 + 116 lines (model-ladder.ts, effort-escalation.ts) plus wiring in batch-executor.ts, phase-executor.ts, config-resolver.ts, settings.ts, three schemas, and flags on both run and ready (bin/cli.ts:442,450,670,676). An advisor on the retry rung (#1138) changed neither verdicts nor loop counts. Founding doc §4, P-4, P-5.

Decisions

ID Decision Rejected
R-1 Delete both modules, their tests, the four flag definitions, run.modelLadder and effortEscalation, and the ladder state in batch-executor.ts keeping the modules behind a hidden flag
R-2 Schemas keep reading ladderRung, escalatedModel, escalationTrigger, escalationHistory and ladder_halt as optional (I-2); nothing writes them a schema version: 2
R-3 A settings file that still sets modelLadder or effortEscalation loads, with one warning naming the removal in 3.0 a hard error
R-4 divergence-halt.ts stays (ready-gate.ts, log-writer.ts, run-log-schema.ts import it); the SPEC_DIVERGENCE halt keeps working with no ladder; the divergence-suspect block, whose only feed is the ladder snapshot, goes with the ladder deleting divergence-halt.ts with the ladder

Prior fixes / producers

Acceptance Criteria

  • AC-1: Both modules are gone and nothing imports them, tests included. Evidence: grep -rlE 'model-ladder|effort-escalation' src bin --include='*.ts' | wc -l | tr -d ' ' → 0
  • AC-2: Neither flag appears on run or ready. Evidence: for c in run ready; do npx tsx bin/cli.ts $c --help; done | grep -cE -- '--model-ladder|--escalate-effort' → 0
  • AC-3: A settings file that sets modelLadder and effortEscalation loads with exactly one warning per removed key that names 3.0, and the run proceeds. Evidence: npx vitest run src/lib/settings.removed-keys.test.ts → ≥ 2 passed, 0 failed
  • AC-4: A pre-3.0 run log carrying ladder_halt, escalationHistory and ladder fields on its phases validates, and sequant logs renders it. Evidence: npx vitest run src/lib/workflow/run-log-schema.legacy.test.ts → ≥ 2 passed, 0 failed
  • AC-5: The SPEC_DIVERGENCE halt still fires with no ladder configured. Evidence: npx vitest run src/lib/workflow/divergence-halt.test.ts → 0 failed (constraint)
  • AC-6: User docs no longer offer the features. Evidence: grep -rlE -- 'model-ladder|escalate-effort|modelLadder|effortEscalation' README.md docs/reference docs/features docs/guides docs/getting-started | wc -l | tr -d ' ' → 0
  • AC-7: The changelog records the removal. Evidence: awk '/^## \[Unreleased\]/,/^## \[[0-9]/' CHANGELOG.md | grep -cE -- '--model-ladder|--escalate-effort' → ≥ 1
  • AC-8: No skill-directory edits. Evidence: git diff --name-only $(git merge-base origin/main HEAD)..HEAD | grep -cE '^(plugin/|\.claude/skills/|templates/skills/)' → 0 (constraint)

isGateTestEvidence classifies none of these ACs as a gate (parse-check, 2026-11-04). AC-4's legacy test still earns its place only if it fails when the schema stops reading old fields: the PR body records that run (make ladderRung required → the legacy test fails; restore) in the Mutation-verified: format.

May touch

src/lib/workflow/model-ladder.ts, effort-escalation.ts and their tests (deleted), batch-executor.ts and batch-executor.model-ladder.test.ts, phase-executor.ts and phase-executor.{model-ladder,effort-escalation}.test.ts, config-resolver.ts, metrics-schema.ts and metrics-schema.effort-escalation.test.ts, state-schema.ts, run-log-schema.ts, log-writer.ts, metrics-writer.ts, types.ts, run-orchestrator.ts, divergence-halt.ts and ready-gate.ts (comments and ladder-only branches; the SPEC_DIVERGENCE halt and the gate's loop unchanged), src/lib/settings.ts, src/commands/run.ts, src/commands/ready.ts, src/mcp/tools/run.ts, bin/cli.ts (the four .option( blocks only), __fixtures__/ (one legacy run log), the named docs pages, CHANGELOG.

Non-Goals

Done when

No code, flag, setting or user doc offers the ladder or escalation, and every pre-3.0 log and settings file still loads.

Activity

  1. added
    graph-2026-11-simplify
    on Nov 7, 2026
  2. added a commit that references this issue on Nov 8, 2026
  3. admarble commented on Nov 8, 2026

    @admarble
    ContributorAuthor

    Runner context, 2026-11-08: repo state since this issue was written

    #1646 merged as f5489a8fe (PR #1660), and #1649 as a5bba3067. Read the quality loop on main at a5bba3067, not as it stood when this issue was filed.

  4. admarble commented on Nov 8, 2026

    @admarble
    ContributorAuthor

    Complexity: Standard (8 ACs, 5 directories: src/lib/workflow, src/lib, src/commands, bin, docs)

    AC Quality Check

    Every AC is one line with an Evidence: clause, and the issue has a ## Non-Goals section. Each evidence command was run on main at a5bba3067 to make sure it fails there:

    • AC-1: 21 files match today. Fails, as it should.
    • AC-2: 4 flag lines today. Fails, as it should.
    • AC-3 and AC-4: the test files don't exist yet. Fails, as it should.
    • AC-5: 14/14 pass today. This is expected for a constraint AC.
    • AC-6: 5 files match (README, run-command.md, ready-command.md, model-ladder.md, mcp-server.md). Fails, as it should.
    • AC-7: 0 matches. Fails, as it should.
    • AC-8: constraint.

    One catch on AC-1: the grep matches comments as well as imports. These files only mention model-ladder/effort-escalation in prose, and their wording has to change too: divergence-halt.ts, divergence-halt.test.ts, batch-executor.repeat-halt.test.ts, batch-executor.test.ts, state-schema.ts, metrics-schema.ts, settings.ts, types.ts, config-resolver.ts.


    Scope Assessment

    Non-Goals: --stacked/--reflect/--full-qa (#1648); the ready gate's loop and divergence-halt.ts; skills.

    • Features: 1 (one removal) ✅
    • AC count: 8 ✅
    • Directory spread: 5 ⚠️ (the dependents of a deletion, not new scope)

    Verdict: ⚠️ SCOPE_WARNING. This is wide but mechanical: 721 lines of modules, about 7 test files deleted and about 14 test files edited. The quality loop is on.


    Acceptance Criteria

    AC-1: Both modules are gone and nothing imports them

    Verification: Integration Test (grep) plus npx tsc --noEmit
    Scenario: Given main → When model-ladder.ts and effort-escalation.ts and their tests are deleted → Then the grep returns 0 and the build passes.
    Assumptions: divergence-halt.ts:30 imports type ModelEscalationRecord from model-ladder.ts. The type moves into divergence-halt.ts, because EvidenceBundle.escalationHistory and the run-log schema still read it. ready.ts:25 and run-orchestrator.ts:94 import formatEscalationTriggerLabel. That import goes along with the escalation printout it serves.

    AC-2: No --model-ladder / --escalate-effort on run or ready

    Verification: Integration Test (CLI help)
    Scenario: sequant run --help and sequant ready --help → no match.
    Assumptions: Only the four .option( blocks in bin/cli.ts (around :442/450/670/676) are touched. RunOptions.escalateEffort/modelLadder in types.ts and ReadyOptions in ready.ts go too. src/mcp/tools/run.ts has no such input params, only the haltReason type (see OQ-2).

    AC-3: Old settings keys load with exactly one "removed in 3.0" warning each

    Verification: Unit Test (new src/lib/settings.removed-keys.test.ts)
    Scenario: validateSettings({run:{modelLadder:["sonnet","opus"], effortEscalation:true}}) → exactly 2 warnings, one per path, each naming 3.0. No Unknown key warning for either. The other settings resolve normally, and neither key appears on settings.run.
    Assumptions: Existing bug found: run.effortEscalation is missing from KNOWN_KEYS.run. Today it already warns Unknown key 'run.effortEscalation' (ignored) even though it works (verified on main). So the test must assert both keys explicitly, including that the generic unknown-key warning does not fire as well. Mechanism: a REMOVED_KEYS map ("run.modelLadder", "run.effortEscalation" → message) checked in detectUnknownKeys before the unknown-key branch. The nested run Zod schema already strips keys it doesn't know, so no schema entry is needed.

    AC-4: A pre-3.0 run log with ladder fields validates and sequant logs renders it

    Verification: Unit Test (new src/lib/workflow/run-log-schema.legacy.test.ts plus one fixture in src/lib/workflow/__fixtures__/)
    Scenario: The fixture has failureCategory: "ladder_halt", a halt bundle whose escalationHistory is non-empty and whose reason is TOP_OF_LADDER, and phases carrying ladderRung/escalatedModel/escalationTrigger/topOfLadder → RunLogSchema.parse succeeds, and logsCommand on that file exits 0 and prints the issue.
    Assumptions: The PR body records the mutation: make ladderRung required → the legacy test fails → restore. That ladderRung is in the state schema and the metrics schema, so the mutation must target whichever field the run-log fixture really carries (the halt bundle's escalationHistory[].rung, or the phase-level field in run-log-schema.ts). Pick the field the fixture actually exercises, and record it with sequant mutation.

    AC-5: SPEC_DIVERGENCE still halts with no ladder (constraint)

    Verification: Unit Test (existing divergence-halt.test.ts, plus batch-executor.repeat-halt.test.ts must stay green)
    Scenario: The loop phase declares SPEC_DIVERGENCE → haltedByDivergence is set (batch-executor :2479) → loopHalted(state) stops the loop → the issue outcome is ladder_halt through ladderHaltOutcome.

    AC-6: User docs no longer offer the features

    Verification: Integration Test (grep)
    Assumptions: docs/reference/model-ladder.md also documents the SPEC_DIVERGENCE escape hatch and the halt bundle, and both survive. Recommendation: rename it to docs/reference/spec-divergence-halt.md, keep the SPEC_DIVERGENCE and repeat-halt sections, and drop the ladder sections. Then update the links in README.md:358, run-command.md:482, docs/THREAT-MODEL.md and mcp-server.md. README.md:100 and :326 and run-command.md:72-74, 458-482 are edited in place. ready-command.md:72 loses its flag row.

    AC-7: CHANGELOG [Unreleased] records the removal

    Verification: Integration Test (awk/grep)
    Assumptions: Add a ### Removed entry next to #1646/#1649 without rewriting theirs. If PR #1370 (fragments) merges first, write a fragment instead and adjust the evidence path. #1370 is still OPEN as of 2026-11-08.

    AC-8: No skill-directory edits (constraint)

    Verification: Integration Test (git diff)
    Assumptions: No skill or hook reads SEQUANT_MODEL_RUNG/SEQUANT_ESCALATION_TRIGGER/SEQUANT_MODEL_TOP_OF_LADDER. A whole-repo grep finds only phase-executor.ts, the ladder tests and state-schema.ts. So the env-var producer in phase-executor.ts:1696-1711 can go without a skill edit.


    Implementation Plan

    Phase 1: Cut the producers (src/lib/workflow)

    1. batch-executor.ts: remove the effort-escalation/model-ladder imports, ladderState, lastTrigger, modelTrigger, modelEscalations, the withEscalatedEffort/withEscalatedModel dispatch (:2317-2390, including the TOP_OF_LADDER assignment at :2380), the isLadderConfigured snapshot gate (:2157-2190), the divergence-suspect block (:3025-3055), consecutiveDivergenceSuspect and DIVERGENCE_SUSPECT_HALT_THRESHOLD. Keep: loopHalted, haltedByDivergence (now only SPEC_DIVERGENCE sets it), repeatHaltBundle/repeatHaltOutcome, ladderHaltOutcome (category ladder_halt unchanged, doc comment reworded), and buildBundle with escalationHistory: [].
    2. ready-gate.ts: remove both escalators around the QA and loop dispatches (:811-841, :932-961), the capability-bound/divergence-suspect detection (:985-1030), the TOP_OF_LADDER/DIVERGENCE_SUSPECT finishes, and the effortEscalations/modelEscalations fields of ReadyResult. Keep the SPEC_DIVERGENCE finishes (:863, :975), the halt bundle, and the loop's iteration logic exactly as it is (Non-Goal).
    3. phase-executor.ts: remove the config.modelEscalation env threading (:1696-1711) and the escalatedModel spread into the phase marker (:1958-1962). types.ts: remove effortEscalation, modelLadder* and modelEscalation from ExecutionConfig, ModelEscalationFacts, and escalateEffort/modelLadder from RunOptions. config-resolver.ts: remove the ladder resolver (:470-565) and its two assignments (:671-690).
    4. divergence-halt.ts: inline ModelEscalationRecord as a local read-shape type and update the comments that mention the module. The union and the formatter stay as they are (Non-Goal).
    5. Delete model-ladder.ts, effort-escalation.ts, and the test files model-ladder{,.recording}.test.ts, effort-escalation.test.ts, batch-executor.model-ladder.test.ts, phase-executor.{model-ladder,effort-escalation}.test.ts.

    Phase 2: Readers stay, writers stop (R-2)

    1. state-schema.ts, run-log-schema.ts and metrics-schema.ts keep every ladder field, ladder_halt, and the DIVERGENCE_SUSPECT/TOP_OF_LADDER bundle reasons as optional reads. Update the comments to say "read-only since chore(cli)!: remove the model ladder and effort escalation — modules, --model-ladder and --escalate-effort on run and ready, their settings and docs; old logs and settings still load #1647". createMetricRun/metrics-writer.ts drop their effortEscalations/modelEscalations options, while the schema still reads those fields. Turn metrics-schema.effort-escalation.test.ts into a test that legacy metrics rows still parse, or fold it into the AC-4 legacy test.
    2. run-orchestrator.ts:2462-2550 and ready.ts:65-269: remove the escalation merge, the printouts and the option passthrough.

    Phase 3: CLI, settings, tests

    1. bin/cli.ts: remove the four .option( blocks. settings.ts: remove effortEscalation/modelLadder from the interface, the schema, the defaults (:1101), KNOWN_KEYS and the generated settings-table row (:1845). Add REMOVED_KEYS with the one-warning behavior. Write settings.removed-keys.test.ts.
    2. Edit the dependent tests (batch-executor.test.ts, ready-gate{,.phase-policy,-run}.test.ts, execution-config-parity.test.ts, config-resolver.{phase-policy,model-roles}.test.ts, run-orchestrator.phase-policy.test.ts, settings.phase-policy.test.ts, ready{,.metrics}.test.ts, run-log-schema.test.ts, log-writer.test.ts, mcp/tools/run.test.ts, divergence-halt.test.ts, batch-executor.repeat-halt.test.ts). Remove the ladder assertions and keep each test's original purpose. Write run-log-schema.legacy.test.ts with its fixture.

    Phase 4: Docs and changelog

    1. Doc edits per AC-6, the ### Removed CHANGELOG entry, and the mutation record for AC-4 in the PR body. Run the full suite in the background, since it takes 10–13 minutes.

    Design Review

    1. Where does this belong? The quality loop (batch-executor.ts, ready-gate.ts) and the config surface (settings.ts, config-resolver.ts, cli.ts). The readers (the three schemas and logs.ts) only get comment changes.
    2. Simplest correct approach? Delete the modules, then follow the type errors outward. Rejected: a hidden flag (R-1), schema v2 (R-2), a hard error on old keys (R-3). There's no new design choice here, so no ADR is needed.
    3. Existing pattern, and how often re-patched? This follows the 2026-04 descoping (arch: extract RunOrchestrator — decouple execution engine from CLI wiring #503–arch: in-process MCP engine — eliminate subprocess indirection and enable real-time streaming #508): one outcome per named surface. git log -S isLadderConfigured shows the ladder was built across feat(run): model escalation ladder on capability-bound non-convergence #971/feat(config): model roles — semantic indirection between phase policy/ladders and concrete model strings #975/feat(run): SPEC_DIVERGENCE escape hatch, ladder halts with evidence bundles, docs, rigged real run (#971 part B) #995/fix(run): a ladder halt is recorded nowhere: the halting phase reads success, failureCategory is empty, and the bundle exists only on stdout #1254. There have been no fix-on-fix issues against the removal path, so nothing to stop on.
    4. What would a senior reviewer challenge? (a) "Why does SPEC_DIVERGENCE still write ladder_halt when the ladder is gone?" Because a new category needs error-classifier.ts (outside May-touch) and changes the log shape, which goes against I-2. The runner comment of 2026-11-08 agrees. The spec agrees: keep ladder_halt, no divergence. (b) "Why keep DIVERGENCE_SUSPECT/TOP_OF_LADDER in the schemas?" Old logs carry them (R-2). (c) "Does deleting the divergence-suspect block change the behavior of a run with no ladder?" No. It could only run when the snapshot existed, and the snapshot was only taken when a ladder was configured (comment at :3033).
    5. Producers and consumers (whole-repo grep). Producers: bin/cli.ts, settings.ts, config-resolver.ts, batch-executor.ts, ready-gate.ts, phase-executor.ts (env vars plus marker spread), run-orchestrator.ts, ready.ts, metrics-writer.ts/createMetricRun. Consumers: state-schema.ts, run-log-schema.ts, metrics-schema.ts, logs.ts, mcp/tools/run.ts (haltReason), divergence-halt.ts (formatter). After the change, every producer is gone and every consumer stays as a read-only reader. scripts/spec/ground-check.ts:257 only mentions escalateEffort as an example inside a doc comment. Leave it.

    Feature Quality Planning

    The standard checks pass. Notable items:

    • Settings warning bug (AC-3 assumptions): today a valid run.effortEscalation warns as unknown. The new test pins exactly one warning per key.
    • Doc content that must survive: the SPEC_DIVERGENCE escape hatch and the evidence-bundle docs now live in model-ladder.md (AC-6, OQ-1).
    • Breaking-change notice: the title has !. The CHANGELOG entry should say that the flags error as unknown options from this release, and that the settings keys warn and are ignored.

    Derived ACs

    • From docs: docs/THREAT-MODEL.md must not link to the deleted model-ladder.md. Medium priority.

    Open Questions

    1. What happens to docs/reference/model-ladder.md? Recommendation: rename it to spec-divergence-halt.md and keep the divergence and repeat-halt content. Impact if wrong: the only reference for a halt that still exists gets deleted.
    2. Should the producer-side unions be narrowed? Recommendation: remove DIVERGENCE_SUSPECT/TOP_OF_LADDER from ReadyTerminalReason in ready-gate.ts, which is now producer-only. Keep them in LadderHaltReason (divergence-halt.ts, a Non-Goal), in the run-log schema, and in the MCP haltReason type, because those can still read an old log. Impact if wrong: dead union members, or a reader that rejects an old log.
    3. Should ladderHaltOutcome be renamed? Recommendation: keep the name and update its doc comment. A rename touches the tests and adds nothing, and the category stays the same either way.

    Recommended Workflow

    Phases: exec → qa
    Quality Loop: enabled
    Reasoning: A large, mechanical deletion across about 25 files, with test edits that are easy to over-trim. The two new tests are named in the ACs and are small, so testgen isn't needed.


    Label Review

    Current: graph-2026-11-simplify
    Recommended: add refactor and breaking (the title has !), plus planned.
    Quality Loop: enabled by the scope warning and the refactor label.

  5. added
    planned
    refactor
    on Nov 8, 2026
  6. admarble commented on Nov 8, 2026

    @admarble
    ContributorAuthor

    QA Verdict: READY_FOR_MERGE

    AC coverage: 8/8 met

    Reviewed in a separate session by claude-code (claude-opus-5-5); the change author was not recorded.

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

    graph-2026-11-simplifyplannedrefactor

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions