workflow-test-fix-cycle
Compare original and translation side by side
🇺🇸
Original
English🇨🇳
Translation
ChineseWorkflow Test-Fix Cycle
工作流测试-修复循环
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).
端到端测试修复工作流流水线:生成包含渐进式测试层级(L0-L3)的测试会话、AI代码验证和任务生成(阶段1),然后通过自适应策略引擎执行迭代修复循环直至通过率≥95%(阶段2)。
Architecture Overview
架构概述
┌────────────────────────────────────────────────────────────────────────────┐
│ 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 │
└──────────┘┌────────────────────────────────────────────────────────────────────────────┐
│ Workflow Test-Fix Cycle Orchestrator (SKILL.md) │
│ → 完整流水线:测试生成 + 迭代执行 │
│ → 阶段调度:读取阶段文档、执行、传递上下文 │
└───────────────┬────────────────────────────────────────────────────────────┘
│
┌────────────┴────────────────────────┐
↓ ↓
┌─────────────────────────┐ ┌─────────────────────────────┐
│ 阶段1:测试-修复生成 │ │ 阶段2:测试周期执行 │
│ phases/01-test-fix-gen │ │ phases/02-test-cycle-execute │
│ 5个子阶段: │ │ 3个阶段: │
│ ① 创建会话 │ │ ① 发现阶段 │
│ ② 收集上下文 │ │ ② 主循环(迭代) │
│ ③ 测试分析(Gemini)│ │ ③ 完成阶段 │
│ ④ 生成任务 │ │ │
│ ⑤ 总结 │ │ Agents(通过spawn_agent调用): │
│ │ │ @cli-planning-agent │
│ Agents(通过spawn_agent调用)│ │ @test-fix-agent │
│ @test-context-search │ │ │
│ @context-search │ │ 策略:保守 → │
│ @cli-execution │ │ 激进 → 精准修复 │
│ @action-planning │ │ │
└────────┬────────────────┘ └────────────┬──────────────────┘
↓ ↓
IMPL-001..002.json 通过率 ≥ 95%
TEST_ANALYSIS_RESULTS.md 自动完成会话
任务流水线:
┌──────────────┐ ┌─────────────────┐ ┌─────────────────┐ ┌──────────────┐
│ IMPL-001 │───→│ IMPL-001.3 │───→│ IMPL-001.5 │───→│ IMPL-002 │
│ 测试生成 │ │ 代码验证 │ │ 质量门禁 │ │ 测试与修复 │
│ L1-L3 │ │ L0 + AI代码问题 │ │ 覆盖率80%+ │ │ 最多10次迭代 │
│@code-developer│ │ @test-fix-agent │ │ @test-fix-agent │ │@test-fix-agent│
└──────────────┘ └─────────────────┘ └─────────────────┘ └──────────────┘
│
修复循环: │
┌──────────────────┘
↓
┌──────────┐
│ @cli-plan│───→ IMPL-fix-N.json
│ agent │
├──────────┤
│@test-fix │───→ 应用修复并重新测试
│ agent │
└──────────┘Key Design Principles
核心设计原则
- Two-Phase Pipeline: Generation (Phase 1) creates session + tasks, Execution (Phase 2) runs iterative fix cycles
- Pure Orchestrator: Dispatch to phase docs, parse outputs, pass context between phases
- Auto-Continue: Full pipeline runs autonomously once triggered
- Subagent Lifecycle: Explicit lifecycle management with spawn_agent → wait → close_agent
- Progressive Test Layers: L0 (Static) → L1 (Unit) → L2 (Integration) → L3 (E2E)
- AI Code Issue Detection: Validates against common AI-generated code problems
- Intelligent Strategy Engine: conservative → aggressive → surgical based on iteration context
- CLI Fallback Chain: Gemini → Qwen → Codex for analysis resilience
- Progressive Testing: Affected tests during iterations, full suite for final validation
- Role Path Loading: Subagent roles loaded via path reference in MANDATORY FIRST STEPS
- 双阶段流水线:生成阶段(阶段1)创建会话和任务,执行阶段(阶段2)运行迭代修复循环
- 纯调度器:调度至阶段文档、解析输出、在阶段间传递上下文
- 自动续行:一旦触发,完整流水线自主运行
- 子Agent生命周期:通过spawn_agent → wait → close_agent进行显式生命周期管理
- 渐进式测试层级:L0(静态)→ L1(单元)→ L2(集成)→ L3(端到端)
- AI代码问题检测:针对常见AI生成代码问题进行验证
- 智能策略引擎:根据迭代上下文从保守策略切换到激进策略再到精准修复策略
- CLI fallback链:Gemini → Qwen → Codex,确保分析的鲁棒性
- 渐进式测试:迭代过程中仅测试受影响的用例,最终验证时运行完整测试套件
- 角色路径加载:子Agent角色通过MANDATORY FIRST STEPS中的路径引用加载
Auto Mode
自动模式
This workflow is fully autonomous - Phase 1 generates test session and tasks, Phase 2 executes iterative fix cycles, all without user intervention until pass rate >= 95% or max iterations reached.
此工作流完全自动化——阶段1生成测试会话和任务,阶段2执行迭代修复循环,全程无需人工干预,直至测试通过率≥95%或达到最大迭代次数。
Subagent API Reference
子Agent API参考
spawn_agent
spawn_agent
Create a new subagent with task assignment.
javascript
const agentId = spawn_agent({
message: `创建一个分配了任务的新子Agent。
javascript
const agentId = spawn_agent({
message: `TASK ASSIGNMENT
TASK ASSIGNMENT
MANDATORY FIRST STEPS (Agent Execute)
MANDATORY FIRST STEPS (Agent Execute)
- Read role definition: ~/.codex/agents/{agent-type}.md (MUST read first)
- Run:
ccw spec load --category "planning execution"
- Read role definition: ~/.codex/agents/{agent-type}.md (MUST read first)
- Run:
ccw spec load --category "planning execution"
TASK CONTEXT
TASK CONTEXT
${taskContext}
${taskContext}
DELIVERABLES
DELIVERABLES
${deliverables}
`
})
undefined${deliverables}
`
})
undefinedwait
wait
Get results from subagent (only way to retrieve results).
javascript
const result = wait({
ids: [agentId],
timeout_ms: 600000 // 10 minutes
})
if (result.timed_out) {
// Handle timeout - can continue waiting or send_input to prompt completion
}从子Agent获取结果(唯一获取结果的方式)。
javascript
const result = wait({
ids: [agentId],
timeout_ms: 600000 // 10分钟
})
if (result.timed_out) {
// 处理超时 - 可继续等待或发送输入提示完成
}send_input
send_input
Continue interaction with active subagent (for clarification or follow-up).
javascript
send_input({
id: agentId,
message: `与活跃子Agent继续交互(用于澄清问题或后续操作)。
javascript
send_input({
id: agentId,
message: `CLARIFICATION ANSWERS
CLARIFICATION ANSWERS
${answers}
${answers}
NEXT STEP
NEXT STEP
Continue with plan generation.
`
})
undefinedContinue with plan generation.
`
})
undefinedclose_agent
close_agent
Clean up subagent resources (irreversible).
javascript
close_agent({ id: agentId })清理子Agent资源(不可逆操作)。
javascript
close_agent({ id: agentId })Usage
使用方法
workflow-test-fix-cycle <input> [options]workflow-test-fix-cycle <input> [options]Input (Phase 1 - Test Generation)
输入(阶段1 - 测试生成)
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)
source-session-id WFS-* 会话ID(会话模式 - 针对已完成实现的测试验证)
feature description 待测试功能的文本描述(提示模式)
/path/to/file.md 需求文件路径(提示模式)
Options (Phase 2 - Cycle Execution)
选项(阶段2 - 周期执行)
--max-iterations=N Custom iteration limit (default: 10)
--max-iterations=N 自定义迭代次数上限(默认: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
workflow-test-fix-cycle WFS-user-auth-v2 # 会话模式
workflow-test-fix-cycle "Test the user authentication API endpoints in src/auth/api.ts" # 提示模式 - 文本
workflow-test-fix-cycle ./docs/api-requirements.md # 提示模式 - 文件
workflow-test-fix-cycle "Test user registration" --max-iterations=15 # 自定义迭代次数
Resume (Phase 2 only - session already created)
恢复(仅阶段2 - 会话已创建)
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)workflow-test-fix-cycle --resume-session="WFS-test-user-auth" # 恢复中断的会话
**质量门禁**:测试通过率≥95%(考虑优先级)或100%
**最大迭代次数**:10次(默认,可调整)
**CLI工具**:Gemini → Qwen → Codex( fallback链)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) |
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 the test-task-generate workflow tool for complete L0-L3 requirements and quality thresholds.
渐进式测试层级(L0-L3):
| 层级 | 名称 | 关注点 |
|---|---|---|
| L0 | 静态分析 | 编译、导入、类型、AI代码问题 |
| L1 | 单元测试 | 函数/类行为(正常/异常/边界场景) |
| L2 | 集成测试 | 组件交互、API契约、故障模式 |
| L3 | 端到端测试 | 用户流程、关键路径(可选) |
核心特性:
- AI代码问题检测 - 针对常见AI生成代码问题进行验证(如幻觉导入、占位符代码、模拟泄漏等)
- 项目类型检测 - 应用合适的测试模板(React、Node API、CLI、库等)
- 质量门禁 - IMPL-001.3(代码验证)和IMPL-001.5(测试质量)确保高标准
详细规范:请查看test-task-generate工作流工具获取完整的L0-L3要求和质量阈值。
Execution Flow
执行流程
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
│
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输入 → 检测模式(会话 | 提示 | 恢复)
│
├─ 恢复模式 → 跳过阶段1
│
└─ 会话/提示模式 → 阶段1
│
阶段1:测试-修复生成(phases/01-test-fix-gen.md)
├─ 子阶段1.1:创建测试会话 → testSessionId
├─ 子阶段1.2:收集测试上下文(spawn_agent) → contextPath
├─ 子阶段1.3:测试生成分析(spawn_agent → Gemini) → TEST_ANALYSIS_RESULTS.md
├─ 子阶段1.4:生成测试任务(spawn_agent) → IMPL-*.json, IMPL_PLAN.md, TODO_LIST.md
└─ 子阶段1.5:阶段1总结
│
阶段2:测试周期执行(phases/02-test-cycle-execute.md)
├─ 发现阶段:加载会话、任务、迭代状态
├─ 主循环(针对每个任务):
│ ├─ 执行 → 测试 → 计算pass_rate
│ ├─ 100% → 成功:进入下一个任务
│ ├─ 95-99% + 低优先级 → 部分成功:批准通过
│ └─ <95% → 修复循环:
│ ├─ 选择策略:保守/激进/精准修复
│ ├─ spawn_agent(@cli-planning-agent) → IMPL-fix-N.json
│ ├─ spawn_agent(@test-fix-agent) → 应用修复并重新测试
│ └─ 重新测试 → 返回决策点
└─ 完成阶段:最终验证 → 总结 → 同步会话状态 → 自动完成会话Core Rules
核心规则
- Start Immediately: First action is progress tracking initialization
- No Preliminary Analysis: Do not read files before Phase 1
- Parse Every Output: Extract data from each phase for the next
- Auto-Continue: After each phase finishes, automatically execute next pending phase
- Phase Loading: Read phase doc on-demand (,
phases/01-*.md)phases/02-*.md - Task Attachment Model: Sub-tasks ATTACH → execute → COLLAPSE
- CRITICAL: DO NOT STOP: Continuous pipeline until Phase 2 completion
- Phase Transition: After Phase 1 summary, immediately begin Phase 2
- Explicit Lifecycle: Always close_agent after wait completes to free resources
- 立即启动:第一项操作是初始化进度跟踪
- 无预分析:在阶段1开始前不要读取任何文件
- 解析所有输出:从每个阶段提取数据用于下一个阶段
- 自动续行:每个阶段完成后,自动执行下一个待处理阶段
- 阶段加载:按需读取阶段文档(,
phases/01-*.md)phases/02-*.md - 任务附加模型:子任务附加 → 执行 → 折叠
- 关键规则:请勿停止:持续运行流水线直至阶段2完成
- 阶段过渡:阶段1总结完成后,立即开始阶段2
- 显式生命周期:wait完成后始终调用close_agent释放资源
Phase Execution
阶段执行细节
Phase 1: Test-Fix Generation
阶段1:测试-修复生成
Read:
phases/01-test-fix-gen.md5 sub-phases that create a test session and generate task JSONs:
- Create Test Session →
testSessionId - Gather Test Context (spawn_agent → wait → close_agent) →
contextPath - Test Generation Analysis (spawn_agent → wait → close_agent) →
TEST_ANALYSIS_RESULTS.md - Generate Test Tasks (spawn_agent → wait → close_agent) → ,
IMPL-001.json,IMPL-001.3.json,IMPL-001.5.json,IMPL-002.json,IMPL_PLAN.mdTODO_LIST.md - Phase 1 Summary (internal - transitions to Phase 2)
Agents Used (via spawn_agent):
- (~/.codex/agents/test-context-search-agent.md) - Context gathering (Session Mode)
test-context-search-agent - (~/.codex/agents/context-search-agent.md) - Context gathering (Prompt Mode)
context-search-agent - (~/.codex/agents/cli-execution-agent.md) - Test analysis with Gemini
cli-execution-agent - (~/.codex/agents/action-planning-agent.md) - Task JSON generation
action-planning-agent
读取文档:
phases/01-test-fix-gen.md5个创建测试会话并生成任务JSON的子阶段:
- 创建测试会话 →
testSessionId - 收集测试上下文(spawn_agent → wait → close_agent) →
contextPath - 测试生成分析(spawn_agent → wait → close_agent) →
TEST_ANALYSIS_RESULTS.md - 生成测试任务(spawn_agent → wait → close_agent) → ,
IMPL-001.json,IMPL-001.3.json,IMPL-001.5.json,IMPL-002.json,IMPL_PLAN.mdTODO_LIST.md - 阶段1总结(内部操作 - 过渡到阶段2)
使用的Agents(通过spawn_agent调用):
- (~/.codex/agents/test-context-search-agent.md) - 上下文收集(会话模式)
test-context-search-agent - (~/.codex/agents/context-search-agent.md) - 上下文收集(提示模式)
context-search-agent - (~/.codex/agents/cli-execution-agent.md) - 基于Gemini的测试分析
cli-execution-agent - (~/.codex/agents/action-planning-agent.md) - 任务JSON生成
action-planning-agent
Phase 2: Test-Cycle Execution
阶段2:测试周期执行
Read:
phases/02-test-cycle-execute.md3-stage iterative execution with adaptive strategy:
- Discovery - Load session, tasks, iteration state
- Main Loop - Execute tasks → Test → Analyze failures → Fix → Re-test
- Completion - Final validation → Summary → Auto-complete session
Agents Used (via spawn_agent):
- (~/.codex/agents/cli-planning-agent.md) - Failure analysis, root cause extraction, fix task generation
cli-planning-agent - (~/.codex/agents/test-fix-agent.md) - Test execution, code fixes, criticality assignment
test-fix-agent
Strategy Engine: conservative (iteration 1-2) → aggressive (pass >80%) → surgical (regression)
读取文档:
phases/02-test-cycle-execute.md3阶段迭代执行,搭配自适应策略:
- 发现阶段 - 加载会话、任务、迭代状态
- 主循环 - 执行任务 → 测试 → 分析失败 → 修复 → 重新测试
- 完成阶段 - 最终验证 → 总结 → 自动完成会话
使用的Agents(通过spawn_agent调用):
- (~/.codex/agents/cli-planning-agent.md) - CLI分析、根因提取、修复任务生成
cli-planning-agent - (~/.codex/agents/test-fix-agent.md) - 测试执行、代码修复、优先级分配
test-fix-agent
策略引擎:保守(迭代1-2)→ 激进(通过率>80%)→ 精准修复(出现回归时)
Output Artifacts
输出产物
Directory Structure
目录结构
{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/{projectRoot}/.workflow/active/WFS-test-[session]/
├── workflow-session.json # 会话元数据
├── IMPL_PLAN.md # 测试生成与执行策略
├── TODO_LIST.md # 任务清单
├── .task/
│ ├── IMPL-001.json # 测试理解与生成
│ ├── IMPL-001.3-validation.json # 代码验证门禁
│ ├── IMPL-001.5-review.json # 测试质量门禁
│ ├── IMPL-002.json # 测试执行与修复循环
│ └── IMPL-fix-{N}.json # 生成的修复任务(阶段2)
├── .process/
│ ├── [test-]context-package.json # 上下文与覆盖率分析
│ ├── TEST_ANALYSIS_RESULTS.md # 测试需求与策略(L0-L3)
│ ├── iteration-state.json # 当前迭代 + 策略 + 阻塞测试用例
│ ├── test-results.json # 最新结果(通过率、优先级)
│ ├── test-output.log # 完整测试输出
│ ├── fix-history.json # 所有修复尝试
│ ├── iteration-{N}-analysis.md # CLI分析报告
│ └── iteration-{N}-cli-output.txt
└── .summaries/iteration-summaries/Progress Tracking Pattern
进度跟踪格式
Phase 1 (Generation):
javascript
[
{ content: "Phase 1: Test-Fix Generation", status: "in_progress" },
{ content: " 1.1 Create Test Session", status: "completed" },
{ content: " 1.2 Gather Test Context", status: "in_progress" },
{ content: " 1.3 Test Generation Analysis", status: "pending" },
{ content: " 1.4 Generate Test Tasks", status: "pending" },
{ content: " 1.5 Phase Summary", status: "pending" },
{ content: "Phase 2: Test-Cycle Execution", status: "pending" }
]Phase 2 (Execution):
javascript
[
{ content: "Phase 1: Test-Fix Generation", status: "completed" },
{ content: "Phase 2: Test-Cycle Execution", status: "in_progress" },
{ content: " Execute IMPL-001: Generate tests [code-developer]", status: "completed" },
{ content: " Execute IMPL-002: Test & Fix Cycle [ITERATION]", status: "in_progress" },
{ 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 auth (pass: 89%, aggressive)", status: "in_progress" }
]Update Rules:
- Phase 1: Attach/collapse sub-phase tasks within Phase 1
- Phase 2: Add iteration items with strategy and pass rate
- Mark completed after each phase/iteration
- Update parent task when all complete
阶段1(生成):
javascript
[
{ content: "Phase 1: Test-Fix Generation", status: "in_progress" },
{ content: " 1.1 Create Test Session", status: "completed" },
{ content: " 1.2 Gather Test Context", status: "in_progress" },
{ content: " 1.3 Test Generation Analysis", status: "pending" },
{ content: " 1.4 Generate Test Tasks", status: "pending" },
{ content: " 1.5 Phase Summary", status: "pending" },
{ content: "Phase 2: Test-Cycle Execution", status: "pending" }
]阶段2(执行):
javascript
[
{ content: "Phase 1: Test-Fix Generation", status: "completed" },
{ content: "Phase 2: Test-Cycle Execution", status: "in_progress" },
{ content: " Execute IMPL-001: Generate tests [code-developer]", status: "completed" },
{ content: " Execute IMPL-002: Test & Fix Cycle [ITERATION]", status: "in_progress" },
{ 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 auth (pass: 89%, aggressive)", status: "in_progress" }
]更新规则:
- 阶段1:在阶段1内附加/折叠子阶段任务
- 阶段2:添加包含策略和通过率的迭代项
- 每个阶段/迭代完成后标记为已完成
- 所有子任务完成后更新父任务状态
Error Handling
错误处理
| 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:
javascript
try {
const agentId = spawn_agent({ message: "..." });
const result = wait({ ids: [agentId], timeout_ms: 600000 });
// ... process result ...
close_agent({ id: agentId });
} catch (error) {
if (agentId) close_agent({ id: agentId });
throw error;
}| 阶段 | 场景 | 操作 |
|---|---|---|
| 1.1 | 源会话不存在(会话模式) | 返回包含会话ID的错误 |
| 1.1 | 无已完成的IMPL任务(会话模式) | 返回错误,源实现不完整 |
| 1.2 | 上下文收集失败 | 返回错误,检查源产物 |
| 1.2 | Agent超时 | 延长超时时间重试,调用close_agent,然后返回错误 |
| 1.3 | Gemini分析失败 | 返回错误,检查上下文包 |
| 1.4 | 任务生成失败 | 重试一次,然后返回错误 |
| 2 | 测试执行错误 | 记录日志,携带错误上下文重试 |
| 2 | CLI分析失败 | Fallback:Gemini → Qwen → Codex → 人工处理 |
| 2 | Agent执行错误 | 保存状态,调用close_agent,携带简化上下文重试 |
| 2 | 达到最大迭代次数 | 生成失败报告,标记为阻塞 |
| 2 | 检测到回归 | 回滚上一次修复,切换到精准修复策略 |
| 2 | 检测到阻塞测试用例 | 切换到替代策略继续执行,在失败报告中记录 |
生命周期错误处理:
javascript
try {
const agentId = spawn_agent({ message: "..." });
const result = wait({ ids: [agentId], timeout_ms: 600000 });
// ... 处理结果 ...
close_agent({ id: agentId });
} catch (error) {
if (agentId) close_agent({ id: agentId });
throw error;
}Coordinator Checklist
协调器检查清单
Phase 1 (Generation):
- Detect input type (session ID / description / file path / resume)
- Initialize progress tracking with 2 top-level phases
- Read for detailed sub-phase execution
phases/01-test-fix-gen.md - Execute 5 sub-phases with spawn_agent → wait → close_agent lifecycle
- Verify all Phase 1 outputs (4+ task JSONs, IMPL_PLAN.md, TODO_LIST.md)
- Ensure all agents are closed after each sub-phase completes
Phase 2 (Execution):
- Read for detailed execution logic
phases/02-test-cycle-execute.md - Load session state and task queue
- Execute iterative test-fix cycles with spawn_agent → wait → close_agent
- Track iterations in progress tracking
- Auto-complete session on success (pass rate >= 95%)
- Ensure all agents are closed after each iteration
Resume Mode:
- If provided, skip Phase 1
--resume-session - Load existing session directly into Phase 2
阶段1(生成):
- 检测输入类型(会话ID / 描述 / 文件路径 / 恢复)
- 初始化包含2个顶级阶段的进度跟踪
- 读取获取子阶段执行细节
phases/01-test-fix-gen.md - 执行5个子阶段,遵循spawn_agent → wait → close_agent生命周期
- 验证阶段1所有输出(4个以上任务JSON、IMPL_PLAN.md、TODO_LIST.md)
- 确保所有Agents在每个子阶段完成后都已关闭
阶段2(执行):
- 读取获取执行逻辑细节
phases/02-test-cycle-execute.md - 加载会话状态和任务队列
- 执行迭代测试-修复循环,遵循spawn_agent → wait → close_agent生命周期
- 在进度跟踪中记录迭代信息
- 成功时自动完成会话(通过率≥95%)
- 确保所有Agents在每个迭代完成后都已关闭
恢复模式:
- 如果提供,跳过阶段1
--resume-session - 直接加载现有会话进入阶段2
Related Skills
相关技能
Prerequisite Skills:
- or
workflow-plan- Complete implementation (Session Mode)workflow-execute - None for Prompt Mode
Phase 1 Agents (used by phases/01-test-fix-gen.md via spawn_agent):
- (~/.codex/agents/test-context-search-agent.md) - Test coverage analysis (Session Mode)
test-context-search-agent - (~/.codex/agents/context-search-agent.md) - Codebase analysis (Prompt Mode)
context-search-agent - (~/.codex/agents/cli-execution-agent.md) - Test requirements with Gemini
cli-execution-agent - (~/.codex/agents/action-planning-agent.md) - Task JSON generation
action-planning-agent
Phase 2 Agents (used by phases/02-test-cycle-execute.md via spawn_agent):
- (~/.codex/agents/cli-planning-agent.md) - CLI analysis, root cause extraction, task generation
cli-planning-agent - (~/.codex/agents/test-fix-agent.md) - Test execution, code fixes, criticality assignment
test-fix-agent
Follow-up:
- Session sync:
$session-sync -y "Test-fix cycle complete: {pass_rate}% pass rate" - Session auto-complete on success
- Issue creation for follow-up work (post-completion expansion)
前置技能:
- 或
workflow-plan- 已完成实现(会话模式)workflow-execute - 提示模式无前置技能
阶段1使用的Agents(由phases/01-test-fix-gen.md通过spawn_agent调用):
- (~/.codex/agents/test-context-search-agent.md) - 测试覆盖率分析(会话模式)
test-context-search-agent - (~/.codex/agents/context-search-agent.md) - 代码库分析(提示模式)
context-search-agent - (~/.codex/agents/cli-execution-agent.md) - 基于Gemini的测试需求分析
cli-execution-agent - (~/.codex/agents/action-planning-agent.md) - 任务JSON生成
action-planning-agent
阶段2使用的Agents(由phases/02-test-cycle-execute.md通过spawn_agent调用):
- (~/.codex/agents/cli-planning-agent.md) - CLI分析、根因提取、任务生成
cli-planning-agent - (~/.codex/agents/test-fix-agent.md) - 测试执行、代码修复、优先级分配
test-fix-agent
后续操作:
- 会话同步:
$session-sync -y "Test-fix cycle complete: {pass_rate}% pass rate" - 成功时自动完成会话
- 完成后创建Issue用于后续扩展工作