Skip to content

feat(run): per-phase model and effort configuration for the claude-code driver #914

Closed

Description

@admarble

Motivation

Users are reporting an Opus 5 regression in code/docs output: overthinking, verbose jargon-heavy prose, overcomplex implementations (see the widely-upvoted r/ClaudeAI thread on stopping Opus 5 from writing documentation). The community consensus fix is phase splitting: plan with a stronger model, delegate implementation to Sonnet. Sequant already has the phase boundaries (spec/exec/qa) where that split is natural — it just doesn't expose the knob.

Today ClaudeCodeDriver.executePhase() passes no model and no effort to the Agent SDK query() call, so every phase inherits the CLI default. The SDK supports both at the session level:

  • Options.model — "Claude model to use. Defaults to the CLI default model."
  • Options.effort — low | medium | high | xhigh | max (default high), "works with adaptive thinking to guide thinking depth."

Because upstream claude-code#43869 makes subagents inherit the parent session's model (subagent model: frontmatter is silently ignored — see #632), setting the phase session model also governs the sequant-implementer/qa-checker subagents that phase spawns. One knob controls the whole phase tree.

Design

Settings — a per-phase map under run, absent-by-default (zero behavior change until opted in):

"run": {
  "phases": {
    "spec": { "model": "fable" },
    "exec": { "model": "sonnet", "effort": "medium" },
    "qa":   { "effort": "high" }
  }
}

CLI overrides on sequant run (and ready), highest precedence:

  • --models <spec> — either a bare value applied to all phases (--models sonnet) or a comma list of phase=model pairs (--models spec=fable,exec=sonnet)
  • --efforts <spec> — same grammar (--efforts exec=medium)

Wiring (standard flag trace: bin/cli.ts → RunOptions → ExecutionConfig → phase-executor → driver):

Validation: pass model aliases/IDs through to the SDK without hard validation (model IDs churn; the SDK errors clearly on a bad one). Effort values validate against the closed enum low|medium|high|xhigh|max at settings-parse time.

Metrics: record the resolved model and effort per phase in run metrics (closed-enum/alias strings only — consistent with the privacy contract in metrics-schema.ts). This is the foundation for measuring whether phase splitting affects quality (#437 follow-up; replay bench tracked separately).

Acceptance Criteria

  • run.phases.<phase>.model and run.phases.<phase>.effort are parsed from settings, validated (effort against the closed enum, unknown phase names rejected with a warning), and default to absent
  • sequant run --models exec=sonnet and --efforts exec=medium override settings; a bare value (--models sonnet) applies to all phases; malformed specs fail fast with a usage error
  • With no per-phase config present, the query() options object contains neither model nor effort (behavior identical to today, verified by a driver unit test)
  • ClaudeCodeDriver forwards configured model/effort into query() options, verified by a unit test asserting the options object
  • Both buildExecutionConfig and ready-gate.ts:buildPhaseConfig resolve per-phase model/effort with identical precedence (CLI > settings > absent), each covered by its own test
  • The Aider driver is unaffected by run.phases config (test: config present, Aider args unchanged)
  • Run metrics record the resolved model and effort per phase when set, and omit the fields when inherited
  • --models/--efforts are registered via .option() in bin/cli.ts and survive the RunOptions dead-surface test
  • README + docs/ document the settings shape, CLI flags, precedence, and the subagent-inheritance note (fix(agents): realign declared model tiers; document upstream routing bug #632 upstream bug means subagents follow the phase model)

Activity

  1. added
    enhancement
    cli
    on Aug 8, 2026
  2. admarble commented on Aug 8, 2026

    @admarble
    ContributorAuthor

    Complexity: Complex (9 ACs, ~3 directories: src/lib/workflow, bin/, docs/)

    AC Quality Check

    All 9 ACs are measurable and verifiable — each names a concrete artifact (settings key, CLI flag, query() options object, a specific test). No vague/unmeasurable/open-ended patterns. One note: AC-7 ("omit the fields when inherited") and AC-3 ("contains neither model nor effort") assert absence, which needs a mutation-verified test (assert the key is not present, not merely falsy) to avoid a vacuous pass.


    Scope Assessment

    Non-Goals: ⚠️ No explicit Non-Goals section. Implied out-of-scope from the body: hard model-ID validation (pass-through to SDK), the replay A/B bench (#916), and evidence-based effort escalation (#915). Recommend confirming these stay out.

    Metric Value Status
    Feature count 1 (per-phase model/effort knob) ✅
    AC items 9 ❌ (red ≥9)
    Directory spread ~3 ⚠️

    Verdict: ⚠️ SCOPE_WARNING — AC count trips the red line, but the 9 ACs are facets of one cohesive flag trace (settings → CLI → ExecutionConfig → executor → driver → metrics → docs), not independent features. Splitting would fracture a single wire. Recommend: keep as one issue, enable the quality loop.


    Acceptance Criteria

    AC-1: Settings parse/validate run.phases.<phase>.{model,effort}, default absent

    Verification: Unit Test
    Scenario: Given a settings object with run.phases.exec.effort = "medium" → When parsed by RunSettingsSchema → Then it round-trips; an invalid effort ("turbo") is rejected at parse; an unknown phase name emits a SettingsWarning (non-fatal); absent run.phases yields undefined.
    Assumptions: Effort validates against closed enum low|medium|high|xhigh|max. Unknown-phase-name → warning (settings side), distinct from CLI fail-fast.

    AC-2: CLI --models / --efforts override settings; bare value = all phases; malformed = usage error

    Verification: Integration Test (CLI parse) + Unit Test (spec parser)
    Scenario: Given --models exec=sonnet → exec overridden, others untouched. Given --models sonnet → applied to all phases. Given --models spec= or --models sonnet,exec=fable (mixed) or --models badphase=x → process exits with a usage error naming the flag.
    Assumptions: Fail-fast happens at the Commander .option() boundary (mirrors parseWholeNumber for --auto-wait, #804), so it shows in --help and never silently no-ops (#305 class).

    AC-3: No per-phase config → query() options contain neither model nor effort

    Verification: Unit Test (driver)
    Scenario: Given AgentExecutionConfig with model/effort unset → When ClaudeCodeDriver.executePhase builds query({options}) → Then "model" in options === false and "effort" in options === false.
    Assumptions: Uses in/key-presence assertion, not truthiness — this is the mutation-verified absence gate.

    AC-4: ClaudeCodeDriver forwards configured model/effort into query() options

    Verification: Unit Test (driver)
    Scenario: Given config {model:"sonnet", effort:"medium"} → Then the query() options object contains model:"sonnet" and effort:"medium".

    AC-5: buildExecutionConfig AND ready-gate.ts:buildPhaseConfig resolve per-phase model/effort with identical precedence (CLI > settings > absent)

    Verification: Unit Test ×2 (one per producer)
    Scenario: Given CLI exec=sonnet + settings exec.model=opus → both producers resolve exec→sonnet. Given only settings → both resolve to settings. Given neither → both resolve absent.
    Assumptions: ⚠️ #833 drift hazard — the two producers diverged before. Mitigate with a single shared resolver both call (see Design).

    AC-6: Aider driver unaffected by run.phases

    Verification: Unit Test
    Scenario: Given run.phases.exec.model="sonnet" present → When Aider driver runs → Then its args/settings.model are byte-identical to the no-config case.

    AC-7: Run metrics record resolved model/effort per phase when set; omit when inherited

    Verification: Unit Test
    Scenario: Given exec resolved to {model:"sonnet"} and qa inherited → Then the metric record carries exec's model (and effort if set) and omits fields for qa.
    Assumptions: Closed-enum/alias strings only, per the metrics-schema.ts privacy contract. See Open Question 2 on metrics vs run-log placement.

    AC-8: --models/--efforts registered via .option() and survive the RunOptions dead-surface test

    Verification: Integration Test
    Scenario: Given the run command → Then both flags parse, appear in --help, and run-options-dead-surface.test.ts sees a live consumer for each new RunOptions field (not inert).

    AC-9: README + docs/ document settings shape, CLI flags, precedence, and the #632 subagent-inheritance note

    Verification: Manual Test (docs content verification)
    Scenario: Given the docs → Then the settings shape, both flags, the CLI>settings>absent precedence, and the "subagents follow the phase model (#632/#43869)" note all appear. Verify content coverage in all locations (main README, marketplace README if present, docs/), not file existence.


    Rule Touchpoints

    This feature is a multi-touchpoint rule — the same "resolve per-phase model/effort" logic must live at every hop, and #833 is the recorded failure of exactly two of them drifting. Touchpoints the implementation must keep in lockstep:

    Concern Touchpoint Note
    Resolve precedence config-resolver.ts:buildExecutionConfig producer 1
    Resolve precedence ready-gate.ts:buildPhaseConfig (via ready.ts) producer 2 — drifted in #833
    Per-phase lookup phase-executor.ts:1258 (agentConfig build) applies map to the running phase
    Forward to SDK drivers/claude-code.ts:121 (query options) claude-code only
    Ignore drivers/aider.ts must stay inert

    Implementation Plan

    Phase 1: Types & settings (foundation)

    1. settings.ts — add PhasePolicySchema = z.object({ model: z.string().optional(), effort: z.enum(["low","medium","high","xhigh","max"]).optional() }). Add phases?: Record<string, PhasePolicy> to RunSettings + RunSettingsSchema (z.record(...).optional()). Add "phases" to KNOWN_KEYS.run, and emit a SettingsWarning for any phase key not in getPhaseNames().
    2. agent-driver.ts — add optional model?: string and effort?: string to AgentExecutionConfig.
    3. types.ts — add phasePolicies?: Record<string, { model?: string; effort?: string }> to ExecutionConfig, and models?: string / efforts?: string (raw specs) to RunOptions.

    Phase 2: Shared resolver (the #833 firewall)

    1. config-resolver.ts — add exported parsePhaseSpec(spec, phaseNames) (grammar: bare → {"*": v}, else comma list of phase=value; throws on malformed / unknown phase) and resolvePhasePolicies(cliModels, cliEfforts, settingsPhases, phaseNames) returning the merged Record<phase,{model?,effort?}> with CLI > settings > absent. Both producers call this one function — mirrors how positiveOr was extracted to serve both timeout producers (fix(cli): bare parseInt on run --timeout lets a malformed value abort every phase instantly (sibling of #818) #833 doc comment).

    Phase 3: Wire both producers

    1. config-resolver.ts:buildExecutionConfig — populate phasePolicies via resolvePhasePolicies(...).
    2. ready.ts + ready-gate.ts — add resolved policies to RunReadyGateOptions; buildPhaseConfig spreads them onto its ExecutionConfig. (Decide: does sequant ready get its own --models/--efforts flags? Body says "run (and ready)" → yes; see Open Question 1.)

    Phase 4: Apply & forward

    1. phase-executor.ts:1258 — look up config.phasePolicies?.[phase] and set agentConfig.model/agentConfig.effort only when present.
    2. drivers/claude-code.ts:121 — spread ...(config.model ? {model: config.model} : {}) and ...(config.effort ? {effort: config.effort} : {}) into query() options.

    Phase 5: CLI + metrics + docs

    1. bin/cli.ts — register --models <spec> and --efforts <spec> with a custom fail-fast parser (validate grammar + phase names + effort enum, model IDs pass through).
    2. metrics-schema.ts — add optional per-phase {model?, effort?} to MetricRunSchema (enum/alias strings only); populate from resolved phasePolicies at createMetricRun. Omit when inherited.
    3. README.md + docs/ — settings shape, flags, precedence, fix(agents): realign declared model tiers; document upstream routing bug #632 note.

    Phase 6: Tests (testgen-seeded)

    1. Driver absence + forwarding (AC-3/4, key-presence assertions), both-producer parity (AC-5), Aider inertness (AC-6), settings validate/warn (AC-1), CLI parse/malformed (AC-2/8), metrics per-phase (AC-7). Mutation-verify the absence and gate tests.

    Design Review

    1. Where does this logic belong? Spec resolution in config-resolver.ts (already the 4-layer merge home); a single shared resolver called by both producers. Per-phase application in phase-executor.ts (it alone knows which phase is running). SDK forwarding isolated to claude-code.ts (owns the SDK import).
    2. Simplest correct approach? A resolved Record<phase,{model?,effort?}> on ExecutionConfig + two optional driver fields. Rejected: resolving inside the driver (driver doesn't know settings/CLI); resolving in buildExecutionConfig per-phase-into-flat-fields (loses the phase dimension). Rejected hard model-ID validation per the issue (IDs churn; SDK errors clearly).
    3. Existing pattern? Follows positiveOr (fix(cli): bare parseInt on run --timeout lets a malformed value abort every phase instantly (sibling of #818) #833) — extract one resolver to serve both phaseTimeout producers — applied here to model/effort. Follows --auto-wait's fail-fast .option() parser (feat(run): --auto-wait — continue a rate-limited run when the window resets instead of halting #804) for the CLI grammar.
    4. What would a senior reviewer challenge? "Why a map on ExecutionConfig instead of flat fields?" — because one ExecutionConfig drives all phases of an issue; the phase is only known at executePhase. "Did you wire both producers?" — yes, AC-5 gates it with a test each, and they share one resolver so they cannot drift.

    Feature Quality Planning

    Standard checks pass. Notable items:

    • Drift (fix(cli): bare parseInt on run --timeout lets a malformed value abort every phase instantly (sibling of #818) #833): the load-bearing risk. Shared resolver + per-producer tests are the mitigation, not optional polish.
    • Vacuous absence tests: AC-3/AC-7 must assert key absence ("model" in options), and be mutation-verified (add a stray model, confirm the test fails) per the repo's gate-test rule.
    • Metrics privacy: only enum/alias strings enter metrics — never a resolved full model ID if it could carry anything sensitive (aliases are safe; the issue scopes to alias/enum strings).
    • Non-claude drivers: Aider inertness is an explicit AC — assert args unchanged, don't just omit forwarding.

    Derived ACs

    Source Derived AC Priority
    Drift hazard Shared resolver has a direct unit test proving CLI>settings>absent, independent of the two producer tests Medium

    Open Questions

    1. Does sequant ready get its own --models/--efforts flags? — The body says "on sequant run (and ready)". Recommendation: yes, add them to the ready command too, feeding the same shared resolver. Impact if skipped: AC-5's ready-side test can still pass via settings-only, but the "(and ready)" CLI promise goes unmet.
    2. Metrics placement — metrics-schema.ts vs run-log PhaseLogSchema? — AC-7 + body say "run metrics" and name metrics-schema.ts. Recommendation: add per-phase fields to MetricRunSchema (literal reading). Note: run-log PhaseLogSchema would be the natural home for the replay bench (bench: replay outcome-distribution smoke for roster/policy changes (descoped from A/B ranking — phase-0) #916) and is per-phase already — worth mirroring there as a cheap follow-up, but only metrics is required here.
    3. Precedence asymmetry — CLI fails fast on unknown phase names, settings only warns. Recommendation: keep it (CLI is interactive/immediate; settings shouldn't hard-crash a run on a typo). Flag explicitly in docs.

    Recommended Workflow

    Phases: spec → testgen → exec → qa
    Quality Loop: enabled
    Reasoning: ACs are Unit/Integration-heavy on a wiring change with a known drift trap (#833) → testgen seeds the absence/parity/inertness stubs before exec; quality loop justified by the 9-AC breadth and SCOPE_WARNING. No UI → no test phase. Not security-sensitive → no security-review.


    Label Review

    Current: enhancement, cli
    Recommended: add complex (9 ACs, multi-touchpoint wiring)
    Reason: Signals the quality loop and the Complex output tier; matches the cross-cutting flag trace.
    Quality Loop: Will auto-enable under SCOPE_WARNING.

    → gh issue edit 914 --add-label complex


    --- DRAFT GITHUB ISSUE COMMENT (PLAN) ---

    This comment is the plan of record for #914.

  3. added
    planned
    on Aug 8, 2026
  4. admarble commented on Aug 8, 2026

    @admarble
    ContributorAuthor

    #914 — feat(run): per-phase model and effort configuration for the claude-code driver
    Open · enhancement, cli
    ────────────────────────────────────────────────────────────────

    → PROCEED — Foundation knob; clear ACs, wiring path known

    Commands:
    sequant run 914 -Q --phases testgen,exec,qa # after in-flight spec

    spec → testgen → exec → qa · 9 ACs

    Flags:
    -Q multi-file wiring across bin/cli.ts, config-resolver, ready-gate, driver, metrics
    --phases testgen,exec,qa spec already running for this issue; testgen from unit-test ACs
    ────────────────────────────────────────────────────────────────
    ⚠ Locked by an in-flight spec-only run at assessment time — wait for it before exec
    ⚠ #915 layers on this issue's effort resolver; land this first (or chain 914 → 915)
    ────────────────────────────────────────────────────────────────

  5. admarble commented on Aug 8, 2026

    @admarble
    ContributorAuthor

    Test Stubs Generated (/testgen)

    Generated from the spec's 9 ACs. All new files were run against vitest to confirm they fail for the right reason (missing symbols / unimplemented behavior — verified: TypeError: X is not a function or an assertion on undefined), not a syntax error.

    AC Verification File Stubs
    AC-1 Unit Test src/lib/settings.phase-policy.test.ts 4
    AC-2 Unit Test (spec parser) src/lib/workflow/config-resolver.phase-policy.test.ts (parsePhaseSpec) 5
    AC-2 Integration (CLI parse) src/lib/cli-flags.phase-policy.test.ts (parsePhaseSpecFlag) 2 (incl. it.each ×3)
    AC-3/AC-4 Unit Test (driver) src/lib/workflow/drivers/claude-code.phase-policy.test.ts 2
    AC-5 Unit Test ×2 (producer parity) config-resolver.phase-policy.test.ts (resolvePhasePolicies + producer 1) + ready-gate.phase-policy.test.ts (producer 2) 5 + 1
    AC-6 Unit Test src/lib/workflow/drivers/aider.phase-policy.test.ts 1
    AC-7 Unit Test src/lib/workflow/metrics-schema.phase-policy.test.ts 3
    AC-8 Integration Test Appended #914 AC-8 describe block to src/lib/workflow/run-options-dead-surface.test.ts (mirrors the existing readyGate live-surface guard) 3
    AC-9 Manual Test (docs) N/A — content-coverage check, no test file Skipped

    Naming/shape choices made as stub proposals (not locked contracts) — /exec may rename during implementation:

    • parsePhaseSpec(spec, phaseNames) and resolvePhasePolicies(cliModels, cliEfforts, settingsPhases, phaseNames) exported from config-resolver.ts, called by both producers (the fix(cli): bare parseInt on run --timeout lets a malformed value abort every phase instantly (sibling of #818) #833 firewall).
    • ExecutionConfig.phasePolicies: Record<phase, {model?, effort?}>.
    • cli-flags.ts:parsePhaseSpecFlag(flag, phaseNames) wraps parsePhaseSpec, converts to InvalidArgumentError at the CLI boundary.
    • MetricRun.phasePolicies mirrors the same shape (Open Question 2 in the spec — recommend confirming during /exec).

    AC-3's absence check already passes today (the current driver forwards nothing), confirming it's a true regression gate, not a new behavior.


    Generated with Claude Code

  6. admarble commented on Aug 8, 2026

    @admarble
    ContributorAuthor

    Exec Complete

    Tests: ✅ 5255 passed | 1 expected fail | 2 skipped (253 files) — full suite, no regressions
    Build: ✅ tsc clean
    Lint: ✅ eslint --max-warnings 0 clean

    Pre-PR AC Verification

    AC Description Status Evidence
    AC-1 Settings parse/validate run.phases.<phase>.{model,effort}, default absent ✅ Implemented settings.ts (PhasePolicySchema, KNOWN_KEYS["run.phases"]); settings.phase-policy.test.ts (4/4)
    AC-2 CLI --models/--efforts override settings; bare=all phases; malformed=usage error ✅ Implemented config-resolver.ts:parsePhaseSpec, cli-flags.ts:parsePhaseSpecFlag; config-resolver.phase-policy.test.ts, cli-flags.phase-policy.test.ts
    AC-3 No config → query() options contain neither model nor effort ✅ Implemented claude-code.ts; key-presence (in) assertion — passes unmodified, confirming it's a live gate not a new behavior
    AC-4 ClaudeCodeDriver forwards configured model/effort ✅ Implemented claude-code.ts; claude-code.phase-policy.test.ts
    AC-5 Both producers resolve identically (CLI > settings > absent) ✅ Implemented Shared resolvePhasePolicies; config-resolver.phase-policy.test.ts (producer 1) + ready-gate.phase-policy.test.ts + ready.phase-policy.test.ts (producer 2, both layers)
    AC-6 Aider driver unaffected ✅ Implemented (no code change needed) aider.phase-policy.test.ts
    AC-7 Metrics record resolved model/effort per phase, omit when inherited ✅ Implemented metrics-schema.ts, wired into run-orchestrator.ts's recordRun call; metrics-schema.phase-policy.test.ts
    AC-8 --models/--efforts registered via .option(), survive dead-surface test ✅ Implemented bin/cli.ts (run + ready commands); live-surface guard added to run-options-dead-surface.test.ts
    AC-9 README + docs document shape/flags/precedence/#632 note ✅ Implemented New "Per-Phase Model & Effort" section in docs/reference/run-command.md + docs/reference/ready-command.md options table. Not separately duplicated into the top-level README, consistent with how comparable flags (--ready-gate, --auto-wait) are documented only in docs/reference/run-command.md

    Quality Plan Alignment

    Dimension Status Notes
    #833 drift hazard ✅ Mitigated One shared resolvePhasePolicies resolver called by both buildExecutionConfig and ready-gate.ts:buildPhaseConfig — cannot drift structurally
    Vacuous absence tests ✅ Addressed AC-3 asserts key presence ("model" in options) not truthiness
    Metrics privacy ✅ Addressed phasePolicies on MetricRunSchema is enum/alias strings only, same contract as the rest of the schema
    Non-claude drivers ✅ Addressed Aider inertness has an explicit test, not just omission

    Pre-PR Confidence Check

    • Weakest part: phase-executor.ts's executePhase (unexported) is where config.phasePolicies[phase] actually becomes AgentExecutionConfig.model/.effort, and it has no direct end-to-end unit test — this file's existing tests exercise executePhaseWithRetry via an injectable executePhaseFn that bypasses executePhase's real body entirely (a pre-existing architectural limit; neighboring fields like config.mcp get the same treatment). The change is a minimal, mechanically-mirrored 3-line addition, and both sides of it are independently verified — producers build ExecutionConfig.phasePolicies correctly (config-resolver.phase-policy.test.ts, ready-gate.phase-policy.test.ts), and the driver forwards AgentExecutionConfig.model/.effort correctly (claude-code.phase-policy.test.ts) — only the connecting line in between is unverified by an automated test.
    • Coverage gaps: run-orchestrator.ts's phasePolicies: config.phasePolicies pass-through into recordRun, and metrics-writer.ts's recordRun → createMetricRun pass-through, are both untested directly — each is a single-line, no-transformation pass-through, and createMetricRun itself is fully tested (metrics-schema.phase-policy.test.ts), so risk is low. Same treatment as untested neighbor fields in that call (e.g. flags, failureCategory).

    Files Changed (22)

    settings.ts, config-resolver.ts, ready-gate.ts, ready.ts, agent-driver.ts, claude-code.ts, phase-executor.ts, metrics-schema.ts, metrics-writer.ts, run-orchestrator.ts, types.ts, cli-flags.ts, bin/cli.ts, CHANGELOG.md, docs/reference/run-command.md, docs/reference/ready-command.md, plus 8 test files (7 from /testgen, 1 new: ready.phase-policy.test.ts).

    Proceeding to QA.

  7. admarble commented on Aug 8, 2026

    @admarble
    ContributorAuthor

    QA Review for Issue #914

    AC Coverage

    AC Source Description Status Notes
    AC-1 Original run.phases.<phase>.{model,effort} parsed/validated, default absent MET PhasePolicySchema + RunSettingsSchema.phases; KNOWN_KEYS["run.phases"] computed from getPhaseNames() so a typo warns (verified: settings.phase-policy.test.ts 4/4, including the unknown-phase-name warning)
    AC-2 Original --models/--efforts override settings; bare=all; malformed=usage error MET Verified live: sequant run 1 --models "sonnet,exec=fable" → error: option '--models <spec>' argument ... is invalid with exit code 1; --models "badphase=x" → names the unknown phase and lists valid ones
    AC-3 Original No config → query() options contain neither model nor effort MET Key-presence (in) assertion, not truthiness; passes unmodified against the pre-#914 driver, confirming it's a live regression gate not new behavior
    AC-4 Original ClaudeCodeDriver forwards configured model/effort MET claude-code.ts conditional spread into query() options; claude-code.phase-policy.test.ts
    AC-5 Original Both producers resolve identically (CLI > settings > absent), each with its own test MET One shared resolvePhasePolicies; producer 1 (config-resolver.phase-policy.test.ts) + producer 2 (ready-gate.phase-policy.test.ts + ready.phase-policy.test.ts, both layers of the ready path) + a resolver-only precedence test independent of both producers (derived AC, see Quality Plan below)
    AC-6 Original Aider driver unaffected by run.phases MET No code change needed (Aider never reads AgentExecutionConfig.model/.effort); explicit inertness test, not just omission
    AC-7 Original Metrics record resolved model/effort per phase when set, omit when inherited MET MetricRunSchema.phasePolicies; wired through run-orchestrator.ts's recordRun call; metrics-schema.phase-policy.test.ts
    AC-8 Original --models/--efforts registered via .option(), survive dead-surface test MET Verified live via --help on both run and ready; live-surface guard added to run-options-dead-surface.test.ts
    AC-9 Original README + docs document shape/flags/precedence/#632 note MET Verified by grep against the actual doc files (not just review): settings shape, both flags, precedence line, and the #632/#43869 note all present in docs/reference/run-command.md + docs/reference/ready-command.md

    Coverage: 9/9 AC items fully met


    Quality Plan Verification

    Spec's Feature Quality Planning section identified 4 load-bearing items:

    Dimension Item Status
    Drift hazard (#833 class) Shared resolver mitigates, not optional polish ✅ Addressed — resolvePhasePolicies is the single function both producers call
    Vacuous absence tests AC-3/AC-7 must assert key absence, mutation-verified ✅ Addressed — "model" in options presence check, passes unmodified pre-#914
    Metrics privacy Only enum/alias strings in metrics ✅ Addressed — phasePolicies schema is {model?: string, effort?: string}, no file content
    Non-claude drivers Aider inertness needs an explicit test ✅ Addressed — aider.phase-policy.test.ts

    Derived AC (Drift hazard, Medium priority): "Shared resolver has a direct unit test proving CLI>settings>absent, independent of the two producer tests" → ✅ Addressed — config-resolver.phase-policy.test.ts's resolvePhasePolicies precedence describe block tests the resolver directly, not through either producer.

    Quality Plan Status: Complete (4/4)


    CI Status

    No PR exists yet for this issue — CI status will be checked at PR creation.


    Quality Metrics

    Metric Value Status
    Type issues (any) 0 OK
    Deleted tests 0 OK
    Files changed 25 OK — proportional to a Complex 9-AC feature (15/25 in src/lib/workflow)
    Lines added +1085 -
    Lines deleted -2 - (additive, non-invasive)

    Test Coverage Analysis

    Changed File Tier Has Tests? Test File
    settings.ts Standard ✅ Yes settings.phase-policy.test.ts
    config-resolver.ts Standard ✅ Yes config-resolver.phase-policy.test.ts
    ready-gate.ts Standard ✅ Yes ready-gate.phase-policy.test.ts
    ready.ts Standard ✅ Yes ready.phase-policy.test.ts
    agent-driver.ts Standard ✅ Yes (via driver tests) claude-code.phase-policy.test.ts, aider.phase-policy.test.ts
    claude-code.ts Standard ✅ Yes claude-code.phase-policy.test.ts
    metrics-schema.ts Standard ✅ Yes metrics-schema.phase-policy.test.ts
    cli-flags.ts Standard ✅ Yes cli-flags.phase-policy.test.ts
    bin/cli.ts Standard ✅ Yes (via live-surface guard + smoke test) run-options-dead-surface.test.ts
    types.ts Optional - (type-only) -
    phase-executor.ts Standard ⚠️ No direct test See Risk Assessment — pre-existing architectural gap for this unexported function
    metrics-writer.ts Standard ⚠️ No direct test Pure pass-through wrapper; createMetricRun (which it calls unchanged) is fully tested
    run-orchestrator.ts Standard ⚠️ No direct test Single-line pass-through (phasePolicies: config.phasePolicies); same treatment as untested neighbor fields in that call

    Coverage: 10/13 changed source files have direct tests; the 3 gaps are all thin pass-through/wiring points whose inputs (the resolver, createMetricRun) are independently fully tested.


    Code Review

    Strengths:

    • The fix(cli): bare parseInt on run --timeout lets a malformed value abort every phase instantly (sibling of #818) #833 drift hazard is structurally prevented, not just tested against: one resolvePhasePolicies function is the only place CLI>settings>absent precedence is computed, called by both buildExecutionConfig and ready-gate.ts:buildPhaseConfig.
    • AC-3's absence assertion uses "model" in options, not options.model truthiness — the correct mutation-resistant form for a "must not exist" claim.
    • Consistent ...(x ? {field: x} : {}) conditional-spread idiom used identically in claude-code.ts (SDK options) and phase-executor.ts (AgentExecutionConfig) — same pattern, same guarantee, at both hops.
    • effort uses a closed literal-union type ("low"|"medium"|"high"|"xhigh"|"max") on AgentExecutionConfig and in settings.ts, narrowing only at the driver boundary — avoids threading an unsafe as cast through every intermediate layer.

    Issues:

    • None blocking.

    Suggestions:

    • run-orchestrator.ts's phasePolicies: config.phasePolicies and metrics-writer.ts's recordRun pass-through have no direct test (see Test Coverage Analysis) — low risk given both are untransformed pass-throughs, but a follow-up could close this if the team wants full-chain coverage.

    Anti-Pattern Detection

    File:Line Category Pattern Suggestion
    — — None found —

    No hardcoded secrets, SQL concatenation, eval/innerHTML, uncleared timers, or N+1 patterns. No package.json changes — dependency audit N/A.


    Call-Site Review

    New exported functions detected: 3

    Function Call Sites Loop? Conditions AC Match
    parsePhaseSpec (config-resolver.ts) resolvePhasePolicies (config-resolver.ts), parsePhaseSpecFlag (cli-flags.ts) No Called unconditionally when a spec string is present ✅ Matches AC-2
    resolvePhasePolicies (config-resolver.ts) buildExecutionConfig (config-resolver.ts), readyCommand (ready.ts) No Called unconditionally per run/ready invocation ✅ Matches AC-5
    parsePhaseSpecFlag (cli-flags.ts) bin/cli.ts ×4 (run and ready commands, --models/--efforts each) No Commander .option() coercion, always invoked when the flag is passed ✅ Matches AC-2/AC-8

    Findings: None — all three new exports have real production call sites matching their AC, no dead exports.


    Execution Evidence

    Test Type Command Exit Code Result
    Happy path (help) node dist/bin/cli.js run --help 0 --models/--efforts appear with correct descriptions
    Happy path (help) node dist/bin/cli.js ready --help 0 --models/--efforts appear with correct descriptions
    Happy path (valid spec) node dist/bin/cli.js run 1 --models exec=sonnet --efforts exec=medium --dry-run (parses cleanly, fails later on unrelated "not initialized") Flags parse without error
    Edge case (mixed bare+pair) node dist/bin/cli.js run 1 --models "sonnet,exec=fable" --dry-run 1 error: option '--models <spec>' argument ... is invalid. --models: Malformed spec segment 'sonnet' ...
    Error handling (unknown phase) node dist/bin/cli.js run 1 --models "badphase=x" --dry-run 1 Names badphase and lists all 9 valid phases

    Evidence status: Complete


    CLI Registration Verification

    Interface Field Runtime Usage CLI Registered Status
    RunOptions.models mergedOptions.models in config-resolver.ts:buildExecutionConfig --models <spec> on run command ✅ OK
    RunOptions.efforts mergedOptions.efforts in config-resolver.ts:buildExecutionConfig --efforts <spec> on run command ✅ OK
    ReadyCommandOptions.models options.models in ready.ts:readyCommand --models <spec> on ready command ✅ OK
    ReadyCommandOptions.efforts options.efforts in ready.ts:readyCommand --efforts <spec> on ready command ✅ OK

    Verification Status: Passed


    Smoke Test

    Test Command Result Notes
    Happy path run --help / ready --help ✅ Flags present with correct help text
    Edge case run 1 --models "sonnet,exec=fable" --dry-run ✅ Correctly rejected, exit 1
    Error handling run 1 --models "badphase=x" --dry-run ✅ Clear error naming the bad phase + valid list

    Smoke Test Status: Complete


    Manual Test ACs

    AC Verification Method Runtime Test Status Evidence
    AC-9 Manual Test (docs content verification) ✅ Executed Grepped the actual doc files for each required element (settings shape, both flags, precedence line, #632/#43869 note) rather than relying on review alone — all 4 present

    Manual Test Enforcement: 1/1 manual-test ACs verified at runtime


    Risk Assessment

    • Likely failure mode: The connective wiring in phase-executor.ts's unexported executePhase — the exact line that reads config.phasePolicies?.[phase] and sets agentConfig.model/.effort — has no direct end-to-end unit test. If a future refactor of that function accidentally drops or misindexes the lookup, no automated test would catch it (both endpoints — the producers building phasePolicies, and the driver forwarding AgentExecutionConfig fields — are independently tested, but the middle connection is not).
    • Not tested: run-orchestrator.ts's and metrics-writer.ts's single-line phasePolicies pass-throughs (see Test Coverage Analysis) — low risk, no transformation happens at either site.
    • Sibling sites considered: Adversarially re-scanned for other ExecutionConfig producers beyond the two AC-5 names — found batch-executor.ts also constructs ExecutionConfig-typed values (issueConfig, loopConfig) and phase-executor.ts has a third (configWithoutMcp, MCP-fallback retry). Inspected all three: each is a {...config, ...} spread of a config already produced by buildExecutionConfig, not an independent producer — phasePolicies flows through automatically. No third drift-prone site exists.
    • Sibling-line audit: N/A — the two-producer pattern (buildExecutionConfig / ready-gate.ts:buildPhaseConfig) is the sibling pair the feature was built around; both were updated together by design, not discovered as an afterthought.

    Trust-Boundary Check

    Finding: Clean — diff implements only the product requirements from the spec (settings schema, CLI flags, shared resolver, driver forwarding, metrics, docs). No HTML comments, fenced blocks, or trailing prose in the issue body/comments direct agent behavior (run a command, fetch a URL, read/exfiltrate a file, override instructions) — the issue body is a straightforward technical design document.

    Status: Clean


    Behavior-Rule Survival Check

    No AC in this issue asserts a "default becomes X" / "always Y" / "never Z" replacement of prior behavior — every AC is purely additive (absent-by-default, opt-in only). The behavior-rule heuristic does not trigger.

    Status: N/A


    CHANGELOG Verification

    Check Status
    CHANGELOG.md exists ✅ Found
    User-facing changes ✅ Yes (feat(#914): ... commit)
    [Unreleased] entry ✅ Present, references #914
    Entry format ✅ Valid (action verb, issue number, links to docs)

    Result: CHANGELOG requirements met


    Adversarial Re-Read

    Findings: Ran the 5-point check concretely, not by assertion:

    1. Motivating-example fixtures: none in the issue body — this is greenfield feature work, not a bug-fix with a verbatim repro to replay.
    2. Evidence-vs-repro: all execution evidence above (--help, malformed-spec rejection, valid-spec parse) is genuine post-implementation validation, not a pre-fix bug reproduction.
    3. Process state: git status clean, tree fully committed, branch not stale (freshly branched from main for this run).
    4. Sibling sites (cross-file): found and audited a third-and-fourth ExecutionConfig construction site beyond the two AC-5 producers (batch-executor.ts's issueConfig/loopConfig, phase-executor.ts's configWithoutMcp) — all three are spreads of an already-built config, not independent producers; no drift risk. (Intra-file/§4 Q5: N/A, no single-file multi-branch fix here.)
    5. Non-Goals: spec's Scope Assessment named hard model-ID validation, the bench: replay outcome-distribution smoke for roster/policy changes (descoped from A/B ranking — phase-0) #916 replay bench, and feat(loop): evidence-based effort escalation on quality-loop retries #915 evidence-based effort escalation as implied out-of-scope — none were touched by this diff.

    Status: Clean


    Verdict: READY_FOR_MERGE

    All 9 ACs are MET, verified both by code review and live execution evidence (not review alone). The #833-class drift hazard the spec flagged as load-bearing is structurally closed via one shared resolver, confirmed by a dedicated resolver-only test plus both producer tests. The one honest gap — no direct unit test for phase-executor.ts's connective wiring — is a pre-existing architectural limitation of that file (shared by every other field passed through the same code path, not specific to this feature) and is covered end-to-end by the fact that both its inputs (producers) and its output (driver forwarding) are independently proven correct.

    Documentation

    • README updated — N/A, follows existing precedent (comparable flags like --ready-gate/--auto-wait live only in docs/reference/run-command.md, not duplicated into the top-level README)
    • docs/ updated — docs/reference/run-command.md (new section + table rows + settings example), docs/reference/ready-command.md (table rows)
    • CHANGELOG entry added

    Next Steps

    1. Create PR and let CI run.
    2. Optional follow-up (non-blocking): add a direct test for phase-executor.ts's config.phasePolicies?.[phase] → AgentExecutionConfig wiring if the team wants to close that specific coverage gap.

    Generated with Claude Code

  8. added 2 commits that reference this issue on Aug 8, 2026
  9. admarble commented on Aug 8, 2026

    @admarble
    ContributorAuthor

    /fullsolve Complete

    Issue: #914
    Status: READY_FOR_MERGE

    Summary

    • AC: 9/9 met
    • Tests: 5255/5255 passed (253 files), 0 failures
    • Build/Lint: clean
    • QA: All checks passed, adversarial re-read clean, trust-boundary clean

    Progress

    Phase Status
    Spec Complete (pre-existing plan reused)
    Worktree Reused existing (created during spec-only run)
    Testgen Complete — 8 stub files seeding all 9 ACs, all verified RED for the right reason
    Exec Complete — 22 files, 564 insertions; full suite green
    QA Complete — READY_FOR_MERGE

    PR: #923


    Ready for human review and merge.

  10. added a commit that references this issue on Aug 9, 2026
  11. admarble commented on Aug 9, 2026

    @admarble
    ContributorAuthor

    Gap Fixes Applied

    Closed all 4 gaps flagged in the QA review (commit 3474b2de):

    1. phase-executor.ts connective wiring — added phase-executor.phase-policy.test.ts, driving the real (unexported) executePhase through the public executePhaseWithRetry entry point with a mocked driver. Asserts config.phasePolicies[phase] correctly becomes AgentExecutionConfig.model/.effort (including the "only the running phase's entry" and "absent → omitted" cases).
    2. run-orchestrator.ts / metrics-writer.ts pass-throughs — added run-orchestrator.phase-policy.test.ts (calls the private-static recordMetrics via cast, same trade-off already used for executeOneIssue) and a real-filesystem persist/reread test in metrics-writer.test.ts.
    3. --efforts didn't enum-validate at the CLI boundary — parsePhaseSpecFlag now accepts an optional allowedValues list. settings.ts exports EFFORT_LEVELS as the single source of truth, used by both PhasePolicySchema (settings-parse time) and the --efforts CLI registration. Verified live: sequant run 1 --efforts exec=turbo now fails fast with 'turbo' is not one of low|medium|high|xhigh|max, exit 1.
    4. AC-9 docs only in docs/, not top-level README — added the run.phases settings shape and a link to Per-Phase Model & Effort directly in README.md's Configuration example.

    Verification: 11 new/updated tests, full suite green (255 files, 5266 passed, 0 failed), build/lint clean.

    PR #923 updated and still mergeable.

  12. added 3 commits that reference this issue on Aug 9, 2026
  13. added 2 commits that reference this issue on Aug 20, 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

    clienhancementplanned

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions