Repository navigation
Description
Epic: W2 Blocked by: — Tier: mechanical Doc: W2 PLAN §4 (phase dispatch + config seams), §5 I-3, §7 D4/D9, §9 OQ-2/OQ-3, Lab §1
Problem
The fresh-session QA study (27 transcripts, 2026-05-30) found 44% of fresh second-look QA passes caught a real would-ship bug, and ranked three mechanism drivers: (1) orchestrated /qa runs lighter by design (SEQUANT_ORCHESTRATOR skips the standalone pre-flight that catches the #318/#529/#570 empty-branch class), (2) adversarial follow-up (§6d, already codified), (3) fresh context / de-anchoring.
Today's orchestrated pipeline gets neither (1) nor (3):
- QA resumes the implementer's session.
batch-executor.tscarriesresumeHandleacross phases (refactor: normalize agent-driver resume semantics (origin-cwd-bound ResumeHandle, driver-owned validation) #674), and since spec runs in the main repo while exec+qa share the worktree cwd,claude-code.ts:canResume's byte-equal-cwd rule means qa is the one phase that reliably resumes — the reviewer starts anchored to ~142k tokens (median, n=44) of the author's transcript. This was a side effect of refactor: normalize agent-driver resume semantics (origin-cwd-bound ResumeHandle, driver-owned validation) #674's exec-continuity goal, not a chosen design. - Full-weight QA exists but is unreachable.
config.fullQa→SEQUANT_FULL_QA=1(feat(cli):sequant ready <issue>— post-resolve A+ QA gate that drives an issue to merge-readiness #683) is fully honored by the qa skill, but its only producer isready-gate.ts:631. Nosequant runflag, no MCP param, no setting.
Token-cost measurement (82 orchestrator QA passes: 44 resumed, 38 fresh, from ~/.claude/projects worktree transcripts)
| Metric (median) | Resumed | Fresh |
|---|---|---|
| Context at QA start | 142k | 29k |
| Turns / output tokens | 30 / 45k | 56 / 69k |
| Cost-weighted input (in + 1.25×cache-write + 0.1×cache-read) | 1.32M | 1.24M |
| Combined (output at 5× input price) | 1.58M | 1.65M (~+5%) |
The +5% is an upper bound — the fresh group includes ready-gate (full-weight) passes and post-failure re-runs. Dropping resume for qa is roughly cost-neutral: larger per-turn context (resumed) offsets fewer turns.
Proposed change (two parts, different defaults)
1. QA never resumes the prior session (default behavior, no flag).
Orchestration policy, not driver ability: don't offer the resumeHandle at qa-phase dispatch in batch-executor.ts (including post-/loop re-QA). Do NOT change canResume — that is the driver's ability contract. exec/loop resume is untouched (anchoring is a feature there; /loop context arrives via SEQUANT_LAST_VERDICT/SEQUANT_FAILED_ACS env, #488, no resume dependency).
2. run.fullQa (opt-in).
Setting run.fullQa in .sequant/settings.json + --full-qa on sequant run + param on MCP sequant_run, all setting config.fullQa. Opt-in initially (adds visible pre-flight work); revisit the default after dogfooding a batch.
Traps to honor
- Two ExecutionConfig producers (fix(cli): bare parseInt on run --timeout lets a malformed value abort every phase instantly (sibling of #818) #833): wire the setting through
buildExecutionConfig;ready-gate.tsalready setsfullQa: true— don't regress it. bin/cli.tsneeds the.option()registration or--full-qasilently no-ops.- MCP: pre-2.13.0 servers silently drop unknown params (NEEDS_VERIFICATION maps to ready_for_merge, blocking QA re-runs; MCP sequant_run ignores force #972 precedent) — note the minimum version in the tool description.
Acceptance Criteria
- AC-1: The qa phase dispatch in
batch-executor.tspasses no resume handle (first qa and post-loop re-qa alike); a test asserts the handle is offered to exec and absent for qa, mutation-verified. - AC-2:
run.fullQa: truein.sequant/settings.jsonresults inSEQUANT_FULL_QA=1in the qa phase agent env viasequant run, verified by a wiring test throughbuildExecutionConfig. - AC-3:
sequant run <n> --full-qaand the MCPsequant_runfullQaparam each setconfig.fullQa, with the CLI flag registered inbin/cli.ts(e2e trace: bin/cli.ts → RunOptions → ExecutionConfig → phase-executor env). - AC-4: With
run.fullQaunset and no flag, the run path is behavior-identical to today except the qa resume drop (existing suite green; no default flip of fullQa). - AC-5:
ready-gate.tsstill forcesfullQa: trueregardless of the new setting (regression test).
Non-Goals
- No fresh-session for exec/loop (anchoring is intentional there).
- No default-on for
run.fullQain this issue. - No
/fullsolveskill changes or plugin-conditional delegation.
Evidence provenance
Measurement script: sums per-turn usage from assistant messages after the Run the /qa N workflow prompt in worktree session jsonl files; fresh = qa prompt is the session's first phase prompt, resumed = qa prompt follows an exec prompt in the same session file. Sidechain (subagent) messages excluded from both groups.
W2 plan — scope and verify commands (node 02)
Scope
- may touch:
src/lib/workflow/batch-executor.ts(qa dispatch sites only),
src/lib/workflow/config-resolver.ts(buildExecutionConfig),
src/lib/settings.ts(onerun.fullQakey, one schema line),
src/lib/cli-flags.ts,bin/cli.ts(one.option()line onrun),
src/commands/run.ts,src/mcp/tools/run.ts(one zod param + description
note),README.md(onerunflags row, one settings-key line),
CHANGELOG.md(one bullet); tests:src/lib/workflow/batch-executor.test.ts,
newsrc/lib/workflow/full-qa.test.ts,src/mcp/tools/run.test.ts,
src/lib/workflow/ready-gate.test.ts(added case only). - not in scope:
drivers/*(I-3),ready-gate.ts(regression test only),
types.ts(fullQa?: booleanalready exists at:208), exec/loop resume,
any default flip offullQa, skills. - real
buildExecutionConfigin the wiring test — no mocking of
config-resolver(I-8).
Acceptance criteria
- AC-1: every dispatch of the
qaphase inbatch-executor.tspasses no resume handle — the first qa and any re-QA after a loop iteration alike — while exec keeps receiving it — Verify:npx vitest run src/lib/workflow/batch-executor.test.ts -t "982"→ the injectedexecutePhaseFnseesresumeHandledefined for exec andundefinedfor every qa call across aspec,exec,qarun with one quality-loop retry. Mutation: pass the handle for qa → fails; restore. (OQ-2: the spec names every site that can dispatch qa — Verify:grep -n "executePhaseWithRetry(" src/lib/workflow/batch-executor.tslisted in the PR body.) - AC-2:
run.fullQa: truein.sequant/settings.jsonproducesSEQUANT_FULL_QA=1in the qa phase agent env viasequant run, wired throughbuildExecutionConfig— Verify:npx vitest run src/lib/workflow/full-qa.test.ts -t "AC-2"→ settings →buildExecutionConfig→ phase-executor env assertion, no mocks on the resolver. - AC-3:
sequant run <n> --full-qaand the MCPsequant_runfullQaparam each setconfig.fullQa; the CLI flag is registered inbin/cli.ts; the MCP description names the minimum server version that honors the param — Verify:node dist/bin/cli.js run --help | grep -c -- '--full-qa'→1;npx vitest run src/mcp/tools/run.test.ts -t "fullQa"→ param accepted and forwarded;grep -c "fullQa" src/lib/workflow/types.ts≥ 2 (RunOptions + ExecutionConfig declarations; runner amendment 2026-09-10, D15 — the originalsrc/lib/cli-flags.tsgrep is unsatisfiable: that file holds value-taking coercions only, and the precedent boolean flags--ready-gate/--escalate-effort/--auto-mergehave 0 hits there). - AC-4: with
run.fullQaunset and no flag, behavior is identical to today except the qa resume drop — Verify:npm run build && npm test→ pass;grep -n "fullQa" src/lib/settings.ts→ the schema line has nodefault(true). - AC-5:
ready-gate.tsstill forcesfullQa: trueregardless of the new setting — Verify:npx vitest run src/lib/workflow/ready-gate.test.ts -t "fullQa"→ the existing case plus one withrun.fullQa: falseboth seefullQa: trueon every qa dispatch. - AC-6:
canResumeand the drivers are untouched — Verify:git diff origin/main --stat -- src/lib/workflow/drivers/ | wc -l→0. - AC-7: documented — README gains one
--full-qarow and onerun.fullQaline;CHANGELOG.md[Unreleased]gains one bullet naming the qa-resume change — Verify:grep -c "full-qa\|fullQa" README.md≥ 2;grep -c "resume" CHANGELOG.md≥ 1.
Done when
The qa phase never starts from the implementer's session, and full-weight QA
is reachable from the CLI flag, the settings key and the MCP param without
changing ready-gate or any driver.
Activity
docs(graph): wave 2 plan — sync ownership, fresh-session QA, trust co…
admarble commentedon Sep 10, 2026
Runner context — W2 wave 1 launch (2026-09-10). Base
mainat 988559f (v2.14.0). Stop-at-PR: open the PR, do not merge. #990 and #980 run in parallel; each adds one.option()line tobin/cli.ts, one README region and one append-only CHANGELOG bullet (PLAN §8) — keep to yours.executePhaseWithRetry(site inbatch-executor.tsthat can dispatch qa.Mutation-verified:in the PR body (CLAUDE.md format).admarble commentedon Sep 10, 2026
Complexity: Standard (7 ACs, 6 files + 2 docs)
AC Quality Check
All 7 ACs already carry concrete
Verify:commands (a strong pattern) — but the parser only recognizes a literalEvidence:clause (EVIDENCE_CLAUSE_REinsrc/lib/ac-parser.ts), so none of these are picked up as declared evidence;extractAcceptanceCriteriawill fall back to keyword inference for each. Inference should still land correctly (command text containsvitest run/npx vitest), so this is non-blocking, but worth naming: future issues in this format won't get the #938 declared-evidence priority unless the keyword is literallyEvidence:.Non-Goals section: present. No vague/unmeasurable phrasing found.
Scope Assessment
Non-Goals: No fresh-session for exec/loop; no default-on for
run.fullQa; no/fullsolveor plugin-conditional changes (from issue body).src/lib/workflow,src/lib,bin,src/commands,src/mcp/tools, root docs)Verdict: ✅ SCOPE_OK — the breadth is real but each touchpoint is a one-line wiring edit (matches the
autoMerge/#958 andmodelLadder/#971 precedent), and the issue's own "may touch"/"not in scope" lists already fence it tightly.Acceptance Criteria
AC-1: Qa phase dispatch never carries a resume handle
Verification: Unit Test
Scenario: Given a
spec,exec,qarun with one quality-loop retry → When each phase dispatches viaexecutePhaseWithRetry→ Then the injectedexecutePhaseFnseesresumeHandledefined forexecandundefinedfor everyqacall (first pass and post-loop re-QA alike).Assumptions: Only one call site needs the change (see OQ-2 below);
canResume/drivers are not touched.Verify:
npx vitest run src/lib/workflow/batch-executor.test.ts -t "982"— mutation-verified per CLAUDE.md (pass the handle for qa → fails; restore).AC-2:
run.fullQasetting reaches the qa agent envVerification: Integration Test
Scenario: Given
.sequant/settings.jsonwithrun.fullQa: true→ Whensequant runbuilds the qa phase config viabuildExecutionConfig→ Then the phase-executor env carriesSEQUANT_FULL_QA=1.Assumptions: No mocking of
config-resolverin the wiring test (project convention, I-8).Verify:
npx vitest run src/lib/workflow/full-qa.test.ts -t "AC-2"AC-3:
--full-qaCLI flag and MCPfullQaparam both setconfig.fullQaVerification: Integration Test
Scenario: Given
sequant run <n> --full-qaor MCPsequant_run({fullQa: true})→ When the run resolves config → Thenconfig.fullQa === truein both paths, and the flag is registered inbin/cli.ts.Assumptions: MCP tool description states the minimum server version that honors the param (pre-2.13.0 servers silently drop unknown params, #972 precedent).
Verify:
node dist/bin/cli.js run --help | grep -c -- '--full-qa'→1;npx vitest run src/mcp/tools/run.test.ts -t "fullQa";grep -c "fullQa" src/lib/cli-flags.ts≥ 1AC-4: Unset
run.fullQa+ no flag ⇒ behavior-identical to today (minus resume drop)Verification: Integration Test
Scenario: Given no
run.fullQasetting and no--full-qaflag → When the full suite runs → Then it's green, and the schema default forfullQaisfalse/absent, neverdefault(true).Assumptions:
RunSettingsSchemainsrc/lib/settings.ts:496is the right home (confirmed: sibling keysautoMerge/modelLadderfollow this exact pattern).Verify:
npm run build && npm test;grep -n "fullQa" src/lib/settings.ts→ nodefault(true)AC-5:
ready-gate.tsstill forcesfullQa: trueregardless of the settingVerification: Unit Test
Scenario: Given
run.fullQa: falsein settings → When the ready gate dispatches qa → ThenbuildPhaseConfig(opts, { fullQa: true })(already atready-gate.ts:760) still wins on every dispatch.Assumptions: This is a regression test only — no production code change to
ready-gate.tsitself.Verify:
npx vitest run src/lib/workflow/ready-gate.test.ts -t "fullQa"AC-6:
canResumeand drivers untouchedVerification: Manual Test (scripted, no judgment call)
Scenario: Given the full PR diff → When diffed against
origin/main→ Thensrc/lib/workflow/drivers/shows zero changed lines.Assumptions: None — this is a hard fence, not a behavior check.
Verify:
git diff origin/main --stat -- src/lib/workflow/drivers/ | wc -l→0AC-7: Documented
Verification: Manual Test
Scenario: Given the merged PR → When a reader checks README/CHANGELOG → Then README has one
--full-qarow + onerun.fullQasettings line, and CHANGELOG[Unreleased]has one bullet naming the qa-resume change.Assumptions: None.
Verify:
grep -c "full-qa\|fullQa" README.md≥ 2;grep -c "resume" CHANGELOG.md≥ 1Implementation Plan
Phase 1: Fresh-session QA (AC-1, AC-6)
executePhaseWithRetry(appears at 4 sites inbatch-executor.ts::913(ready-gate'srunPhase, already passesundefinedunconditionally — no change needed),:1122(spec-only dispatch, never qa — no change needed),:1638(the per-phasefor (phaseIdx...)loop — this is the only qa dispatch site, sincephasescan include"qa"and iterates again on quality-loop retry),:1957(the"loop"phase itself, not qa — no change needed). Change:1638to passphase === "qa" ? undefined : resumeHandle.batch-executor.test.tsper AC-1.git diff --stat -- src/lib/workflow/drivers/stays empty (AC-6) — this change never touchescanResume.Phase 2:
run.fullQawiring (AC-2, AC-3, AC-5)fullQa: z.boolean().default(false)toRunSettingsSchema(src/lib/settings.ts:496), next toautoMerge/modelLadder.settings.run.fullQathrough the existing 4-layer merge inconfig-resolver.ts'sbuildExecutionConfig— same shape asautoWaitMinutes..option("--full-qa", "Force full-weight QA regardless of resume/context state")on theruncommand inbin/cli.ts; addfullQa?: booleantoRunOptions(types.ts:541); pass through as the explicit layer.fullQa: z.boolean().optional().describe(...)torunToolInputSchemainsrc/mcp/tools/run.ts, description names the minimum server version (mirror thephases/forceparam doc style already there).buildPhaseConfig(opts, { fullQa: true })overrides the new settings layer, not the other way around.Phase 3: Docs + full-suite gate (AC-4, AC-7)
--full-qaflag row, onerun.fullQasettings-key line.[Unreleased]: one bullet on the qa-resume-drop behavior change.npm run build && npm testgreen; confirm nodefault(true)regression.Design Review
batch-executor.ts(not the driver'scanResumecontract — AC-6 enforces that split);fullQais standard 4-layer config resolution (config-resolver.ts+settings.ts+ CLI/MCP explicit layers).phase === "qa" ? undefined : resumeHandleconditional at the one real dispatch site (:1638) — no change toexecutePhaseWithRetry's signature, no change tocanResume. Minimizes blast radius and satisfies AC-6 by construction rather than by discipline.fullQa's 4-layer + zod-schema + CLI-option + MCP-param wiring is identical in shape toautoMerge(fix(fullsolve): Phase 5.3 auto-merges the PR — the skill's own stop-list says to halt at the final summary #958) andmodelLadder(feat(run): model escalation ladder on capability-bound non-convergence #971) — no new resolution mechanism invented.loopphase at:1957need the same treatment?" — No: it's a distinct phase name, not qa, and its resume continuity is intentional (that's what lets/loopsee prior context; cross-iteration context also arrives viaSEQUANT_LAST_VERDICT/SEQUANT_FAILED_ACSenv per Quality loop retries misclassified as cold-start failures, wasting retry budget #488, independent of resume). Worth stating explicitly in the PR body so a reviewer doesn't have to re-derive it from the loop-phase code.Feature Quality Planning
All standard checks pass. Notable items:
Verify:rather than the parser's literalEvidence:keyword (see AC Quality Check above) — non-blocking, flagged for future issue authoring.security-reviewphase needed..tsx/.jsxtouched — no browser-test label needed.Open Questions
fullQa: trueoverride survive being layered on top of a resolvedrun.fullQa: false? — Recommendation: yes by construction, sinceready-gate.ts:760'sbuildPhaseConfig(opts, { fullQa: true })applies afterbuildExecutionConfigresolves the settings layer, not before; AC-5's regression test is exactly this check. Impact if wrong: ready-gate silently downgrades to non-full QA, regressing the feat(qa/loop/ready): structured gap findings — finite taxonomy with required evidence, replacing the lossy prose-scrape gap channel #937 gate's strength — this is why AC-5 is a hard requirement, not a nice-to-have.Recommended Workflow
Phases: spec → testgen → exec → qa
Quality Loop: disabled
Reasoning: Mechanical tier per the W2 plan (PLAN §4/§7); ACs 1, 2, 3, 5 resolve to Unit/Integration Test by keyword inference (
vitest runin each verify command) even though not declared viaEvidence:— testgen can stubbatch-executor.test.ts,full-qa.test.ts,run.test.ts(mcp), and theready-gate.test.tsaddition directly from the named verify commands. Quality loop off — scope is SCOPE_OK and the wave-1 graph plan already classifies this node as mechanical with a human gate at PR (#1027), not an auto-retry loop.Label Review
Current:
enhancement,graph-2026-09-w2Recommended:
enhancement,graph-2026-09-w2,plannedReason: Labels are already correct for a graph-plan node; adding
plannedper the standard/spechandoff signal.Quality Loop: Won't auto-enable — scope verdict is SCOPE_OK, not SCOPE_WARNING.
→
gh issue edit 982 --add-label "planned"admarble commentedon Sep 10, 2026
QA Verdict: AC_MET_BUT_NOT_A_PLUS
AC coverage: 0/1 met
Gaps:
Suggestions:
"fullQa"appears inrunToolInputSchema, or derive the handler's param type from the schema viaz.inferso TS binds them).:1657comment to state where the guard actually bites (loop skipped / no loop handle / post-qa phases) and note the loop-resume consequence.--full-qarow andrun.fullQaline todocs/reference/run-command.md.fix(#982): post-QA follow-ups — accurate guard rationale, loop-aware …
docs(graph): wave-1 execution record — D15–D17, post-wave ledger, han…
docs(graph): wave-2 plan — node 09 (#1030), D14–D17, and the wave-1 e…
feat(run): fresh-session QA — never resume the exec session into qa; …