# Phase 2: Milestone Decomposition

**Based on Phase 0 + Phase 1, decompose the path to North Star into milestones.**

## Rules for milestones

1. **3-7 milestones total** (not more)
2. Each milestone must have:
   - One-sentence goal
   - 2-4 concrete deliverables
   - Executable verification commands (copy-pasteable, in the repo's primary shell)
   - Clear "Done When" criteria with observable evidence
   - Estimated scope (which files/modules change)
   - Maximum 3 parallel work items
   - **Compaction checkpoint**: what the agent must remember if context is compressed
3. Milestones are **ordered by dependency**, not priority
4. First milestone should be achievable in 1-3 sessions
5. Verification commands must use tools already in the project
   (or the milestone includes setting them up)
6. **M0 must ensure verification capability exists** — before any feature work,
   the project must have at least one runnable verification command. How this is
   achieved depends on what Phase 0 discovered:
   - If quality infrastructure is **missing**: M0 is "Quality Infrastructure" (set up
     lint, test, format, validation scripts)
   - If quality infrastructure **already exists and passes**: M0 can be the first
     feature milestone instead — but must still include verification commands
   - If quality infrastructure is **partial**: M0 fills the gaps only
   - Present the M0 recommendation to the human in Phase 1 for confirmation

## Milestone template

```markdown
### M<N>: <one-sentence goal>

**Scope**: <which modules/files change>
**Deliverables**:
- [ ] <deliverable 1>
- [ ] <deliverable 2>

**Verification**:
```text
<primary-shell command 1 that must pass>
<primary-shell command 2 that must pass>
```

**Compaction Checkpoint**: <2-3 sentences summarizing what was achieved and
what the agent must remember if context is compressed mid-milestone>

**Done When**:
- <observable condition 1>
- <observable condition 2>
- All verification commands pass
- <primary doc validation command> passes

**Depends on**: M<N-1> (or "none")
```

## M0: Ensure Verification Capability

The first milestone ensures mechanical verification works. Its content adapts to
what Phase 0 discovered:

**If quality infrastructure is missing** (common for greenfield):
```markdown
### M0: Quality Infrastructure

**Goal**: Every future change is mechanically validated before merge.

**Deliverables** (adapt to discovered needs — do not include tools the project doesn't need):
- [ ] Linter configured and passing (if applicable to the language)
- [ ] Formatter configured and enforced (if applicable)
- [ ] Test runner configured with baseline passing tests
- [ ] Validation scripts generated (only the confirmed variants)
- [ ] Quality gate script generated (only the confirmed variants)
- [ ] Architecture dependency rules documented (and lint-enforced where tooling exists)
```

**If quality infrastructure already exists and passes**:
- M0 can be the first feature milestone
- But it must still include verification commands that prove the harness works

**If quality infrastructure is partial**:
- M0 fills only the gaps discovered in Phase 0f
- Do not re-create what already works

**Invariant (always applies regardless of M0 content)**:
- Before any feature work begins, at least one quality gate command must be runnable
- The primary doc validation command must pass (if docs were generated)

## Present to user

Show all milestones and ask:
- "Does this ordering make sense?"
- "Is M1 small enough to start immediately?"
- "Any milestone missing?"
