feat(verification): add verify → plan → execute loop for gap closure

- Add verify_phase_goal step to execute-phase workflow
- Verifier outputs structured gaps: YAML for planner consumption
- Add --gaps flag to plan-phase for gap closure mode
- Route by verification status: passed, gaps_found, human_needed
- Gap closure creates sequential plans (04, 05...) from verification gaps
- User stays in control at each decision point

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
This commit is contained in:
Lex Christopherson
2026-01-15 10:34:38 -06:00
parent afc43e8833
commit 8e6ad96af1
5 changed files with 388 additions and 377 deletions

View File

@@ -65,9 +65,10 @@ Phase: $ARGUMENTS
- Spawn `gsd-verifier` subagent with phase directory and goal
- Verifier checks must_haves against actual codebase (not SUMMARY claims)
- Creates VERIFICATION.md with detailed report
- If gaps found: create fix plans, execute, re-verify (max 3 cycles)
- If human verification needed: present items to user
- Block until verification passes or user approves
- Route by status:
- `passed` → continue to step 7
- `human_needed` → present items, get approval or feedback
- `gaps_found` → present gaps, offer `/gsd:plan-phase {X} --gaps`
7. **Update roadmap and state**
- Update ROADMAP.md, STATE.md
@@ -93,25 +94,23 @@ Phase: $ARGUMENTS
<offer_next>
**MANDATORY: Present copy/paste-ready next command.**
After phase completes, determine what's next:
After verification completes, route based on status:
**Step 1: Check milestone status**
Read ROADMAP.md. Find current phase number and highest phase in milestone.
| Condition | Action |
|-----------|--------|
| current < highest | More phases → Route A |
| current = highest | Milestone complete → Route B |
| Status | Route |
|--------|-------|
| `gaps_found` | Route C (gap closure) |
| `human_needed` | Present checklist, then re-route based on approval |
| `passed` + more phases | Route A (next phase) |
| `passed` + last phase | Route B (milestone complete) |
---
**Route A: More phases remain in milestone**
**Route A: Phase verified, more phases remain**
```
## ✓ Phase {Z}: {Name} Complete
All {Y} plans finished.
All {Y} plans finished. Phase goal verified.
---
@@ -135,14 +134,14 @@ All {Y} plans finished.
---
**Route B: Milestone complete**
**Route B: Phase verified, milestone complete**
```
🎉 MILESTONE COMPLETE!
## ✓ Phase {Z}: {Name} Complete
All {N} phases finished.
All {N} phases finished. All goals verified.
---
@@ -162,6 +161,46 @@ All {N} phases finished.
---
```
---
**Route C: Gaps found — need additional planning**
```
## ⚠ Phase {Z}: {Name} — Gaps Found
**Score:** {N}/{M} must-haves verified
**Report:** .planning/phases/{phase_dir}/{phase}-VERIFICATION.md
### What's Missing
{Extract gap summaries from VERIFICATION.md}
---
## ▶ Next Up
**Plan gap closure** — create additional plans to complete the phase
`/gsd:plan-phase {Z} --gaps`
<sub>`/clear` first → fresh context window</sub>
---
**Also available:**
- `cat .planning/phases/{phase_dir}/{phase}-VERIFICATION.md` — see full report
- `/gsd:verify-work {Z}` — manual testing before planning
---
```
After user runs `/gsd:plan-phase {Z} --gaps`:
1. Planner reads VERIFICATION.md gaps
2. Creates plans 04, 05, etc. to close gaps
3. User runs `/gsd:execute-phase {Z}` again
4. Execute-phase runs incomplete plans (04, 05...)
5. Verifier runs again → loop until passed
</offer_next>
<wave_execution>

View File

@@ -1,7 +1,7 @@
---
name: gsd:plan-phase
description: Create detailed execution plan for a phase (PLAN.md)
argument-hint: "[phase]"
argument-hint: "[phase] [--gaps]"
allowed-tools:
- Read
- Bash
@@ -18,6 +18,9 @@ Create executable phase prompt with discovery, context injection, and task break
Purpose: Break down roadmap phases into concrete, executable PLAN.md files that Claude can execute.
Output: One or more PLAN.md files in the phase directory (.planning/phases/XX-name/{phase}-{plan}-PLAN.md)
**Gap closure mode (`--gaps` flag):**
When invoked with `--gaps`, plans address gaps identified by the verifier. Load VERIFICATION.md, create plans to close specific gaps.
</objective>
<execution_context>
@@ -33,6 +36,7 @@ Output: One or more PLAN.md files in the phase directory (.planning/phases/XX-na
<context>
Phase number: $ARGUMENTS (optional - auto-detects next unplanned phase if not provided)
Gap closure mode: `--gaps` flag triggers gap closure workflow
**Load project state first:**
@.planning/STATE.md
@@ -59,19 +63,33 @@ Check for and read `.planning/phases/XX-name/{phase}-CONTEXT.md` - contains rese
**Load codebase context if exists:**
Check for `.planning/codebase/` and load relevant documents based on phase type.
**If --gaps flag present, also load:**
@.planning/phases/XX-name/{phase}-VERIFICATION.md — contains structured gaps in YAML frontmatter
</context>
<process>
1. Check .planning/ directory exists (error if not - user should run /gsd:new-project)
2. If phase number provided via $ARGUMENTS, validate it exists in roadmap
3. If no phase number, detect next unplanned phase from roadmap
4. Follow plan-phase.md workflow:
2. Parse arguments: extract phase number and check for `--gaps` flag
3. If phase number provided, validate it exists in roadmap
4. If no phase number, detect next unplanned phase from roadmap
**Standard mode (no --gaps flag):**
5. Follow plan-phase.md workflow:
- Load project state and accumulated decisions
- Perform mandatory discovery (Level 0-3 as appropriate)
- Read project history (prior decisions, issues, concerns)
- Break phase into tasks
- Estimate scope and split into multiple plans if needed
- Create PLAN.md file(s) with executable structure
**Gap closure mode (--gaps flag):**
5. Follow plan-phase.md workflow with gap_closure_mode:
- Load VERIFICATION.md and parse `gaps:` YAML from frontmatter
- Read existing SUMMARYs to understand what's already built
- Create tasks from gaps (each gap.missing item → task candidates)
- Number plans sequentially after existing (if 01-03 exist, create 04, 05...)
- Create PLAN.md file(s) focused on closing specific gaps
</process>
<success_criteria>