create-harness-vibe-coding 0.8.6 → 0.8.8

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