@matt82198/aesop 0.1.0-rc.1 → 0.2.0

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 (114) hide show
  1. package/CHANGELOG.md +101 -2
  2. package/README.md +66 -15
  3. package/bin/cli.js +164 -41
  4. package/daemons/run-watchdog.sh +16 -4
  5. package/daemons/selfheal.sh +231 -0
  6. package/docs/ANY-REPO.md +427 -0
  7. package/docs/CONTRIBUTING.md +72 -0
  8. package/docs/DEMO.md +334 -0
  9. package/docs/INSTALL.md +70 -1
  10. package/docs/QUICKSTART.md +80 -0
  11. package/docs/README.md +33 -3
  12. package/docs/TEAM-STATE.md +540 -0
  13. package/driver/CLAUDE.md +148 -0
  14. package/driver/README.md +383 -0
  15. package/driver/aesop.config.example.json +80 -0
  16. package/driver/agent_driver.py +355 -0
  17. package/driver/backend_config.py +253 -0
  18. package/driver/claude_code_driver.py +198 -0
  19. package/driver/codex_driver.py +626 -0
  20. package/driver/openai_compatible_driver.py +249 -0
  21. package/driver/openai_transport.py +146 -0
  22. package/driver/verification_policy.py +75 -0
  23. package/driver/wave_bridge.py +246 -0
  24. package/driver/wave_loop.py +1041 -0
  25. package/hooks/pre-push-policy.sh +109 -28
  26. package/mcp/server.mjs +320 -4
  27. package/package.json +23 -15
  28. package/skills/CLAUDE.md +132 -2
  29. package/skills/buildsystem/SKILL.md +330 -0
  30. package/skills/buildsystem/wave-flat-dispatch.template.mjs +658 -0
  31. package/skills/fleet/SKILL.md +113 -0
  32. package/skills/power/SKILL.md +246 -131
  33. package/state_store/__init__.py +2 -1
  34. package/state_store/api.py +19 -4
  35. package/state_store/coordination.py +209 -0
  36. package/state_store/identity.py +51 -0
  37. package/state_store/store.py +185 -73
  38. package/templates/wave-presets/data.json +65 -0
  39. package/templates/wave-presets/library.json +65 -0
  40. package/templates/wave-presets/saas.json +64 -0
  41. package/tools/audit_report.py +388 -0
  42. package/tools/bench_runner.py +100 -3
  43. package/tools/ci_merge_wait.py +256 -35
  44. package/tools/ci_workflow_lint.py +430 -0
  45. package/tools/claudemd_drift.py +394 -0
  46. package/tools/claudemd_lint.py +359 -0
  47. package/tools/common.py +39 -3
  48. package/tools/cost_ceiling.py +63 -31
  49. package/tools/cost_econ.py +480 -0
  50. package/tools/defect_escape.py +252 -0
  51. package/tools/doctor.js +1 -1
  52. package/tools/eod_sweep.py +58 -0
  53. package/tools/fleet.js +260 -0
  54. package/tools/fleet_ledger.py +209 -7
  55. package/tools/git_identity_check.py +315 -0
  56. package/tools/health-score.js +40 -0
  57. package/tools/health_score.py +361 -0
  58. package/tools/metrics_gate.py +13 -4
  59. package/tools/mutation_test.py +401 -0
  60. package/tools/portability_check.py +206 -0
  61. package/tools/reconcile.py +7 -4
  62. package/tools/secret_scan.py +137 -50
  63. package/tools/self_stats.py +20 -0
  64. package/tools/transcript_digest.py +380 -0
  65. package/tools/verify_activity_filter.py +437 -0
  66. package/tools/verify_agent_inspector.py +2 -0
  67. package/tools/verify_dash.py +2 -0
  68. package/tools/verify_dispatch_panel.py +301 -0
  69. package/tools/verify_failure_drilldown.py +188 -0
  70. package/tools/verify_prboard.py +2 -0
  71. package/tools/verify_scorecards.py +281 -0
  72. package/tools/verify_submit_encoding.py +2 -0
  73. package/tools/verify_ui_trio.py +409 -0
  74. package/tools/verify_wave_telemetry.py +268 -0
  75. package/tools/wave_backlog_analyzer.py +490 -0
  76. package/tools/wave_ledger_hook.py +150 -0
  77. package/tools/wave_preflight.py +512 -0
  78. package/tools/wave_resume.py +215 -0
  79. package/tools/wave_templates.py +215 -0
  80. package/ui/agents.py +68 -14
  81. package/ui/collectors.py +0 -55
  82. package/ui/config.py +7 -2
  83. package/ui/cost.py +231 -12
  84. package/ui/handler.py +183 -0
  85. package/ui/quality_scorecard.py +232 -0
  86. package/ui/wave_audit_tail.py +213 -0
  87. package/ui/wave_dispatch.py +280 -0
  88. package/ui/wave_failure.py +288 -0
  89. package/ui/wave_gantt.py +152 -0
  90. package/ui/wave_reasoning_tail.py +176 -0
  91. package/ui/wave_telemetry.py +377 -0
  92. package/ui/web/dist/assets/index-BGbgw2Nh.js +9 -0
  93. package/ui/web/dist/assets/index-DqZLgwNg.css +1 -0
  94. package/ui/web/dist/index.html +2 -2
  95. package/bin/CLAUDE.md +0 -76
  96. package/daemons/CLAUDE.md +0 -36
  97. package/dash/CLAUDE.md +0 -32
  98. package/docs/archive/README.md +0 -3
  99. package/docs/archive/spikes/tiered-cognition/ACTIVATION.md +0 -125
  100. package/docs/archive/spikes/tiered-cognition/DESIGN.md +0 -287
  101. package/docs/archive/spikes/tiered-cognition/FINDINGS.md +0 -113
  102. package/docs/archive/spikes/tiered-cognition/README.md +0 -27
  103. package/docs/archive/spikes/tiered-cognition/aesop-cognition.example.md +0 -32
  104. package/docs/archive/spikes/tiered-cognition/force-model-policy.merged.mjs +0 -673
  105. package/docs/archive/spikes/tiered-cognition/strip-tools-hook.mjs +0 -434
  106. package/hooks/CLAUDE.md +0 -89
  107. package/mcp/CLAUDE.md +0 -213
  108. package/monitor/CLAUDE.md +0 -40
  109. package/scan/CLAUDE.md +0 -30
  110. package/state_store/CLAUDE.md +0 -39
  111. package/tools/CLAUDE.md +0 -79
  112. package/ui/CLAUDE.md +0 -127
  113. package/ui/web/dist/assets/index-0qQYnvMC.js +0 -9
  114. package/ui/web/dist/assets/index-BdIlFieV.css +0 -1
package/skills/CLAUDE.md CHANGED
@@ -1,4 +1,134 @@
1
1
  # skills/ — Orchestration and priming skills
2
2
 
3
- - **power/** /power skill: prime the filesystem brain (load rules, dispatch model, memory, state) and report system health — see power/SKILL.md
4
- - **healthcheck/** /healthcheck skill: check fleet health one colored ball (heartbeats, alerts, orchestrator, tracker items) — see healthcheck/SKILL.md
3
+ ## Universal rules (every domain)
4
+ - Feature branch only, never main; every push gated by `python tools/secret_scan.py --staged` exit 0.
5
+ - Tests never pollute cwd or global git config; temp dirs only; dummy secrets are runtime-concatenated, never literal.
6
+ - In worktrees use ABSOLUTE paths under the worktree for every write.
7
+ - Domain docs stay minimal-but-complete; update this file in the same PR as code it describes.
8
+
9
+ ## Module layout
10
+
11
+ Four orchestration skills, each invoked via CLI (e.g., `/buildsystem`, `/power`):
12
+
13
+ - **power/** — prime the filesystem brain (load CLAUDE.md rules, dispatch model, memory, state); init-prime or fast-path for already-primed repos
14
+ - **buildsystem/** — execute one complete orchestrated development wave (backlog rank → parallel Haiku fleet → merge train → checkpoint → audit)
15
+ - **healthcheck/** — check fleet health (one colored ball: green/yellow/red based on heartbeats, alerts, orchestrator status)
16
+ - **fleet/** — snapshot fleet state as JSON (agents, heartbeats, tracker lanes, orchestrator status) — never mutates
17
+
18
+ ## Buildsystem manifest & work-order contract
19
+
20
+ **Backlog format** (`state/BACKLOG.md`):
21
+ ```markdown
22
+ ## P1: Critical
23
+ - [ ] Task title — agent-type — time-estimate
24
+ Example: Fix secret-scan hang — backend-dev — 5min
25
+ ## P2: Features
26
+ - [ ] Add feature X — frontend-dev — 8min
27
+ ## P3: Tech Debt
28
+ - [ ] Refactor module Y — backend-dev — 15min
29
+ ```
30
+
31
+ Time estimates: 3–5 min (typo/config), 5–10 min (function/test), 10–15 min (module refactor), 15+ min (split smaller).
32
+
33
+ **Work-order contract** (each agent receives):
34
+ - Task: one backlog item (feature/fix/tech debt)
35
+ - Agent type: backend-dev, frontend-dev, test-bot, docs-agent, etc.
36
+ - Time budget: 3–10 min (Haiku best-effort scope)
37
+ - Scope: reproduce, change location, test command, commit message template
38
+ - Constraints: never modify CLAUDE.md/STATE.md, must pass pre-commit hook, no external calls
39
+
40
+ **Preflight guard invariant** (wave-flat-dispatch.template.mjs):
41
+ - No two backlog items may own the same file or directory
42
+ - Each item assigned to exactly one agent
43
+ - Preflight detects overlap and aborts with remediation plan before dispatch
44
+
45
+ **Phases**:
46
+ 1. Preflight (1–2 min) — validate setup, check heartbeat, parse backlog, detect file overlap
47
+ 2. Backlog & Dispatch (5–10 min) — rank items, assign agents, create work orders
48
+ 3. Fleet Execution (30–90 min) — Haiku agents work in parallel, in isolated worktrees
49
+ 4. Code Review & Integration (10–30 min) — run CI, merge train (serial), flag failures
50
+ 5. Checkpoint & Audit (2–5 min) — update STATE.md, append BUILDLOG.md, commit + push
51
+
52
+ **Worktree isolation** (critical):
53
+ - Each agent runs in `aesop-wt-<wave>-<agent-id>/` (independent branch, HEAD, working dir)
54
+ - Zero cross-agent interference
55
+ - Automatic cleanup after wave closes
56
+
57
+ **Merge serialization** (critical):
58
+ - All PRs from a wave merge through serial merge train
59
+ - First agent to green CI merges, next waits for main to stabilize, re-tests, then merges
60
+
61
+ ## Power skill
62
+
63
+ Two entry paths:
64
+
65
+ 1. **Init-prime** (unprimed repo, no CLAUDE.md): fan-out Haiku explorers → synthesize project CLAUDE.md + domain units + STATE.md seed → commit + push
66
+ 2. **Already-primed** (fast path): load global rules (`~/.claude/CLAUDE.md`), load memory (MEMORY.md), load active project STATE.md, report compact brief, optionally spin up app and monitor background loops
67
+
68
+ Prerequisites: Aesop scaffolded into repo via CLI (`npx @matt82198/aesop . --name "my-project"`).
69
+
70
+ ## Healthcheck skill
71
+
72
+ One-line status command: `python tools/healthcheck.py` (or `--json` for machine-readable).
73
+
74
+ Output ball:
75
+ - **🟢 Green** — watchdog <300s, monitor <3600s, no HIGH alerts
76
+ - **🟡 Yellow** — stale heartbeat OR unreviewed MED alert
77
+ - **🔴 Red** — HIGH alert OR watchdog dead (>600s) during active dispatch
78
+
79
+ ## Fleet skill
80
+
81
+ One-shot snapshot: `aesop fleet` (JSON output, read-only, never mutates state).
82
+
83
+ Returns:
84
+ - heartbeats (watchdog, monitor: age, status, thresholds)
85
+ - agents (active: id, project, status, age, tokens, task label)
86
+ - tracker (backlog counts by lane)
87
+ - orchestrator (activity, phase, timestamp)
88
+
89
+ Graceful degradation: missing files produce `unavailable: "<reason>"` entries.
90
+
91
+ ## Test commands
92
+
93
+ - **buildsystem**: Run a full wave (in a test repo with mock backlog)
94
+ ```bash
95
+ cd <test-repo>
96
+ /buildsystem
97
+ # Verify: STATE.md updated, BUILDLOG.md appended, PRs merged
98
+ ```
99
+ - **power**: Prime a new repo or already-primed repo
100
+ ```bash
101
+ /power
102
+ # Verify: compact brief output, CLAUDE.md files readable, STATE.md NEXT STEPS clear
103
+ ```
104
+ - **healthcheck**: Check fleet health
105
+ ```bash
106
+ python tools/healthcheck.py
107
+ python tools/healthcheck.py --json
108
+ ```
109
+ - **fleet**: Snapshot fleet state
110
+ ```bash
111
+ aesop fleet
112
+ # Verify: JSON valid, heartbeats present, agents or "unavailable" message
113
+ ```
114
+
115
+ ## Key invariants & gotchas
116
+
117
+ 1. **Buildsystem is stateless across phases** — each phase stands alone (safe to restart mid-wave)
118
+ 2. **Backlog must be parseable** (YAML or markdown, consistent format) — preflight will abort on parse errors
119
+ 3. **File ownership overlap is fatal** — preflight guard prevents two agents from touching same file
120
+ 4. **Worktrees auto-cleanup** — don't manually delete `aesop-wt-*` dirs; buildsystem handles it
121
+ 5. **Power init-prime writes repo files** — controlled commit + push via secret-scan gate
122
+ 6. **Healthcheck is read-only** — diagnostics only, never repairs
123
+ 7. **Fleet snapshot is JSON canonical** — orchestrators use this, not ad-hoc state reads
124
+
125
+ ## Domain-specific details
126
+
127
+ Each skill has its own **SKILL.md** file in its directory with complete implementation details, manifests, and troubleshooting:
128
+
129
+ - `skills/buildsystem/SKILL.md` — phases, manifest, work-order contract, troubleshooting
130
+ - `skills/power/SKILL.md` — init-prime and fast-path workflows
131
+ - `skills/healthcheck/SKILL.md` — diagnostics and repair procedures
132
+ - `skills/fleet/SKILL.md` — snapshot structure and queries
133
+
134
+ Map of all domains: /CLAUDE.md
@@ -0,0 +1,330 @@
1
+ ---
2
+ name: buildsystem
3
+ description: Execute one orchestrated development wave — rank backlog, dispatch Haiku fleet in parallel, merge train, checkpoint, closing audit.
4
+ version: 1.0.0
5
+ ---
6
+
7
+ # Buildsystem — Orchestrated Development Wave
8
+
9
+ This skill automates one complete development wave: backlog prioritization, parallel Haiku agent dispatch, code review, merge train, and state checkpoint. It reads your `CLAUDE.md` rules and project backlog, then orchestrates a fleet of small, focused agents to deliver working features or fixes.
10
+
11
+ **Core principle**: A wave is a bounded unit of work (2–4 hours) that delivers measurable progress. The orchestrator dispatches independent Haiku agents to parallel worktrees, each agent works in isolation, all agents converge on a merge train, and the wave closes with a checkpoint and audit.
12
+
13
+ ---
14
+
15
+ ## Quick Start
16
+
17
+ ### Prerequisites
18
+
19
+ Before running `/buildsystem`, ensure:
20
+
21
+ 1. **Repository is primed** — Run `/power` first to load your CLAUDE.md layer and confirm orchestrator brain health
22
+ 2. **Backlog exists** — Create a ranked backlog in `state/BACKLOG.md` or document your work items in the active `STATE.md`
23
+ 3. **Aesop is initialized** — Config file (`aesop.config.json`), watchdog running, state directory populated
24
+
25
+ ### One Command
26
+
27
+ ```bash
28
+ /buildsystem
29
+ ```
30
+
31
+ The orchestrator reads your backlog, dispatches agents, monitors progress, and delivers a closed wave with merged PRs.
32
+
33
+ ---
34
+
35
+ ## Wave Phases
36
+
37
+ ### Phase 0: Preflight (1–2 min)
38
+
39
+ The orchestrator validates setup:
40
+ - Confirms CLAUDE.md is loaded and rules are understood
41
+ - Checks watchdog heartbeat (healthy daemon)
42
+ - Validates backlog format and work-item sizing
43
+ - Confirms all repos in config are cloned and clean
44
+ - Detects any active uncommitted work or stale agent directories
45
+
46
+ **Output**: Preflight report (green/red status, any blockers)
47
+
48
+ If blockers exist, the wave aborts with remediation steps.
49
+
50
+ ### Phase 1: Backlog Rank & Dispatch (5–10 min)
51
+
52
+ The orchestrator reads the backlog and assigns agents:
53
+ - Rank work by priority (P1/P2/P3) and dependencies
54
+ - Assign each item to an agent type (backend-dev, frontend-dev, test-bot, docs-agent, etc.)
55
+ - Estimate size (Haiku time, ~3–10 min per item)
56
+ - Create work orders for each agent
57
+
58
+ **Output**: Dispatch summary showing which agent works on which item
59
+
60
+ The orchestrator then spawns 3–8 Haiku agents in parallel, each with its own worktree and task brief.
61
+
62
+ ### Phase 2: Fleet Execution (30–90 min)
63
+
64
+ Haiku agents work independently in parallel:
65
+ - Each agent runs in its own worktree (no conflicts)
66
+ - Implements the feature/fix
67
+ - Writes tests and runs local verification
68
+ - Commits to its feature branch (not main)
69
+ - Pushes to origin
70
+
71
+ The orchestrator monitors:
72
+ - Agent heartbeats (alive/stalled detection)
73
+ - Build/test results (compile, unit tests)
74
+ - Token usage and cost
75
+ - Agent runtime (total time, cost per agent)
76
+
77
+ **Output**: Real-time agent status, progress updates
78
+
79
+ ### Phase 3: Code Review & Integration (10–30 min)
80
+
81
+ Pull requests are created automatically as agents push. The orchestrator:
82
+ - Collects all PRs from this wave
83
+ - Routes them through review (linters, unit tests, integration tests)
84
+ - Approves and merges PRs that pass (green CI)
85
+ - Flags PRs with failures for manual triage
86
+
87
+ **Output**: Merge train progress, any PRs awaiting triage
88
+
89
+ ### Phase 4: Checkpoint & Audit (2–5 min)
90
+
91
+ The wave closes:
92
+ - Confirms all work is merged to main
93
+ - Updates `STATE.md` with phase completion, NEXT STEPS
94
+ - Appends summary line to `BUILDLOG.md`
95
+ - Runs closing audit (security scan, coverage, test count, code quality metrics)
96
+ - Commits and pushes checkpoint files
97
+
98
+ **Output**: Wave closed, audit report, ready for next wave
99
+
100
+ ---
101
+
102
+ ## Backlog Format
103
+
104
+ Create a `state/BACKLOG.md` file or update `STATE.md` with your ranked work:
105
+
106
+ ```markdown
107
+ # Wave 15 Backlog
108
+
109
+ ## P1: Critical
110
+
111
+ - [ ] Fix secret-scan gate hang (blocking CI) — backend-dev — 5min
112
+ - [ ] Update MEMORY.md with wave-15 learnings — docs-agent — 3min
113
+
114
+ ## P2: Features
115
+
116
+ - [ ] Add cost-ceiling dashboard widget — frontend-dev — 8min
117
+ - [ ] Implement fleet-ops monitoring — backend-dev — 10min
118
+
119
+ ## P3: Tech Debt
120
+
121
+ - [ ] Refactor monitor/collect-signals.mjs (duplicate checks) — backend-dev — 15min
122
+ - [ ] Add type hints to Python tools — test-bot — 10min
123
+ ```
124
+
125
+ **Sizing guide**:
126
+ - **3–5 min**: Typo fix, simple config change, one-line refactor
127
+ - **5–10 min**: New function, small feature, unit test
128
+ - **10–15 min**: Module refactor, feature with 2–3 functions
129
+ - **15+ min**: Split into smaller items (waves work best in 30–90 min total)
130
+
131
+ **Priorities**:
132
+ - **P1**: Blockers, security fixes, showstoppers
133
+ - **P2**: Features, quality, important bug fixes
134
+ - **P3**: Tech debt, docs, refactoring, minor improvements
135
+
136
+ ---
137
+
138
+ ## Work-Order Contract
139
+
140
+ Each agent receives a work order (brief) describing:
141
+
142
+ ```
143
+ Agent: haiku-backend-dev-5
144
+ Task: Fix secret-scan gate hang (blocking CI)
145
+ Backlog Item: Wave 15 / P1
146
+ Time Budget: 5 min (0 buffer)
147
+ Scope: Identify why secret_scan.py times out on large staged files; implement fast path or raise limit.
148
+ - Reproduce: git add large-file && git push (hangs at secret-scan gate)
149
+ - Change: Modify tools/secret_scan.py line 42 OR config file
150
+ - Test: Verify gate completes within 10s for fixture data
151
+ - Commit message: fix(security): secret-scan gate timeout on large files
152
+ Constraints:
153
+ - Never modify CLAUDE.md or STATE.md
154
+ - Must pass pre-commit hook
155
+ - Use Haiku best-effort only (no external calls, no model training)
156
+ ```
157
+
158
+ The agent reads the work order, implements the change, commits, and pushes the feature branch. The orchestrator then integrates the work.
159
+
160
+ ---
161
+
162
+ ## Orchestrator Isolation & Safety
163
+
164
+ ### Disjoint File Ownership (Preflight Guard)
165
+
166
+ The orchestrator enforces a critical safety invariant: **no two agents should modify the same file in a single wave**.
167
+
168
+ Before dispatch, the preflight verifies:
169
+ - Each backlog item is assigned to exactly one agent
170
+ - No two items touch the same file or directory (checked via domain map)
171
+ - If overlap is detected, the wave aborts with a remediation plan (reorder/resplit items)
172
+
173
+ This guard is the Preflight phase of `skills/buildsystem/wave-flat-dispatch.template.mjs` (ships with aesop): it refuses to dispatch when two manifest items own the same file, returning `{aborted: true, reason: 'ownership_overlap'}` before any worker spawns.
174
+
175
+ ### Worktree Isolation
176
+
177
+ Each agent runs in its own git worktree (`aesop-wt-<wave>-<agent-id>/`):
178
+ - Independent branch, independent HEAD, independent working directory
179
+ - No git conflicts (git worktree is designed for this)
180
+ - Automatic cleanup after wave closes
181
+ - Zero cross-agent interference
182
+
183
+ ### Single-Merge Serialization
184
+
185
+ All PRs from a wave merge through a serial merge train:
186
+ - First agent to reach green CI merges
187
+ - Next agent waits for main to stabilize, re-tests, then merges
188
+ - Prevents race conditions (all PRs are based on stable main at merge time)
189
+
190
+ ---
191
+
192
+ ## Monitoring & Cost
193
+
194
+ The dashboard (`aesop dashboard`) shows real-time wave progress:
195
+ - **Phase**: Current phase (dispatch, execution, review, checkpoint)
196
+ - **Agents**: Running agents, age, tokens used, task
197
+ - **PRs**: Open PRs this wave, pass/fail status, review progress
198
+ - **Cost**: Total tokens, per-agent cost, cost vs budget
199
+ - **ETA**: Estimated wave completion time
200
+
201
+ The orchestrator emits heartbeats every 10s so you can monitor progress without polling.
202
+
203
+ ---
204
+
205
+ ## Failure & Remediation
206
+
207
+ ### Agent Stalls
208
+
209
+ If an agent hasn't updated its heartbeat for 5 min, the orchestrator:
210
+ 1. Checks the agent's transcript (last 50 lines of .claude/transcript.jsonl)
211
+ 2. Determines if the agent is:
212
+ - **Stuck in a loop** (repeating the same error)
213
+ - **Waiting for input** (blocked on a prompt, should never happen)
214
+ - **Genuinely stalled** (no heartbeat for 10+ min)
215
+ 3. Terminates the stalled agent and reports the failure
216
+ 4. Optionally retries the work item (if within retry budget: 2 retries max)
217
+
218
+ ### PR Failures
219
+
220
+ If a PR doesn't pass CI (linter, test failures):
221
+ 1. The orchestrator collects the failure reason from CI logs
222
+ 2. Routes the PR to a human reviewer or re-dispatch a fix agent
223
+ 3. Documents the failure in BUILDLOG.md for the wave audit
224
+ 4. Tracks retries to avoid infinite loops
225
+
226
+ ### Preflight Blockers
227
+
228
+ If preflight detects blockers:
229
+ - Reports the blocker with remediation steps
230
+ - Aborts the wave (safe-fail)
231
+ - Suggests fixes (e.g., "split item X into X.1 and X.2" or "commit pending work first")
232
+
233
+ ---
234
+
235
+ ## Closing Audit
236
+
237
+ At wave end, the orchestrator runs a closing audit:
238
+
239
+ **Security**: Runs secret-scan on all merged code (no secrets shipped)
240
+
241
+ **Coverage**: Compares test coverage before/after wave (target: no decrease)
242
+
243
+ **Quality**: Counts:
244
+ - Total files changed
245
+ - Total LOC changed
246
+ - Total commits
247
+ - Total agent time (sum of all agent runtimes)
248
+ - PR review cycle time (avg time from push to merge)
249
+
250
+ **Output**: Audit report in `state/BUILDLOG.md`, sample:
251
+
252
+ ```
253
+ Wave 15 closed (phase 4/4)
254
+ Agents: 5 (haiku-backend-dev-1, haiku-frontend-dev-1, haiku-test-bot-1, haiku-docs-agent-1, haiku-backend-dev-2)
255
+ Time: 87 min (dispatch 6m, exec 65m, review 12m, checkpoint 4m)
256
+ Backlog: 7 items, 1 skipped (P1: 2/2, P2: 4/4, P3: 1/1)
257
+ PRs: 6 merged, 0 failed, 1 retry
258
+ Coverage: 82% → 84% (+2%)
259
+ Security: clean
260
+ NEXT STEPS: (1) review MEMORY.md updates, (2) stage wave-16 backlog
261
+ ```
262
+
263
+ ---
264
+
265
+ ## Best Practices
266
+
267
+ 1. **Size work for Haiku** — Each item should take 1–2 Haiku tokens (3–10 min). Too large and agents will fail mid-task.
268
+
269
+ 2. **Use domain map** — Ensure your `CLAUDE.md` layer has a clear domain map so the preflight guard can validate assignments.
270
+
271
+ 3. **One wave per session** — Run `/buildsystem` once per session (not repeatedly). Use the closing audit to inform the next wave.
272
+
273
+ 4. **Monitor in real-time** — Open the dashboard (`aesop dashboard`) to watch agents work. This builds confidence and catches stalls early.
274
+
275
+ 5. **Commit backlog to git** — Keep your backlog (`state/BACKLOG.md`) in git so wave history is durable and reviewable.
276
+
277
+ 6. **Review NEXT STEPS** — After wave closes, read `STATE.md` NEXT STEPS and `BUILDLOG.md` audit report to plan the next wave.
278
+
279
+ ---
280
+
281
+ ## Troubleshooting
282
+
283
+ ### Wave hangs on Phase 1 (dispatch)
284
+
285
+ **Cause**: Backlog parsing error or domain-map conflict detected.
286
+
287
+ **Fix**:
288
+ 1. Check `state/BACKLOG.md` format (YAML or markdown, consistent)
289
+ 2. Verify each item has: `- [ ] Title — agent-type — time-estimate`
290
+ 3. Run `aesop doctor` to verify domain map
291
+ 4. Retry: `/buildsystem`
292
+
293
+ ### Wave reports "Preflight blockers"
294
+
295
+ **Cause**: Uncommitted work, repo not clean, or agent directory conflict.
296
+
297
+ **Fix**:
298
+ 1. Commit all pending work: `git add -A && git commit -m "checkpoint: pending work"` (in each repo)
299
+ 2. Confirm watchdog is running: `bash daemons/run-watchdog.sh --once`
300
+ 3. Clean up stale worktrees: `git worktree prune`
301
+ 4. Retry: `/buildsystem`
302
+
303
+ ### Agent stalls mid-task
304
+
305
+ **Cause**: Infinite loop, network issue, or model rate-limit.
306
+
307
+ **Fix**:
308
+ 1. Check agent transcript: `tail -50 <wave-workdir>/transcript.jsonl`
309
+ 2. Understand the loop (repeating error?) and file an issue
310
+ 3. Manually fix the work item or retry in next wave
311
+ 4. Document the failure in BUILDLOG.md
312
+
313
+ ### PR fails CI (linter/test)
314
+
315
+ **Cause**: Agent didn't run tests locally or introduced a bug.
316
+
317
+ **Fix**:
318
+ 1. Review the PR diff and CI logs
319
+ 2. Comment on the PR with remediation
320
+ 3. Assign a fix agent or manually fix
321
+ 4. Retry: `/buildsystem wave-<N>-retry` to re-merge just this PR
322
+
323
+ ---
324
+
325
+ ## See Also
326
+
327
+ - **[/power skill](../power/SKILL.md)** — Prime your orchestrator brain before running a wave
328
+ - **[FIRST-WAVE.md](../docs/FIRST-WAVE.md)** — Tutorial on running your first wave
329
+ - **[CLAUDE.md format](../docs/CONFIGURE.md#claudemd-layer)** — Document your codebase for agents
330
+ - **[Wave architecture](../docs/ARCHITECTURE.md#wave-cycle)** — Deep dive on the orchestration model