diff --git a/.claude/commands/workflow/test-cycle-execute.md b/.claude/commands/workflow/test-cycle-execute.md index 75386255..29925025 100644 --- a/.claude/commands/workflow/test-cycle-execute.md +++ b/.claude/commands/workflow/test-cycle-execute.md @@ -10,6 +10,12 @@ allowed-tools: SlashCommand(*), TodoWrite(*), Read(*), Bash(*), Task(*) ## Overview Orchestrates dynamic test-fix workflow execution through iterative cycles of testing, analysis, and fixing. **Unlike standard execute, this command dynamically generates intermediate tasks** during execution based on test results and CLI analysis, enabling adaptive problem-solving. +**⚠️ CRITICAL - Orchestrator Boundary**: +- This command is the **ONLY place** where test failures are handled +- All CLI analysis (Gemini/Qwen), fix task generation (IMPL-fix-N.json), and iteration management happen HERE +- Agents (@test-fix-agent) only execute single tasks and return results +- **Do NOT handle test failures in main workflow or other commands** - always delegate to this orchestrator + **Resume Mode**: When called with `--resume-session` flag, skips discovery and continues from interruption point. ## Core Philosophy @@ -53,7 +59,7 @@ Orchestrates dynamic test-fix workflow execution through iterative cycles of tes ## Responsibility Matrix -**Clear division of labor between orchestrator and agents:** +**⚠️ CRITICAL - Clear division of labor between orchestrator and agents:** | Responsibility | test-cycle-execute (Orchestrator) | @test-fix-agent (Executor) | |----------------|----------------------------|---------------------------| @@ -62,12 +68,14 @@ Orchestrates dynamic test-fix workflow execution through iterative cycles of tes | Generate IMPL-fix-N.json | ✅ Creates task files | ❌ Not involved | | Run tests | ❌ Delegates to agent | ✅ Executes test command | | Apply fixes | ❌ Delegates to agent | ✅ Modifies code | -| Detect test failures | ✅ Analyzes agent output | ✅ Reports results | +| Detect test failures | ✅ Analyzes results and decides next action | ✅ Executes tests and reports outcomes | | Add tasks to queue | ✅ Manages queue | ❌ Not involved | -| Update iteration state | ✅ Maintains state files | ✅ Updates task status | +| Update iteration state | ✅ Maintains overall iteration state | ✅ Updates individual task status only | **Key Principle**: Orchestrator manages the "what" and "when"; agents execute the "how". +**⚠️ ENFORCEMENT**: If test failures occur outside this orchestrator, do NOT handle them inline - always call `/workflow:test-cycle-execute` instead. + ## Execution Lifecycle ### Phase 1: Discovery & Initialization @@ -217,13 +225,15 @@ Iteration N (managed by test-cycle-execute orchestrator): **Orchestrator executes CLI analysis between agent tasks:** #### When Test Failures Occur -1. **[Orchestrator]** Detects failures from agent output +1. **[Orchestrator]** Detects failures from agent test execution output 2. **[Orchestrator]** Collects failure context from `.process/test-results.json` and logs -3. **[Orchestrator]** Runs Gemini/Qwen CLI with failure context -4. **[CLI Tool]** Analyzes failures and generates fix strategy +3. **[Orchestrator]** Executes Gemini/Qwen CLI tool with failure context +4. **[Orchestrator]** Interprets CLI tool output to extract fix strategy 5. **[Orchestrator]** Saves analysis to `.process/iteration-N-analysis.md` 6. **[Orchestrator]** Generates `IMPL-fix-N.json` with strategy content (not just path) +**Note**: The orchestrator executes CLI analysis tools and processes their output. CLI tools provide analysis, orchestrator manages the workflow. + #### CLI Analysis Command (executed by orchestrator) ```bash cd {project_root} && gemini -p " @@ -516,15 +526,16 @@ Task(subagent_type="{meta.agent}", ### For test-fix (IMPL-002): - Run test suite: {test_command} - Collect results to .process/test-results.json - - If failures: Save context, return to orchestrator + - Report results to orchestrator (do NOT analyze failures) + - Orchestrator will handle failure detection and iteration decisions - If success: Mark complete ### For test-fix-iteration (IMPL-fix-N): - Load fix strategy from context.fix_strategy (CONTENT, not path) - Apply surgical fixes to identified files - - Run tests to verify - - If still failures: Save context with new failure data - - Update iteration state + - Return results to orchestrator + - Do NOT run tests independently - orchestrator manages all test execution + - Do NOT handle failures - orchestrator analyzes and decides next iteration ## STEP 4: Implementation Context (From JSON) **Requirements**: {context.requirements} diff --git a/.claude/commands/workflow/test-fix-gen.md b/.claude/commands/workflow/test-fix-gen.md index bc9878a3..a8179de2 100644 --- a/.claude/commands/workflow/test-fix-gen.md +++ b/.claude/commands/workflow/test-fix-gen.md @@ -13,7 +13,11 @@ allowed-tools: SlashCommand(*), TodoWrite(*), Read(*), Bash(*) This command creates an independent test-fix workflow session for existing code. It orchestrates a 5-phase process to analyze implementation, generate test requirements, and create executable test generation and fix tasks. -**⚠️ Command Scope**: Prepares test workflow artifacts only. Task execution requires separate commands (`/workflow:test-cycle-execute` or `/workflow:execute`). +**⚠️ CRITICAL - Command Scope**: +- **This command ONLY generates task JSON files** (IMPL-001.json, IMPL-002.json) +- **Does NOT execute tests or apply fixes** - all execution happens in separate orchestrator +- **Must call `/workflow:test-cycle-execute`** after this command to actually run tests and fixes +- **Test failure handling happens in test-cycle-execute**, not here ### Dual-Mode Support @@ -44,12 +48,15 @@ fi ### Coordinator Role -This command is a **pure orchestrator**: +This command is a **pure planning coordinator**: - Does NOT analyze code directly - Does NOT generate tests or documentation -- ONLY coordinates slash commands in sequence +- Does NOT execute tests or apply fixes +- Does NOT handle test failures or iterations +- ONLY coordinates slash commands to generate task JSON files - Parses outputs to pass data between phases - Creates independent test workflow session +- **All execution delegated to `/workflow:test-cycle-execute`** --- @@ -267,14 +274,20 @@ Review artifacts: - Test plan: .workflow/[testSessionId]/IMPL_PLAN.md - Task list: .workflow/[testSessionId]/TODO_LIST.md -Next Steps: -- Review IMPL_PLAN.md -- Execute: /workflow:test-cycle-execute [testSessionId] +⚠️ CRITICAL - Next Steps: +1. Review IMPL_PLAN.md +2. **MUST execute: /workflow:test-cycle-execute** + - This command only generated task JSON files + - Test execution and fix iterations happen in test-cycle-execute + - Do NOT attempt to run tests or fixes in main workflow ``` **TodoWrite**: Mark phase 5 completed -**Note**: Command completes here. Task execution requires separate workflow commands. +**⚠️ BOUNDARY NOTE**: +- Command completes here - only task JSON files generated +- All test execution, failure detection, CLI analysis, fix generation happens in `/workflow:test-cycle-execute` +- This command does NOT handle test failures or apply fixes --- @@ -329,7 +342,9 @@ Generates minimum 2 tasks (expandable for complex projects): **Agent**: `@test-fix-agent` -**Purpose**: Execute tests and apply iterative fixes (max 5 iterations) +**Purpose**: Execute initial tests and trigger orchestrator-managed fix cycles + +**Note**: This task executes tests and reports results. The test-cycle-execute orchestrator manages all fix iterations, CLI analysis, and fix task generation. **Task Configuration**: - Task ID: `IMPL-002` @@ -340,11 +355,12 @@ Generates minimum 2 tasks (expandable for complex projects): - `context.requirements`: Execute and fix tests **Test-Fix Cycle Specification**: -- **Cycle Pattern**: test → gemini_diagnose → manual_fix (or codex) → retest -- **Tools Configuration**: +**Note**: This specification describes what test-cycle-execute orchestrator will do. The agent only executes single tasks. +- **Cycle Pattern** (orchestrator-managed): test → gemini_diagnose → manual_fix (or codex) → retest +- **Tools Configuration** (orchestrator-controlled): - Gemini for analysis with bug-fix template → surgical fix suggestions - Manual fix application (default) OR Codex if `--use-codex` flag (resume mechanism) -- **Exit Conditions**: +- **Exit Conditions** (orchestrator-enforced): - Success: All tests pass - Failure: Max iterations reached (5)