Skip to content

feat(run): fresh-session QA — never resume the exec session into qa; expose run.fullQa (setting + --full-qa + MCP param) #982

Closed

Description

@admarble

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):

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

Acceptance Criteria

  • AC-1: The qa phase dispatch in batch-executor.ts passes 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: true in .sequant/settings.json results in SEQUANT_FULL_QA=1 in the qa phase agent env via sequant run, verified by a wiring test through buildExecutionConfig.
  • AC-3: sequant run <n> --full-qa and the MCP sequant_run fullQa param each set config.fullQa, with the CLI flag registered in bin/cli.ts (e2e trace: bin/cli.ts → RunOptions → ExecutionConfig → phase-executor env).
  • AC-4: With run.fullQa unset 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.ts still forces fullQa: true regardless of the new setting (regression test).

Non-Goals

  • No fresh-session for exec/loop (anchoring is intentional there).
  • No default-on for run.fullQa in this issue.
  • No /fullsolve skill 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 (one run.fullQa key, one schema line),
    src/lib/cli-flags.ts, bin/cli.ts (one .option() line on run),
    src/commands/run.ts, src/mcp/tools/run.ts (one zod param + description
    note), README.md (one run flags row, one settings-key line),
    CHANGELOG.md (one bullet); tests: src/lib/workflow/batch-executor.test.ts,
    new src/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?: boolean already exists at :208), exec/loop resume,
    any default flip of fullQa, skills.
  • real buildExecutionConfig in the wiring test — no mocking of
    config-resolver (I-8).

Acceptance criteria

  • AC-1: every dispatch of the qa phase in batch-executor.ts passes 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 injected executePhaseFn sees resumeHandle defined for exec and undefined for every qa call across a spec,exec,qa run 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.ts listed in the PR body.)
  • AC-2: run.fullQa: true in .sequant/settings.json produces SEQUANT_FULL_QA=1 in the qa phase agent env via sequant run, wired through buildExecutionConfig — 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-qa and the MCP sequant_run fullQa param each set config.fullQa; the CLI flag is registered in bin/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 original src/lib/cli-flags.ts grep is unsatisfiable: that file holds value-taking coercions only, and the precedent boolean flags --ready-gate/--escalate-effort/--auto-merge have 0 hits there).
  • AC-4: with run.fullQa unset 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 no default(true).
  • AC-5: ready-gate.ts still forces fullQa: true regardless of the new setting — Verify: npx vitest run src/lib/workflow/ready-gate.test.ts -t "fullQa" → the existing case plus one with run.fullQa: false both see fullQa: true on every qa dispatch.
  • AC-6: canResume and the drivers are untouched — Verify: git diff origin/main --stat -- src/lib/workflow/drivers/ | wc -l → 0.
  • AC-7: documented — README gains one --full-qa row and one run.fullQa line; 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

  1. added
    enhancement
    on Aug 31, 2026
  2. added
    graph-2026-09-w2
    on Sep 9, 2026
  3. admarble commented on Sep 10, 2026

    @admarble
    ContributorAuthor

    Runner context — W2 wave 1 launch (2026-09-10). Base main at 988559f (v2.14.0). Stop-at-PR: open the PR, do not merge. #990 and #980 run in parallel; each adds one .option() line to bin/cli.ts, one README region and one append-only CHANGELOG bullet (PLAN §8) — keep to yours.

    • OQ-2: the spec and the PR body must list every executePhaseWithRetry( site in batch-executor.ts that can dispatch qa.
    • AC-1 is a gate test: record Mutation-verified: in the PR body (CLAUDE.md format).
    • Commit a WIP within 5 minutes and every ~10 minutes; a phase silent for 30 minutes is killed. Targeted tests in the foreground only.
  4. admarble commented on Sep 10, 2026

    @admarble
    ContributorAuthor

    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 literal Evidence: clause (EVIDENCE_CLAUSE_RE in src/lib/ac-parser.ts), so none of these are picked up as declared evidence; extractAcceptanceCriteria will fall back to keyword inference for each. Inference should still land correctly (command text contains vitest 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 literally Evidence:.

    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 /fullsolve or plugin-conditional changes (from issue body).

    Metric Value Status
    Feature count 2 (resume-drop policy; fullQa opt-in surface) ✅
    AC items 7 ✅
    Directory spread 6 (src/lib/workflow, src/lib, bin, src/commands, src/mcp/tools, root docs) ⚠️ wide-but-shallow

    Verdict: ✅ SCOPE_OK — the breadth is real but each touchpoint is a one-line wiring edit (matches the autoMerge/#958 and modelLadder/#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,qa run with one quality-loop retry → When each phase dispatches via executePhaseWithRetry → Then the injected executePhaseFn sees resumeHandle defined for exec and undefined for every qa call (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.fullQa setting reaches the qa agent env

    Verification: Integration Test
    Scenario: Given .sequant/settings.json with run.fullQa: true → When sequant run builds the qa phase config via buildExecutionConfig → Then the phase-executor env carries SEQUANT_FULL_QA=1.
    Assumptions: No mocking of config-resolver in the wiring test (project convention, I-8).
    Verify: npx vitest run src/lib/workflow/full-qa.test.ts -t "AC-2"

    AC-3: --full-qa CLI flag and MCP fullQa param both set config.fullQa

    Verification: Integration Test
    Scenario: Given sequant run <n> --full-qa or MCP sequant_run({fullQa: true}) → When the run resolves config → Then config.fullQa === true in both paths, and the flag is registered in bin/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 ≥ 1

    AC-4: Unset run.fullQa + no flag ⇒ behavior-identical to today (minus resume drop)

    Verification: Integration Test
    Scenario: Given no run.fullQa setting and no --full-qa flag → When the full suite runs → Then it's green, and the schema default for fullQa is false/absent, never default(true).
    Assumptions: RunSettingsSchema in src/lib/settings.ts:496 is the right home (confirmed: sibling keys autoMerge/modelLadder follow this exact pattern).
    Verify: npm run build && npm test; grep -n "fullQa" src/lib/settings.ts → no default(true)

    AC-5: ready-gate.ts still forces fullQa: true regardless of the setting

    Verification: Unit Test
    Scenario: Given run.fullQa: false in settings → When the ready gate dispatches qa → Then buildPhaseConfig(opts, { fullQa: true }) (already at ready-gate.ts:760) still wins on every dispatch.
    Assumptions: This is a regression test only — no production code change to ready-gate.ts itself.
    Verify: npx vitest run src/lib/workflow/ready-gate.test.ts -t "fullQa"

    AC-6: canResume and drivers untouched

    Verification: Manual Test (scripted, no judgment call)
    Scenario: Given the full PR diff → When diffed against origin/main → Then src/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 → 0

    AC-7: Documented

    Verification: Manual Test
    Scenario: Given the merged PR → When a reader checks README/CHANGELOG → Then README has one --full-qa row + one run.fullQa settings 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 ≥ 1


    Implementation Plan

    Phase 1: Fresh-session QA (AC-1, AC-6)

    1. OQ-2 answered by grep — executePhaseWithRetry( appears at 4 sites in batch-executor.ts: :913 (ready-gate's runPhase, already passes undefined unconditionally — no change needed), :1122 (spec-only dispatch, never qa — no change needed), :1638 (the per-phase for (phaseIdx...) loop — this is the only qa dispatch site, since phases can include "qa" and iterates again on quality-loop retry), :1957 (the "loop" phase itself, not qa — no change needed). Change :1638 to pass phase === "qa" ? undefined : resumeHandle.
    2. Add the mutation-verified test case to batch-executor.test.ts per AC-1.
    3. Confirm git diff --stat -- src/lib/workflow/drivers/ stays empty (AC-6) — this change never touches canResume.

    Phase 2: run.fullQa wiring (AC-2, AC-3, AC-5)

    1. Add fullQa: z.boolean().default(false) to RunSettingsSchema (src/lib/settings.ts:496), next to autoMerge/modelLadder.
    2. Thread settings.run.fullQa through the existing 4-layer merge in config-resolver.ts's buildExecutionConfig — same shape as autoWaitMinutes.
    3. Add .option("--full-qa", "Force full-weight QA regardless of resume/context state") on the run command in bin/cli.ts; add fullQa?: boolean to RunOptions (types.ts:541); pass through as the explicit layer.
    4. Add fullQa: z.boolean().optional().describe(...) to runToolInputSchema in src/mcp/tools/run.ts, description names the minimum server version (mirror the phases/force param doc style already there).
    5. Add the ready-gate regression case per AC-5 — confirm buildPhaseConfig(opts, { fullQa: true }) overrides the new settings layer, not the other way around.

    Phase 3: Docs + full-suite gate (AC-4, AC-7)

    1. README: one --full-qa flag row, one run.fullQa settings-key line.
    2. CHANGELOG [Unreleased]: one bullet on the qa-resume-drop behavior change.
    3. npm run build && npm test green; confirm no default(true) regression.

    Design Review

    1. Where does this logic belong? Two separate homes, correctly split by the issue: the resume decision is orchestration policy in batch-executor.ts (not the driver's canResume contract — AC-6 enforces that split); fullQa is standard 4-layer config resolution (config-resolver.ts + settings.ts + CLI/MCP explicit layers).
    2. Simplest correct approach: a single phase === "qa" ? undefined : resumeHandle conditional at the one real dispatch site (:1638) — no change to executePhaseWithRetry's signature, no change to canResume. Minimizes blast radius and satisfies AC-6 by construction rather than by discipline.
    3. What existing pattern does this follow? fullQa's 4-layer + zod-schema + CLI-option + MCP-param wiring is identical in shape to autoMerge (fix(fullsolve): Phase 5.3 auto-merges the PR — the skill's own stop-list says to halt at the final summary #958) and modelLadder (feat(run): model escalation ladder on capability-bound non-convergence #971) — no new resolution mechanism invented.
    4. What would a senior reviewer challenge? "Does the loop phase at :1957 need the same treatment?" — No: it's a distinct phase name, not qa, and its resume continuity is intentional (that's what lets /loop see prior context; cross-iteration context also arrives via SEQUANT_LAST_VERDICT/SEQUANT_FAILED_ACS env 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:

    • AC verify commands use Verify: rather than the parser's literal Evidence: keyword (see AC Quality Check above) — non-blocking, flagged for future issue authoring.
    • Not security-sensitive (no auth/payment/admin surface touched) — no security-review phase needed.
    • No .tsx/.jsx touched — no browser-test label needed.

    Open Questions

    1. Does ready-gate's per-dispatch fullQa: true override survive being layered on top of a resolved run.fullQa: false? — Recommendation: yes by construction, since ready-gate.ts:760's buildPhaseConfig(opts, { fullQa: true }) applies after buildExecutionConfig resolves 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 run in each verify command) even though not declared via Evidence: — testgen can stub batch-executor.test.ts, full-qa.test.ts, run.test.ts (mcp), and the ready-gate.test.ts addition 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-w2
    Recommended: enhancement, graph-2026-09-w2, planned
    Reason: Labels are already correct for a graph-plan node; adding planned per the standard /spec handoff signal.
    Quality Loop: Won't auto-enable — scope verdict is SCOPE_OK, not SCOPE_WARNING.

    → gh issue edit 982 --add-label "planned"

  5. added
    planned
    on Sep 10, 2026
  6. admarble commented on Sep 10, 2026

    @admarble
    ContributorAuthor

    QA Verdict: AC_MET_BUT_NOT_A_PLUS

    AC coverage: 0/1 met

    Gaps:

    • The MCP sequant_run fullQa zod param — one of the two surfaces AC-3 names — has no gate test, so it can go inert without TypeScript, the build, or any test failing
    • The resume-capture guard's stated rationale describes an effect the code does not produce in the mainline quality-loop path
    • The canonical flag reference the README points readers to was not updated with --full-qa or run.fullQa
    • Dropping qa's handle capture silently changed what the loop phase resumes, an undisclosed second behavior change under AC-4's behavior-identical wording
    • The AC-1 test's exec-continuity assertion models a loop phase that returns no resume handle, diverging from production

    Suggestions:

    • Add an MCP-side live-surface tripwire (assert "fullQa" appears in runToolInputSchema, or derive the handler's param type from the schema via z.infer so TS binds them).
    • Reword the :1657 comment to state where the guard actually bites (loop skipped / no loop handle / post-qa phases) and note the loop-resume consequence.
    • Add the --full-qa row and run.fullQa line to docs/reference/run-command.md.
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

    enhancementgraph-2026-09-w2planned

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions