Skip to content

feat(run): --ready-gate — run the post-QA ready gate inside sequant run (automates the any-gaps/fix-gaps second look, stops at human merge) #817

Description

@admarble

Context

sequant ready (#683, promoted in #689) reproduces the maintainer's manual fresh-session A+ pass: a policy-bounded qa → loop → qa engine that stops at a human merge gate. Its header comment explicitly designs the next step: "This module is the reusable engine — a future sequant run --ready-gate (out of scope for #683) can reuse runReadyGate directly" (src/lib/workflow/ready-gate.ts:20-22).

Session-log analysis (2026-07-26, 43 driver sessions / 20 issues over Jun 20–Jul 26) quantifies the gap this closes: after essentially every /qa, the maintainer manually types the same triple — a gap probe ("any gaps?"), a fix command ("fix all gaps"), then "merge". 34 of 249 typed messages are literally these strings, and the probe reliably surfaces real defects the first /qa pass accepted (consistent with the recorded 44%-of-second-looks defect rate). The engine that automates exactly this loop already exists; it just isn't reachable from sequant run.

A second dead end this fixes: on the run path, an AC_MET_BUT_NOT_A_PLUS verdict breaks to PR (#749, correctly) and nothing re-drives it — ready --policy a-plus is the intended escalation, but invoking it is manual and requires knowing it exists.

Proposal

An opt-in --ready-gate flag on sequant run that invokes the existing runReadyGate engine after the standard phases succeed, driving the issue to the configured policy threshold (ac default / a-plus) before handing back to the human. Exact sequencing relative to PR creation/finalization is /spec's call; the requirement is only that the run terminates with the PR open, the gate's gap report produced, and the issue in waiting_for_merge-style state — never merged.

Design constraints (strategic, from past failures):

  • No inert flag. --qa-gate shipped unwired and had to be deprecated (chore(run): --qa-gate is an inert no-op flag — remove or make it actually gate #795). The flag must be traced end-to-end (bin/cli.ts .option()RunOptionsExecutionConfig → batch-executor) with a test that fails if any link is dropped.
  • No new policy surface. Reuse ready's existing policy setting and bounds (maxIterations, token budget, LOOP_NO_DIFF stagnation guard, Non-Goals exclusion). Zero new configuration concepts for end users.
  • Default off, byte-identical behavior without the flag. Existing users' runs must not get longer or more expensive without opting in.

Acceptance Criteria

  • sequant run -Q <issue> --ready-gate invokes the existing runReadyGate engine after the standard phases succeed, and the run terminates with the PR open, the gate report produced, and the persisted status matching sequant ready's terminal semantics — it never merges.
  • With --ready-gate, an AC_MET_BUT_NOT_A_PLUS outcome is escalated through the gate per the configured policy instead of dead-ending at PR; without the flag, fix(run): AC_MET_BUT_NOT_A_PLUS QA verdict misrouted into quality loop → fails with no PR (should break to PR) #749 behavior is unchanged.
  • The flag is wired end-to-end (bin/cli.ts option → RunOptions → ExecutionConfig → executor) and a test fails if the flag stops reaching the engine (the chore(run): --qa-gate is an inert no-op flag — remove or make it actually gate #795 inert-flag class).
  • Gate policy, iteration cap, token budget, stagnation guard, and Non-Goals handling all come from the existing ready machinery; no new flags or settings beyond --ready-gate itself.
  • Without the flag, run behavior is unchanged (existing run-path tests still pass unmodified).
  • The run summary and PR body surface the gate outcome (threshold reached vs guard halt) the same way sequant ready reports it.
  • Documentation covers the flag in the main README, marketplace README, and docs/.

Out of scope

Auto-merge or adding merger to default phases (human merge gate is deliberate policy); MCP exposure of the gate; changing -Q semantics; batch/chain interaction beyond "gate runs per-issue after that issue's phases" (if chain interaction is non-trivial, note it and defer).

References

Metadata

Metadata

Assignees

No one assigned

    Labels

    cliCLI commands and interfaceenhancementNew feature or requestplannedImplementation plan approvedready-for-reviewReady for code review

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions