Repository navigation
Closed
Labels
cliCLI commands and interfaceenhancementNew feature or requestplannedImplementation plan approvedready-for-reviewReady for code review
Description
Depends on #914 (per-phase model/effort configuration).
Motivation
The quality risk in effort tuning lives entirely in speculative downgrades — guessing "this task looks easy" from weak proxies and lowering effort before any evidence. The inverse move carries essentially zero quality risk: escalate effort when the workflow observes failure. Sequant already detects exactly those moments:
- quality-loop iteration ≥ 2 (
/loopre-entry after unmet QA findings) - QA stagnation (
qa-stagnation.ts— repeated iterations without finding-count progress) - spec retry (
spec-retry.ts)
Escalation adapts to observed difficulty rather than predicted difficulty — it can only trade cost for quality, never the reverse. This is the honest version of "adaptive effort." Predictive adaptation (deriving exec effort from /spec's scope-analyzer verdict) is deliberately out of scope until dogfood metrics from #914 justify it.
Design
- Opt-in:
run.effortEscalation: boolean(defaultfalse— escalation raises token cost, which is the user's call on subscription plans) plus a--escalate-effortCLI flag. - Trigger: when a phase execution is a retry of a failed/looped attempt (loop iteration ≥ 2, spec retry, or stagnation-driven re-run), resolve the phase's effort one tier above its configured/inherited value on the ladder
low → medium → high → xhigh → max. - Base tier when no per-phase effort is configured: treat the base as
high(the SDK default) so the first escalation lands onxhigh. - Cap: never exceed
max; never escalate more than one tier per retry; the escalated tier applies only to the retried phase execution, not subsequent phases. - Observability: the escalated effort is recorded in run metrics (same fields as feat(run): per-phase model and effort configuration for the claude-code driver #914) and surfaced in verbose output (
effort: high → xhigh (loop retry)), so the cost/quality tradeoff is auditable per run. - Both ExecutionConfig producers (
buildExecutionConfig,ready-gate.ts:buildPhaseConfig) apply the same escalation logic (fix(cli): bare parseInt on run --timeout lets a malformed value abort every phase instantly (sibling of #818) #833 drift guard).
Acceptance Criteria
-
run.effortEscalation(defaultfalse) and--escalate-effortare parsed, with CLI taking precedence over settings - With escalation disabled, retried phases run at their configured/inherited effort (test: loop iteration 2, options object carries the unescalated value)
- With escalation enabled, a loop iteration ≥ 2 runs the retried phase one effort tier above its resolved base, verified by a driver-options unit test
- Escalation applies on spec retry and QA-stagnation re-runs via the same code path (one resolver function, not per-call-site copies)
- Escalation from an unconfigured phase treats the base as
highand lands onxhigh - Effort never exceeds
maxand never jumps more than one tier per retry (test: basemaxstaysmax; basehighon 3rd loop iteration isxhigh, notmax) - The escalated tier applies only to the retried phase execution; the next phase in the chain resolves from its own configuration
- Run metrics and verbose output record both the base and escalated effort for escalated executions
- README + docs/ document the flag, the escalation ladder, the cost implication, and why speculative downgrades are intentionally not offered
Metadata
Metadata
Assignees
Labels
cliCLI commands and interfaceenhancementNew feature or requestplannedImplementation plan approvedready-for-reviewReady for code review
Activity
admarble commentedon Aug 8, 2026
Complexity: Complex (9 ACs, 3 directories)
Depends on #914 — currently OPEN, no PR. #914 introduces the entire effort concept this issue builds on: the
EffortTiertype, per-phaseeffortresolution, theeffortfield onExecutionConfig, the wire that carries effort to the claude-code driver, and the run-metrics effort fields. None of that exists onmaintoday (grep -rn "EffortTier\|reasoningEffort\|run.effort" src/→ 0 hits). This issue has nothing to escalate until #914 lands. Recommend--baseoff #914's branch (or wait for merge) so the escalation resolver plugs into #914'sEffortTierladder and driver-options surface rather than inventing a parallel one.AC Quality Check
All 9 ACs pass the linter (no vague/unmeasurable/open-ended patterns). They are unusually well-specified — each names its own test oracle (e.g. AC-6 "base
highon 3rd loop iteration isxhigh, notmax"). No refinements needed.Scope Assessment
Non-Goals: ✅ Present and explicit — predictive adaptation (deriving exec effort from
/spec's scope verdict, or speculative downgrades) is deliberately out of scope until #914 dogfood metrics justify it. This is the load-bearing scope boundary; keep it.src/lib/workflow,bin,docs+README)Verdict: ✅ SCOPE_OK — 9 ACs is high, but they decompose one cohesive resolver + its wiring + tests + docs. No split warranted. Enable the quality loop anyway (see Recommended Workflow) since the correctness surface is a boundary-condition table (the ladder caps).
Acceptance Criteria
AC-1:
run.effortEscalation(defaultfalse) +--escalate-effortparsed, CLI > settingsVerification: Unit Test —
resolveRunOptions/buildExecutionConfiginconfig-resolver.ts.Scenario: Given setting
false+--escalate-effort→ When options resolved → TheneffortEscalation === true(CLI wins); Given neither → Thenfalse.Assumptions:
--escalate-effortadded via.option()inbin/cli.ts(flag silently absent otherwise) and toRunOptionsintypes.ts; setting added toRunSettingsSchemainsettings.ts.AC-2: Disabled → retried phase runs at configured/inherited effort
Verification: Unit Test (driver-options).
Scenario: Given escalation disabled + loop iteration 2 → When phase dispatched → Then the options object carries the unescalated base tier.
AC-3: Enabled → loop iteration ≥ 2 runs one tier above resolved base
Verification: Unit Test (driver-options).
Scenario: Given enabled + base
high+ iteration 2 → When phase dispatched → Then effort isxhigh.AC-4: Spec retry + QA-stagnation re-runs use the SAME resolver (one function, no per-call-site copies)
Verification: Unit Test + code review.
Scenario: Given a single exported
resolveEscalatedEffort(base, isRetry, enabled)→ When called from the loop-retry path (batch-executor.ts), the spec-retry path (run-orchestrator.ts:~1050), and the stagnation-re-run path (qa-stagnation.ts) → Then all three produce identical output for identical inputs. Test asserts one import site per caller, no inline ladder math.Assumptions: All three signals converge on a boolean "this execution is a retry" fed to the shared resolver.
AC-5: Unconfigured phase → base treated as
high→ lands onxhighVerification: Unit Test.
Scenario: Given no per-phase effort configured + escalation on a retry → When resolved → Then base defaults to
high(SDK default) and escalates toxhigh.AC-6: Cap at
max; ≤ one tier per retryVerification: Unit Test (table).
Scenario: base
max+ retry →max; basehigh+ 3rd loop iteration →xhigh(NOTmax— escalation is per-retry-of-one-tier, not cumulative-by-iteration-count). Ladder:low → medium → high → xhigh → max.AC-7: Escalated tier applies only to the retried execution; next phase resolves from its own config
Verification: Unit + Integration Test.
Scenario: Given phase A retried at
xhigh→ When the chain advances to phase B → Then B resolves from its own configured/inherited base, unaffected by A's escalation. (This is why escalation must be applied at dispatch time per execution, not baked statically into a singleExecutionConfig— see Design Review Q2.)AC-8: Metrics + verbose record base AND escalated effort for escalated executions
Verification: Unit Test + Integration.
Scenario: Given an escalated execution → Then run metrics carry both base and escalated tiers (same fields as #914) and verbose output prints
effort: high → xhigh (loop retry).Assumptions: #914's metric fields are extended, not duplicated.
AC-9: README + docs/ document flag, ladder, cost implication, and why speculative downgrades are omitted
Verification: Manual (docs content check — verify coverage, not file existence; check README and
docs/reference/run-command.md, matching the--ready-gateprecedent at README:23).Implementation Plan
Phase 1: Wire the flag/setting (AC-1)
--escalate-effortboolean via.option()inbin/cli.ts; addeffortEscalationtoRunOptions(types.ts).effortEscalation(defaultfalse) toRunSettingsSchemainsettings.ts.buildExecutionConfig(config-resolver.ts:243) resolveeffortEscalation = mergedOptions.escalateEffort ?? settings.run.effortEscalation ?? false(CLI-precedence pattern, mirroringreadyGateat :309). Mirror intoready-gate.ts:buildPhaseConfig(fix(cli): bare parseInt on run --timeout lets a malformed value abort every phase instantly (sibling of #818) #833 drift — both producers).Phase 2: The shared resolver (AC-4, AC-5, AC-6)
["low","medium","high","xhigh","max"]and a pureresolveEscalatedEffort(base: EffortTier | undefined, isRetry: boolean, enabled: boolean): EffortTierbeside feat(run): per-phase model and effort configuration for the claude-code driver #914's effort resolution. Rules:!enabled || !isRetry→ base (orhighdefault per AC-5); elsemin(indexOf(base ?? "high") + 1, lastIndex)→ cap atmax, one tier only.Phase 3: Feed the retry signal at dispatch (AC-2, AC-3, AC-7)
batch-executor.ts(iteration > 1, line ~1295/1314), compute the execution's effort via the resolver and pass it into the driver options for that execution only.run-orchestrator.ts:~1050) and the stagnation re-run (qa-stagnation.ts) through the same resolver withisRetry = true.Phase 4: Observability + docs (AC-8, AC-9)
base → escalated (reason)line.docs/reference/run-command.md.Rule Touchpoints
AC-6's cap rule ("never exceed
max, never jump > one tier") is exactly the kind of behavior rule that gets copy-pasted into each call site and drifts. The real touchpoints for this feature are the twoExecutionConfigproducers (the behavior-rule detector's auto-found touchpoints were all false positives — its own source + unrelated skill docs). AC-4 pre-empts the drift by mandating one resolver; enforce it here.src/lib/workflow/config-resolver.ts:243buildExecutionConfig(...)— producer #1, must delegate to resolversrc/lib/workflow/ready-gate.ts:287buildPhaseConfig(...)— producer #2 (#833 drift guard)src/lib/workflow/batch-executor.ts:~1295if (useQualityLoop && iteration > 1)— the retry-dispatch siteDesign Review
config-resolver.ts— the layer that already owns config→ExecutionConfig, and the module fix(cli): bare parseInt on run --timeout lets a malformed value abort every phase instantly (sibling of #818) #833 designated as the single guard point.resolveEscalatedEffortfunction; call it at each of the three retry-dispatch sites. Reject baking a static escalated value intoExecutionConfigat build time — that violates AC-7 (escalation is per-execution, andbuildExecutionConfigruns once per run, not per phase-execution). The config carries the base + enabled flag; escalation is computed at dispatch.readyGateopt-in flag (CLI→settings→default,config-resolver.ts:309) for wiring; thepositiveOrtwo-producer guard pattern (fix(cli): bare parseInt on run --timeout lets a malformed value abort every phase instantly (sibling of #818) #833) for keeping both producers in sync.highon 3rd iteration isxhigh, notmax): each retry is one tier above the configured base, not the previous escalated value. Document that intent at the resolver.Feature Quality Planning
All standard checks pass. Notable items:
EffortTier/driver-options surface changes before merge, the resolver signature must track it. Build on feat(run): per-phase model and effort configuration for the claude-code driver #914's branch to avoid a phantom interface.Derived ACs
buildExecutionConfigpath ANDbuildPhaseConfigpath (delete one → a test fails)Open Questions
ExecutionConfigcan't express. Recommendation: producers carrybase effort + effortEscalation flag; the shared resolver runs at dispatch. Impact if wrong: escalating one phase leaks into the next (AC-7 fails).effortconfigured but no feat(run): per-phase model and effort configuration for the claude-code driver #914 inheritance — AC-5 covers unconfigured →high. Confirm a configured phase escalates from its configured value, not fromhigh. Recommendation: resolver takes the resolved base verbatim; only theundefinedcase defaults tohigh.Recommended Workflow
Phases: spec → testgen → exec → qa
Quality Loop: enabled
Reasoning: 6 of 9 ACs are Unit-Test-verifiable with explicit boundary oracles (ladder caps) — testgen should stub them before exec so the cap table is codified first.
enhancementlabel + >2 ACs and Unit/Integration verification methods both trigger testgen. Quality loop on: the correctness surface is a boundary table where an off-by-one in the ladder is the likely defect. No UI → notestphase. Not security-sensitive → nosecurity-review. Do not schedule exec until #914 has merged (or exec on--baseoff #914's branch).Label Review
Current:
enhancementRecommended:
enhancement+ considerblocked(until #914 merges) andcliReason:
blockedreflects the hard #914 dependency;climatches #914's own labeling (new flag surface). Nocomplex/refactorneeded — cohesive single feature.Quality Loop: Won't auto-enable from labels; enable via
--quality-loopper the workflow above.→
gh issue edit 915 --add-label cliadmarble commentedon Aug 8, 2026
#915 — feat(loop): evidence-based effort escalation on quality-loop retries
Open · enhancement
────────────────────────────────────────────────────────────────
→ PROCEED — Builds on #914's effort resolver — run after it
Commands:
sequant run 915 -Q --phases testgen,exec,qa # after #914 lands
spec → testgen → exec → qa · 9 ACs
Flags:
-Q escalation resolver must be wired identically into both ExecutionConfig producers
--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
⚠ Depends on #914: consumes its per-phase effort resolver and both modify buildExecutionConfig + ready-gate.ts:buildPhaseConfig — exec after #914 lands, or use sequant run 914 915 --chain
────────────────────────────────────────────────────────────────
admarble commentedon Aug 9, 2026
#915 — feat(loop): evidence-based effort escalation on quality-loop retries
OPEN · enhancement, planned
────────────────────────────────────────────────────────────────
Supersedes prior assess from 2026-08-08 (PROCEED)
→ PROCEED — Blocking dep #914 now merged; spec already complete
Commands:
sequant run 915 -Q --phases testgen,exec,qa # resume — #914 merged
testgen → exec → qa · 9 ACs
Flags:
-Q escalation resolver touches both ExecutionConfig producers plus a boundary-condition ladder table
--phases testgen,exec,qa prior spec marker already exists and blocking dep #914 is now merged
────────────────────────────────────────────────────────────────
Cleanup:
gh issue edit 915 --add-label cli # flag surface, per this issue's own prior spec label review — not yet applied
────────────────────────────────────────────────────────────────
⚠ #914 shipped effort as a plain string field, not an EffortTier ladder type — the resolver's ladder const must be authored fresh, not imported
⚠ Modifies batch-executor.ts (overlaps #920, #921); land sequentially
────────────────────────────────────────────────────────────────
admarble commentedon Aug 9, 2026
Complexity: Complex (9 ACs, 4 directories)
What #914 actually shipped (the surface this builds on)
src/lib/settings.ts:75—EFFORT_LEVELS = ["low","medium","high","xhigh","max"]config-resolver.ts:319resolvePhasePoliciesconfig-resolver.ts:435(buildExecutionConfig)ready-gate.ts:316(buildPhaseConfig), fed fromRunReadyGateOptions.phasePoliciesphase-executor.ts:1262—config.phasePolicies?.[phase]→AgentExecutionConfig.effort→claude-code.ts:139metrics-schema.ts:121phasePolicies, recorded once per run atrun-orchestrator.ts:1703The load-bearing consequence: effort reaches the driver only via
config.phasePolicies[phase].effort, and every retry call site passes the sameconfigobject. Escalation is therefore expressed as a locally-cloned config at the retry call site — not as a field baked intoExecutionConfigat build time. This is what makes AC-7 (per-execution scoping) fall out for free.AC Quality Check
8 of 9 ACs pass the linter cleanly and name their own test oracle. Two wording issues, both from the ACs being drafted before #914's implementation existed:
query()options entirely (its AC-3, mutation-verified). There is no "unescalated value" to carry. The test must assert key absence ("effort" in opts === false) in that case, and the unescalated value only for a phase that is configured. Building to the literal wording produces a test that can't be satisfied.Scope Assessment
Non-Goals: ✅ Explicit and load-bearing — predictive adaptation (deriving effort from
/spec's scope verdict; speculative downgrades) is out of scope until #914 dogfood metrics justify it. Keep it.src/lib,src/lib/workflow,bin,docs+README)Verdict: ✅ SCOPE_OK — 9 ACs, but they decompose one resolver plus its wiring, tests, and docs. No split. Quality loop on regardless: the correctness surface is a boundary table (ladder caps) where an off-by-one is the likely defect.
Acceptance Criteria
AC-1:
run.effortEscalation(defaultfalse) +--escalate-effort, CLI > settingsVerification: Unit Test —
buildExecutionConfiginconfig-resolver.ts.Scenario: Given
settings.run.effortEscalation: false+--escalate-effort→ TheneffortEscalation === true. Given neither →false.Assumptions:
.option()added inbin/cli.ts(the flag silently does not exist otherwise);escalateEffortadded toRunOptionsintypes.ts— noterun-options-dead-surface.test.tsguards that file for declared-but-unwired fields, so the flag and its consumer must land in the same change.AC-2: Disabled → retried phase runs at its configured/inherited effort
Verification: Unit Test (driver options, via
executePhaseWithRetrywith a mocked driver — the entry pointphase-executor.phase-policy.test.tsalready uses).Scenario: Given escalation disabled + loop iteration 2 → Then the options object is byte-identical to iteration 1's: the configured tier for a configured phase, and no
effortkey at all for an unconfigured one.AC-3: Enabled → loop iteration ≥ 2 runs one tier above the resolved base
Verification: Unit Test (driver options).
Scenario: Given enabled + base
high+ iteration 2 → Theneffort === "xhigh".AC-4: Spec retry and the ready-gate QA loop use the SAME resolver
Verification: Unit Test + code review.
Scenario: One exported function; three call sites import it; no inline ladder arithmetic anywhere. The three real retry sites are listed under Rule Touchpoints. (QA stagnation is not one of them — Open Question 1.)
AC-5: Unconfigured phase → base treated as the SDK default → lands one tier above
Verification: Unit Test.
⚠️ The AC asserts that constant is
Scenario: Given no configured effort + a retry → base defaults to a named constant, escalation lands one tier up.
high. Verify before building — see Open Question 2. If the Agent SDK's real default isxhigh(as it is in Claude Code), escalating from an assumedhighproducesxhigh, which is the default — a silent no-op that every test in this AC would still pass.AC-6: Cap at
max; ≤ one tier per retryVerification: Unit Test (table).
Scenario: base
max+ retry →max. basehigh+ 3rd loop iteration →xhigh, notmax— escalation is one tier above the configured base, never cumulative over the previous escalated value. Ladder issettings.ts:EFFORT_LEVELS; do not redeclare it.AC-7: Escalation is scoped to the retried execution
Verification: Unit + Integration Test.
Scenario: Given phase A retried at
xhigh→ When the chain advances to phase B → Then B resolves from its own config. Falls out of the design: the retry site passes a cloned config and never mutatesissueConfig. The test should assert the shared config object is unchanged after an escalated call.AC-8: Metrics + verbose record base AND escalated effort
Verification: Unit Test + Integration.
⚠️ "same fields as #914" is not achievable as written.
Scenario: Verbose prints
effort: high → xhigh (loop retry); metrics carry both tiers.phasePoliciesis recorded once per run (run-orchestrator.ts:1703, fromconfig.phasePolicies) and is a flatphase → {model, effort}map. Escalation is per-execution and can fire several times in one run, so it cannot be expressed in that shape. Design below adds a sibling optional array rather than overloading it. There is also no existing verbose effort output — that line is entirely new, not an extension.AC-9: README +
docs/document the flag, ladder, cost, and the no-downgrade rationaleVerification: Manual (content coverage, not file existence). Both locations, following the #914 precedent:
README.md:307anddocs/reference/run-command.md#per-phase-model--effort(:347–378). Checkdocs/reference/ready-command.mdtoo if AC-1's flag lands onsequant ready(Open Question 3).Implementation Plan
Phase 1 — Flag and setting (AC-1)
bin/cli.ts:--escalate-effortvia.option()onrun(andready, pending OQ3), beside the existing--models/--effortsat :395–400.types.ts:RunOptions.escalateEffort+ExecutionConfig.effortEscalation, each with a doc comment naming its consumer (dead-surface guard).settings.ts:effortEscalation: z.boolean().optional()onRunSettingsSchema, defaultfalse.buildExecutionConfig(config-resolver.ts:435, next tophasePolicies) andready-gate.ts:316via a newRunReadyGateOptions.effortEscalationfed fromcommands/ready.ts:172. This is the fix(cli): bare parseInt on run --timeout lets a malformed value abort every phase instantly (sibling of #818) #833 drift point.Phase 2 — The shared resolver (AC-4, AC-5, AC-6)
config-resolver.ts, besideresolvePhasePolicies:DEFAULT_EFFORT— one named constant, the base for an unconfigured phase (value pending OQ2), with a comment tying it to the SDK default.escalateEffort(base: string | undefined, enabled: boolean): string | undefined— pure.!enabled→baseunchanged. Else index intoEFFORT_LEVELSfrombase ?? DEFAULT_EFFORT,+1, clamped to the last index. An unrecognizedbasereturnsbaseunchanged (never throw at dispatch time).withEscalatedEffort(config: ExecutionConfig, phase: Phase): ExecutionConfig— returns a shallow clone withphasePolicies[phase].effortreplaced; returnsconfigby identity when escalation is off or produces no change. This is the single entry point all three call sites use, and the reason AC-7 holds.Phase 3 — Wire the three retry sites (AC-2, AC-3, AC-7)
batch-executor.ts:1354— wrap thewithActivityHook(issueConfig, …)argument wheniteration > 1. Theiterationvariable is already in scope at that line.phase-executor.ts:1676— theSPEC_EXTRA_RETRIESloop passes an escalated config toexecutePhaseFn. Conditional on Open Question 1's answer — this loop exists to recover transient failures, which is not evidence of difficulty.ready-gate.ts:495and:552— passiterations > 1throughbuildPhaseConfig's result.Phase 4 — Observability + docs (AC-8, AC-9)
effortEscalations?: Array<{phase, base, escalated}>toMetricRunSchema(additive, optional, no version bump — same pattern asphasePoliciesatmetrics-schema.ts:113–126), threaded from the executor rather than fromconfig. Omit the field entirely when empty.effort: <base> → <escalated> (<reason>)from the single point wherewithEscalatedEffortactually changes something, so the message can't drift from the value.docs/reference/run-command.md(+ ready-command per OQ3): flag, ladder, cost implication, and why speculative downgrades are intentionally absent.Rule Touchpoints
AC-6's cap rule is exactly the sort that gets copy-pasted per call site and drifts, which is why AC-4 mandates one resolver. (The automated detector was run on this issue during the prior spec pass and returned only false positives — its own source plus unrelated skill docs. The real touchpoints are enumerated from the merged #914 code.)
config-resolver.ts:435phasePolicies: resolvePhasePolicies(...)— producer 1ready-gate.ts:316phasePolicies: opts.phasePolicies— producer 2 (#833)batch-executor.ts:1354executePhaseWithRetry(..., withActivityHook(issueConfig, ...))underiteration > 1phase-executor.ts:1676for (let i = 0; i < SPEC_EXTRA_RETRIES; i++)— the real spec-retry loopready-gate.ts:486while (iterations < maxIterations)— QA-pass loop, dispatches at :495 / :552run-orchestrator.ts:1703phasePolicies: config.phasePolicies— run-scoped, cannot carry per-execution dataDesign Review
resolvePhasePoliciesinconfig-resolver.ts— the module feat(run): per-phase model and effort configuration for the claude-code driver #914 already designated as the single anti-drift point, and the one both producers import.ExecutionConfigat build time:buildExecutionConfigruns once per run, not once per phase execution, so a static value would leak across phases and fail AC-7. Also reject threading a neweffortparameter downexecutePhaseWithRetry's signature — it is already 10 positional parameters deep with a comment (phase-executor.ts:1365–1372) pinning the last one's position for the feat: detect rate-limit failures mid-chain and halt cleanly instead of timeout-cascading #761/fix(run): -Q quality loop retries after an "Out of credits" exec instead of failing fast (billing cascades into "unparseable verdict") #799 regression tests. Cloning the config keeps that signature untouched.readyGate(config-resolver.ts:431) for the opt-in flag wiring;resolvePhasePoliciesfor the shared-resolver-across-two-producers shape.highat iteration 3 isxhigh, notmax. Each retry is one tier above the configured base. Document that at the resolver, because the alternative reading is the natural one.Feature Quality Planning
Notable items:
executePhaseWithRetrymust NOT escalate. They are infrastructure recovery (phase-executor.ts:1456–1600), not evidence of task difficulty. Escalating there burns tokens on an npx cold cache. The plan touches only theSPEC_EXTRA_RETRIESloop, and a test should pin that a cold-start retry keeps the base tier.Derived ACs
Open Questions
AC-4 names "QA-stagnation re-runs" as a trigger, but no such code path exists.
detectStagnation(qa-stagnation.ts:74) is a halt signal — its own doc comment says the orchestrator "should NOT re-invoke/qa." Its only consumers areready-gate.ts:346(which halts) andscripts/qa-stagnation.ts, a shim the fullsolve/loop SKILL.md files call. There is nothing to escalate. Recommendation: treat the ready-gate QA-pass loop (ready-gate.ts:486) as the intended third site — it is a genuine retry loop in the same subsystem — and drop the stagnation reference from the AC. Related, and sharper: the issue's own thesis is "escalate on observed difficulty," but the spec-retry loop's in-code rationale (phase-executor.ts:1673) is that spec has a transient failure rate (~8.6%). A transient failure is not evidence of difficulty; escalating there trades cost for nothing. Recommendation: wire the loop retry (site 1) and the ready-gate loop (site 3) as the shipped triggers, and either drop spec-retry or gate it behind a non-transient error classification. Impact if wrong: token spend on cold-start-class failures with no quality return — precisely the outcome the issue's motivation argues against.AC-5 asserts the SDK default effort is
high; this needs verification before it becomes a constant.highis the Messages API default. Claude Code runsxhighby default, and the Claude Agent SDK is the Claude Code harness packaged as a library — so the SDK-level default is plausiblyxhigh. If it is, escalating an unconfigured phase from an assumedhighyieldsxhigh— identical to what it was already running — and every AC-5/AC-3 unit test still passes while the feature does nothing. Note feat(run): per-phase model and effort configuration for the claude-code driver #914 deliberately never named a value:docs/reference/run-command.md:70says only "(SDK default)". Recommendation: confirm the Agent SDK's default againstcode.claude.com/docs/en/agent-sdkduring exec; put the answer in one exportedDEFAULT_EFFORTconstant with a comment citing the source, so it is a one-line fix if it changes. Impact if wrong: the headline unconfigured-phase case is a silent no-op.Does
--escalate-effortalso land onsequant ready? The issue sayssequant run, butready-gate.tsis one of the three retry sites and its ownExecutionConfigproducer, and feat(run): per-phase model and effort configuration for the claude-code driver #914 shipped--models/--effortson both commands (bin/cli.ts:395and:611). Recommendation: add it to both, for parity with feat(run): per-phase model and effort configuration for the claude-code driver #914 and because escalation is inert onreadyotherwise. Impact if wrong: the ready-gate wiring exists with no way to enable it — the chore(run): --qa-gate is an inert no-op flag — remove or make it actually gate #795 inert-flag class.AC-2's literal test is unsatisfiable for an unconfigured phase (see AC Quality Check). Recommendation: split it into two assertions — key-absent for unconfigured, unchanged-value for configured. Impact if wrong: a test written to the literal wording fails for the right reason and gets "fixed" by weakening it.
Recommended Workflow
Phases: testgen → exec → qa
Quality Loop: enabled
Reasoning: 6 of 9 ACs are unit-testable with explicit boundary oracles (the ladder cap table), so testgen should codify that table before exec.
enhancement+ >2 ACs + Unit/Integration verification methods all trigger testgen. Quality loop on: an off-by-one in the ladder is the likely defect and it is cheap to catch. No UI → notestphase. Not security-sensitive → nosecurity-review. #914 is merged, so nothing blocks scheduling.Label Review
Current:
enhancement,plannedRecommended: add
cli(new flag surface, matching #914's labeling). Theblockedlabel the prior spec suggested is moot — #914 merged.Quality Loop: Won't auto-enable from labels; pass
-Q.admarble commentedon Aug 9, 2026
QA Review for Issue #915
AC Coverage
run.effortEscalation(defaultfalse) +--escalate-effortparsed, CLI > settings.option("--escalate-effort", ...)on bothrunandready;RunSettingsSchema.effortEscalation.default(false);mergedOptions.escalateEffort ?? settings.run.effortEscalation ?? falseinconfig-resolver.ts:444and the mirror incommands/ready.ts. Mutation-verified both producers (deleting either wire fails exactly its guarding test).effortkey entirely rather than sending a value, and there is no "unescalated value" for a key that was never present. Implemented and tested as: unconfigured phase stays key-absent; configured phase carries its value unchanged.effort-escalation.test.ts+batch-executor.test.ts(live dispatch, disabled case).resolveEscalatedEffort), cross-producer level (ready-gate.phase-policy.test.ts), and live dispatch level (batch-executor.test.ts, realrunIssueWithLoggingcall with a scripted qa-fail-then-recover).effort-escalation.ts) used at all three real dispatch sites — no per-call-site copies.high, lands onxhighDEFAULT_ESCALATION_BASE = "high", escalates to"xhigh". Runtime-executed against the builtdist/output during this QA pass (not just unit-tested) — confirmedresolveEscalatedEffort(undefined, true, true) === "xhigh". Flagged in the module's doc comment as an explicit assumption about the Agent SDK's actual default, isolated to one named constant.max; ≤ one tier per retry, from configured baseMath.min(..., EFFORT_LEVELS.length - 1)fails exactly the 2 boundary tests (base max stays max, ladder table) for the right reason. "3rd loop iteration, base high → xhigh not max" explicitly tested (AC-6: base already at maxtest + the ladder table test).withEscalatedEffortclonesExecutionConfigper dispatch, never mutates the shared input — verified by identity checks ineffort-escalation.test.tsand cross-phase non-leak assertions. One real-world nuance surfaced and documented in code + tests: because the outer quality loop re-runs its whole phase list per iteration (not just the failed phase), every phase dispatched during a retried iteration escalates together — this is the correct reading of "retried execution" given the loop's existing granularity, not a narrowing of AC-7.effortEscalationsmetrics array (mutation-verified aggregation inrun-orchestrator.ts, dedicated schema tests). Verbose print at both live sites (batch-executor.tsinline,run-orchestrator.tsfor the ready-gate path,commands/ready.tsfor standalonesequant ready). Note: standalonesequant readyhas never written to.sequant/metrics.json(pre-existing, unrelated to this issue) — its escalations are only visible via--verbose, not metrics.README.md,docs/reference/run-command.md(new "Effort Escalation on Retries" section + Options table row),docs/reference/ready-command.md(Options table row),CHANGELOG.md.Coverage: 9/9 met (1 with a disclosed literal-wording deviation on AC-4, both flagged loudly rather than silently reinterpreted).
Deviation from AC-4's literal text (flagged during /spec, carried into /exec)
AC-4 names "spec retry and QA-stagnation re-runs" as the third escalation trigger. Investigation found neither applies as written:
detectStagnation(qa-stagnation.ts) is a halt signal, not a retry. Its own doc comment: "the orchestrator should NOT re-invoke/qa" when stagnant. There is no re-run to escalate.phase-executor.ts'sSPEC_EXTRA_RETRIES) recovers transient failures, not evidence of difficulty. Its own code comment cites an ~8.6% transient failure rate. Escalating there spends tokens with no quality signal — the opposite of the issue's own cost/quality thesis.In their place,
ready-gate.ts's QA-pass loop (qa/loopdispatch, pass ≥ 2) was wired as the third genuine retry site in the same subsystem. One shared resolver (effort-escalation.ts) is used at all three real sites (batch-executor's outer loop, ready-gate'sqadispatch, ready-gate'sloopdispatch) — satisfying AC-4's "same code path, not per-call-site copies" requirement even though the named trigger sites differ from the literal text.CI Status
validate-skillsbuild (22.x)node-floor-guardtypecheckvalidate-pluginCI Summary: 4 passed, 1 pending, 0 failed. Diff includes
.tsfiles (not markdown-only), so the markdown-only relaxation does not apply —build (22.x)is gating.CI-related AC items: none of the 9 ACs above name CI directly; this affects the overall verdict via the standard
pending_count > 0 → NEEDS_VERIFICATIONrule, not any individual AC's status.Quality Metrics
: any/as anyin added lines)Full local suite:
npm run buildclean,npm run lintclean (0 warnings), fullnpx vitest run— 259 files, 5339 tests passed (1 pre-existing expected-fail, 2 pre-existing skipped), run twice across the session with no regressions.Test Coverage Analysis
src/lib/workflow/effort-escalation.tseffort-escalation.test.ts(dedicated, 15 tests covering every AC boundary)src/lib/workflow/batch-executor.tsbatch-executor.test.ts(+3 live-dispatch tests: AC-2/AC-3/AC-7/AC-6)src/lib/workflow/ready-gate.tsready-gate.phase-policy.test.ts(+2 tests: producer-2 wiring, end-to-end 2-pass escalation)src/lib/workflow/config-resolver.tsconfig-resolver.phase-policy.test.ts(+3 tests: CLI/settings/default precedence)src/lib/workflow/metrics-schema.tsmetrics-schema.effort-escalation.test.ts(dedicated, 5 tests)src/lib/workflow/metrics-writer.tsrun-orchestrator.phase-policy.test.ts'srecordRunassertionssrc/lib/workflow/run-orchestrator.tsrun-orchestrator.phase-policy.test.ts(+3 tests: cross-issue aggregation, ready-gate path, empty case; mutation-verified)src/lib/settings.tssettings.phase-policy.test.ts(+3 tests: default, round-trip, invalid-type rejection)src/commands/ready.tsready.test.ts(existing suite fixed for the new required field + verbose print exercised)bin/cli.ts--models/--effortsprecedent (also untested at the parse layer, resolution tested downstream). Smoke-tested this QA pass:--helpon bothrunandreadyshows the flag.src/lib/workflow/types.tstscCoverage: 10/10 non-type-only changed source files have direct or indirect test coverage. No critical-path files (no auth/payment/security/admin paths touched).
Cache Status
N/A — no
--use-cache/--no-cacheflag context; quality checks ran fresh via sub-agents (this repo's.sequant/.cache/qa/was not consulted for this run).Build Verification
N/A — build passed cleanly on the feature branch.
Code Review
Strengths:
effort-escalation.ts) placed to avoid a real circular-import hazard (config-resolver.ts→batch-executor.ts→ would-beconfig-resolver.ts) rather than following the spec plan's original file placement blindly — a correct judgment call under a discovered constraint, not a shortcut.ExecutionConfigrather than being baked into a static build-time value — this is the right design givenbuildExecutionConfig/buildPhaseConfigrun once per run/gate, not once per phase execution (correctly rejected in the design review during /spec).Issues:
Suggestions (non-blocking):
DEFAULT_ESCALATION_BASE = "high"is an explicit assumption about the Agent SDK's real default wheneffortis omitted (per the /spec plan's Open Question 2, the SDK's actual default was never conclusively determined — Claude Code's own product default isxhigh, but that's a different layer than whatquery()does when the option is omitted). This is a one-line constant with a doc comment flagging it, so it's cheap to correct if dogfood metrics show it's wrong — worth a follow-up note when feat(run): per-phase model and effort configuration for the claude-code driver #914's metrics mature enough to check.Test Quality Review
ExecutionConfigshape, not internals.runReadyGaterather than mocking the loop itself.batch-executor.test.tsmocks onlyexecutePhaseWithRetry(pre-existing pattern) — no new over-mocking introduced.snapshotFn/readTokensUsedare deterministic injected functions, not real git/filesystem calls.Issues Found: None.
Anti-Pattern Detection
Dependency audit: N/A — no
package.jsonchanges.Code patterns: None found by the security-scan sub-agent (0 critical/warning/info) or my own read of the diff. No N+1 patterns, no empty catch blocks, no uncleared timers.
Call-Site Review
New exported functions detected:
resolveEscalatedEffort,withEscalatedEffort,DEFAULT_ESCALATION_BASE(fromeffort-escalation.ts).withEscalatedEffortbatch-executor.ts(1),ready-gate.ts(2: qa + loop)iteration > 1/iterations > 1— the retry signal each loop already tracksiteration > 1is per-retried-ITERATION (documented deviation from a possible narrower per-failed-phase reading)resolveEscalatedEffortwithEscalatedEffortonlyDEFAULT_ESCALATION_BASEeffort-escalation.ts(resolver default), 2 test files (assertion)Findings: No mismatches. All three real retry sites use the shared resolver; no inline ladder-arithmetic copies exist anywhere in the diff (verified by grep for
EFFORT_LEVELS.indexOf— appears only insideeffort-escalation.ts).Execution Evidence
Ran the built
dist/output directly during this QA pass (not just unit tests against source):Evidence status: Complete.
CLI Registration Verification
Option files modified: Yes (
bin/cli.ts,src/lib/workflow/types.ts,src/commands/ready.ts).RunOptions.escalateEffortmergedOptions.escalateEffort(config-resolver.ts:444)--escalate-effortonrun(bin/cli.ts)ReadyCommandOptions.escalateEffortoptions.escalateEffort(commands/ready.ts)--escalate-effortonready(bin/cli.ts)ExecutionConfig.effortEscalationwithEscalatedEffortRunReadyGateOptions.effortEscalationopts.effortEscalationinbuildPhaseConfigVerification Status: Passed. Smoke-tested above — both flags actually appear in
--helpoutput on the built CLI, not just declared in TypeScript.Skill Command Verification / Skill Change Review / Detection Pattern Verification
N/A — no
.claude/skills/**/*.mdfiles changed in this diff.Smoke Test
Workflow-affecting changes: Yes (new CLI flag on
bin/cli.ts).node dist/bin/cli.js run --help--escalate-effortpresent with correct descriptionnode dist/bin/cli.js ready --help--escalate-effortpresent with correct descriptionresolveEscalatedEffort/withEscalatedEffortagainst the built outputSmoke Test Status: Complete.
Manual Test ACs
N/A — no AC in the /spec plan used
**Verification:** Manual Test; all 9 ACs were Unit Test / Integration Test, and all were exercised by real automated tests (not code-review-only reasoning).Risk Assessment
effortis omitted turns out to bexhighrather than the assumedhigh(see the Code Review suggestion above), an unconfigured phase escalating "from high to xhigh" would be a silent no-op in practice — the phase was already effectively running atxhigh. This doesn't break anything (no crash, no wrong value sent), it just means AC-5's headline case delivers no observable behavior change until the constant is corrected. Isolated to one named, documented constant.sequant run -Q --escalate-effortagainst an actual Claude Code subprocess and inspects thequery()options it receives — coverage stops at theExecutionConfig/dispatch layer, consistent with how feat(run): per-phase model and effort configuration for the claude-code driver #914's own model/effort feature was tested (same boundary, not a new gap this PR introduces).executePhaseWithRetry-equivalent phase dispatch happens outsidephase-executor.ts's own internal cold-start/MCP-fallback loops, which were deliberately excluded (see AC-4 deviation) rather than missed.batch-executor.tshas exactly one outer-loop dispatch site,ready-gate.tshas exactly two (qa, loop), both wired.Trust-Boundary Check
Finding: Clean — diff implements only the product requirements from the issue body and the /spec plan (posted to this issue, comment linked in the PR). The issue body contains no HTML comments, and no part of the diff runs a command, reaches the network, or reads/transmits a file in response to issue/comment text — every new capability (the CLI flag, the resolver, the metrics field) traces directly to a stated AC.
Status: Clean
Behavior-Rule Survival Check
Ran the detector against AC-1, AC-2, and AC-6 (the ACs most likely to trigger on
default/always/neverkeywords).Status: N/A (no AC triggers the heuristic)
CHANGELOG Verification
featcommit, new CLI flag + setting)[Unreleased]entry(#915), under### AddedResult: CHANGELOG requirements met.
Adversarial Re-Read
Findings: Walked the diff a second time against 5 specific angles: (1) ran every literal AC boundary case against the built
dist/output, not just the vitest harness — confirmed the ladder, default, cap, and clone-identity behave identically at runtime (see Execution Evidence); (2) checked every "verified"/"tested" claim in the PR description against an actual mutation test in this session — the ladder cap, both cross-producer wiring lines, and the metrics aggregation were each mutated and confirmed to fail their guarding tests, not asserted from reading the code; (3) inspected process state — worktree is clean, HEAD matches the pushed branch, no stashed or uncommitted work, locks were acquired correctly in Phase 0; (4) sibling sites — see Risk Assessment above, explicitly none, with the reasoning for why (the three dispatch sites are the complete set); (5) checked the issue body's Non-Goals section for scope creep — the issue's stated Non-Goal ("predictive adaptation... deliberately out of scope") is respected; nothing in the diff derives effort from/spec's scope verdict or any other predictive signal. One additional angle beyond the required 5: re-verified thatphase-executor.ts's cold-start/MCP-fallback retry loops — which do NOT escalate by design — actually don't, by readingexecutePhaseWithRetry's cold-start loop and confirming it never touchesconfig.phasePoliciesor callswithEscalatedEffort.Status: Clean
Verdict: NEEDS_VERIFICATION
All 9 ACs are MET (with the AC-4 deviation disclosed and judged a correct substitution, not a gap). Every other gate — type safety, security, scope/size, CLI registration, trust-boundary, behavior-rule survival, CHANGELOG, test coverage, adversarial re-read — is Clean/Passed. The sole blocker is CI:
build (22.x)was stillIN_PROGRESSat the time of this review (4/5 checks passed:validate-skills,node-floor-guard,typecheck,validate-plugin). Per the standard CI Status mapping, a gating pending check floors the verdict atNEEDS_VERIFICATIONregardless of everything else — re-run/qa 915(or just confirm the check) once CI reports.Documentation
run-command.md,ready-command.md)Next Steps
build (22.x)to complete on PR feat(#915): evidence-based effort escalation on quality-loop retries #926, then re-check:gh pr checks 926.admarble commentedon Aug 9, 2026
QA Follow-up: CI Complete
build (22.x)has completed since the review above — all 5 CI checks now pass (validate-skills,build (22.x),node-floor-guard,typecheck,validate-plugin, 0 pending, 0 failed).The prior review's sole blocker (
NEEDS_VERIFICATION— pending CI) is resolved. All 9 ACs were already MET (with the AC-4 deviation disclosed and judged correct), and every other gate was Clean/Passed.Verdict: READY_FOR_MERGE
PR: #926
admarble commentedon Aug 9, 2026
/fullsolve Complete
Issue: #915
Status: READY_FOR_MERGE (awaiting human merge decision)
Summary
NEEDS_VERIFICATION— then confirmed green on follow-up)Progress
ui/frontend/adminlabelsPR: #926
This does not auto-merge — the PR is ready for human review and merge at your discretion.
admarble commentedon Aug 10, 2026
Filed #929 for the third gap raised in review: standalone
sequant readyhas never written to.sequant/metrics.json(pre-existing, not specific to this issue —sequant run --ready-gatealready records correctly via #915'sIssueResult.readyGate.effortEscalationspath). Scoped out of this PR since fixing it means adding a new capability toready, not a scoped fix to escalation logic.The other two gaps raised in review are fixed in the latest commits:
DEFAULT_ESCALATION_BASE = "high"verified directly against the installed@anthropic-ai/claude-agent-sdk's ownquery()Options type (sdk.d.ts), not left as an unverified assumption.phase-executor.effort-escalation.test.ts, an end-to-end test chaining the real resolver → realexecutePhaseWithRetry→ realClaudeCodeDriver(mocking only the SDK'squery()call) — proves an escalated tier actually reaches the wire, not just each hop in isolation. Mutation-verified.fix(#915): verify SDK default effort against installed types; add end…
feat(#915): evidence-based effort escalation on quality-loop retries (#…
fix(#958): gate /fullsolve's PR merge behind --auto-merge, off by def…
fix(ready-gate): collapse the second ExecutionConfig producer so driv…