End-to-end test-fix workflow generate test sessions with progressive layers (L0-L3), then execute iterative fix cycles until pass rate >= 95%...
End-to-end test-fix workflow pipeline: generate test sessions with progressive layers (L0-L3), AI code validation, and task generation (Phase 1), then execute iterative fix cycles with adaptive strategy engine until pass rate >= 95% (Phase 2).
ββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ
β Workflow Test-Fix Cycle Orchestrator (SKILL.md) β
β β Full pipeline: Test generation + Iterative execution β
β β Phase dispatch: Read phase docs, execute, pass context β
βββββββββββββββββ¬βββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ
β
ββββββββββββββ΄βββββββββββββββββββββββββ
β β
βββββββββββββββββββββββββββ βββββββββββββββββββββββββββββββ
β Phase 1: Test-Fix Gen β β Phase 2: Test-Cycle Execute β
β phases/01-test-fix-gen β β phases/02-test-cycle-execute β
β 5 sub-phases: β β 3 stages: β
β β Create Session β β β Discovery β
β β‘ Gather Context β β β‘ Main Loop (iterate) β
β β’ Test Analysis (Gemini)β β β’ Completion β
β β£ Generate Tasks β β β
β β€ Summary β β Agents (via spawn_agent): β
β β β @cli-planning-agent β
β Agents (via spawn_agent)β β @test-fix-agent β
β @test-context-search β β β
β @context-search β β Strategy: conservative β β
β @cli-execution β β aggressive β surgical β
β @action-planning β β β
ββββββββββ¬βββββββββββββββββ ββββββββββββββ¬βββββββββββββββββββ
β β
IMPL-001..002.json Pass Rate >= 95%
TEST_ANALYSIS_RESULTS.md Auto-complete session
Task Pipeline:
ββββββββββββββββ βββββββββββββββββββ βββββββββββββββββββ ββββββββββββββββ
β IMPL-001 ββββββ IMPL-001.3 ββββββ IMPL-001.5 ββββββ IMPL-002 β
β Test Gen β β Code Validate β β Quality Gate β β Test & Fix β
β L1-L3 β β L0 + AI Issues β β Coverage 80%+ β β Max 10 iter β
β@code-developerβ β @test-fix-agent β β @test-fix-agent β β@test-fix-agentβ
ββββββββββββββββ βββββββββββββββββββ βββββββββββββββββββ ββββββββββββββββ
β
Fix Loop: β
ββββββββββββββββββββ
β
ββββββββββββ
β @cli-planβββββ IMPL-fix-N.json
β agent β
ββββββββββββ€
β@test-fix βββββ Apply & re-test
β agent β
ββββββββββββ
Phase 1 generates test session and tasks. Phase 2 executes iterative fix cycles until pass rate >= 95% or max iterations reached. Between Phase 1 and Phase 2, you MUST stop and wait for user confirmation before proceeding to execution. Phase 2 runs autonomously once approved.
Create a new subagent with task assignment.
const agentId = spawn_agent({
agent_type: "{agent_type}",
message: `
## TASK ASSIGNMENT
### MANDATORY FIRST STEPS (Agent Execute)
1. Run: `ccw spec load --category "planning execution"`
## TASK CONTEXT
${taskContext}
## DELIVERABLES
${deliverables}
`
})
Get results from subagent (only way to retrieve results).
const result = wait_agent({
timeout_ms: 1800000 // 30 minutes
})
if (result.timed_out) {
followup_task({ target: agentId, message: "STATUS_CHECK: Report current progress, findings so far, and estimated remaining work." })
const status = wait_agent({ timeout_ms: 180000 }) // 3 min
if (status.timed_out) {
followup_task({ target: agentId, message: "FINALIZE: Output all current findings immediately. Time limit reached.", interrupt: true })
const forced = wait_agent({ timeout_ms: 180000 }) // 3 min
if (forced.timed_out) {
close_agent({ target: agentId })
}
}
}
Assign new work to active subagent (for clarification or follow-up).
followup_task({
target: agentId,
message: `
## CLARIFICATION ANSWERS
${answers}
## NEXT STEP
Continue with plan generation.
`
})
Clean up subagent resources (irreversible).
close_agent({ target: agentId })
workflow-test-fix-cycle <input> [options]
# Input (Phase 1 - Test Generation)
source-session-id WFS-* session ID (Session Mode - test validation for completed implementation)
feature description Text description of what to test (Prompt Mode)
/path/to/file.md Path to requirements file (Prompt Mode)
# Options (Phase 2 - Cycle Execution)
--max-iterations=N Custom iteration limit (default: 10)
# Examples
workflow-test-fix-cycle WFS-user-auth-v2 # Session Mode
workflow-test-fix-cycle "Test the user authentication API endpoints in src/auth/api.ts" # Prompt Mode - text
workflow-test-fix-cycle ./docs/api-requirements.md # Prompt Mode - file
workflow-test-fix-cycle "Test user registration" --max-iterations=15 # With custom iterations
# Resume (Phase 2 only - session already created)
workflow-test-fix-cycle --resume-session="WFS-test-user-auth" # Resume interrupted session
Quality Gate: Test pass rate >= 95% (criticality-aware) or 100% Max Iterations: 10 (default, adjustable) CLI Tools: Gemini β Qwen β Codex (fallback chain)
Progressive Test Layers (L0-L3):
| Layer | Name | Focus |
|---|---|---|
| L0 | Static Analysis | Compilation, imports, types, AI code issues |
| L1 | Unit Tests | Function/class behavior (happy/negative/edge cases) |
| L2 | Integration Tests | Component interactions, API contracts, failure modes |
| L3 | E2E Tests | User journeys, critical paths (optional) |
Key Features:
Detailed specifications: See the test-task-generate workflow tool for complete L0-L3 requirements and quality thresholds.
Input β Detect Mode (session | prompt | resume)
β
ββ resume mode β Skip to Phase 2
β
ββ session/prompt mode β Phase 1
β
Phase 1: Test-Fix Generation (phases/01-test-fix-gen.md)
ββ Sub-phase 1.1: Create Test Session β testSessionId
ββ Sub-phase 1.2: Gather Test Context (spawn_agent) β contextPath
ββ Sub-phase 1.3: Test Generation Analysis (spawn_agent β Gemini) β TEST_ANALYSIS_RESULTS.md
ββ Sub-phase 1.4: Generate Test Tasks (spawn_agent) β IMPL-*.json, IMPL_PLAN.md, TODO_LIST.md
ββ Sub-phase 1.5: Phase 1 Summary
β
β MANDATORY CONFIRMATION GATE
β Present plan summary β request_user_input β User approves/cancels
β NEVER auto-proceed to Phase 2
β
Phase 2: Test-Cycle Execution (phases/02-test-cycle-execute.md)
ββ Discovery: Load session, tasks, iteration state
ββ Main Loop (for each task):
β ββ Execute β Test β Calculate pass_rate
β ββ 100% β SUCCESS: Next task
β ββ 95-99% + low criticality β PARTIAL SUCCESS: Approve
β ββ <95% β Fix Loop:
β ββ Select strategy: conservative/aggressive/surgical
β ββ spawn_agent(@cli-planning-agent) β IMPL-fix-N.json
β ββ spawn_agent(@test-fix-agent) β Apply fix & re-test
β ββ Re-test β Back to decision
ββ Completion: Final validation β Summary β Sync session state β Auto-complete session
functions.update_plan initializationphases/01-*.md, phases/02-*.md)Read: phases/01-test-fix-gen.md
5 sub-phases that create a test session and generate task JSONs:
testSessionIdcontextPathTEST_ANALYSIS_RESULTS.mdIMPL-001.json, IMPL-001.3.json, IMPL-001.5.json, IMPL-002.json, IMPL_PLAN.md, TODO_LIST.mdAgents Used (via spawn_agent):
test_context_search_agent (agent_type: test_context_search_agent) - Context gathering (Session Mode)context_search_agent (agent_type: context_search_agent) - Context gathering (Prompt Mode)cli_execution_agent (agent_type: cli_execution_agent) - Test analysis with Geminiaction_planning_agent (agent_type: action_planning_agent) - Task JSON generationRead: phases/02-test-cycle-execute.md
3-stage iterative execution with adaptive strategy:
Agents Used (via spawn_agent):
cli_planning_agent (agent_type: cli_planning_agent) - Failure analysis, root cause extraction, fix task generationtest_fix_agent (agent_type: test_fix_agent) - Test execution, code fixes, criticality assignmentStrategy Engine: conservative (iteration 1-2) β aggressive (pass >80%) β surgical (regression)
{projectRoot}/.workflow/active/WFS-test-[session]/
βββ workflow-session.json # Session metadata
βββ IMPL_PLAN.md # Test generation and execution strategy
βββ TODO_LIST.md # Task checklist
βββ .task/
β βββ IMPL-001.json # Test understanding & generation
β βββ IMPL-001.3-validation.json # Code validation gate
β βββ IMPL-001.5-review.json # Test quality gate
β βββ IMPL-002.json # Test execution & fix cycle
β βββ IMPL-fix-{N}.json # Generated fix tasks (Phase 2)
βββ .process/
β βββ [test-]context-package.json # Context and coverage analysis
β βββ TEST_ANALYSIS_RESULTS.md # Test requirements and strategy (L0-L3)
β βββ iteration-state.json # Current iteration + strategy + stuck tests
β βββ test-results.json # Latest results (pass_rate, criticality)
β βββ test-output.log # Full test output
β βββ fix-history.json # All fix attempts
β βββ iteration-{N}-analysis.md # CLI analysis report
β βββ iteration-{N}-cli-output.txt
βββ .summaries/iteration-summaries/
// Initialize progress tracking after input parsing
functions.update_plan([
{ id: "phase-1", title: "Phase 1: Test-Fix Generation", status: "in_progress" },
{ id: "phase-2", title: "Phase 2: Test-Cycle Execution", status: "pending" }
])
// After Phase 1 completes (before mandatory confirmation gate)
functions.update_plan([
{ id: "phase-1", status: "completed" },
{ id: "phase-2", status: "in_progress" }
])
// After Phase 2 completes (pass rate >= 95% or max iterations)
functions.update_plan([{ id: "phase-2", status: "completed" }])
// When --resume-session skips Phase 1
functions.update_plan([
{ id: "phase-1", title: "Phase 1: Test-Fix Generation", status: "completed" },
{ id: "phase-2", title: "Phase 2: Test-Cycle Execution", status: "in_progress" }
])
| Phase | Scenario | Action |
|---|---|---|
| 1.1 | Source session not found (session mode) | Return error with session ID |
| 1.1 | No completed IMPL tasks (session mode) | Return error, source incomplete |
| 1.2 | Context gathering failed | Return error, check source artifacts |
| 1.2 | Agent timeout | Retry with extended timeout, close_agent, then return error |
| 1.3 | Gemini analysis failed | Return error, check context package |
| 1.4 | Task generation failed | Retry once, then return error |
| 2 | Test execution error | Log, retry with error context |
| 2 | CLI analysis failure | Fallback: Gemini β Qwen β Codex β manual |
| 2 | Agent execution error | Save state, close_agent, retry with simplified context |
| 2 | Max iterations reached | Generate failure report, mark blocked |
| 2 | Regression detected | Rollback last fix, switch to surgical strategy |
| 2 | Stuck tests detected | Continue with alternative strategy, document in failure report |
Lifecycle Error Handling:
try {
const agentId = spawn_agent({ message: "..." });
const result = wait_agent({ timeout_ms: 1800000 }); // 30 minutes
// ... process result ...
close_agent({ target: agentId });
} catch (error) {
if (agentId) close_agent({ target: agentId });
throw error;
}
Phase 1 (Generation):
functions.update_plan with 2 top-level phasesphases/01-test-fix-gen.md for detailed sub-phase executionPhase 2 (Execution):
phases/02-test-cycle-execute.md for detailed execution logicfunctions.update_planResume Mode:
--resume-session provided, skip Phase 1Prerequisite Skills:
workflow-plan or workflow-execute - Complete implementation (Session Mode)Phase 1 Agents (used by phases/01-test-fix-gen.md via spawn_agent):
test_context_search_agent (agent_type: test_context_search_agent) - Test coverage analysis (Session Mode)context_search_agent (agent_type: context_search_agent) - Codebase analysis (Prompt Mode)cli_execution_agent (agent_type: cli_execution_agent) - Test requirements with Geminiaction_planning_agent (agent_type: action_planning_agent) - Task JSON generationPhase 2 Agents (used by phases/02-test-cycle-execute.md via spawn_agent):
cli_planning_agent (agent_type: cli_planning_agent) - CLI analysis, root cause extraction, task generationtest_fix_agent (agent_type: test_fix_agent) - Test execution, code fixes, criticality assignmentFollow-up:
$session-sync -y "Test-fix cycle complete: {pass_rate}% pass rate"