Skip to content

feat(cli): sequant ready <issue> — post-resolve A+ QA gate that drives an issue to merge-readiness #683

Closed

Description

@admarble

Problem

Empirical analysis of our own .entire conversation logs (2026-05-30) shows the QA pass that runs inside sequant run / /fullsolve systematically under-catches relative to the fresh standalone /qa the maintainer runs in a separate session afterward.

Across 27 captured fresh-session QA passes (24 of which ran after an in-orchestrator QA had already passed the same work):

  • 12/27 (44%) caught a real shipping bug or unmet AC — something that would have merged broken
  • 11/27 (41%) caught a substantive quality gap
  • 2/27 (7%) were clean

Representative catches the in-run QA missed: #421 (feature non-functional for its primary multi-issue use case, after a READY_FOR_MERGE verdict), #529 / #570 (no implementation existed — empty branch, zero commits — but the orchestrator reported success; exposed null-verdict-as-success bug #534), #503 (the new programmatic API was broken at launch), #467 (an AC test passed vacuously with zero assertions firing), #318 (merge would have deleted the --reflect feature from main).

Root cause — two structural gaps (not "fresh session magic")

  1. Orchestrated QA trusts orchestrator git state and skips pre-flight checks. skills/qa/SKILL.md:54-58 ("Trust git state — orchestrator verified branch status") and :254 skip the branch-freshness / process-state checks. That is exactly the class — no-implementation / divergent branch / uncommitted work — that caught refactor(run): split 3,459-line monolith into focused modules #318 / feat(qa): enforce 'Manual Test' ACs are executed or marked PENDING, never MET from code review #529 / bug(hooks): pre-tool.sh regexes for destructive/deployment/reset/workflow commands also match inside quoted gh body content #570.
  2. The fullsolve QA loop stops at "good enough." skills/fullsolve/SKILL.md:572-574 breaks the loop at AC_MET_BUT_NOT_A_PLUS ("Good enough, proceed with notes"). It never drives toward A+; the maintainer's manual fix all gaps does.

(A third factor — context de-anchoring from a genuinely fresh session — is real but secondary, and is obtained for free by running QA in a clean subagent context. A literal new OS session is not required, which is what makes this automatable.)

§6d Adversarial Re-Read already runs in both modes (skills/qa/SKILL.md:2077), so it is not the gap. The existing --qa-gate flag is unrelated — it is a chain-mode sync ("wait for QA before next issue", bin/cli.ts:260), not a human-review-before-merge gate.

Today the maintainer reproduces the fresh pass by hand: open a new session → qa <N> → "any gaps? fix all gaps. use sequential thinking" → re-qa → merge. This issue collapses that ritual into one command while preserving the human merge decision.

Proposed solution

A new standalone command, sequant ready <issue>, run after a resolve finishes. It reproduces the fresh-session A+ pass deterministically:

$ sequant ready 712
  → standalone-weight /qa   (full pre-flight: branch freshness, process-state, no git-trust skip)
  → §6d adversarial re-read (already mandatory in standalone /qa)
  → /loop                   (auto-fix gaps, scoped by gate policy)
  → re-/qa                  (policy `ac`: until ACs met · policy `a-plus`: until READY_FOR_MERGE
                             — both also bounded by maxIterations / budget / no-diff guard)
  → gap report + verdict    (unfixed gaps documented, not hidden)
  → STOP at human merge gate (never auto-merges)

Design decisions (confirmed with maintainer):

  • Delivery: dedicated sequant ready <issue> command (not a run flag), matching the existing two-session habit and keeping it testable in isolation. A future sequant run --ready-gate can reuse the same engine (out of scope here).
  • Gap handling is a configurable gate policy (see below). The loop's exit threshold is set by policy, not hardcoded. Default is ac (AC-bounded); a-plus (auto-loop everything) is opt-in. Regardless of policy, the signal-to-noise, budget, and stagnation guards below are mandatory acceptance criteria.

Gate policy (configurable rigor)

"A+" is the right bar for a solo maintainer dogfooding sequant, but the wrong default at scale. For a company engineer with a fixed agenda, auto-loop-everything risks: (a) scope creep — "fixing" things the issue's own Non-Goals deliberately excluded; (b) a subjective stop condition reviewers can't predict; (c) the noise/runaway the #608 study warned about. "ACs met" is, by contrast, an objective stop condition — the written acceptance-criteria checklist.

The boundary already exists as QA verdicts, so policy just selects the loop-exit threshold — minimal new logic:

Policy Loops until Quality / polish gaps Audience
ac (default) no AC_NOT_MET remains (ACs objectively met) documented in the gap report, NOT auto-fixed team engineer, fixed agenda, predictable diff
a-plus (opt-in) READY_FOR_MERGE auto-fixed in the loop solo maintainer / max-quality
  • ac mode still runs the full-weight QA + §6d adversarial re-read, so every gap is surfaced in the report (nothing hidden) — it just stops fixing at the AC boundary, turning remaining findings into a deliberate follow-up backlog instead of unrequested scope.
  • In ac mode, any finding that touches the issue's Non-Goals is explicitly report-only.
  • Config: ready.policy in .sequant/settings.json (default "ac"), overridable per-invocation with --policy ac|a-plus.
  • Termination in either policy also bounded by maxIterations, the token budget, and the LOOP_NO_DIFF stagnation guard.
  • Full-weight QA: the command must run /qa without the SEQUANT_ORCHESTRATOR git-trust skip path — i.e. it performs the pre-flight branch/process-state checks. (Mechanism: do not set SEQUANT_ORCHESTRATOR, or introduce an explicit SEQUANT_FULL_QA=1 that forces the standalone checks even under an orchestrator.)
  • Human gate: terminates in a waiting_for_human_merge state with a written report; it never calls merge.
  • Issue-centric: operates on an issue number (reuses existing worktree/state infra). --from-pr <N> (reverse PR→issue resolution) is a follow-up, not in scope.

Acceptance Criteria

  • AC-1 sequant ready <issue> is registered in bin/cli.ts and dispatches a pipeline of qa → loop → qa (repeating) against the issue's existing worktree. Verify: integration test asserts the phase sequence dispatched.
  • AC-2 The QA phases run in full standalone weight — the branch-freshness and process-state pre-flight checks execute (they are NOT skipped via the orchestrator git-trust path). Verify: unit test asserts SEQUANT_ORCHESTRATOR is unset (or SEQUANT_FULL_QA is set) in the env passed to the phase executor, and a fixture with a divergent/zero-commit branch is flagged rather than trusted.
  • AC-3 The loop's exit threshold is set by gate policy: ac (default) stops once no AC_NOT_MET remains and reports unfixed quality gaps; a-plus loops toward READY_FOR_MERGE. Both also terminate on maxIterations, token budget, or the LOOP_NO_DIFF stagnation guard. Verify: unit tests asserting ac stops at AC-met (and does NOT auto-fix a quality-only gap), a-plus loops past it, and each guard-based exit.
  • AC-3a Policy is read from ready.policy in .sequant/settings.json (default "ac") and overridable via --policy ac|a-plus. In ac mode, findings that touch the issue's Non-Goals are report-only. Verify: config-resolution unit test (flag overrides settings overrides default); test that a Non-Goal-touching gap is reported, not fixed, under ac.
  • AC-4 The command never merges. It ends in waiting_for_human_merge and emits a structured gap report (auto-fixed items + remaining/accepted items + final verdict). Verify: integration test asserts no merge invocation and the terminal state + report shape.
  • AC-5 Regression guard for the fix(orchestrator): treat null QA verdict and zero-diff exec as failure, not success #534 class: a zero-diff exec and/or a null QA verdict must NOT be reported as ready. Verify: replay the feat(qa): enforce 'Manual Test' ACs are executed or marked PENDING, never MET from code review #529/bug(hooks): pre-tool.sh regexes for destructive/deployment/reset/workflow commands also match inside quoted gh body content #570 scenario (empty branch) → command reports "not ready / no implementation", not READY_FOR_MERGE.
  • AC-6 Runaway protection: a configurable token/iteration budget caps the A+ loop; on exhaustion the command halts with a clear "needs human" message rather than looping. Verify: unit test with a forced non-converging fixture asserts a clean halt within budget.
  • AC-7 Backtest recall (see Testing Strategy, Layer 2) is documented in docs/investigations/ready-gate-backtest.md with measured recall against the 12 known would-ship defects and a measured false-positive/noise rate. Manual test — executed on the feature branch, results committed.
  • AC-8 Docs + CHANGELOG entry; command documented in README + marketplace README + docs/. Verify: docs check across all locations.

Testing strategy

Because the feature's output is LLM-judgment (non-deterministic), testing is layered — deterministic plumbing in CI, empirical quality offline.

Layer 1 — Deterministic wiring (vitest, CI-gated).
Command parsing/registration (AC-1); env-weight assertion that the QA runs full-weight (AC-2); the three loop-exit conditions (AC-3); never-merges + terminal state + report shape (AC-4); the #534 zero-diff/null-verdict regression (AC-5); budget/stagnation halt (AC-6). Fast, deterministic, blocks merge.

Layer 2 — Backtest against the 27-transcript ground-truth corpus (the centerpiece, offline).
We already have 27 captured fresh-session QA passes with known caught defects (12 real-bug: #421, #503, #467, #529, #570, #318, #465, #484, #528, #554, #573, #625). For each, check out the pre-fix commit the fresh QA reviewed, run sequant ready against it, and measure:

Layer 3 — Forward shadow dogfood (feature branch).
On the next ≥ 10 real issues, run BOTH the maintainer's normal manual fresh QA AND sequant ready in shadow (no auto-merge). Compare: agreement, automated-only catches, human-only catches the bot missed. Track via sequant stats --label --since cohort filters (#640). Promotion criteria for public release: automated chain catches ≥ 80% of what the manual fresh QA catches, with acceptable noise, across the cohort. If it underperforms, keep it as an opt-in experimental flag rather than a default.

Layer 4 — Safety/guardrails (vitest).
Never auto-merges; stagnation halts cleanly (LOOP_NO_DIFF); budget cap holds; #534-class inputs never report ready. (Overlaps AC-4/5/6 — called out separately because these are the "don't ship a footgun" tests.)

Rollout plan

  1. Feature branch feature/<this-issue>-ready-gate. Implement Layer-1 wiring; ship behind an experimental marker.
  2. Layer-2 backtest on the 27-corpus; tune loop-exit + verdict thresholds + noise; commit docs/investigations/ready-gate-backtest.md (AC-7).
  3. Layer-3 shadow dogfood on ≥ 10 live issues; record cohort metrics.
  4. Promotion gate: meet the Layer-3 criteria → graduate to a documented command. Otherwise refine, or keep experimental/opt-in.
  5. Release: docs + CHANGELOG; minor version bump (new feature, per versioning policy).

Risks / open questions

Non-goals

  • --from-pr <N> / reverse PR→issue resolution (follow-up).
  • sequant run --ready-gate flag integration (follow-up; reuse this engine).
  • Auto-merge of any kind — the human merge gate is intentional and permanent.
  • Changing the in-orchestrator QA's lite-mode behavior (that path stays fast; ready is the deliberate full-weight pass).

Motivation data and mechanism analysis: .entire log study, 2026-05-30. See also #448 (first-pass QA rate), #582 (adversarial re-read), #608/#609 (gap-check signal-to-noise), #534 (null-verdict-as-success).

Activity

  1. admarble commented on May 31, 2026

    @admarble
    ContributorAuthor

    Complexity: Complex (9 ACs, ~6 directories)

    AC Quality Check

    ACs are well-formed, measurable, and each carries an explicit Verify: clause — strong. Two flags:

    • ⚠️ AC format won't parse. The list uses - [ ] **AC-1** ... (no colon). Sequant's own AC_PATTERNS (src/lib/ac-parser.ts:45-53) all require a colon (**AC-1:**). Result: extractAcceptanceCriteria returns 0 items, so /testgen stub generation and .sequant/state.json AC tracking will be empty for this issue. Fix: add a colon after each ID (**AC-1:**). Low effort, prevents downstream tooling from silently no-op'ing.
    • ⚠️ AC-7 is "Manual test, executed on the branch" — inherently non-CI-gated and dependent on the 27-transcript corpus. That's acknowledged in the issue, but it means AC-7 (and the Layer-3 dogfood) gate promotion, not merge. Recommend treating them as committed-deliverable + follow-up rather than merge blockers (see Scope).

    Scope Assessment

    Non-Goals: ✅ Present and specific (--from-pr, run --ready-gate, auto-merge, in-orchestrator lite-QA behavior).

    Metric Value Status
    Feature count ~3 (command + policy engine + full-weight-QA mechanism) ⚠️
    AC items 9 ❌
    Directory spread ~6 (bin/, src/commands/, src/lib/workflow/, src/lib/settings.ts, skills/qa ×3, docs/ ×3) ❌

    Verdict: ❌ SCOPE_SPLIT_RECOMMENDED (by metrics) — but the work is cohesive (one command + its config), and the issue's own rollout plan already stages it. Recommendation: land AC-1–6 + AC-8 as the implementation PR; AC-7 backtest is a committed doc produced on the branch (rollout step 2) but is fine to track as its own deliverable; Layer-3 shadow dogfood is explicitly a post-merge promotion gate, not part of this PR. This keeps the mergeable diff predictable and matches the phased rollout.


    Acceptance Criteria

    AC-1: sequant ready <issue> registered + dispatches qa → loop → qa

    Verification: Integration Test — assert the phase sequence dispatched against the issue's worktree.
    Scenario: Given a resolved worktree for #N → When sequant ready N runs → Then phases dispatch in order qa, loop, qa[, loop, qa…].
    Assumptions: Reuses executePhaseWithRetry (phase-executor.ts:765) + phaseRegistry qa/loop defs; worktree resolved via worktree-discovery.ts.

    AC-2: QA runs full standalone weight (pre-flight checks NOT skipped)

    Verification: Unit Test — assert env passed to phase executor sets SEQUANT_FULL_QA (or omits SEQUANT_ORCHESTRATOR); fixture with divergent/zero-commit branch is flagged, not trusted.
    Scenario: Given ready invokes QA → When env is built → Then standalone branch-freshness + process-state checks execute despite orchestration.
    Assumptions: ⚠️ phase-executor.ts:595 sets SEQUANT_ORCHESTRATOR unconditionally. So "just don't set it" is not available when reusing the executor — SEQUANT_FULL_QA=1 override is the correct mechanism (see Open Questions Q1).

    AC-3: Loop exit threshold set by gate policy

    Verification: Unit Tests — ac stops at AC-met and does NOT auto-fix a quality-only gap; a-plus loops past it; each guard exit (maxIterations, budget, LOOP_NO_DIFF).
    Scenario: Given QA returns AC_MET_BUT_NOT_A_PLUS → When policy=ac → Then loop stops (gap reported); When policy=a-plus → Then loop continues until READY_FOR_MERGE or a guard fires.
    Assumptions: Verdicts already parsed in phase-executor.ts:126-140; LOOP_NO_DIFF infra exists (qa-stagnation.ts). ac-mode "don't fix quality gaps" enforced by scoping the loop to AC_NOT_MET findings via existing SEQUANT_FAILED_ACS env (phase-executor.ts:607).

    AC-3a: Policy resolution + Non-Goal report-only

    Verification: Unit Test — flag > ready.policy setting > default "ac"; a Non-Goal-touching gap is reported, not fixed, under ac.
    Scenario: Given .sequant/settings.json ready.policy="a-plus" and --policy ac → Then ac wins. Given an ac run with a finding touching a Non-Goals item → Then it is report-only.
    Assumptions: New ReadySettings/SequantSettings.ready in src/lib/settings.ts (schema + defaults + key-section maps + docs table). Non-Goals parsed from issue body.

    AC-4: Never merges; ends waiting_for_human_merge + structured report

    Verification: Integration Test — assert no merge invocation; assert terminal state + report shape (auto-fixed + remaining/accepted + verdict).
    Scenario: Given any ready run → When it completes → Then it never calls merge and ends in waiting_for_human_merge with a structured gap report.
    Assumptions: ⚠️ IssueStatusSchema (state-schema.ts:51-60) does not include waiting_for_human_merge — requires adding the enum value (or documented reuse of ready_for_merge). See Open Questions Q3.

    AC-5: #534-class regression guard

    Verification: Integration Test — replay #529/#570 (empty branch, zero commits) → command reports "not ready / no implementation", never READY_FOR_MERGE.
    Scenario: Given a zero-diff exec or null/unparseable QA verdict → Then ready reports not-ready, not success.
    Assumptions: Reuse existing null-verdict guard (phase-executor.ts:406) + zero-diff guard (:431). ready must propagate these as terminal "not ready", not swallow them.

    AC-6: Runaway protection (budget/iteration cap → clean halt)

    Verification: Unit Test — forced non-converging fixture asserts clean halt within budget with a "needs human" message.
    Scenario: Given a fixture that never reaches the policy threshold → Then the loop halts at maxIterations/budget with a clear message, not an infinite loop.
    Assumptions: Reuse settings.run.maxIterations + token budget; surface via the gap report.

    AC-7: Backtest doc with measured recall + noise rate

    Verification: Manual Test — docs/investigations/ready-gate-backtest.md committed with per-policy recall vs the 12 known would-ship defects + measured FP/noise. Mirrors #608/#609 format.
    Assumptions: Reuses .entire extraction harness (/tmp/qa_sessions condenser). Not CI-gated.

    AC-8: Docs + CHANGELOG (all locations)

    Verification: Docs check across main README, marketplace README, docs/, and CHANGELOG. Verify content coverage (command name, --policy, ready.policy, human-gate behavior), not just file existence.


    Implementation Plan

    Phase 1: Config + state plumbing

    1. src/lib/settings.ts — add ReadySettings { policy: "ac" | "a-plus" }, SequantSettings.ready, Zod schema (default("ac")), defaults block, key→section maps (~:443/:465), and the settings-doc table (~:932). (AC-3a)
    2. src/lib/workflow/state-schema.ts — add waiting_for_human_merge to IssueStatusSchema (:51). (AC-4)

    Phase 2: Full-weight QA mechanism (multi-touchpoint — see note)

    1. src/lib/workflow/phase-executor.ts — thread a fullQa config flag → env.SEQUANT_FULL_QA = "1" near the SEQUANT_ORCHESTRATOR block (:595). (AC-2)
    2. skills/qa/SKILL.md (× 3 mirror dirs: .claude/skills/qa, templates/skills/qa, skills/qa) — re-enable standalone pre-flight when SEQUANT_FULL_QA is set even under an orchestrator. Edit the behavior table (:52-62), Stale-Branch skip (:254), pre-flight skip (:233), and :2426. (AC-2)

    Phase 3: The ready command

    1. src/commands/ready.ts (new, mirror merge.ts shape) — resolve worktree + policy (flag > setting > "ac"); drive the qa → loop → qa loop via executePhaseWithRetry with fullQa; in ac mode pass only AC_NOT_MET findings to loop (via SEQUANT_FAILED_ACS) and classify Non-Goal-touching findings report-only; enforce maxIterations/budget/LOOP_NO_DIFF; treat null-verdict/zero-diff as not-ready (AC-5); never call merge; end waiting_for_human_merge; emit structured gap report (auto-fixed + remaining/accepted + verdict). (AC-1,3,3a,4,5,6)
    2. bin/cli.ts — register program.command("ready").argument("<issue>") with --policy <ac|a-plus>, --max-iterations <n>, --budget <tokens>, --json, -v; import readyCommand. (AC-1) — CLI-wiring gap reminder: every option must be registered here, not just in the command's options interface.

    Phase 4: Verification artifacts + docs

    1. Backtest: check out pre-fix commits for the 12 defects, run ready, record per-policy recall + noise → docs/investigations/ready-gate-backtest.md. (AC-7)
    2. Docs + CHANGELOG across all locations. (AC-8)

    Note — multi-touchpoint rule (AC-2): the behavior-rule detector did not auto-trigger, but the "full-weight QA" rule is genuinely duplicated across the skills/qa/SKILL.md prompt (×3 dirs) and the phase-executor.ts env builder. Edit both sides or one goes stale (cf. #533). Sync all 3 skill dirs (feedback_read_each_mirrored_file).


    Design Review

    1. Where does this logic belong? A standalone src/commands/ready.ts orchestrating existing executePhaseWithRetry + phaseRegistry — not a fork of run-orchestrator.ts. Policy/state types belong in settings.ts/state-schema.ts. The issue's "future run --ready-gate reuses this engine" implies the loop driver should be a small reusable function, not buried in the command action.
    2. What's the simplest correct approach? Reuse: phase dispatch (executePhaseWithRetry), verdict parsing + fix(orchestrator): treat null QA verdict and zero-diff exec as failure, not success #534 guards (phase-executor.ts:126-140,406,431), stagnation (qa-stagnation.ts), loop scoping (SEQUANT_FAILED_ACS). Net new logic is small: the policy-driven exit predicate, the SEQUANT_FULL_QA flag, the waiting_for_human_merge status, and the report formatter. Reject building a new loop engine.
    3. What existing pattern does this follow? merge.ts (standalone post-run command with exit codes + --json) for shape; run-orchestrator for the phase-loop idiom; QA verdict gating already centralized in phase-executor.
    4. What would a senior reviewer challenge? (a) "Why a new SEQUANT_FULL_QA instead of just not setting SEQUANT_ORCHESTRATOR?" → because the executor sets it unconditionally and other orchestrator behaviors (worktree reuse, state-hook) are still wanted; an explicit override is narrower and testable. (b) "Does ac mode actually refrain from fixing quality gaps, or just hope the loop does?" → must be enforced by feeding the loop only AC_NOT_MET findings, asserted by AC-3's negative test. (c) "Is waiting_for_human_merge observable?" → must be a real IssueStatusSchema value, not just prose.

    Feature Quality Planning

    All standard checks pass. Notable items:

    • Determinism boundary: Layer-1 tests must mock the QA/loop subagent output (verdict strings) so the wiring is deterministic; never assert on real LLM judgment in CI.
    • Backtest reproducibility: AC-7 depends on the .entire corpus + pre-fix commit checkouts — document the exact harness invocation so the doc is reproducible, not a one-off.
    • ac-mode negative assertion (does NOT fix a quality-only gap) is the highest-value test — it's the entire point of the default policy and the easiest thing to get subtly wrong.

    Derived ACs

    Source Derived AC Priority
    Observability The waiting_for_human_merge terminal state is persisted to state.json and visible via sequant status Medium
    Tooling consistency Reformat issue ACs to **AC-N:** so /testgen + state tracking parse them High (pre-exec)

    Open Questions

    1. Full-weight mechanism (AC-2). Recommendation: explicit SEQUANT_FULL_QA=1 override (the issue's "cleaner if ready ever runs inside a larger flow" rationale). Impact if wrong: choosing "unset SEQUANT_ORCHESTRATOR" also disables wanted orchestrator behaviors (worktree reuse, state-hook suppression) and isn't even reachable without refactoring phase-executor.ts:595.
    2. ac-mode loop scoping. Recommendation: reuse the existing SEQUANT_FAILED_ACS env to feed the loop only AC_NOT_MET findings, so quality gaps are surfaced-but-not-fixed. Impact if wrong: ac mode silently behaves like a-plus, defeating the default's scope-creep protection.
    3. waiting_for_human_merge status. Recommendation: add it to IssueStatusSchema. Impact if wrong: AC-4's terminal-state assertion can't be satisfied against a real enum; reusing ready_for_merge would conflate it with the existing PR-ready meaning.

    Recommended Workflow

    Phases: spec → testgen → exec → qa
    Quality Loop: enabled
    Reasoning: AC-1–6 are Unit/Integration verified (testgen stubs the deterministic Layer-1/Layer-4 wiring before implementation). No UI → no test phase. Not auth/payments/file-ops → no security-review. 9 ACs across orchestration internals → quality loop on. AC-7/Layer-3 are post-implementation manual gates, not phases.


    Label Review

    Current: (none)
    Recommended: enhancement, cli, complex
    Reason: New user-facing CLI command (enhancement+cli); 9 ACs + cross-cutting orchestration touchpoints (complex).
    Quality Loop: Will auto-enable (complex label + SCOPE red).

    → gh issue edit 683 --add-label enhancement,cli,complex


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

    📋 Plan — sequant ready <issue>

    Complexity: Complex (9 ACs, ~6 directories) · Workflow: spec → testgen → exec → qa (quality loop on)

    Acceptance Criteria + verification

    Key implementation notes

    • Reuse executePhaseWithRetry + phaseRegistry qa/loop; do not fork run-orchestrator.
    • AC-2 mechanism: phase-executor.ts:595 sets SEQUANT_ORCHESTRATOR unconditionally → use an explicit SEQUANT_FULL_QA=1 override, threaded into skills/qa/SKILL.md across all 3 skill dirs (behavior table + stale-branch/pre-flight skips).
    • AC-4: waiting_for_human_merge must be added to IssueStatusSchema (state-schema.ts:51).
    • AC-3 ac-mode: enforce "report but don't fix quality gaps" by feeding the loop only AC_NOT_MET findings via existing SEQUANT_FAILED_ACS.
    • AC-5: reuse existing null-verdict (:406) + zero-diff (:431) guards.

    Pre-exec ask

    ⚠️ Reformat ACs to **AC-1:** (add colon) — current **AC-1** format isn't matched by AC_PATTERNS, so /testgen + state tracking parse 0 ACs.

    Open questions (recommendations)

    1. Full-weight via explicit SEQUANT_FULL_QA=1 (not unsetting SEQUANT_ORCHESTRATOR).
    2. Scope ac-mode fixes via SEQUANT_FAILED_ACS.
    3. Add waiting_for_human_merge to the status enum.

    Scope

    Land AC-1–6 + AC-8 as the implementation PR; AC-7 backtest is a committed deliverable (rollout step 2); Layer-3 shadow dogfood is a post-merge promotion gate.

  2. added
    planned
    on May 31, 2026
  3. admarble commented on May 31, 2026

    @admarble
    ContributorAuthor

    Plan Complete — sequant ready <issue> (post-resolve A+ QA gate)

    Complexity: Complex (9 ACs, ~6 directories)

    Architecture (grounded in code audit)

    A new ready command drives an existing issue worktree through a qa → loop → qa … pipeline at full standalone weight, never merges, and ends in waiting_for_human_merge with a structured gap report.

    New file Role
    src/commands/ready.ts CLI handler; resolves issue → worktree, reads policy, prints/JSON report
    src/lib/workflow/ready-orchestrator.ts The loop engine (runReadyGate), DI-injectable phase runner for tests
    src/lib/workflow/ready-report.ts Gap-report rendering (markdown + JSON: auto-fixed / remaining / verdict)
    Modified file Change
    bin/cli.ts Register ready <issue> + --policy ac|a-plus, --max-iterations, --budget, --json
    src/lib/settings.ts Add ready.policy (default "ac") + ready.maxTokens to interface/schema/KNOWN_KEYS/defaults
    src/lib/workflow/types.ts ExecutionConfig.fullQa?: boolean
    src/lib/workflow/phase-executor.ts When config.fullQa, set env.SEQUANT_FULL_QA="1"
    src/lib/workflow/state-schema.ts Add waiting_for_human_merge to IssueStatusSchema (+ audit consumers)
    skills/qa/SKILL.md ×3 (skills/, .claude/skills/, templates/skills/) Honor SEQUANT_FULL_QA=1 → force standalone pre-flight even under orchestrator
    README.md · docs/reference/ready-command.md · CHANGELOG.md · docs/investigations/ready-gate-backtest.md Docs (AC-7, AC-8)

    AC coverage map

    • AC-1 Register + dispatch qa→loop→qa. Test: integration asserts phase sequence.
    • AC-2 Full-weight QA via SEQUANT_FULL_QA=1 (chosen over unsetting SEQUANT_ORCHESTRATOR — cleaner if ready ever nests in a larger flow, per issue Risks). Test: env assertion + divergent/zero-commit branch flagged.
    • AC-3 Policy sets loop-exit threshold: ac stops at "no AC_NOT_MET"; a-plus loops to READY_FOR_MERGE. Both bounded by maxIterations / token budget / LOOP_NO_DIFF (reuse detectStagnation/compareLoopProgress). Tests: each exit path.
    • AC-3a Policy resolution: flag > ready.policy settings > default ac. ac mode marks Non-Goal-touching findings report-only. Tests: config resolution + Non-Goal report-only.
    • AC-4 Never merges; ends waiting_for_human_merge; structured report. Test: no merge invocation + terminal state + report shape.
    • AC-5 fix(orchestrator): treat null QA verdict and zero-diff exec as failure, not success #534 guard: zero-diff exec / null verdict ⇒ "not ready / no implementation" (reuse hasExecChanges; add zero-commit branch check). Test: replay feat(qa): enforce 'Manual Test' ACs are executed or marked PENDING, never MET from code review #529/bug(hooks): pre-tool.sh regexes for destructive/deployment/reset/workflow commands also match inside quoted gh body content #570 empty branch.
    • AC-6 Runaway cap (iteration + token budget) ⇒ clean "needs human" halt. Test: non-converging fixture halts within budget.
    • AC-7 Backtest doc docs/investigations/ready-gate-backtest.md. ⚠️ The empirical recall numbers require an offline harness run over 27 pre-fix commits (real LLM QA) — not reproducible in CI/this session. I will commit the methodology + corpus table + harness instructions and flag the measured-numbers row as pending the offline run (matches the issue's "Layer 2 = offline, committed report" framing).
    • AC-8 Docs + CHANGELOG across README + docs/ (marketplace README is generated from README.md).

    Design Review

    1. Where it belongs: a thin src/commands/ready.ts over a reusable ready-orchestrator.ts in src/lib/workflow/ — mirrors run.ts→run-orchestrator.ts. Phase execution reuses executePhaseWithRetry (DI-injected for tests).
    2. Simplest correct approach: drive phases manually (["qa"], then ["loop"], then ["qa"] …) rather than fork RunOrchestrator; gate the loop on QA verdict + policy. Reuse parseQaVerdict, parseQaSummary, detectStagnation, hasExecChanges.
    3. Existing pattern: command→orchestrator→report, DI phase runner (executePhaseFn param already exists), Zod settings schema.
    4. Senior-reviewer challenge: "Why a new terminal enum value?" — AC-4 names it literally; I'll add waiting_for_human_merge and audit every IssueStatus switch/consumer (reconcile, state-cleanup, status) to keep exhaustiveness intact.

    Open Questions / Scope Notes

    1. AC-7 empirical backtest is an offline/manual artifact (per the issue's own Layer-2 framing). Deliverable here = the doc scaffold + methodology; the measured recall/noise numbers are produced by running the committed harness offline. Flagged transparently rather than fabricated.
    2. Layer-3 shadow dogfood (≥10 live issues) and the promotion gate are explicitly post-merge rollout steps — out of scope for this PR.
    3. Token budget: no global token aggregation exists today; primary cap is iteration-based (maxIterations), with an optional ready.maxTokens / --budget knob that halts cleanly. AC-6's deterministic test uses the iteration cap with a non-converging fixture.

    Recommended Workflow

    Phases: exec → qa · Quality Loop: enabled (Complex, new public API)
    Reasoning: CLI/backend feature, no browser test. Deterministic vitest for AC-1–6; AC-7 manual doc.

  4. admarble commented on May 31, 2026

    @admarble
    ContributorAuthor

    QA Review for Issue #683

    Full-weight QA on feature/683-…-ready-gate (HEAD 86f4444f6). Implementation is complete and well-tested; one AC is a manual offline backtest pending execution.

    AC Coverage

    AC Description Status Notes
    AC-1 Register ready + dispatch qa→loop→qa MET bin/cli.ts; engine test asserts dispatched sequence [qa, loop, qa]
    AC-2 Full-weight QA (no git-trust skip) MET config.fullQa→SEQUANT_FULL_QA=1 (phase-executor); qa/SKILL.md ×3 honor it; zero-commit branch → NO_IMPLEMENTATION
    AC-3 Policy loop-exit thresholds + guards MET ac/a-plus + MAX_ITERATIONS/TOKEN_BUDGET/LOOP_NO_DIFF all unit-tested
    AC-3a Policy resolution + Non-Goal report-only MET resolvePolicy precedence (flag>settings>default); Non-Goal gap excluded from fix loop, tagged report-only
    AC-4 Never merges; terminal state + report MET No merge invocation (grep-verified); waiting_for_human_merge; structured md/JSON report
    AC-5 #534 guard (zero-diff / null verdict) MET null verdict & zero-diff → NO_IMPLEMENTATION, exit 2
    AC-6 Runaway protection (iteration/token budget) MET clean halt on each cap
    AC-7 Backtest doc w/ measured recall + noise PENDING Methodology + 27-case corpus + harness + scoring rubric committed (docs/investigations/ready-gate-backtest.md); the measured numbers require an offline live-LLM run over 27 pre-fix commits — a Manual Test AC, deferred to rollout-plan step 2 (not executable in an autonomous session)
    AC-8 Docs + CHANGELOG (all locations) MET README (What's new + Automation + headless), docs/reference/ready-command.md, CHANGELOG [Unreleased]

    Coverage: 8/9 MET · AC-7 PENDING (offline manual backtest)

    Quality Metrics

    Metric Value
    Files changed 20 (+1581 / −7)
    New tests 29 (ready-gate ×24, ready ×5) — all green
    Build (tsc) ✅ pass
    Lint (eslint --max-warnings 0) ✅ pass
    Skill 3-dir sync ✅ byte-identical
    CLI smoke ready --help ✓; no-worktree → exit 2 ✓

    Code Review

    Strengths: Clean command→engine split (ready.ts over ready-gate.ts); DI-injectable phase runner makes the loop fully deterministic to test; reuses existing infra (compareLoopProgress, hasExecChanges, token-utils, parseQaVerdict); SEQUANT_FULL_QA cleanly scoped to the qa phase only; new waiting_for_human_merge status wired through every exhaustive Record<IssueStatus> consumer (dashboard, status, reconcile) — tsc confirms exhaustiveness.

    Issues: None blocking.

    Minor / follow-up:

    • AC-2's divergent (behind-main) branch flagging is delegated to the QA skill's stale-branch pre-flight prose (now reached via SEQUANT_FULL_QA), not an independent runtime unit test. The zero-commit half is unit-tested via the NO_IMPLEMENTATION guard. By design — pre-flight is the skill's job — but worth noting.
    • Token budget relies on token-utils per-phase files being populated during a real run; the cap logic is injection-tested, the real-path population is not exercised here.

    Risk Assessment

    • Likely failure mode: A real run depends on the QA skill actually performing the standalone pre-flight when SEQUANT_FULL_QA=1 — that's prose-driven (LLM), so a skill regression could silently skip it. The deterministic fix(orchestrator): treat null QA verdict and zero-diff exec as failure, not success #534 guard in the engine is the backstop for the worst case (empty branch).
    • Not tested: End-to-end live phase execution (by design — engine is DI-tested); AC-7 empirical recall/noise (offline).
    • Sibling sites considered: none — no cross-file siblings; the IssueStatus enum addition was swept across all three Record<IssueStatus> maps.
    • Sibling-line audit: none — single new engine.

    Adversarial Re-Read

    Findings: No blocking gaps. Traced: (1) no merge/gh pr merge/--squash anywhere in ready.ts/ready-gate.ts — the human gate is structural; (2) the #534 guard fires before any positive verdict can be reported on an empty branch; (3) remaining reflects the final QA's gaps — an unfixed Non-Goal gap correctly re-surfaces as report-only (test fixture corrected to match real re-QA behavior); (4) Non-Goals from the issue body parsed and honored in ac mode; no scope creep. One honest gap surfaced and disclosed, not hidden: AC-7's measured numbers are not produced (offline live-LLM backtest).
    Status: Gaps Found (AC-7 pending — non-code, offline)

    Verdict: NEEDS_VERIFICATION

    All 8 code/doc ACs are MET with green build, lint, and 29 new deterministic tests. AC-7 is a manual offline backtest (live-LLM recall/noise over 27 pre-fix commits) — its scaffold (methodology, corpus, harness, scoring rubric) is committed, but the measured numbers must be produced on the feature branch per the issue's own rollout-plan step 2. This is external/manual verification, not a code gap, so the work is mergeable-pending-backtest rather than blocked. Recommend creating the PR and running the offline backtest before public promotion (the command can ship behind its experimental marker meanwhile).

    Documentation

    • README updated (What's new + Automation table + headless examples)
    • docs/ updated (reference + investigations)
    • CHANGELOG [Unreleased] entry added

    Next Steps

    1. Create PR (ACs met; AC-7 backtest tracked as the pending verification).
    2. Run the offline backtest harness (docs/investigations/ready-gate-backtest.md) on the feature branch; commit measured recall/noise → flips AC-7 to MET.
    3. Promote per rollout plan once recall ≥70% with acceptable noise.
  5. admarble commented on May 31, 2026

    @admarble
    ContributorAuthor

    /fullsolve Complete

    Issue: #683 · PR: #686 · Status: NEEDS_VERIFICATION (mergeable; one offline backtest pending)

    Summary

    sequant ready <issue> implemented end-to-end: full-weight qa → loop → qa gate, configurable ac/a-plus policy, #534 zero-diff/null-verdict guard, iteration + token-budget + LOOP_NO_DIFF caps, new waiting_for_human_merge terminal state, structured gap report — never merges.

    Quality

    • AC: 8/9 MET · AC-7 PENDING (manual offline live-LLM backtest — scaffold committed, numbers per rollout step 2)
    • Tests: 29 new deterministic cases, all green
    • CI: ✅ 7/7 checks SUCCESS (build 22.x, typecheck, validate-skills, validate-plugin, Plugin Structure, Hooks, Setup)
    • Build + lint: ✅ clean · Skill 3-dir sync: ✅ byte-identical
    • Mergeable: ✅

    Iterations

    • Exec: 1 (built on existing worktree WIP — added tests + docs + lint fix)
    • QA: 1 → NEEDS_VERIFICATION

    Next step (human)

    Review PR #686 and merge when satisfied (the human merge gate is intentional — fitting for this feature). Run the offline backtest (docs/investigations/ready-gate-backtest.md) on the branch to flip AC-7 → MET before public promotion.

  6. added 4 commits that reference this issue on Jun 1, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    planned

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions