aether-colony 5.0.0 → 5.2.1

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 (317) hide show
  1. package/.aether/aether-utils.sh +3226 -3345
  2. package/.aether/agents-claude/aether-ambassador.md +265 -0
  3. package/.aether/agents-claude/aether-archaeologist.md +327 -0
  4. package/.aether/agents-claude/aether-architect.md +236 -0
  5. package/.aether/agents-claude/aether-auditor.md +271 -0
  6. package/.aether/agents-claude/aether-builder.md +224 -0
  7. package/.aether/agents-claude/aether-chaos.md +269 -0
  8. package/.aether/agents-claude/aether-chronicler.md +305 -0
  9. package/.aether/agents-claude/aether-gatekeeper.md +330 -0
  10. package/.aether/agents-claude/aether-includer.md +374 -0
  11. package/.aether/agents-claude/aether-keeper.md +272 -0
  12. package/.aether/agents-claude/aether-measurer.md +322 -0
  13. package/.aether/agents-claude/aether-oracle.md +237 -0
  14. package/.aether/agents-claude/aether-probe.md +211 -0
  15. package/.aether/agents-claude/aether-queen.md +330 -0
  16. package/.aether/agents-claude/aether-route-setter.md +178 -0
  17. package/.aether/agents-claude/aether-sage.md +418 -0
  18. package/.aether/agents-claude/aether-scout.md +179 -0
  19. package/.aether/agents-claude/aether-surveyor-disciplines.md +417 -0
  20. package/.aether/agents-claude/aether-surveyor-nest.md +355 -0
  21. package/.aether/agents-claude/aether-surveyor-pathogens.md +289 -0
  22. package/.aether/agents-claude/aether-surveyor-provisions.md +360 -0
  23. package/.aether/agents-claude/aether-tracker.md +270 -0
  24. package/.aether/agents-claude/aether-watcher.md +280 -0
  25. package/.aether/agents-claude/aether-weaver.md +248 -0
  26. package/.aether/commands/archaeology.yaml +653 -0
  27. package/.aether/commands/build.yaml +1221 -0
  28. package/.aether/commands/chaos.yaml +653 -0
  29. package/.aether/commands/colonize.yaml +442 -0
  30. package/.aether/commands/continue.yaml +1484 -0
  31. package/.aether/commands/council.yaml +509 -0
  32. package/.aether/commands/data-clean.yaml +80 -0
  33. package/.aether/commands/dream.yaml +275 -0
  34. package/.aether/commands/entomb.yaml +863 -0
  35. package/.aether/commands/export-signals.yaml +64 -0
  36. package/.aether/commands/feedback.yaml +158 -0
  37. package/.aether/commands/flag.yaml +160 -0
  38. package/.aether/commands/flags.yaml +177 -0
  39. package/.aether/commands/focus.yaml +112 -0
  40. package/.aether/commands/help.yaml +167 -0
  41. package/.aether/commands/history.yaml +137 -0
  42. package/.aether/commands/import-signals.yaml +79 -0
  43. package/.aether/commands/init.yaml +502 -0
  44. package/.aether/commands/insert-phase.yaml +102 -0
  45. package/.aether/commands/interpret.yaml +285 -0
  46. package/.aether/commands/lay-eggs.yaml +224 -0
  47. package/.aether/commands/maturity.yaml +122 -0
  48. package/.aether/commands/memory-details.yaml +74 -0
  49. package/.aether/commands/migrate-state.yaml +174 -0
  50. package/.aether/commands/oracle.yaml +1224 -0
  51. package/.aether/commands/organize.yaml +446 -0
  52. package/.aether/commands/patrol.yaml +621 -0
  53. package/.aether/commands/pause-colony.yaml +424 -0
  54. package/.aether/commands/phase.yaml +124 -0
  55. package/.aether/commands/pheromones.yaml +153 -0
  56. package/.aether/commands/plan.yaml +1364 -0
  57. package/.aether/commands/preferences.yaml +63 -0
  58. package/.aether/commands/quick.yaml +104 -0
  59. package/.aether/commands/redirect.yaml +123 -0
  60. package/.aether/commands/resume-colony.yaml +375 -0
  61. package/.aether/commands/resume.yaml +407 -0
  62. package/.aether/commands/run.yaml +229 -0
  63. package/.aether/commands/seal.yaml +1214 -0
  64. package/.aether/commands/skill-create.yaml +337 -0
  65. package/.aether/commands/status.yaml +408 -0
  66. package/.aether/commands/swarm.yaml +352 -0
  67. package/.aether/commands/tunnels.yaml +814 -0
  68. package/.aether/commands/update.yaml +131 -0
  69. package/.aether/commands/verify-castes.yaml +159 -0
  70. package/.aether/commands/watch.yaml +454 -0
  71. package/.aether/docs/INCIDENT_TEMPLATE.md +32 -0
  72. package/.aether/docs/QUEEN-SYSTEM.md +11 -11
  73. package/.aether/docs/README.md +32 -2
  74. package/.aether/docs/command-playbooks/README.md +23 -0
  75. package/.aether/docs/command-playbooks/build-complete.md +349 -0
  76. package/.aether/docs/command-playbooks/build-context.md +282 -0
  77. package/.aether/docs/command-playbooks/build-full.md +1683 -0
  78. package/.aether/docs/command-playbooks/build-prep.md +284 -0
  79. package/.aether/docs/command-playbooks/build-verify.md +405 -0
  80. package/.aether/docs/command-playbooks/build-wave.md +749 -0
  81. package/.aether/docs/command-playbooks/continue-advance.md +524 -0
  82. package/.aether/docs/command-playbooks/continue-finalize.md +447 -0
  83. package/.aether/docs/command-playbooks/continue-full.md +1725 -0
  84. package/.aether/docs/command-playbooks/continue-gates.md +686 -0
  85. package/.aether/docs/command-playbooks/continue-verify.md +407 -0
  86. package/.aether/docs/context-continuity.md +84 -0
  87. package/.aether/docs/disciplines/DISCIPLINES.md +9 -7
  88. package/.aether/docs/error-codes.md +1 -1
  89. package/.aether/docs/known-issues.md +34 -173
  90. package/.aether/docs/pheromones.md +86 -6
  91. package/.aether/docs/plans/pheromone-display-plan.md +257 -0
  92. package/.aether/docs/queen-commands.md +10 -9
  93. package/.aether/docs/source-of-truth-map.md +132 -0
  94. package/.aether/docs/xml-utilities.md +47 -0
  95. package/.aether/rules/aether-colony.md +23 -13
  96. package/.aether/scripts/incident-test-add.sh +47 -0
  97. package/.aether/scripts/weekly-audit.sh +79 -0
  98. package/.aether/skills/.index.json +649 -0
  99. package/.aether/skills/colony/.manifest.json +16 -0
  100. package/.aether/skills/colony/build-discipline/SKILL.md +78 -0
  101. package/.aether/skills/colony/colony-interaction/SKILL.md +56 -0
  102. package/.aether/skills/colony/colony-lifecycle/SKILL.md +77 -0
  103. package/.aether/skills/colony/colony-visuals/SKILL.md +112 -0
  104. package/.aether/skills/colony/context-management/SKILL.md +80 -0
  105. package/.aether/skills/colony/error-presentation/SKILL.md +99 -0
  106. package/.aether/skills/colony/pheromone-protocol/SKILL.md +79 -0
  107. package/.aether/skills/colony/pheromone-visibility/SKILL.md +81 -0
  108. package/.aether/skills/colony/state-safety/SKILL.md +84 -0
  109. package/.aether/skills/colony/worker-priming/SKILL.md +82 -0
  110. package/.aether/skills/domain/.manifest.json +24 -0
  111. package/.aether/skills/domain/README.md +33 -0
  112. package/.aether/skills/domain/django/SKILL.md +49 -0
  113. package/.aether/skills/domain/docker/SKILL.md +52 -0
  114. package/.aether/skills/domain/golang/SKILL.md +52 -0
  115. package/.aether/skills/domain/graphql/SKILL.md +51 -0
  116. package/.aether/skills/domain/html-css/SKILL.md +48 -0
  117. package/.aether/skills/domain/nextjs/SKILL.md +45 -0
  118. package/.aether/skills/domain/nodejs/SKILL.md +53 -0
  119. package/.aether/skills/domain/postgresql/SKILL.md +53 -0
  120. package/.aether/skills/domain/prisma/SKILL.md +59 -0
  121. package/.aether/skills/domain/python/SKILL.md +50 -0
  122. package/.aether/skills/domain/rails/SKILL.md +52 -0
  123. package/.aether/skills/domain/react/SKILL.md +45 -0
  124. package/.aether/skills/domain/rest-api/SKILL.md +58 -0
  125. package/.aether/skills/domain/svelte/SKILL.md +47 -0
  126. package/.aether/skills/domain/tailwind/SKILL.md +45 -0
  127. package/.aether/skills/domain/testing/SKILL.md +53 -0
  128. package/.aether/skills/domain/typescript/SKILL.md +58 -0
  129. package/.aether/skills/domain/vue/SKILL.md +49 -0
  130. package/.aether/templates/QUEEN.md.template +23 -41
  131. package/.aether/templates/colony-state-reset.jq.template +1 -0
  132. package/.aether/templates/colony-state.template.json +4 -0
  133. package/.aether/templates/learning-observations.template.json +6 -0
  134. package/.aether/templates/midden.template.json +13 -0
  135. package/.aether/templates/pheromones.template.json +6 -0
  136. package/.aether/templates/session.template.json +9 -0
  137. package/.aether/utils/atomic-write.sh +63 -17
  138. package/.aether/utils/chamber-utils.sh +145 -2
  139. package/.aether/utils/council.sh +425 -0
  140. package/.aether/utils/emoji-audit.sh +166 -0
  141. package/.aether/utils/error-handler.sh +21 -7
  142. package/.aether/utils/file-lock.sh +182 -27
  143. package/.aether/utils/flag.sh +278 -0
  144. package/.aether/utils/hive.sh +572 -0
  145. package/.aether/utils/immune.sh +508 -0
  146. package/.aether/utils/learning.sh +1928 -0
  147. package/.aether/utils/midden.sh +520 -0
  148. package/.aether/utils/oracle/oracle.md +168 -0
  149. package/.aether/utils/oracle/oracle.sh +1023 -0
  150. package/.aether/utils/pheromone.sh +2029 -0
  151. package/.aether/utils/queen.sh +1710 -0
  152. package/.aether/utils/scan.sh +860 -0
  153. package/.aether/utils/semantic-cli.sh +10 -8
  154. package/.aether/utils/session.sh +816 -0
  155. package/.aether/utils/skills.sh +509 -0
  156. package/.aether/utils/spawn-tree.sh +103 -271
  157. package/.aether/utils/spawn.sh +260 -0
  158. package/.aether/utils/state-api.sh +389 -0
  159. package/.aether/utils/state-loader.sh +8 -6
  160. package/.aether/utils/suggest.sh +611 -0
  161. package/.aether/utils/swarm-display.sh +10 -1
  162. package/.aether/utils/swarm.sh +1004 -0
  163. package/.aether/utils/watch-spawn-tree.sh +11 -2
  164. package/.aether/utils/xml-compose.sh +2 -2
  165. package/.aether/utils/xml-convert.sh +9 -5
  166. package/.aether/utils/xml-core.sh +5 -9
  167. package/.aether/utils/xml-query.sh +4 -4
  168. package/.aether/workers.md +86 -67
  169. package/.claude/agents/ant/aether-ambassador.md +2 -1
  170. package/.claude/agents/ant/aether-archaeologist.md +6 -1
  171. package/.claude/agents/ant/aether-architect.md +236 -0
  172. package/.claude/agents/ant/aether-auditor.md +6 -1
  173. package/.claude/agents/ant/aether-builder.md +38 -1
  174. package/.claude/agents/ant/aether-chaos.md +2 -1
  175. package/.claude/agents/ant/aether-chronicler.md +1 -0
  176. package/.claude/agents/ant/aether-gatekeeper.md +6 -1
  177. package/.claude/agents/ant/aether-includer.md +1 -0
  178. package/.claude/agents/ant/aether-keeper.md +1 -0
  179. package/.claude/agents/ant/aether-measurer.md +6 -1
  180. package/.claude/agents/ant/aether-oracle.md +237 -0
  181. package/.claude/agents/ant/aether-probe.md +2 -1
  182. package/.claude/agents/ant/aether-queen.md +6 -1
  183. package/.claude/agents/ant/aether-route-setter.md +6 -1
  184. package/.claude/agents/ant/aether-sage.md +68 -3
  185. package/.claude/agents/ant/aether-scout.md +38 -1
  186. package/.claude/agents/ant/aether-surveyor-disciplines.md +2 -1
  187. package/.claude/agents/ant/aether-surveyor-nest.md +2 -1
  188. package/.claude/agents/ant/aether-surveyor-pathogens.md +2 -1
  189. package/.claude/agents/ant/aether-surveyor-provisions.md +2 -1
  190. package/.claude/agents/ant/aether-tracker.md +6 -1
  191. package/.claude/agents/ant/aether-watcher.md +37 -1
  192. package/.claude/agents/ant/aether-weaver.md +2 -1
  193. package/.claude/commands/ant/archaeology.md +1 -8
  194. package/.claude/commands/ant/build.md +43 -1159
  195. package/.claude/commands/ant/chaos.md +1 -14
  196. package/.claude/commands/ant/colonize.md +3 -14
  197. package/.claude/commands/ant/continue.md +40 -1026
  198. package/.claude/commands/ant/council.md +213 -15
  199. package/.claude/commands/ant/data-clean.md +81 -0
  200. package/.claude/commands/ant/dream.md +12 -9
  201. package/.claude/commands/ant/entomb.md +62 -87
  202. package/.claude/commands/ant/export-signals.md +57 -0
  203. package/.claude/commands/ant/feedback.md +18 -0
  204. package/.claude/commands/ant/flag.md +12 -0
  205. package/.claude/commands/ant/flags.md +22 -8
  206. package/.claude/commands/ant/focus.md +18 -0
  207. package/.claude/commands/ant/help.md +40 -8
  208. package/.claude/commands/ant/history.md +3 -0
  209. package/.claude/commands/ant/import-signals.md +71 -0
  210. package/.claude/commands/ant/init.md +349 -191
  211. package/.claude/commands/ant/insert-phase.md +105 -0
  212. package/.claude/commands/ant/interpret.md +11 -0
  213. package/.claude/commands/ant/lay-eggs.md +167 -158
  214. package/.claude/commands/ant/maturity.md +22 -11
  215. package/.claude/commands/ant/memory-details.md +77 -0
  216. package/.claude/commands/ant/migrate-state.md +6 -0
  217. package/.claude/commands/ant/oracle.md +317 -62
  218. package/.claude/commands/ant/organize.md +10 -5
  219. package/.claude/commands/ant/patrol.md +620 -0
  220. package/.claude/commands/ant/pause-colony.md +8 -22
  221. package/.claude/commands/ant/phase.md +26 -37
  222. package/.claude/commands/ant/pheromones.md +156 -0
  223. package/.claude/commands/ant/plan.md +199 -50
  224. package/.claude/commands/ant/preferences.md +65 -0
  225. package/.claude/commands/ant/quick.md +100 -0
  226. package/.claude/commands/ant/redirect.md +18 -0
  227. package/.claude/commands/ant/resume-colony.md +37 -22
  228. package/.claude/commands/ant/resume.md +60 -7
  229. package/.claude/commands/ant/run.md +231 -0
  230. package/.claude/commands/ant/seal.md +506 -78
  231. package/.claude/commands/ant/skill-create.md +286 -0
  232. package/.claude/commands/ant/status.md +171 -1
  233. package/.claude/commands/ant/swarm.md +11 -23
  234. package/.claude/commands/ant/tunnels.md +1 -0
  235. package/.claude/commands/ant/update.md +58 -135
  236. package/.claude/commands/ant/verify-castes.md +90 -42
  237. package/.claude/commands/ant/watch.md +1 -0
  238. package/.opencode/agents/aether-ambassador.md +1 -1
  239. package/.opencode/agents/aether-architect.md +133 -0
  240. package/.opencode/agents/aether-builder.md +3 -3
  241. package/.opencode/agents/aether-oracle.md +137 -0
  242. package/.opencode/agents/aether-queen.md +1 -1
  243. package/.opencode/agents/aether-route-setter.md +1 -1
  244. package/.opencode/agents/aether-scout.md +1 -1
  245. package/.opencode/agents/aether-surveyor-disciplines.md +6 -1
  246. package/.opencode/agents/aether-surveyor-nest.md +6 -1
  247. package/.opencode/agents/aether-surveyor-pathogens.md +6 -1
  248. package/.opencode/agents/aether-surveyor-provisions.md +6 -1
  249. package/.opencode/agents/aether-tracker.md +1 -1
  250. package/.opencode/agents/aether-watcher.md +1 -1
  251. package/.opencode/agents/aether-weaver.md +1 -1
  252. package/.opencode/commands/ant/archaeology.md +7 -14
  253. package/.opencode/commands/ant/build.md +54 -88
  254. package/.opencode/commands/ant/chaos.md +7 -24
  255. package/.opencode/commands/ant/colonize.md +10 -17
  256. package/.opencode/commands/ant/continue.md +595 -66
  257. package/.opencode/commands/ant/council.md +150 -18
  258. package/.opencode/commands/ant/data-clean.md +77 -0
  259. package/.opencode/commands/ant/dream.md +15 -17
  260. package/.opencode/commands/ant/entomb.md +28 -18
  261. package/.opencode/commands/ant/export-signals.md +54 -0
  262. package/.opencode/commands/ant/feedback.md +24 -5
  263. package/.opencode/commands/ant/flag.md +16 -4
  264. package/.opencode/commands/ant/flags.md +24 -10
  265. package/.opencode/commands/ant/focus.md +22 -5
  266. package/.opencode/commands/ant/help.md +41 -8
  267. package/.opencode/commands/ant/history.md +9 -0
  268. package/.opencode/commands/ant/import-signals.md +68 -0
  269. package/.opencode/commands/ant/init.md +396 -154
  270. package/.opencode/commands/ant/insert-phase.md +111 -0
  271. package/.opencode/commands/ant/interpret.md +16 -0
  272. package/.opencode/commands/ant/lay-eggs.md +184 -112
  273. package/.opencode/commands/ant/maturity.md +18 -2
  274. package/.opencode/commands/ant/memory-details.md +83 -0
  275. package/.opencode/commands/ant/migrate-state.md +12 -0
  276. package/.opencode/commands/ant/oracle.md +322 -67
  277. package/.opencode/commands/ant/organize.md +14 -12
  278. package/.opencode/commands/ant/patrol.md +626 -0
  279. package/.opencode/commands/ant/pause-colony.md +12 -29
  280. package/.opencode/commands/ant/phase.md +30 -40
  281. package/.opencode/commands/ant/pheromones.md +162 -0
  282. package/.opencode/commands/ant/plan.md +210 -57
  283. package/.opencode/commands/ant/preferences.md +71 -0
  284. package/.opencode/commands/ant/quick.md +91 -0
  285. package/.opencode/commands/ant/redirect.md +22 -5
  286. package/.opencode/commands/ant/resume-colony.md +41 -29
  287. package/.opencode/commands/ant/resume.md +80 -20
  288. package/.opencode/commands/ant/run.md +237 -0
  289. package/.opencode/commands/ant/seal.md +230 -25
  290. package/.opencode/commands/ant/skill-create.md +63 -0
  291. package/.opencode/commands/ant/status.md +125 -30
  292. package/.opencode/commands/ant/swarm.md +3 -345
  293. package/.opencode/commands/ant/tunnels.md +3 -9
  294. package/.opencode/commands/ant/update.md +63 -127
  295. package/.opencode/commands/ant/verify-castes.md +96 -42
  296. package/.opencode/commands/ant/watch.md +7 -0
  297. package/CHANGELOG.md +368 -1
  298. package/README.md +195 -324
  299. package/bin/cli.js +236 -429
  300. package/bin/generate-commands.js +186 -0
  301. package/bin/generate-commands.sh +128 -89
  302. package/bin/lib/spawn-logger.js +0 -15
  303. package/bin/lib/update-transaction.js +285 -35
  304. package/bin/npx-install.js +178 -0
  305. package/bin/validate-package.sh +85 -3
  306. package/package.json +16 -4
  307. package/.aether/CONTEXT.md +0 -160
  308. package/.aether/docs/QUEEN.md +0 -84
  309. package/.aether/exchange/colony-registry.xml +0 -11
  310. package/.aether/exchange/pheromones.xml +0 -87
  311. package/.aether/exchange/queen-wisdom.xml +0 -14
  312. package/.aether/model-profiles.yaml +0 -100
  313. package/.aether/utils/spawn-with-model.sh +0 -56
  314. package/bin/lib/model-profiles.js +0 -445
  315. package/bin/lib/model-verify.js +0 -288
  316. package/bin/lib/proxy-health.js +0 -253
  317. package/bin/lib/telemetry.js +0 -441
@@ -0,0 +1,1683 @@
1
+ ---
2
+ name: ant:build
3
+ description: "🔨🐜🏗️🐜🔨 Build a phase with pure emergence - colony self-organizes and completes tasks"
4
+ ---
5
+
6
+ You are the **Queen**. You DIRECTLY spawn multiple workers — do not delegate to a single Prime Worker.
7
+
8
+ ## Pheromone Suggestions
9
+
10
+ At build start, the colony analyzes the codebase for patterns that might benefit
11
+ from pheromone signals (complex files, TODOs, debug artifacts, etc.). Suggested
12
+ signals are presented for approval and written as FOCUS pheromones if approved.
13
+
14
+ Use `--no-suggest` to skip this analysis.
15
+
16
+ The phase to build is: `$ARGUMENTS`
17
+
18
+ ## Instructions
19
+
20
+ ### Context Confirmation Rule (CRITICAL)
21
+
22
+ **Before switching to a different colony directory, you MUST confirm with the user.**
23
+
24
+ When the user mentions a colony name that doesn't match the current directory:
25
+ 1. State clearly: "You're currently in [Current Directory/Colony Name]"
26
+ 2. Ask: "Did you mean to switch to [Other Colony], or continue here?"
27
+ 3. Wait for confirmation — DO NOT proceed until the user clarifies
28
+
29
+ **Example:**
30
+ > User: "THE FUCKING ANIMATION COLONY DO THE NEXT BUILD"
31
+ >
32
+ > Assistant: "You're currently in SonoTherapie (ACF/WPML site). Did you mean:
33
+ > 1. Continue with SonoTherapie (which has animated hero sections)
34
+ > 2. Switch to AnalogWave (NEW SITE)
35
+ >
36
+ > Which would you like?"
37
+
38
+ This prevents accidental context switches when the user is frustrated or uses imprecise language.
39
+
40
+ <failure_modes>
41
+ ### Wave Failure Mid-Build
42
+ If a worker fails during a build wave:
43
+ - Do NOT continue to next wave (failed dependencies will cascade)
44
+ - Report which worker failed, what task it was on, and what was attempted
45
+ - Options: (1) Retry the failed task, (2) Skip and continue with remaining tasks, (3) Abort build
46
+
47
+ ### Partial File Writes
48
+ If a builder crashes mid-write:
49
+ - Check git status for uncommitted partial changes
50
+ - If partial changes exist, offer: (1) Review and keep, (2) Revert with git checkout, (3) Stash for later
51
+
52
+ ### State Corruption
53
+ If COLONY_STATE.json becomes invalid during build:
54
+ - STOP all workers immediately
55
+ - Do not attempt to fix state automatically
56
+ - Report the issue and offer to restore from last known good state
57
+ </failure_modes>
58
+
59
+ <success_criteria>
60
+ Command is complete when:
61
+ - All waves executed in order with no skipped dependencies
62
+ - Each worker's task output is verified (files exist, tests pass)
63
+ - COLONY_STATE.json reflects completed phase progress
64
+ - Build summary reports all workers' outcomes
65
+ </success_criteria>
66
+
67
+ <read_only>
68
+ Do not touch during build:
69
+ - .aether/dreams/ (user notes)
70
+ - .aether/chambers/ (archived colonies)
71
+ - .env* files
72
+ - .claude/settings.json
73
+ - .github/workflows/
74
+ - Other agents' config files (only modify files assigned to the current build task)
75
+ </read_only>
76
+
77
+ ### Step 0.6: Verify LiteLLM Proxy
78
+
79
+ Check that the LiteLLM proxy is running for model routing:
80
+
81
+ Run using the Bash tool with description "Checking model proxy...":
82
+ ```bash
83
+ curl -s http://localhost:4000/health | grep -q "healthy" && echo "Proxy healthy" || echo "Proxy not running - workers will use default model"
84
+ ```
85
+
86
+ If proxy is not healthy, log a warning but continue (workers will fall back to default routing).
87
+
88
+ ### Step 0.5: Load Colony State
89
+
90
+ Run using the Bash tool with description "Loading colony state...": `bash .aether/aether-utils.sh load-state`
91
+
92
+ If the command fails (non-zero exit or JSON has ok: false):
93
+ 1. Parse error JSON
94
+ 2. If error code is E_FILE_NOT_FOUND: "No colony initialized. Run /ant:init first." and stop
95
+ 3. If validation error: Display error details with recovery suggestion and stop
96
+ 4. For other errors: Display generic error and suggest /ant:status for diagnostics
97
+
98
+ If successful:
99
+ 1. Parse the state JSON from result field
100
+ 2. Check if goal is null - if so: "No colony initialized. Run /ant:init first." and stop
101
+ 3. Check if `milestone` == `"Crowned Anthill"` - if so: "This colony has been sealed. Start a new colony with `/ant:init \"new goal\"`." and stop
102
+ 4. Extract current_phase and phase name from plan.phases[current_phase - 1].name
103
+ 4. Display brief resumption context:
104
+ ```
105
+ 🔄 Resuming: Phase X - Name
106
+ ```
107
+ (If HANDOFF.md exists, this provides orientation before the build proceeds)
108
+
109
+ After displaying context, run using the Bash tool with description "Releasing colony lock...": `bash .aether/aether-utils.sh unload-state` to release the lock.
110
+
111
+ ### Step 1: Validate + Read State
112
+
113
+ **Parse $ARGUMENTS:**
114
+ 1. Extract the phase number (first argument)
115
+ 2. Check remaining arguments for flags:
116
+ - If contains `--verbose` or `-v`: set `verbose_mode = true`
117
+ - If contains `--no-visual`: set `visual_mode = false` (visual is ON by default)
118
+ - If contains `--no-suggest`: set `suggest_enabled = false` (suggestions are ON by default)
119
+ - If contains `--depth <level>`: set `cli_depth_override = <level>`
120
+ - Otherwise: set `visual_mode = true`, `suggest_enabled = true` (defaults)
121
+
122
+ If the phase number is empty or not a number:
123
+
124
+ ```
125
+ Usage: /ant:build <phase_number> [--verbose|-v] [--no-visual] [--no-suggest] [--depth <level>]
126
+
127
+ Options:
128
+ --verbose, -v Show full completion details (spawn tree, TDD, patterns)
129
+ --no-visual Disable real-time visual display (visual is on by default)
130
+ --no-suggest Skip pheromone suggestion analysis
131
+ --depth <level> Set colony depth for this build (light|standard|deep|full)
132
+
133
+ Examples:
134
+ /ant:build 1 Build Phase 1 (with visual display)
135
+ /ant:build 1 --verbose Build Phase 1 (full details + visual)
136
+ /ant:build 1 --no-visual Build Phase 1 without visual display
137
+ /ant:build 1 --no-suggest Build Phase 1 without pheromone suggestions
138
+ /ant:build 1 --depth deep Build Phase 1 with thorough investigation
139
+ ```
140
+
141
+ Stop here.
142
+
143
+ **Set colony depth (if --depth flag provided):**
144
+ If `cli_depth_override` is set:
145
+ 1. Run using the Bash tool with description "Setting colony depth...": `bash .aether/aether-utils.sh colony-depth set "$cli_depth_override"`
146
+ 2. Parse JSON result - if `.ok` is false:
147
+ - Display: `Error: Invalid depth "$cli_depth_override". Use: light, standard, deep, full`
148
+ - Stop here
149
+ 3. If valid: Display `Colony depth: {level}`
150
+
151
+ **Read colony depth:**
152
+
153
+ Run using the Bash tool with description "Reading colony depth...":
154
+ ```bash
155
+ depth_result=$(bash .aether/aether-utils.sh colony-depth get 2>/dev/null || echo '{"ok":true,"result":{"depth":"standard","source":"default"}}')
156
+ colony_depth=$(echo "$depth_result" | jq -r '.result.depth // "standard"')
157
+ depth_source=$(echo "$depth_result" | jq -r '.result.source // "default"')
158
+ echo "colony_depth=$colony_depth"
159
+ echo "depth_source=$depth_source"
160
+ ```
161
+
162
+ Store `colony_depth` as cross-stage state for use by build-wave.md and build-verify.md.
163
+
164
+ Display depth with label:
165
+ ```
166
+ Depth: {colony_depth} ({label})
167
+ ```
168
+
169
+ Where label maps:
170
+ - light -> "Builder only -- fastest"
171
+ - standard -> "Builder + Scout -- balanced"
172
+ - deep -> "Builder + Scout + Oracle -- thorough"
173
+ - full -> "All agents -- most thorough"
174
+
175
+ If `colony_depth` is "standard" and `depth_source` is "default" (user never explicitly set it), also display:
176
+ ```
177
+ (Tip: use --depth deep for Oracle research, or --depth light for fast builds)
178
+ ```
179
+
180
+ **Auto-upgrade old state:**
181
+ If `version` field is missing, "1.0", or "2.0":
182
+ 1. Preserve: `goal`, `state`, `current_phase`, `plan.phases`
183
+ 2. Write upgraded v3.0 state (same structure as /ant:init but preserving data)
184
+ 3. Output: `State auto-upgraded to v3.0`
185
+ 4. Continue with command.
186
+
187
+ Extract:
188
+ - `goal`, `state`, `current_phase` from top level
189
+ - `plan.phases` for phase data
190
+ - `errors.records` for error context
191
+ - `memory` for decisions/learnings
192
+
193
+ **Validate:**
194
+ - If `plan.phases` is empty -> output `No project plan. Run /ant:plan first.` and stop.
195
+ - Find the phase matching the requested ID. If not found -> output `Phase {id} not found.` and stop.
196
+ - If the phase status is `"completed"` -> output `Phase {id} already completed.` and stop.
197
+
198
+ ### Step 1.5: Blocker Advisory (Non-blocking)
199
+
200
+ Check for unresolved blocker flags on the requested phase:
201
+
202
+ Run using the Bash tool with description "Checking for blockers...":
203
+ ```bash
204
+ bash .aether/aether-utils.sh flag-check-blockers {phase_number}
205
+ ```
206
+
207
+ Parse the JSON result (`.result.blockers`):
208
+
209
+ - **If blockers == 0:** Display nothing (or optionally a brief `No active blockers for Phase {id}.` line). Proceed to Step 2.
210
+ - **If blockers > 0:** Retrieve blocker details:
211
+ Run using the Bash tool with description "Loading blocker details...":
212
+ ```bash
213
+ bash .aether/aether-utils.sh flag-list --type blocker --phase {phase_number}
214
+ ```
215
+ Parse `.result.flags` and display an advisory warning:
216
+ ```
217
+ ⚠️ BLOCKER ADVISORY: {blockers} unresolved blocker(s) for Phase {id}
218
+ {for each flag in result.flags:}
219
+ - [{flag.id}] {flag.title}
220
+ {end for}
221
+
222
+ Consider reviewing with /ant:flags or auto-fixing with /ant:swarm before building.
223
+ Proceeding anyway...
224
+ ```
225
+ **This is advisory only — do NOT stop.** Continue to Step 2 regardless.
226
+
227
+ ### Step 2: Update State
228
+
229
+ Read then update `.aether/data/COLONY_STATE.json`:
230
+ - Set `state` to `"EXECUTING"`
231
+ - Set `current_phase` to the phase number
232
+ - Set the phase's `status` to `"in_progress"` in `plan.phases[N]`
233
+ - Add `build_started_at` field with current ISO-8601 UTC timestamp
234
+ - Append to `events`: `"<timestamp>|phase_started|build|Phase <id>: <name> started"`
235
+
236
+ If `events` exceeds 100 entries, keep only the last 100.
237
+
238
+ Write COLONY_STATE.json.
239
+
240
+ Validate the state file:
241
+ Run using the Bash tool with description "Validating colony state...":
242
+ ```bash
243
+ bash .aether/aether-utils.sh validate-state colony
244
+ ```
245
+
246
+ ### Step 3: Git Checkpoint
247
+
248
+ Create a git checkpoint for rollback capability.
249
+
250
+ Run using the Bash tool with description "Checking git repository...":
251
+ ```bash
252
+ git rev-parse --git-dir 2>/dev/null
253
+ ```
254
+
255
+ - **If succeeds** (is a git repo):
256
+ 1. Check for changes in Aether-managed directories only: `.aether .claude/commands/ant .claude/commands/st .opencode bin`
257
+ 2. **If changes exist**: Run using the Bash tool with description "Creating git checkpoint...": `git stash push -m "aether-checkpoint: pre-phase-$PHASE_NUMBER" -- .aether .claude/commands/ant .claude/commands/st .opencode bin`
258
+ - IMPORTANT: Never use `--include-untracked` — it stashes ALL files including user work!
259
+ - Run using the Bash tool with description "Verifying checkpoint...": `git stash list | head -1 | grep "aether-checkpoint"` — warn if empty
260
+ - Store checkpoint as `{type: "stash", ref: "aether-checkpoint: pre-phase-$PHASE_NUMBER"}`
261
+ 3. **If clean working tree**: Run using the Bash tool with description "Recording HEAD position...": `git rev-parse HEAD`
262
+ - Store checkpoint as `{type: "commit", ref: "$HEAD_HASH"}`
263
+ - **If fails** (not a git repo): Set checkpoint to `{type: "none", ref: "(not a git repo)"}`.
264
+
265
+ Rollback procedure: `git stash pop` (if type is "stash") or `git reset --hard $ref` (if type is "commit").
266
+
267
+ Output header:
268
+
269
+ ```
270
+ ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
271
+ B U I L D I N G P H A S E {id}
272
+ ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
273
+
274
+ 📍 Phase {id}: {name}
275
+ 💾 Git checkpoint saved
276
+ ```
277
+
278
+ ### Step 4: Load Colony Context (colony-prime)
279
+
280
+ Call `colony-prime --compact` to get unified worker context (wisdom + context capsule + signals + instincts):
281
+
282
+ Run using the Bash tool with description "Loading colony context...":
283
+ ```bash
284
+ prime_result=$(bash .aether/aether-utils.sh colony-prime --compact 2>/dev/null)
285
+ ```
286
+
287
+ **Parse the JSON response:**
288
+ - If `.ok` is false: This is a FAIL HARD error - display the error message and stop the build
289
+ - If successful: Extract from `.result`:
290
+ - `signal_count` - number of active pheromone signals
291
+ - `instinct_count` - number of filtered instincts
292
+ - `prompt_section` - the formatted markdown to inject into worker prompts
293
+ - `log_line` - status message for display
294
+
295
+ Display after constraints:
296
+ ```
297
+ {log_line from colony-prime}
298
+ ```
299
+
300
+ Then display the active pheromones table by running:
301
+ ```bash
302
+ bash .aether/aether-utils.sh pheromone-display
303
+ ```
304
+
305
+ This shows the user exactly what signals are guiding the colony:
306
+ - 🎯 FOCUS signals (what to pay attention to)
307
+ - 🚫 REDIRECT signals (what to avoid - hard constraints)
308
+ - 💬 FEEDBACK signals (guidance to consider)
309
+
310
+ **Store for worker injection:** The `prompt_section` variable contains compact formatted context (QUEEN wisdom + context capsule + pheromone signals) ready for injection.
311
+
312
+ ### Step 4.0: Load Territory Survey
313
+
314
+ Check if territory survey exists and load relevant documents:
315
+
316
+ Run using the Bash tool with description "Loading territory survey...":
317
+ ```bash
318
+ bash .aether/aether-utils.sh survey-load "{phase_name}" 2>/dev/null
319
+ ```
320
+
321
+ **Parse the JSON response:**
322
+ - If `.ok` is false: Set `survey_docs = null` and skip survey loading
323
+ - If successful: Extract `.docs` (comma-separated list) and `.dir`
324
+
325
+ **Determine phase type from phase name:**
326
+ | Phase Contains | Documents to Load |
327
+ |----------------|-------------------|
328
+ | UI, frontend, component, button, page | DISCIPLINES.md, CHAMBERS.md |
329
+ | API, endpoint, backend, route | BLUEPRINT.md, DISCIPLINES.md |
330
+ | database, schema, model, migration | BLUEPRINT.md, PROVISIONS.md |
331
+ | test, spec, coverage | SENTINEL-PROTOCOLS.md, DISCIPLINES.md |
332
+ | integration, external, client | TRAILS.md, PROVISIONS.md |
333
+ | refactor, cleanup, debt | PATHOGENS.md, BLUEPRINT.md |
334
+ | setup, config, initialize | PROVISIONS.md, CHAMBERS.md |
335
+ | *default* | PROVISIONS.md, BLUEPRINT.md |
336
+
337
+ **Read the relevant survey documents** from `.aether/data/survey/`:
338
+ - Extract key patterns to follow
339
+ - Note file locations for new code
340
+ - Identify known concerns to avoid
341
+
342
+ **Display summary:**
343
+ ```
344
+ ━━━ 🗺️🐜 S U R V E Y L O A D E D ━━━
345
+ {for each doc loaded}
346
+ {emoji} {filename} — {brief description}
347
+ {/for}
348
+
349
+ {if no survey}
350
+ (No territory survey — run /ant:colonize for deeper context)
351
+ {/if}
352
+ ```
353
+
354
+ **Store for builder injection:**
355
+ - `survey_patterns` — patterns to follow
356
+ - `survey_locations` — where to place files
357
+ - `survey_concerns` — concerns to avoid
358
+
359
+ ### Step 4.1: Archaeologist Pre-Build Scan
360
+
361
+ **Conditional step — only fires when the phase modifies existing files.**
362
+
363
+ 1. **Detect existing-file modification:**
364
+ Examine each task in the phase. Look at task descriptions, constraints, and hints for signals:
365
+ - Keywords: "update", "modify", "add to", "integrate into", "extend", "change", "refactor", "fix"
366
+ - References to existing file paths (files that already exist in the repo)
367
+ - Task type: if a task is purely "create new file X" with no references to existing code, it is new-file-only
368
+
369
+ **If ALL tasks are new-file-only** (no existing files will be modified):
370
+ - Skip this step silently — produce no output, no spawn
371
+ - Proceed directly to Step 4.2
372
+
373
+ ### Step 4.2: Suggest Pheromones
374
+
375
+ **Conditional step — skipped if `--no-suggest` flag is passed.**
376
+
377
+ Analyze codebase and suggest pheromone signals based on detected patterns.
378
+
379
+ Run using the Bash tool with description "Analyzing codebase for suggestions...":
380
+ ```bash
381
+ bash .aether/aether-utils.sh suggest-approve --dry-run 2>/dev/null
382
+ ```
383
+
384
+ Parse the JSON result to get `suggestion_count`.
385
+
386
+ If `suggestion_count` > 0:
387
+ - Display: "💡 {count} pheromone suggestion(s) detected from code analysis"
388
+ - Run: `bash .aether/aether-utils.sh suggest-approve`
389
+ - Parse result for approved/rejected/skipped counts
390
+ - If approved > 0: Display "✓ {approved} FOCUS signal(s) added"
391
+
392
+ If `suggestion_count` == 0:
393
+ - Skip silently (no output)
394
+
395
+ **Non-blocking**: This step never stops the build. Even if suggest-approve fails,
396
+ log a warning and continue to Step 5.
397
+
398
+ **Error handling**:
399
+ - If suggest-analyze returns error: Log warning, continue
400
+ - If suggest-approve returns error: Log warning, continue
401
+ - Never let suggestion failures block the build
402
+
403
+ 2. **If existing code modification detected — spawn Archaeologist Scout:**
404
+
405
+ Generate archaeologist name and dispatch:
406
+ Run using the Bash tool with description "Naming archaeologist...": `bash .aether/aether-utils.sh generate-ant-name "archaeologist"` (store as `{archaeologist_name}`)
407
+ Run using the Bash tool with description "Dispatching archaeologist...": `bash .aether/aether-utils.sh spawn-log "Queen" "scout" "{archaeologist_name}" "Pre-build archaeology scan"`
408
+
409
+ Display:
410
+ ```
411
+ 🏺🐜 Archaeologist {archaeologist_name} spawning
412
+ Scanning history of files to be modified...
413
+ ```
414
+
415
+ Spawn a Scout (using Task tool with `subagent_type="aether-archaeologist"`, include `description: "🏺 Archaeologist {archaeologist_name}: Pre-build history scan"`) with this prompt:
416
+ # FALLBACK: If "Agent type not found", use general-purpose and inject role: "You are an Archaeologist Ant - git historian that excavates why code exists."
417
+
418
+ ```
419
+ You are {Archaeologist-Name}, a 🏺🐜 Archaeologist Ant.
420
+
421
+ Mission: Pre-build archaeology scan
422
+
423
+ Files: {list of existing files that will be modified}
424
+
425
+ Work:
426
+ 1. Read each file to understand current state
427
+ 2. Run: git log --oneline -15 -- "{file_path}" for history
428
+ 3. Run: git log --all --grep="fix\|bug\|workaround\|hack\|revert" --oneline -- "{file_path}" for incident history
429
+ 4. Run: git blame "{file_path}" | head -40 for authorship
430
+ 5. Note TODO/FIXME/HACK markers
431
+
432
+ Log activity: bash .aether/aether-utils.sh activity-log "READ" "{Ant-Name}" "description"
433
+
434
+ Report (plain text):
435
+ - WHY key code sections exist (from commits)
436
+ - Known workarounds/hacks to preserve
437
+ - Key architectural decisions
438
+ - Areas of caution (high churn, reverts, emergencies)
439
+ - Stable bedrock vs volatile sand sections
440
+ ```
441
+
442
+ **Wait for results** (blocking — use TaskOutput with `block: true`).
443
+
444
+ Log completion and update swarm display:
445
+ Run using the Bash tool with description "Recording archaeologist findings...": `bash .aether/aether-utils.sh spawn-complete "{archaeologist_name}" "completed" "Pre-build archaeology scan"`
446
+
447
+ 3. **Store and display findings:**
448
+
449
+ Store the archaeologist's output as `archaeology_context`.
450
+
451
+ Display summary:
452
+ ```
453
+ ━━━ 🏺🐜 A R C H A E O L O G Y ━━━
454
+ {summary of findings from archaeologist}
455
+ ```
456
+
457
+ 4. **Injection into builder prompts:**
458
+ The `archaeology_context` will be injected into builder prompts in Step 5.1 (see below).
459
+ If this step was skipped (no existing files modified), the archaeology section is omitted from builder prompts.
460
+
461
+ ---
462
+
463
+ ### Step 5: Initialize Swarm Display and Analyze Tasks
464
+
465
+ **YOU (the Queen) will spawn workers directly. Do NOT delegate to a single Prime Worker.**
466
+
467
+ **Log phase start:**
468
+ Run using the Bash tool with description "Logging phase start...":
469
+ ```bash
470
+ bash .aether/aether-utils.sh activity-log "EXECUTING" "Queen" "Phase {id}: {name} - Queen dispatching workers"
471
+ ```
472
+
473
+ **Show real-time display header:**
474
+ ```
475
+ ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
476
+ Phase {id}: {name} — {N} waves, {M} tasks
477
+ ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
478
+ ```
479
+
480
+ Where N = number of builder waves (excluding watcher/chaos) and M = total builder tasks.
481
+
482
+ Record `build_started_at_epoch=$(date +%s)` — this epoch integer is used by the BUILD SUMMARY block in Step 7 to calculate elapsed time.
483
+
484
+ Analyze the phase tasks:
485
+
486
+ Analyze the phase tasks:
487
+
488
+ 1. **Group tasks by dependencies:**
489
+ - **Wave 1:** Tasks with `depends_on: "none"` or `depends_on: []` (can run in parallel)
490
+ - **Wave 2:** Tasks depending on Wave 1 tasks
491
+ - **Wave 3+:** Continue until all tasks assigned
492
+
493
+ 2. **Assign castes:**
494
+ - Implementation tasks → 🔨🐜 Builder
495
+ - Research/docs tasks → 🔍🐜 Scout
496
+ - Testing/validation → 👁️🐜 Watcher (ALWAYS spawn at least one)
497
+ - Resilience testing → 🎲🐜 Chaos (ALWAYS spawn one after Watcher)
498
+
499
+ 3. **Generate ant names for each worker:**
500
+
501
+ Run using the Bash tool with description "Naming builder ant...": `bash .aether/aether-utils.sh generate-ant-name "builder"`
502
+ Run using the Bash tool with description "Naming watcher ant...": `bash .aether/aether-utils.sh generate-ant-name "watcher"`
503
+ Run using the Bash tool with description "Naming chaos ant...": `bash .aether/aether-utils.sh generate-ant-name "chaos"`
504
+
505
+ Display spawn plan with caste emojis:
506
+ ```
507
+ ━━━ 🐜 S P A W N P L A N ━━━
508
+
509
+ Wave 1 — Parallel
510
+ 🔨🐜 {Builder-Name} Task {id} {description}
511
+ 🔨🐜 {Builder-Name} Task {id} {description}
512
+
513
+ Wave 2 — After Wave 1
514
+ 🔨🐜 {Builder-Name} Task {id} {description}
515
+
516
+ Verification
517
+ 👁️🐜 {Watcher-Name} Verify all work independently
518
+ 🎲🐜 {Chaos-Name} Resilience testing (after Watcher)
519
+
520
+ Total: {N} Builders + 1 Watcher + 1 Chaos = {N+2} spawns
521
+ ```
522
+
523
+ **Caste Emoji Legend:**
524
+ - 🔨🐜 Builder (cyan if color enabled)
525
+ - 👁️🐜 Watcher (green if color enabled)
526
+ - 🎲🐜 Chaos (red if color enabled)
527
+ - 🔍🐜 Scout (yellow if color enabled)
528
+ - 🏺🐜 Archaeologist (magenta if color enabled)
529
+ - 🥚 Queen/Prime
530
+
531
+ **Every spawn must show its caste emoji.**
532
+
533
+ **Add to Caste Emoji Legend:**
534
+ - 🔌🐜 Ambassador (blue if color enabled) — external integration specialist
535
+
536
+ ### Step 5.0.5: Select and Announce Workflow Pattern
537
+
538
+ Examine the phase name and task descriptions. Select the first matching pattern:
539
+
540
+ | Phase contains | Pattern |
541
+ |----------------|---------|
542
+ | "bug", "fix", "error", "broken", "failing" | Investigate-Fix |
543
+ | "research", "oracle", "explore", "investigate" | Deep Research |
544
+ | "refactor", "restructure", "clean", "reorganize" | Refactor |
545
+ | "security", "audit", "compliance", "accessibility", "license" | Compliance |
546
+ | "docs", "documentation", "readme", "guide" | Documentation Sprint |
547
+ | (default) | SPBV |
548
+
549
+ Display the selected pattern:
550
+ ```
551
+ ━━ Pattern: {pattern_name} ━━
552
+ {announce_line from Queen's Workflow Patterns definition}
553
+ ```
554
+
555
+ Store `selected_pattern` for inclusion in the BUILD SUMMARY (Step 7).
556
+
557
+ ### Step 5.1: Spawn Wave 1 Workers (Parallel)
558
+
559
+ **CRITICAL: Spawn ALL Wave 1 workers in a SINGLE message using multiple Task tool calls.**
560
+
561
+ **Announce the wave before spawning:**
562
+
563
+ Display the spawn announcement immediately before firing Task calls:
564
+
565
+ For single-caste waves (typical — all builders):
566
+ ```
567
+ ──── 🔨🐜 Spawning {N} Builders in parallel ────
568
+ ```
569
+
570
+ For mixed-caste waves (uncommon):
571
+ ```
572
+ ──── 🐜 Spawning {N} workers ({X} 🔨 Builder, {Y} 🔍 Scout) ────
573
+ ```
574
+
575
+ For a single worker:
576
+ ```
577
+ ──── 🔨🐜 Spawning {ant_name} — {task_summary} ────
578
+ ```
579
+
580
+ ### Step 5.1.1: Ambassador External Integration (Conditional Caste Replacement)
581
+
582
+ **Check if any Wave 1 tasks involve external integration:**
583
+
584
+ For each task in Wave 1, examine the task description and constraints for external integration keywords (case-insensitive):
585
+ - "API", "SDK", "OAuth", "external service", "integration", "webhook", "third-party", "stripe", "sendgrid", "twilio", "openai", "aws", "azure", "gcp"
586
+
587
+ Run using the Bash tool with description "Checking for external integration tasks...":
588
+ ```bash
589
+ # Check phase name and task descriptions for external integration keywords
590
+ phase_name="{phase_name_from_state}"
591
+ task_descriptions="{concatenated task descriptions from Wave 1}"
592
+
593
+ integration_keywords="api sdk oauth external integration webhook third-party stripe sendgrid twilio openai aws azure gcp"
594
+ is_integration_phase="false"
595
+
596
+ for keyword in $integration_keywords; do
597
+ if [[ "${phase_name,,}" == *"$keyword"* ]] || [[ "${task_descriptions,,}" == *"$keyword"* ]]; then
598
+ is_integration_phase="true"
599
+ matched_keyword="$keyword"
600
+ break
601
+ fi
602
+ done
603
+
604
+ echo "{\"is_integration_phase\": \"$is_integration_phase\", \"matched_keyword\": \"$matched_keyword\"}"
605
+ ```
606
+
607
+ Parse the JSON result. If `is_integration_phase` is `"false"`:
608
+ - Skip to standard Builder spawning (continue with existing Step 5.1 logic)
609
+
610
+ If `is_integration_phase` is `"true"`:
611
+
612
+ 1. **Generate Ambassador name and dispatch:**
613
+ Run using the Bash tool with description "Naming ambassador...": `bash .aether/aether-utils.sh generate-ant-name "ambassador"` (store as `{ambassador_name}`)
614
+ Run using the Bash tool with description "Dispatching ambassador...": `bash .aether/aether-utils.sh spawn-log "Queen" "ambassador" "{ambassador_name}" "External integration design"`
615
+
616
+ Display:
617
+ ```
618
+ ━━━ 🔌🐜 A M B A S S A D O R ━━━
619
+ ──── 🔌🐜 Spawning {ambassador_name} — external integration design ────
620
+ 🔌 Ambassador {ambassador_name} spawning — Designing integration for {matched_keyword}...
621
+ ```
622
+
623
+ 2. **Spawn Ambassador using Task tool:**
624
+ Spawn the Ambassador using Task tool with `subagent_type="aether-ambassador"`, include `description: "🔌 Ambassador {Ambassador-Name}: External integration design"` (DO NOT use run_in_background - task blocks until complete):
625
+
626
+ # FALLBACK: If "Agent type not found", use general-purpose and inject role: "You are an Ambassador Ant - integration specialist that designs external API connections."
627
+
628
+ **Ambassador Worker Prompt (CLEAN OUTPUT):**
629
+ ```
630
+ You are {Ambassador-Name}, a 🔌 Ambassador Ant.
631
+
632
+ Mission: Design external integration for Phase {id}
633
+
634
+ Phase: {phase_name}
635
+ Trigger keyword: {matched_keyword}
636
+
637
+ Task context:
638
+ - Task descriptions: {Wave 1 task descriptions}
639
+ - Files to be created/modified: {from task files}
640
+
641
+ Work:
642
+ 1. Research the external service/API requirements
643
+ 2. Design integration pattern (Client Wrapper, Circuit Breaker, Retry with Backoff)
644
+ 3. Plan authentication method (OAuth, API keys, tokens)
645
+ 4. Design rate limiting handling
646
+ 5. Plan error scenarios (timeout, auth failure, rate limit)
647
+ 6. Document required environment variables
648
+ 7. Create integration plan for Builder execution
649
+
650
+ **Integration Patterns to Consider:**
651
+ - Client Wrapper: Abstract API complexity
652
+ - Circuit Breaker: Handle service failures
653
+ - Retry with Backoff: Handle transient errors
654
+ - Caching: Reduce API calls
655
+ - Queue Integration: Async processing
656
+
657
+ **Security Requirements:**
658
+ - API keys must use environment variables
659
+ - No secrets in tracked files
660
+ - HTTPS only
661
+ - Validate SSL certificates
662
+
663
+ Log activity: bash .aether/aether-utils.sh activity-log "RESEARCH" "{Ambassador-Name}" "description"
664
+
665
+ Return ONLY this JSON (no other text):
666
+ {
667
+ "ant_name": "{Ambassador-Name}",
668
+ "caste": "ambassador",
669
+ "status": "completed" | "failed" | "blocked",
670
+ "summary": "Integration design summary",
671
+ "integration_plan": {
672
+ "service_name": "...",
673
+ "authentication_method": "OAuth|API Key|Token",
674
+ "env_vars_required": ["API_KEY", "..."],
675
+ "integration_pattern": "Client Wrapper|Circuit Breaker|...",
676
+ "rate_limit_handling": "...",
677
+ "error_scenarios_covered": ["timeout", "auth_failure", "rate_limit"],
678
+ "files_to_create": ["..."],
679
+ "implementation_steps": ["..."]
680
+ },
681
+ "endpoints_integrated": [],
682
+ "rate_limits_handled": true,
683
+ "documentation_pages": 0,
684
+ "blockers": []
685
+ }
686
+ ```
687
+
688
+ 3. **Parse Ambassador JSON output:**
689
+ Extract from response: `integration_plan`, `env_vars_required`, `error_scenarios_covered`, `blockers`
690
+
691
+ Log completion and update swarm display:
692
+ Run using the Bash tool with description "Recording ambassador completion...": `bash .aether/aether-utils.sh spawn-complete "{ambassador_name}" "completed" "Integration design complete"`
693
+
694
+ **Display Ambassador completion line:**
695
+ ```
696
+ 🔌 {Ambassador-Name}: Integration design ({integration_plan.service_name}) ✓
697
+ ```
698
+
699
+ 4. **Log integration plan to midden:**
700
+ Run using the Bash tool with description "Logging integration plan...":
701
+ ```bash
702
+ bash .aether/aether-utils.sh midden-write "integration" "Plan for {integration_plan.service_name}: {integration_plan.integration_pattern} pattern, auth via {integration_plan.authentication_method}" "ambassador"
703
+ ```
704
+
705
+ For each env var required:
706
+ ```bash
707
+ bash .aether/aether-utils.sh midden-write "integration" "Required env var: {env_var}" "ambassador"
708
+ ```
709
+
710
+ 5. **Display integration summary:**
711
+ ```
712
+ 🔌 Ambassador complete — Integration plan ready for {integration_plan.service_name}
713
+
714
+ Authentication: {integration_plan.authentication_method}
715
+ Pattern: {integration_plan.integration_pattern}
716
+ Env vars: {integration_plan.env_vars_required | join: ", "}
717
+
718
+ Builder will execute this plan in Wave 1.
719
+ ```
720
+
721
+ 6. **Store integration plan for Builder injection:**
722
+ Store the `integration_plan` object to be injected into Builder prompts in the standard Wave 1 spawn.
723
+
724
+ **First, mark build start in context:**
725
+ Run using the Bash tool with description "Marking build start...": `bash .aether/aether-utils.sh context-update build-start {phase_id} {wave_1_worker_count} {wave_1_task_count}`
726
+
727
+ Before dispatching each worker, refresh colony context so new pheromones/memory are visible:
728
+ Run using the Bash tool with description "Refreshing colony context...": `prime_result=$(bash .aether/aether-utils.sh colony-prime --compact 2>/dev/null)` and update `prompt_section` from `prime_result.result.prompt_section`.
729
+
730
+ For each Wave 1 task, use Task tool with `subagent_type="aether-builder"`, include `description: "🔨 Builder {Ant-Name}: {task_description}"` (DO NOT use run_in_background - multiple Task calls in a single message run in parallel and block until complete):
731
+
732
+ **PER WORKER:** Build graveyard caution context automatically:
733
+ - Identify explicit repo file paths from the task metadata (`files`, `hints`, `constraints`, and description when a concrete path is present).
734
+ - For each identified file path, run using the Bash tool with description "Checking graveyard cautions for {file}...":
735
+ `bash .aether/aether-utils.sh grave-check "{file}"`
736
+ - Parse each JSON result and keep only entries where `caution_level` is `high` or `low`.
737
+ - Merge these into a single `grave_context` block for that worker.
738
+ - If no file paths are identified, or all checks return `none`, set `grave_context` to empty.
739
+ - If `grave_context` is non-empty, display a visible line before spawning that worker:
740
+ `⚰️ Graveyard caution for {ant_name}: {file_1} ({level_1}), {file_2} ({level_2})`
741
+
742
+ **PER WORKER:** Run using the Bash tool with description "Preparing worker {name}...": `bash .aether/aether-utils.sh spawn-log "Queen" "builder" "{ant_name}" "{task_description}" && bash .aether/aether-utils.sh context-update worker-spawn "{ant_name}" "builder" "{task_description}"`
743
+
744
+ **Builder Worker Prompt (CLEAN OUTPUT):**
745
+ ```
746
+ You are {Ant-Name}, a 🔨🐜 Builder Ant.
747
+
748
+ Task {id}: {description}
749
+
750
+ Goal: "{colony_goal}"
751
+
752
+ { archaeology_context if exists }
753
+
754
+ { integration_plan if exists }
755
+
756
+ { grave_context if exists }
757
+
758
+ **External Integration Context (if provided by Ambassador):**
759
+ If integration_plan is provided above, you MUST:
760
+ 1. Follow the implementation_steps in order
761
+ 2. Use the specified authentication_method
762
+ 3. Implement the integration_pattern as designed
763
+ 4. Handle all error_scenarios_covered
764
+ 5. Reference required env_vars_required (do NOT hardcode values)
765
+
766
+ { prompt_section }
767
+
768
+ **Graveyard Caution Context (if provided):**
769
+ - Treat `high` caution files as unstable terrain.
770
+ - Preserve proven behavior first, then make minimal safe edits.
771
+ - Add tests around any high-caution file before broader refactors.
772
+
773
+ **IMPORTANT:** When using the Bash tool for activity calls, always include a description parameter:
774
+ - activity-log calls → "Logging {action}..."
775
+ - pheromone-read calls → "Checking colony signals..."
776
+ - spawn-can-spawn calls → "Checking spawn budget..."
777
+ - generate-ant-name calls → "Naming sub-worker..."
778
+ - spawn-log calls → "Dispatching sub-worker..."
779
+
780
+ Use colony-flavored language, 4-8 words, trailing ellipsis.
781
+
782
+ Work:
783
+ 1. Read .aether/workers.md for Builder discipline
784
+ 2. Implement task, write tests
785
+ 3. Log activity using Bash tool with description
786
+ 4. Update display using Bash tool with description
787
+ 5. At natural breakpoints (between tasks, after errors): Check for new signals using Bash tool with description
788
+
789
+ **Approach Change Logging:**
790
+ If you try an approach that doesn't work and switch to a different approach, log it:
791
+ ```bash
792
+ colony_name=$(bash .aether/aether-utils.sh colony-name 2>/dev/null | jq -r '.result.name // ""')
793
+ [[ -z "$colony_name" ]] && colony_name="unknown"
794
+ phase_num=$(jq -r '.phase.number // "unknown"' .aether/data/COLONY_STATE.json 2>/dev/null || echo "unknown")
795
+
796
+ cat >> .aether/midden/approach-changes.md << EOF
797
+ - timestamp: "$(date -u +%Y-%m-%dT%H:%M:%SZ)"
798
+ phase: ${phase_num}
799
+ colony: "${colony_name}"
800
+ worker: "{Ant-Name}"
801
+ task: "{task_id}"
802
+ tried: "initial approach that failed"
803
+ why_it_failed: "reason it didn't work"
804
+ switched_to: "new approach that worked"
805
+ EOF
806
+
807
+ # Write to structured midden for threshold detection (MID-02)
808
+ bash .aether/aether-utils.sh midden-write "abandoned-approach" "Tried: initial approach that failed. Switched to: new approach. Reason: reason it didn't work" "builder" 2>/dev/null || true
809
+
810
+ # Enter memory pipeline for learning observation tracking (MID-02)
811
+ bash .aether/aether-utils.sh memory-capture \
812
+ "failure" \
813
+ "Approach abandoned: initial approach that failed -> new approach (reason it didn't work)" \
814
+ "failure" \
815
+ "worker:builder" 2>/dev/null || true
816
+ ```
817
+
818
+ Spawn sub-workers ONLY if 3x complexity:
819
+ - Check spawn budget using Bash tool with description: `bash .aether/aether-utils.sh spawn-can-spawn {depth} --enforce`
820
+ - Generate name using Bash tool with description
821
+ - Announce: "🐜 Spawning {child_name} for {reason}"
822
+ - Log spawn using Bash tool with description
823
+
824
+ Count your total tool calls (Read + Grep + Edit + Bash + Write) and report as tool_count.
825
+
826
+ Return ONLY this JSON (no other text):
827
+ {"ant_name": "{Ant-Name}", "task_id": "{id}", "status": "completed|failed|blocked", "summary": "What you did", "tool_count": 0, "files_created": [], "files_modified": [], "tests_written": [], "blockers": []}
828
+ ```
829
+
830
+ ### Step 5.2: Process Wave 1 Results
831
+
832
+ **Task calls return results directly (no TaskOutput needed).**
833
+
834
+ Before using any worker payload, validate schema:
835
+ Run using the Bash tool with description "Validating worker response...": `bash .aether/aether-utils.sh validate-worker-response builder '{worker_json}'`
836
+ If validation fails, treat the worker as failed with blocker `invalid_worker_response`.
837
+
838
+ **As each worker result arrives, IMMEDIATELY display a single completion line — do not wait for other workers:**
839
+
840
+ For successful workers:
841
+ ```
842
+ 🔨 {Ant-Name}: {task_description} ({tool_count} tools) ✓
843
+ ```
844
+
845
+ For failed workers:
846
+ ```
847
+ 🔨 {Ant-Name}: {task_description} ✗ ({failure_reason} after {tool_count} tools)
848
+ ```
849
+
850
+ Where `tool_count` comes from the worker's returned JSON `tool_count` field, and `failure_reason` is extracted from the first item in the worker's `blockers` array or "unknown error" if empty.
851
+
852
+ **Log failure to midden and record observation (MEM-02):**
853
+
854
+ After displaying a failed worker, run using the Bash tool with description "Logging failure to midden...":
855
+ ```bash
856
+ colony_name=$(bash .aether/aether-utils.sh colony-name 2>/dev/null | jq -r '.result.name // ""')
857
+ [[ -z "$colony_name" ]] && colony_name="unknown"
858
+ phase_num=$(jq -r '.phase.number // "unknown"' .aether/data/COLONY_STATE.json 2>/dev/null || echo "unknown")
859
+
860
+ # Append to build-failures.md
861
+ cat >> .aether/midden/build-failures.md << EOF
862
+ - timestamp: "$(date -u +%Y-%m-%dT%H:%M:%SZ)"
863
+ phase: ${phase_num}
864
+ colony: "${colony_name}"
865
+ worker: "${ant_name}"
866
+ task: "${task_id}"
867
+ what_failed: "${blockers[0]:-$failure_reason}"
868
+ why: "worker returned failed status"
869
+ what_worked: null
870
+ error_type: "worker_failure"
871
+ EOF
872
+
873
+ # Write to structured midden for threshold detection (MID-01)
874
+ bash .aether/aether-utils.sh midden-write "worker_failure" "Builder ${ant_name} failed on task ${task_id}: ${blockers[0]:-$failure_reason}" "builder" 2>/dev/null || true
875
+
876
+ # Capture failure in memory pipeline (observe + pheromone + auto-promotion)
877
+ bash .aether/aether-utils.sh memory-capture \
878
+ "failure" \
879
+ "Builder ${ant_name} failed on task ${task_id}: ${blockers[0]:-$failure_reason}" \
880
+ "failure" \
881
+ "worker:builder" 2>/dev/null || true
882
+ ```
883
+
884
+ **PER WORKER:** Run using the Bash tool with description "Recording {name} completion...": `bash .aether/aether-utils.sh spawn-complete "{ant_name}" "completed" "{summary}" && bash .aether/aether-utils.sh context-update worker-complete "{ant_name}" "completed"`
885
+
886
+ **Check for total wave failure:**
887
+
888
+ After processing all worker results in this wave, check if EVERY worker returned `status: "failed"`. If ALL workers in the wave failed:
889
+
890
+ Display a prominent halt alert:
891
+ ```
892
+ ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
893
+ ⚠ WAVE FAILURE — BUILD HALTED
894
+ ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
895
+
896
+ All {N} workers in Wave {X} failed. Something is fundamentally wrong.
897
+
898
+ Failed workers:
899
+ {for each failed worker in this wave:}
900
+ {caste_emoji} {Ant-Name}: {task_description} ✗ ({failure_reason} after {tool_count} tools)
901
+ {end for}
902
+
903
+ Next steps:
904
+ /ant:flags Review blockers
905
+ /ant:swarm Auto-repair mode
906
+ ```
907
+
908
+ Then STOP — do not proceed to subsequent waves, Watcher, or Chaos. Skip directly to Step 5.9 synthesis with `status: "failed"`.
909
+
910
+ **Partial wave failure — escalation path:**
911
+
912
+ If SOME (but not all) workers in the wave failed:
913
+ 1. For each failed worker, attempt Tier 3 escalation: Queen spawns a different caste for the same task
914
+ 2. If Tier 3 succeeds: continue to next wave
915
+ 3. If Tier 3 fails: display the Tier 4 ESCALATION banner (from Queen agent definition):
916
+
917
+ ```
918
+ ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
919
+ ⚠ ESCALATION — QUEEN NEEDS YOU
920
+ ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
921
+
922
+ Task: {failed task description}
923
+ Phase: {phase number} — {phase name}
924
+
925
+ Tried:
926
+ • Worker retry (2 attempts) — {what failed}
927
+ • Parent tried alternate approach — {what failed}
928
+ • Queen reassigned to {other caste} — {what failed}
929
+
930
+ Options:
931
+ A) {recommended option} — RECOMMENDED
932
+ B) {alternate option}
933
+ C) Skip and continue — this task will be marked blocked
934
+
935
+ Awaiting your choice.
936
+ ```
937
+
938
+ Log escalation as flag:
939
+ Run using the Bash tool with description "Logging escalation...": `bash .aether/aether-utils.sh flag-add "blocker" "{task title}" "{failure summary}" "escalation" {phase_number}`
940
+
941
+ If at least one worker succeeded, continue normally to the next wave.
942
+
943
+ **Parse each worker's validated JSON output to collect:** status, files_created, files_modified, blockers
944
+
945
+ **Intra-phase midden threshold check (MID-03):**
946
+
947
+ After processing all wave results, check if any midden error category has reached 3+ occurrences. If so, emit a REDIRECT pheromone mid-build to alert the colony.
948
+
949
+ Run using the Bash tool with description "Checking midden thresholds...":
950
+ ```bash
951
+ midden_result=$(bash .aether/aether-utils.sh midden-recent-failures 50 2>/dev/null || echo '{"count":0,"failures":[]}')
952
+ midden_count=$(echo "$midden_result" | jq '.count // 0')
953
+
954
+ if [[ "$midden_count" -gt 0 ]]; then
955
+ recurring_categories=$(echo "$midden_result" | jq -r '
956
+ [.failures[] | .category]
957
+ | group_by(.)
958
+ | map(select(length >= 3))
959
+ | map({category: .[0], count: length})
960
+ | .[]
961
+ | @base64
962
+ ' 2>/dev/null || echo "")
963
+
964
+ redirect_emit_count=0
965
+ for encoded in $recurring_categories; do
966
+ [[ $redirect_emit_count -ge 3 ]] && break
967
+ [[ -z "$encoded" ]] && continue
968
+ category=$(echo "$encoded" | base64 -d | jq -r '.category')
969
+ count=$(echo "$encoded" | base64 -d | jq -r '.count')
970
+
971
+ existing=$(jq -r --arg cat "$category" '
972
+ [.signals[] | select(.active == true and .source == "auto:error" and (.content.text | contains($cat)))] | length
973
+ ' .aether/data/pheromones.json 2>/dev/null || echo "0")
974
+
975
+ if [[ "$existing" == "0" ]]; then
976
+ bash .aether/aether-utils.sh pheromone-write REDIRECT \
977
+ "[error-pattern] Category \"$category\" recurring ($count occurrences)" \
978
+ --strength 0.7 \
979
+ --source "auto:error" \
980
+ --reason "Auto-emitted: midden error pattern recurred 3+ times mid-build" \
981
+ --ttl "30d" 2>/dev/null || true
982
+ redirect_emit_count=$((redirect_emit_count + 1))
983
+ fi
984
+ done
985
+
986
+ if [[ $redirect_emit_count -gt 0 ]]; then
987
+ echo "Warning: Midden threshold triggered -- $redirect_emit_count REDIRECT pheromone(s) emitted mid-build"
988
+ fi
989
+ fi
990
+ ```
991
+
992
+ Display if any REDIRECT was emitted:
993
+ ```
994
+ Warning: Midden threshold: "{category}" recurring ({count}x) -- REDIRECT emitted mid-build
995
+ ```
996
+
997
+ Chat users see the structured completion lines above.
998
+
999
+ ### Step 5.3: Spawn Wave 2+ Workers (Sequential Waves)
1000
+
1001
+ **Before each subsequent wave, display a wave separator:**
1002
+ ```
1003
+ ━━━ 🐜 Wave {X} of {N} ━━━
1004
+ ```
1005
+ Then display the spawn announcement (same format as Step 5.1).
1006
+
1007
+ Repeat Step 5.1-5.2 for each subsequent wave, waiting for previous wave to complete.
1008
+
1009
+ ### Step 5.4: Spawn Watcher for Verification
1010
+
1011
+ **MANDATORY: Always spawn a Watcher — testing must be independent.**
1012
+
1013
+ **Announce the verification wave:**
1014
+ ```
1015
+ ━━━ 👁️🐜 V E R I F I C A T I O N ━━━
1016
+ ──── 👁️🐜 Spawning {watcher_name} ────
1017
+ ```
1018
+
1019
+ Spawn the Watcher using Task tool with `subagent_type="aether-watcher"`, include `description: "👁️ Watcher {Watcher-Name}: Independent verification"` (DO NOT use run_in_background - task blocks until complete):
1020
+
1021
+ Run using the Bash tool with description "Dispatching watcher...": `bash .aether/aether-utils.sh spawn-log "Queen" "watcher" "{watcher_name}" "Independent verification"`
1022
+
1023
+ **Watcher Worker Prompt (CLEAN OUTPUT):**
1024
+ ```
1025
+ You are {Watcher-Name}, a 👁️🐜 Watcher Ant.
1026
+
1027
+ Verify all work done by Builders in Phase {id}.
1028
+
1029
+ Files to verify:
1030
+ - Created: {list from builder results}
1031
+ - Modified: {list from builder results}
1032
+
1033
+ { prompt_section }
1034
+
1035
+ **IMPORTANT:** When using the Bash tool for activity calls, always include a description parameter:
1036
+ - activity-log calls → "Logging {action}..."
1037
+ - pheromone-read calls → "Checking colony signals..."
1038
+ - spawn-log calls → "Dispatching sub-worker..."
1039
+
1040
+ Use colony-flavored language, 4-8 words, trailing ellipsis.
1041
+
1042
+ Verification:
1043
+ 1. Check files exist (Read each)
1044
+ 2. Run build/type-check
1045
+ 3. Run tests if they exist
1046
+ 4. Check success criteria: {list}
1047
+
1048
+ Spawn sub-workers if needed:
1049
+ - Log spawn using Bash tool with description
1050
+ - Announce: "🐜 Spawning {child} to investigate {issue}"
1051
+
1052
+ Count your total tool calls (Read + Grep + Edit + Bash + Write) and report as tool_count.
1053
+
1054
+ Return ONLY this JSON:
1055
+ {"ant_name": "{Watcher-Name}", "verification_passed": true|false, "files_verified": [], "issues_found": [], "quality_score": N, "tool_count": 0, "recommendation": "proceed|fix_required"}
1056
+ ```
1057
+
1058
+ ### Step 5.5: Process Watcher Results
1059
+
1060
+ **Task call returns results directly (no TaskOutput needed).**
1061
+
1062
+ Validate watcher payload first:
1063
+ Run using the Bash tool with description "Validating watcher response...": `bash .aether/aether-utils.sh validate-worker-response watcher '{watcher_json}'`
1064
+
1065
+ **Parse the Watcher's validated JSON response:** verification_passed, issues_found, quality_score, recommendation
1066
+
1067
+ **Display Watcher completion line:**
1068
+
1069
+ For successful verification:
1070
+ ```
1071
+ 👁️ {Watcher-Name}: Independent verification ({tool_count} tools) ✓
1072
+ ```
1073
+
1074
+ For failed verification:
1075
+ ```
1076
+ 👁️ {Watcher-Name}: Independent verification ✗ ({issues_found count} issues after {tool_count} tools)
1077
+ ```
1078
+
1079
+ **Store results for synthesis in Step 5.7**
1080
+
1081
+ ### Step 5.5.1: Measurer Performance Agent (Conditional)
1082
+
1083
+ **Conditional step — only runs for performance-sensitive phases.**
1084
+
1085
+ 1. **Check if phase is performance-sensitive:**
1086
+
1087
+ Extract phase name from COLONY_STATE.json (already loaded in Step 1). Check for performance keywords (case-insensitive):
1088
+ - "performance", "optimize", "latency", "throughput", "benchmark", "speed", "memory", "cpu", "efficiency"
1089
+
1090
+ Run using the Bash tool with description "Checking phase for performance sensitivity...":
1091
+ ```bash
1092
+ phase_name="{phase_name_from_state}"
1093
+ performance_keywords="performance optimize latency throughput benchmark speed memory cpu efficiency"
1094
+ is_performance_sensitive="false"
1095
+ for keyword in $performance_keywords; do
1096
+ if [[ "${phase_name,,}" == *"$keyword"* ]]; then
1097
+ is_performance_sensitive="true"
1098
+ break
1099
+ fi
1100
+ done
1101
+ echo "{\"is_performance_sensitive\": \"$is_performance_sensitive\", \"phase_name\": \"$phase_name\"}"
1102
+ ```
1103
+
1104
+ Parse the JSON result. If `is_performance_sensitive` is `"false"`:
1105
+ - Display: `📊 Measurer: Phase not performance-sensitive — skipping baseline measurement`
1106
+ - Skip to Step 5.6 (Chaos Ant)
1107
+
1108
+ 2. **Check Watcher verification status:**
1109
+
1110
+ Only spawn Measurer if Watcher verification passed (`verification_passed: true`). If Watcher failed:
1111
+ - Display: `📊 Measurer: Watcher verification failed — skipping performance measurement`
1112
+ - Skip to Step 5.6 (Chaos Ant)
1113
+
1114
+ 3. **Generate Measurer name and dispatch:**
1115
+
1116
+ Run using the Bash tool with description "Naming measurer...": `bash .aether/aether-utils.sh generate-ant-name "measurer"` (store as `{measurer_name}`)
1117
+ Run using the Bash tool with description "Dispatching measurer...": `bash .aether/aether-utils.sh spawn-log "Queen" "measurer" "{measurer_name}" "Performance baseline measurement"`
1118
+
1119
+ Display:
1120
+ ```
1121
+ ━━━ 📊🐜 M E A S U R E R ━━━
1122
+ ──── 📊🐜 Spawning {measurer_name} — establishing performance baselines ────
1123
+ 📊 Measurer {measurer_name} spawning — Establishing performance baselines for {phase_name}...
1124
+ ```
1125
+
1126
+ 4. **Get files to measure:**
1127
+
1128
+ Use `files_created` and `files_modified` from builder results (already collected in synthesis preparation). Filter for source files only:
1129
+ - Include: `.js`, `.ts`, `.sh`, `.py` files
1130
+ - Exclude: `.test.js`, `.test.ts`, `.spec.js`, `.spec.ts`, `__tests__/`, config files
1131
+
1132
+ Store filtered list as `{source_files_to_measure}`.
1133
+
1134
+ 5. **Spawn Measurer using Task tool:**
1135
+
1136
+ Spawn the Measurer using Task tool with `subagent_type="aether-measurer"`, include `description: "📊 Measurer {Measurer-Name}: Performance baseline measurement"` (DO NOT use run_in_background - task blocks until complete):
1137
+
1138
+ # FALLBACK: If "Agent type not found", use general-purpose and inject role: "You are a Measurer Ant - performance profiler that benchmarks and identifies bottlenecks."
1139
+
1140
+ **Measurer Worker Prompt (CLEAN OUTPUT):**
1141
+ ```
1142
+ You are {Measurer-Name}, a 📊 Measurer Ant.
1143
+
1144
+ Mission: Performance baseline measurement for Phase {id}
1145
+
1146
+ Phase: {phase_name}
1147
+ Keywords that triggered spawn: {matched_keywords}
1148
+
1149
+ Files to measure:
1150
+ - {list from source_files_to_measure}
1151
+
1152
+ Work:
1153
+ 1. Read each source file to understand operation patterns
1154
+ 2. Analyze algorithmic complexity (Big O) for key functions
1155
+ 3. Identify potential bottlenecks (loops, recursion, I/O)
1156
+ 4. Document current baseline metrics for comparison
1157
+ 5. Recommend optimizations with estimated impact
1158
+
1159
+ **IMPORTANT:** You are strictly read-only. Do not modify any files.
1160
+
1161
+ Log activity: bash .aether/aether-utils.sh activity-log "BENCHMARKING" "{Measurer-Name}" "description"
1162
+
1163
+ Return ONLY this JSON (no other text):
1164
+ {
1165
+ "ant_name": "{Measurer-Name}",
1166
+ "caste": "measurer",
1167
+ "status": "completed" | "failed" | "blocked",
1168
+ "summary": "What you measured and found",
1169
+ "metrics": {
1170
+ "response_time_ms": 0,
1171
+ "throughput_rps": 0,
1172
+ "cpu_percent": 0,
1173
+ "memory_mb": 0
1174
+ },
1175
+ "baselines_established": [
1176
+ {"operation": "name", "complexity": "O(n)", "file": "path", "line": 0}
1177
+ ],
1178
+ "bottlenecks_identified": [
1179
+ {"description": "...", "severity": "high|medium|low", "location": "file:line"}
1180
+ ],
1181
+ "recommendations": [
1182
+ {"priority": 1, "change": "...", "estimated_improvement": "..."}
1183
+ ],
1184
+ "tool_count": 0
1185
+ }
1186
+ ```
1187
+
1188
+ 6. **Parse Measurer JSON output:**
1189
+
1190
+ Extract from response: `baselines_established`, `bottlenecks_identified`, `recommendations`, `tool_count`
1191
+
1192
+ Log completion and update swarm display:
1193
+ Run using the Bash tool with description "Recording measurer completion...": `bash .aether/aether-utils.sh spawn-complete "{measurer_name}" "completed" "Baselines established, bottlenecks identified"`
1194
+
1195
+ **Display Measurer completion line:**
1196
+ ```
1197
+ 📊 {Measurer-Name}: Performance baseline measurement ({tool_count} tools) ✓
1198
+ ```
1199
+
1200
+ 7. **Log findings to midden:**
1201
+
1202
+ For each baseline established, run using the Bash tool with description "Logging baseline...":
1203
+ ```bash
1204
+ bash .aether/aether-utils.sh midden-write "performance" "Baseline: {baseline.operation} ({baseline.complexity}) at {baseline.file}:{baseline.line}" "measurer"
1205
+ ```
1206
+
1207
+ For each bottleneck identified, run using the Bash tool with description "Logging bottleneck...":
1208
+ ```bash
1209
+ bash .aether/aether-utils.sh midden-write "performance" "Bottleneck: {bottleneck.description} ({bottleneck.severity}) at {bottleneck.location}" "measurer"
1210
+ ```
1211
+
1212
+ For each recommendation, run using the Bash tool with description "Logging recommendation...":
1213
+ ```bash
1214
+ bash .aether/aether-utils.sh midden-write "performance" "Recommendation (P{rec.priority}): {rec.change} - {rec.estimated_improvement}" "measurer"
1215
+ ```
1216
+
1217
+ 8. **Display summary and store for synthesis:**
1218
+
1219
+ Display:
1220
+ ```
1221
+ 📊 Measurer complete — {baseline_count} baselines, {bottleneck_count} bottlenecks logged to midden
1222
+ ```
1223
+
1224
+ Store Measurer results in synthesis data structure:
1225
+ - Add `performance` object to synthesis JSON with: `baselines_established`, `bottlenecks_identified`, `recommendations`
1226
+ - Include in BUILD SUMMARY display: `📊 Measurer: {baseline_count} baselines established, {bottleneck_count} bottlenecks identified`
1227
+
1228
+ 9. **Continue to Chaos Ant:**
1229
+
1230
+ Proceed to Step 5.6 (Chaos Ant) regardless of Measurer results — Measurer is strictly non-blocking.
1231
+
1232
+ ### Step 5.6: Spawn Chaos Ant for Resilience Testing
1233
+
1234
+ **After the Watcher completes, spawn a Chaos Ant to probe the phase work for edge cases and boundary conditions.**
1235
+
1236
+ Generate a chaos ant name and dispatch:
1237
+ Run using the Bash tool with description "Naming chaos ant...": `bash .aether/aether-utils.sh generate-ant-name "chaos"` (store as `{chaos_name}`)
1238
+ Run using the Bash tool with description "Loading existing flags...": `bash .aether/aether-utils.sh flag-list --phase {phase_number}`
1239
+ Parse the result and extract unresolved flag titles into a list: `{existing_flag_titles}` (comma-separated titles from `.result.flags[].title`). If no flags exist, set `{existing_flag_titles}` to "None".
1240
+ Run using the Bash tool with description "Dispatching chaos ant...": `bash .aether/aether-utils.sh spawn-log "Queen" "chaos" "{chaos_name}" "Resilience testing of Phase {id} work"`
1241
+
1242
+ **Announce the resilience testing wave:**
1243
+ ```
1244
+ ──── 🎲🐜 Spawning {chaos_name} — resilience testing ────
1245
+ ```
1246
+
1247
+ Spawn the Chaos Ant using Task tool with `subagent_type="aether-chaos"`, include `description: "🎲 Chaos {Chaos-Name}: Resilience testing"` (DO NOT use run_in_background - task blocks until complete):
1248
+ # FALLBACK: If "Agent type not found", use general-purpose and inject role: "You are a Chaos Ant - resilience tester that probes edge cases and boundary conditions."
1249
+
1250
+ **Chaos Ant Prompt (CLEAN OUTPUT):**
1251
+ ```
1252
+ You are {Chaos-Name}, a 🎲🐜 Chaos Ant.
1253
+
1254
+ Test Phase {id} work for edge cases and boundary conditions.
1255
+
1256
+ Files to test:
1257
+ - {list from builder results}
1258
+
1259
+ Skip these known issues: {existing_flag_titles}
1260
+
1261
+ **IMPORTANT:** When using the Bash tool for activity calls, always include a description parameter:
1262
+ - activity-log calls → "Logging {action}..."
1263
+ - pheromone-read calls → "Checking colony signals..."
1264
+
1265
+ Use colony-flavored language, 4-8 words, trailing ellipsis.
1266
+
1267
+ Rules:
1268
+ - Max 5 scenarios
1269
+ - Read-only (don't modify code)
1270
+ - Focus: edge cases, boundaries, error handling
1271
+
1272
+ Count your total tool calls (Read + Grep + Edit + Bash + Write) and report as tool_count.
1273
+
1274
+ Return ONLY this JSON:
1275
+ {"ant_name": "{Chaos-Name}", "scenarios_tested": 5, "findings": [{"id": 1, "category": "edge_case|boundary|error_handling", "severity": "critical|high|medium|low", "title": "...", "description": "..."}], "overall_resilience": "strong|moderate|weak", "tool_count": 0, "summary": "..."}
1276
+ ```
1277
+
1278
+ ### Step 5.7: Process Chaos Ant Results
1279
+
1280
+ **Task call returns results directly (no TaskOutput needed).**
1281
+
1282
+ **Parse the Chaos Ant's JSON response:** findings, overall_resilience, summary
1283
+
1284
+ **Display Chaos completion line:**
1285
+ ```
1286
+ 🎲 {Chaos-Name}: Resilience testing ({tool_count} tools) ✓
1287
+ ```
1288
+
1289
+ **Store results for synthesis in Step 5.9**
1290
+
1291
+ **Flag critical/high findings:**
1292
+
1293
+ If any findings have severity `"critical"` or `"high"`:
1294
+ Run using the Bash tool with description "Flagging {finding.title}...": `bash .aether/aether-utils.sh flag-add "blocker" "{finding.title}" "{finding.description}" "chaos-testing" {phase_number} && bash .aether/aether-utils.sh activity-log "FLAG" "Chaos" "Created blocker: {finding.title}"`
1295
+
1296
+ **Log resilience finding to midden (MEM-02):**
1297
+
1298
+ For each critical/high finding, run using the Bash tool with description "Logging resilience finding...":
1299
+ ```bash
1300
+ colony_name=$(bash .aether/aether-utils.sh colony-name 2>/dev/null | jq -r '.result.name // ""')
1301
+ [[ -z "$colony_name" ]] && colony_name="unknown"
1302
+ phase_num=$(jq -r '.phase.number // "unknown"' .aether/data/COLONY_STATE.json 2>/dev/null || echo "unknown")
1303
+
1304
+ # Append to build-failures.md
1305
+ cat >> .aether/midden/build-failures.md << EOF
1306
+ - timestamp: "$(date -u +%Y-%m-%dT%H:%M:%SZ)"
1307
+ phase: ${phase_num}
1308
+ colony: "${colony_name}"
1309
+ worker: "${chaos_name}"
1310
+ test_context: "resilience"
1311
+ what_failed: "${finding.title}"
1312
+ why: "${finding.description}"
1313
+ what_worked: null
1314
+ severity: "${finding.severity}"
1315
+ EOF
1316
+
1317
+ # Write to structured midden for threshold detection (MID-01)
1318
+ bash .aether/aether-utils.sh midden-write "resilience" "Chaos finding: ${finding.title} (${finding.severity})" "chaos" 2>/dev/null || true
1319
+
1320
+ # Capture resilience failure in memory pipeline (observe + pheromone + auto-promotion)
1321
+ bash .aether/aether-utils.sh memory-capture \
1322
+ "failure" \
1323
+ "Resilience issue found: ${finding.title} (${finding.severity})" \
1324
+ "failure" \
1325
+ "worker:chaos" 2>/dev/null || true
1326
+ ```
1327
+
1328
+ Log chaos ant completion and update swarm display:
1329
+ Run using the Bash tool with description "Recording chaos completion...": `bash .aether/aether-utils.sh spawn-complete "{chaos_name}" "completed" "{summary}"`
1330
+
1331
+ ### Step 5.8: Create Flags for Verification Failures
1332
+
1333
+ If the Watcher reported `verification_passed: false` or `recommendation: "fix_required"`:
1334
+
1335
+ For each issue in `issues_found`:
1336
+ Run using the Bash tool with description "Flagging {issue_title}...": `bash .aether/aether-utils.sh flag-add "blocker" "{issue_title}" "{issue_description}" "verification" {phase_number} && bash .aether/aether-utils.sh activity-log "FLAG" "Watcher" "Created blocker: {issue_title}"`
1337
+
1338
+ **Log verification failure to midden (MEM-02):**
1339
+
1340
+ After flagging each issue, run using the Bash tool with description "Logging verification failure...":
1341
+ ```bash
1342
+ colony_name=$(bash .aether/aether-utils.sh colony-name 2>/dev/null | jq -r '.result.name // ""')
1343
+ [[ -z "$colony_name" ]] && colony_name="unknown"
1344
+ phase_num=$(jq -r '.phase.number // "unknown"' .aether/data/COLONY_STATE.json 2>/dev/null || echo "unknown")
1345
+
1346
+ # Append to test-failures.md
1347
+ cat >> .aether/midden/test-failures.md << EOF
1348
+ - timestamp: "$(date -u +%Y-%m-%dT%H:%M:%SZ)"
1349
+ phase: ${phase_num}
1350
+ colony: "${colony_name}"
1351
+ worker: "${watcher_name}"
1352
+ test_context: "verification"
1353
+ what_failed: "${issue_title}"
1354
+ why: "${issue_description}"
1355
+ what_worked: null
1356
+ severity: "high"
1357
+ EOF
1358
+
1359
+ # Write to structured midden for threshold detection (MID-01)
1360
+ bash .aether/aether-utils.sh midden-write "verification" "Watcher verification failed: ${issue_title}" "watcher" 2>/dev/null || true
1361
+
1362
+ # Capture verification failure in memory pipeline (observe + pheromone + auto-promotion)
1363
+ bash .aether/aether-utils.sh memory-capture \
1364
+ "failure" \
1365
+ "Verification failed: ${issue_title} - ${issue_description}" \
1366
+ "failure" \
1367
+ "worker:watcher" 2>/dev/null || true
1368
+ ```
1369
+
1370
+ This ensures verification failures are persisted as blockers that survive context resets. Chaos Ant findings are flagged in Step 5.7.
1371
+
1372
+ ### Step 5.9: Synthesize Results
1373
+
1374
+ **This step runs after all worker tasks have completed (Builders, Watcher, Chaos).**
1375
+
1376
+ Collect all worker outputs and create phase summary:
1377
+
1378
+ ```json
1379
+ {
1380
+ "status": "completed" | "failed" | "blocked",
1381
+ "summary": "...",
1382
+ "tasks_completed": [...],
1383
+ "tasks_failed": [...],
1384
+ "files_created": [...],
1385
+ "files_modified": [...],
1386
+ "spawn_metrics": {
1387
+ "spawn_count": {total workers spawned, including archaeologist if Step 4.5 fired, measurer if Step 5.5.1 fired, ambassador if Step 5.1.1 fired},
1388
+ "builder_count": {N},
1389
+ "watcher_count": 1,
1390
+ "chaos_count": 1,
1391
+ "archaeologist_count": {0 or 1, conditional on Step 4.5},
1392
+ "measurer_count": {0 or 1, conditional on Step 5.5.1},
1393
+ "ambassador_count": {0 or 1, conditional on Step 5.1.1},
1394
+ "parallel_batches": {number of waves}
1395
+ },
1396
+ "spawn_tree": {
1397
+ "{Archaeologist-Name}": {"caste": "archaeologist", "task": "pre-build history scan", "status": "completed"},
1398
+ "{Ambassador-Name}": {"caste": "ambassador", "task": "external integration design", "status": "completed"},
1399
+ "{Builder-Name}": {"caste": "builder", "task": "...", "status": "completed"},
1400
+ "{Watcher-Name}": {"caste": "watcher", "task": "verify", "status": "completed"},
1401
+ "{Measurer-Name}": {"caste": "measurer", "task": "performance baseline", "status": "completed"},
1402
+ "{Chaos-Name}": {"caste": "chaos", "task": "resilience testing", "status": "completed"}
1403
+ },
1404
+ "verification": {from Watcher output},
1405
+ "performance": {from Measurer output, or null if Step 5.5.1 was skipped},
1406
+ "resilience": {from Chaos Ant output},
1407
+ "archaeology": {from Archaeologist output, or null if Step 4.5 was skipped},
1408
+ "quality_notes": "..."
1409
+ }
1410
+ ```
1411
+
1412
+ **Graveyard Recording:**
1413
+ For each worker that returned `status: "failed"`:
1414
+ For each file in that worker's `files_modified` or `files_created`:
1415
+ Run using the Bash tool with description "Recording failure grave...": `bash .aether/aether-utils.sh grave-add "{file}" "{ant_name}" "{task_id}" {phase} "{first blocker or summary}" && bash .aether/aether-utils.sh activity-log "GRAVE" "Queen" "Grave marker placed at {file} — {ant_name} failed: {summary}"`
1416
+ Then display a user-visible confirmation line:
1417
+ `⚰️ Grave recorded: {file} — {ant_name} failed ({summary})`
1418
+
1419
+ **Error Handoff Update:**
1420
+ If workers failed, update handoff with error context for recovery:
1421
+
1422
+ Resolve the build error handoff template path:
1423
+ Check ~/.aether/system/templates/handoff-build-error.template.md first,
1424
+ then .aether/templates/handoff-build-error.template.md.
1425
+
1426
+ If no template found: output "Template missing: handoff-build-error.template.md. Run aether update to fix." and stop.
1427
+
1428
+ Read the template file. Fill all {{PLACEHOLDER}} values:
1429
+ - {{PHASE_NUMBER}} → current phase number
1430
+ - {{PHASE_NAME}} → current phase name
1431
+ - {{BUILD_TIMESTAMP}} → current ISO-8601 UTC timestamp
1432
+ - {{FAILED_WORKERS}} → formatted list of failed workers (one "- {ant_name}: {failure_summary}" per line)
1433
+ - {{GRAVE_MARKERS}} → formatted list of grave markers (one "- {file}: {caution_level} caution" per line)
1434
+
1435
+ Remove the HTML comment lines at the top of the template.
1436
+ Write the result to .aether/HANDOFF.md using the Write tool.
1437
+
1438
+ Only fires when workers fail. Zero impact on successful builds.
1439
+
1440
+ --- SPAWN TRACKING ---
1441
+
1442
+ The spawn tree will be visible in `/ant:watch` because each spawn is logged.
1443
+
1444
+ --- OUTPUT FORMAT ---
1445
+
1446
+ Return JSON:
1447
+ {
1448
+ "status": "completed" | "failed" | "blocked",
1449
+ "summary": "What the phase accomplished",
1450
+ "tasks_completed": ["1.1", "1.2"],
1451
+ "tasks_failed": [],
1452
+ "files_created": ["path1", "path2"],
1453
+ "files_modified": ["path3"],
1454
+ "spawn_metrics": {
1455
+ "spawn_count": 7,
1456
+ "watcher_count": 1,
1457
+ "chaos_count": 1,
1458
+ "archaeologist_count": 1,
1459
+ "measurer_count": 1,
1460
+ "ambassador_count": 1,
1461
+ "builder_count": 3,
1462
+ "parallel_batches": 2,
1463
+ "sequential_tasks": 1
1464
+ },
1465
+ "spawn_tree": {
1466
+ "Relic-8": {"caste": "archaeologist", "task": "pre-build history scan", "status": "completed", "children": {}},
1467
+ "Diplomat-7": {"caste": "ambassador", "task": "external integration design", "status": "completed", "children": {}},
1468
+ "Hammer-42": {"caste": "builder", "task": "...", "status": "completed", "children": {}},
1469
+ "Vigil-17": {"caste": "watcher", "task": "...", "status": "completed", "children": {}},
1470
+ "Benchmark-3": {"caste": "measurer", "task": "performance baseline", "status": "completed", "children": {}},
1471
+ "Entropy-9": {"caste": "chaos", "task": "resilience testing", "status": "completed", "children": {}}
1472
+ },
1473
+ "verification": {
1474
+ "build": {"command": "npm run build", "exit_code": 0, "passed": true},
1475
+ "tests": {"command": "npm test", "passed": 24, "failed": 0, "total": 24},
1476
+ "success_criteria": [
1477
+ {"criterion": "API endpoint exists", "evidence": "GET /api/users returns 200", "passed": true},
1478
+ {"criterion": "Tests cover happy path", "evidence": "3 tests in users.test.ts", "passed": true}
1479
+ ]
1480
+ },
1481
+ "debugging": {
1482
+ "issues_encountered": 0,
1483
+ "issues_resolved": 0,
1484
+ "fix_attempts": 0,
1485
+ "architectural_concerns": []
1486
+ },
1487
+ "tdd": {
1488
+ "cycles_completed": 5,
1489
+ "tests_added": 5,
1490
+ "tests_total": 47,
1491
+ "coverage_percent": 85,
1492
+ "all_passing": true
1493
+ },
1494
+ "learning": {
1495
+ "patterns_observed": [
1496
+ {
1497
+ "type": "success",
1498
+ "trigger": "when implementing API endpoints",
1499
+ "action": "use repository pattern with DI",
1500
+ "evidence": "All tests passed first try"
1501
+ }
1502
+ ],
1503
+ "instincts_applied": ["instinct_123"],
1504
+ "instinct_outcomes": [
1505
+ {"id": "instinct_123", "success": true}
1506
+ ]
1507
+ },
1508
+ "quality_notes": "Any concerns or recommendations",
1509
+ "ui_touched": true | false
1510
+ }
1511
+ ```
1512
+
1513
+ ### Step 6: Visual Checkpoint (if UI touched)
1514
+
1515
+ Parse synthesis result. If `ui_touched` is true:
1516
+
1517
+ ```
1518
+ ━━━ 🖼️🐜 V I S U A L C H E C K P O I N T ━━━
1519
+
1520
+ UI changes detected. Verify appearance before continuing.
1521
+
1522
+ Files touched:
1523
+ {list files from files_created + files_modified that match UI patterns}
1524
+
1525
+ Options:
1526
+ 1. Approve - UI looks correct
1527
+ 2. Reject - needs changes (describe issues)
1528
+ 3. Skip - defer visual review
1529
+ ```
1530
+
1531
+ Use AskUserQuestion to get approval. Record in events:
1532
+ - If approved: `"<timestamp>|visual_approved|build|Phase {id} UI approved"`
1533
+ - If rejected: `"<timestamp>|visual_rejected|build|Phase {id} UI rejected: {reason}"`
1534
+
1535
+ ### Step 6.5: Update Handoff Document
1536
+
1537
+ After synthesis is complete, update the handoff document with current state for session recovery:
1538
+
1539
+ ```bash
1540
+ # Update handoff with build results
1541
+ jq -n \
1542
+ --arg timestamp "$(date -u +%Y-%m-%dT%H:%M:%SZ)" \
1543
+ --arg goal "$(jq -r '.goal' .aether/data/COLONY_STATE.json)" \
1544
+ --arg phase "$(jq -r '.current_phase' .aether/data/COLONY_STATE.json)" \
1545
+ --arg phase_name "{phase_name}" \
1546
+ --arg status "{synthesis.status}" \
1547
+ --arg summary "{synthesis.summary}" \
1548
+ --argjson tasks_completed '{synthesis.tasks_completed | length}' \
1549
+ --argjson tasks_failed '{synthesis.tasks_failed | length}' \
1550
+ --arg next_action "{if synthesis.status == "completed" then "/ant:continue" else "/ant:flags" end}" \
1551
+ '{
1552
+ "last_updated": $timestamp,
1553
+ "goal": $goal,
1554
+ "current_phase": $phase,
1555
+ "phase_name": $phase_name,
1556
+ "build_status": $status,
1557
+ "summary": $summary,
1558
+ "tasks_completed": $tasks_completed,
1559
+ "tasks_failed": $tasks_failed,
1560
+ "next_recommended_action": $next_action,
1561
+ "can_resume": true,
1562
+ "note": "Phase build completed. Run /ant:continue to advance if verification passed."
1563
+ }' > .aether/data/last-build-result.json
1564
+ ```
1565
+
1566
+ Resolve the build success handoff template path:
1567
+ Check ~/.aether/system/templates/handoff-build-success.template.md first,
1568
+ then .aether/templates/handoff-build-success.template.md.
1569
+
1570
+ If no template found: output "Template missing: handoff-build-success.template.md. Run aether update to fix." and stop.
1571
+
1572
+ Read the template file. Fill all {{PLACEHOLDER}} values:
1573
+ - {{GOAL}} → colony goal (from COLONY_STATE.json)
1574
+ - {{PHASE_NUMBER}} → current phase number
1575
+ - {{PHASE_NAME}} → current phase name
1576
+ - {{BUILD_STATUS}} → synthesis.status
1577
+ - {{BUILD_TIMESTAMP}} → current ISO-8601 UTC timestamp
1578
+ - {{BUILD_SUMMARY}} → synthesis summary
1579
+ - {{TASKS_COMPLETED}} → count of completed tasks
1580
+ - {{TASKS_FAILED}} → count of failed tasks
1581
+ - {{FILES_CREATED}} → count of created files
1582
+ - {{FILES_MODIFIED}} → count of modified files
1583
+ - {{SESSION_NOTE}} → "Build succeeded — ready to advance." if status is completed, else "Build completed with issues — review before continuing."
1584
+
1585
+ Remove the HTML comment lines at the top of the template.
1586
+ Write the result to .aether/HANDOFF.md using the Write tool.
1587
+
1588
+ This ensures the handoff always reflects the latest build state, even if the session crashes before explicit pause.
1589
+
1590
+ ### Step 6.5: Update Context Document
1591
+
1592
+ Log this build activity to `.aether/CONTEXT.md`:
1593
+
1594
+ Run using the Bash tool with description "Updating build context...": `bash .aether/aether-utils.sh context-update activity "build {phase_id}" "{synthesis.status}" "{files_created_count + files_modified_count}" && bash .aether/aether-utils.sh context-update build-complete "{synthesis.status}" "{synthesis.status == 'completed' ? 'success' : 'failed'}"`
1595
+
1596
+ Also update safe-to-clear status:
1597
+ - If build completed successfully: `context-update safe-to-clear "YES" "Build complete, ready to continue"`
1598
+ - If build failed: `context-update safe-to-clear "NO" "Build failed — run /ant:swarm or /ant:flags"`
1599
+
1600
+ ### Step 5.10: Check for Promotion Proposals
1601
+
1602
+ After build completion (success or failure), check if any observations have met promotion thresholds.
1603
+
1604
+ Run using the Bash tool with description "Checking for wisdom promotions...":
1605
+ ```bash
1606
+ proposals=$(bash .aether/aether-utils.sh learning-check-promotion 2>/dev/null || echo '{"proposals":[]}')
1607
+ proposal_count=$(echo "$proposals" | jq '.proposals | length')
1608
+ echo "{\"proposal_count\": $proposal_count}"
1609
+ ```
1610
+
1611
+ Parse the result. If proposal_count > 0:
1612
+ - Display: "📚 $proposal_count wisdom proposal(s) ready for review"
1613
+ - Run: `bash .aether/aether-utils.sh learning-approve-proposals`
1614
+ - This presents the one-at-a-time UI for user review
1615
+
1616
+ If proposal_count == 0:
1617
+ - Silently continue (no output needed per user decision)
1618
+
1619
+ Note: This runs regardless of build success/failure. Failed builds may have recorded failure observations that are ready for promotion.
1620
+
1621
+ ### Step 7: Display Results
1622
+
1623
+ **This step runs ONLY after synthesis is complete. All values come from actual worker results.**
1624
+
1625
+ **Display BUILD SUMMARY (always shown, replaces compact/verbose split):**
1626
+
1627
+ Calculate `total_tools` by summing `tool_count` from all worker return JSONs (builders + watcher + chaos).
1628
+ Calculate `elapsed` using `build_started_at_epoch` (epoch integer captured at Step 5 start by Plan 01): `$(( $(date +%s) - build_started_at_epoch ))` formatted as Xm Ys.
1629
+
1630
+ ```
1631
+ ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
1632
+ B U I L D S U M M A R Y
1633
+ ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
1634
+ Phase {id}: {name}
1635
+ Pattern: {selected_pattern}
1636
+
1637
+ Workers: {pass_count} passed {fail_count} failed ({total} total)
1638
+ Tools: {total_tools} calls across all workers
1639
+ Duration: {elapsed}
1640
+
1641
+ {if measurer_ran:}
1642
+ 📊 Measurer: {baseline_count} baselines established, {bottleneck_count} bottlenecks identified
1643
+ {end if}
1644
+
1645
+ {if ambassador_ran:}
1646
+ 🔌 Ambassador: Integration plan for {integration_plan.service_name} ready
1647
+ {end if}
1648
+
1649
+ {if fail_count > 0:}
1650
+ Failed:
1651
+ {for each failed worker:}
1652
+ {caste_emoji} {Ant-Name}: {task_description} ✗ ({failure_reason} after {tool_count} tools)
1653
+ {end for}
1654
+
1655
+ Retry: /ant:swarm to auto-repair failed tasks, or /ant:flags to review blockers
1656
+ {end if}
1657
+ ```
1658
+
1659
+ **If verbose_mode is true**, additionally show the spawn tree and TDD details after the BUILD SUMMARY block (keep the existing verbose-only sections: Colony Work Tree, Tasks Completed, TDD, Patterns Learned, Debugging, Model Routing). Prepend with:
1660
+ ```
1661
+ ━━ Details (--verbose) ━━
1662
+ ```
1663
+
1664
+ After displaying the BUILD SUMMARY (and optional verbose details), call the Next Up helper by running using the Bash tool with description "Displaying next steps...":
1665
+ ```bash
1666
+ state=$(jq -r '.state // "IDLE"' .aether/data/COLONY_STATE.json 2>/dev/null || echo "IDLE")
1667
+ current_phase=$(jq -r '.current_phase // 0' .aether/data/COLONY_STATE.json 2>/dev/null || echo "0")
1668
+ total_phases=$(jq -r '.plan.phases | length' .aether/data/COLONY_STATE.json 2>/dev/null || echo "0")
1669
+ bash .aether/aether-utils.sh print-next-up "$state" "$current_phase" "$total_phases"
1670
+ ```
1671
+
1672
+ **Routing Note:** The state-based Next Up block above routes based on colony state. If verification failed or blockers exist, review `/ant:flags` before continuing.
1673
+
1674
+ **IMPORTANT:** Build does NOT update task statuses or advance state. Run `/ant:continue` to:
1675
+ - Mark tasks as completed
1676
+ - Extract learnings
1677
+ - Advance to next phase
1678
+
1679
+ ### Step 8: Update Session
1680
+
1681
+ Update the session tracking file to enable `/ant:resume` after context clear:
1682
+
1683
+ Run using the Bash tool with description "Saving build session...": `bash .aether/aether-utils.sh session-update "/ant:build {phase_id}" "/ant:continue" "Phase {phase_id} build completed: {synthesis.status}"`