Repository navigation
Description
Problem
When QA returns AC_NOT_MET, the quality loop retries consistently fail and burn the entire retry budget on doomed invocations. This was observed on a real run (bf4b66d0, issue #125 in the workout project) and is reproducible for any issue where QA finds unimplemented ACs.
Failure chain
- QA fails with
AC_NOT_MET(5m 19s — genuine work) - Quality loop invokes
/loopwith bare prompt:"Parse test/QA findings for GitHub issue #N and iterate until quality gates pass." /loopruns for ~51s — Claude Code starts, skill tries to parse QA findings from GitHub comments, but exits with code 1- 51s < 60s cold-start threshold →
executePhaseWithRetrymisclassifies this as a cold-start failure and retries - Cold-start retries fail the same way → MCP fallback fires → also fails
- Loop phase exhausted → next quality loop iteration starts from
testgen testgenalso fails in ~47-49s with exit code 1 → same misclassification cascade- All 3 iterations burned on retries that can never succeed
Root causes
1. The /loop prompt has no context (phase-executor.ts:36)
The prompt is a single line. The /loop skill must reconstruct all context by fetching QA findings from GitHub comments via gh issue view, but it's running in a new Claude Code subprocess with no prior session. If the gh call fails or comment format doesn't match, it crashes. The QA verdict, failed ACs, and specific findings should be passed directly in the prompt or via env vars.
2. Cold-start threshold catches real failures (phase-executor.ts:105,570)
The 60s threshold was tuned for initialization failures (empirically 15-39s). But loop/testgen retries that fail at 47-51s fall in the same bucket, triggering up to 2 cold-start retries + 1 MCP fallback = 3 extra doomed invocations per phase. For a 3-iteration quality loop, that's 9+ wasted Claude Code spawns.
Impact
- Users see a wall of
✖failures with unhelpful "Claude Code process exited with code 1" errors - Entire quality loop budget wasted — no fixes are ever attempted
- Each wasted spawn costs ~50s of wall time + API usage
- The "retrying without MCP" message is misleading — MCP isn't the problem
Proposed fixes
1. Enrich the loop prompt (high impact)
At batch-executor.ts:853, pass the QA verdict and failed ACs directly into the prompt. The QA phase result already has the verdict field; the issue comment body could be fetched once and injected as context. This eliminates the round-trip through GitHub that causes the skill to crash.
2. Distinguish loop failures from cold-starts (medium impact)
Options:
- Skip cold-start retries for
loopphase (it's always a re-run, never a first boot) - Use a phase-aware threshold (loop/testgen retries in quality loop context aren't cold-starts)
- Track whether the failure is a retry of a previously-failed phase
3. Pass last phase result via env vars (low effort)
Add SEQUANT_LAST_VERDICT and SEQUANT_FAILED_ACS env vars so the loop skill doesn't need to reconstruct context from GitHub comments.
Relevant code
- Phase prompts:
src/lib/workflow/phase-executor.ts:25-39 - Cold-start threshold:
src/lib/workflow/phase-executor.ts:105 - Cold-start retry logic:
src/lib/workflow/phase-executor.ts:548-587 - MCP fallback:
src/lib/workflow/phase-executor.ts:592-636 - Quality loop invocation:
src/lib/workflow/batch-executor.ts:830-898 - Loop skill:
.claude/skills/loop/SKILL.md
Acceptance Criteria
-
/loopphase receives QA findings directly (verdict + failed ACs) rather than reconstructing from GitHub - Quality loop retry failures (47-51s) are not misclassified as cold-start failures
- Wasted Claude Code spawns reduced from 9+ to ≤1 per quality loop iteration
- MCP fallback does not trigger for non-MCP failures
- Quality loop can actually fix issues when ACs are unmet (the core purpose of the feature)
Activity
fix(#488): prevent loop phase retry misclassification as cold-start
admarble commentedon Apr 6, 2026
/fullsolve Complete
Issue: #488
Status: READY_FOR_MERGE
AC Coverage
/loopreceives QA findings directly (verdict + gaps)Summary
executePhaseWithRetrynow skips cold-start retry loop and MCP fallback forloopphasepromptContextSEQUANT_LAST_VERDICTandSEQUANT_FAILED_ACSenv vars propagated to skillsQuality Metrics
Iterations
PR: #489
Ready for human review and merge.
admarble commentedon Apr 6, 2026
QA Review for Issue #488
PR: #489 — fix(#488): prevent loop phase retry misclassification as cold-start
Commit: 9bfea4d | Branch: feature/488-quality-loop-retry-misclassification
Scope: 4 files, +211/-26 lines
Size Gate
AC Coverage
/loopreceives QA findings directly (verdict + gaps)buildLoopContext()enriches prompt with verdict, gaps, suggestions, error, output tail.SEQUANT_LAST_VERDICTandSEQUANT_FAILED_ACSenv vars also set.skipColdStartRetry = phase === "loop"gates single-attempt path. Test at line 952 verifies.!skipColdStartRetryguard at line 637 prevents MCP fallback for loop phase. Test at line 973 verifies./loopskill — no round-trip through GitHub.Coverage: 5/5 AC items fully met
Quality Plan Verification
N/A — No quality plan found in issue comments
CI Status
build (22.x)733bf55)build (20.x)typecheckvalidate-pluginvalidate-skillsCI Summary: 3 passed, 2 pre-existing failures (verified against main)
CI-related AC items: None
Build Verification
tsc)src/mcp/tools/run.tserrors)Quality Metrics
any)Test Coverage Analysis
src/lib/workflow/phase-executor.tsphase-executor.test.ts(4 new tests)src/lib/workflow/batch-executor.tsbatch-executor.test.ts(existing)src/lib/workflow/types.tssrc/lib/workflow/phase-executor.test.tsCoverage: All changed source files have corresponding tests
Critical paths without tests: None
Code Review
Strengths:
buildLoopContext()is a pure function composing prompt context fromPhaseResultslice(-2000)truncates output tailgetPhasePrompttest verifies end-to-end context propagationIssues: None blocking.
Suggestions:
slice(-2000)). Consider extracting to a named constant for discoverability — not blocking.Test Quality Review
executePhaseFninjected — minimal mockingAnti-Pattern Detection
No anti-patterns detected:
CLI Registration Verification
Option files modified: Yes (
types.ts—ExecutionConfiginterface)promptContextconfig.promptContext(internal)mergedOptionsusage)lastVerdictconfig.lastVerdict(internal)mergedOptionsusage)failedAcsconfig.failedAcs(internal)mergedOptionsusage)Verification Status: N/A — all new fields are internal-only (set programmatically in
batch-executor.ts, not user-facing)Call-Site Review
N/A — No new exported functions.
buildLoopContext()is module-private.Self-Evaluation
tsc --noEmit), 72/72 tests pass, reviewed all code pathsphase === "loop"check wouldn't cover it. A set/config approach would be more extensible, but YAGNI for now.CHANGELOG Verification
fix:commit — affects quality loop behavior)CHANGELOG: Missing entry for user-facing bug fix. Add to
## [Unreleased]→### Fixedsection before merging.Verdict: AC_MET_BUT_NOT_A_PLUS
All 5 ACs are fully met. Code is clean, well-tested, and architecturally sound. The fix is surgical — only the loop phase behavior changes, existing retry logic for other phases is untouched.
Blocking merge: Missing CHANGELOG entry for this user-facing bug fix.
Next Steps
## [Unreleased]→### Fixed:Documentation: Before merging, run
/docs 488to generate feature documentation.test(#488): add buildLoopContext unit tests and CHANGELOG entry