From 25278371c3280662f18f75f1df95cbb8057aeb8c Mon Sep 17 00:00:00 2001 From: catlog22 Date: Fri, 13 Feb 2026 23:31:12 +0800 Subject: [PATCH] feat: convert test-fix-gen and test-cycle-execute commands to unified workflow-test-fix skill Merge two workflow commands into orchestrator+phases skill structure: - SKILL.md as pure coordinator with 2-phase architecture - Phase 1 (test-fix-gen): session creation, context gathering, test analysis, task generation - Phase 2 (test-cycle-execute): iterative fix loop with adaptive strategy engine, CLI fallback chain --- .claude/skills/workflow-test-fix/SKILL.md | 354 ++++++++++++ .../phases/01-test-fix-gen.md | 309 ++++++++++ .../phases/02-test-cycle-execute.md | 533 ++++++++++++++++++ 3 files changed, 1196 insertions(+) create mode 100644 .claude/skills/workflow-test-fix/SKILL.md create mode 100644 .claude/skills/workflow-test-fix/phases/01-test-fix-gen.md create mode 100644 .claude/skills/workflow-test-fix/phases/02-test-cycle-execute.md diff --git a/.claude/skills/workflow-test-fix/SKILL.md b/.claude/skills/workflow-test-fix/SKILL.md new file mode 100644 index 00000000..01c636db --- /dev/null +++ b/.claude/skills/workflow-test-fix/SKILL.md @@ -0,0 +1,354 @@ +--- +name: workflow-test-fix +description: Unified test-fix pipeline combining test generation (session, context, analysis, task gen) with iterative test-cycle execution (adaptive strategy, progressive testing, CLI fallback). Triggers on "workflow:test-fix-gen", "workflow:test-cycle-execute", "test fix workflow". +allowed-tools: Skill, Task, AskUserQuestion, TaskCreate, TaskUpdate, TaskList, Read, Write, Edit, Bash, Glob, Grep +--- + +# Workflow Test Fix + +Unified test-fix orchestrator that combines **test planning generation** (Phase 1) with **iterative test-cycle execution** (Phase 2) into a single end-to-end pipeline. Creates test sessions with progressive L0-L3 test layers, generates test tasks, then executes them with adaptive fix cycles until pass rate >= 95% or max iterations reached. + +## Architecture Overview + +``` +┌───────────────────────────────────────────────────────────────────────────┐ +│ Workflow Test Fix Orchestrator (SKILL.md) │ +│ → Pure coordinator: Route entry point, track progress, pass context │ +│ → Two phases: Generation (Phase 1) + Execution (Phase 2) │ +└──────────────────────────────────┬────────────────────────────────────────┘ + │ + ┌───────────────────────────┼────────────────────────────┐ + ↓ ↓ +┌──────────────────────┐ ┌──────────────────────┐ +│ Phase 1: Test Gen │ │ Phase 2: Test Cycle │ +│ (test-fix-gen) │─── testSessionId ───────→│ (test-cycle-execute)│ +│ │ │ │ +│ 1. Session Create │ │ 1. Discovery │ +│ 2. Context Gather │ │ 2. Initial Execute │ +│ 3. Test Analysis │ │ 3. Fix Loop │ +│ 4. Task Generation │ │ 4. Completion │ +│ 5. Summary │ │ │ +└──────────────────────┘ └──────────────────────┘ + sessionId pass_rate >= 95% + contextPath or max iterations + IMPL_PLAN.md + IMPL-*.json + +Task Pipeline (generated in Phase 1, executed in Phase 2): +┌──────────────┐ ┌─────────────────┐ ┌─────────────────┐ ┌──────────────┐ +│ 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 N iter │ +│@code-developer│ │ @test-fix-agent │ │ @test-fix-agent │ │@test-fix-agent│ +└──────────────┘ └─────────────────┘ └─────────────────┘ └──────────────┘ +``` + +## Key Design Principles + +1. **Unified Pipeline**: Generation and execution are one continuous workflow - no manual handoff +2. **Pure Orchestrator**: SKILL.md coordinates only - delegates all execution detail to phase files +3. **Auto-Continue**: Phase 1 completes → Phase 2 starts automatically +4. **Task Attachment/Collapse**: Sub-tasks attached during phase execution, collapsed after completion +5. **Progressive Phase Loading**: Phase docs read **only** when that phase executes, not upfront +6. **Adaptive Strategy**: Fix loop auto-selects strategy (conservative/aggressive/surgical) based on iteration context +7. **Quality Gate**: Pass rate >= 95% (criticality-aware) terminates the fix loop +8. **Original Commands Preserved**: Phase files preserve full original command content and Skill() calls + +## Usage + +```bash +# Full pipeline: generate + execute +/workflow:test-fix-gen "Test the user authentication API" +/workflow:test-fix-gen WFS-user-auth-v2 + +# Execute only (resume from existing test session with generated tasks) +/workflow:test-cycle-execute +/workflow:test-cycle-execute --resume-session="WFS-test-user-auth" +/workflow:test-cycle-execute --max-iterations=15 +``` + +## Auto Mode + +When `--yes` or `-y`: Auto-select first active session, skip confirmations, auto-complete on success. + +## Execution Flow + +``` +Entry Point Detection: + ├─ /workflow:test-fix-gen → Full Pipeline (Phase 1 → Phase 2) + └─ /workflow:test-cycle-execute → Execution Only (Phase 2) + +Phase 1: Test Generation (test-fix-gen) + └─ Ref: phases/01-test-fix-gen.md + ├─ Step 1.1: Detect input mode (session | prompt) + ├─ Step 1.2: Create test session → testSessionId + ├─ Step 1.3: Gather test context → contextPath + ├─ Step 1.4: Test analysis (Gemini) → TEST_ANALYSIS_RESULTS.md + ├─ Step 1.5: Generate test tasks → IMPL_PLAN.md, IMPL-*.json, TODO_LIST.md + └─ Output: testSessionId, 4+ task JSONs + → Auto-continue to Phase 2 + +Phase 2: Test Cycle Execution (test-cycle-execute) + └─ Ref: phases/02-test-cycle-execute.md + ├─ Step 2.1: Discovery (load session, tasks, iteration state) + ├─ Step 2.2: Execute initial tasks (IMPL-001 → 001.3 → 001.5 → 002) + ├─ Step 2.3: Fix loop (if pass_rate < 95%) + │ ├─ Select strategy: conservative/aggressive/surgical + │ ├─ Generate fix task via @cli-planning-agent + │ ├─ Execute fix via @test-fix-agent + │ └─ Re-test → loop or exit + └─ Step 2.4: Completion (summary, session archive) + └─ Output: final pass_rate, summary +``` + +**Phase Reference Documents** (read on-demand when phase executes): + +| Phase | Document | Purpose | +|-------|----------|---------| +| 1 | [phases/01-test-fix-gen.md](phases/01-test-fix-gen.md) | Create test session, gather context, analyze, generate tasks | +| 2 | [phases/02-test-cycle-execute.md](phases/02-test-cycle-execute.md) | Execute tasks, iterative fix cycles, completion | + +## Core Rules + +1. **Start Immediately**: First action is TaskCreate initialization, second action is Phase 1 (or Phase 2 for execute-only entry) +2. **No Preliminary Analysis**: Do not read files or gather context before starting the phase +3. **Parse Every Output**: Extract required data from each step output for next step +4. **Auto-Continue**: Phase 1 → Phase 2 automatically (for full pipeline entry) +5. **Track Progress**: Update TaskCreate/TaskUpdate dynamically with task attachment/collapse pattern +6. **Task Attachment Model**: Sub-tasks **attached** during phase, **collapsed** after completion +7. **DO NOT STOP**: Continuous workflow until quality gate met or max iterations reached +8. **Progressive Loading**: Read phase doc ONLY when that phase is about to execute +9. **Entry Point Routing**: `/workflow:test-fix-gen` → Phase 1 + Phase 2; `/workflow:test-cycle-execute` → Phase 2 only + +## Input Processing + +### test-fix-gen Entry (Full Pipeline) +``` +User input → Detect type: + ├─ Starts with "WFS-" → MODE=session, sourceSessionId=input + ├─ Ends with ".md" → MODE=prompt, description=Read(input) + └─ Otherwise → MODE=prompt, description=input +``` + +### test-cycle-execute Entry (Phase 2 Only) +``` +Arguments → Parse flags: + ├─ --resume-session="WFS-xxx" → sessionId=WFS-xxx + ├─ --max-iterations=N → maxIterations=N (default: 10) + └─ (no args) → auto-discover active test session +``` + +## Data Flow + +``` +User Input (session ID | description | file path) + ↓ +[Detect Mode: session | prompt] + ↓ +Phase 1: Test Generation ───────────────────────────────────────── + ↓ 1.1: session:start → testSessionId + ↓ 1.2: test-context-gather/context-gather → contextPath + ↓ 1.3: test-concept-enhanced → TEST_ANALYSIS_RESULTS.md + ↓ 1.4: test-task-generate → IMPL_PLAN.md, IMPL-*.json, TODO_LIST.md + ↓ 1.5: Summary with next step + ↓ +Phase 2: Test Cycle Execution ──────────────────────────────────── + ↓ 2.1: Load session + tasks + iteration state + ↓ 2.2: Execute IMPL-001 → 001.3 → 001.5 → 002 + ↓ 2.3: Fix loop (analyze → fix → retest) until pass_rate >= 95% + ↓ 2.4: Completion → summary → session archive +``` + +## Test Strategy Overview + +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) | + +**Quality Thresholds**: +- Code Validation (IMPL-001.3): Zero CRITICAL issues, zero compilation errors +- Minimum Coverage: 80% line, 70% branch +- Static Analysis (IMPL-001.5): Zero critical anti-patterns +- Pass Rate Gate: >= 95% (criticality-aware) or 100% +- Max Fix Iterations: 10 (default, adjustable) + +## Strategy Engine (Phase 2) + +| Strategy | Trigger | Behavior | +|----------|---------|----------| +| **Conservative** | Iteration 1-2 (default) | Single targeted fix, full validation | +| **Aggressive** | Pass rate >80% + similar failures | Batch fix related issues | +| **Surgical** | Regression detected (pass rate drops >10%) | Minimal changes, rollback focus | + +Selection logic and CLI fallback chain (Gemini → Qwen → Codex) are detailed in Phase 2. + +## Agent Roles + +| Agent | Used In | Responsibility | +|-------|---------|---------------| +| **Orchestrator** | Both phases | Route entry, track progress, pass context | +| **@code-developer** | Phase 2 (IMPL-001) | Test generation (L1-L3) | +| **@test-fix-agent** | Phase 2 | Test execution, code fixes, criticality assignment | +| **@cli-planning-agent** | Phase 2 (fix loop) | CLI analysis, root cause extraction, fix task generation | + +## TodoWrite Pattern + +**Core Concept**: Dynamic task tracking with attachment/collapse for real-time visibility. + +> **Implementation Note**: Phase files use `TodoWrite` syntax to describe the conceptual tracking pattern. At runtime, these are implemented via `TaskCreate/TaskUpdate/TaskList` tools from the allowed-tools list. Map `TodoWrite` examples as follows: +> - Initial list creation → `TaskCreate` for each item +> - Status changes → `TaskUpdate({ taskId, status })` +> - Sub-task attachment → `TaskCreate` + `TaskUpdate({ addBlockedBy })` +> - Sub-task collapse → `TaskUpdate({ status: "completed" })` + `TaskUpdate({ status: "deleted" })` for collapsed sub-items + +### Full Pipeline (Phase 1 + Phase 2) + +```json +[ + {"content": "Phase 1: Test Generation", "status": "in_progress"}, + {"content": " → Create test session", "status": "in_progress"}, + {"content": " → Gather test context", "status": "pending"}, + {"content": " → Test analysis (Gemini)", "status": "pending"}, + {"content": " → Generate test tasks", "status": "pending"}, + {"content": "Phase 2: Test Cycle Execution", "status": "pending"} +] +``` + +### Phase 1 Collapsed → Phase 2 Active + +```json +[ + {"content": "Phase 1: Test Generation", "status": "completed"}, + {"content": "Phase 2: Test Cycle Execution", "status": "in_progress"}, + {"content": " → Execute IMPL-001 [code-developer]", "status": "in_progress"}, + {"content": " → Execute IMPL-001.3 [test-fix-agent]", "status": "pending"}, + {"content": " → Execute IMPL-001.5 [test-fix-agent]", "status": "pending"}, + {"content": " → Execute IMPL-002 [test-fix-agent]", "status": "pending"}, + {"content": " → Fix Loop", "status": "pending"} +] +``` + +### Fix Loop Iterations + +```json +[ + {"content": "Phase 1: Test Generation", "status": "completed"}, + {"content": "Phase 2: Test Cycle Execution", "status": "in_progress"}, + {"content": " → Initial tasks", "status": "completed"}, + {"content": " → Iteration 1: Initial test (pass: 70%, conservative)", "status": "completed"}, + {"content": " → Iteration 2: Fix validation (pass: 82%, conservative)", "status": "completed"}, + {"content": " → Iteration 3: Batch fix (pass: 89%, aggressive)", "status": "in_progress"} +] +``` + +## Session File Structure + +``` +.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 fix loop) +├── .process/ +│ ├── [test-]context-package.json # Context and coverage analysis +│ ├── TEST_ANALYSIS_RESULTS.md # Test requirements (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/ +``` + +## Error Handling + +### Phase 1 (Generation) + +| Step | Error Condition | Action | +|------|----------------|--------| +| Session create | Source session not found (session mode) | Return error with session ID | +| Session create | No completed IMPL tasks (session mode) | Return error, source incomplete | +| Context gather | Context gathering failed | Return error, check source artifacts | +| Analysis | Gemini analysis failed | Return error, check context package | +| Task gen | Task generation failed | Retry once, then return error | + +### Phase 2 (Execution) + +| Scenario | Action | +|----------|--------| +| Test execution error | Log, retry with error context | +| CLI analysis failure | Fallback: Gemini → Qwen → Codex → manual | +| Agent execution error | Save state, retry with simplified context | +| Max iterations reached | Generate failure report, mark blocked | +| Regression detected | Rollback last fix, switch to surgical strategy | +| Stuck tests detected | Continue with alternative strategy, document | + +## Commit Strategy (Phase 2) + +Automatic commits at key checkpoints: +1. **After successful iteration** (pass rate increased): `test-cycle: iteration N - strategy (pass: old% → new%)` +2. **Before rollback** (regression detected): `test-cycle: rollback iteration N - regression detected` + +## Completion Conditions + +| Condition | Pass Rate | Action | +|-----------|-----------|--------| +| **Full Success** | 100% | Auto-complete session | +| **Partial Success** | >= 95%, all failures low criticality | Auto-approve with review note | +| **Failure** | < 95% after max iterations | Failure report, mark blocked | + +## Post-Completion Expansion + +After completion, ask user if they want to expand into issues (test/enhance/refactor/doc). Selected items call `/issue:new "{summary} - {dimension}"`. + +## Coordinator Checklist + +### Phase 1 (test-fix-gen) +- [ ] Detect input type (session ID / description / file path) +- [ ] Initialize TaskCreate before any execution +- [ ] Read Phase 1 doc, execute all 5 internal steps +- [ ] Parse testSessionId from step output, store in memory +- [ ] Verify all Phase 1 outputs (4 task JSONs, IMPL_PLAN.md, TODO_LIST.md) +- [ ] Collapse Phase 1 tasks, auto-continue to Phase 2 + +### Phase 2 (test-cycle-execute) +- [ ] Read Phase 2 doc +- [ ] Load session, tasks, iteration state +- [ ] Execute initial tasks sequentially +- [ ] Calculate pass rate from test-results.json +- [ ] If pass_rate < 95%: Enter fix loop +- [ ] Track iteration count, stuck tests, regression +- [ ] If pass_rate >= 95% or max iterations: Complete +- [ ] Generate completion summary +- [ ] Offer post-completion expansion + +## Related Skills + +**Prerequisite Skills**: +- `/workflow:plan` or `/workflow:execute` - Complete implementation (Session Mode source) +- None for Prompt Mode + +**Called During Execution**: +- `/workflow:session:start` - Phase 1: Create test session +- `/workflow:tools:test-context-gather` - Phase 1 (Session Mode) +- `/workflow:tools:context-gather` - Phase 1 (Prompt Mode) +- `/workflow:tools:test-concept-enhanced` - Phase 1: Gemini analysis +- `/workflow:tools:test-task-generate` - Phase 1: Task generation +- `/workflow:session:complete` - Phase 2: Archive session + +**Follow-up Skills**: +- `/workflow:status` - Review workflow state +- `/workflow:review` - Post-implementation review +- `/issue:new` - Create follow-up issues diff --git a/.claude/skills/workflow-test-fix/phases/01-test-fix-gen.md b/.claude/skills/workflow-test-fix/phases/01-test-fix-gen.md new file mode 100644 index 00000000..6621a7c8 --- /dev/null +++ b/.claude/skills/workflow-test-fix/phases/01-test-fix-gen.md @@ -0,0 +1,309 @@ +# Phase 1: Test Fix Generation (test-fix-gen) + +Create test-fix workflow session with progressive test layers (L0-L3), AI code validation, and test task generation. This phase runs 5 internal steps sequentially, calling existing sub-commands via Skill(). + +## Objective + +- Detect input mode (session ID vs description) +- Create test workflow session +- Gather test context (coverage analysis or codebase scan) +- Analyze test requirements with Gemini (L0-L3 layers) +- Generate test task JSONs via action-planning-agent + +## Test Strategy Overview + +This workflow generates tests using **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**: +- **AI Code Issue Detection** - Validates against common AI-generated code problems (hallucinated imports, placeholder code, mock leakage, etc.) +- **Project Type Detection** - Applies appropriate test templates (React, Node API, CLI, Library, etc.) +- **Quality Gates** - IMPL-001.3 (code validation) and IMPL-001.5 (test quality) ensure high standards + +**Detailed specifications**: See `/workflow:tools:test-task-generate` for complete L0-L3 requirements and quality thresholds. + +## Execution + +### Step 1.0: Detect Input Mode + +``` +// Automatic mode detection based on input pattern +if (input.startsWith("WFS-")) { + MODE = "session" + // Load source session to preserve original task description + Read(".workflow/active/[sourceSessionId]/workflow-session.json") +} else { + MODE = "prompt" +} +``` + +### Step 1.1: Create Test Session + +``` +// Session Mode - preserve original task description +Skill(skill="workflow:session:start", args="--type test --new \"Test validation for [sourceSessionId]: [originalTaskDescription]\"") + +// Prompt Mode - use user's description directly +Skill(skill="workflow:session:start", args="--type test --new \"Test generation for: [description]\"") +``` + +**Parse Output**: +- Extract: `SESSION_ID: WFS-test-[slug]` (store as `testSessionId`) + +**Validation**: +- Session Mode: Source session `.workflow/active/[sourceSessionId]/` exists with completed IMPL tasks +- Both Modes: New test session directory created with metadata + +**TodoWrite**: Mark step 1.1 completed, step 1.2 in_progress + +### Step 1.2: Gather Test Context + +``` +// Session Mode - gather from source session +Skill(skill="workflow:tools:test-context-gather", args="--session [testSessionId]") + +// Prompt Mode - gather from codebase +Skill(skill="workflow:tools:context-gather", args="--session [testSessionId] \"[task_description]\"") +``` + +**Input**: `testSessionId` from Step 1.1 + +**Parse Output**: +- Extract: context package path (store as `contextPath`) +- Pattern: `.workflow/active/[testSessionId]/.process/[test-]context-package.json` + +**Validation**: +- Context package file exists and is valid JSON +- Contains coverage analysis (session mode) or codebase analysis (prompt mode) +- Test framework detected + +**TodoWrite Update (tasks attached)**: +```json +[ + {"content": "Phase 1: Test Generation", "status": "in_progress"}, + {"content": " → Create test session", "status": "completed"}, + {"content": " → Gather test context", "status": "in_progress"}, + {"content": " → Load source/codebase context", "status": "in_progress"}, + {"content": " → Analyze test coverage", "status": "pending"}, + {"content": " → Generate context package", "status": "pending"}, + {"content": " → Test analysis (Gemini)", "status": "pending"}, + {"content": " → Generate test tasks", "status": "pending"}, + {"content": "Phase 2: Test Cycle Execution", "status": "pending"} +] +``` + +**TodoWrite Update (tasks collapsed)**: +```json +[ + {"content": "Phase 1: Test Generation", "status": "in_progress"}, + {"content": " → Create test session", "status": "completed"}, + {"content": " → Gather test context", "status": "completed"}, + {"content": " → Test analysis (Gemini)", "status": "pending"}, + {"content": " → Generate test tasks", "status": "pending"}, + {"content": "Phase 2: Test Cycle Execution", "status": "pending"} +] +``` + +### Step 1.3: Test Generation Analysis + +``` +Skill(skill="workflow:tools:test-concept-enhanced", args="--session [testSessionId] --context [contextPath]") +``` + +**Input**: +- `testSessionId` from Step 1.1 +- `contextPath` from Step 1.2 + +**Expected Behavior**: +- Use Gemini to analyze coverage gaps +- Detect project type and apply appropriate test templates +- Generate **multi-layered test requirements** (L0-L3) +- Scan for AI code issues +- Generate `TEST_ANALYSIS_RESULTS.md` + +**Output**: `.workflow/[testSessionId]/.process/TEST_ANALYSIS_RESULTS.md` + +**Validation** - TEST_ANALYSIS_RESULTS.md must include: +- Project Type Detection (with confidence) +- Coverage Assessment (current vs target) +- Test Framework & Conventions +- Multi-Layered Test Plan (L0-L3) +- AI Issue Scan Results +- Test Requirements by File (with layer annotations) +- Quality Assurance Criteria +- Success Criteria + +**Note**: Detailed specifications for project types, L0-L3 layers, and AI issue detection are defined in `/workflow:tools:test-concept-enhanced`. + +### Step 1.4: Generate Test Tasks + +``` +Skill(skill="workflow:tools:test-task-generate", args="--session [testSessionId]") +``` + +**Input**: `testSessionId` from Step 1.1 + +**Note**: test-task-generate invokes action-planning-agent to generate test-specific IMPL_PLAN.md and task JSONs based on TEST_ANALYSIS_RESULTS.md. + +**Expected Output** (minimum 4 tasks): + +| Task | Type | Agent | Purpose | +|------|------|-------|---------| +| IMPL-001 | test-gen | @code-developer | Test understanding & generation (L1-L3) | +| IMPL-001.3 | code-validation | @test-fix-agent | Code validation gate (L0 + AI issues) | +| IMPL-001.5 | test-quality-review | @test-fix-agent | Test quality gate | +| IMPL-002 | test-fix | @test-fix-agent | Test execution & fix cycle | + +**Validation**: +- `.workflow/active/[testSessionId]/.task/IMPL-001.json` exists +- `.workflow/active/[testSessionId]/.task/IMPL-001.3-validation.json` exists +- `.workflow/active/[testSessionId]/.task/IMPL-001.5-review.json` exists +- `.workflow/active/[testSessionId]/.task/IMPL-002.json` exists +- `.workflow/active/[testSessionId]/IMPL_PLAN.md` exists +- `.workflow/active/[testSessionId]/TODO_LIST.md` exists + +### Step 1.5: Return Summary + +**Return to Orchestrator**: +``` +Test-fix workflow created successfully! + +Input: [original input] +Mode: [Session|Prompt] +Test Session: [testSessionId] + +Tasks Created: +- IMPL-001: Test Understanding & Generation (@code-developer) +- IMPL-001.3: Code Validation Gate - AI Error Detection (@test-fix-agent) +- IMPL-001.5: Test Quality Gate - Static Analysis & Coverage (@test-fix-agent) +- IMPL-002: Test Execution & Fix Cycle (@test-fix-agent) + +Quality Thresholds: +- Code Validation: Zero CRITICAL issues, zero compilation errors +- Minimum Coverage: 80% line, 70% branch +- Static Analysis: Zero critical anti-patterns +- Max Fix Iterations: 5 + +Review artifacts: +- Test plan: .workflow/[testSessionId]/IMPL_PLAN.md +- Task list: .workflow/[testSessionId]/TODO_LIST.md +- Analysis: .workflow/[testSessionId]/.process/TEST_ANALYSIS_RESULTS.md +``` + +**CRITICAL - Next Step**: Auto-continue to Phase 2: Test Cycle Execution. +Pass `testSessionId` to Phase 2 for test execution pipeline. Do NOT wait for user confirmation — the unified pipeline continues automatically. + +## Execution Flow Diagram + +``` +User triggers: /workflow:test-fix-gen "Test user authentication" + ↓ +[Input Detection] → MODE: prompt + ↓ +[TodoWrite Init] Phase 1 sub-steps + Phase 2 + ↓ +Step 1.1: Create Test Session + → /workflow:session:start --type test + → testSessionId extracted (WFS-test-user-auth) + ↓ +Step 1.2: Gather Test Context (Skill executed) + → ATTACH 3 sub-tasks: ← ATTACHED + - → Load codebase context + - → Analyze test coverage + - → Generate context package + → Execute sub-tasks sequentially + → COLLAPSE tasks ← COLLAPSED + → contextPath extracted + ↓ +Step 1.3: Test Generation Analysis (Skill executed) + → ATTACH 3 sub-tasks: ← ATTACHED + - → Analyze coverage gaps with Gemini + - → Detect AI code issues (L0.5) + - → Generate L0-L3 test requirements + → Execute sub-tasks sequentially + → COLLAPSE tasks ← COLLAPSED + → TEST_ANALYSIS_RESULTS.md created + ↓ +Step 1.4: Generate Test Tasks (Skill executed) + → Single agent task (test-task-generate → action-planning-agent) + → Agent autonomously generates: + - IMPL-001.json (test generation) + - IMPL-001.3-validation.json (code validation) + - IMPL-001.5-review.json (test quality) + - IMPL-002.json (test execution) + - IMPL_PLAN.md + - TODO_LIST.md + ↓ +Step 1.5: Return Summary + → Display summary + → Phase 1 complete +``` + +## Output Artifacts + +### Directory Structure + +``` +.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-*.json # Additional tasks (if applicable) +└── .process/ + ├── [test-]context-package.json # Context and coverage analysis + └── TEST_ANALYSIS_RESULTS.md # Test requirements and strategy (L0-L3) +``` + +### Session Metadata + +**File**: `workflow-session.json` + +| Mode | Fields | +|------|--------| +| **Session** | `type: "test"`, `source_session_id: "[sourceId]"` | +| **Prompt** | `type: "test"` (no source_session_id) | + +## Error Handling + +| Step | Error Condition | 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.3 | Gemini analysis failed | Return error, check context package | +| 1.4 | Task generation failed | Retry once, then return error | + +## Usage Examples + +```bash +# Session Mode - test validation for completed implementation +/workflow:test-fix-gen WFS-user-auth-v2 + +# Prompt Mode - text description +/workflow:test-fix-gen "Test the user authentication API endpoints in src/auth/api.ts" + +# Prompt Mode - file reference +/workflow:test-fix-gen ./docs/api-requirements.md +``` + +## Output + +- **Variable**: `testSessionId` (WFS-test-xxx) +- **Variable**: `contextPath` (context-package.json path) +- **Files**: IMPL_PLAN.md, IMPL-*.json (4+), TODO_LIST.md, TEST_ANALYSIS_RESULTS.md +- **TodoWrite**: Mark Phase 1 completed, Phase 2 in_progress + +## Next Phase + +Return to orchestrator, then auto-continue to [Phase 2: Test Cycle Execution](02-test-cycle-execute.md). diff --git a/.claude/skills/workflow-test-fix/phases/02-test-cycle-execute.md b/.claude/skills/workflow-test-fix/phases/02-test-cycle-execute.md new file mode 100644 index 00000000..68cd8dd1 --- /dev/null +++ b/.claude/skills/workflow-test-fix/phases/02-test-cycle-execute.md @@ -0,0 +1,533 @@ +# Phase 2: Test Cycle Execution (test-cycle-execute) + +Execute test-fix workflow with dynamic task generation and iterative fix cycles until test pass rate >= 95% or max iterations reached. Uses @cli-planning-agent for failure analysis and task generation. + +## Objective + +- Discover and load test session with generated tasks +- Execute initial task pipeline (IMPL-001 → 001.3 → 001.5 → 002) +- Run iterative fix loop with adaptive strategy engine +- Achieve pass rate >= 95% or exhaust max iterations +- Complete session with summary and post-expansion options + +## Quick Start + +```bash +# Execute test-fix workflow (auto-discovers active session) +/workflow:test-cycle-execute + +# Resume interrupted session +/workflow:test-cycle-execute --resume-session="WFS-test-user-auth" + +# Custom iteration limit (default: 10) +/workflow:test-cycle-execute --max-iterations=15 +``` + +**Quality Gate**: Test pass rate >= 95% (criticality-aware) or 100% +**Max Iterations**: 10 (default, adjustable) +**CLI Tools**: Gemini → Qwen → Codex (fallback chain) + +## Core Concept + +Dynamic test-fix orchestrator with **adaptive task generation** based on runtime analysis. + +**Orchestrator Boundary**: The orchestrator (this phase) is responsible ONLY for: +- Loop control and iteration tracking +- Strategy selection and threshold decisions +- Delegating analysis to @cli-planning-agent and execution to @test-fix-agent +- Reading results and making pass/fail decisions +- The orchestrator does NOT directly modify source code, run tests, or perform root cause analysis + +**vs Standard Execute**: +- **Standard**: Pre-defined tasks → Execute sequentially → Done +- **Test-Cycle**: Initial tasks → **Test → Analyze failures → Generate fix tasks → Fix → Re-test** → Repeat until pass + +## Execution + +### Step 2.1: Discovery + +Load session, tasks, and iteration state. + +``` +1. Discovery + └─ Load session, tasks, iteration state +``` + +**For full-pipeline entry (from Phase 1)**: Use `testSessionId` passed from Phase 1. + +**For direct entry (/workflow:test-cycle-execute)**: +- `--resume-session="WFS-xxx"` → Use specified session +- No args → Auto-discover active test session (find `.workflow/active/WFS-test-*`) + +### Step 2.2: Execute Initial Tasks + +Execute the generated task pipeline sequentially: + +``` +IMPL-001 (test-gen, @code-developer) → +IMPL-001.3 (code-validation, @test-fix-agent) → +IMPL-001.5 (test-quality-review, @test-fix-agent) → +IMPL-002 (test-fix, @test-fix-agent) → +Calculate pass_rate from test-results.json +``` + +**Agent Invocation - @test-fix-agent** (execution): +```javascript +Task( + subagent_type="test-fix-agent", + run_in_background=false, + description=`Execute ${task.meta.type}: ${task.title}`, + prompt=` + ## Task Objective + ${taskTypeObjective[task.meta.type]} + + ## MANDATORY FIRST STEPS + 1. Read task JSON: ${session.task_json_path} + 2. Read iteration state: ${session.iteration_state_path} + 3. ${taskTypeSpecificReads[task.meta.type]} + + ## CRITICAL: Syntax Check Priority + **Before any code modification or test execution:** + - Run project syntax checker (TypeScript: tsc --noEmit, ESLint, etc.) + - Verify zero syntax errors before proceeding + - If syntax errors found: Fix immediately before other work + - Syntax validation is MANDATORY gate - no exceptions + + ## Session Paths + - Workflow Dir: ${session.workflow_dir} + - Task JSON: ${session.task_json_path} + - Test Results Output: ${session.test_results_path} + - Test Output Log: ${session.test_output_path} + - Iteration State: ${session.iteration_state_path} + + ## Task Type: ${task.meta.type} + ${taskTypeGuidance[task.meta.type]} + + ## Expected Deliverables + ${taskTypeDeliverables[task.meta.type]} + + ## Success Criteria + - ${taskTypeSuccessCriteria[task.meta.type]} + - Update task status in task JSON + - Save all outputs to specified paths + - Report completion to orchestrator + ` +) + +// Task Type Configurations +const taskTypeObjective = { + "test-gen": "Generate comprehensive tests based on requirements", + "test-fix": "Execute test suite and report results with criticality assessment", + "test-fix-iteration": "Apply fixes from strategy and validate with tests" +}; + +const taskTypeSpecificReads = { + "test-gen": "Read test context: ${session.test_context_path}", + "test-fix": "Read previous results (if exists): ${session.test_results_path}", + "test-fix-iteration": "Read fix strategy: ${session.analysis_path}, fix history: ${session.fix_history_path}" +}; + +const taskTypeGuidance = { + "test-gen": ` + - Review task.context.requirements for test scenarios + - Analyze codebase to understand implementation + - Generate tests covering: happy paths, edge cases, error handling + - Follow existing test patterns and framework conventions + `, + "test-fix": ` + - Run test command from task.context or project config + - Capture: pass/fail counts, error messages, stack traces + - Assess criticality for each failure: + * high: core functionality broken, security issues + * medium: feature degradation, data integrity issues + * low: edge cases, flaky tests, env-specific issues + - Save structured results to test-results.json + `, + "test-fix-iteration": ` + - Load fix_strategy from task.context.fix_strategy + - Identify modification_points: ${task.context.fix_strategy.modification_points} + - Apply surgical fixes (minimal changes) + - Test execution mode: ${task.context.fix_strategy.test_execution.mode} + * affected_only: Run ${task.context.fix_strategy.test_execution.affected_tests} + * full_suite: Run complete test suite + - If failures persist: Document in test-results.json, DO NOT analyze (orchestrator handles) + ` +}; + +const taskTypeDeliverables = { + "test-gen": "- Test files in target directories\n - Test coverage report\n - Summary in .summaries/", + "test-fix": "- test-results.json (pass_rate, criticality, failures)\n - test-output.log (full test output)\n - Summary in .summaries/", + "test-fix-iteration": "- Modified source files\n - test-results.json (updated pass_rate)\n - test-output.log\n - Summary in .summaries/" +}; + +const taskTypeSuccessCriteria = { + "test-gen": "All test files created, executable without errors, coverage documented", + "test-fix": "Test results saved with accurate pass_rate and criticality, all failures documented", + "test-fix-iteration": "Fixes applied per strategy, tests executed, results reported (pass/fail to orchestrator)" +}; +``` + +**Decision after IMPL-002 execution**: +``` +pass_rate = Read(test-results.json).pass_rate +├─ 100% → SUCCESS: Proceed to Step 2.4 (Completion) +├─ 95-99% + all failures low criticality → PARTIAL SUCCESS: Proceed to Step 2.4 +└─ <95% or critical failures → Enter Step 2.3 (Fix Loop) +``` + +### Step 2.3: Iterative Fix Loop + +**Conditional**: Only enters when pass_rate < 95% or critical failures exist. + +#### Intelligent Strategy Engine + +**Auto-selects optimal strategy based on iteration context:** + +| Strategy | Trigger | Behavior | +|----------|---------|----------| +| **Conservative** | Iteration 1-2 (default) | Single targeted fix, full validation | +| **Aggressive** | Pass rate >80% + similar failures | Batch fix related issues | +| **Surgical** | Regression detected (pass rate drops >10%) | Minimal changes, rollback focus | + +**Selection Logic** (in orchestrator): +```javascript +if (iteration <= 2) return "conservative"; +if (passRate > 80 && failurePattern.similarity > 0.7) return "aggressive"; +if (regressionDetected) return "surgical"; +return "conservative"; +``` + +**Integration**: Strategy passed to @cli-planning-agent in prompt for tailored analysis. + +#### Progressive Testing + +**Runs affected tests during iterations, full suite only for final validation.** + +**How It Works**: +1. @cli-planning-agent analyzes fix_strategy.modification_points +2. Maps modified files to test files (via imports + integration patterns) +3. Returns `affected_tests[]` in task JSON +4. @test-fix-agent runs: `npm test -- ${affected_tests.join(' ')}` +5. Final validation: `npm test` (full suite) + +**Benefits**: 70-90% iteration speed improvement, instant feedback on fix effectiveness. + +#### Orchestrator Runtime Calculations + +**From iteration-state.json**: +- Current iteration: `iterations.length + 1` +- Stuck tests: Tests appearing in `failed_tests` for 3+ consecutive iterations +- Regression: Compare consecutive `pass_rate` values (>10% drop) +- Max iterations: Read from `task.meta.max_iterations` + +#### Fix Loop Flow + +``` +for each iteration (N = 1 to maxIterations): + 1. Detect: stuck tests, regression, progress trend + 2. Select strategy: conservative/aggressive/surgical + 3. Generate fix task via @cli-planning-agent + 4. Execute fix via @test-fix-agent + 5. Re-test → Calculate pass_rate + 6. Decision: + ├─ pass_rate >= 95% → EXIT loop → Step 2.4 + ├─ regression detected → Rollback, switch to surgical + └─ continue → Next iteration +``` + +#### Agent Invocation - @cli-planning-agent (failure analysis) + +```javascript +Task( + subagent_type="cli-planning-agent", + run_in_background=false, + description=`Analyze test failures (iteration ${N}) - ${strategy} strategy`, + prompt=` + ## Task Objective + Analyze test failures and generate fix task JSON for iteration ${N} + + ## Strategy + ${selectedStrategy} - ${strategyDescription} + + ## MANDATORY FIRST STEPS + 1. Read test results: ${session.test_results_path} + 2. Read test output: ${session.test_output_path} + 3. Read iteration state: ${session.iteration_state_path} + + ## Context Metadata (Orchestrator-Calculated) + - Session ID: ${sessionId} (from file path) + - Current Iteration: ${N} (= iterations.length + 1) + - Max Iterations: ${maxIterations} (from task.meta.max_iterations) + - Current Pass Rate: ${passRate}% + - Selected Strategy: ${selectedStrategy} (from iteration-state.json) + - Stuck Tests: ${stuckTests} (calculated from iterations[].failed_tests history) + + ## CLI Configuration + - Tool Priority: gemini & codex + - Template: 01-diagnose-bug-root-cause.txt + - Timeout: 2400000ms + + ## Expected Deliverables + 1. Task JSON: ${session.task_dir}/IMPL-fix-${N}.json + - Must include: fix_strategy.test_execution.affected_tests[] + - Must include: fix_strategy.confidence_score + 2. Analysis report: ${session.process_dir}/iteration-${N}-analysis.md + 3. CLI output: ${session.process_dir}/iteration-${N}-cli-output.txt + + ## Strategy-Specific Requirements + - Conservative: Single targeted fix, high confidence required + - Aggressive: Batch fix similar failures, pattern-based approach + - Surgical: Minimal changes, focus on rollback safety + + ## Success Criteria + - Concrete fix strategy with modification points (file:function:lines) + - Affected tests list for progressive testing + - Root cause analysis (not just symptoms) + ` +) +``` + +#### CLI Tool Configuration + +**Fallback Chain**: Gemini → Qwen → Codex +**Template**: `~/.ccw/workflows/cli-templates/prompts/analysis/01-diagnose-bug-root-cause.txt` +**Timeout**: 40min (2400000ms) + +**Tool Details**: +1. **Gemini** (primary): `gemini-2.5-pro` +2. **Qwen** (fallback): `coder-model` +3. **Codex** (fallback): `gpt-5.1-codex` + +**When to Fallback**: HTTP 429, timeout, analysis quality degraded + +**CLI Fallback Triggers** (Gemini → Qwen → Codex → manual): + +Fallback is triggered when any of these conditions occur: + +1. **Invalid Output**: + - CLI tool fails to generate valid `IMPL-fix-N.json` (JSON parse error) + - Missing required fields: `fix_strategy.modification_points` or `fix_strategy.affected_tests` + +2. **Low Confidence**: + - `fix_strategy.confidence_score < 0.4` (indicates uncertain analysis) + +3. **Technical Failures**: + - HTTP 429 (rate limit) or 5xx errors + - Timeout (exceeds 2400000ms / 40min) + - Connection errors + +4. **Quality Degradation**: + - Analysis report < 100 words (too brief, likely incomplete) + - No concrete modification points provided (only general suggestions) + - Same root cause identified 3+ consecutive times (stuck analysis) + +**Fallback Sequence**: +- Try primary tool (Gemini) +- If trigger detected → Try fallback (Qwen) +- If trigger detected again → Try final fallback (Codex) +- If all fail → Mark as degraded, use basic pattern matching from fix-history.json, notify user + +#### Iteration State JSON + +**Purpose**: Persisted state machine for iteration loop - enables Resume and historical analysis. + +```json +{ + "current_task": "IMPL-002", + "selected_strategy": "aggressive", + "next_action": "execute_fix_task", + "iterations": [ + { + "iteration": 1, + "pass_rate": 70, + "strategy": "conservative", + "failed_tests": ["test_auth_flow", "test_user_permissions"] + }, + { + "iteration": 2, + "pass_rate": 82, + "strategy": "conservative", + "failed_tests": ["test_user_permissions", "test_token_expiry"] + }, + { + "iteration": 3, + "pass_rate": 89, + "strategy": "aggressive", + "failed_tests": ["test_auth_edge_case"] + } + ] +} +``` + +**Field Descriptions**: +- `current_task`: Pointer to active task (essential for Resume) +- `selected_strategy`: Current iteration strategy (runtime state) +- `next_action`: State machine next step (`execute_fix_task` | `retest` | `complete`) +- `iterations[]`: Historical log of all iterations (source of truth for trends) + +#### TodoWrite Update (Fix Loop) + +```javascript +TodoWrite({ + todos: [ + { + content: "Execute IMPL-001: Generate tests [code-developer]", + status: "completed", + activeForm: "Executing test generation" + }, + { + content: "Execute IMPL-002: Test & Fix Cycle [ITERATION]", + status: "in_progress", + activeForm: "Running test-fix iteration cycle" + }, + { + content: " → Iteration 1: Initial test (pass: 70%, conservative)", + status: "completed", + activeForm: "Running initial tests" + }, + { + content: " → Iteration 2: Fix validation (pass: 82%, conservative)", + status: "completed", + activeForm: "Fixing validation issues" + }, + { + content: " → Iteration 3: Batch fix auth (pass: 89%, aggressive)", + status: "in_progress", + activeForm: "Fixing authentication issues" + } + ] +}); +``` + +**Update Rules**: +- Add iteration item with: strategy, pass rate +- Mark completed after each iteration +- Update parent task when all complete + +### Step 2.4: Completion + +#### Completion Conditions + +**Full Success**: +- All tasks completed +- Pass rate === 100% +- Action: Auto-complete session + +**Partial Success**: +- All tasks completed +- Pass rate >= 95% and < 100% +- All failures are "low" criticality +- Action: Auto-approve with review note + +**Failure**: +- Max iterations (10) reached without 95% pass rate +- Pass rate < 95% after max iterations +- Action: Generate failure report, mark blocked, return to user + +#### Commit Strategy + +**Automatic Commits** (orchestrator-managed): + +The orchestrator automatically creates git commits at key checkpoints to enable safe rollback: + +1. **After Successful Iteration** (pass rate increased): + ```bash + git add . + git commit -m "test-cycle: iteration ${N} - ${strategy} strategy (pass: ${oldRate}% → ${newRate}%)" + ``` + +2. **Before Rollback** (regression detected): + ```bash + # Current state preserved, then: + git revert HEAD + git commit -m "test-cycle: rollback iteration ${N} - regression detected (pass: ${newRate}% < ${oldRate}%)" + ``` + +**Commit Content**: +- Modified source files from fix application +- Updated test-results.json, iteration-state.json +- Excludes: temporary files, logs + +**Benefits**: +- Each successful iteration is a safe rollback point +- Regression detection can instantly revert to last known-good state +- Full iteration history visible in git log for post-mortem analysis +- No manual intervention needed for rollback — orchestrator handles automatically + +#### Post-Completion Expansion + +完成后询问用户是否扩展为issue(test/enhance/refactor/doc),选中项调用 `/issue:new "{summary} - {dimension}"` + +## Agent Roles Summary + +| Agent | Responsibility | +|-------|---------------| +| **Orchestrator** | Loop control, strategy selection, pass rate calculation, threshold decisions | +| **@cli-planning-agent** | CLI analysis (Gemini/Qwen/Codex), root cause extraction, task generation, affected test detection | +| **@test-fix-agent** | Test execution, code fixes, criticality assignment, result reporting | + +**Core Responsibilities (Detailed)**: + +- **Orchestrator** (this skill): + - Loop control: iteration count, max iterations enforcement, exit conditions + - Strategy selection based on iteration context (conservative → aggressive → surgical) + - Pass rate calculation from test-results.json after each iteration + - Threshold decisions: 95% gate, criticality-aware partial success + - Commit management: auto-commit on improvement, rollback on regression + - Regression detection: compare consecutive pass_rate values (>10% drop triggers surgical) + - Stuck test tracking: tests failing 3+ consecutive iterations flagged for alternative strategy + +- **@cli-planning-agent** (failure analysis): + - Execute CLI tools (Gemini/Qwen/Codex) with fallback chain for root cause analysis + - Extract concrete modification points (file:function:lines) from analysis + - Generate fix task JSON (IMPL-fix-N.json) with fix_strategy and confidence_score + - Detect affected tests for progressive testing (map modified files → test files) + - Apply strategy-specific analysis (conservative: single fix, aggressive: batch, surgical: minimal) + +- **@test-fix-agent** (execution): + - Execute test suite and capture pass/fail counts, error messages, stack traces + - Apply code fixes per fix_strategy.modification_points (surgical, minimal changes) + - Assess criticality for each failure (high/medium/low based on impact) + - Report structured results to test-results.json with pass_rate and failure details + - Validate syntax before any code modification (TypeScript: tsc --noEmit, ESLint) + +## Error Handling + +| Scenario | Action | +|----------|--------| +| Test execution error | Log, retry with error context | +| CLI analysis failure | Fallback: Gemini → Qwen → Codex → manual | +| Agent execution error | Save state, retry with simplified context | +| Max iterations reached | Generate failure report, mark blocked | +| Regression detected | Rollback last fix, switch to surgical strategy | +| Stuck tests detected | Continue with alternative strategy, document in failure report | + +## Session File Structure + +``` +.workflow/active/WFS-test-{session}/ +├── workflow-session.json # Session metadata +├── IMPL_PLAN.md, TODO_LIST.md +├── .task/ +│ ├── IMPL-{001,002}.json # Initial tasks +│ └── IMPL-fix-{N}.json # Generated fix tasks +├── .process/ +│ ├── 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/ +``` + +## Output + +- **Variable**: `finalPassRate` (percentage) +- **File**: `test-results.json` (final results) +- **File**: `iteration-state.json` (full iteration history) +- **TodoWrite**: Mark Phase 2 completed + +## Next Phase + +Return to orchestrator. Workflow complete. Offer post-completion expansion options.