Skip to content

feat(#1646): the quality loop halts on a second consecutive AC_NOT_MET — its own counter, no ladder needed; maxIterations stays 3 - #1660

Merged
admarble merged 2 commits into
mainfrom
feature/1646-feat-run-the-quality-loop-halts-on-a-second-consec
Nov 8, 2026
Merged

admarble merged 2 commits into
mainfrom
feature/1646-feat-run-the-quality-loop-halts-on-a-second-consec

Conversation

@admarble

@admarble admarble commented Nov 8, 2026 •

Copy link
Copy Markdown
Contributor

Summary

How it works:

  • The counter. recordAcNotMetStreak in batch-executor.ts runs after every QA phase. An AC_NOT_MET verdict adds {iteration, sha, verdict, failedAcs} to a list. Any other verdict, or no verdict, empties the list. It reuses the commit SHA already looked up for the verdict comment and the AC rows recordAcStatuses already returns, so it adds no git calls.
  • The stop. At two in a row it sets repeatHaltBundle and prints the bundle with warn. The bundle's reason is the new AC_NOT_MET_REPEATED. A new loopHalted(state) check now drives both the outer-loop break and the /loop spawn guard, which used to have separate copies of the same list. Nothing in this path depends on the ladder, so chore(cli)!: remove the model ladder and effort escalation — modules, --model-ladder and --escalate-effort on run and ready, their settings and docs; old logs and settings still load #1647 can delete the ladder without losing this halt.
  • What the run log records. repeatHaltOutcome sets failureCategory: "ac_not_met_repeated". The abortReason reads ac_not_met_repeated: AC_NOT_MET twice in qa at <sha1>, <sha2> (failed: AC-…), and the evidence bundle is attached. The existing recordIssueCompletion path writes both to the run log; a test covers this.
  • Schema. The changes are additive and version stays 1:
    • ac_not_met_repeated is added to ERROR_CATEGORIES and to the inline category list in the schema.
    • AC_NOT_MET_REPEATED is a new bundle reason.
    • Each bundle iteration gains an optional failedAcs.
  • Bundle header. For this halt the printed header reads "Quality loop halt" instead of "Ladder halt".
  • Outside the may-touch list:
    • divergence-halt.ts: the additive edit the spec recommended.
    • src/mcp/tools/run.ts: its haltReason type needed the new reason to compile.
    • __tests__/error-capture.test.ts: this test checks the category count, so it now expects 11 categories, one more than before.

Pre-PR AC Verification

AC Status Evidence
AC-1 ✅ npx vitest run src/lib/workflow/batch-executor.repeat-halt.test.ts → 6 passed, 0 failed (repeat halt, refusal then pass, null verdict resets, no AC record, no snapshot without a ladder, reaches the run log)
AC-2 ✅ npx vitest run src/lib/workflow/run-log-schema.test.ts -t "ac_not_met_repeated" → 3 passed, 0 failed; all existing fixtures still validate
AC-3 ✅ grep -c 'maxIterations: z.number().positive().default(3)' src/lib/settings.ts → 1 (not touched)
AC-4 ✅ docs/reference/run-command.md, under ### Quality Loop Mode → 1
AC-5 ✅ CHANGELOG.md [Unreleased] ### Changed → 1 (#1370 is not merged, so no changelog.d/)
AC-6 ✅ skill-directory grep → 0

No AC is a gate test, so there are no SEQUANT_MUTATION markers. As an extra check, I removed repeatHaltBundle from loopHalted: the 4 halt tests failed and the 2 no-halt tests passed. Then I restored the file.

Checks

  • npm run build: passed. npm run lint: passed, 0 warnings.
  • Affected tests: npx vitest run --changed origin/main selected 172 files, so I ran it in 3 shards with every SEQUANT_* variable unset:
    • Shard 1: 58 files, 1042 tests, all passed.
    • Shard 2: 1 failure in __tests__/error-capture.test.ts. That test hard-codes the category count at 10, and my change made it 11. I updated it and it now passes, 29/29.
    • Shard 3: 57 files, 1336 tests, all passed.
  • Extra set: 12 files, 446 tests, all passed. It covered the tautology detector, divergence-halt.test.ts, batch-executor.test.ts, batch-executor.model-ladder.test.ts, mcp-run-async.test.ts and the files that grep for the changed paths. scripts/qa/health-report.test.ts passed separately, 12/12.
  • Test coverage: every changed source file has tests. batch-executor.ts is covered by the new batch-executor.repeat-halt.test.ts, run-log-schema.ts by its schema test, and the category list by error-capture.test.ts.

OQ-2

One of 92 run logs in .sequant/logs/ (main checkout plus this worktree) has two QA verdicts in a row that are both `AC_NOT_ME

Fixes #1646

QA verdict: NEEDS_VERIFICATION — acceptance criteria met, pending external verification (e.g. CI or a manual test). See the QA review comment.

Follow-ups

  • Two new exports are unused outside batch-executor.ts — import in a test or drop the export — fixed by the runner in 997ae80 (both file-local)
  • Streak is not reset by an iteration that never reaches qa; no test pins this — dropped: consistent with consecutive-verdict semantics in H-1

🤖 Generated by sequant run

Runner verification (graph-2026-11-simplify W1, 2026-11-07)

Closes #1646

…T — its own counter, no ladder needed; maxIterations stays 3

A counter on the parsed QA verdict in recordLoopPhaseOutcome stops the loop before the next /loop spawn when AC_NOT_MET repeats; any other verdict or none resets it. One loopHalted(state) predicate replaces the two duplicated halt lists. The issue fails with category ac_not_met_repeated, an abortReason naming both SHAs and the failed ACs, and an EvidenceBundle with reason AC_NOT_MET_REPEATED and per-iteration failedAcs (run log version stays 1).

Entire-Checkpoint: 1b8b0a83d395
@admarble

admarble commented Nov 8, 2026

Copy link
Copy Markdown
Contributor Author

Read first

Computed from the diff, the issue's Evidence: clauses and git log. Nothing here is written by a model.

Residue

  • __tests__/error-capture.test.ts (+4 −1): no AC's evidence names it — git diff --numstat origin/main...HEAD -- __tests__/error-capture.test.ts
  • src/lib/workflow/batch-executor.ts (+126 −11): no AC's evidence names it — git diff --numstat origin/main...HEAD -- src/lib/workflow/batch-executor.ts
  • src/lib/workflow/divergence-halt.ts (+24 −3): no AC's evidence names it — git diff --numstat origin/main...HEAD -- src/lib/workflow/divergence-halt.ts
  • src/lib/workflow/error-classifier.ts (+3 −0): no AC's evidence names it — git diff --numstat origin/main...HEAD -- src/lib/workflow/error-classifier.ts
  • src/lib/workflow/run-log-schema.ts (+9 −2): no AC's evidence names it — git diff --numstat origin/main...HEAD -- src/lib/workflow/run-log-schema.ts
  • src/lib/workflow/types.ts (+5 −2): no AC's evidence names it — git diff --numstat origin/main...HEAD -- src/lib/workflow/types.ts
  • src/mcp/tools/run.ts (+6 −2): no AC's evidence names it — git diff --numstat origin/main...HEAD -- src/mcp/tools/run.ts
  • CHANGELOG.md is hot: 18 fix commits in 28 days — git log --since=28.days --format=%s origin/main -- CHANGELOG.md | grep -cE '^fix(\(|:|!)'

Tests

  • __tests__/error-capture.test.ts: real; mutation record: none — grep -nE 'vi\.mock|jest\.mock|SKILL\.md' __tests__/error-capture.test.ts, gh pr view 1660 --json body
  • src/lib/workflow/batch-executor.repeat-halt.test.ts: mock; mutation record: none — grep -nE 'vi\.mock|jest\.mock|SKILL\.md' src/lib/workflow/batch-executor.repeat-halt.test.ts, gh pr view 1660 --json body
  • src/lib/workflow/run-log-schema.test.ts: real; mutation record: none — grep -nE 'vi\.mock|jest\.mock|SKILL\.md' src/lib/workflow/run-log-schema.test.ts, gh pr view 1660 --json body

Explained

  • src/lib/workflow/batch-executor.repeat-halt.test.ts — AC-1
  • src/lib/workflow/run-log-schema.test.ts — AC-2
  • docs/reference/run-command.md — AC-4
  • CHANGELOG.md — AC-5

AC verdict: the SEQUANT_QA_VERDICT comment on #1646.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

feat(run): the quality loop halts on a second consecutive AC_NOT_MET — its own counter, no ladder needed; maxIterations stays 3

1 participant