Skip to content

fix(ready-gate): collapse the second ExecutionConfig producer so driver settings reach the gate (#863) - #1004

Merged
admarble merged 9 commits into
mainfrom
feature/863-fix-ready-gate-driver-settings-never-reach-the-gat
Sep 8, 2026
Merged

admarble merged 9 commits into
mainfrom
feature/863-fix-ready-gate-driver-settings-never-reach-the-gat

Conversation

@admarble

@admarble admarble commented Sep 7, 2026 •

Copy link
Copy Markdown
Contributor

Summary

The ready gate never received the run's driver settings. RunReadyGateOptions had no agent/aiderSettings field at all, so neither caller could pass one, and buildPhaseConfig built each gate phase's ExecutionConfig from its own literal. With run.agent: "aider" configured, a project ran its main phases on aider and its ready-gate QA pass silently on claude-code.

Rather than add agent/aiderSettings as two more one-off primitives (today's instance of #833's drift class, already patched per-field at #914/#915/#936), this collapses the second producer:

  • RunReadyGateOptions carries the caller's fully-resolved ExecutionConfig as one required config field.
  • buildPhaseConfig spreads it and overrides only the six gate-semantic keys in GATE_CONFIG_OVERRIDES (phases, qualityLoop, sequential, concurrency, parallel, dryRun).
  • commands/ready.ts resolves once via buildExecutionConfig instead of keeping inline resolvePhasePolicies / effortEscalation blocks in lockstep by hand.
  • batch-executor.ts passes the parent run's config straight through — issueConfig, not config, so a docs-labelled issue's gate phases carry the same issueType its earlier phases had.

Inherited behaviour changes (declared, not discovered)

  • retry now honours --no-retry instead of being hardcoded true.
  • settings.run.mcp is now honoured by sequant ready (A+ pass: the command routes through resolveRunOptions → buildExecutionConfig, which reads run.mcp; previously MCP was on unless --no-mcp was passed).
  • autoWaitMinutes now lets a rate-limited gate phase wait out the window (feat(run): --auto-wait — continue a rate-limited run when the window resets instead of halting #804) instead of failing.
  • relayEnabled now reaches gate phases.
  • skipVerification, noSmartTests, isolateParallel, issueType now inherit.
  • readyGate: true is inherited but inert — only batch-executor reads it, so there is no recursion; phase-executor never consults it.

AC Verification

AC Verify command (run verbatim, I-9) Result
AC-1 grep -nE 'agent\?*:|aiderSettings\?*:' src/lib/workflow/ready-gate.ts ✅ no matches (exit 1) — fields arrive only inside config
AC-2 npx vitest run src/commands/ready.test.ts src/lib/workflow/ready-gate.test.ts -t "863" ✅ 3 passed
AC-3 same -t "863" run — spies getDriver, asserts "aider" ✅ passed
AC-4 npx vitest run src/lib/workflow/execution-config-parity.test.ts ✅ 9 passed
AC-5 npx vitest run src/lib/workflow/ready-gate-run.test.ts src/lib/workflow/ready-gate.phase-policy.test.ts src/commands/ready.phase-policy.test.ts ✅ 12 passed

Mutation records

Mutation-verified: AC-4 — re-hardcoded retry: true in buildPhaseConfig; execution-config-parity.test.ts failed; restored.

Mutation-verified: AC-1 — re-added a compiling resolvePhasePolicies call to commands/ready.ts (the second producer); config-resolver.model-roles.test.ts failed; restored.

Both mutations were applied against a committed tree and verified to fail exactly the named test while the sibling ready/gate/parity suites stayed green.

Test plan

  • npm run build ✅
  • npm run lint ✅ (0 warnings, --max-warnings 0)
  • npx vitest run (full suite) — 285/288 files pass; 5799 passed. Three failures (prompt-wait.test.ts, batch-executor.test.ts > withActivityHook, relay-hook.integration.test.ts) are pre-existing: settled by checking out origin/main in this same worktree and reproducing all three identically. None touch this change's surface.

Known gaps

  • runReadyGateForIssue is module-private and untested; the config: issueConfig call-site change is a one-line pass-through documented in-code rather than gated by a test. Exporting it purely to assert one argument was judged out of proportion to the risk.
  • Spec Open Question 1 resolved as recommended: src/commands/ready.phase-policy.test.ts (one file off the "may touch" list) is re-anchored from opts.phasePolicies to opts.config.phasePolicies. Keeping the top-level field would leave the duplicate channel this change exists to remove.
  • Spec Open Question 2 kept as-is: the gate still forces dryRun: false, allowlisted in the parity test as permitted to differ. Pre-existing behaviour, not a regression here.

Closes #863

A+ pass (runner, 2026-09-07, commit b7b13ff)

Addresses the QA round-1 notes so this PR can reach READY_FOR_MERGE:

  • ready.ts no longer bypasses resolveRunOptions — its CLI subset goes through the same CLI > env > settings merge as run, so run.smartTests / SEQUANT_SMART_TESTS, run.autoWaitMinutes / SEQUANT_AUTO_WAIT_MINUTES and agents.isolateParallel resolve identically on both entry points (the QA's measured divergence). New test in ready.test.ts asserts noSmartTests/autoWaitMinutes reach the gate config from settings; the existing fix(ready-gate): driver settings never reach the gate (RunReadyGateOptions lacks the fields) — silently runs claude-code for aider/opencode configs #863 deep-equal test now computes its expected value through resolveRunOptions exactly as the command does. CHANGELOG entry added.
  • Stale two-producer doc comments retired at all seven sites the QA listed (config-resolver.ts ×2 incl. the positiveOr export rationale, types.ts ×2, ready-gate.phase-policy.test.ts, ready-limits.test.ts, phase-executor.ts) plus four more found by grep (ready.ts resolveReadyLimits rationale, config-resolver.ts effortEscalation, config-resolver.model-roles.test.ts header, phase-executor.phase-policy.test.ts header).
  • Off-list file disclosure: src/lib/workflow/config-resolver.model-roles.test.ts was edited in 2079fc1e (its feat(config): model roles — semantic indirection between phase policy/ladders and concrete model strings #975 AC-5 drift guard asserted the producer this PR deletes; re-anchored onto the collapse) — disclosed here per the QA's note.

A+ rounds 2–4 (commits ebe5898, ca517a0, a916aa5)

  • ready-gate.phase-policy.test.ts and config-resolver.phase-policy.test.ts headers and describe titles retitled off the producer-1/producer-2 framing; config-resolver.ts phasePolicies comment, config-resolver.model-roles.test.ts title, and run-orchestrator.model-roles.test.ts comment likewise. Completeness claim, this time by grep: grep -rni producer src leaves only historical wording ("before the producer collapse", "was a second producer") and unrelated producers (prompt-context builders, log writers, the package-manager drift class in stacks.ts).
  • settings.run.mcp on the ready path: CHANGELOG + inherited-changes list updated; direct test added (opts.config.mcp === false from settings) and a separate --no-mcp CLI-flag test, so removing the resolveRunOptions hop would fail a test rather than silently no-op the flag.
  • CHANGELOG notes that inherited auto-wait is budgeted per gate phase (fresh ledger), not per issue.
  • Still not done: a test for the config: issueConfig call site in batch-executor.ts (runReadyGateForIssue is module-private); the existing call-site comment states the intent.

A+ round 5 (commit 0f07de6)

  • Env layer on the ready path: --max-iterations/--timeout now go into resolveRunOptions raw, so SEQUANT_MAX_ITERATIONS applies between CLI and settings (there is no timeout env var — an earlier draft of this bullet named one) exactly as on run (QA measured 9 vs 3 before); buildExecutionConfig's positiveOr chain guards the result, and the gate's loop limit / per-phase timeout are read back from the resolved config. resolveReadyLimits is consumed only for tokenBudget now (kept exported and tested). New test asserts SEQUANT_MAX_ITERATIONS=9 reaches opts.config.maxIterations.
  • Inert skipVerification: the parity test's OQ-12 case no longer asserts it (no producer sets it, nothing reads it — the assertion could not fail) and the CHANGELOG's inherited-fields list drops it. The field itself is pre-existing dead surface on ExecutionConfig (types.ts:105, defaulted in DEFAULT_CONFIG, no CLI flag); not removed here — that is a separate cleanup, recorded in this PR rather than filed (PLAN §5 I-7).

A+ round 6 (commit 6a7f81c)

  • The round-5 comment named a SEQUANT_TIMEOUT env var that does not exist; removed (only SEQUANT_MAX_ITERATIONS is in the env layer).
  • resolveReadyLimits now returns only tokenBudget — the one value that never enters an ExecutionConfig; maxIterations/phaseTimeout are read back from the resolved config, so the function no longer carries an unreachable guard. ready-limits.test.ts keeps the budget cases and points at the new ready.test.ts case that asserts the fix(cli): bare parseInt on run --timeout lets a malformed value abort every phase instantly (sibling of #818) #833 property on the ready path (settings.run.timeout: 0 / maxIterations: 0 → defaults reach the gate, and the gate's own loop bound follows the resolved config). Unused imports in ready.ts pruned; positiveOr's export rationale corrected (no module calls it since this change).
  • Parity-test header sentence repaired.

A+ round 7 (commit 80a1f6d)

  • The sequant run --ready-gate caller is now gated too: ready-gate-run.test.ts asserts the gate receives the resolved config itself (agent: "aider", aiderSettings, maxIterations, readyGate) and that a docs-labelled issue's gate phases carry issueType: "docs" — the config: issueConfig call-site choice that earlier rounds left ungated. No export was needed (runReadyGate is already mocked there).
  • ready.test.ts notes the hand-copied CLI-subset mirror as a known constraint and points at the per-flag cases that gate what the deep-equal cannot.

The ready gate never received the run's driver settings. `RunReadyGateOptions`
had no `agent`/`aiderSettings` field at all, so neither caller could pass one,
and `buildPhaseConfig` built each gate phase's `ExecutionConfig` from its own
literal. With `run.agent: "aider"` configured, a project ran its main phases on
aider and its ready-gate QA pass silently on claude-code — a mid-run backend
switch with different cost, auth and behaviour that the user never asked for.

Rather than add `agent`/`aiderSettings` as two more one-off primitives (today's
instance of #833's drift class, already patched per-field at #914/#915/#936),
collapse the second producer: `RunReadyGateOptions` now carries the caller's
fully-resolved `ExecutionConfig` as one required `config` field, and
`buildPhaseConfig` spreads it, overriding only the six gate-semantic keys in
`GATE_CONFIG_OVERRIDES` (phases, qualityLoop, sequential, concurrency,
parallel, dryRun). `commands/ready.ts` now resolves once via
`buildExecutionConfig` instead of keeping inline `resolvePhasePolicies` /
`effortEscalation` blocks in lockstep by hand; `batch-executor.ts` passes the
parent run's config straight through.

Inherited behaviour changes (the point of the fix, named so they are declared
rather than discovered):

- `retry` now honours `--no-retry` instead of being hardcoded true.
- `autoWaitMinutes` now lets a rate-limited gate phase wait out the window
  (#804) instead of failing.
- `relayEnabled` now reaches gate phases.
- `skipVerification`, `noSmartTests`, `isolateParallel`, `issueType` inherit.
- `readyGate: true` is inherited but inert — only `batch-executor` reads it, so
  there is no recursion; `phase-executor` never consults it.
- Under `sequant run --ready-gate` the call site now passes `issueConfig`, so a
  docs-labelled issue's gate phases carry the same `issueType` its earlier
  phases had.

`src/commands/ready.phase-policy.test.ts` is re-anchored from
`opts.phasePolicies` onto `opts.config.phasePolicies` (spec Open Question 1 —
keeping the top-level field would leave the duplicate channel this change
exists to remove). New `execution-config-parity.test.ts` diffs both producers
over the union of their keys and fails on any unallowlisted drift.

Closes #863

Entire-Checkpoint: bfbeff23de75
`config-resolver.model-roles.test.ts` asserted that `commands/ready.ts`
calls `resolvePhasePolicies` itself with `modelRoles` + `activeDriver` —
written when ready.ts was the second ExecutionConfig producer. #863
deletes that producer, so both assertions failed against the new code.

Re-anchored onto the invariant that replaced them: ready delegates to
`buildExecutionConfig` and does not re-implement phase-policy resolution.
The drift #975 detected is now structurally impossible rather than merely
caught, and the behaviour it cared about (role: resolves, unknown role
throws) is covered against the single producer by the AC-1/AC-2 cases in
the same file.

Assertions now match comment-stripped source. The old
`/resolvePhasePolicies/` check passed against the new ready.ts only
because a comment explaining the removal named the symbol — the
whole-file-match trap CLAUDE.md warns about.

Entire-Checkpoint: ea98aea86810
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

fix(ready-gate): driver settings never reach the gate (RunReadyGateOptions lacks the fields) — silently runs claude-code for aider/opencode configs

1 participant