Skip to content

fix(run): AC_MET_BUT_NOT_A_PLUS QA verdict misrouted into quality loop → fails with no PR (should break to PR) #749

Closed

Description

@admarble

Summary

A QA verdict of AC_MET_BUT_NOT_A_PLUS is treated as a phase failure in the sequant run path. With -Q (quality loop) this feeds the loop, fails repeatedly, and exits with status=failure and no PR — even though acceptance criteria are met. Documented/expected behavior is to break out and proceed to PR (do NOT run /loop on it).

Repro / evidence

sequant run 125 126 --chain --qa-gate -Q --testgen

#126 phase sequence from the run log:

spec(success) → testgen(success) → exec(success) → test(success)
→ qa(FAILURE, verdict=AC_MET_BUT_NOT_A_PLUS)
→ testgen(FAILURE 38s) → testgen(FAILURE 5s)
→ status=failure, no PR

By contrast #125's QA returned NEEDS_VERIFICATION and did ship PR #127.

Root cause (single load-bearing line)

src/lib/workflow/phase-executor.ts:396-412, mapAgentSuccessToPhaseResult():

if (verdict && verdict !== "READY_FOR_MERGE" && verdict !== "NEEDS_VERIFICATION") {
  return { phase, success: false, error: `QA verdict: ${verdict}`, ... };
}

The success allowlist is only {READY_FOR_MERGE, NEEDS_VERIFICATION}. AC_MET_BUT_NOT_A_PLUS falls through to success: false. That asymmetry is exactly why #125 (NEEDS_VERIFICATION) shipped while #126 (AC_MET_BUT_NOT_A_PLUS) failed.

Cascade (downstream routers are correct given the wrong input)

  1. batch-executor.ts:1010-1090: non-success qa sets phasesFailed=true; with -Q and iteration < maxIterations, spawns /loop and restarts the pipeline.
  2. Each iteration re-runs phases from index 0. Because --testgen does phases.unshift("testgen") (batch-executor.ts:759), each retry starts with testgen — these are the two trailing testgen failures (loop iterations 2 and 3), not qa retries.
  3. batch-executor.ts:1095-1115: success only true if an iteration finishes with zero failures; it never does → state in_progress, no checkpoint, no rebase, no PR (shouldCreatePR, line 1160 false).
  4. run-orchestrator.ts:1002-1009: with --qa-gate --chain, the qa-non-success also breaks the chain.

Correct logic already exists

src/lib/workflow/ready-gate.ts:155-162 (the ac policy) already treats AC_MET_BUT_NOT_A_PLUS as a stopping/ready state. But that gate is only wired into sequant ready (#683), not sequant run. The two engines disagree.

This also matches the project's documented policy: AC_MET_BUT_NOT_A_PLUS → break to PR; /loop is for AC_NOT_MET only.

Bug is locked by a test

src/lib/workflow/phase-executor.test.ts:1557 ("fails on AC_MET_BUT_NOT_A_PLUS verdict (existing behavior preserved)") asserts success === false. Any fix must update this. src/commands/run.test.ts:1282-1292 also asserts the buggy behavior.

Fix

  • Add AC_MET_BUT_NOT_A_PLUS to the success allowlist at phase-executor.ts:396 (keep verdict on the result so the PR/log surfaces the "not A+" note). Only AC_NOT_MET and null/unparseable (fix(orchestrator): treat null QA verdict and zero-diff exec as failure, not success #534) should remain hard failures.
  • Optionally gate on policy (ac vs a-plus) mirroring ready-gate so an explicit "push to A+" mode can still loop; the documented default is break-to-PR.
  • Flip phase-executor.test.ts:1557 and add a positive assertion that the run path proceeds to PR on AC_MET_BUT_NOT_A_PLUS.

Acceptance criteria

  • sequant run with QA verdict AC_MET_BUT_NOT_A_PLUS breaks out and proceeds to PR instead of entering the quality loop / failing.
  • --qa-gate --chain is not broken by an AC_MET_BUT_NOT_A_PLUS predecessor verdict.
  • AC_NOT_MET and null/unparseable verdicts still hard-fail.
  • Tests updated: phase-executor.test.ts:1557 flipped + positive break-to-PR assertion; run.test.ts:1282-1292 reconciled.

Related

Refines #218 and #534 (the deliberate-failure decisions being revised) and mirrors #683 / ready-gate.ts (which already implements the correct "stop at AC-met" policy for sequant ready).

Activity

  1. added
    bug
    qa
    multi-agent
    on Jun 26, 2026
  2. admarble commented on Jun 28, 2026

    @admarble
    ContributorAuthor

    → PROCEED — AC_MET_BUT_NOT_A_PLUS misrouted into quality loop → no PR; single load-bearing line at phase-executor.ts:396, correct policy already in ready-gate.ts.

    Workflow: exec → qa (skip spec — bug label, root cause + fix pinpointed). Quality loop on.

    ⚠ Must flip locking tests that assert the buggy behavior: phase-executor.test.ts:1557, run.test.ts:1282-1292.
    ⚠ Overlaps #748 on batch-executor.ts + run-orchestrator.ts — run sequentially.

    npx sequant run 749 -q --phases exec,qa
    
  3. admarble commented on Jun 29, 2026

    @admarble
    ContributorAuthor

    Complexity: Standard (4 ACs, 2 directories)

    AC Quality Check

    All four ACs are measurable and reference concrete code/tests. One correction to the issue body itself:

    • AC-4 cites run.test.ts:1282-1292 as asserting the buggy behavior — it does not. Those lines (and 1192-1193) are parseQaVerdict parser tests; they assert the verdict string parses correctly, not that the run path breaks to the loop. There is no routing-behavior assertion to reconcile in run.test.ts. AC-4's run.test.ts clause is effectively a no-op — verify, don't edit.

    Scope Assessment

    Non-Goals: Not stated explicitly. Inferred boundary: this fix does not introduce an explicit a-plus "keep looping" policy into the run path (that would require plumbing ReadyPolicy from run.ts → batch-executor → phase-executor, which does not exist today). The issue lists that as "optional" — recommend deferring to a follow-up.

    Metric Value Status
    Feature count 1 (allowlist fix) ✅
    AC items 4 ✅
    Directory spread 2 (src/lib/workflow, src/commands) ✅

    Verdict: ✅ SCOPE_OK


    Acceptance Criteria

    AC-1: sequant run with QA verdict AC_MET_BUT_NOT_A_PLUS breaks to PR instead of entering the quality loop / failing

    Verification: Unit Test
    Scenario: Given a qa AgentPhaseResult whose output parses to AC_MET_BUT_NOT_A_PLUS → When mapAgentSuccessToPhaseResult("qa", …) runs → Then it returns success: true with verdict: "AC_MET_BUT_NOT_A_PLUS" retained on the result.
    Assumptions: Every downstream router (batch-executor loop trigger, chain-break, shouldCreatePR) keys off result.success only — verified: flipping the mapping is sufficient to reach PR creation; no router changes needed.

    AC-2: --qa-gate --chain is not broken by an AC_MET_BUT_NOT_A_PLUS predecessor verdict

    Verification: Integration Test
    Scenario: Given a chain where the predecessor's qa returns AC_MET_BUT_NOT_A_PLUS → When --qa-gate --chain evaluates whether to continue → Then the chain proceeds (predecessor counts as a successful gate).
    Assumptions: Satisfied as a consequence of AC-1 — run-orchestrator breaks the chain on qa non-success; once the qa PhaseResult is success: true, the gate passes. Confirm with a focused test rather than relying on transitivity alone.

    AC-3: AC_NOT_MET and null/unparseable verdicts still hard-fail

    Verification: Unit Test
    Scenario: Given qa output parsing to AC_NOT_MET, OR empty/unparseable output (null verdict, #534) → When mapped → Then success: false with the existing error strings preserved.
    Assumptions: The fix narrows the failing branch from "anything not in {READY_FOR_MERGE, NEEDS_VERIFICATION}" to "AC_NOT_MET (+ null branch unchanged)". Existing #534 null-verdict tests must stay green untouched.

    AC-4: Tests updated

    Verification: Unit Test
    Scenario: phase-executor.test.ts:1557 ("fails on AC_MET_BUT_NOT_A_PLUS … existing behavior preserved") is flipped to assert success === true + verdict === "AC_MET_BUT_NOT_A_PLUS", renamed to reflect new behavior; add a positive assertion that the run path proceeds to PR (success drives shouldCreatePR). run.test.ts — verify the AC_MET parser tests still pass; no routing assertion exists there to change (see AC Quality Check).
    Assumptions: Renaming the test string keeps the locking test honest rather than leaving a now-misleading name.


    Implementation Plan

    Phase 1: Flip the allowlist (single load-bearing line)

    1. src/lib/workflow/phase-executor.ts:396-412 — narrow the failing condition so only AC_NOT_MET (verdict-present) hard-fails. Replace the verdict !== "READY_FOR_MERGE" && verdict !== "NEEDS_VERIFICATION" guard with an explicit verdict === "AC_NOT_MET" check. Keep the separate null-verdict branch (413-425, fix(orchestrator): treat null QA verdict and zero-diff exec as failure, not success #534) exactly as-is.
    2. Keep verdict (and summary) on the success: true result so the PR body / run log can surface the "not A+" note. Confirm the success branch (426+) already carries verdict.

    Phase 2: Reconcile tests

    1. src/lib/workflow/phase-executor.test.ts:1557 — flip the assertion to success === true, assert verdict === "AC_MET_BUT_NOT_A_PLUS", rename the it(...) title (e.g. "treats AC_MET_BUT_NOT_A_PLUS as success → break to PR").
    2. Add a positive assertion (same file) that a success: true qa result is what shouldCreatePR consumes to ship a PR — or a focused batch/orchestrator-level test that an AC_MET_BUT_NOT_A_PLUS predecessor does not break a --qa-gate --chain (covers AC-2).
    3. src/commands/run.test.ts — run the suite; confirm the parser tests (1192-1193, 1282-1292) stay green. No edit expected.

    Phase 3: Verify

    1. npm test -- phase-executor and the chain/qa-gate tests; confirm AC_NOT_MET + null-verdict (fix(orchestrator): treat null QA verdict and zero-diff exec as failure, not success #534) tests remain red-on-failure / green-on-pass unchanged.

    Design Review

    1. Where does this logic belong? The verdict→success mapping belongs in mapAgentSuccessToPhaseResult (phase-executor) — it is the single translation point. Correct location; the fix stays there.
    2. What's the simplest correct approach? Invert the guard to an explicit AC_NOT_MET failure check. Rejected: plumbing ReadyPolicy into phase-executor to mirror ready-gate — more correct long-term but adds a parameter through run.ts → batch-executor → phase-executor; not needed for the documented default (break-to-PR). Defer.
    3. What existing pattern does this follow? ready-gate.ts:155-162 isAtThreshold — AC_MET_BUT_NOT_A_PLUS is a stopping state under the ac policy. This change makes the run path agree with the already-correct sequant ready path.
    4. What would a senior reviewer challenge? "Why an explicit AC_NOT_MET check instead of a new allowlist member?" — because the set of stopping verdicts is open-ended and the set of hard-failures is closed (AC_NOT_MET + null); an explicit fail-list is more robust to future verdict additions. Also: "Should NEEDS_VERIFICATION really still be success here while ready-gate says it never stops?" — out of scope; flag as Open Question, don't change.

    Feature Quality Planning

    All standard checks pass. Notable items:


    Open Questions

    1. Should the optional a-plus policy gate be implemented now? — Recommendation: No, follow-up issue. No ReadyPolicy plumbing exists in the run path; the documented default is break-to-PR. Impact if wrong: users wanting "push to A+" looping have no opt-in until the follow-up lands.
    2. NEEDS_VERIFICATION divergence between phase-executor (success) and ready-gate (never-stop) — Recommendation: leave as-is for fix(run): AC_MET_BUT_NOT_A_PLUS QA verdict misrouted into quality loop → fails with no PR (should break to PR) #749; file a follow-up to reconcile the two engines' verdict semantics. Impact: cosmetic until someone relies on one engine's behavior in the other's context.

    Recommended Workflow

    Phases: exec → qa
    Quality Loop: enabled
    Reasoning: Bug label, root cause + fix pinpointed — skip spec/testgen (test changes are edits to existing tests, not new stubs). The fix is exactly the kind of qa-verdict routing this issue corrects; quality loop is safe here because the ACs are crisp and test-locked.


    Label Review

    Current: bug, qa, multi-agent
    Recommended: bug, qa, multi-agent, planned
    Reason: Labels accurately reflect a qa-path bug fix. No complex/refactor warranted (single line + test reconcile). Quality loop won't auto-enable from scope (SCOPE_OK) — enable it explicitly via -q as the assess comment recommends.
    Quality Loop: Won't auto-enable (scope is green); pass -q explicitly.

    → gh issue edit 749 --add-label planned


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

    Plan — exec → qa (Standard, SCOPE_OK)

    The fix is the single load-bearing line at phase-executor.ts:396-412. Downstream routers (batch loop trigger, chain-break, shouldCreatePR) all key off result.success, so flipping the mapping fixes AC-1 and AC-2 together; AC-3 stays a hard fail by narrowing the guard to an explicit AC_NOT_MET check (null/#534 branch untouched).

    ACs

    • AC-1 — mapAgentSuccessToPhaseResult returns success: true (verdict retained) for AC_MET_BUT_NOT_A_PLUS; run path reaches PR. (Unit)
    • AC-2 — --qa-gate --chain proceeds past an AC_MET_BUT_NOT_A_PLUS predecessor. (Integration; follows from AC-1, confirm with focused test)
    • AC-3 — AC_NOT_MET and null/unparseable verdicts still hard-fail (existing error strings + fix(orchestrator): treat null QA verdict and zero-diff exec as failure, not success #534 tests preserved). (Unit)
    • AC-4 — phase-executor.test.ts:1557 flipped + renamed, positive break-to-PR assertion added. (Unit)

    Correction: run.test.ts:1282-1292 are parseQaVerdict parser tests, not routing assertions — they need no change, only re-verification. AC-4's run.test.ts clause is a no-op.

    Deferred (follow-ups, not this issue):

    • Optional a-plus policy gate (requires ReadyPolicy plumbing through the run path; not present today).
    • NEEDS_VERIFICATION semantics diverge between phase-executor (success) and ready-gate (never-stop) — pre-existing, file separately.

    Note: #748 already merged (fd9b67e); the assess "run sequentially / overlap on batch-executor + run-orchestrator" warning is moot — the fix touches only phase-executor.ts + its test.

    Run: npx sequant run 749 -q --phases exec,qa

  4. added
    planned
    on Jun 29, 2026
  5. admarble commented on Jun 29, 2026

    @admarble
    ContributorAuthor

    Exec Complete — PR #753

    The single load-bearing line at phase-executor.ts:396 is fixed: the qa failing branch is narrowed from "any verdict outside {READY_FOR_MERGE, NEEDS_VERIFICATION}" to an explicit verdict === "AC_NOT_MET" check. AC_MET_BUT_NOT_A_PLUS now returns success: true (verdict retained), so the run breaks to PR instead of feeding the quality loop. The #534 null/unparseable branch is untouched.

    AC Coverage

    AC Status Notes
    AC-1 — run breaks to PR on AC_MET_BUT_NOT_A_PLUS ✅ mapping flipped; covered by renamed test
    AC-2 — --qa-gate --chain not broken by such a predecessor ✅ follows from AC-1 (chain break keys on result.success); focused test applies the run-orchestrator.ts:1077 predicate
    AC-3 — AC_NOT_MET + null/unparseable still hard-fail ✅ explicit AC_NOT_MET branch + #534 null branch preserved
    AC-4 — tests updated/reconciled ✅ phase-executor.test.ts locking test flipped + renamed + positive assertions; run.test.ts 1192-1193/1282-1292 confirmed parser-only (no edit — matches /spec correction)

    Files changed

    • src/lib/workflow/phase-executor.ts — narrow qa fail branch to AC_NOT_MET
    • src/lib/workflow/phase-executor.test.ts — flip locking test, add AC-2 chain-gate assertion
    • CHANGELOG.md — [Unreleased] → Fixed entry

    Gates

    • npm run build ✅ · npm run lint ✅ · phase-executor.test.ts 127 ✅ · run.test.ts 143 ✅

    Deferred (out of scope)

    • Optional a-plus "keep looping" policy gate (needs ReadyPolicy plumbing through the run path; absent today).
    • NEEDS_VERIFICATION semantic divergence between phase-executor (success) and ready-gate (never-stop) — pre-existing.
  6. admarble commented on Jun 29, 2026

    @admarble
    ContributorAuthor

    QA Review for Issue #749 (Simple Fix)

    Size Gate

    Check Value
    Diff size 43 lines (threshold: 100)
    package.json changed No
    Security-sensitive paths No
    Decision Inline checks

    AC Coverage

    AC Description Status Notes
    AC-1 run with AC_MET_BUT_NOT_A_PLUS breaks to PR instead of looping/failing MET phase-executor.ts:396 now returns success: true with verdict retained; test "treats AC_MET_BUT_NOT_A_PLUS as success → break to PR (#749)" asserts it.
    AC-2 --qa-gate --chain not broken by an AC_MET_BUT_NOT_A_PLUS predecessor MET Chain break (run-orchestrator.ts:1076-1080) keys off result.success; qa is now success. Focused test applies the exact p.phase === "qa" && !p.success predicate → false.
    AC-3 AC_NOT_MET and null/unparseable verdicts still hard-fail MET Guard narrowed to explicit verdict === "AC_NOT_MET"; #534 null branch untouched. Adversarially confirmed parseQaVerdict can return only the 4 enum literals or null (regex capture group is constrained), so no unknown string can silently become success.
    AC-4 Tests flipped + positive assertion; run.test.ts reconciled MET Locking test flipped/renamed + success/verdict assertions added; run.test.ts 1192-1193/1282-1292 are parser-only (no routing assertion) — verified unchanged, 143 pass.

    Coverage: 4/4 AC items fully met


    Quality Metrics

    Metric Value Status
    Type issues (any) 0 OK
    Deleted tests 0 OK
    Files changed 3 OK
    Lines added +35 -
    Lines deleted -8 -
    Security patterns 0 OK

    Tests: net +1 (AC_MET_BUT_NOT_A_PLUS test renamed in place; one new AC-2 chain-gate test added).


    CI Status

    Check State Impact
    build (22.x) SUCCESS (2m28s) ✅ MET
    typecheck SUCCESS ✅ MET
    node-floor-guard SUCCESS ✅ MET
    validate-plugin SUCCESS ✅ MET
    validate-skills SUCCESS ✅ MET

    CI Summary: 5 passed, 0 pending, 0 failed (waited for build matrix to finish before verdict).


    Code Review

    Strengths:

    Issues: None.

    Suggestions:

    • (Non-blocking, already deferred in spec) The fail-list approach means a future 5th verdict added to QaVerdictSchema would default to success unless explicitly added to the fail branch. Acceptable given a verdict addition is a schema change that forces review; worth a one-line comment if the enum grows.

    Test Coverage Analysis

    Changed File Tier Has Tests? Test File
    src/lib/workflow/phase-executor.ts Standard ✅ Yes phase-executor.test.ts (127 pass)
    src/lib/workflow/phase-executor.test.ts — self —
    CHANGELOG.md Optional — docs

    Coverage: 1/1 changed source file has corresponding tests.


    Anti-Pattern Detection

    No anti-patterns in the diff (no any, no empty catch, no secrets, no loop-await, no uncleared timers).


    CHANGELOG Verification

    Check Status
    CHANGELOG.md exists ✅ Found
    User-facing change (fix(#749) commit) ✅ Yes
    [Unreleased] → Fixed entry ✅ Present (references #749)

    Result: CHANGELOG requirements met.


    Risk Assessment

    • Likely failure mode: A future QA verdict added to the enum that should hard-fail would, under the new fail-list guard, default to success (break-to-PR) until explicitly added to the AC_NOT_MET branch. Deliberate, documented tradeoff — fails open toward shipping rather than toward the loop trap this issue fixes.
    • Not tested: The full run-path integration (batch-executor → shouldCreatePR, orchestrator chain loop) is not exercised end-to-end; AC-1/AC-2 are verified at the mapping-function + predicate level. Spec explicitly deferred a full orchestrator harness as disproportionate to a one-line routing fix.
    • Sibling sites considered: none — the verdict→success mapping lives only in mapAgentSuccessToPhaseResult. ready-gate.ts's parallel ac policy is the correct reference, not a co-bugged sibling.
    • Sibling-line audit: none — single qa-verdict branch; the adjacent exec no-changes branch is unrelated.

    Adversarial Re-Read

    Findings: No gaps. Walked the core logic adversarially: (1) traced parseQaVerdict — its regex capture group is constrained to the 4 QaVerdictSchema literals, so the as QaVerdict cast is sound and no unknown-but-truthy string can reach the success branch (the one real risk of inverting an allowlist into a fail-list); (2) confirmed the #534 null branch is byte-for-byte unchanged, preserving AC-3's "unparseable hard-fails"; (3) confirmed the success branch already carried verdict/summary so the "not A+" note survives; (4) re-ran the AC_MET parser tests in run.test.ts (143 pass) to confirm AC-4's no-edit claim; (5) no Non-Goal scope creep — only the qa branch changed.

    Status: Clean


    Verdict: READY_FOR_MERGE

    All 4 ACs MET, all CI green, build/lint/tests pass locally, no type/security/anti-pattern issues, test coverage increased, CHANGELOG entry present. The fix matches the spec's pinpointed root cause exactly and the guard inversion is provably exhaustive against the verdict enum.

    Documentation: Before merging, optionally run /docs 749 — though this is an internal routing fix with a CHANGELOG entry already in place, so dedicated docs are not required.

    Next Steps

    1. Merge PR fix(#749): AC_MET_BUT_NOT_A_PLUS QA verdict breaks to PR instead of looping #753.
    2. Run ./scripts/cleanup-worktree.sh after merge to free the worktree/branch.
  7. added
    ready-for-review
    on Jun 29, 2026
  8. added 2 commits that reference this issue on Jul 14, 2026
  9. added 2 commits that reference this issue on Jul 26, 2026
  10. 268 remaining items

  11. admarble commented on Sep 20, 2026

    @admarble
    ContributorAuthor

    QA Verdict: AC_MET_BUT_NOT_A_PLUS

  12. admarble commented on Sep 20, 2026

    @admarble
    ContributorAuthor

    QA Verdict: AC_MET_BUT_NOT_A_PLUS

  13. admarble commented on Sep 20, 2026

    @admarble
    ContributorAuthor

    QA Verdict: AC_MET_BUT_NOT_A_PLUS

  14. admarble commented on Sep 20, 2026

    @admarble
    ContributorAuthor

    QA Verdict: AC_MET_BUT_NOT_A_PLUS

  15. admarble commented on Sep 20, 2026

    @admarble
    ContributorAuthor

    QA Verdict: AC_MET_BUT_NOT_A_PLUS

  16. admarble commented on Sep 20, 2026

    @admarble
    ContributorAuthor

    QA Verdict: AC_MET_BUT_NOT_A_PLUS

  17. admarble commented on Sep 20, 2026

    @admarble
    ContributorAuthor

    QA Verdict: AC_MET_BUT_NOT_A_PLUS

  18. admarble commented on Sep 20, 2026

    @admarble
    ContributorAuthor

    QA Verdict: AC_MET_BUT_NOT_A_PLUS

  19. admarble commented on Sep 20, 2026

    @admarble
    ContributorAuthor

    QA Verdict: AC_MET_BUT_NOT_A_PLUS

  20. admarble commented on Sep 20, 2026

    @admarble
    ContributorAuthor

    QA Verdict: AC_MET_BUT_NOT_A_PLUS

  21. admarble commented on Sep 20, 2026

    @admarble
    ContributorAuthor

    QA Verdict: AC_MET_BUT_NOT_A_PLUS

  22. admarble commented on Sep 20, 2026

    @admarble
    ContributorAuthor

    QA Verdict: AC_MET_BUT_NOT_A_PLUS

  23. admarble commented on Sep 20, 2026

    @admarble
    ContributorAuthor

    QA Verdict: AC_MET_BUT_NOT_A_PLUS

  24. admarble commented on Sep 20, 2026

    @admarble
    ContributorAuthor

    QA Verdict: AC_MET_BUT_NOT_A_PLUS

  25. admarble commented on Sep 20, 2026

    @admarble
    ContributorAuthor

    QA Verdict: AC_MET_BUT_NOT_A_PLUS

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

    bugmulti-agentplannedqaready-for-review

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions