create-harness-vibe-coding 0.8.0 → 0.8.2

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 (37) hide show
  1. package/README-CN.md +40 -24
  2. package/README.md +44 -20
  3. package/package.json +1 -1
  4. package/src/generator.js +1 -1
  5. package/src/index.js +211 -11
  6. package/src/prompts.js +1 -1
  7. package/templates/common/.claude/agents/tdd-guide.md +55 -0
  8. package/templates/common/.claude/settings.json +22 -0
  9. package/templates/common/.claude/skills/tdd/SKILL.md +30 -0
  10. package/templates/common/.claude/skills/wf-auto/SKILL.md +107 -0
  11. package/templates/common/.claude/skills/wf-auto-spark/SKILL.md +39 -0
  12. package/templates/common/.claude/skills/wf-max/SKILL.md +10 -2
  13. package/templates/common/.claude/skills/wf-remove/SKILL.md +12 -5
  14. package/templates/common/.claude/skills/wf-update/SKILL.md +12 -5
  15. package/templates/common/.codex/hooks.json +59 -37
  16. package/templates/common/.harness-version +48 -25
  17. package/templates/common/AGENTS.md +5 -5
  18. package/templates/common/CLAUDE.md +12 -17
  19. package/templates/common/Harness/ECC-GUIDE.md +246 -0
  20. package/templates/common/Harness/README.md +129 -130
  21. package/templates/common/Harness/TDD-GUIDE.md +83 -0
  22. package/templates/common/Harness/WF-AUTO-SPARK.md +297 -0
  23. package/templates/common/Harness/WF-AUTO.md +508 -0
  24. package/templates/common/Harness/WF-MAX.md +24 -0
  25. package/templates/common/Harness/context-loading.md +38 -1
  26. package/templates/common/Harness/dispatch.md +40 -40
  27. package/templates/common/Harness/subagents.md +7 -21
  28. package/templates/common/Harness/tasks/_template/NAMING.md +47 -0
  29. package/templates/common/MEMORY.md +73 -66
  30. package/templates/common/SETUP.md +98 -63
  31. package/templates/common/scripts/validate-harness.mjs +92 -58
  32. package/templates/common/scripts/wf-mode-hook.mjs +895 -318
  33. package/templates/common/scripts/wf-remove.mjs +301 -81
  34. package/templates/common/scripts/wf-statusline.ps1 +62 -38
  35. package/templates/common/scripts/wf-statusline.sh +67 -48
  36. package/templates/common/scripts/wf-update-check.mjs +179 -81
  37. package/templates/optional/catalog.json +5 -5
@@ -0,0 +1,508 @@
1
+ # WF-AUTO — Perpetual Auto-Optimization Workflow
2
+
3
+ ## Trigger
4
+
5
+ - Explicit: `/wf-auto`, `wf auto`, `auto mode`
6
+ - The user wants continuous improvement that never stops on its own.
7
+ - The user is done giving instructions and wants the system to self-direct.
8
+
9
+ ## Core Principle
10
+
11
+ **NEVER STOP.** WF-AUTO is a perpetual loop. It does not stop when a task is "done" — it finds the next improvement and continues. The ONLY permitted stop is the 8-Angle Exhaustion Gate: when all 8 independent perspectives agree there is no worthwhile optimization direction left.
12
+
13
+ This fills the gap between:
14
+ - `/wf` — task-bounded, stops on completion
15
+ - `/wf-max` — task-bounded, stops on completion, just faster
16
+ - `/wf-auto` — **unbounded, self-directed, perpetual improvement**
17
+
18
+ ## Organization Model
19
+
20
+ ```
21
+ CEO(1) ──┬── Angle-Agent₁ (correctness)
22
+ ├── Angle-Agent₂ (performance)
23
+ ├── Angle-Agent₃ (security)
24
+ ├── Angle-Agent₄ (maintainability)
25
+ ├── Angle-Agent₅ (test-coverage)
26
+ ├── Angle-Agent₆ (architecture)
27
+ ├── Angle-Agent₇ (ux-dx)
28
+ └── Angle-Agent₈ (robustness)
29
+
30
+
31
+ CEO synthesizes → picks highest-impact direction
32
+
33
+
34
+ Implementer → Reviewer → Debugger (if needed) → Verifier
35
+
36
+
37
+ LOOP → W0 (re-sense)
38
+
39
+ ─── WHEN ALL 8 EXHAUSTED ───
40
+
41
+ CEO → Cross-Model Oracle (Codex/Claude)
42
+
43
+ ├── Oracle finds directions → feed into W1
44
+ └── Oracle also empty → Tier 2 confirm rounds → STOP
45
+ ```
46
+
47
+ CEO orchestrates the perpetual loop. CEO never writes production code — delegates all implementation. CEO synthesizes angle findings, picks direction, dispatches implement/review/verify, then loops.
48
+
49
+ When all 8 angles return exhausted, the CEO does NOT immediately enter confirmation — it first consults the other AI model (the Cross-Model Oracle) for a fresh perspective. Only when the oracle also finds nothing do confirmation rounds begin.
50
+
51
+ ### State Machine
52
+
53
+ WF-AUTO operates in explicit states. Without a state machine, "auto-degrade", "switch", "return", and "stop asking" become ambiguous.
54
+
55
+ ```
56
+ ┌──────────────────────────────┐
57
+ │ auto.internal │ ←── W0-W5 loop (8-angle scan + oracle + spark)
58
+ │ (active optimization cycle) │
59
+ └──────────┬───────────────────┘
60
+
61
+ ┌────────────────┼────────────────┐
62
+ ▼ ▼ ▼
63
+ [findings exist] [all exhausted] [cycle count % N == 0]
64
+ │ │ │
65
+ ▼ ▼ ▼
66
+ W1 continue auto.spark auto.checkpoint
67
+ (external (Intent Checkpoint)
68
+ candidate │
69
+ search) ├── user clear → back to auto.internal
70
+ │ │ ├── user vague → propose spark
71
+ │ ▼ ├── user "stop asking" → extend interval
72
+ │ [spark finds └── user "stop" → paused
73
+ │ candidates?]
74
+ │ │ │
75
+ │ ▼ ▼
76
+ │ [yes→W1] [no→confirm]
77
+ │ │
78
+ ▼ ▼
79
+ auto.internal auto.exhausted (STOP)
80
+
81
+ paused ←── user interrupt at any point
82
+ ```
83
+
84
+ **States:**
85
+
86
+ | State | Meaning | Entry Condition |
87
+ |-------|---------|-----------------|
88
+ | `auto.internal` | Running W0-W5 with internal 8-angle scan | Default, or return from checkpoint/spark |
89
+ | `auto.spark` | Searching external sources for candidates when internal + oracle are empty | All 8 exhausted + oracle empty, OR user requested spark mode |
90
+ | `auto.checkpoint` | Intent Checkpoint — brief user alignment check | Every N cycles (adaptive: 2→5→10) |
91
+ | `auto.exhausted` | A-GATE passed permanently | 3 consecutive all-exhausted rounds + oracle confirmed |
92
+ | `paused` | User interrupted, waiting for direction | User says "stop" or interrupts at any point |
93
+
94
+ **State transitions are CEO-owned.** The CEO decides which state to enter based on W0 results and checkpoint responses. The state machine is recorded in `Harness/tasks/auto/PROGRESS.md` at each transition.
95
+
96
+ ## The 8 Angles (Exhaustion Dimensions)
97
+
98
+ These are the ONLY lenses through which optimization is justified. An angle is "exhausted" when it finds zero actionable improvements.
99
+
100
+ | # | Angle | Focus | Example Signals |
101
+ |---|-------|-------|----------------|
102
+ | 1 | **Correctness** | Bugs, logic errors, edge cases, null safety, race conditions, state inconsistency | Unhandled error paths, missing null checks, off-by-one, stale cache |
103
+ | 2 | **Performance** | Speed, memory, I/O, algorithmic complexity, bundle size, query efficiency | O(n²) where O(n log n) exists, unnecessary allocations, blocking I/O |
104
+ | 3 | **Security** | Injection, auth/authz, secret exposure, input validation, dependency CVEs | Unsanitized input, hardcoded keys, missing rate limits, outdated deps |
105
+ | 4 | **Maintainability** | Code clarity, DRY violations, coupling, naming, comment accuracy, dead code | Duplicated logic, misleading names, god functions, stale comments |
106
+ | 5 | **Test Coverage** | Missing tests, weak assertions, untested edge cases, flaky tests, test speed | Untested error branches, mock-only tests (no integration), slow suites |
107
+ | 6 | **Architecture** | Boundary violations, dependency direction, interface stability, layer discipline | Circular deps, leaky abstractions, wrong layer ownership |
108
+ | 7 | **UX / DX** | Error messages, API ergonomics, documentation, logging, CLI/API consistency | Cryptic errors, missing docs, inconsistent flags, poor discoverability |
109
+ | 8 | **Robustness** | Resilience, retry/backoff, graceful degradation, observability, recovery | Missing retries, no circuit breaker, silent failures, no health checks |
110
+
111
+ These 8 angles are comprehensive by design. If ALL 8 return empty, the codebase is genuinely optimized to the point where further changes would be cosmetic or harmful.
112
+
113
+ ## Perpetual Loop
114
+
115
+ ```text
116
+ ┌──────────────────────────────────────────────────────────────┐
117
+ │ W0: SENSE — 8 angle agents + oracle + spark (all parallel) │
118
+ │ ↓ │
119
+ │ A-GATE: Angle Exhaustion Gate │
120
+ │ ├── Findings exist (any source) → continue to W1 │
121
+ │ └── ALL sources empty? → CROSS-MODEL ORACLE │
122
+ │ ├── Oracle finds directions → feed into W1 │
123
+ │ └── Oracle also empty → auto.spark state │
124
+ │ ├── Spark finds candidates → feed into W1 │
125
+ │ └── Spark also empty → CONFIRM round │
126
+ │ ├── confirmCount < 2 → re-scan with variation│
127
+ │ └── confirmCount ≥ 2 → STOP (permanent) │
128
+ │ ↓ │
129
+ │ CHECKPOINT: every N cycles (adaptive: 2→5→10) │
130
+ │ ├── "Still aligned?" + "What should change?" │
131
+ │ └── Drift signal? → earlier checkpoint │
132
+ │ ↓ │
133
+ │ W1: PRIORITIZE — CEO ranks across ALL sources │
134
+ │ ↓ │
135
+ │ W2: IMPLEMENT — bounded change (≤3 files per cycle) │
136
+ │ ↓ │
137
+ │ W3: REVIEW — adversarial review of the change │
138
+ │ ↓ │
139
+ │ W4: DEBUG — if review/verify fails, fix and re-review │
140
+ │ ↓ │
141
+ │ W5: VERIFY — confirm the change works │
142
+ │ ↓ │
143
+ │ RECORD + EVIDENCE LEDGER — write to PROGRESS.md │
144
+ │ ↓ │
145
+ │ LOOP → W0 │
146
+ └──────────────────────────────────────────────────────────────┘
147
+ ```
148
+
149
+ ### W0: SENSE (Parallel Angle Scan)
150
+
151
+ CEO dispatches ALL 8 angle agents in ONE message. Each agent:
152
+
153
+ - **Role**: Read-only scanner through one angle lens
154
+ - **Read set**: The project source tree (scoped by CEO to relevant paths)
155
+ - **Return**: `{angle, findings: [{file, line, severity, description, suggestedFix}], exhausted: boolean, confidence: 0-1}`
156
+ - **Stop condition**: Returns when scan is complete — does not implement anything
157
+
158
+ Angle agents are READ-ONLY. They find, they don't fix.
159
+
160
+ Every cycle starts with a fresh W0 scan. The codebase changed since last cycle (due to W2-W5), so new findings may emerge.
161
+
162
+ ### A-GATE: Angle Exhaustion Gate (THE ONLY STOP)
163
+
164
+ This is the single most important gate in WF-AUTO. It prevents both premature stopping and infinite busywork.
165
+
166
+ **Gate Protocol (three-tier):**
167
+
168
+ ```
169
+ TIER 1 — All 8 angles return exhausted=true?
170
+ ├── NO → Findings exist. Continue to W1. Reset confirmCount to 0.
171
+ └── YES → Move to Tier 1.5 (Cross-Model Oracle).
172
+
173
+ TIER 1.5 — CROSS-MODEL ORACLE (fresh eyes before confirming exhaustion)
174
+ ├── CEO prepares a context pack: project summary, recent cycle history,
175
+ │ architecture overview, and the 8 angle exhaustion reports.
176
+ ├── CEO invokes the OTHER CLI (Codex if running as Claude, Claude if
177
+ │ running as Codex) — same detection rule as /wf-review.
178
+ │ Command: `git diff --stat && cat Harness/tasks/auto/PROGRESS.md |
179
+ │ codex exec "This project believes it is fully optimized. From 8
180
+ │ angles (correctness, performance, security, maintainability, test
181
+ │ coverage, architecture, UX/DX, robustness), find ANY optimization
182
+ │ direction that was missed. Be adversarial — prove us wrong."`
183
+ ├── Oracle returns: {findings: [...], empty: boolean}
184
+ ├── Oracle finds directions? → Feed into W1 as HIGH priority findings.
185
+ │ Reset confirmCount to 0. The oracle's fresh perspective broke the
186
+ │ local blind spot. Continue looping.
187
+ └── Oracle also empty? → Move to Tier 2. The external model agrees:
188
+ this codebase is genuinely optimized.
189
+
190
+ TIER 2 — Confirmation round.
191
+ ├── confirmCount < 2? → Increment confirmCount. Re-run W0 with
192
+ │ DIFFERENT agent seeds/scopes to prevent false negatives.
193
+ │ (e.g., if first scan was broad, second scan is deep-dive on
194
+ │ recent change areas; if first used file-level, second uses
195
+ │ function-level.)
196
+ └── confirmCount ≥ 2? → 3 consecutive rounds with all 8 exhausted
197
+ AND cross-model oracle confirmed empty. PERMANENT STOP.
198
+ Record final exhaustion evidence.
199
+ ```
200
+
201
+ **Oracle Rules (modeled on /wf-review):**
202
+
203
+ - [ ] CEO detects which CLI is running: `which codex` / `which claude`
204
+ - [ ] CEO invokes the OTHER CLI — never the same model
205
+ - [ ] If neither CLI is available: skip oracle, move directly to Tier 2, record "oracle unavailable" in PROGRESS.md
206
+ - [ ] Oracle is invoked at most ONCE per Tier 1 exhaustion event (not re-invoked per confirmation round — the confirmation rounds are local)
207
+ - [ ] Oracle findings are treated as severity=high by default (external model perspective gets extra weight)
208
+
209
+ **Gate Rules:**
210
+
211
+ - [ ] All 8 angles returned structured findings (not just "looks good")
212
+ - [ ] Each angle scanned ≥80% of its relevant surface area
213
+ - [ ] No angle was skipped or timed out
214
+ - [ ] Cross-Model Oracle was consulted (or unavailability recorded)
215
+ - [ ] confirmCount ≥ 2 (three consecutive all-exhausted rounds)
216
+ - [ ] CEO reviewed at least 2 angle returns that were borderline (confidence < 0.9)
217
+
218
+ **Anti-false-exhaustion measures:**
219
+ - Angle agents MUST include confidence scores. Low confidence (0.5-0.7) on "exhausted" = CEO re-dispatches that angle with a deeper scope.
220
+ - Between confirmation rounds, CEO varies the scan strategy: broad → deep, file-level → function-level, recent-changes → full-tree.
221
+ - If any angle returns confidence < 0.8 on "exhausted", that angle MUST be re-run with expanded scope before counting toward confirmCount.
222
+ - The Cross-Model Oracle is the ultimate blind-spot breaker — a different model family with different inductive biases. If it finds anything, the loop continues.
223
+
224
+ ### W1: PRIORITIZE
225
+
226
+ CEO takes all angle findings, deduplicates, and ranks:
227
+
228
+ ```
229
+ priorityScore = severity × impactRadius × reversibility
230
+
231
+ severity: critical=10, high=6, medium=3, low=1
232
+ impactRadius: files touched × user paths affected
233
+ reversibility: easy-to-revert=1.2, hard-to-revert=0.5
234
+ ```
235
+
236
+ CEO picks the SINGLE highest-scoring finding. One change per cycle keeps each iteration bounded and reviewable.
237
+
238
+ If multiple findings tie, prefer: correctness > security > robustness > performance > architecture > maintainability > test-coverage > ux-dx.
239
+
240
+ ### W2: IMPLEMENT
241
+
242
+ Modeled on WF's build loop but scoped to ONE change:
243
+
244
+ 1. CEO writes the change spec in `Harness/tasks/auto/PROGRESS.md` (cycle number, angle, finding, planned change, write set ≤3 files)
245
+ 2. CEO dispatches `implementer` with the change spec
246
+ 3. Implementer changes ONLY the declared write set
247
+
248
+ CEO NEVER writes production code — this rule is inherited from WF-MAX (AP1: CEO-as-Worker).
249
+
250
+ ### W3: REVIEW
251
+
252
+ Two-gate review (from WF/subagents.md):
253
+
254
+ 1. **Spec review**: Did the change address the finding without introducing extras?
255
+ 2. **Code-quality review**: Is the change correct, maintainable, safe?
256
+
257
+ At least one `reviewer` subagent. For critical/security findings, dispatch two independent reviewers.
258
+
259
+ ### W4: DEBUG (Recovery)
260
+
261
+ If review or verification fails:
262
+ 1. `debugger` isolates the smallest failing path
263
+ 2. Fix and re-review (max 2 attempts per cycle)
264
+ 3. On 3rd failure: record the finding as "attempted, blocked" and move to next finding in W1
265
+ 4. Blocked findings are revisited after 3 cycles (the codebase may have changed enough to unblock)
266
+
267
+ ### W5: VERIFY
268
+
269
+ - Run project test suite (or relevant subset)
270
+ - For browser-visible changes: real browser check
271
+ - For API changes: real request/response check
272
+ - Record evidence in `Harness/tasks/auto/PROGRESS.md`
273
+
274
+ ### RECORD
275
+
276
+ Every cycle writes one entry to `Harness/tasks/auto/PROGRESS.md`:
277
+
278
+ ```text
279
+ ## Cycle N (timestamp) — State: auto.internal | auto.spark | auto.checkpoint
280
+ - Source: internal (angle: correctness) | oracle | spark-github | spark-ecosystem
281
+ - Finding: unhandled null in userService.getUser()
282
+ - Source citation: <URL if external>
283
+ - Change: added null guard + error response in controller
284
+ - Files: src/controllers/user.ts, src/services/user.ts
285
+ - Value Gate scores: Impact=4, Evidence=3, Fit=5, Timing=4, Cost/Risk=4 (Total=20/25 ✓)
286
+ - Review: PASS (spec + code-quality)
287
+ - Verify: PASS (unit tests + manual API check)
288
+ - Evidence Ledger:
289
+ - Evidence type: code analysis
290
+ - Expected impact: null safety in user lookup path
291
+ - Verification method: unit test + manual API check
292
+ - Measured result: CONFIRMED — null case now returns 404 instead of 500
293
+ - Residual risk: none
294
+ ```
295
+
296
+ ### LOOP → W0
297
+
298
+ IMMEDIATELY return to W0. No pause between cycles — the only breaks are the adaptive Intent Checkpoint and the A-GATE.
299
+
300
+ ### Intent Checkpoint (adaptive re-anchoring)
301
+
302
+ WF-AUTO is autonomous but not blind. Every N cycles, the CEO pauses briefly to verify alignment. This is NOT a hard stop — it's a lightweight drift check.
303
+
304
+ **Adaptive interval:**
305
+ - First checkpoint: after 2 cycles (quick alignment check)
306
+ - Then: every 5 cycles
307
+ - After user says "keep going, don't ask": every 10 cycles
308
+ - Early trigger on drift signals: destructive change, public API change, or CEO confidence in alignment drops below 0.7
309
+
310
+ **Checkpoint protocol (only 2 questions):**
311
+
312
+ CEO presents:
313
+ 1. Summary of recent cycles (max 3 lines)
314
+ 2. Current inferred trajectory
315
+ 3. Two questions:
316
+
317
+ > **Q1**: "Still aligned with what you want?"
318
+ > **Q2**: "What should change?"
319
+
320
+ **Responses:**
321
+ - User confirms or gives direction → update trajectory in PLAN.md, continue
322
+ - User says "I don't know" / vague → CEO proposes auto.spark mode: "I can search external sources (GitHub, docs, trends) for inspiration. I'll verify every idea has real value before implementing. Switch to spark-augmented mode?"
323
+ - User says "keep going, don't ask again" → extend interval to 10 cycles, record preference
324
+ - User says "stop" → transition to `paused` state
325
+
326
+ **Why 2 questions, not 5:** Five aggressive questions train users to say "keep going" to escape the interrogation. Two questions with a concrete summary gets honest answers.
327
+
328
+ ### Spark: External Candidate Provider
329
+
330
+ Spark is NOT a separate optimization engine. It is a **candidate provider** plugged into W0, alongside the internal 8-angle scan and the cross-model oracle. W1 still owns prioritization across ALL sources.
331
+
332
+ **When spark activates:**
333
+ - W0 internal scan returns empty AND oracle also empty → `auto.spark` state
334
+ - User explicitly requests `/wf-auto-spark` → full perpetual inspiration mode (see `WF-AUTO-SPARK.md`)
335
+ - User says "I don't know" at an Intent Checkpoint
336
+
337
+ **`/wf-auto-spark` is a standalone perpetual mode** (spec: `Harness/WF-AUTO-SPARK.md`). Unlike vanilla spark which is a candidate provider inside `/wf-auto`, the standalone mode:
338
+ - Never auto-stops — only user can stop it
339
+ - Requires a roadmap (North Star + staged milestones) declared at startup
340
+ - Enforces ≤50% deviation guard against North Star
341
+ - Runs Re-Anchor Gate every 10 cycles for user course-correction
342
+
343
+ **Spark sources (searched in parallel, read-only):**
344
+
345
+ | # | Source | Tool | Evidence Weight |
346
+ |---|--------|------|-----------------|
347
+ | 1 | **Official Docs & Advisories** | WebSearch + Docs | HIGH — authoritative |
348
+ | 2 | **Ecosystem Pulse** | WebSearch / registry | MEDIUM — factual but may not apply |
349
+ | 3 | **GitHub Trending (same stack)** | WebSearch | LOW-MEDIUM — popular ≠ correct |
350
+ | 4 | **Best Practices (latest)** | WebSearch + Docs | MEDIUM — context-dependent |
351
+ | 5 | **Competitor/Peer Projects** | WebSearch | LOW — hypothesis only, needs verification |
352
+ | 6 | **Real-world Issues** | WebSearch / Stack Overflow | MEDIUM — evidence of real pain |
353
+ | 7 | **Architecture Trends** | WebSearch | LOW — premature adoption risk |
354
+ | 8 | **Performance Benchmarks** | WebSearch | MEDIUM — if reproducible |
355
+
356
+ **Spark source-quality rules:**
357
+ - Official docs and security advisories beat blog posts
358
+ - Trending repos are weak evidence — many stars ≠ good fit
359
+ - Competitor behavior is hypothesis only, never justification
360
+ - Every spark candidate MUST cite its source with URL and date
361
+ - Offline: if web search fails, skip spark, record "spark offline" in PROGRESS.md
362
+ - Stale sources (>1 year for fast-moving ecosystems): flag with `[STALE]` tag
363
+
364
+ **Spark candidates flow into W1 with `source=spark-<source-name>`:**
365
+
366
+ W1 prioritization now handles three source types:
367
+ - `source=internal` — from 8-angle scan
368
+ - `source=oracle` — from cross-model review
369
+ - `source=spark-<name>` — from external inspiration search
370
+
371
+ Tie-breaking: internal > oracle > spark (local context beats external inspiration).
372
+
373
+ ### Value Gate (scoring, not binary)
374
+
375
+ Before a spark candidate enters W1, it passes through the Value Gate. Binary yes/no invites fake confidence. Use 5-dimension scoring:
376
+
377
+ | Dimension | 1 (worst) | 3 (acceptable) | 5 (best) |
378
+ |-----------|-----------|----------------|----------|
379
+ | **Impact** | Cosmetic, no user notice | Noticeable improvement | Transformative |
380
+ | **Evidence** | "Feels right", no data | One source or benchmark | Multiple sources + reproducible |
381
+ | **Fit** | Conflicts with project direction | Neutral, doesn't hurt | Directly advances trajectory |
382
+ | **Timing** | Premature, distracts from current bet | Reasonable moment | Urgent or uniquely opportune |
383
+ | **Cost/Risk** | High risk, fragile change | Moderate, reversible | Low risk, trivial to revert |
384
+
385
+ **Pass threshold:** Total ≥ 18/25 AND no dimension below 3.
386
+
387
+ **Spark stop condition (empirical, not arbitrary):**
388
+ Spark mode stops when ANY of:
389
+ - 5 consecutive candidates fail the Value Gate (nothing meaningful found)
390
+ - 3 implemented spark cycles with weak measured impact (evidence ledger shows no real gain)
391
+ - 2 repeated source families with zero new candidates (search exhausted)
392
+ - User interrupts
393
+
394
+ ### Evidence Ledger
395
+
396
+ Every cycle records an evidence entry. This turns spark from "inspiration theater" into an empirical optimization loop:
397
+
398
+ ```text
399
+ ## Cycle N - Evidence Ledger
400
+ Candidate source: internal (angle: performance) | oracle | spark-github | spark-ecosystem
401
+ Source citation: <URL and date if external>
402
+ Evidence type: benchmark | docs | user report | code analysis | hypothesis
403
+ Expected impact: <concrete metric or observable change>
404
+ Verification method: test | benchmark | manual check | browser evidence
405
+ Measured result: <actual outcome after W5 — filled AFTER verification>
406
+ Verdict: CONFIRMED (impact matched) | PARTIAL (some gain) | NEGLIGIBLE (no real change) | REVERTED (caused regression)
407
+ ```
408
+
409
+ If a spark cycle's measured result is NEGLIGIBLE or REVERTED, increment `weakSparkCount`. After 3 weak spark cycles, spark enters `auto.exhausted`.
410
+
411
+ ## CEO Constraints
412
+
413
+ The CEO operates under the same strict tool boundary as WF-MAX:
414
+
415
+ | CEO Has | CEO MUST NOT Use (on source code) |
416
+ |---------|-----------------------------------|
417
+ | Task (spawn agents) | Edit (on source files) |
418
+ | Read (for scoping) | Write (on source files) |
419
+ | Grep/Glob (for scoping) | MultiEdit (on source files) |
420
+ | Write (to PROGRESS.md only) | Bash (except final verification) |
421
+
422
+ **Exception**: CEO MAY write to `Harness/tasks/auto/PROGRESS.md` and `Harness/tasks/auto/PLAN.md` — these are task-tracking artifacts.
423
+
424
+ ## Anti-Pattern Catalog
425
+
426
+ | # | Anti-Pattern | Symptom | Fix |
427
+ |---|-------------|---------|-----|
428
+ | AP1 | **CEO-as-Worker** | CEO writes production code | Delegate ALL implementation to Workers |
429
+ | AP2 | **Premature stop** | CEO decides "good enough" before A-GATE | A-GATE is the ONLY stop. No exceptions. |
430
+ | AP3 | **Shallow angle scan** | Angle returns "exhausted" after scanning 1-2 files | Require ≥80% surface coverage per angle |
431
+ | AP4 | **Batch implementation** | Multiple unrelated changes in one cycle | ONE finding per cycle. Split if needed. |
432
+ | AP5 | **Sequential angle scan** | Angles dispatched one at a time | ALL 8 angles in ONE message, every cycle |
433
+ | AP6 | **Skip review** | Implementation → verify without review | Review gate is mandatory, every cycle |
434
+ | AP7 | **Scope creep** | A "simple fix" grows to 5+ files | Hard cap: ≤3 files per cycle. Split larger changes across cycles. |
435
+ | AP8 | **False exhaustion** | Angle returns exhausted=true with low confidence | Require confidence ≥0.8 on exhausted. Re-dispatch low-confidence angles. |
436
+ | AP9 | **Stale angle agents** | Same scan strategy every cycle → blind spots emerge | Vary scan depth and scope between cycles |
437
+ | AP10 | **Skip oracle** | All 8 exhausted → CEO goes straight to confirm rounds without consulting other CLI | Oracle is mandatory at Tier 1.5. If CLI unavailable, record it and proceed — but never skip because "it's probably fine." |
438
+ | AP11 | **Spark as escape hatch** | Using spark to avoid the discipline of internal scan | Spark activates ONLY when internal + oracle are empty. It augments W0, not replaces it. |
439
+ | AP12 | **Fake value scoring** | Inflating Value Gate scores to pass candidates through | CEO must justify each dimension score. Reviewer checks Value Gate scores as part of spec review. |
440
+ | AP13 | **Shiny object syndrome** | Implementing every spark candidate without Value Gate filtering | All spark candidates MUST pass the Value Gate (≥18/25, no dimension <3). |
441
+ | AP14 | **Inspiration theater** | Spark cycles without evidence ledger → no way to know if they worked | Evidence ledger is mandatory per cycle. Weak spark count tracked. |
442
+ | AP15 | **Interrogation checkpoint** | Asking 5+ aggressive questions → user tunes out | Exactly 2 questions: "Still aligned?" + "What should change?" |
443
+
444
+ ## Safety Controls
445
+
446
+ ### File Change Cap
447
+ - Max 3 files changed per cycle
448
+ - Max 50 lines changed per cycle (total diff)
449
+ - Prevents runaway refactors
450
+
451
+ ### Destructive Change Detection
452
+ Before W2, CEO checks: does this change delete functionality, change public API, or alter behavior visible to users?
453
+ - If yes → flag in PROGRESS.md, require higher confidence threshold, add rollback plan
454
+ - If the finding is "delete dead code" → only delete if genuinely unreachable (verified by grep across full tree)
455
+
456
+ ### Idle Detection
457
+ - If 5 consecutive cycles produce 0-line changes (all findings rejected at review), trigger IDLE alarm
458
+ - IDLE → CEO re-evaluates: are angle agents scoped too narrowly? Is the codebase actually done?
459
+ - After IDLE alarm + re-scope + 2 more empty cycles → consider A-GATE
460
+
461
+ ### User Interrupt
462
+ - User can interrupt at any time with new instructions
463
+ - Interrupt pauses the loop; CEO records current cycle state
464
+ - After addressing interrupt, resume from W0 (fresh scan)
465
+
466
+ ## When NOT to Use /wf-auto
467
+
468
+ - Explicit user task with defined completion criteria → use `/wf` or `/wf-max`
469
+ - Single known bug → just fix it directly
470
+ - User wants to review every change before it's made → /wf-auto is autonomous by design
471
+ - Codebase is <100 lines → angle scan overhead > benefit
472
+ - Production hotfix needed urgently → direct fix, not optimization loop
473
+
474
+ ## /wf vs /wf-max vs /wf-auto
475
+
476
+ | Dimension | /wf | /wf-max | /wf-auto |
477
+ |-----------|-----|---------|----------|
478
+ | Scope | Task-bounded | Task-bounded | Unbounded |
479
+ | Stop condition | Task complete | Task complete | 8-angle exhaustion + oracle + spark exhausted + 2 confirm rounds |
480
+ | Direction | User-specified | User-specified | AI-inferred + cross-model oracle + external spark |
481
+ | Organization | Flat (CEO + agents) | 3-tier (CEO→Mgr→Worker) | Flat (CEO + angle agents + oracle + spark searchers + build agents) |
482
+ | Duration | One task | One task | Perpetual |
483
+ | User interaction | At key gates | At key gates | Adaptive checkpoint (2→5→10 cycles), 2 questions only |
484
+ | Cycle count | 1 | 1 (multi-wave) | ∞ (until exhaustion) |
485
+ | Files/cycle | Per task | Per wave (many) | ≤3 per cycle |
486
+ | Exploration | 3-5 agents once | 5-10 agents once | 8 angles + oracle + 8 spark sources EVERY cycle |
487
+ | Cross-model check | No (wf-review is separate) | No (wf-review is separate) | Yes — Cross-Model Oracle built into A-GATE Tier 1.5 |
488
+ | External inspiration | No | No | Yes — Spark candidate provider when internal sources empty |
489
+ | Evidence tracking | Per task | Per task | Evidence ledger per cycle with measured impact |
490
+
491
+ ## Task Capsule
492
+
493
+ WF-AUTO uses a dedicated task capsule at `Harness/tasks/auto/`:
494
+
495
+ - `Harness/tasks/auto/PROGRESS.md` — cycle log, exhaustion evidence, cumulative stats
496
+ - `Harness/tasks/auto/PLAN.md` — current cycle's change spec
497
+
498
+ Unlike normal task capsules, this one is never archived — it's the permanent home of the auto-optimization state.
499
+
500
+ ## Closeout (The Only Exit)
501
+
502
+ Closeout happens exactly once, when A-GATE passes permanently:
503
+
504
+ 1. CEO records final exhaustion evidence from all 8 angles (3 consecutive rounds)
505
+ 2. CEO writes summary: total cycles, files changed, findings addressed, findings rejected, residual risk
506
+ 3. CEO marks `Harness/tasks/auto/PROGRESS.md` as "WF-AUTO EXHAUSTED" with timestamp
507
+ 4. `Harness/PROGRESS.md` is updated with the auto session outcome
508
+ 5. No further automatic action is taken
@@ -1,5 +1,29 @@
1
1
  # WF-MAX — Maximum Parallelism Workflow
2
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
+
3
27
  ## Trigger
4
28
 
5
29
  - Explicit: `/wf-max [task]`
@@ -32,57 +32,94 @@ Load other docs only by trigger.
32
32
  | research, competitors, stack choice | `Harness/research/README.md`, `Harness/research/research-results.md` |
33
33
  | task split, owner, write set | `Harness/tasks/<task-id>/PROGRESS.md`, `Harness/tasks/<task-id>/PLAN.md`, `Harness/agent-workflow.md` |
34
34
  | parallel agents, dispatch, worktree decision | `Harness/subagents.md`, `Harness/dispatch.md`, `Harness/tasks/<task-id>/PLAN.md` |
35
+ | `/wf` mode, long task, multi-file, multi-agent | `Harness/WF.md`, `Harness/subagents.md`, `Harness/dispatch.md`, `Harness/tasks/<task-id>/PLAN.md` |
36
+ | `/wf max`, 5+ disjoint files, maximum parallelism | `Harness/WF-MAX.md`, `Harness/subagents.md`, `Harness/dispatch.md`, `Harness/tasks/<task-id>/PLAN.md` |
35
37
  | memory, repeated tool failure, repeated user correction, reusable lesson | `Harness/MEMORY.md`, the relevant `Harness/memory/*.md` file |
36
38
  | subagent spawn | `Harness/subagents.md`, this file plus the role pack below |
37
39
 
40
+ ## ECC Rules Per Role
41
+
42
+ Each subagent role loads a specific ECC rule subset. The dispatcher MUST include
43
+ `ecc` in the dispatch packet so the subagent knows which rules to read first.
44
+
45
+ | Role | Frontend Task | Backend Task | Full-Stack Task |
46
+ |------|--------------|-------------|-----------------|
47
+ | **Explorer** | `web/patterns.md`, `web/design-quality.md` | `common/patterns.md`, stack patterns | All |
48
+ | **Planner** | `common/patterns.md`, `web/patterns.md` | `common/patterns.md`, stack patterns | All |
49
+ | **Architect** | `web/patterns.md`, `web/performance.md` | `common/patterns.md`, `python/fastapi.md` or `golang/patterns.md` | All + API contract |
50
+ | **Implementer (FE)** | `web/design-quality.md`, `web/patterns.md`, `web/performance.md`, `typescript/patterns.md` | N/A | Frontend subset |
51
+ | **Implementer (BE)** | N/A | `common/patterns.md`, `python/fastapi.md` or `golang/patterns.md` | Backend subset |
52
+ | **Test Writer** | `web/testing.md`, `typescript/testing.md` | Stack testing rules | Both |
53
+ | **Reviewer** | `web/design-quality.md`, `web/security.md`, `web/performance.md` | Stack security + testing rules | All |
54
+ | **Debugger** | Stack-specific hooks + coding-style | Stack-specific hooks + coding-style | Context-dependent |
55
+ | **Verifier** | `web/testing.md` | Stack testing rules | Both |
56
+
38
57
  ## Subagent Packs
39
58
 
59
+ Each pack now includes `ecc` — the ECC rule files this role MUST load first.
60
+
40
61
  Explorer Pass:
62
+ - ecc: `common/patterns.md` + stack-specific patterns (see ECC Rules Per Role)
41
63
  - inject: question, read boundary, relevant docs
42
64
  - forbid: writes
43
65
  - return: files found, facts, risks, suggested tests
44
66
 
45
67
  Planner:
68
+ - ecc: `common/patterns.md` + `common/development-workflow.md`
46
69
  - inject: user goal, lifecycle phase, PRD or PLAN section, dispatch constraints
47
70
  - forbid: production code
48
71
  - return: tasks, dependencies, read/write sets, dispatch table, gates, open questions
49
72
 
50
73
  Researcher:
74
+ - ecc: none (uses WebSearch/WebFetch, not code rules)
51
75
  - inject: question, decision needed, source boundaries, tool options
52
76
  - forbid: production code
53
77
  - return: sources, adopted/rejected/watch decisions, risks, research-results.md patch
54
78
 
55
79
  Docs Researcher:
80
+ - ecc: none (uses official docs, not code rules)
56
81
  - inject: library/API/config, implementation question, version/date constraints
57
82
  - forbid: production code
58
83
  - return: official links, constraints, errors, examples, affected docs
59
84
 
60
85
  Architect:
86
+ - ecc: `common/patterns.md` + stack-specific (web/patterns.md for FE, python/fastapi.md for BE)
61
87
  - inject: PRD, current architecture, ports
62
88
  - forbid: implementation
63
89
  - return: boundary decision, affected docs, risks
64
90
 
65
91
  Test Writer:
92
+ - ecc: `common/testing.md` + stack-specific testing rules
66
93
  - inject: acceptance criteria, feature doc, test write set
67
94
  - forbid: production code
68
95
  - return: failing tests and test intent
69
96
 
70
- Implementer:
97
+ Implementer (Frontend):
98
+ - ecc: `web/design-quality.md`, `web/patterns.md`, `web/performance.md`, `typescript/patterns.md`
99
+ - inject: task, tests, allowed write set, forbidden scope
100
+ - forbid: unrelated refactor and test loosening
101
+ - return: changed files and implementation notes
102
+
103
+ Implementer (Backend):
104
+ - ecc: `common/patterns.md`, stack-specific patterns (`python/fastapi.md` or `golang/patterns.md`)
71
105
  - inject: task, tests, allowed write set, forbidden scope
72
106
  - forbid: unrelated refactor and test loosening
73
107
  - return: changed files and implementation notes
74
108
 
75
109
  Reviewer:
110
+ - ecc: `web/design-quality.md` (FE), `web/security.md` (FE), `common/security.md`, stack security
76
111
  - inject: diff, acceptance criteria, architecture docs
77
112
  - forbid: writes
78
113
  - return: findings by severity, missing tests, boundary issues
79
114
 
80
115
  Debugger:
116
+ - ecc: stack-specific coding-style + hooks rules
81
117
  - inject: failing command, error output, related files
82
118
  - forbid: broad rewrites
83
119
  - return: root cause, fix, proof
84
120
 
85
121
  Verifier:
122
+ - ecc: stack-specific testing rules
86
123
  - inject: verification commands and acceptance criteria
87
124
  - forbid: code changes
88
125
  - return: commands run, results, residual risk