Skip to content

fix(#581): /fullsolve QA loop early-exit on same-SHA same-verdict cycles - #591

Merged
admarble merged 3 commits into
mainfrom
feature/581-bug-fullsolve-qa-loop-re-runs-qa-with-no-state-cha
May 7, 2026
Merged

admarble merged 3 commits into
mainfrom
feature/581-bug-fullsolve-qa-loop-re-runs-qa-with-no-state-cha

Conversation

@admarble

@admarble admarble commented May 7, 2026

Copy link
Copy Markdown
Contributor

Summary

Fixes the QA loop in /fullsolve that previously consumed MAX_QA_ITERATIONS=2 re-running /qa on identical state when /loop produced no commit and no working-tree change. Two new escalation gates short-circuit the wasted-cycle pattern surfaced during /fullsolve 570 (3 sequential AC_NOT_MET verdicts at SHA cb77c8e6):

  • Pre-/qa stagnation gate in /fullsolve §4.3 — runs npx tsx scripts/qa-stagnation.ts detect <issue> before each /qa re-invocation after iteration 0; halts with SAME_SHA_NO_PROGRESS when the prior qa:failed marker's commitSHA matches HEAD AND git status --porcelain is empty.
  • Post-/loop no-diff guard as new "Step 5.5" in /loop — snapshot/compare brackets Step 5 (Fix Issues) and exits with LOOP_NO_DIFF when neither HEAD nor the working-tree (excluding .sequant/ state writes) changed.

What Changed

  • src/lib/workflow/qa-stagnation.ts (new, 285 lines) — detectStagnation() (pure decision function, 7 branches), recordStagnation() (additive qaStagnation array on IssueState), snapshotLoopProgress() / compareLoopProgress() (with .sequant/ exclusion in the porcelain v1 parser).
  • scripts/qa-stagnation.ts (new, 150 lines) — CLI shim (detect/record/snapshot/compare-snapshot) so SKILL.md and tests exercise the same code path.
  • src/lib/workflow/state-schema.ts — additive QAStagnationEntrySchema + optional qaStagnation: QAStagnationEntry[] field on IssueState (preserves older state files).
  • {.claude/skills,skills,templates/skills}/fullsolve/SKILL.md — §4.3 wired with stagnation gate + record + halt.
  • {.claude/skills,skills,templates/skills}/loop/SKILL.md — new "Step 5.5: No-Diff Guard" section in all 3 mirrors.
  • src/lib/workflow/qa-stagnation.test.ts (new, 26 tests) — covers all detectStagnation branches, recordStagnation persistence + additive append, compareLoopProgress paths, .sequant/ exclusion, leading-space porcelain handling, and a 4-test integration suite that drives the qa-loop logic against real git init temp repos.
  • CHANGELOG.md — entry under [Unreleased] > Fixed.

Pre-existing drift between loop/SKILL.md mirrors (Orchestration Context block missing from skills/ and templates/skills/) was deliberately left untouched per the spec note: "full reconciliation is out of scope."

AC Coverage (5/5 MET)

  • AC-1 Pre-/qa no-progress gate in fullsolve QA loop — wired in all 3 mirrors at §4.3.
  • AC-2 Post-/loop no-diff guard — new Step 5.5 in all 3 mirrors; readDirtyExcludingState correctly slices porcelain v1 XY prefix without trim corruption.
  • AC-3 Stagnation telemetry in .sequant/state.json — additive schema + caller (CLI shim invoked from both fullsolve and loop SKILL.md) + 4 unit tests.
  • AC-4 Integration test for no-progress halt — proves halt at iteration 1 with qaInvocations==1 (NOT MAX_QA_ITERATIONS=2) and reason==LOOP_NO_DIFF against a real git worktree.
  • AC-5 Documentation — new escalation docs identical across all 6 SKILL.md files.

Quality Metrics

  • Tests: 26/26 passing
  • Build: PASS (tsc clean)
  • lint:skill-calls: No violations
  • Type issues (any): 0
  • Deleted tests: 0

Closes #581

Test plan

  • npx vitest run src/lib/workflow/qa-stagnation.test.ts — 26 tests pass
  • npm run build — tsc clean
  • npm run lint:skill-calls — no unqualified Skill() calls
  • Mirror parity: diff -q confirms all 3 fullsolve SKILL.md mirrors identical; loop mirrors share identical new Step 5.5 section
  • Integration: real git init temp repo + stub /loop returning no diff → halts at iteration 1 with LOOP_NO_DIFF
  • Real-world: next /fullsolve invocation on a stuck issue should halt with stagnation telemetry instead of consuming 2 wasted cycles

admarble added 3 commits May 6, 2026 19:31
Adds a stagnation gate to /fullsolve's QA loop and a no-diff guard to
/loop so that wasted iterations (same HEAD SHA, same AC_NOT_MET verdict)
halt with a hard blocker instead of consuming MAX_QA_ITERATIONS.

- src/lib/workflow/qa-stagnation.ts — detectStagnation() + recordStagnation()
  + snapshotLoopProgress()/compareLoopProgress() helpers, with .sequant/
  exclusion for state-file writes (per issue's open question).
- scripts/qa-stagnation.ts — CLI shim (detect / record / snapshot /
  compare-snapshot) so SKILL.md and tests exercise the same code path.
- state-schema.ts — additive QAStagnationEntrySchema + qaStagnation array
  on IssueState (AC-3 telemetry).
- /fullsolve SKILL.md (3 mirrors) — §4.3 wires the stagnation detector
  before each /qa re-invocation after iteration 0; halts on
  SAME_SHA_NO_PROGRESS (AC-1, AC-5).
- /loop SKILL.md (3 mirrors) — new Step 5.5 No-Diff Guard takes a
  before/after snapshot and exits with LOOP_NO_DIFF if /loop produced
  no commit and no working-tree change excluding .sequant/ (AC-2, AC-5).
- qa-stagnation.test.ts — unit + integration coverage: AC-3
  recordStagnation persistence, AC-4 simulator proves halt at iteration
  1 (NOT MAX_QA_ITERATIONS) when /loop returns no diff.

Closes #581
Documents the SAME_SHA_NO_PROGRESS / LOOP_NO_DIFF escalation gates,
the new qa-stagnation helpers and CLI shim, the additive
QAStagnationEntrySchema, and the unit + integration test coverage.
…coverage

- Rename 'halts via SAME_SHA_NO_PROGRESS at iteration 2 if /loop appears
  to diff but state is restored' to accurately describe LOOP_NO_DIFF halt.
- Add new test that exercises SAME_SHA_NO_PROGRESS detection directly via
  detectStagnation() against a real worktree, covering the resumption path
  (prior qa:failed marker at current HEAD, no /loop in this invocation).
- Add new test where /loop writes-then-reverts (clean tree at gate) to
  exercise the LOOP_NO_DIFF early-halt path on iteration 1.

26 tests pass.
@admarble
admarble merged commit dfc2b65 into main May 7, 2026
8 checks passed
@admarble
admarble deleted the feature/581-bug-fullsolve-qa-loop-re-runs-qa-with-no-state-cha branch May 7, 2026 01:58
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.

bug(fullsolve): QA loop re-runs /qa with no state change instead of escalating same-SHA same-verdict cycles

1 participant