# Stage 4: Planning 3 — Task Decomposition & Estimation

## Purpose

Break implementation specs into worker-ready tasks with dependency graphs, estimates, and context packets.

## Input

- Implementation specs from Planning 2
- ADR from Planning 1
- Project codebase context

## Composition — FIXED

| Role             | Model  | Purpose                                     |
| ---------------- | ------ | ------------------------------------------- |
| Task Distributor | Sonnet | Decomposition, dependency graphs, ownership |
| Context Manager  | Sonnet | Compact context packets per worker task     |

## Process

1. Task Distributor reads all implementation specs
2. Decomposes into concrete tasks:
   - Each task has ONE owner (one worker)
   - Each task has ONE completion condition
   - Write-scope separation (no two concurrent tasks edit same files)
   - Dependency ordering (what must finish before what can start)
3. Context Manager produces a context packet per task:
   - Relevant files/symbols and why they matter
   - Patterns to follow (from specialist specs)
   - Patterns to avoid
   - Acceptance criteria
   - What NOT to touch
4. Estimation in tool-call rounds (not human hours):
   - Simple (< 20 rounds)
   - Medium (20-60 rounds)
   - Complex (60+ rounds — consider splitting)

## Output

- `tasks/` directory with one file per task:
  - Task ID, description, owner type (Codex/Claude)
  - Dependencies (which tasks must complete first)
  - Context packet (files, patterns, constraints)
  - Acceptance criteria
  - Estimated rounds
  - Explicit "do NOT" list
- `tasks/GRAPH.md` — dependency graph with parallel execution opportunities
- `tasks/ESTIMATE.md` — total estimated rounds, critical path

## Gate: decomposition-approval

### Mechanical

- [ ] Every component from Planning 2 has at least one task
- [ ] No task edits files owned by another concurrent task
- [ ] Dependency graph has no cycles
- [ ] Every task has acceptance criteria
- [ ] Every task has an estimate
- [ ] Context packet exists per task

### Gate Reviewer

- "Is this actually implementable as decomposed? Any tasks that are too vague or too large?"
