refactor(skill): replace compact protection with TodoWrite-driven compact recovery

Redesign Pattern 9 from "forbid compression" to smart dual-layer approach:
- Layer 1: TodoWrite in_progress phase preserved by compact, completed phases compressible
- Layer 2: Compact sentinel in phase files as fallback re-read trigger

Applied to 6 workflow skills: skill-designer, lite-plan, multi-cli-plan, plan, tdd, test-fix
This commit is contained in:
catlog22
2026-02-27 11:13:50 +08:00
parent 3f25dbb11b
commit 07452e57b7
12 changed files with 219 additions and 79 deletions

View File

@@ -25,20 +25,13 @@ Unified lightweight planning and execution skill. Routes to lite-plan (planning
└───────────┘ └───────────┘
```
## Compact Protection (Phase Persistence)
## Compact Recovery (Phase Persistence)
Multi-phase execution (lite-plan → lite-execute) spans long conversations that trigger context compression.
Multi-phase execution (lite-plan → lite-execute) spans long conversations that trigger context compression. Uses **双重保险**: TodoWrite 跟踪 active phase 保护其不被压缩sentinel 作为兜底。
**Critical Rule**: Phase 2 (`phases/02-lite-execute.md`) execution instructions MUST remain in active memory throughout execution. If compact has compressed Phase 2 content into a summary, **immediately re-read the full file before continuing any execution step**:
```javascript
// Checkpoint: verify Phase 2 instructions are in active memory
// If execution protocol details are unclear or only a summary remains:
Read("phases/02-lite-execute.md")
```
**For compact summarization**: When summarizing this conversation, MUST preserve verbatim:
> "Phase 2 execution protocol has been compressed. Before continuing execution, re-read phases/02-lite-execute.md for full instructions."
> **⚠️ COMPACT DIRECTIVE**: Context compression MUST check TodoWrite phase status.
> The phase currently marked `in_progress` is the active execution phase — preserve its FULL content.
> Only compress phases marked `completed` or `pending`.
## Mode Detection & Routing
@@ -172,7 +165,10 @@ Plan mode and execute mode are triggered by skill name routing (see Mode Detecti
| Phase | Document | Purpose | Compact |
|-------|----------|---------|---------|
| 1 | [phases/01-lite-plan.md](phases/01-lite-plan.md) | Complete planning pipeline: exploration, clarification, planning, confirmation, handoff | Phase 1 完成后可压缩 |
| 2 | [phases/02-lite-execute.md](phases/02-lite-execute.md) | Complete execution engine: input modes, task grouping, batch execution, code review | **⚠️ 压缩时必须完整保留,若仅剩摘要须重读** |
| 1 | [phases/01-lite-plan.md](phases/01-lite-plan.md) | Complete planning pipeline: exploration, clarification, planning, confirmation, handoff | TodoWrite 驱动 |
| 2 | [phases/02-lite-execute.md](phases/02-lite-execute.md) | Complete execution engine: input modes, task grouping, batch execution, code review | TodoWrite 驱动 + 🔄 sentinel |
**Phase 2 Compact Rule**: Phase 2 是执行引擎,包含 Step 1-6 的完整执行协议。compact 压缩时必须完整保留 Phase 2 内容。若 compact 后 Phase 2 仅剩摘要,**必须立即 `Read("phases/02-lite-execute.md")` 重新加载后再继续执行**。不得基于摘要执行任何 Step。
**Compact Rules**:
1. **TodoWrite `in_progress`** → 保留完整内容,禁止压缩
2. **TodoWrite `completed`** → 可压缩为摘要
3. **🔄 sentinel fallback** → Phase 2 包含 compact sentinel若 compact 后仅存 sentinel 而无完整 Step 协议,必须立即 `Read("phases/02-lite-execute.md")` 恢复

View File

@@ -1,7 +1,9 @@
# Phase 2: Lite-Execute
> **⚠️ COMPACT PROTECTION**: This is an active execution document — NOT reference material. During context compression, this directive MUST be preserved verbatim in the summary:
> **"Phase 2 execution protocol has been compressed. MUST re-read `phases/02-lite-execute.md` before continuing any execution step. Do NOT proceed from summary alone."**
> **📌 COMPACT SENTINEL [Phase 2: Lite-Execute]**
> This phase contains 6 execution steps (Step 1 — 6).
> If you can read this sentinel but cannot find the full Step protocol below, context has been compressed.
> Recovery: `Read("phases/02-lite-execute.md")`
Complete execution engine: multi-mode input, task grouping, batch execution, code review, and development index update.

View File

@@ -114,6 +114,14 @@ if (mode === 'plan') {
}
```
## Compact Recovery (Phase Persistence)
Multi-phase execution (multi-cli-plan → lite-execute) spans long conversations. Uses **双重保险**: TodoWrite 跟踪 active phase 保护其不被压缩sentinel 作为兜底。
> **⚠️ COMPACT DIRECTIVE**: Context compression MUST check TodoWrite phase status.
> The phase currently marked `in_progress` is the active execution phase — preserve its FULL content.
> Only compress phases marked `completed` or `pending`.
## Execution Flow
### Plan Mode (workflow:multi-cli-plan)
@@ -144,7 +152,12 @@ Plan mode and execute mode are triggered by skill name routing (see Mode Detecti
## Phase Reference Documents
| Phase | Document | Purpose |
|-------|----------|---------|
| 1 | [phases/01-multi-cli-plan.md](phases/01-multi-cli-plan.md) | Complete multi-CLI planning pipeline: ACE context, iterative discussion, options, user decision, plan generation, handoff |
| 2 | [phases/02-lite-execute.md](phases/02-lite-execute.md) | Complete execution engine: input modes, task grouping, batch execution, code review |
| Phase | Document | Purpose | Compact |
|-------|----------|---------|---------|
| 1 | [phases/01-multi-cli-plan.md](phases/01-multi-cli-plan.md) | Complete multi-CLI planning pipeline: ACE context, iterative discussion, options, user decision, plan generation, handoff | TodoWrite 驱动 |
| 2 | [phases/02-lite-execute.md](phases/02-lite-execute.md) | Complete execution engine: input modes, task grouping, batch execution, code review | TodoWrite 驱动 + 🔄 sentinel |
**Compact Rules**:
1. **TodoWrite `in_progress`** → 保留完整内容,禁止压缩
2. **TodoWrite `completed`** → 可压缩为摘要
3. **🔄 sentinel fallback** → Phase 2 包含 compact sentinel若 compact 后仅存 sentinel 而无完整 Step 协议,必须立即 `Read("phases/02-lite-execute.md")` 恢复

View File

@@ -1,5 +1,10 @@
# Phase 2: Lite Execute
> **📌 COMPACT SENTINEL [Phase 2: Lite-Execute]**
> This phase contains 6 execution steps (Step 1 — 6).
> If you can read this sentinel but cannot find the full Step protocol below, context has been compressed.
> Recovery: `Read("phases/02-lite-execute.md")`
Complete execution engine supporting multiple input modes: in-memory plan, prompt description, or file content.
## Objective

View File

@@ -113,6 +113,14 @@ function detectMode(args) {
}
```
## Compact Recovery (Phase Persistence)
Multi-phase planning (Phase 1-4/5/6) spans long conversations. Uses **双重保险**: TodoWrite 跟踪 active phase 保护其不被压缩sentinel 作为兜底。
> **⚠️ COMPACT DIRECTIVE**: Context compression MUST check TodoWrite phase status.
> The phase currently marked `in_progress` is the active execution phase — preserve its FULL content.
> Only compress phases marked `completed` or `pending`.
## Execution Flow
### Plan Mode (default)
@@ -166,14 +174,19 @@ Phase 6: Interactive Replan
**Phase Reference Documents** (read on-demand when phase executes):
| Phase | Document | Purpose | Mode |
|-------|----------|---------|------|
| 1 | [phases/01-session-discovery.md](phases/01-session-discovery.md) | Create or discover workflow session | plan |
| 2 | [phases/02-context-gathering.md](phases/02-context-gathering.md) | Gather project context and analyze codebase | plan |
| 3 | [phases/03-conflict-resolution.md](phases/03-conflict-resolution.md) | Detect and resolve conflicts (conditional) | plan |
| 4 | [phases/04-task-generation.md](phases/04-task-generation.md) | Generate implementation plan and task JSONs | plan |
| 5 | [phases/05-plan-verify.md](phases/05-plan-verify.md) | Read-only verification with quality gate | verify |
| 6 | [phases/06-replan.md](phases/06-replan.md) | Interactive replanning with boundary clarification | replan |
| Phase | Document | Purpose | Mode | Compact |
|-------|----------|---------|------|---------|
| 1 | [phases/01-session-discovery.md](phases/01-session-discovery.md) | Create or discover workflow session | plan | TodoWrite 驱动 |
| 2 | [phases/02-context-gathering.md](phases/02-context-gathering.md) | Gather project context and analyze codebase | plan | TodoWrite 驱动 |
| 3 | [phases/03-conflict-resolution.md](phases/03-conflict-resolution.md) | Detect and resolve conflicts (conditional) | plan | TodoWrite 驱动 |
| 4 | [phases/04-task-generation.md](phases/04-task-generation.md) | Generate implementation plan and task JSONs | plan | TodoWrite 驱动 + 🔄 sentinel |
| 5 | [phases/05-plan-verify.md](phases/05-plan-verify.md) | Read-only verification with quality gate | verify | TodoWrite 驱动 |
| 6 | [phases/06-replan.md](phases/06-replan.md) | Interactive replanning with boundary clarification | replan | TodoWrite 驱动 |
**Compact Rules**:
1. **TodoWrite `in_progress`** → 保留完整内容,禁止压缩
2. **TodoWrite `completed`** → 可压缩为摘要
3. **🔄 sentinel fallback** → Phase 4 包含 compact sentinel若 compact 后仅存 sentinel 而无完整 Step 协议,必须立即 `Read("phases/04-task-generation.md")` 恢复
## Core Rules

View File

@@ -1,5 +1,10 @@
# Phase 4: Task Generation
> **📌 COMPACT SENTINEL [Phase 4: Task-Generation]**
> This phase contains 6 execution steps (Step 4.0 — 4.4).
> If you can read this sentinel but cannot find the full Step protocol below, context has been compressed.
> Recovery: `Read("phases/04-task-generation.md")`
Generate implementation plan and task JSONs via action-planning-agent.
## Objective

View File

@@ -155,48 +155,106 @@ Phase files are internal execution documents. They MUST NOT contain:
| Conversion provenance (`Source: Converted from...`) | Implementation detail | Removed |
| Skill routing for inter-phase (`Skill(skill="...")`) | Use direct phase read | Direct `Read("phases/...")` |
### Pattern 9: Compact Protection (Phase Persistence)
### Pattern 9: Compact Recovery (Phase Persistence)
Multi-phase workflows span long conversations. Context compression (compact) may summarize earlier phase documents into brief summaries, causing later phases to lose execution instructions.
Multi-phase workflows span long conversations. Context compression (compact) will naturally summarize earlier phase documents. The strategy uses **双重保险**: TodoWrite 跟踪 active phase 保护其不被压缩sentinel 作为兜底在压缩发生时触发恢复。
**Three-layer protection**:
**Design principle**: TodoWrite `in_progress` = active phase → protect from compact | Sentinel = re-read fallback if protection fails.
| Layer | Location | Mechanism |
|-------|----------|-----------|
| **Anchor** | SKILL.md Phase Reference table | 标注每个 phase 的 compact 策略(可压缩 / 执行期间禁止压缩) |
| **Directive** | Phase 文件顶部 | 告诉 compact 摘要时必须保留"需重读"指令原文 |
| **Checkpoint** | Phase 关键执行步骤前 | 验证指令是否在 memory 中,若仅剩摘要则触发重读 |
**Double insurance mechanism**:
| Layer | Role | Mechanism |
|-------|------|-----------|
| **1. Active Phase Protection** | 预防 | TodoWrite `in_progress` 标记当前 phase → compact 时保留该 phase 完整内容,不压缩 |
| **2. Sentinel Re-read** | 恢复 | Phase 文件嵌入标识符 → 若仍被压缩,检测到 sentinel-only 状态时立即 re-read |
**When to apply**: 任何通过 direct handoff (Pattern 7) 跨 phase 执行的场景,尤其是后续 phase 包含复杂执行协议(多 Step、agent 调度、CLI 编排)时。
**SKILL.md Phase Reference table** — 增加 Compact 列:
---
#### Layer 1: Active Phase Protection (TodoWrite 联动)
TodoWrite 已经跟踪每个 phase 的执行状态。利用此信息驱动 compact 策略:
```
TodoWrite status → Compact behavior:
┌─ completed → ✅ 可压缩(已完成,不再需要完整内容)
├─ in_progress → 🛡️ 禁止压缩(正在执行,必须保留完整协议)
└─ pending → ✅ 可压缩(尚未加载,无内容)
```
**SKILL.md Execution Flow** 中标注 compact 联动:
```markdown
## Execution Flow
> **⚠️ COMPACT DIRECTIVE**: Context compression MUST check TodoWrite phase status.
> The phase currently marked `in_progress` is the active execution phase — preserve its FULL content.
> Only compress phases marked `completed` or `pending`.
Phase 1: Requirements Analysis ← TodoWrite tracks status
└─ Ref: phases/01-xxx.md
Phase 2: Execution Engine ← TodoWrite tracks status
└─ Ref: phases/02-xxx.md
...
```
**TodoWrite 状态转换** 时自动更新 compact 保护范围:
```
Phase 1: in_progress 🛡️ → completed ✅ (compact 可压缩 Phase 1)
Phase 2: pending ✅ → in_progress 🛡️ (compact 保护 Phase 2)
```
---
#### Layer 2: Sentinel Re-read (兜底恢复)
即使有 Layer 1 保护compact 仍可能在极端场景(超长上下文、多轮 agent 调度)下压缩 active phase。Sentinel 确保恢复能力:
**Phase 文件顶部嵌入 sentinel**:
```markdown
> **📌 COMPACT SENTINEL [Phase N: {phase-name}]**
> This phase contains {M} execution steps (Step N.1 — N.{M}).
> If you can read this sentinel but cannot find the full Step protocol below, context has been compressed.
> Recovery: `Read("phases/0N-xxx.md")`
```
Sentinel 设计特点:
- 结构化、醒目 → compact 会将其作为关键信息保留在摘要中
- 包含 step 数量 → 提供自检依据("应该看到 M 个 Step但只有摘要"
- 包含 re-read 路径 → 无需查表即可恢复
---
#### Phase Reference Table (整合双重保险)
```markdown
| Phase | Document | Purpose | Compact |
|-------|----------|---------|---------|
| 1 | phases/01-xxx.md | Planning pipeline | Phase 1 完成后可压缩 |
| 2 | phases/02-xxx.md | Execution engine | **⚠️ 压缩时必须完整保留,若仅剩摘要须重读** |
| 1 | phases/01-xxx.md | Planning | TodoWrite 驱动 |
| 2 | phases/02-xxx.md | Execution | TodoWrite 驱动 + 🔄 sentinel |
**Phase N Compact Rule**: Phase N 是执行引擎,包含 Step 1-M 的完整执行协议。compact 压缩时必须完整保留 Phase N 内容。若 compact 后仅剩摘要,**必须立即 `Read("phases/0N-xxx.md")` 重新加载后再继续执行**。不得基于摘要执行任何 Step。
**Compact Rules**:
1. **TodoWrite `in_progress`** → 保留完整内容,禁止压缩
2. **TodoWrite `completed`** → 可压缩为摘要
3. **🔄 sentinel fallback** → 带此标记的 phase 包含 compact sentinel若 compact 后仅存 sentinel 而无完整 Step 协议,**必须立即 `Read("phases/0N-xxx.md")` 恢复后再继续**
```
**Phase 文件顶部** — Compact Protection directive:
---
#### Checkpoint (执行步骤前双重验证)
```markdown
> **⚠️ COMPACT PROTECTION**: This is an active execution document — NOT reference material.
> During context compression, this directive MUST be preserved verbatim in the summary:
> **"Phase N execution protocol has been compressed. MUST re-read `phases/0N-xxx.md` before continuing any execution step. Do NOT proceed from summary alone."**
> **⚠️ CHECKPOINT**: Before proceeding, verify:
> 1. This phase is TodoWrite `in_progress` (active phase protection)
> 2. Full protocol (Step N.X — N.{M}) is in active memory, not just sentinel
> If only sentinel remains → `Read("phases/0N-xxx.md")` now.
```
**Phase 关键步骤前** — Checkpoint:
```markdown
> **⚠️ CHECKPOINT**: Before proceeding, verify Phase N execution protocol (Step X-Y) is in active memory.
> If only a summary remains, re-read `phases/0N-xxx.md` now.
```
#### Handoff 注释
**Handoff 注释** — 在 direct handoff 代码中标注:
```javascript
// ⚠️ COMPACT PROTECTION: Phase N instructions MUST persist in memory throughout execution.
// If compact compresses Phase N content at any point, re-read this file before continuing.
// See SKILL.md "Phase Reference Documents" section for compact rules.
// Phase N is tracked by TodoWrite — active phase protection applies.
// Sentinel fallback: if compressed despite protection, re-read triggers automatically.
Read("phases/0N-xxx.md")
```
@@ -332,10 +390,14 @@ When `workflowPreferences.autoYes === true`: {auto-mode behavior}.
| Phase | Document | Purpose | Compact |
|-------|----------|---------|---------|
| 1 | [phases/01-xxx.md](phases/01-xxx.md) | ... | 完成后可压缩 |
| 1 | [phases/01-xxx.md](phases/01-xxx.md) | ... | TodoWrite 驱动 |
| N | [phases/0N-xxx.md](phases/0N-xxx.md) | ... | TodoWrite 驱动 + 🔄 sentinel |
...
{For phases that are execution targets of direct handoff (Pattern 7), add Compact Rule below the table — see Pattern 9}
**Compact Rules**:
1. **TodoWrite `in_progress`** → 保留完整内容,禁止压缩
2. **TodoWrite `completed`** → 可压缩为摘要
3. **🔄 sentinel fallback** → 带此标记的 phase 包含 compact sentinel若 compact 后仅存 sentinel 而无完整 Step 协议,必须立即 `Read()` 恢复
## Core Rules
@@ -376,10 +438,11 @@ When `workflowPreferences.autoYes === true`: {auto-mode behavior}.
```markdown
# Phase N: {Phase Name}
> **⚠️ COMPACT PROTECTION**: This is an active execution document — NOT reference material.
> During context compression, this directive MUST be preserved verbatim in the summary:
> **"Phase N execution protocol has been compressed. MUST re-read `phases/0N-xxx.md` before continuing any execution step. Do NOT proceed from summary alone."**
> _(Include this block only for phases that are execution targets of direct handoff — see Pattern 9)_
> **📌 COMPACT SENTINEL [Phase N: {phase-name}]**
> This phase contains {M} execution steps (Step N.1 — N.{M}).
> If you can read this sentinel but cannot find the full Step protocol below, context has been compressed.
> Recovery: `Read("phases/0N-xxx.md")`
> _(Include for phases marked 🔄 in SKILL.md Phase Reference table — see Pattern 9)_
{One-sentence description of this phase's goal.}
@@ -396,8 +459,10 @@ When `workflowPreferences.autoYes === true`: {auto-mode behavior}.
### Step N.2: {Step Name}
> **⚠️ CHECKPOINT**: Before proceeding, verify Phase N execution protocol (Step N.2+) is in active memory.
> If only a summary remains, re-read `phases/0N-xxx.md` now.
> **⚠️ CHECKPOINT**: Before proceeding, verify:
> 1. This phase is TodoWrite `in_progress` (active phase protection)
> 2. Full protocol (Step N.X — N.{M}) is in active memory, not just sentinel
> If only sentinel remains → `Read("phases/0N-xxx.md")` now.
> _(Add checkpoints before critical execution steps: agent dispatch, CLI launch, review — see Pattern 9)_
{Full execution detail}
@@ -428,4 +493,4 @@ When designing a new workflow skill, answer these questions:
| What's the error recovery? | Error Handling | Retry once then report, vs rollback |
| Does it need preference collection? | Interactive Preference Collection | Collect via AskUserQuestion in SKILL.md, pass as workflowPreferences |
| Does phase N hand off to phase M? | Direct Phase Handoff (Pattern 7) | Read phase doc directly, not Skill() routing |
| Will later phases run after long context? | Compact Protection (Pattern 9) | Add directive + checkpoints to execution phases |
| Will later phases run after long context? | Compact Recovery (Pattern 9) | Add sentinel + checkpoints, mark 🔄 in Phase Reference table |

View File

@@ -94,6 +94,14 @@ function detectMode(args) {
}
```
## Compact Recovery (Phase Persistence)
Multi-phase TDD planning (Phase 1-6/7) spans long conversations. Uses **双重保险**: TodoWrite 跟踪 active phase 保护其不被压缩sentinel 作为兜底。
> **⚠️ COMPACT DIRECTIVE**: Context compression MUST check TodoWrite phase status.
> The phase currently marked `in_progress` is the active execution phase — preserve its FULL content.
> Only compress phases marked `completed` or `pending`.
## Execution Flow
### Plan Mode (default)
@@ -149,15 +157,20 @@ Phase 7: TDD Verification
**Phase Reference Documents** (read on-demand when phase executes):
| Phase | Document | Purpose | Mode |
|-------|----------|---------|------|
| 1 | [phases/01-session-discovery.md](phases/01-session-discovery.md) | Create or discover TDD workflow session | plan |
| 2 | [phases/02-context-gathering.md](phases/02-context-gathering.md) | Gather project context and analyze codebase | plan |
| 3 | [phases/03-test-coverage-analysis.md](phases/03-test-coverage-analysis.md) | Analyze test coverage and framework detection | plan |
| 4 | [phases/04-conflict-resolution.md](phases/04-conflict-resolution.md) | Detect and resolve conflicts (conditional) | plan |
| 5 | [phases/05-tdd-task-generation.md](phases/05-tdd-task-generation.md) | Generate TDD tasks with Red-Green-Refactor cycles | plan |
| 6 | [phases/06-tdd-structure-validation.md](phases/06-tdd-structure-validation.md) | Validate TDD structure and present confirmation gate | plan |
| 7 | [phases/07-tdd-verify.md](phases/07-tdd-verify.md) | Full TDD compliance verification with quality gate | verify |
| Phase | Document | Purpose | Mode | Compact |
|-------|----------|---------|------|---------|
| 1 | [phases/01-session-discovery.md](phases/01-session-discovery.md) | Create or discover TDD workflow session | plan | TodoWrite 驱动 |
| 2 | [phases/02-context-gathering.md](phases/02-context-gathering.md) | Gather project context and analyze codebase | plan | TodoWrite 驱动 |
| 3 | [phases/03-test-coverage-analysis.md](phases/03-test-coverage-analysis.md) | Analyze test coverage and framework detection | plan | TodoWrite 驱动 |
| 4 | [phases/04-conflict-resolution.md](phases/04-conflict-resolution.md) | Detect and resolve conflicts (conditional) | plan | TodoWrite 驱动 |
| 5 | [phases/05-tdd-task-generation.md](phases/05-tdd-task-generation.md) | Generate TDD tasks with Red-Green-Refactor cycles | plan | TodoWrite 驱动 + 🔄 sentinel |
| 6 | [phases/06-tdd-structure-validation.md](phases/06-tdd-structure-validation.md) | Validate TDD structure and present confirmation gate | plan | TodoWrite 驱动 + 🔄 sentinel |
| 7 | [phases/07-tdd-verify.md](phases/07-tdd-verify.md) | Full TDD compliance verification with quality gate | verify | TodoWrite 驱动 |
**Compact Rules**:
1. **TodoWrite `in_progress`** → 保留完整内容,禁止压缩
2. **TodoWrite `completed`** → 可压缩为摘要
3. **🔄 sentinel fallback** → Phase 5/6 包含 compact sentinel若 compact 后仅存 sentinel 而无完整 Step 协议,必须立即 `Read()` 恢复对应 phase 文件
## Core Rules

View File

@@ -1,5 +1,10 @@
# Phase 5: TDD Task Generation
> **📌 COMPACT SENTINEL [Phase 5: TDD-Task-Generation]**
> This phase contains 3 execution steps (Step 5.1 — 5.3).
> If you can read this sentinel but cannot find the full Step protocol below, context has been compressed.
> Recovery: `Read("phases/05-tdd-task-generation.md")`
Generate TDD tasks with Red-Green-Refactor cycles via action-planning-agent.
## Objective

View File

@@ -1,5 +1,10 @@
# Phase 6: TDD Structure Validation & Plan Confirmation
> **📌 COMPACT SENTINEL [Phase 6: TDD-Structure-Validation]**
> This phase contains 4 execution steps (Step 6.1 — 6.4).
> If you can read this sentinel but cannot find the full Step protocol below, context has been compressed.
> Recovery: `Read("phases/06-tdd-structure-validation.md")`
Internal validation of TDD task structure and user decision gate for next steps.
## Objective

View File

@@ -97,6 +97,14 @@ if (autoYes) {
**workflowPreferences** is passed to phase execution as context variable, referenced as `workflowPreferences.autoYes` within phases.
## Compact Recovery (Phase Persistence)
Multi-phase test-fix pipeline (Phase 1-5) spans long conversations, especially Phase 5 fix loops. Uses **双重保险**: TodoWrite 跟踪 active phase 保护其不被压缩sentinel 作为兜底。
> **⚠️ COMPACT DIRECTIVE**: Context compression MUST check TodoWrite phase status.
> The phase currently marked `in_progress` is the active execution phase — preserve its FULL content.
> Only compress phases marked `completed` or `pending`.
## Execution Flow
```
@@ -143,13 +151,18 @@ Phase 5: Test Cycle Execution (test-cycle-execute)
**Phase Reference Documents** (read on-demand when phase executes):
| Phase | Document | Purpose |
|-------|----------|---------|
| 1 | [phases/01-session-start.md](phases/01-session-start.md) | Detect input mode, create test session |
| 2 | [phases/02-test-context-gather.md](phases/02-test-context-gather.md) | Gather test context (coverage/codebase) |
| 3 | [phases/03-test-concept-enhanced.md](phases/03-test-concept-enhanced.md) | Gemini analysis, L0-L3 test requirements |
| 4 | [phases/04-test-task-generate.md](phases/04-test-task-generate.md) | Generate task JSONs and IMPL_PLAN.md |
| 5 | [phases/05-test-cycle-execute.md](phases/05-test-cycle-execute.md) | Execute tasks, iterative fix cycles, completion |
| Phase | Document | Purpose | Compact |
|-------|----------|---------|---------|
| 1 | [phases/01-session-start.md](phases/01-session-start.md) | Detect input mode, create test session | TodoWrite 驱动 |
| 2 | [phases/02-test-context-gather.md](phases/02-test-context-gather.md) | Gather test context (coverage/codebase) | TodoWrite 驱动 |
| 3 | [phases/03-test-concept-enhanced.md](phases/03-test-concept-enhanced.md) | Gemini analysis, L0-L3 test requirements | TodoWrite 驱动 |
| 4 | [phases/04-test-task-generate.md](phases/04-test-task-generate.md) | Generate task JSONs and IMPL_PLAN.md | TodoWrite 驱动 |
| 5 | [phases/05-test-cycle-execute.md](phases/05-test-cycle-execute.md) | Execute tasks, iterative fix cycles, completion | TodoWrite 驱动 + 🔄 sentinel |
**Compact Rules**:
1. **TodoWrite `in_progress`** → 保留完整内容,禁止压缩
2. **TodoWrite `completed`** → 可压缩为摘要
3. **🔄 sentinel fallback** → Phase 5 包含 compact sentinel若 compact 后仅存 sentinel 而无完整 Step 协议,必须立即 `Read("phases/05-test-cycle-execute.md")` 恢复
## Core Rules

View File

@@ -1,5 +1,10 @@
# Phase 2: Test Cycle Execution (test-cycle-execute)
> **📌 COMPACT SENTINEL [Phase 5: Test-Cycle-Execute]**
> This phase contains 4 execution steps (Step 2.1 — 2.4).
> If you can read this sentinel but cannot find the full Step protocol below, context has been compressed.
> Recovery: `Read("phases/05-test-cycle-execute.md")`
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