create-harness-vibe-coding 0.8.6 → 0.8.7

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (38) hide show
  1. package/package.json +1 -1
  2. package/src/generator.js +30 -11
  3. package/src/index.js +129 -5
  4. package/templates/common/.claude/agents/reflector.md +35 -0
  5. package/templates/common/.claude/agents/verifier.md +5 -3
  6. package/templates/common/.claude/commands/wf-help.md +1 -2
  7. package/templates/common/.claude/skills/subagent-orchestrator/SKILL.md +10 -4
  8. package/templates/common/.claude/skills/wf/SKILL.md +7 -3
  9. package/templates/common/.claude/skills/wf-auto/SKILL.md +59 -107
  10. package/templates/common/.claude/skills/wf-auto-spark/SKILL.md +19 -17
  11. package/templates/common/.claude/skills/wf-max/SKILL.md +40 -21
  12. package/templates/common/.claude/skills/wf-update/SKILL.md +9 -4
  13. package/templates/common/.codex/config.toml +5 -0
  14. package/templates/common/.harness-version +36 -34
  15. package/templates/common/AGENTS.md +26 -25
  16. package/templates/common/CLAUDE.md +10 -9
  17. package/templates/common/Harness/ACCEPTANCE_PROTOCOL.md +12 -4
  18. package/templates/common/Harness/README.md +10 -11
  19. package/templates/common/Harness/WF-AUTO-SPARK.md +18 -1
  20. package/templates/common/Harness/WF-AUTO.md +518 -492
  21. package/templates/common/Harness/WF-MAX.md +284 -232
  22. package/templates/common/Harness/WF.md +47 -29
  23. package/templates/common/Harness/agent-workflow.md +108 -76
  24. package/templates/common/Harness/dispatch.md +96 -95
  25. package/templates/common/Harness/extension.md +1 -1
  26. package/templates/common/Harness/subagents.md +78 -56
  27. package/templates/common/Harness/tasks/_template/ARTIFACTS.md +1 -1
  28. package/templates/common/Harness/tasks/_template/NOTES.md +1 -1
  29. package/templates/common/Harness/tasks/_template/PLAN.md +53 -60
  30. package/templates/common/Harness/tasks/_template/PROGRESS.md +26 -29
  31. package/templates/common/MEMORY.md +26 -29
  32. package/templates/common/SETUP.md +1 -1
  33. package/templates/common/scripts/scan-clean.mjs +80 -41
  34. package/templates/common/scripts/validate-harness.mjs +101 -31
  35. package/templates/common/scripts/wf-remove.mjs +279 -278
  36. package/templates/common/scripts/wf-update-check.mjs +395 -195
  37. package/templates/optional/skills/browser-e2e/.claude/skills/wf-browser/SKILL.md +1 -1
  38. package/templates/optional/skills/browser-e2e/Harness/workflows/browser-e2e.md +57 -21
@@ -1,73 +1,119 @@
1
- # WF-MAX Maximum Parallelism Workflow
2
-
3
- **WF-MAX is a three-layer architecture: global mode (`wf-max`), agent role (`ceo|manager|worker|reviewer`), dispatch permission (`writeSet`, `forbidden`, `verification`). Global mode every agent is CEO.**
4
-
5
- ```
6
- CEO CONTRACT (top-level orchestrator only Workers follow their dispatch packet):
7
-
8
- ALLOWED first actions:
9
- 1. Read CLAUDE.md, Harness/MEMORY.md, Harness/README.md, Harness/WF-MAX.md
10
- 2. Create task PLAN/PROGRESS
11
- 3. Spawn W0 read-only agents in ONE message
12
-
13
- FORBIDDEN before W0 returns:
14
- - Read source files deeply (scoping only via Grep/Glob)
15
- - Edit / Write / MultiEdit on source files
16
- - Bash (except ls/dir/tree/git status/git diff)
17
-
18
- FORBIDDEN always (unless writing PLAN.md/PROGRESS.md):
19
- - Edit / Write / MultiEdit on source files delegate to Workers with explicit writeSet
20
-
21
- Workers: edit only files in dispatch.writeSet. Outside writeSet blocked.
22
- Managers: scope, coordinate. No source edits. Reviewers: read only.
23
-
24
- If tempted to Read/Edit/Bash a source file STOP. Spawn a Worker.
25
- ```
26
-
27
- WF-MAX is the maximum-parallelism version of the same acceptance-driven flow used
28
- by `/wf`: Mini PRD -> Acceptance Criteria -> UI/API Contracts -> Test Plan ->
29
- Implementation Dispatch -> Independent Validation -> Review -> Debug -> Memory.
1
+ # WF-MAX - Maximum Parallelism Workflow
2
+
3
+ **WF-MAX is a three-layer architecture: global mode (`wf-max`), agent role (`ceo|manager|worker|reviewer|verifier|reflector`), dispatch permission (`writeSet`, `forbidden`, `verification`). Global mode != every agent is CEO.**
4
+
5
+ ```
6
+ CEO CONTRACT (top-level orchestrator only - Workers follow their dispatch packet):
7
+
8
+ ALLOWED first actions:
9
+ 1. Read CLAUDE.md, Harness/MEMORY.md, Harness/README.md, Harness/WF-MAX.md
10
+ 2. Create task PLAN/PROGRESS
11
+ 3. Spawn W0 read-only agents in ONE message
12
+
13
+ FORBIDDEN before W0 returns:
14
+ - Read source files deeply (scoping only via Grep/Glob)
15
+ - Edit / Write / MultiEdit on source files - delegate to Workers with explicit writeSet
16
+ - Bash (except ls/dir/tree/git status/git diff)
17
+
18
+ FORBIDDEN always (unless writing PLAN.md/PROGRESS.md):
19
+ - Edit / Write / MultiEdit on source files - delegate to Workers with explicit writeSet
20
+
21
+ Workers: edit only files in dispatch.writeSet. Outside writeSet -> blocked.
22
+ Managers: scope, coordinate. No source edits. Reviewers: read only.
23
+
24
+ If tempted to Read/Edit/Bash a source file -> STOP. Spawn a Worker.
25
+ ```
26
+
27
+ WF-MAX is the maximum-parallelism extension of WF. It is a strict superset: it
28
+ inherits the complete WF role chain and all acceptance gates, then expands each
29
+ phase through CEO -> Manager -> Worker fan-out. The required chain is:
30
+ Mini PRD -> Acceptance Criteria -> UI/API Contracts -> Test Plan ->
31
+ Implementation Dispatch -> Independent Validation -> Cross-Review ->
32
+ Debug/iterate if needed -> verifier evidence -> Cross-Review ->
33
+ Reflector PASS -> Final Acceptance -> Memory.
30
34
  The hierarchy changes; the source of truth does not. PRD-derived AC IDs govern
31
- every worker dispatch, test, review, validation result, debug handoff, and memory
32
- entry. See [ACCEPTANCE_PROTOCOL.md](ACCEPTANCE_PROTOCOL.md),
35
+ every worker dispatch, test, review, validation result, debug handoff,
36
+ reflection verdict, and memory entry. See
37
+ [ACCEPTANCE_PROTOCOL.md](ACCEPTANCE_PROTOCOL.md),
33
38
  [AGENT_ISOLATION.md](AGENT_ISOLATION.md), and [HARNESS_BRIDGE.md](HARNESS_BRIDGE.md).
34
39
 
35
40
  ## Trigger
36
-
37
- - Explicit: `/wf-max [task]`
38
- - Auto: WF task with write-set 5 files AND clear disjoint boundaries
39
- - parallelismScore = (files × avgLines × 3 / 800) × independenceFactor
40
- - spawn 2.0 | maybe 1.0-2.0 | skip <1.0 (degrade to /wf)
41
-
42
- ## Explicit Invocation Is an Absolute Fan-Out Mandate
43
-
44
- When the user types `/wf-max` (or `wf max`), spawning subagents is **mandatory and unconditional**. File count, task size, line count, and overhead estimates DO NOT apply to explicit invocation they govern ONLY auto-triggering (whether the harness enters wf-max on its own). A 1-file task invoked with `/wf-max` still fans out to parallel subagents.
45
-
46
- "Degrade to /wf" changes the **organization** (flat vs CEO→Manager→Worker), never the **fact** of fan-out: `/wf` itself requires ≥3 subagents before second planning. There is no path from an explicitly typed command to a solo main-thread pass. If you find yourself reading source files and editing them directly after the user typed `/wf-max`, you have violated this mandate — stop and dispatch.
47
-
48
- ## Companion Docs
49
-
50
- - [subagents.md](subagents.md) agent roster, controller role, efficiency ladder
51
- - [dispatch.md](dispatch.md) — handoff format, File claim, Concurrency group fields
52
- - [agent-workflow.md](agent-workflow.md) build/test/review loop, cohesion rule, completion gate
53
-
54
- ## Organization Model
55
-
56
- ```
57
- CEO(1) ──┬── Manager₁(span) ──┬── Worker₁..ₙ
58
- │ └── Sub-Manager(span) Worker₁..ₙ [depth ≥3]
59
- └── Manager₂(span) ── Worker₁..ₙ
60
- ```
61
-
62
- - CEO: intent, scope, integration, final verification. Direct reports 3-5 Managers. **CEO never writes code directly** — dispatch Workers for all file changes. CEO only synthesizes results and decides next waves.
63
- - Manager: domain partition → parallel dispatch → synthesize → report. Serial across domains; parallel within domain. **Manager agents must be defined by the project** (not shipped by the harness) — create them under `.claude/agents/` with the `Agent` tool enabled for nested spawning.
64
- - Worker: single file per write Worker (implementer, one file_claim). Single dimension/topic per read Worker (reviewer, researcher). File claims must be file-level disjoint. Topic-level splitting within a single file is only allowed for read-only Workers.
65
- - depth ≥3: Manager spawns Sub-Manager (span ≤7) instead of Worker. Recursive until leaf condition met.
66
-
67
- ## Decomposition Gate (MANDATORY — CEO-level, before ANY Worker dispatch)
68
-
69
- The Decomposition Gate is a hard stop. No code changes, no Worker spawns until the gate passes. The CEO MUST produce a Dispatch Table artifact and pass the Self-Audit Checklist. This is the single most important enforcement mechanism in WF-MAX — it exists because **models default to "do it myself" rather than "decompose and delegate."**
70
-
41
+
42
+ - Explicit: `/wf-max [task]`
43
+ - Auto: WF task with write-set >=5 files AND clear disjoint boundaries
44
+ - parallelismScore = (files * avgLines * 3 / 800) * independenceFactor
45
+ - spawn >=2.0 | maybe 1.0-2.0 | skip <1.0 (degrade to /wf)
46
+
47
+ ## Explicit Invocation Is an Absolute Fan-Out Mandate
48
+
49
+ When the user types `/wf-max` (or `wf max`), spawning subagents is **mandatory and unconditional**. File count, task size, line count, and overhead estimates DO NOT apply to explicit invocation - they govern ONLY auto-triggering (whether the harness enters wf-max on its own). A 1-file task invoked with `/wf-max` still fans out to parallel subagents.
50
+
51
+ WF-MAX uses cross-CLI overflow for maximum fan-out: use the current runtime
52
+ subagent pool first; when it reaches a practical limit, spawn the other CLI with
53
+ explicit dispatch packets (Codex -> `claude -p`, Claude -> available Codex CLI
54
+ such as `codex exec`). Only use bounded-pass fallback when neither runtime
55
+ subagents nor cross-CLI overflow are available.
56
+
57
+ ### Runtime Thread Budget And Overflow
58
+
59
+ WF-MAX removes the Harness default agent-count cap, not the runtime's real
60
+ limits. Before a large fan-out wave, the CEO records the active runtime budget:
61
+
62
+ - Codex: inspect known config surfaces when available, especially
63
+ `agents.max_threads` and `agents.max_depth` in Codex config. Generated
64
+ Harness projects set `.codex/config.toml` to `max_threads = 12` and
65
+ `max_depth = 1` by default. Codex's unset default may be lower than the
66
+ planned wave.
67
+ - Claude: use the available subagent/task limit reported by the current
68
+ runtime.
69
+ - Billing, rate limits, local resources, and organization policy still apply.
70
+
71
+ Overflow order:
72
+
73
+ 1. Use the current runtime's native subagents up to the configured safe budget.
74
+ 2. Close completed agents before treating the pool as exhausted.
75
+ 3. If more independent work remains, overflow to the other CLI with explicit
76
+ dispatch packets (`claude -p` or `codex exec`).
77
+ 4. If Codex remains bottlenecked and additional native Codex parallelism would
78
+ materially help, ask the user before raising `agents.max_threads` above the
79
+ scaffold default. Offer a concrete value and tradeoff. Do not silently edit
80
+ project or global Codex config.
81
+ 5. Keep `agents.max_depth = 1` unless the user explicitly approves recursive
82
+ delegation; deeper nesting can multiply fan-out, token use, latency, and
83
+ local resource pressure.
84
+ 6. If both runtimes are unavailable or exhausted, use bounded role passes and
85
+ record the fallback in the task PLAN.
86
+
87
+ Do not rely on forked conversations, derived threads, undocumented config,
88
+ environment variables, Codex++, local patches, or third-party forks as stable
89
+ capacity. Treat them as experimental at best and unsafe for required WF-MAX
90
+ behavior.
91
+
92
+ "Degrade to /wf" changes the **organization** (flat vs CEO/Manager/Worker), never the **complete WF role chain**. `/wf` itself requires plan, research/docs research as needed, architecture, test, implement, independent validation, cross-review, reflector, and final acceptance. There is no path from an explicitly typed command to a solo main-thread pass. If you find yourself reading source files and editing them directly after the user typed `/wf-max`, you have violated this mandate: stop and dispatch.
93
+
94
+ ## Companion Docs
95
+
96
+ - [subagents.md](subagents.md) - agent roster, controller role, efficiency ladder
97
+ - [dispatch.md](dispatch.md) - handoff format, File claim, Concurrency group fields
98
+ - [agent-workflow.md](agent-workflow.md) - build/test/review loop, cohesion rule, completion gate
99
+
100
+ ## Organization Model
101
+
102
+ ```
103
+ CEO(1) -> Manager_1(span) -> Worker_1..n
104
+ -> Manager_2(span) -> Sub-Manager(span) -> Worker_1..n [depth >=3]
105
+ -> Manager_3(span) -> Worker_1..n
106
+ ```
107
+
108
+ - CEO: intent, scope, integration, final verification. Direct reports 3-5 Managers. **CEO never writes code directly** - dispatch Workers for all file changes. CEO only synthesizes results and decides next waves.
109
+ - Manager: domain partition -> parallel dispatch -> synthesize -> report. Serial across domains; parallel within domain. **Manager agents must be defined by the project** (not shipped by the harness) - create them under `.claude/agents/` with the `Agent` tool enabled for nested spawning.
110
+ - Worker: single file per write Worker (implementer, one file_claim). Single dimension/topic per read Worker (reviewer, researcher). File claims must be file-level disjoint. Topic-level splitting within a single file is only allowed for read-only Workers.
111
+ - depth >=3: Manager spawns Sub-Manager (span <=7) instead of Worker. Recursive until leaf condition met.
112
+
113
+ ## Decomposition Gate (MANDATORY - CEO-level, before ANY Worker dispatch)
114
+
115
+ The Decomposition Gate is a hard stop. No code changes, no Worker spawns until the gate passes. The CEO MUST produce a Dispatch Table artifact and pass the Self-Audit Checklist. This is the single most important enforcement mechanism in WF-MAX - it exists because **models default to "do it myself" rather than "decompose and delegate."**
116
+
71
117
  ### Gate Artifact: Dispatch Table
72
118
 
73
119
  WF-MAX gate order:
@@ -81,6 +127,7 @@ PRD-GATE
81
127
  -> IMPLEMENT-GATE
82
128
  -> VALIDATION-GATE
83
129
  -> REVIEW-GATE
130
+ -> REFLECT-GATE
84
131
  ```
85
132
 
86
133
  D-GATE answers "who may change which file." The earlier gates answer "what must
@@ -89,7 +136,7 @@ implementers." The Dispatch Table must map each write Worker to the AC IDs it
89
136
  implements.
90
137
 
91
138
  CEO MUST write this table in the task PLAN.md after W1 architecture defines the write-set and before W2 implementation dispatch:
92
-
139
+
93
140
  ```
94
141
  | File | Concern | Worker Type | Worker Label | Read-Only? |
95
142
  |------|---------|------------|--------------|------------|
@@ -108,135 +155,136 @@ Acceptance-specific gate rules:
108
155
  1. PRD, AC, UI/API contracts, and test plan must exist before implementation dispatch.
109
156
  2. Every write Worker row must cite AC IDs.
110
157
  3. Implementer forbidden set must include PRD, AC, UI/API contracts, test plan, and validation report unless an approved Change Request is recorded.
111
-
112
- 1. **Every file in the write-set MUST have exactly one write Worker.** Unassigned files = fail. This is the anti-bundling rule one Worker touching >1 write file = fail. (Read Workers may span multiple files.)
113
- 2. **Manager count MUST span_min = ceil(sqrt(write_files) / 3).** This is the anti-under-decomposition rule at the domain level. Fewer than the minimum number of Managers means domains are too coarse. "One Manager can handle everything" is NOT valid in WF-MAX if the task were that simple, degrade to /wf.
114
- 3. **Each Manager MUST have 2 Workers and ≤7 Workers.** 0-1 Workers = Phantom Manager dissolve. >7 Workers Manager context is overloaded split the domain and add a Manager.
115
- 4. **CEO MUST NOT appear as a Worker row.** CEO writes no production code fail.
116
-
117
- ### CEO Tool Boundary
118
-
119
- The CEO operates under a strict tool restriction model for production code:
120
-
121
- | CEO Has | CEO MUST NOT Use (on source code) |
122
- |---------|-----------------------------------|
123
- | Task (spawn agents) | Edit (on source files) |
124
- | Read (for scoping) | Write (on source files) |
125
- | TodoWrite (tracking) | Bash (except final verification) |
126
- | Grep/Glob (for scoping) | MultiEdit (on source files) |
127
-
128
- **Exception**: CEO MAY write to `Harness/tasks/<id>/PLAN.md` and `Harness/tasks/<id>/PROGRESS.md` these are task-tracking artifacts, not production code. The Dispatch Table, Self-Audit Checklist, and synthesis reports are the CEO's primary durable artifacts.
129
-
130
- If the CEO finds itself reaching for Edit/Write/Bash on source files, it is violating role boundaries. Stop. Delegate to a Worker.
131
-
132
- ### Self-Audit Checklist
133
-
158
+
159
+ 1. **Every file in the write-set MUST have exactly one write Worker.** Unassigned files = fail. This is the anti-bundling rule - one Worker touching >1 write file = fail. (Read Workers may span multiple files.)
160
+ 2. **Manager count MUST be at least `Manager_min`.** This is the anti-under-decomposition rule at the domain level. Fewer than the minimum number of Managers means domains are too coarse. "One Manager can handle everything" is NOT valid in WF-MAX - if the task were that simple, degrade to /wf.
161
+ 3. **Each write Manager MUST have 2-7 write Workers, except XS explicit `/wf-max` where a one-file write set may use one write Worker plus separate read/review/verify/reflect roles.** Read-only review/research Managers use the domain caps below. 0-1 unsupported Workers = Phantom Manager -> dissolve. > cap = Manager context is overloaded -> split the domain and add a Manager.
162
+ 4. **CEO MUST NOT appear as a Worker row.** CEO writes no production code - fail.
163
+
164
+ ### CEO Tool Boundary
165
+
166
+ The CEO operates under a strict tool restriction model for production code:
167
+
168
+ | CEO Has | CEO MUST NOT Use (on source code) |
169
+ |---------|-----------------------------------|
170
+ | Task (spawn agents) | Edit (on source files) |
171
+ | Read (for scoping) | Write (on source files) |
172
+ | TodoWrite (tracking) | Bash (except final verification) |
173
+ | Grep/Glob (for scoping) | MultiEdit (on source files) |
174
+
175
+ **Exception**: CEO MAY write to `Harness/tasks/<id>/PLAN.md` and `Harness/tasks/<id>/PROGRESS.md` - these are task-tracking artifacts, not production code. The Dispatch Table, Self-Audit Checklist, and synthesis reports are the CEO's primary durable artifacts.
176
+
177
+ If the CEO finds itself reaching for Edit/Write/Bash on source files, it is violating role boundaries. Stop. Delegate to a Worker.
178
+
179
+ ### Self-Audit Checklist
180
+
134
181
  After producing the Dispatch Table, CEO MUST answer all before proceeding:
135
182
 
136
183
  - [ ] Do PRD, AC, contracts, and test plan exist before implementation dispatch?
137
184
  - [ ] Does every implementation Worker row cite AC IDs?
138
185
  - [ ] Are truth files excluded from implementer write sets unless Change Request is approved?
139
-
140
- - [ ] Did I assign myself any source file? (must be **No** PLAN.md/PROGRESS.md writes are the exception)
141
- - [ ] Is every file with planned changes assigned to exactly one write Worker? (must be **Yes**)
142
- - [ ] Does any Worker have >1 write file? (must be **No**)
143
- - [ ] Is Manager count ceil(sqrt(write_files) / 3)? (must be **Yes**, or justification written)
144
- - [ ] Does every Manager have 2-7 Workers? (<2 = Phantom Manager, >7 = overloaded)
145
- - [ ] Are there files >200 lines or with >1 concern that should be split into separate files?
146
- - [ ] Could any serial chain be parallelized? (different files with no shared imports = parallelize)
147
- - [ ] Will all Workers be spawned in ONE message?
148
-
149
- Gate retries until all checks pass. **CEO may NOT proceed to W1 with a failing gate.**
150
-
151
- ## Anti-Pattern Catalog
152
-
153
- Before every wave dispatch, CEO MUST scan for these patterns. **Any match = stop and re-decompose.**
154
-
155
- | # | Anti-Pattern | Symptom | Detection | Fix |
156
- |---|-------------|---------|-----------|-----|
157
- | AP1 | **CEO-as-Worker** | CEO assigns itself a file or starts writing code | CEO in Dispatch Table; Edit/Write/Bash used by CEO | Re-delegate to a Worker immediately |
158
- | AP2 | **Under-decomposition** | Fewer Workers than `ceil(sqrt(files))` | Count check fails; "1-2 agents is enough for this" | Split files by concern, module, or layer |
159
- | AP3 | **Serialization trap** | "Let me do X first, then I'll know how to dispatch Y" | Sequential plan without parallel candidates | Dispatch X and Y in parallel NOW; Worker-X returns spec that Worker-Y consumes |
160
- | AP4 | **Fake parallelism** | Multiple Workers assigned same file | Duplicate file path in Dispatch Table | One file = one Writer. Split file into separate modules, or serialize |
161
- | AP5 | **Phantom Manager** | Manager spawns 0-1 Workers | Manager's sub-table has <2 Workers | Dissolve Manager; CEO or sibling absorbs domain |
162
- | AP6 | **Sequential spawn** | Workers spawned one-per-turn instead of batched | Only 1 Task() call per message | Batch ALL Task() calls into ONE message |
163
- | AP7 | **Silent degrade** | CEO switches to /wf without recording reason | No Dispatch Table; flat agent spawns | Explicit decision + justification in PLAN.md; only valid reason is overhead > 0.30 |
164
-
165
- ## Span Formula (Prescriptive Floor)
166
-
167
- ```
168
- Manager_min = ceil(sqrt(write_files) / 3) # HARD FLOOR you MUST have ≥ this many Managers
169
- Manager_max = min(Manager_min × 2, 7) # per-wave; exceed only with written justification
170
- Worker_max_per_manager = 7 # hard cap; split domain if exceeded
171
-
172
- Worker count per wave = write_files (one Worker per write file, guaranteed by Gate Rule #1)
173
-
174
- Domain caps (workers per Manager by type):
175
- Architecture: cap = 3
176
- Implementation: cap = 7
177
- Review: cap = 10
178
- Research: cap = 12
179
- ```
180
-
181
- **Manager_min is a floor, not a target.** The span formula prevents domain-level under-decomposition the real failure mode where one Manager tries to coordinate too many Workers across unrelated concerns. Worker-level under-decomposition is prevented by Gate Rule #1 (one file per Worker).
182
-
183
- ## Total Agents (recursive, scales to 1000)
184
-
185
- ```
186
- total(depth, span) = Σ span^L for L=0..depth
187
- ```
188
-
189
- - depth=0: CEO + Workers only (XS)
190
- - depth=1: CEO + Managers + Workers
191
- - depth=2: CEO + Managers + Workers
192
- - depth3: CEO + Managers + Sub-Managers + Workers (recursive)
193
- - no hard agent cap; recursion governed by leaf condition + overhead filter
194
-
195
- ## Sizing Table
196
-
197
- | Scale | Files | Depth | CEO | Mgrs | Workers | Total |
198
- |-------|---------|-------|-----|------|---------|-------|
199
- | XS | 1-4 | 0 | 1 | 0 | 1-3 | 2-4 |
200
- | S | 5-12 | 1 | 1 | 2 | 6 | 9 |
201
- | M | 13-30 | 1 | 1 | 3 | 15 | 19 |
202
- | L | 31-60 | 2 | 1 | 5 | 35 | 41 |
203
- | XL | 61-200 | 2 | 1 | 7 | 49 | 57 |
204
- | XXL | 201-500 | 3 | 1 | 7 | 343 | 351 |
205
- | XXXL | 501-1000| 3 | 1 | 7 | 686 | 694 |
206
-
207
- - depth≥3: Managers spawn Sub-Managers (span≤7). No mixed Worker+Sub-Manager dispatch in same wave.
208
-
209
- ## Leaf Condition (stop splitting)
210
-
211
- - files ≤ span×2
212
- - OR avgLines < 50
213
- - OR overhead > 0.30 (degrade to /wf)
214
-
215
- ## Manager Types (4)
216
-
217
- | Type | Trigger | Span | Worker Roles |
218
- |---------------|-------------------------------|------|---------------------------------------------------------------|
219
- | Architect-Mgr | cross-file interfaces, new ports | 3 | boundary-researcher, interface-designer, data-flow-mapper |
220
- | Implement-Mgr | write-set defined | 5-7 | implementer₁..ₙ (1 file_claim each) |
221
- | Review-Mgr | implementation wave complete | 3-4 | reviewer-spec, reviewer-code, reviewer-security |
222
- | Explore-Mgr | L+ project, uncertain scope | 5-10 | researcher₁..ₙ, domain-explorer₁..ₙ |
223
-
224
- ## Manager Synthesis Protocol
225
-
226
- ```
227
- 1. COLLECT → await all Worker returns
228
- 2. DEDUPLICATE → dedupe, merge overlap
229
- 3. CONFLICT → flag contradictions (file_claim overlap, interface mismatch); no silent resolve
230
- 4. SYNTHESIZE → single integrated artifact
231
- 5. REPORT → CEO-actionable synthesis + raw Worker returns (audit)
232
- ```
233
-
234
- - Worker failure: retry 1× → on 2nd failure, Manager absorbs or escalates to CEO for replan.
235
-
186
+
187
+ - [ ] Did I assign myself any source file? (must be **No** - PLAN.md/PROGRESS.md writes are the exception)
188
+ - [ ] Is every file with planned changes assigned to exactly one write Worker? (must be **Yes**)
189
+ - [ ] Does any Worker have >1 write file? (must be **No**)
190
+ - [ ] Is Manager count >= `Manager_min`? (must be **Yes**, or justification written)
191
+ - [ ] Does every Manager have 2-7 Workers? (<2 = Phantom Manager, >7 = overloaded)
192
+ - [ ] Are there files >200 lines or with >1 concern that should be split into separate files?
193
+ - [ ] Could any serial chain be parallelized? (different files with no shared imports = parallelize)
194
+ - [ ] Will all Workers be spawned in ONE message?
195
+
196
+ Gate retries until all checks pass. **CEO may NOT proceed to W2 implementation dispatch with a failing gate.**
197
+
198
+ ## Anti-Pattern Catalog
199
+
200
+ Before every wave dispatch, CEO MUST scan for these patterns. **Any match = stop and re-decompose.**
201
+
202
+ | # | Anti-Pattern | Symptom | Detection | Fix |
203
+ |---|-------------|---------|-----------|-----|
204
+ | AP1 | **CEO-as-Worker** | CEO assigns itself a file or starts writing code | CEO in Dispatch Table; Edit/Write/Bash used by CEO | Re-delegate to a Worker immediately |
205
+ | AP2 | **Under-decomposition** | Fewer Workers than `ceil(sqrt(files))` | Count check fails; "1-2 agents is enough for this" | Split files by concern, module, or layer |
206
+ | AP3 | **Serialization trap** | "Let me do X first, then I'll know how to dispatch Y" | Sequential plan without parallel candidates | Dispatch X and Y in parallel NOW; Worker-X returns spec that Worker-Y consumes |
207
+ | AP4 | **Fake parallelism** | Multiple Workers assigned same file | Duplicate file path in Dispatch Table | One file = one Writer. Split file into separate modules, or serialize |
208
+ | AP5 | **Phantom Manager** | Manager spawns 0-1 Workers | Manager's sub-table has <2 Workers | Dissolve Manager; CEO or sibling absorbs domain |
209
+ | AP6 | **Sequential spawn** | Workers spawned one-per-turn instead of batched | Only 1 Task() call per message | Batch ALL Task() calls into ONE message |
210
+ | AP7 | **Silent degrade** | CEO switches to /wf without recording reason | No Dispatch Table; flat agent spawns | Explicit decision + justification in PLAN.md; only valid reason is overhead > 0.30 |
211
+
212
+ ## Span Formula (Prescriptive Floor)
213
+
214
+ ```
215
+ Manager_min = max(1, ceil(write_files / 7), ceil(sqrt(write_files) / 2)) # hard floor for write decomposition
216
+ Manager_max = min(max(Manager_min * 2, Manager_min), 7) # per-wave; exceed only with written justification
217
+ Write_worker_max_per_manager = 7 # hard cap for write Managers; split domain if exceeded
218
+
219
+ Worker count per wave = write_files (one Worker per write file, guaranteed by Gate Rule #1)
220
+
221
+ Domain caps (workers per Manager by type):
222
+ Architecture: cap = 3
223
+ Implementation: write cap = 7
224
+ Review: read-only cap = 10
225
+ Research: read-only cap = 12
226
+ ```
227
+
228
+ **Manager_min is a floor, not a target.** The span formula prevents domain-level under-decomposition - the real failure mode where one Manager tries to coordinate too many Workers across unrelated concerns. Worker-level under-decomposition is prevented by Gate Rule #1 (one file per Worker).
229
+
230
+ ## Total Agents (recursive, scales to 1000)
231
+
232
+ ```
233
+ total(depth, span) = sum(span^L) for L=0..depth
234
+ ```
235
+
236
+ - depth=0: CEO + Workers only (XS)
237
+ - depth=1: CEO + Managers + Workers
238
+ - depth=2: CEO + Managers + Workers
239
+ - depth>=3: CEO + Managers + Sub-Managers + Workers (recursive)
240
+ - no Harness hard cap; runtime thread budgets, config, billing, and local
241
+ resources still cap actual concurrency
242
+
243
+ ## Sizing Table
244
+
245
+ | Scale | Files | Depth | CEO | Mgrs | Workers | Total |
246
+ |-------|---------|-------|-----|------|---------|-------|
247
+ | XS | 1-4 | 0 | 1 | 0 | 1-3 | 2-4 |
248
+ | S | 5-12 | 1 | 1 | 2 | 6 | 9 |
249
+ | M | 13-30 | 1 | 1 | 3 | 15 | 19 |
250
+ | L | 31-60 | 2 | 1 | 5 | 35 | 41 |
251
+ | XL | 61-200 | 2 | 1 | 7 | 49 | 57 |
252
+ | XXL | 201-500 | 3 | 1 | 7 | 343 | 351 |
253
+ | XXXL | 501-1000| 3 | 1 | 7 | 686 | 694 |
254
+
255
+ - depth>=3: Managers spawn Sub-Managers (span<=7). No mixed Worker+Sub-Manager dispatch in same wave.
256
+
257
+ ## Leaf Condition (stop splitting)
258
+
259
+ - files <= span*2
260
+ - OR avgLines < 50
261
+ - OR overhead > 0.30 (degrade to /wf)
262
+
263
+ ## Manager Types (4)
264
+
265
+ | Type | Trigger | Span | Worker Roles |
266
+ |---------------|-------------------------------|------|---------------------------------------------------------------|
267
+ | Architect-Mgr | cross-file interfaces, new ports | 3 | boundary-researcher, interface-designer, data-flow-mapper |
268
+ | Implement-Mgr | write-set defined | 5-7 | implementer_1..n (1 file_claim each) |
269
+ | Review-Mgr | implementation wave complete | 3-4 | reviewer-spec, reviewer-code, reviewer-security |
270
+ | Explore-Mgr | L+ project, uncertain scope | 5-10 | researcher_1..n, domain-explorer_1..n |
271
+
272
+ ## Manager Synthesis Protocol
273
+
274
+ ```
275
+ 1. COLLECT -> await all Worker returns
276
+ 2. DEDUPLICATE -> dedupe, merge overlap
277
+ 3. CONFLICT -> flag contradictions (file_claim overlap, interface mismatch); no silent resolve
278
+ 4. SYNTHESIZE -> single integrated artifact
279
+ 5. REPORT -> CEO-actionable synthesis + raw Worker returns (audit)
280
+ ```
281
+
282
+ - Worker failure: retry 1x -> on 2nd failure, Manager absorbs or escalates to CEO for replan.
283
+
236
284
  ## Wave Orchestration
237
285
 
238
286
  WF-MAX expands `/wf` by turning each acceptance phase into a manager/worker
239
- wave when useful:
287
+ wave while preserving the complete WF role chain:
240
288
 
241
289
  ```text
242
290
  Product Manager Group -> PRD-GATE
@@ -247,60 +295,64 @@ Architecture Manager -> boundary/interface contract
247
295
  Implementation Manager -> AC-mapped D-GATE and write-set coloring
248
296
  Validation Manager -> E2E/screenshot/trace/contract validation matrix
249
297
  Review Manager -> spec/code/test/UX/security review
298
+ Reflection Manager -> reflector verdict and unresolved-risk synthesis
250
299
  Debug Manager -> AC failure root-cause loop
251
300
  Memory Master -> durable lessons
252
301
  ```
253
302
 
254
303
  ```
255
- W0: Explore-Mgr N parallel researchers synthesize CEO
256
- E-GATE: Exploration Gate: CEO verifies all exploration questions answered, findings synthesized (lightweight; see WF.md Decomposition Gate)
257
- W1: Architect-Mgr 3 parallel boundary decisions + interface contract CEO approval
258
- D-GATE: Write Decomposition Gate: CEO produces Dispatch Table + Self-Audit GATE PASS/FAIL (MANDATORY, applied to the write-set defined by architecture)
259
- W2: Implement-Mgr write-set coloring wave dispatch: ALL Workers spawned in ONE message merge CEO
260
- W2R: Review-Mgr 3-4 parallel reviewers dedupe + severity CEO assigns fixes
261
- W3+: Dependent waves (repeat W2 pattern; re-run D-GATE if write-set changed significantly)
262
- INTEGRATION: CEO verifier fail debugger loop (cap=3)
263
- CLOSEOUT: CEO context-master + memory-master (direct, no Manager)
264
- ```
265
-
266
- - **E-GATE** (Exploration Gate): read-only agents each had a specific question; all returns are synthesized into PLAN.md. No exploration blind spots.
267
- - **D-GATE** (Write Decomposition Gate): applies AFTER architecture defines the write-set, BEFORE any implementation Worker spawns. Dispatch Table covers the actual write-set. Gate is non-negotiable.
268
- - W2 dispatch: ALL Workers for a wave MUST be spawned in a single message not one per turn. Batching is what makes parallelism real.
269
-
304
+ W0: Explore-Mgr -> N parallel researchers -> synthesize -> CEO
305
+ E-GATE: -> Exploration Gate: CEO verifies all exploration questions answered, findings synthesized (lightweight; see WF.md Decomposition Gate)
306
+ W1: Architect-Mgr -> 3 parallel -> boundary decisions + interface contract -> CEO approval
307
+ D-GATE: -> Write Decomposition Gate: CEO produces Dispatch Table + Self-Audit -> GATE PASS/FAIL (MANDATORY, applied to the write-set defined by architecture)
308
+ W2: Implement-Mgr -> write-set coloring -> wave dispatch: ALL Workers spawned in ONE message -> merge -> CEO
309
+ W2R: Review-Mgr -> 3-4 parallel reviewers -> dedupe + severity -> CEO assigns fixes
310
+ W3+: Dependent waves (repeat W2 pattern; re-run D-GATE if write-set changed significantly)
311
+ VALIDATION: CEO -> verifier -> AC evidence matrix -> cross-review
312
+ REFLECT: CEO -> reflector -> PASS/RETURN_TO_DEBUG/BLOCKED
313
+ CLOSEOUT: CEO -> final acceptance -> context-master + memory-master (direct, no Manager)
314
+ ```
315
+
316
+ - **E-GATE** (Exploration Gate): read-only agents each had a specific question; all returns are synthesized into PLAN.md. No exploration blind spots.
317
+ - **D-GATE** (Write Decomposition Gate): applies AFTER architecture defines the write-set, BEFORE any implementation Worker spawns. Dispatch Table covers the actual write-set. Gate is non-negotiable.
318
+ - W2 dispatch: ALL Workers for a wave MUST be spawned in a single message - not one per turn. Batching is what makes parallelism real.
319
+
270
320
  - Acceptance gates apply before D-GATE. D-GATE decomposes the write set; it does not define the acceptance truth.
321
+ - Cross-review and reflector PASS are required before final acceptance.
271
322
  - Wave scheduling: Managers serial across domains, Workers parallel within domain.
272
- - CEO validates wave output before starting next wave. No pipelining.
273
-
274
- ## Overhead & Cost Filter
275
-
276
- ```
277
- overhead(depth) = 0.10 (depth2) | 0.20 (depth=3) | 0.35 (depth4)
278
- ```
279
-
280
- - overhead > 0.30 degrade to /wf
281
- - independenceFactor: 1.0 (no deps) | 0.3-0.7 (shared imports)
282
-
283
- ## When NOT to use /wf-max
284
-
285
- These conditions govern **auto-trigger degradation only** (wf-max /wf). They never apply when the user explicitly types `/wf-max`, and "degrade" always means the flat /wf multi-subagent loop, never a solo pass.
286
-
287
- - files < 5 use /wf
288
- - all changes share single interface serial dependency
289
- - import/re-export refactor global consistency required
290
- - communication overhead > 30% degrade
291
-
323
+ - CEO validates wave output before starting next wave. No pipelining.
324
+
325
+ ## Overhead & Cost Filter
326
+
327
+ ```
328
+ overhead(depth) = 0.10 (depth<=2) | 0.20 (depth=3) | 0.35 (depth>=4)
329
+ ```
330
+
331
+ - overhead > 0.30 -> degrade to /wf complete role chain
332
+ - independenceFactor: 1.0 (no deps) | 0.3-0.7 (shared imports)
333
+
334
+ ## When NOT to use /wf-max
335
+
336
+ These conditions govern **auto-trigger degradation only** (wf-max -> /wf). They never apply when the user explicitly types `/wf-max`, and "degrade" always means the flat /wf complete role chain, never a solo pass.
337
+
338
+ - files < 5 -> use /wf complete role chain
339
+ - all changes share single interface -> serial dependency
340
+ - import/re-export refactor -> global consistency required
341
+ - communication overhead > 30% -> degrade to /wf complete role chain
342
+
292
343
  ## /wf vs /wf-max
293
344
 
294
345
  Both modes use the same acceptance-driven mother flow. `/wf-max` changes the
295
346
  organization and amount of parallelism, not the PRD-derived source of truth.
296
347
 
297
348
  | Dimension | /wf | /wf-max |
298
- |------------------|------------------|----------------------------------|
299
- | Organization | flat | CEO Mgr Worker (3-tier) |
300
- | Exploration | 3-5 serial | Mgr 10 parallel |
301
- | Implementation | 1 serial | Mgr N parallel (span 5-7) |
302
- | Review | 1-2 serial gate | Mgr 3-4 parallel dimensions |
303
- | Span formula | none | sqrt(files) + domain cap |
304
- | Recursive depth | 0 | 1-3 (scales to 1000 agents) |
305
- | Context threshold| ~85% | ~70% |
306
- | Granularity floor| none | <50 lines → no split |
349
+ |------------------|------------------|----------------------------------|
350
+ | Organization | flat complete role chain | CEO -> Manager -> Worker hierarchy |
351
+ | Exploration | planner/research/docs/architect roles | manager-led max-parallel exploration |
352
+ | Implementation | bounded implementer lane | manager-led N parallel workers (span 5-7) |
353
+ | Review | 2+ independent review lenses | manager-led parallel spec/code/test/security lenses |
354
+ | Reflection | reflector required before acceptance | reflector required before acceptance |
355
+ | Span formula | none | sqrt(files) + domain cap |
356
+ | Recursive depth | 0 | 1-3; overflow can use `claude -p` or `codex exec` manager/worker processes |
357
+ | Context threshold| ~85% | ~70% |
358
+ | Granularity floor| none | <50 lines -> no split |