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