create-harness-vibe-coding 0.8.8 → 0.8.9

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 (80) hide show
  1. package/README-CN.md +7 -1
  2. package/README.md +21 -2
  3. package/docs/images/harness-icon.png +0 -0
  4. package/package.json +2 -1
  5. package/src/generator.js +36 -0
  6. package/src/index.js +72 -4
  7. package/templates/common/.claude/agents/architect.md +31 -31
  8. package/templates/common/.claude/agents/codebase-explorer.md +45 -0
  9. package/templates/common/.claude/agents/docs-researcher.md +41 -41
  10. package/templates/common/.claude/agents/memory-master.md +26 -8
  11. package/templates/common/.claude/agents/reviewer.md +34 -34
  12. package/templates/common/.claude/agents/task-scribe.md +70 -0
  13. package/templates/common/.claude/commands/wf-help.md +8 -4
  14. package/templates/common/.claude/commands/wf-update.md +24 -0
  15. package/templates/common/.claude/rules/ecc/common.md +15 -2
  16. package/templates/common/.claude/settings.json +13 -0
  17. package/templates/common/.claude/skills/subagent-orchestrator/SKILL.md +8 -4
  18. package/templates/common/.claude/skills/wf/SKILL.md +15 -8
  19. package/templates/common/.claude/skills/wf-auto/SKILL.md +3 -2
  20. package/templates/common/.claude/skills/wf-learn/SKILL.md +9 -2
  21. package/templates/common/.claude/skills/wf-max/SKILL.md +23 -5
  22. package/templates/common/.claude/skills/wf-update/SKILL.md +15 -2
  23. package/templates/common/.codex/hooks.json +17 -0
  24. package/templates/common/.harness-version +89 -44
  25. package/templates/common/.opencode/agents/architect.md +24 -24
  26. package/templates/common/.opencode/agents/codebase-explorer.md +45 -0
  27. package/templates/common/.opencode/agents/docs-researcher.md +34 -34
  28. package/templates/common/.opencode/agents/memory-master.md +26 -8
  29. package/templates/common/.opencode/agents/reviewer.md +27 -27
  30. package/templates/common/.opencode/agents/task-scribe.md +70 -0
  31. package/templates/common/.opencode/commands/wf-auto-spark.md +15 -0
  32. package/templates/common/.opencode/commands/wf-auto.md +15 -0
  33. package/templates/common/.opencode/commands/wf-help.md +8 -4
  34. package/templates/common/.opencode/commands/wf-learn.md +15 -0
  35. package/templates/common/.opencode/commands/wf-max.md +15 -0
  36. package/templates/common/.opencode/commands/wf-readme.md +15 -0
  37. package/templates/common/.opencode/commands/wf-remove.md +15 -0
  38. package/templates/common/.opencode/commands/wf-review.md +15 -0
  39. package/templates/common/.opencode/commands/wf-update.md +24 -0
  40. package/templates/common/.opencode/commands/wf.md +15 -0
  41. package/templates/common/.opencode/plugins/harness-wf-status.mjs +135 -0
  42. package/templates/common/AGENTS.md +2 -29
  43. package/templates/common/CLAUDE.md +35 -6
  44. package/templates/common/Harness/ACCEPTANCE_PROTOCOL.md +2 -2
  45. package/templates/common/{MEMORY.md → Harness/MEMORY.md} +16 -3
  46. package/templates/common/Harness/MEMORY_PROTOCOL.md +80 -30
  47. package/templates/common/Harness/README.md +50 -22
  48. package/templates/common/{SETUP.md → Harness/SETUP.md} +278 -276
  49. package/templates/common/Harness/TASK_ARCHIVE.md +56 -0
  50. package/templates/common/Harness/WF-AUTO-SPARK.md +5 -14
  51. package/templates/common/Harness/WF-AUTO.md +13 -76
  52. package/templates/common/Harness/WF-KERNEL.md +189 -0
  53. package/templates/common/Harness/WF-MAX.md +60 -328
  54. package/templates/common/Harness/WF-STATE.md +83 -0
  55. package/templates/common/Harness/WF.md +117 -237
  56. package/templates/common/Harness/agent-workflow.md +2 -2
  57. package/templates/common/Harness/context-loading.md +3 -3
  58. package/templates/common/Harness/dispatch.md +43 -35
  59. package/templates/common/Harness/scripts/archive-tasks.mjs +239 -0
  60. package/templates/common/{scripts → Harness/scripts}/scan-clean.mjs +28 -1
  61. package/templates/common/{scripts → Harness/scripts}/validate-harness.mjs +909 -699
  62. package/templates/common/Harness/scripts/wf-auto-update-prompt.mjs +258 -0
  63. package/templates/common/{scripts → Harness/scripts}/wf-update-check.mjs +40 -7
  64. package/templates/common/Harness/subagents.md +28 -27
  65. package/templates/common/Harness/tasks/_template/PLAN.md +5 -0
  66. package/templates/common/Harness/tasks/_template/STATE.json +23 -0
  67. package/templates/common/README.md +1 -1
  68. package/templates/common/memory/agent-lessons-patterns.md +9 -8
  69. package/templates/common/memory/routes.md +43 -0
  70. package/templates/common/memory/startup-hints.md +32 -0
  71. package/templates/common/memory/tool-usage-reflections.md +9 -8
  72. package/templates/common/memory/user-corrections-preferences.md +11 -9
  73. package/templates/optional/catalog.json +8 -0
  74. package/templates/optional/skills/browser-e2e/.claude/skills/browser-e2e/SKILL.md +42 -42
  75. package/templates/optional/skills/browser-e2e/.opencode/commands/wf-browser.md +15 -0
  76. package/templates/optional/skills/github-pr-review/.claude/skills/github-pr-review/SKILL.md +40 -40
  77. package/templates/optional/skills/python-backend/.claude/skills/python-backend/SKILL.md +40 -40
  78. package/templates/optional/skills/ts-react-frontend/.claude/skills/ts-react-frontend/SKILL.md +43 -43
  79. package/templates/optional/skills/ui-ux-review/.claude/skills/ui-ux-review/SKILL.md +40 -40
  80. /package/templates/common/{scripts → Harness/scripts}/wf-remove.mjs +0 -0
@@ -1,358 +1,90 @@
1
- # WF-MAX - Maximum Parallelism Workflow
1
+ # WF-MAX Maximum Safe Parallelism
2
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.**
3
+ `/wf-max` = `/wf` kernel + maximum safe fan-out. It is NOT a separate workflow. It is a parallelism superset of `/wf` and inherits the full [WF-KERNEL.md](WF-KERNEL.md) orchestration engine and [WF.md](WF.md) tier contract, then expands execution through a three-layer architecture (CEO → Manager → Worker) with dispatch permissions (writeSet, forbidden, verification). Global mode != every agent is CEO.
4
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.
34
- The hierarchy changes; the source of truth does not. PRD-derived AC IDs govern
35
- every worker dispatch, test, review, validation result, debug handoff,
36
- reflection verdict, and memory entry. See
37
- [ACCEPTANCE_PROTOCOL.md](ACCEPTANCE_PROTOCOL.md),
38
- [AGENT_ISOLATION.md](AGENT_ISOLATION.md), and [HARNESS_BRIDGE.md](HARNESS_BRIDGE.md).
39
-
40
- ## Trigger
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
-
117
- ### Gate Artifact: Dispatch Table
118
-
119
- WF-MAX gate order:
120
-
121
- ```text
122
- PRD-GATE
123
- -> AC-GATE
124
- -> CONTRACT-GATE
125
- -> TEST-GATE
126
- -> D-GATE
127
- -> IMPLEMENT-GATE
128
- -> VALIDATION-GATE
129
- -> REVIEW-GATE
130
- -> REFLECT-GATE
131
- ```
132
-
133
- D-GATE answers "who may change which file." The earlier gates answer "what must
134
- be accepted, how it will be tested, and which truth files are forbidden to
135
- implementers." The Dispatch Table must map each write Worker to the AC IDs it
136
- implements.
137
-
138
- CEO MUST write this table in the task PLAN.md after W1 architecture defines the write-set and before W2 implementation dispatch:
139
-
140
- ```
141
- | File | Concern | Worker Type | Worker Label | Read-Only? |
142
- |------|---------|------------|--------------|------------|
143
- | src/a.ts | Auth middleware | implementer | impl-auth | No |
144
- | src/b.ts | DB schema | implementer | impl-db | No |
145
- | docs/arch.md | Research existing patterns | researcher | res-arch | Yes |
146
- ```
147
-
148
- For acceptance-driven work, add an `AC IDs` column to this table and list every
149
- criterion the Worker is allowed to satisfy.
150
-
151
- ### Gate Rules (any violation = gate fail, retry)
152
-
153
- Acceptance-specific gate rules:
154
-
155
- 1. PRD, AC, UI/API contracts, and test plan must exist before implementation dispatch.
156
- 2. Every write Worker row must cite AC IDs.
157
- 3. Implementer forbidden set must include PRD, AC, UI/API contracts, test plan, and validation report unless an approved Change Request is recorded.
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
-
181
- After producing the Dispatch Table, CEO MUST answer all before proceeding:
182
-
183
- - [ ] Do PRD, AC, contracts, and test plan exist before implementation dispatch?
184
- - [ ] Does every implementation Worker row cite AC IDs?
185
- - [ ] Are truth files excluded from implementer write sets unless Change Request is approved?
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.**
5
+ WF-MAX is **explicit only**. Enter ONLY when the user explicitly types `/wf-max`, `$wf-max`, or `/skills wf-max`.
201
6
 
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 |
7
+ ## Delta from /wf
211
8
 
212
- ## Span Formula (Prescriptive Floor)
9
+ | Dimension | /wf | /wf-max |
10
+ |---|---|---|
11
+ | Orchestration | Ready-queue, tier-gated | Same ready-queue + max decomposition |
12
+ | Exploration | codebase-explorer fan-out | explore-manager → 5-10 researchers |
13
+ | Architecture | architect (when triggered) | architect-manager → 3 architects |
14
+ | Implementation | One implementer per wave | implement-manager → 5-7 implementers (one file_claim each) |
15
+ | Review | Reviewer(s) per wave | review-manager → 3-4 parallel reviewers |
16
+ | State | Controller or task-scribe | task-scribe continuously maintains dispatch ledger |
17
+ | Source edits | Implementer writes | Workers write ONLY dispatch.writeSet; CEO never writes source |
213
18
 
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
19
+ ## Fan-Out Modes
242
20
 
243
- ## Sizing Table
21
+ **WF-Max-Useful** (default): fan-out only where writeSets or review lenses are meaningfully independent. Overhead > 0.30 degrades a wave to flat role pass. CEO uses D-GATE but Manager/Worker fan-out is gated by actual independence.
244
22
 
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 |
23
+ **WF-Max-Strict** (explicit `--strict`, `strict wf-max`, or `strict mode`): unconditional fan-out per span formula. Every file gets a Worker.
254
24
 
255
- - depth>=3: Managers spawn Sub-Managers (span<=7). No mixed Worker+Sub-Manager dispatch in same wave.
25
+ ## CEO Contract
256
26
 
257
- ## Leaf Condition (stop splitting)
27
+ CEO reads, plans, dispatches, synthesizes, and writes task state only.
28
+ - **CEO never writes production source code.** All source edits are delegated to Workers.
29
+ - CEO may spawn task-scribe (haiku) to maintain dispatch ledger and heartbeat.
30
+ - CEO may spawn codebase-explorer(s) (haiku) for scoped source discovery.
258
31
 
259
- - files <= span*2
260
- - OR avgLines < 50
261
- - OR overhead > 0.30 (degrade to /wf)
32
+ ## Parallelism Priority
262
33
 
263
- ## Manager Types (4)
34
+ 1. Read-only exploration — max parallel, all readSets
35
+ 2. Docs/research — max parallel
36
+ 3. Test design — max parallel
37
+ 4. Implementation — parallel only when writeSets are DISJOINT
38
+ 5. WriteSet conflicts → sequential wave, patch-only return, or worktree/branch isolation
39
+ 6. Review — parallel per-wave when verifier evidence is ready
40
+ 7. Idle capacity → immediately dispatch next ready item from queue
264
41
 
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
42
+ ## Span Formula (WF-Max-Strict)
273
43
 
274
44
  ```
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)
45
+ Manager_min = max(1, ceil(write_files / 7), ceil(sqrt(write_files) / 2))
46
+ Manager_max = min(max(Manager_min * 2, Manager_min), 7)
280
47
  ```
281
48
 
282
- - Worker failure: retry 1x -> on 2nd failure, Manager absorbs or escalates to CEO for replan.
283
-
284
- ## Wave Orchestration
49
+ ## Worker Discipline
285
50
 
286
- WF-MAX expands `/wf` by turning each acceptance phase into a manager/worker
287
- wave while preserving the complete WF role chain:
51
+ - One file_claim per write Worker
52
+ - WriteSet must be disjoint across parallel Workers
53
+ - Workers return <=250 tokens + evidence/file paths
54
+ - task-scribe (haiku) runs alongside any wave
288
55
 
289
- ```text
290
- Product Manager Group -> PRD-GATE
291
- Acceptance Manager -> AC-GATE
292
- Contract Manager -> CONTRACT-GATE
293
- Test Manager -> TEST-GATE
294
- Architecture Manager -> boundary/interface contract
295
- Implementation Manager -> AC-mapped D-GATE and write-set coloring
296
- Validation Manager -> E2E/screenshot/trace/contract validation matrix
297
- Review Manager -> spec/code/test/UX/security review
298
- Reflection Manager -> reflector verdict and unresolved-risk synthesis
299
- Debug Manager -> AC failure root-cause loop
300
- Memory Master -> durable lessons
301
- ```
56
+ ## Token Budget and Fan-Out Caps
302
57
 
303
- ```
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
- ```
58
+ WF-MAX fan-out is bounded. Unbounded worker dispatch is forbidden.
315
59
 
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.
60
+ - **Total worker cap**: Maximum 15 agents per WF-MAX task (all waves combined). Managers, reviewers, and verifiers count toward this cap. Read-only scouts and task-scribe do not count.
61
+ - **Per-wave cap**: Maximum 7 Workers per implementation wave (enforced by implement-manager span formula).
62
+ - **Reviewer cap**: Maximum 4 reviewers per wave (review-manager).
63
+ - **Manager cap**: Maximum 4 Managers total (explore, architect, implement, review).
64
+ - **Token budget**: If `budget.total` is set (user-specified budget), CEO MUST reserve >=30% for review/verify/reflect phases. Stop dispatching Workers when remaining budget is below 50k tokens.
65
+ - **Overflow discipline**: Cross-CLI overflow (Codex → Claude, Claude → Codex) is allowed only after native subagent pool is genuinely exhausted (not just busy). Each overflow dispatch costs context; prefer closing completed agents first.
66
+ - **Idle workers**: Close completed agents before declaring the pool exhausted. Do not spawn new workers while idle capacity is available.
319
67
 
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.
322
- - Wave scheduling: Managers serial across domains, Workers parallel within domain.
323
- - CEO validates wave output before starting next wave. No pipelining.
324
-
325
- ## Overhead & Cost Filter
68
+ ## Organization Model
326
69
 
327
70
  ```
328
- overhead(depth) = 0.10 (depth<=2) | 0.20 (depth=3) | 0.35 (depth>=4)
71
+ CEO(1) -> Manager_1(span) -> Worker_1..n
72
+ -> Manager_2(span) -> Sub-Manager(span) -> Worker_1..n
329
73
  ```
330
74
 
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
75
+ ## D-GATE
335
76
 
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.
77
+ D-GATE is mandatory before implementation waves per [WF-KERNEL.md](WF-KERNEL.md) dispatch packet format: dispatch table, AC IDs, disjoint file claims, self-audit, reviewer plan. CEO may NOT proceed to W2 implementation dispatch with a failing gate.
337
78
 
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
79
+ ## Overflow
342
80
 
343
- ## /wf vs /wf-max
81
+ 1. Current runtime subagents first.
82
+ 2. Close completed agents; fill idle slots immediately.
83
+ 3. Cross-CLI overflow: Codex → `claude -p`, Claude → `codex exec`.
84
+ 4. Bounded-pass fallback only when subagents and overflow are exhausted.
85
+ 5. Generated Codex config defaults to `agents.max_threads = 12` and `agents.max_depth = 1`. Ask the user before raising `agents.max_threads` above that default. Keep `max_depth = 1` unless recursive delegation is explicitly approved.
86
+ 6. Do not rely on Codex++, undocumented config, environment variables, forked/derived conversations, or third-party forks as stable capacity.
344
87
 
345
- Both modes use the same acceptance-driven mother flow. `/wf-max` changes the
346
- organization and amount of parallelism, not the PRD-derived source of truth.
88
+ ## Anti-Patterns and Sizing
347
89
 
348
- | Dimension | /wf | /wf-max |
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 |
90
+ See original [WF-MAX.md](WF-MAX.md) anti-pattern catalog (AP1-AP7) and sizing table (XS-XXXL). These apply under WF-Max-Strict and serve as reference for WF-Max-Useful decomposition.
@@ -0,0 +1,83 @@
1
+ # WF-STATE — Lightweight Resumable State Machine
2
+
3
+ Purpose: persist resumable workflow state across compaction, new Claude Code windows, new terminals, and project reopen. It is NOT a scheduler, daemon, lock manager, async runtime, or graph framework.
4
+
5
+ ## State Files
6
+
7
+ | File | Role |
8
+ |------|------|
9
+ | `Harness/PROGRESS.md` | Global active pointer — which task is current |
10
+ | `Harness/tasks/<task-id>/STATE.json` | Machine-readable resume truth |
11
+ | `Harness/tasks/<task-id>/PROGRESS.md` | Human-readable summary |
12
+ | `Harness/tasks/<task-id>/PLAN.md` | Plan, decisions, scope context |
13
+
14
+ ## Enums
15
+
16
+ ### phase
17
+ `intake`, `clarify`, `requirements`, `prd`, `acceptance`, `plan`, `explore`, `implement`, `verify`, `review`, `fix`, `reflect`, `closeout`, `blocked`, `archived`
18
+
19
+ ### item status (queues)
20
+ `pending`, `ready`, `running`, `done`, `blocked`, `skipped`, `failed`
21
+
22
+ ### mode
23
+ `direct`, `wf`, `wf-max`, `wf-auto`, `wf-auto-spark`, `wf-review`, `wf-browser`
24
+
25
+ ### tier
26
+ `none`, `light`, `standard`, `full`, `max-useful`, `max-strict`
27
+
28
+ ## Rules
29
+
30
+ 1. **STATE.json is machine-readable resume truth.** On session start, the agent reads it to know where it left off.
31
+ 2. **PROGRESS.md is human-readable summary.** It mirrors key state but is secondary for machine reasoning.
32
+ 3. **PLAN.md is plan/decision context.** Load only when decisions or scope need review.
33
+ 4. **On every phase transition, dispatch return, blocker, verification result, review finding, or closeout, update STATE.json.** task-scribe or controller writes; production agents never write task state.
34
+ 5. **Long logs/transcripts never go into STATE.json.** Store paths only.
35
+ 6. **task-scribe may update STATE.json and task summaries; production agents may not.**
36
+ 7. **If STATE.json conflicts with PLAN/PROGRESS, controller stops and reconciles before continuing.**
37
+
38
+ ## Resume Protocol
39
+
40
+ New window / session start:
41
+ 1. Read `CLAUDE.md`.
42
+ 2. If user says "continue", "resume", "last task", "current task", "status", or the work is not a simple direct task:
43
+ - Read `Harness/PROGRESS.md` → find Active Task
44
+ - If Active Task exists, read `Harness/tasks/<active-task>/STATE.json`
45
+ - Read `Harness/tasks/<active-task>/PROGRESS.md`
46
+ - Read `Harness/tasks/<active-task>/PLAN.md` only if decisions/scope need review
47
+ 3. From STATE.json, determine:
48
+ - Current phase, gate, tier
49
+ - activeQuestion (needs user answer before proceeding)
50
+ - Queues: ready (can dispatch immediately), running (awaiting results), blocked (needs resolution), done
51
+ - nextAction (what to do next)
52
+ 4. Do NOT bulk-read `Harness/tasks/` to find context. Use the active pointer.
53
+ 5. Direct simple tasks may skip STATE/PLAN/PROGRESS unless the user says "continue"/"resume".
54
+
55
+ ## State Transitions
56
+
57
+ ```
58
+ intake → clarify → requirements → prd → acceptance → plan
59
+ → explore → implement → verify → review
60
+ → (fix → verify → review loop)
61
+ → reflect → closeout
62
+ ```
63
+
64
+ Any phase may transition to `blocked` if a dependency, user decision, or external input is required.
65
+
66
+ ## Dispatch Ledger
67
+
68
+ Every dispatch packet MUST have an `id`. On return, controller or task-scribe updates the ledger item:
69
+ - `id`, `agent`, `role`, `phase`, `status` (pending/ready/running/done/blocked/skipped/failed), `evidence`
70
+
71
+ See [WF-KERNEL.md](WF-KERNEL.md) for the dispatch packet format.
72
+
73
+ ## Integration with /wf and /wf-max
74
+
75
+ - `/wf` uses the STATE ready queue for dynamic orchestration.
76
+ - `/wf-max` uses the SAME STATE ready queue for maximum safe fan-out.
77
+ - When a subagent returns or goes idle, controller immediately dispatches the next ready item.
78
+ - task-scribe is the exception for task-state writes.
79
+ - Production source agents do not write STATE/PLAN/PROGRESS unless explicitly dispatched as task-scribe.
80
+
81
+ ## Template
82
+
83
+ See `Harness/tasks/_template/STATE.json` for the canonical template. On task creation, copy and populate from the template.