## Management Wave Orchestration Strategy

> This file defines the orchestration workflow for the Management Wave — executing metadata management in waves based on a dependency graph.

### Core Philosophy

**Management handles the metadata of defect reports; it does not touch code.**

All strategies operate only on report text and metadata; they do not invoke code tools such as Grep/Read/find_definition. The goal is to maximize noise reduction and calibrate report quality before entering report generation.

### Dependency Graph

```
deduplication (must execute first)
     |
     +-> scope-validation --------+
     +-> noise-filter -----------+  Parallel execution (after dedup)
     +-> severity-calibration ---+
     |
     +-> defect-clustering (execute last, on surviving defects)
```

### Main Task Responsibilities (Orchestrator)

#### 1. Restore Context

1. Read `<output_dir>/.draft-03-validation/manifest.json` (obtain the promoted defect list)
2. Read `.draft-03-validation/<defect_id>.md` as needed (obtain validation details of promoted defects)
3. Create the `<output_dir>/.draft-04-management/` directory
4. Write the initial version of `<output_dir>/.draft-04-management/manifest.json`:
```json
{
  "version": 1,
  "stage": "management",
  "status": "in_progress",
  "waves": {
    "deduplication": {"status": "pending", "output_file": "deduplication.md"},
    "scope-validation": {"status": "pending", "output_file": "scope-validation.md"},
    "noise-filter": {"status": "pending", "output_file": "noise-filter.md"},
    "severity-calibration": {"status": "pending", "output_file": "severity-calibration.md"},
    "defect-clustering": {"status": "pending", "output_file": "defect-clustering.md"}
  },
  "surviving_defects": [],
  "clusters": [],
  "summary": {
    "input_defects": 0,
    "surviving_defects": 0,
    "dedup_removed": 0,
    "scope_removed": 0,
    "noise_removed": 0,
    "severity_changed": 0,
    "clusters_found": 0
  }
}
```

#### 2. Wave 1: deduplication (must execute first)

1. Obtain the full list of promoted defects and their details from the Validation Manifest
2. Launch an Agent subtask, passing in the **subtask execution template** and filling in:
   - `<strategy_name>`: deduplication
   - `<defect_list>`: JSON summary list of all promoted defects
   - `<prev_wave_result>`: none (first Wave)
3. Wait for the subtask to complete
4. Extract deduplication results from the subtask output, update `manifest.json`:
   - `waves.deduplication.status: "completed"`
   - Remove duplicate defects from subsequent input
5. Update TodoWrite

#### 3. Wave 2 (can be parallel): scope-validation + noise-filter + severity-calibration

1. Obtain the deduplicated surviving defect list from Wave 1 results
2. Launch 1-3 Agent subtasks (can run in parallel), each with:
   - `<strategy_name>`: scope-validation / noise-filter / severity-calibration
   - `<defect_list>`: Wave 1 surviving defect list
   - `<prev_wave_result>`: Wave 1 deduplication result summary
3. Wait for all subtasks to complete
4. Merge results, update `manifest.json`:
   - Each wave entry `status: "completed"`
   - Defects determined as filtered by scope-validation / noise-filter are marked for removal
   - Adjustments from severity-calibration are recorded in surviving_defects
5. If any strategy determines a defect should be filtered, that defect is removed (downgrade from severity-calibration does not count as filtering)
6. Update TodoWrite

#### 4. Wave 3: defect-clustering (execute last)

1. Obtain the final surviving defect list from Wave 2 results
2. Launch an Agent subtask:
   - `<strategy_name>`: defect-clustering
   - `<defect_list>`: surviving defect list after Wave 2
   - `<prev_wave_result>`: Wave 2 filtering/adjustment result summary
3. Wait for the subtask to complete
4. Update `manifest.json`:
   - `waves.defect-clustering.status: "completed"`
   - Write clustering results to the `clusters` array
   - Write `cluster_id` into each `surviving_defects` entry
5. Update TodoWrite

#### 5. Aggregation

1. Merge all Wave results into `surviving_defects` and `clusters`
2. Calculate `summary` (number removed/adjusted by each strategy)
3. Set `manifest.json` `status: "completed"`

### Subtask Execution Template

---

## Role
You are a defect management expert, handling the metadata of defect reports without touching code.

## Input
- **Management strategy**: `<strategy_name>`
- **Defect list**:
```json
<defect_list>
```
- **Previous Wave results**: <prev_wave_result>
- **Strategy file**: read `<skill-root>/references/management/<strategy_name>.md`

## Execution Steps

**Warning (mandatory): Use the TodoWrite tool to organize the execution workflow**

1. Read `<skill-root>/references/management/<strategy_name>.md` and execute according to its guidance
2. Evaluate each defect independently
3. **Do not invoke code tools** (Grep/Read/find_definition); operate only on report text and metadata

## Output Format

Write to `<output_dir>/.draft-04-management/<strategy_name>.md`:

```
### <Strategy Name> Execution Results

| Defect ID | Action | Details |
|-----------|--------|---------|
| D001 | Keep | -- |
| D003 | Filter | Reason... |

**Detailed explanation**:
(Specific reasons for each defect that was filtered/adjusted/merged/clustered)
```
