---
description: Convert RFC into actionable tasks grouped by subsystem with pre-drafted commits
alwaysApply: false
globs: ["plan/**/*.md"]
---

# Plan

Convert approved RFC into actionable, atomic task list.

**Shortcut**: `::plan`

**Works with**: `modules/evidence-handling`, `modules/types-as-contracts`

---

## RFC Lifecycle Position

```
plan/drafted/    →    plan/evaluated/    →    plan/ready/    →    DELETE
                           ↑                      ↑
                      ::rfc-eval               ::plan
```

---

## Prerequisites

- RFC must be in `plan/evaluated/` (passed `::rfc-eval`)
- Confidence ≥ 85%
- No unresolved critical issues

---

## Procedure

### Step 1: Analyze RFC

Extract from the approved RFC:
- Recommended approach
- Architecture impact table
- Implementation plan outline
- Estimated effort

### Step 2: Define Type Contracts First

For each new component, define types before implementation tasks:

```python
# Task 1.1 is ALWAYS: Define types/contracts
@dataclass(frozen=True)
class NewComponent:
    """The contract - defines expected structure."""
    field: Type
```

### Step 3: Group Tasks by Subsystem

```yaml
subsystems:
  core:      bengal/core/
  orch:      bengal/orchestration/
  render:    bengal/rendering/
  cache:     bengal/cache/
  health:    bengal/health/
  cli:       bengal/cli/
  tests:     tests/
```

### Step 4: Order by Dependencies

```
Types → Implementation → Integration → Tests
```

### Step 5: Pre-Draft Commits

Each task gets a commit message following Bengal conventions:

```bash
git add -A && git commit -m "<scope>: <what changed>"
```

---

## Output Format

```markdown
# Plan: [Feature Name]

**RFC**: `plan/evaluated/rfc-[name].md`
**Status**: Ready
**Created**: [date]
**Estimated Effort**: [N] hours

---

## Overview

[2-3 sentences: what this plan delivers, key phases]

---

## Phase 1: Type Contracts

Define types before implementation (Bengal philosophy: types as contracts).

### Task 1.1: Define [Component] Type Contract

**Subsystem**: Core
**File**: `bengal/core/[component].py`

**Changes**:
```python
@dataclass(frozen=True)
class NewContract:
    """Immutable contract for [purpose]."""
    field: Type
```

**Tests**: `tests/unit/core/test_[component].py`
- `test_contract_is_frozen`
- `test_contract_fields`

**Commit**:
```bash
git add -A && git commit -m "core: add [Component] type contract"
```

**Confidence Gate**: 90% (core module)

---

### Task 1.2: [Next type contract if needed]
[Same structure]

---

## Phase 2: Core Implementation

### Task 2.1: Implement [Component] Logic

**Subsystem**: Core
**File**: `bengal/core/[component].py`
**Depends on**: 1.1

**Changes**:
- Add `from_dict()` factory method
- Add computed properties

**Tests**: `tests/unit/core/test_[component].py`
- `test_from_dict_creates_instance`
- `test_computed_property_returns_expected`

**Commit**:
```bash
git add -A && git commit -m "core: implement [Component] logic"
```

---

## Phase 3: Orchestration

### Task 3.1: Add [Component] to Build Pipeline

**Subsystem**: Orchestration
**File**: `bengal/orchestration/[orchestrator].py`
**Depends on**: 2.1

**Changes**:
- Import new component
- Add processing step

**Tests**: `tests/integration/test_[feature].py`

**Commit**:
```bash
git add -A && git commit -m "orchestration: integrate [Component] into build"
```

---

## Phase 4: Integration & Polish

### Task 4.1: Add Integration Tests

**Subsystem**: Tests
**File**: `tests/integration/test_[feature].py`
**Depends on**: 3.1

**Tests**:
- `test_end_to_end_[feature]`
- `test_[feature]_with_edge_cases`

**Test Root**: `tests/roots/test-[feature]/` (if new fixture needed)

**Commit**:
```bash
git add -A && git commit -m "tests: add integration tests for [feature]"
```

---

## Dependencies

```mermaid
graph TD
    1.1[1.1 Type Contract] --> 2.1[2.1 Implementation]
    2.1 --> 3.1[3.1 Orchestration]
    3.1 --> 4.1[4.1 Integration Tests]
```

---

## Quality Gates

| Phase | Subsystem | Required Confidence |
|-------|-----------|---------------------|
| 1 | Core | 90% |
| 2 | Core | 90% |
| 3 | Orchestration | 90% |
| 4 | Tests | 85% |

---

## Checklist

- [ ] All tasks have pre-drafted commits
- [ ] Each task is atomic (one commit)
- [ ] Dependencies are explicit
- [ ] Type contracts come first
- [ ] Core tasks require 90% confidence
- [ ] Integration tests defined
```

---

## Task Principles

1. **Types First** - Define contracts before implementation
2. **Atomic** - One logical change per task
3. **Ordered** - Dependencies explicit
4. **Testable** - Each task has verification criteria
5. **Committable** - Each task = one atomic commit

---

## After Planning

```bash
# Move plan to ready
mv plan/evaluated/rfc-[name].md plan/ready/
# Create plan file
# plan/ready/plan-[name].md

# Update RFC status
Status: Ready

# Begin implementation
::implement
```

---

## Related

- `commands/rfc` - RFC drafting
- `commands/rfc-eval` - RFC evaluation
- `commands/implement` - Execute tasks
- `modules/types-as-contracts` - Type-first philosophy
