Skip to content

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

Closed

Description

@admarble

Summary

/fullsolve's QA loop currently re-runs /qa from scratch on each iteration even when nothing has changed since the prior run — same HEAD SHA, same uncommitted state, same disk content. This wastes a full QA cycle and produces an identical verdict, telling the user nothing new.

The behavior should instead detect "I'm about to issue the same verdict at the same SHA as the last run" and either:

  1. Apply the missing edit (if the prior QA's "Next Steps" enumerated specific fixes), OR
  2. Surface a hard blocker to the orchestrator (escalate, don't loop)

Concrete incident — issue #570

The fullsolve run on #570 produced 3 sequential QA failures with identical AC_NOT_MET verdicts, all at SHA cb77c8e6 (== origin/main):

Run SHA Verdict What changed since last run
QA #1 cb77c8e6 AC_NOT_MET (initial)
QA #2 cb77c8e6 AC_NOT_MET nothing — same state on disk
QA #3 cb77c8e6 AC_NOT_MET nothing — same state on disk

QA #3's own comment captures this:

"Re-running /qa 570 without first applying the missing .claude/hooks/pre-tool.sh edits will continue to produce the same outcome."

The 4th attempt (this session, manually triggered) applied the missing edit, committed, and got to READY_FOR_MERGE. But that should have happened automatically after QA #1 — not after 3 wasted cycles.

Root cause hypothesis

The fullsolve QA loop appears to:

  1. Run /qa → parse verdict
  2. If verdict ≠ READY_FOR_MERGE → invoke /sequant:loop for fixes
  3. Re-run /qa → repeat (max iterations)

The gap is in step 2: /sequant:loop runs but does not actually apply the fixes — either it doesn't parse the prior QA's "Next Steps" into edits, or it does but the edits aren't committed back to the worktree, or it skips the loop entirely. Whichever — the symptom is identical state at QA #N+1.

Acceptance Criteria

  • AC-1: Before invoking /qa, fullsolve's QA loop checks the latest QA phase marker on the issue. If commitSHA matches current HEAD AND status == "failed" AND no edits have been made since (git status --porcelain empty), the loop does not re-invoke /qa. Instead it either invokes /loop to apply the prior QA's recommendations, or surfaces a hard blocker.
  • AC-2: When /sequant:loop runs, it must verify it actually produced a diff before yielding back to /qa. If git status --porcelain is unchanged after /loop, the loop bails out with a clear "loop fixer made no changes — manual intervention required" message rather than re-QAing the same state.
  • AC-3: Telemetry / logging captures same-SHA same-verdict cycles in .sequant/state.json (or equivalent) so future runs can detect "we've been here before" within a single fullsolve invocation.
  • AC-4: Test coverage: integration test that simulates a fullsolve where /loop produces no diff, and asserts the workflow halts after the first wasted cycle (not after MAX_QA_ITERATIONS).
  • AC-5: Documentation in .claude/skills/fullsolve/SKILL.md and .claude/skills/loop/SKILL.md (and the templates/skills mirrors) describing the new escalation behavior.

Non-Goals

  • Not redesigning the QA loop algorithm. Keep MAX_QA_ITERATIONS=2 as the cap; this issue only adds an early-exit when iterations would be wasted.
  • Not auto-applying QA recommendations programmatically (that's a much bigger change). The bar is just "detect no-progress and escalate," not "fix automatically."
  • Not changing the QA verdict algorithm itself.

Risks / Open Questions

  • git status --porcelain may not be the right "did anything change" signal if /loop writes to files outside the worktree (settings, state file). Worth a quick audit of where /loop actually writes.
  • Phase marker availability — AC-1 relies on the prior QA having posted a marker with commitSHA. The qa skill emits these now, but legacy QAs without markers would force the loop to fall back to verbatim re-runs. That's acceptable degradation.

Complexity

simple-fix — the gating logic is ~20 lines in fullsolve's QA-loop section + a similar check in /loop. The harder part is the integration test (AC-4).

Self-assessed workflow

spec → exec → qa (AC-4 integration test takes the place of testgen — direct hand-rolled test against the orchestration runtime).

Related

Activity

  1. added
    bug
    planned
    on May 6, 2026
  2. added a commit that references this issue on May 6, 2026
  3. admarble commented on May 6, 2026

    @admarble
    ContributorAuthor

    Complexity: Standard (5 ACs, 3 directories)

    AC Quality Check

    All 5 ACs are measurable with clear pass/fail signals (specific files, specific git commands, specific verdict comparisons). No issues flagged.


    Scope Assessment

    Non-Goals (from issue body): keep MAX_QA_ITERATIONS=2; no auto-applying QA recommendations; no changes to QA verdict algorithm.

    Metric Value Status
    Feature count 1 ✅
    AC items 5 ✅
    Directory spread 3 (skills/*/fullsolve, skills/*/loop, src/lib/workflow) ✅

    Verdict: ✅ SCOPE_OK


    Acceptance Criteria

    AC-1: Pre-/qa no-progress gate in fullsolve QA loop

    Verification: Integration Test
    Scenario: Given qa:failed marker with commitSHA == HEAD AND git status --porcelain empty → When fullsolve enters QA loop iteration ≥2 → Then it must NOT invoke Skill(skill: "qa"). It either invokes /loop once or emits SAME_SHA_NO_PROGRESS and breaks.

    AC-2: Post-/loop no-diff guard

    Verification: Integration Test
    Scenario: Given /loop runs in orchestrated mode → When both git rev-parse HEAD AND git status --porcelain are unchanged before vs after the fix attempt → Then /loop exits with LOOP_NO_DIFF and the manual-intervention message; does NOT yield back to /qa. State-file/settings writes do NOT count as progress (per issue body's open question).

    AC-3: Stagnation telemetry in .sequant/state.json

    Verification: Unit Test
    Scenario: Given fullsolve detects a same-SHA same-verdict cycle → Then per-issue state contains an additive qaStagnation: [{ sha, verdict, detectedAt, iteration }] entry. Existing schema preserved.

    AC-4: Integration test for no-progress halt

    Verification: Integration Test
    Scenario: Given a temp git repo + stub /loop that returns no diff → When the stagnation helper drives the QA-loop logic → Then it halts at iteration 1 (NOT MAX_QA_ITERATIONS=2) with reason SAME_SHA_NO_PROGRESS. Test under src/lib/workflow/ next to phase-executor.test.ts.
    Assumptions: Logic must live in a TS helper (e.g. src/lib/workflow/qa-stagnation.ts) so test and SKILL.md exercise the same path; SKILL.md invokes via npx tsx.

    AC-5: Documentation across three skill mirrors

    Verification: Manual Test
    Scenario: .claude/skills/{fullsolve,loop}/SKILL.md AND templates/skills/{fullsolve,loop}/SKILL.md AND skills/{fullsolve,loop}/SKILL.md each describe the no-progress gate, the SAME_SHA_NO_PROGRESS / LOOP_NO_DIFF halts, and when manual intervention is required.
    ⚠️ Pre-existing drift: skills/loop/SKILL.md and templates/skills/loop/SKILL.md lack the entire "Orchestration Context" section vs the canonical .claude/skills/loop/SKILL.md. Implementation should land the new escalation docs in canonical + mirror only the new section to the drifted copies; full reconciliation is out of scope (see Open Question 4).


    Implementation Plan

    Phase 1: Stagnation helper (foundation for AC-1, AC-3, AC-4)

    1. Create src/lib/workflow/qa-stagnation.ts:
      • detectStagnation({ currentSha, isDirty, lastMarker }) — pure function
      • recordStagnation(issueNumber, entry) — appends to state via StateManager
      • CLI shim: npx tsx src/lib/workflow/qa-stagnation.ts detect <issue> → prints STAGNANT|FRESH for SKILL.md to consume
    2. Extend StateManager with optional qaStagnation array on per-issue record (additive — no migration).

    Phase 2: Wire into fullsolve QA loop (AC-1)

    1. Edit .claude/skills/fullsolve/SKILL.md §4.3 (lines 505–529): before each Skill(skill: "qa") after iteration 1, run helper. If STAGNANT: try /loop once if not already this iter; if /loop returns LOOP_NO_DIFF, break with SAME_SHA_NO_PROGRESS.
    2. Update §4.4 to recognize SAME_SHA_NO_PROGRESS as a distinct halt reason.

    Phase 3: Wire into /loop skill (AC-2)

    1. Edit .claude/skills/loop/SKILL.md Step 6/7: snapshot HEAD + git status --porcelain before fix, compare after. If both unchanged → exit LOOP_NO_DIFF and skip Re-run Validation.

    Phase 4: Sync mirrors (AC-5)

    1. Mirror Phases 2 + 3 edits to templates/skills/ and skills/ for both fullsolve and loop. Note the loop mirror drift — land only the new section.

    Phase 5: Integration test (AC-4)

    1. Add src/lib/workflow/qa-stagnation.test.ts: temp git repo (follow phase-executor.test.ts pattern), seeded qa:failed marker matching HEAD, stubbed /loop returning LOOP_NO_DIFF. Assert iteration halts at 1 with SAME_SHA_NO_PROGRESS.

    Design Review

    1. Where does this logic belong? Workflow-orchestration logic → src/lib/workflow/qa-stagnation.ts. Skills shell out via npx tsx (same pattern qa SKILL.md §0 already uses for marker parsing).
    2. What's the simplest correct approach? A pure detection function + a separate state-recording function. Rejected: inline bash in SKILL.md — would make AC-4's integration test impossible without duplicating logic.
    3. What existing pattern does this follow? Mirrors qa SKILL.md §0 (lines 510–574) short-circuit pattern. The new gate is the status=failed counterpart to the existing status=completed short-circuit.
    4. What would a senior reviewer challenge? "Why TypeScript helper instead of more bash?" → AC-4 demands integration test; markdown-embedded bash is untestable. "Why three mirror dirs?" → existing repo convention; out of scope.

    Feature Quality Planning

    All standard checks pass. Notable items:

    • Mirror drift in /loop SKILL.md — skills/ and templates/skills/ versions lack the Orchestration Context section. Do NOT attempt full reconciliation in this issue; file follow-up.
    • State-file writes — Helper must explicitly exclude .sequant/state.json writes from "progress" detection (issue body flags this risk).
    • Cross-reference qa skill's existing short-circuit — Avoid confusion between status=completed short-circuit (already exists) and new status=failed no-progress gate.

    Open Questions

    1. Should LOOP_NO_DIFF ever retry? — Recommend: no. Same prompt → same result. Impact if wrong: rare benign re-attempt.
    2. qaStagnation array vs single object? — Recommend: append-only array. Preserves multi-stagnation history. Impact: minor schema rev later.
    3. AC-1 escalation: try /loop once or escalate immediately? — Recommend: try /loop once on first detection (matches issue's "Apply OR Surface" spec), escalate on second. Impact: one extra cycle vs missed auto-fix.
    4. Reconcile /loop mirror drift in this issue? — Recommend: no. File follow-up. Impact: docs land canonical-first; mirrors stay incomplete temporarily.

    Recommended Workflow

    Phases: spec → exec → qa
    Quality Loop: disabled
    Reasoning: Honoring issue author's self-assessment. AC-4 is a hand-rolled integration test, so testgen stubs would be discarded. No UI → no test. Skill-orchestration bug → no security-review.


    Label Review

    Current: bug, planned
    Recommended: no change
    Reason: bug is accurate. planned already set. Body claims "simple-fix" complexity but the integration test (AC-4) lifts it to Standard tier — no simple-fix label warranted.
    Quality Loop: Won't auto-enable.


    Conflict Risk Analysis

    Active worktrees touching adjacent surfaces (#587, #569, #571) all edit qa/, ac-linter, or markdown-only-ci — none touch fullsolve or loop. Low conflict risk. Worktree for #581 already exists at ../worktrees/feature/581-bug-fullsolve-qa-loop-re-runs-qa-with-no-state-cha.


  4. admarble commented on May 6, 2026

    @admarble
    ContributorAuthor

    QA Review for Issue #581

    AC Coverage

    AC Source Description Status Notes
    AC-1 Original Pre-/qa no-progress gate in fullsolve QA loop NOT_MET Helper exists (detectStagnation()) but no edits to .claude/skills/fullsolve/SKILL.md (or templates/skills/, skills/ mirrors). The QA loop never invokes the gate. grep -l qa-stagnation over all 3 fullsolve SKILL.md returns zero matches.
    AC-2 Original Post-/loop no-diff guard NOT_MET Helper exists (snapshotLoopProgress/compareLoopProgress) but no edits to .claude/skills/loop/SKILL.md or its mirrors. Plus a confirmed parsing bug in readDirtyExcludingState (see Code Review) means even when wired up, unstaged changes to .sequant/state.json would falsely register as progress — the exact behavior AC-2 was supposed to prevent.
    AC-3 Original Stagnation telemetry in .sequant/state.json PARTIALLY_MET QAStagnationEntrySchema added to state-schema.ts ✅ and recordStagnation() implemented ✅, but no caller invokes it (orphan code) and no unit test exists per the spec's "Verification: Unit Test" requirement.
    AC-4 Original Integration test for no-progress halt NOT_MET No test file: src/lib/workflow/qa-stagnation.test.ts does not exist. The spec explicitly required this as the highest-leverage AC ("AC-4 demands integration test; markdown-embedded bash is untestable").
    AC-5 Original Documentation across three skill mirrors NOT_MET No SKILL.md was edited in .claude/skills/, templates/skills/, or skills/ for either fullsolve or loop. grep -l confirms zero references to SAME_SHA_NO_PROGRESS/LOOP_NO_DIFF/stagnation in any skill markdown.

    Coverage: 0/5 AC items fully met (1 partially met, 4 not met)


    Quality Plan Verification

    Dimension Items Planned Items Addressed Status
    Phase 1 (Stagnation helper) 2 (helper + StateManager extension) 2 ✅ Complete
    Phase 2 (Wire into fullsolve QA loop) 2 (§4.3 + §4.4 edits) 0 ❌ Not addressed
    Phase 3 (Wire into /loop skill) 1 (Step 6/7 edits) 0 ❌ Not addressed
    Phase 4 (Sync mirrors) 2 (templates + skills mirrors) 0 ❌ Not addressed
    Phase 5 (Integration test) 1 (qa-stagnation.test.ts) 0 ❌ Not addressed

    Quality Plan Status: Not Addressed (1/5 phases done — Phase 1 only)


    CI Status

    No PR exists for branch feature/581-bug-fullsolve-qa-loop-re-runs-qa-with-no-state-cha. CI status check skipped.


    Quality Metrics

    Metric Value Status
    Type issues (any) 0 OK
    Deleted tests 0 OK
    Files changed 3 (1 modified + 2 untracked) OK
    Lines added ~448 (23 schema + 275 helper + 150 CLI) -
    Lines deleted 0 -
    Commits on branch 0 (HEAD == origin/main) ⚠️ All work uncommitted

    Test Coverage Analysis

    Changed File Tier Has Tests? Test File
    src/lib/workflow/qa-stagnation.ts Standard ⚠️ No -
    scripts/qa-stagnation.ts Standard ⚠️ No -
    src/lib/workflow/state-schema.ts Standard ⚠️ No -

    Coverage: 0/3 changed source files have corresponding tests.
    Critical paths without tests: AC-4 specifically demands an integration test for the orchestration logic — its absence is the binding gap.


    Code Review

    Strengths (helper module):

    • Clean separation of pure decision (detectStagnation) from I/O (readHeadSha, readIsDirty) — directly testable.
    • Schema addition is minimal and additive (qaStagnation?: QAStagnationEntry[]) — preserves backward compatibility per the spec's "no migration" goal.
    • CLI shim correctly uses the streaming .comments[].body form (not [.comments[].body]), avoiding the JSON-encoding pitfall called out in qa SKILL.md §0a.
    • detectStagnation codes return paths cleanly; the early-return ladder is readable and maps 1:1 to the AC-1 contract.

    Issues:

    • 🐞 Confirmed bug — readDirtyExcludingState regex strips path bytes (src/lib/workflow/qa-stagnation.ts:209-220). The logic does .trim() then .replace(/^.{1,3}/, ""), but git status --porcelain v1 emits unstaged-only entries with a leading space (e.g. M file.ts). After .trim() the leading space is gone, so the regex chops 3 real characters from the path. Live demonstration in this very worktree:
      $ npx tsx scripts/qa-stagnation.ts snapshot
      {"sha":"164aef89...","dirty":["rc/lib/workflow/state-schema.ts","scripts/qa-stagnation.ts","src/lib/workflow/qa-stagnation.ts"]}
      Note rc/lib/workflow/state-schema.ts (lost ' M s'). Untracked ?? lines survive because they have no leading space; modified-unstaged lines do not. Functional impact: an unstaged .sequant/state.json write becomes sequant/state.json after parsing, fails the startsWith(".sequant/") filter, and would falsely register as progress — defeating AC-2's stated guarantee that "state-file/settings writes do NOT count as progress". Suggested fix: parse using line.slice(3) directly on the raw porcelain output (not the trimmed line), or use git status --porcelain=v2 and parse fields explicitly. Don't .trim() first.
    • 🐞 Schema/data mismatch in detectStagnation.priorVerdict (line 124). It assigns lastMarker.error as the prior verdict, but per qa SKILL.md the failed-marker shape is {phase, status:"failed", error:"AC_NOT_MET", commitSHA, ...} and the verdict on a completed marker lives in lastMarker.verdict. For the failed-marker case AC-1 targets, error will be the literal string "AC_NOT_MET" so this happens to work — but the field naming will mislead future readers and break if a non-AC error fires.
    • 🐞 Untracked-only — git diff main shows nothing. All work sits unstaged or untracked; the branch HEAD is identical to origin/main. Without a commit, the worktree QA cannot validate this against any merge target, and a follow-up /loop invocation would also see "no diff" and bail.
    • ⚠️ recordStagnation requires existing issue state (line 150). It throws if state.issues[issueNumber] is missing. In a fresh fullsolve where /spec/exec already ran, the issue record exists; for any other invocation path (manual /qa, retroactive recording) it'll throw. Either lazy-create the record or document the precondition in the CLI shim.
    • ⚠️ No tests for the helper module — the entire decision matrix in detectStagnation (5 early-return branches + the success branch) is unverified. AC-4 requires this; the spec's design review explicitly flagged "AC-4 demands integration test" as the reason for the TS helper extraction.

    Suggestions:

    • Stage and commit the helper + CLI shim as a self-contained "phase 1" commit so subsequent SKILL.md wiring can rebase against a stable base.
    • Add a small unit test table for detectStagnation's decision matrix (no git fixtures needed — it's pure).
    • Consider exposing STATE_DIR_PREFIX as a constant or making the exclusion list configurable; right now it's a magic string.

    Test Quality Review

    N/A — No test files were added or modified.


    Anti-Pattern Detection

    Dependency Audit

    N/A — package.json not modified.

    Code Patterns

    File:Line Category Pattern Suggestion
    src/lib/workflow/qa-stagnation.ts:218 Correctness Regex /^.{1,3}/ strips path bytes after .trim() of porcelain output Parse raw porcelain with .slice(3) (preserves leading space); or use --porcelain=v2

    Critical Issues: 0
    Warnings: 1 (parsing bug — see Code Review for impact analysis)


    Call-Site Review

    New exported functions detected: 6 (detectStagnation, recordStagnation, readHeadSha, readIsDirty, snapshotLoopProgress, compareLoopProgress)

    Function Call Sites Loop? Conditions AC Match
    detectStagnation scripts/qa-stagnation.ts:87 (detect subcommand) only No None ⚠️ Only the CLI shim calls it; no SKILL.md invocation — AC-1 requires fullsolve QA loop to call it
    recordStagnation scripts/qa-stagnation.ts:115 (record subcommand) only No None ⚠️ No SKILL.md or orchestrator code calls it — AC-3 telemetry is never recorded in practice
    snapshotLoopProgress scripts/qa-stagnation.ts:126 (snapshot subcommand) only No None ⚠️ No /loop SKILL.md uses it — AC-2 not wired
    compareLoopProgress scripts/qa-stagnation.ts:143 (compare-snapshot subcommand) only No None ⚠️ No /loop SKILL.md uses it — AC-2 not wired

    Findings: All six new exports are reachable only via the CLI shim. Nothing in the existing skill suite or workflow runtime invokes them, so the helper has no observable effect on /fullsolve or /loop behavior today. This is the single biggest gap — Phase 1 (helper) is done; Phases 2–5 (wiring + tests + docs) are not.

    Recommendations: Land the SKILL.md edits per the implementation plan's Phases 2–4 before any further QA cycles, then hand-roll the integration test in Phase 5.


    Execution Evidence

    Test Type Command Exit Code Result
    Smoke test (CLI invocable) npx tsx scripts/qa-stagnation.ts 1 ✅ Prints usage as expected
    Smoke test (snapshot subcommand) npx tsx scripts/qa-stagnation.ts snapshot 0 ⚠️ Runs, but reveals the parsing bug (rc/lib/workflow/state-schema.ts)
    Build npm run build 0 ✅ Passes

    Evidence status: Complete (helpers compile and run; the smoke test surfaced the latent regex bug).


    Skill Command Verification

    N/A — No .claude/skills/**/*.md files modified.

    Detection Pattern Verification

    N/A — No skill markdown edits in this diff. (Note: when the missing SKILL.md edits land, the new grep/regex patterns added to fullsolve/loop SKILL.md will need to be verified per Section 6c against past phase markers and git status output.)

    CLI Registration Verification

    N/A — No RunOptions or bin/cli.ts changes.

    Skill Change Review

    N/A — No skill files changed (which is itself the AC-5 gap).

    Smoke Test

    Test Command Result Notes
    Helper compiles npm run build ✅ tsc passes
    CLI shim runs npx tsx scripts/qa-stagnation.ts snapshot ⚠️ Returns garbled paths for unstaged-modified files
    Stagnation detection happy path npx tsx scripts/qa-stagnation.ts detect 581 (not run — would query GitHub for #581's qa marker; only spec marker exists) -

    Smoke Test Status: Partial — happy-path detection requires a prior failed qa marker which doesn't exist on #581.

    Manual Test ACs

    N/A — No ACs flagged Manual Test in the spec plan (AC-5 is "Manual Test" in the spec but it asks for documentation review, which is a code-review check, not runtime).

    CHANGELOG Verification

    Check Status
    CHANGELOG.md exists ✅ Found
    User-facing changes ⚠️ Skill behavior change (when wired)
    [Unreleased] entry ❌ Not added

    Result: No CHANGELOG entry. Add one once SKILL.md wiring lands.


    Risk Assessment

    • Likely failure mode: Today, none — the helper is dead code from the orchestrator's view, so /fullsolve will continue to waste cycles exactly as bug(fullsolve): QA loop re-runs /qa with no state change instead of escalating same-SHA same-verdict cycles #581 reports. Once wired, the parsing bug (readDirtyExcludingState strips path bytes from unstaged-modified lines) will misclassify worktree state and either (a) treat a state-file write as a real progress diff, defeating AC-2's exclusion guarantee, or (b) more rarely, miss a real diff in .sequant/-prefixed paths if the prefix happens to land in the chopped 3 bytes.
    • Not tested: detectStagnation's 5 decision branches; recordStagnation's state mutation; compareLoopProgress's set comparison; the porcelain parser. AC-4 explicitly required the integration test that would have caught the parser bug on the first pass.
    • Sibling sites considered: none — the parsing logic in readDirtyExcludingState is single-instance in this file/module. compareLoopProgress is a downstream consumer (different shape), not a sibling.

    Adversarial Re-Read

    # Sub-prompt Finding
    1 Verbatim fixtures Issue body has no fenced code blocks under non-Setup headings and no **Verify:**/**Repro:** snippets. The blockquoted line ("Re-running /qa 570 without first applying...") and the SHA cb77c8e6 table are prose context, not test fixtures.
    2 Evidence framing The smoke-test execution above is post-implementation validation, not a pre-fix bug repro. The parsing-bug evidence (rc/lib/workflow/state-schema.ts in snapshot output) is a live runtime observation, not a hypothesis.
    3 Process state git status shows: 1 modified (state-schema.ts), 2 untracked (qa-stagnation.ts × 2). git rev-parse HEAD == origin/main. Nothing committed — the entire Phase 1 work would be lost if the worktree were destroyed.
    4 Sibling sites See Section 5. None — parser is single-instance.
    5 Out-of-scope/Non-Goals Issue Non-Goals: keep MAX_QA_ITERATIONS=2, no auto-applying recommendations, no QA verdict algorithm changes. Implementation touches none of these (it touches almost nothing yet). When SKILL.md wiring lands, verify the gate is additive to the iteration cap, not a replacement.

    Findings: Two structural gaps were missed by the in-section AC reviews:

    1. Live parsing bug in the helper — caught only by running the CLI shim, not by reading the diff. AC-4's missing integration test is the tool that should have caught this.
    2. Zero commits on branch — the entire diff is uncommitted, which means /loop's no-diff detection (AC-2) would also flag this state. Worth committing Phase 1 before continuing.

    Status: Severe Gap (verbatim per Section 6d: "AC marked MET on the basis of code review without the runtime / corpus check the AC's text required" — AC-3's "Verification: Unit Test" was not satisfied; AC-4's integration test was the AC).


    Verdict: AC_NOT_MET

    Why: 4 of 5 ACs are unmet and the 5th is partially met. The implementation completed Phase 1 of the spec plan (helper module + CLI shim + schema extension) but skipped Phases 2–5 (fullsolve wiring, /loop wiring, mirror docs, integration test). Without the SKILL.md edits the orchestrator never invokes the helper, so the original bug (/fullsolve 570 running 3 same-SHA same-verdict QA cycles) would still occur today. Plus a confirmed parsing bug in readDirtyExcludingState would defeat AC-2's stated state-file exclusion when the helper is eventually wired up.

    Per the verdict algorithm: not_met_count > 0 → AC_NOT_MET (no further gates evaluated).

    Documentation

    • N/A — verdict is AC_NOT_MET; documentation deferred.

    Next Steps

    1. Commit Phase 1 (state-schema.ts + both qa-stagnation.ts files) so the helper has a stable base and /loop doesn't see "no diff" on its own working tree.
    2. Fix the parsing bug in readDirtyExcludingState (src/lib/workflow/qa-stagnation.ts:209-220): either drop the .trim() and use line.slice(3) directly on raw porcelain lines, or migrate to --porcelain=v2 with explicit field parsing. Verify with the same npx tsx scripts/qa-stagnation.ts snapshot smoke test.
    3. Wire AC-1 into fullsolve — edit .claude/skills/fullsolve/SKILL.md §4.3 to invoke npx tsx scripts/qa-stagnation.ts detect <issue> before each Skill(skill: "qa") after iteration 1, and react to stagnant: true per the spec plan.
    4. Wire AC-2 into /loop — edit .claude/skills/loop/SKILL.md to call snapshot before the fix attempt and compare-snapshot after, exiting LOOP_NO_DIFF when not progressed.
    5. Mirror Steps 3 + 4 to templates/skills/ and skills/ per AC-5; respect the loop-skill drift caveat (don't reconcile the missing Orchestration Context section in this issue).
    6. Write src/lib/workflow/qa-stagnation.test.ts per AC-4 — table-driven unit tests for detectStagnation's decision matrix plus an integration test that drives the QA-loop helper with a stub /loop returning no diff and asserts halt at iteration 1 (not MAX_QA_ITERATIONS).
    7. Wire recordStagnation at the detection site so AC-3's telemetry actually lands in .sequant/state.json.
    8. Add a CHANGELOG entry to [Unreleased] once the wiring lands.
  5. added
    needs-work
    and removed
    planned
    on May 6, 2026
  6. admarble commented on May 7, 2026

    @admarble
    ContributorAuthor

    QA Review for Issue #581

    AC Coverage

    AC Source Description Status Notes
    AC-1 Original Pre-/qa no-progress gate in fullsolve QA loop MET All 3 fullsolve SKILL.md mirrors (.claude/skills/, skills/, templates/skills/) wire npx tsx scripts/qa-stagnation.ts detect <issue-number> at §4.3 before each /qa re-invocation when qa_iteration > 0; halts with SAME_SHA_NO_PROGRESS and records telemetry.
    AC-2 Original Post-/loop no-diff guard MET All 3 loop SKILL.md mirrors gain a new "Step 5.5: No-Diff Guard" section; snapshotLoopProgress brackets Step 5; compareLoopProgress returns LOOP_NO_DIFF when neither HEAD nor working-tree (excluding .sequant/) changed; halt with manual-intervention exit. readDirtyExcludingState correctly slices XY-prefixed porcelain output (no trim corruption); test preserves leading-space paths confirms.
    AC-3 Original Stagnation telemetry in .sequant/state.json MET Additive QAStagnationEntrySchema + qaStagnation: QAStagnationEntry[]? on IssueStateSchema. recordStagnation() invoked from CLI shim's record subcommand, which both fullsolve §4.3 and loop Step 5.5 invoke. Unit tests cover persistence, additive append (2 entries), missing-issue throw, and additive-schema preservation.
    AC-4 Original Integration test for no-progress halt MET New src/lib/workflow/qa-stagnation.test.ts (26 tests, 17 KB). Integration suite drives the qa-loop logic against a real temp git worktree with stub /loop returning no diff; asserts halt at iteration 1 with qaInvocations==1 (NOT MAX_QA_ITERATIONS=2) and reason==LOOP_NO_DIFF. Additional cases: write-then-revert, multi-iteration progress to MAX_ITERATIONS, READY_FOR_MERGE on first try, and direct detectStagnation SAME_SHA_NO_PROGRESS coverage on a real worktree.
    AC-5 Original Documentation across three skill mirrors MET New escalation docs landed in canonical .claude/skills/{fullsolve,loop}/SKILL.md and mirrored verbatim to templates/skills/ and skills/. grep -c "Step 5.5: No-Diff Guard" returns 1 in each loop mirror; grep -c "qa-stagnation.ts detect" returns 2 in each fullsolve mirror. Pre-existing drift in OTHER sections (Orchestration Context block in loop mirrors, Step 1 wording) was deliberately left untouched per the spec note "full reconciliation is out of scope."

    Coverage: 5/5 AC items fully met
    Original ACs: 5/5 met
    Derived ACs: 0 (none specified)


    Quality Plan Verification

    N/A — No Feature Quality Planning section in spec comment (Standard tier).


    CI Status

    No PR exists yet (will be created in Phase 5). CI not yet run.


    Quality Metrics

    Metric Value Status
    Type issues (any) 0 OK
    Deleted tests 0 OK
    Files changed 11 OK
    Lines added +1242 -
    Lines deleted -3 -
    Commits on branch 3 (0877fb5, a07c4a1, dc473b2) OK
    Tests passing 26/26 (qa-stagnation.test.ts) OK
    Build PASS OK
    lint:skill-calls No violations OK

    Code Review

    Strengths:

    • detectStagnation is a pure function (no I/O), separately testable from CLI side effects — 7-branch decision tree, all branches covered.
    • readDirtyExcludingState correctly handles porcelain v1 quirks: raw slice(3) (not trim), rename arrow extraction, and .sequant/ filter — comment explains the bug it's avoiding.
    • CLI shim and SKILL.md invoke the same TypeScript helpers, so unit tests prove the runtime path; no markdown-only logic that could drift undetected.
    • State schema change is additive (qaStagnation?: QAStagnationEntry[]), preserving older state files; recordStagnation correctly uses withLock for concurrency.
    • Integration suite uses real git init temp repos rather than mocking git — high-fidelity coverage of the actual code paths.
    • New SKILL.md sections use the same pseudo-code style as the surrounding fullsolve §4.3 and loop Steps 4–7.

    Issues:

    • None blocking.

    Suggestions:

    • (Future) The stagnation gate could record a qaStagnation entry even when the gate halts (currently the SKILL.md pseudo-code calls record only on SAME_SHA_NO_PROGRESS, and /loop's LOOP_NO_DIFF exit also calls record); both paths are now covered. Consider a follow-up to surface qaStagnation history in /assess output.
    • (Future) The compareLoopProgress "same path in both dirty sets = no progress" simplification is fine for the orchestrator's invariant (loop starts on a clean tree), but documenting that invariant in the helper's JSDoc would help future readers.

    Test Quality Review

    Category Status Notes
    Behavior vs Implementation OK Asserts on stagnant, reason, progressed, qaInvocations (outputs), not internals.
    Coverage Depth OK 7 detectStagnation branches, 5 compareLoopProgress paths, 4 snapshot edge cases (incl. .sequant exclusion + leading-space porcelain), 4 recordStagnation cases, 4 integration scenarios.
    Mock Hygiene OK No mocks of git or fs — real git init temp repos.
    Test Reliability OK No timing dependencies; deterministic.

    Anti-Pattern Detection

    Code Patterns

    File:Line Category Pattern Suggestion
    src/lib/workflow/qa-stagnation.ts:215 Performance execSync synchronous I/O in helper Acceptable per feedback_sync_io_acceptable.md — single-shot CLI helper, not hot path.

    Critical Issues: 0
    Warnings: 0


    Call-Site Review

    New exported functions detected: 6 (detectStagnation, recordStagnation, readHeadSha, readIsDirty, snapshotLoopProgress, compareLoopProgress)

    Function Call Sites Loop? Conditions AC Match
    detectStagnation scripts/qa-stagnation.ts:87 (CLI detect); qa-stagnation.test.ts (10 unit + 1 integration) No Always after iteration 0 in fullsolve §4.3 ✅ Matches AC-1 ("only on iteration ≥ 2")
    recordStagnation scripts/qa-stagnation.ts:115 (CLI record); 4 unit tests No After detection of stagnant=true OR LOOP_NO_DIFF ✅ Matches AC-3 (telemetry)
    snapshotLoopProgress scripts/qa-stagnation.ts:127 (CLI snapshot); 4 tests No Bracketing Step 5 in loop SKILL.md ✅ Matches AC-2
    compareLoopProgress scripts/qa-stagnation.ts:142 (CLI compare-snapshot); 5 unit + 3 integration tests No After Step 5 in loop SKILL.md ✅ Matches AC-2
    readHeadSha, readIsDirty Used by detectStagnation callers + tests No Always ✅ Helpers, no AC constraint

    Findings: All call sites match AC constraints. No dead exports.


    Execution Evidence

    Test Type Command Exit Code Result
    Test suite npx vitest run src/lib/workflow/qa-stagnation.test.ts 0 26/26 passed
    Build npm run build 0 tsc clean
    Skill-call lint npm run lint:skill-calls 0 No violations
    Integration (real git init temp repo, stub /loop, asserts halt at iteration 1) 0 Halts with reason=LOOP_NO_DIFF, qaInvocations=1

    Evidence status: Complete


    Skill Command Verification

    Skill files changed: 6 (3 fullsolve + 3 loop mirrors)

    File Commands Found Verification Status
    .claude/skills/fullsolve/SKILL.md 2 (detect, record) ✅ Skipped (placeholders <issue-number>) — syntax verified, JSON shape matches CLI shim output
    skills/fullsolve/SKILL.md 2 ✅ Skipped (mirror)
    templates/skills/fullsolve/SKILL.md 2 ✅ Skipped (mirror)
    .claude/skills/loop/SKILL.md 4 (snapshot, compare-snapshot, record, jq parse) ✅ Skipped (placeholders) — snapshot and compare-snapshot smoke-tested via 9 unit tests against the same code path
    skills/loop/SKILL.md 4 ✅ Skipped (mirror)
    templates/skills/loop/SKILL.md 4 ✅ Skipped (mirror)

    Commands verified:

    • npx tsx scripts/qa-stagnation.ts snapshot → returns {sha, dirty} JSON (covered by snapshotLoopProgress tests)
    • npx tsx scripts/qa-stagnation.ts compare-snapshot <before> <after> → returns {progressed, reason, message} JSON (covered by compareLoopProgress tests)
    • detect and record require live GitHub issue + state.json — covered by unit tests on the underlying functions.

    Verification Status: Skipped (placeholders) — equivalent to Passed for verdict purposes.


    CLI Registration Verification

    N/A — No RunOptions or other CLI option interface changes. The new scripts/qa-stagnation.ts is a script invoked directly via npx tsx, not a sub-command.


    Skill Change Review

    • Command verified: snapshot and compare-snapshot exercised via 9 tests; detect and record exercised via unit tests on detectStagnation / recordStagnation.
    • Fields verified: JSON output shapes (stagnant, reason, progressed, message) match CLI consumer expectations (jq filter .progressed in loop SKILL.md).
    • Patterns complete: Both halt reasons (SAME_SHA_NO_PROGRESS, LOOP_NO_DIFF) covered; stagnation gate skipped on iteration 0 (no prior marker possible).
    • Dependencies explicit: npx tsx, gh (for marker fetch in detect), jq (for SKILL.md JSON parsing). All standard sequant prerequisites.

    Smoke Test

    Test Command Result Notes
    Happy path npx vitest run src/lib/workflow/qa-stagnation.test.ts ✅ PASS 26/26
    Build npm run build ✅ PASS tsc clean
    Lint guard npm run lint:skill-calls ✅ PASS No violations
    Mirror parity (new section) grep -c "Step 5.5: No-Diff Guard" .claude/skills/loop/SKILL.md skills/loop/SKILL.md templates/skills/loop/SKILL.md ✅ PASS All return 1
    Mirror parity (full file) diff -q .claude/skills/fullsolve/SKILL.md skills/fullsolve/SKILL.md templates/skills/fullsolve/SKILL.md ✅ PASS All identical

    Smoke Test Status: Complete


    CHANGELOG Verification

    Check Status
    CHANGELOG.md exists ✅ Found
    User-facing changes ✅ Yes (workflow behavior change)
    [Unreleased] entry ✅ Present (commit a07c4a1)
    Entry format ✅ Includes issue number (#581), under Fixed

    Result: CHANGELOG requirements met.


    Self-Evaluation

    • Verified working: YES — 26 tests pass against real git init temp repos; the integration suite proves qaInvocations==1 when /loop returns no diff (NOT MAX_QA_ITERATIONS=2). The new SAME_SHA_NO_PROGRESS-on-real-worktree test directly exercises the resumption path.
    • Test efficacy: HIGH — integration tests use real git operations, not mocks of git itself; assertions check behavior (qaInvocations, reason, halted) not implementation details.
    • Likely failure mode: The SKILL.md uses literal <issue-number> placeholders that the orchestrator must substitute. If a future refactor breaks the substitution, the gate would silently no-op (the script would error with usage; the loop would proceed). Mitigation: same placeholder convention as the rest of fullsolve §4.3, which is exercised every fullsolve run.
    • Verdict confidence: HIGH

    Verdict: READY_FOR_MERGE

    All 5 ACs literally met (verified via grep + test execution against the helper code paths). Code quality is high: pure-function decision logic, additive schema, real-worktree integration tests, six-mirror SKILL.md parity for new section, no type any, no deleted tests, CHANGELOG entry present, lint clean, build clean.

    The implementation directly addresses the #570 incident pattern documented in the issue body — a future fullsolve invocation that would have wasted 3 cycles on identical SHA / identical AC_NOT_MET verdicts will now halt at iteration 1 with a clear SAME_SHA_NO_PROGRESS or LOOP_NO_DIFF message, surface telemetry to .sequant/state.json, and require manual intervention rather than silently consuming MAX_QA_ITERATIONS.

    Documentation

    Next Steps

    1. Create PR (Phase 5 of /fullsolve).

  7. admarble commented on May 7, 2026

    @admarble
    ContributorAuthor

    /fullsolve Complete

    Issue: #581
    Status: READY_FOR_MERGE
    PR: #591

    Summary

    • AC: 5/5 met
    • Tests: 26/26 passing (src/lib/workflow/qa-stagnation.test.ts)
    • Build: PASS
    • lint:skill-calls: No violations
    • CHANGELOG: Updated

    Iterations

    • Spec loop: 1 (resumed from prior spec:completed marker)
    • QA loop: 2 (initial AC_NOT_MET → /loop applied Phases 2–5 → READY_FOR_MERGE)

    Workflow Resume Path

    1. Resumed from prior session: spec:completed + qa:failed (AC_NOT_MET) markers detected
    2. Worktree fast-forwarded twice to keep up with main during the session (feat(#569): /qa relaxes md-only diffs from pending CI build matrix #588, feat(#587): /qa §4 Q5 intra-file sibling-site audit + cross-file §5 reframe #589, feat(#568): lint:skill-calls CI guard for unqualified Skill() collisions #590 landed mid-flight)
    3. /loop applied missing Phase 2–5 work: canonical .claude/skills/fullsolve/SKILL.md wiring, all 3 loop/SKILL.md mirrors with new Step 5.5, consolidated unit + integration test (24 tests)
    4. Adversarial re-read of test suite caught a misleading test name + missing SAME_SHA_NO_PROGRESS integration coverage → 2 additional tests added (final: 26/26)
    5. CHANGELOG entry added under [Unreleased] > Fixed
    6. /qa re-run posted READY_FOR_MERGE with literal AC verification across all 5 ACs

    Commits on Branch


    Ready for human review and merge.

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

    bugneeds-work

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions