You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
src/lib/workflow/phase-executor.ts is a core orchestration module (handles phase execution, cold-start retry, MCP fallback, QA verdict parsing) but has no dedicated test file. Discovered during QA of #371.
Goal
Add src/lib/workflow/phase-executor.test.ts covering the module's key functions.
Acceptance Criteria
Test parseQaVerdict() — all verdict formats (markdown header, bold, plain), case insensitivity, null on no match
Test formatDuration() — seconds-only, minutes+seconds edge cases
Test getPhasePrompt() — issue number substitution, AGENTS.md inclusion when present, graceful null when absent
Export getPhasePrompt with @internal tag rather than testing indirectly — simpler, more focused tests, matches existing executePhaseWithRetry precedent
Use injected executePhaseFn for retry tests — the seam already exists, no new mocking infrastructure needed
Mock readAgentsMd via vi.mock — follows agents-md.test.ts pattern
Only readAgentsMd mocked (external I/O); executePhaseFn injected via existing seam
Test Reliability
✅ OK
No timing dependencies, all deterministic
Anti-Pattern Detection
Dependency Audit
N/A — No dependency changes
Code Patterns
No anti-patterns detected in changed files.
Call-Site Review
New exported functions detected: 1 (getPhasePrompt)
Function
Call Sites
Loop?
Conditions
AC Match
getPhasePrompt()
phase-executor.ts:181 (internal)
No
Unconditional in executePhase
✅ @internal — exported for testing only, no new external callers
CHANGELOG Verification
Result: N/A — test-only change, no user-facing changes
Execution Evidence
N/A — No executable changes (test-only addition + minor export change)
Self-Evaluation
Verified working: Yes — ran npm test -- --run src/lib/workflow/phase-executor.test.ts and all 44 tests pass
Test efficacy: High — tests directly exercise the functions under test with specific assertions on return values; cold-start retry logic is thoroughly exercised through the injected executePhaseFn seam
Likely failure mode: If PHASE_PROMPTS or AIDER_PHASE_PROMPTS templates change, getPhasePrompt tests that assert on specific substrings (e.g., /spec 42, gh issue view) may need updating — this is expected and desirable (tests should break when prompt structure changes)
Verdict confidence: High — clean, focused test-only PR with full CI green
Verdict: READY_FOR_MERGE
All 6 AC items fully met. 44 unit tests covering parseQaVerdict, formatDuration, getPhasePrompt, and executePhaseWithRetry. Clean code review, no issues found. All CI checks pass.
Activity
admarble commentedon Mar 25, 2026
Spec Plan — #378: Add unit tests for phase-executor.ts
AC Checklist with Verification Criteria
AC-1: Test
parseQaVerdict()Verification Method: Unit Test
parseQaVerdict(input)is calledQaVerdictvalue, case-insensitively; returnsnullfor empty/no-matchAC-2: Test
formatDuration()Verification Method: Unit Test
formatDuration(seconds)is called"Xs"for <60,"Xm Ys"for ≥60; handles 0, fractional, exact minutesAC-3: Test
getPhasePrompt()Verification Method: Unit Test
getPhasePrompt()is called{issue}substituted; includes AGENTS.md when present; uses AIDER_PHASE_PROMPTS for non-claude agentsAC-4: Test
executePhaseWithRetry()Verification Method: Unit Test (injected
executePhaseFn)mcp: falseconfig.retry === false→ single call, no retryAC-5 (Derived): Export
getPhasePromptwith@internalJSDoc tagVerification Method: Code review — matches
executePhaseWithRetryprecedentAC-6 (Derived): Test
NEEDS_VERIFICATIONverdictVerification Method: Unit Test — 4th QaVerdict value coverage
Implementation Plan
Phase 1: Pure function tests
src/lib/workflow/phase-executor.test.tsparseQaVerdict()— all 4 verdict values × 4 formats + null casesformatDuration()— boundary at 60s, edge casesPhase 2: getPhasePrompt tests
4. Export
getPhasePromptwith@internaltag inphase-executor.ts5. Mock
readAgentsMdviavi.mock("../agents-md.js")6. Test issue substitution, AGENTS.md present/absent, agent prompt selection
Phase 3: executePhaseWithRetry tests
7. Test cold-start retry, MCP fallback, retry disabled, genuine failure, first-attempt success
Design Decisions
getPhasePromptwith@internaltag rather than testing indirectly — simpler, more focused tests, matches existingexecutePhaseWithRetryprecedentexecutePhaseFnfor retry tests — the seam already exists, no new mocking infrastructure neededreadAgentsMdviavi.mock— followsagents-md.test.tspatternNon-Goals
executePhase()directly (private, complex driver dependencies)PhaseSpinnerorShutdownManager(have their own test files)Recommended Workflow
Phases: exec → qa | Quality Loop: disabled
feat(#378): add unit tests for phase-executor.ts
admarble commentedon Mar 25, 2026
Exec Phase — Progress Update
AC Coverage
parseQaVerdict()formatDuration()getPhasePrompt()executePhaseWithRetry()getPhasePromptwith@internalphase-executor.ts:151NEEDS_VERIFICATIONverdictFiles Changed
src/lib/workflow/phase-executor.tsgetPhasePromptwith@internalJSDoc tagsrc/lib/workflow/phase-executor.test.tsQuality Gates
npm run buildnpm run lintnpm testPR
Created: #433
Quality Plan Alignment: N/A — No quality plan in issue
CHANGELOG: N/A (test-only change)
admarble commentedon Mar 25, 2026
QA Review for Issue #378
AC Coverage
parseQaVerdict()formatDuration()getPhasePrompt()executePhaseWithRetry()getPhasePromptwith@internaltag@internalJSDoc at line 145NEEDS_VERIFICATIONverdictCoverage: 6/6 AC items fully met
Original ACs: 4/4 met
Derived ACs: 2/2 met
Quality Plan Verification
N/A — No quality plan found in issue comments
CI Status
build (20.x)build (22.x)typecheckvalidate-skillsvalidate-pluginCI Summary: 5 passed, 0 pending, 0 failed
Stale Branch Check
Quality Metrics
any)Test Coverage Analysis
src/lib/workflow/phase-executor.tssrc/lib/workflow/phase-executor.test.tssrc/lib/workflow/phase-executor.test.tsCoverage: 1/1 changed source files have corresponding tests
Code Review
Strengths:
describeblocks map 1:1 to AC itemsexecutePhaseFninjection seam — no new mocking infrastructure neededvi.mock("../agents-md.js")follows established patterns (agents-md.test.ts)getPhasePromptwith@internaltag — clean, low-riskmakeResult()helper keepsexecutePhaseWithRetrytests readableIssues:
Suggestions:
Test Quality Review
readAgentsMdmocked (external I/O);executePhaseFninjected via existing seamAnti-Pattern Detection
Dependency Audit
N/A — No dependency changes
Code Patterns
No anti-patterns detected in changed files.
Call-Site Review
New exported functions detected: 1 (
getPhasePrompt)getPhasePrompt()phase-executor.ts:181(internal)executePhase@internal— exported for testing only, no new external callersCHANGELOG Verification
Result: N/A — test-only change, no user-facing changes
Execution Evidence
N/A — No executable changes (test-only addition + minor export change)
Self-Evaluation
npm test -- --run src/lib/workflow/phase-executor.test.tsand all 44 tests passexecutePhaseFnseamPHASE_PROMPTSorAIDER_PHASE_PROMPTStemplates change,getPhasePrompttests that assert on specific substrings (e.g.,/spec 42,gh issue view) may need updating — this is expected and desirable (tests should break when prompt structure changes)Verdict: READY_FOR_MERGE
All 6 AC items fully met. 44 unit tests covering
parseQaVerdict,formatDuration,getPhasePrompt, andexecutePhaseWithRetry. Clean code review, no issues found. All CI checks pass.Documentation
Next Steps
feat(#378): add unit tests for phase-executor.ts (#433)
admarble commentedon Mar 25, 2026
Documentation Generated
File:
docs/features/phase-executor-tests.mdSections Included:
Next Steps:
Ready to merge!
docs: generate feature docs for #377 and #378