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,749 @@
1
+ ### Step 4.5: Checkpoint State
2
+
3
+ Before modifying colony state during the build, create a rolling backup:
4
+
5
+ Run using the Bash tool with description "Checkpointing colony state...":
6
+ ```bash
7
+ bash .aether/aether-utils.sh state-checkpoint "pre-build-wave" 2>/dev/null || echo "Warning: State checkpoint failed -- continuing without backup" >&2
8
+ ```
9
+
10
+ This creates a timestamped backup of COLONY_STATE.json in `.aether/data/backups/` with at most 3 retained.
11
+
12
+ ### Step 5: Analyze Tasks
13
+
14
+ **YOU (the Queen) will spawn workers directly. Do NOT delegate to a single Prime Worker.**
15
+
16
+ **Show build header:**
17
+ ```
18
+ ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
19
+ Phase {id}: {name} — {N} waves, {M} tasks
20
+ ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
21
+ ```
22
+
23
+ Where N = number of builder waves (excluding watcher/chaos) and M = total builder tasks.
24
+
25
+ Record `build_started_at_epoch=$(date +%s)` — this epoch integer is used by the BUILD SUMMARY block in Step 7 to calculate elapsed time.
26
+
27
+ Analyze the phase tasks:
28
+
29
+ 1. **Group tasks by dependencies:**
30
+ - **Wave 1:** Tasks with `depends_on: "none"` or `depends_on: []` (can run in parallel)
31
+ - **Wave 2:** Tasks depending on Wave 1 tasks
32
+ - **Wave 3+:** Continue until all tasks assigned
33
+
34
+ 2. **Assign castes:**
35
+ - Implementation tasks → 🔨🐜 Builder
36
+ - Research/docs tasks → 🔍🐜 Scout (**only if `colony_depth` is "standard", "deep", or "full"**; at "light" depth, reassign to Builder or skip)
37
+ - Testing/validation → 👁️🐜 Watcher (ALWAYS spawn at least one)
38
+ - Resilience testing → 🎲🐜 Chaos (ALWAYS spawn one after Watcher)
39
+
40
+ 3. **Generate ant names for each worker:**
41
+
42
+ Run using the Bash tool with description "Naming builder ant...": `bash .aether/aether-utils.sh generate-ant-name "builder"`
43
+ Run using the Bash tool with description "Naming watcher ant...": `bash .aether/aether-utils.sh generate-ant-name "watcher"`
44
+ Run using the Bash tool with description "Naming chaos ant...": `bash .aether/aether-utils.sh generate-ant-name "chaos"`
45
+
46
+ Display spawn plan with caste emojis:
47
+ ```
48
+ ━━━ 🐜 S P A W N P L A N ━━━
49
+
50
+ Wave 1 — Parallel
51
+ 🔨🐜 {Builder-Name} Task {id} {description}
52
+ 🔨🐜 {Builder-Name} Task {id} {description}
53
+
54
+ Wave 2 — After Wave 1
55
+ 🔨🐜 {Builder-Name} Task {id} {description}
56
+
57
+ Verification
58
+ 👁️🐜 {Watcher-Name} Verify all work independently
59
+ {if colony_depth == "full": 🎲🐜 {Chaos-Name} Resilience testing (after Watcher)}
60
+
61
+ Total: {N} Builders + 1 Watcher{if colony_depth == "full": " + 1 Chaos"}{if colony_depth in ["deep","full"]: " + 1 Oracle + 1 Architect"} = {total} spawns
62
+ ```
63
+
64
+ **Caste Emoji Legend:**
65
+ - 🔨🐜 Builder (cyan if color enabled)
66
+ - 👁️🐜 Watcher (green if color enabled)
67
+ - 🎲🐜 Chaos (red if color enabled)
68
+ - 🔍🐜 Scout (yellow if color enabled)
69
+ - 🏺🐜 Archaeologist (magenta if color enabled)
70
+ - 🔮🐜 Oracle (indigo if color enabled) — deep research specialist
71
+ - 🏛️🐜 Architect (violet if color enabled) — architecture design specialist
72
+ - 🥚 Queen/Prime
73
+
74
+ **Every spawn must show its caste emoji.**
75
+
76
+ **Add to Caste Emoji Legend:**
77
+ - 🔌🐜 Ambassador (blue if color enabled) — external integration specialist
78
+
79
+ ### Step 5.0.1: Oracle Research Step (Non-Blocking)
80
+
81
+ **DEPTH CHECK: Skip if colony depth is "light" or "standard".**
82
+
83
+ The `colony_depth` value is available from build-prep.md cross-stage state.
84
+ - If `colony_depth` is "light" or "standard": Display `Oracle skipped (depth: {colony_depth})` and skip to Step 5.0.5.
85
+ - If `colony_depth` is "deep" or "full": Proceed with existing Oracle spawn logic below.
86
+
87
+ **Oracle runs BEFORE worker waves. Failure is non-blocking -- the build continues with a warning.**
88
+
89
+ 1. **Generate Oracle name:**
90
+ Run using the Bash tool with description "Naming oracle ant...": `bash .aether/aether-utils.sh generate-ant-name "oracle"` (store as `{oracle_name}`)
91
+
92
+ 2. **Log spawn:**
93
+ Run using the Bash tool with description "Dispatching oracle...": `bash .aether/aether-utils.sh spawn-log "Queen" "oracle" "{oracle_name}" "Phase {phase_id} research"`
94
+
95
+ 3. **Display announcement:**
96
+ ```
97
+ ━━━ 🔮 O R A C L E R E S E A R C H ━━━
98
+ ──── 🔮🐜 Spawning {oracle_name} — Phase {phase_id} research ────
99
+ ```
100
+
101
+ 4. **Spawn Oracle using Task tool with `subagent_type="aether-oracle"`**, include `description: "🔮 Oracle {oracle_name}: Phase {phase_id} research"` (DO NOT use run_in_background):
102
+
103
+ > **Platform note**: In Claude Code, use `Task tool with subagent_type`. In OpenCode, use the equivalent agent spawning mechanism for your platform.
104
+
105
+ **Oracle Worker Prompt:**
106
+ ```
107
+ You are {oracle_name}, a 🔮 Oracle Ant.
108
+
109
+ Mission: Conduct deep research for Phase {phase_id}
110
+
111
+ Phase: {phase_name}
112
+ Colony goal: "{colony_goal}"
113
+
114
+ Active pheromone signals (if any):
115
+ {pheromone_summary from prompt_section}
116
+
117
+ Tasks to research:
118
+ {list of phase tasks with descriptions}
119
+
120
+ Work:
121
+ 1. Analyze the codebase for patterns relevant to these tasks
122
+ 2. Research best practices, gotchas, and recommended approaches
123
+ 3. Identify potential risks or dependencies
124
+ 4. Write findings to `.aether/data/research/oracle-{phase_id}.md`
125
+
126
+ **IMPORTANT:** This is a single-pass research invocation (not iterative RALF loop). Produce your best findings in one pass.
127
+
128
+ Return ONLY this JSON (no other text):
129
+ {
130
+ "ant_name": "{oracle_name}",
131
+ "caste": "oracle",
132
+ "status": "completed" | "failed" | "blocked",
133
+ "summary": "Key findings and recommendations",
134
+ "findings": ["finding1", "finding2"],
135
+ "recommendations": ["rec1", "rec2"],
136
+ "risks": ["risk1"],
137
+ "research_file": ".aether/data/research/oracle-{phase_id}.md",
138
+ "blockers": []
139
+ }
140
+ ```
141
+
142
+ 5. **Parse Oracle JSON output:**
143
+ - If status is `"completed"`, store `oracle_findings` for injection into Architect and Builder prompts.
144
+ - If status is `"failed"` or `"blocked"`, log warning and set `oracle_findings` to empty:
145
+
146
+ ```
147
+ ⚠ Oracle {oracle_name} research unavailable — proceeding without research context
148
+ ```
149
+
150
+ 6. **Log completion:**
151
+ Run using the Bash tool with description "Recording oracle completion...": `bash .aether/aether-utils.sh spawn-complete "{oracle_name}" "{status}" "{summary}"`
152
+
153
+ ### Step 5.0.2: Architect Design Step (Non-Blocking)
154
+
155
+ **DEPTH CHECK: Skip if colony depth is "light" or "standard".**
156
+
157
+ Architect depends on Oracle findings. If Oracle was skipped, Architect must also be skipped.
158
+ - If `colony_depth` is "light" or "standard": Display `Architect skipped (depth: {colony_depth})` and skip to Step 5.0.5.
159
+ - If `colony_depth` is "deep" or "full": Proceed with existing Architect spawn logic below.
160
+
161
+ **Architect runs AFTER Oracle, BEFORE worker waves. Failure is non-blocking -- the build continues with a warning.**
162
+
163
+ 1. **Generate Architect name:**
164
+ Run using the Bash tool with description "Naming architect ant...": `bash .aether/aether-utils.sh generate-ant-name "architect"` (store as `{architect_name}`)
165
+
166
+ 2. **Log spawn:**
167
+ Run using the Bash tool with description "Dispatching architect...": `bash .aether/aether-utils.sh spawn-log "Queen" "architect" "{architect_name}" "Phase {phase_id} design"`
168
+
169
+ 3. **Display announcement:**
170
+ ```
171
+ ━━━ 🏛️ A R C H I T E C T D E S I G N ━━━
172
+ ──── 🏛️🐜 Spawning {architect_name} — Phase {phase_id} design ────
173
+ ```
174
+
175
+ 4. **Spawn Architect using Task tool with `subagent_type="aether-architect"`**, include `description: "🏛️ Architect {architect_name}: Phase {phase_id} design"` (DO NOT use run_in_background):
176
+
177
+ > **Platform note**: In Claude Code, use `Task tool with subagent_type`. In OpenCode, use the equivalent agent spawning mechanism for your platform.
178
+
179
+ **Architect Worker Prompt:**
180
+ ```
181
+ You are {architect_name}, a 🏛️ Architect Ant.
182
+
183
+ Mission: Design architecture for Phase {phase_id}
184
+
185
+ Phase: {phase_name}
186
+ Colony goal: "{colony_goal}"
187
+
188
+ {oracle_findings if available, otherwise: "No Oracle research available for this phase."}
189
+
190
+ Active pheromone signals (if any):
191
+ {pheromone_summary from prompt_section}
192
+
193
+ Tasks to design for:
194
+ {list of phase tasks with descriptions}
195
+
196
+ Work:
197
+ 1. Analyze codebase structure and existing patterns
198
+ 2. Identify architectural boundaries and component relationships
199
+ 3. Design approach (component structure, data flow, interfaces)
200
+ 4. Write design document to `.aether/data/research/architect-{phase_id}.md`
201
+ 5. Return actionable design decisions for Builder consumption
202
+
203
+ Return ONLY this JSON (no other text):
204
+ {
205
+ "ant_name": "{architect_name}",
206
+ "caste": "architect",
207
+ "status": "completed" | "failed" | "blocked",
208
+ "summary": "Design approach and key decisions",
209
+ "design_decisions": ["decision1", "decision2"],
210
+ "component_structure": {"overview": "..."},
211
+ "data_flow": {"overview": "..."},
212
+ "design_file": ".aether/data/research/architect-{phase_id}.md",
213
+ "blockers": []
214
+ }
215
+ ```
216
+
217
+ 5. **Parse Architect JSON output:**
218
+ - If status is `"completed"`, store `architect_design` for injection into Builder prompts.
219
+ - If status is `"failed"` or `"blocked"`, log warning and set `architect_design` to empty:
220
+
221
+ ```
222
+ ⚠ Architect {architect_name} design unavailable — proceeding without design context
223
+ ```
224
+
225
+ 6. **Log completion:**
226
+ Run using the Bash tool with description "Recording architect completion...": `bash .aether/aether-utils.sh spawn-complete "{architect_name}" "{status}" "{summary}"`
227
+
228
+ ### Step 5.0.5: Select and Announce Workflow Pattern
229
+
230
+ Examine the phase name and task descriptions. Select the first matching pattern:
231
+
232
+ | Phase contains | Pattern |
233
+ |----------------|---------|
234
+ | "bug", "fix", "error", "broken", "failing" | Investigate-Fix |
235
+ | "research", "oracle", "explore", "investigate" | Deep Research |
236
+ | "refactor", "restructure", "clean", "reorganize" | Refactor |
237
+ | "security", "audit", "compliance", "accessibility", "license" | Compliance |
238
+ | "docs", "documentation", "readme", "guide" | Documentation Sprint |
239
+ | (default) | SPBV |
240
+
241
+ Display the selected pattern:
242
+ ```
243
+ ━━ Pattern: {pattern_name} ━━
244
+ {announce_line from Queen's Workflow Patterns definition}
245
+ ```
246
+
247
+ Store `selected_pattern` for inclusion in the BUILD SUMMARY (Step 7).
248
+
249
+ ### Step 5.1: Spawn Wave 1 Workers (Parallel)
250
+
251
+ **CRITICAL: Spawn ALL Wave 1 workers in a SINGLE message using multiple Task tool calls.**
252
+
253
+ **Announce the wave before spawning:**
254
+
255
+ Display the spawn announcement immediately before firing Task calls:
256
+
257
+ For single-caste waves (typical — all builders):
258
+ ```
259
+ ──── 🔨🐜 Spawning {N} Builders in parallel ────
260
+ ```
261
+
262
+ For mixed-caste waves (uncommon):
263
+ ```
264
+ ──── 🐜 Spawning {N} workers ({X} 🔨 Builder, {Y} 🔍 Scout) ────
265
+ ```
266
+
267
+ For a single worker:
268
+ ```
269
+ ──── 🔨🐜 Spawning {ant_name} — {task_summary} ────
270
+ ```
271
+
272
+ ### Step 5.1.1: Ambassador External Integration (Conditional Caste Replacement)
273
+
274
+ **Check if any Wave 1 tasks involve external integration:**
275
+
276
+ For each task in Wave 1, examine the task description and constraints for external integration keywords (case-insensitive):
277
+ - "API", "SDK", "OAuth", "external service", "integration", "webhook", "third-party", "stripe", "sendgrid", "twilio", "openai", "aws", "azure", "gcp"
278
+
279
+ Run using the Bash tool with description "Checking for external integration tasks...":
280
+ ```bash
281
+ # Check phase name and task descriptions for external integration keywords
282
+ phase_name="{phase_name_from_state}"
283
+ task_descriptions="{concatenated task descriptions from Wave 1}"
284
+
285
+ integration_keywords="api sdk oauth external integration webhook third-party stripe sendgrid twilio openai aws azure gcp"
286
+ is_integration_phase="false"
287
+
288
+ for keyword in $integration_keywords; do
289
+ if [[ "${phase_name,,}" == *"$keyword"* ]] || [[ "${task_descriptions,,}" == *"$keyword"* ]]; then
290
+ is_integration_phase="true"
291
+ matched_keyword="$keyword"
292
+ break
293
+ fi
294
+ done
295
+
296
+ echo "{\"is_integration_phase\": \"$is_integration_phase\", \"matched_keyword\": \"$matched_keyword\"}"
297
+ ```
298
+
299
+ Parse the JSON result. If `is_integration_phase` is `"false"`:
300
+ - Skip to standard Builder spawning (continue with existing Step 5.1 logic)
301
+
302
+ If `is_integration_phase` is `"true"`:
303
+
304
+ 1. **Generate Ambassador name and dispatch:**
305
+ Run using the Bash tool with description "Naming ambassador...": `bash .aether/aether-utils.sh generate-ant-name "ambassador"` (store as `{ambassador_name}`)
306
+ Run using the Bash tool with description "Dispatching ambassador...": `bash .aether/aether-utils.sh spawn-log "Queen" "ambassador" "{ambassador_name}" "External integration design"`
307
+
308
+ Display:
309
+ ```
310
+ ━━━ 🔌🐜 A M B A S S A D O R ━━━
311
+ ──── 🔌🐜 Spawning {ambassador_name} — external integration design ────
312
+ ```
313
+
314
+ 2. **Spawn Ambassador using Task tool:**
315
+ > **Platform note**: In Claude Code, use `Task tool with subagent_type`. In OpenCode, use the equivalent agent spawning mechanism for your platform (e.g., invoke the agent definition from `.opencode/agents/`).
316
+
317
+ 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):
318
+
319
+ # FALLBACK: If "Agent type not found", use general-purpose and inject role: "You are an Ambassador Ant - integration specialist that designs external API connections."
320
+
321
+ **Ambassador Worker Prompt (CLEAN OUTPUT):**
322
+ ```
323
+ You are {Ambassador-Name}, a 🔌 Ambassador Ant.
324
+
325
+ Mission: Design external integration for Phase {id}
326
+
327
+ Phase: {phase_name}
328
+ Trigger keyword: {matched_keyword}
329
+
330
+ Task context:
331
+ - Task descriptions: {Wave 1 task descriptions}
332
+ - Files to be created/modified: {from task files}
333
+
334
+ Work:
335
+ 1. Research the external service/API requirements
336
+ 2. Design integration pattern (Client Wrapper, Circuit Breaker, Retry with Backoff)
337
+ 3. Plan authentication method (OAuth, API keys, tokens)
338
+ 4. Design rate limiting handling
339
+ 5. Plan error scenarios (timeout, auth failure, rate limit)
340
+ 6. Document required environment variables
341
+ 7. Create integration plan for Builder execution
342
+
343
+ **Integration Patterns to Consider:**
344
+ - Client Wrapper: Abstract API complexity
345
+ - Circuit Breaker: Handle service failures
346
+ - Retry with Backoff: Handle transient errors
347
+ - Caching: Reduce API calls
348
+ - Queue Integration: Async processing
349
+
350
+ **Security Requirements:**
351
+ - API keys must use environment variables
352
+ - No secrets in tracked files
353
+ - HTTPS only
354
+ - Validate SSL certificates
355
+
356
+ Log activity: bash .aether/aether-utils.sh activity-log "RESEARCH" "{Ambassador-Name}" "description"
357
+
358
+ Return ONLY this JSON (no other text):
359
+ {
360
+ "ant_name": "{Ambassador-Name}",
361
+ "caste": "ambassador",
362
+ "status": "completed" | "failed" | "blocked",
363
+ "summary": "Integration design summary",
364
+ "integration_plan": {
365
+ "service_name": "...",
366
+ "authentication_method": "OAuth|API Key|Token",
367
+ "env_vars_required": ["API_KEY", "..."],
368
+ "integration_pattern": "Client Wrapper|Circuit Breaker|...",
369
+ "rate_limit_handling": "...",
370
+ "error_scenarios_covered": ["timeout", "auth_failure", "rate_limit"],
371
+ "files_to_create": ["..."],
372
+ "implementation_steps": ["..."]
373
+ },
374
+ "endpoints_integrated": [],
375
+ "rate_limits_handled": true,
376
+ "documentation_pages": 0,
377
+ "blockers": []
378
+ }
379
+ ```
380
+
381
+ 3. **Parse Ambassador JSON output:**
382
+ Extract from response: `integration_plan`, `env_vars_required`, `error_scenarios_covered`, `blockers`
383
+
384
+ Log completion:
385
+ Run using the Bash tool with description "Recording ambassador completion...": `bash .aether/aether-utils.sh spawn-complete "{ambassador_name}" "completed" "Integration design complete"`
386
+
387
+ **Display Ambassador completion line:**
388
+ ```
389
+ 🔌 {Ambassador-Name}: Integration design ({integration_plan.service_name}) ✓
390
+ ```
391
+
392
+ 4. **Log integration plan to midden:**
393
+ Run using the Bash tool with description "Logging integration plan...":
394
+ ```bash
395
+ 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"
396
+ ```
397
+
398
+ For each env var required:
399
+ ```bash
400
+ bash .aether/aether-utils.sh midden-write "integration" "Required env var: {env_var}" "ambassador"
401
+ ```
402
+
403
+ 5. **Display integration summary:**
404
+ ```
405
+ 🔌 Ambassador complete — Integration plan ready for {integration_plan.service_name}
406
+
407
+ Authentication: {integration_plan.authentication_method}
408
+ Pattern: {integration_plan.integration_pattern}
409
+ Env vars: {integration_plan.env_vars_required | join: ", "}
410
+
411
+ Builder will execute this plan in Wave 1.
412
+ ```
413
+
414
+ 6. **Store integration plan for Builder injection:**
415
+ Store the `integration_plan` object to be injected into Builder prompts in the standard Wave 1 spawn.
416
+
417
+ **First, mark build start in context:**
418
+ 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}`
419
+
420
+ Before dispatching each worker, refresh colony context so new pheromones/memory are visible:
421
+ 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`.
422
+
423
+ **PER WAVE:** Query midden for recent failures to inject into builder context:
424
+ Run using the Bash tool with description "Checking midden for recent failures...":
425
+ `midden_result=$(bash .aether/aether-utils.sh midden-recent-failures 3 2>/dev/null || echo '{"count":0,"failures":[]}')`
426
+
427
+ Parse `midden_result`. If `count > 0`, format as `midden_context`:
428
+ ```
429
+ **Previous Failures (from colony midden):**
430
+ - [{category}] {message} (source: {source}, {timestamp})
431
+ ...
432
+ ```
433
+
434
+ **Budget cap:** `midden_context` must not exceed 2000 characters. If it exceeds the cap, truncate and append `[midden truncated]`.
435
+
436
+ If `count == 0`, set `midden_context` to empty.
437
+
438
+ > **Platform note**: In Claude Code, use `Task tool with subagent_type`. In OpenCode, use the equivalent agent spawning mechanism for your platform (e.g., invoke the agent definition from `.opencode/agents/`).
439
+
440
+ 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):
441
+
442
+ **PER WORKER:** Build graveyard caution context automatically:
443
+ - Identify explicit repo file paths from the task metadata (`files`, `hints`, `constraints`, and description when a concrete path is present).
444
+ - For each identified file path, run using the Bash tool with description "Checking graveyard cautions for {file}...":
445
+ `bash .aether/aether-utils.sh grave-check "{file}"`
446
+ - Parse each JSON result and keep only entries where `caution_level` is `high` or `low`.
447
+ - Merge these into a single `grave_context` block for that worker.
448
+ - **Budget cap:** `grave_context` must not exceed 2000 characters per worker. If it exceeds the cap, truncate and append `[graveyard truncated]`.
449
+ - If no file paths are identified, or all checks return `none`, set `grave_context` to empty.
450
+ - If `grave_context` is non-empty, display a visible line before spawning that worker:
451
+ `⚰️ Graveyard caution for {ant_name}: {file_1} ({level_1}), {file_2} ({level_2})`
452
+
453
+ **PER WORKER:** Match and inject skills for the worker's role and task:
454
+ Run using the Bash tool with description "Matching skills for {ant_name}...":
455
+ ```bash
456
+ skill_match_result=$(bash .aether/aether-utils.sh skill-match "builder" "{task_description}" 2>/dev/null) || skill_match_result='{"result":{"colony_skills":[],"domain_skills":[]}}'
457
+ skill_inject_result=$(bash .aether/aether-utils.sh skill-inject "$(echo "$skill_match_result" | jq -r '.result')" 2>/dev/null) || skill_inject_result='{"result":{"skill_section":"","colony_count":0,"domain_count":0}}'
458
+ skill_section=$(echo "$skill_inject_result" | jq -r '.result.skill_section // ""')
459
+ skill_colony_count=$(echo "$skill_inject_result" | jq -r '.result.colony_count // 0')
460
+ skill_domain_count=$(echo "$skill_inject_result" | jq -r '.result.domain_count // 0')
461
+ ```
462
+
463
+ Display per worker:
464
+ ```
465
+ 🧠 Skills: {colony_count} colony + {domain_count} domain loaded for builder
466
+ ```
467
+
468
+ **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}"`
469
+
470
+ **Context layer budget caps (enforce before injecting into prompt):**
471
+ - `archaeology_context`: cap at 4000 characters. If it exceeds the cap, truncate and append `[archaeology truncated]`.
472
+ - `midden_context`: cap at 2000 characters (already enforced above).
473
+ - `grave_context`: cap at 2000 characters per worker (already enforced above).
474
+
475
+ **Builder Worker Prompt (CLEAN OUTPUT):**
476
+ ```
477
+ You are {Ant-Name}, a 🔨🐜 Builder Ant.
478
+
479
+ Task {id}: {description}
480
+
481
+ Goal: "{colony_goal}"
482
+
483
+ { archaeology_context if exists }
484
+
485
+ { integration_plan if exists }
486
+
487
+ { research_context if exists }
488
+
489
+ **Phase Research Context (if provided):**
490
+ - This is domain research conducted during planning. Use it to understand patterns, avoid gotchas, and follow the recommended approach.
491
+ - If the research mentions specific files to study, read them before implementing.
492
+
493
+ { grave_context if exists }
494
+
495
+ { midden_context if exists }
496
+
497
+ **Midden Context (if provided):**
498
+ - These are previous failures from this colony. Avoid repeating these patterns.
499
+ - If a failure is related to your task, take extra care or try a different approach.
500
+
501
+ **External Integration Context (if provided by Ambassador):**
502
+ If integration_plan is provided above, you MUST:
503
+ 1. Follow the implementation_steps in order
504
+ 2. Use the specified authentication_method
505
+ 3. Implement the integration_pattern as designed
506
+ 4. Handle all error_scenarios_covered
507
+ 5. Reference required env_vars_required (do NOT hardcode values)
508
+
509
+ { prompt_section }
510
+
511
+ { skill_section }
512
+
513
+ **Graveyard Caution Context (if provided):**
514
+ - Treat `high` caution files as unstable terrain.
515
+ - Preserve proven behavior first, then make minimal safe edits.
516
+ - Add tests around any high-caution file before broader refactors.
517
+
518
+ **IMPORTANT:** When using the Bash tool for activity calls, always include a description parameter:
519
+ - activity-log calls → "Logging {action}..."
520
+ - pheromone-read calls → "Checking colony signals..."
521
+ - spawn-can-spawn calls → "Checking spawn budget..."
522
+ - generate-ant-name calls → "Naming sub-worker..."
523
+ - spawn-log calls → "Dispatching sub-worker..."
524
+
525
+ Use colony-flavored language, 4-8 words, trailing ellipsis.
526
+
527
+ Work:
528
+ 1. Read .aether/workers.md for Builder discipline
529
+ 2. Implement task, write tests
530
+ 3. Log activity using Bash tool with description
531
+ 4. At natural breakpoints (between tasks, after errors): Check for new signals using Bash tool with description
532
+
533
+ **Approach Change Logging:**
534
+ If you try an approach that doesn't work and switch to a different approach, log it:
535
+ ```bash
536
+ colony_name=$(bash .aether/aether-utils.sh colony-name 2>/dev/null | jq -r '.result.name // ""')
537
+ [[ -z "$colony_name" ]] && colony_name="unknown"
538
+ phase_num=$(jq -r '.phase.number // "unknown"' .aether/data/COLONY_STATE.json 2>/dev/null || echo "unknown")
539
+
540
+ cat >> .aether/midden/approach-changes.md << EOF
541
+ - timestamp: "$(date -u +%Y-%m-%dT%H:%M:%SZ)"
542
+ phase: ${phase_num}
543
+ colony: "${colony_name}"
544
+ worker: "{Ant-Name}"
545
+ task: "{task_id}"
546
+ tried: "initial approach that failed"
547
+ why_it_failed: "reason it didn't work"
548
+ switched_to: "new approach that worked"
549
+ EOF
550
+
551
+ # Write to structured midden for threshold detection (MID-02)
552
+ 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
553
+
554
+ # Enter memory pipeline for learning observation tracking (MID-02)
555
+ bash .aether/aether-utils.sh memory-capture \
556
+ "failure" \
557
+ "Approach abandoned: initial approach that failed -> new approach (reason it didn't work)" \
558
+ "failure" \
559
+ "worker:builder" 2>/dev/null || true
560
+ ```
561
+
562
+ Spawn sub-workers ONLY if 3x complexity:
563
+ - Check spawn budget using Bash tool with description: `bash .aether/aether-utils.sh spawn-can-spawn {depth} --enforce`
564
+ - Generate name using Bash tool with description
565
+ - Announce: "🐜 Spawning {child_name} for {reason}"
566
+ - Log spawn using Bash tool with description
567
+
568
+ Count your total tool calls (Read + Grep + Edit + Bash + Write) and report as tool_count.
569
+
570
+ Return ONLY this JSON (no other text):
571
+ {"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": []}
572
+ ```
573
+
574
+ ### Step 5.2: Process Wave 1 Results
575
+
576
+ **Task calls return results directly (no TaskOutput needed).**
577
+
578
+ Before using any worker payload, validate schema:
579
+ Run using the Bash tool with description "Validating worker response...": `bash .aether/aether-utils.sh validate-worker-response builder '{worker_json}'`
580
+ If validation fails, treat the worker as failed with blocker `invalid_worker_response`.
581
+
582
+ **As each worker result arrives, IMMEDIATELY display a single completion line — do not wait for other workers:**
583
+
584
+ For successful workers:
585
+ ```
586
+ 🔨 {Ant-Name}: {task_description} ({tool_count} tools) ✓
587
+ ```
588
+
589
+ For failed workers:
590
+ ```
591
+ 🔨 {Ant-Name}: {task_description} ✗ ({failure_reason} after {tool_count} tools)
592
+ ```
593
+
594
+ 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.
595
+
596
+ **Log failure to midden and record observation (MEM-02):**
597
+
598
+ After displaying a failed worker, run using the Bash tool with description "Logging failure to midden...":
599
+ ```bash
600
+ colony_name=$(bash .aether/aether-utils.sh colony-name 2>/dev/null | jq -r '.result.name // ""')
601
+ [[ -z "$colony_name" ]] && colony_name="unknown"
602
+ phase_num=$(jq -r '.phase.number // "unknown"' .aether/data/COLONY_STATE.json 2>/dev/null || echo "unknown")
603
+
604
+ # Append to build-failures.md
605
+ cat >> .aether/midden/build-failures.md << EOF
606
+ - timestamp: "$(date -u +%Y-%m-%dT%H:%M:%SZ)"
607
+ phase: ${phase_num}
608
+ colony: "${colony_name}"
609
+ worker: "${ant_name}"
610
+ task: "${task_id}"
611
+ what_failed: "${blockers[0]:-$failure_reason}"
612
+ why: "worker returned failed status"
613
+ what_worked: null
614
+ error_type: "worker_failure"
615
+ EOF
616
+
617
+ # Write to structured midden for threshold detection (MID-01)
618
+ 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
619
+
620
+ # Capture failure in memory pipeline (observe + pheromone + auto-promotion)
621
+ bash .aether/aether-utils.sh memory-capture \
622
+ "failure" \
623
+ "Builder ${ant_name} failed on task ${task_id}: ${blockers[0]:-$failure_reason}" \
624
+ "failure" \
625
+ "worker:builder" 2>/dev/null || true
626
+ ```
627
+
628
+ **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"`
629
+
630
+ **Check for total wave failure:**
631
+
632
+ After processing all worker results in this wave, check if EVERY worker returned `status: "failed"`. If ALL workers in the wave failed:
633
+
634
+ Display a prominent halt alert:
635
+ ```
636
+ ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
637
+ ⚠ WAVE FAILURE — BUILD HALTED
638
+ ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
639
+
640
+ All {N} workers in Wave {X} failed. Something is fundamentally wrong.
641
+
642
+ Failed workers:
643
+ {for each failed worker in this wave:}
644
+ {caste_emoji} {Ant-Name}: {task_description} ✗ ({failure_reason} after {tool_count} tools)
645
+ {end for}
646
+
647
+ Next steps:
648
+ /ant:flags Review blockers
649
+ /ant:swarm Auto-repair mode
650
+ ```
651
+
652
+ Then STOP — do not proceed to subsequent waves, Watcher, or Chaos. Skip directly to Step 5.9 synthesis with `status: "failed"`.
653
+
654
+ **Partial wave failure — escalation path:**
655
+
656
+ If SOME (but not all) workers in the wave failed:
657
+ 1. For each failed worker, attempt Tier 3 escalation: Queen spawns a different caste for the same task
658
+ 2. If Tier 3 succeeds: continue to next wave
659
+ 3. If Tier 3 fails: display the Tier 4 ESCALATION banner (from Queen agent definition):
660
+
661
+ ```
662
+ ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
663
+ ⚠ ESCALATION — QUEEN NEEDS YOU
664
+ ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
665
+
666
+ Task: {failed task description}
667
+ Phase: {phase number} — {phase name}
668
+
669
+ Tried:
670
+ • Worker retry (2 attempts) — {what failed}
671
+ • Parent tried alternate approach — {what failed}
672
+ • Queen reassigned to {other caste} — {what failed}
673
+
674
+ Options:
675
+ A) {recommended option} — RECOMMENDED
676
+ B) {alternate option}
677
+ C) Skip and continue — this task will be marked blocked
678
+
679
+ Awaiting your choice.
680
+ ```
681
+
682
+ Log escalation as flag:
683
+ Run using the Bash tool with description "Logging escalation...": `bash .aether/aether-utils.sh flag-add "blocker" "{task title}" "{failure summary}" "escalation" {phase_number}`
684
+
685
+ If at least one worker succeeded, continue normally to the next wave.
686
+
687
+ **Parse each worker's validated JSON output to collect:** status, files_created, files_modified, blockers
688
+
689
+ **Intra-phase midden threshold check (MID-03):**
690
+
691
+ 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.
692
+
693
+ Run using the Bash tool with description "Checking midden thresholds...":
694
+ ```bash
695
+ midden_result=$(bash .aether/aether-utils.sh midden-recent-failures 50 2>/dev/null || echo '{"count":0,"failures":[]}')
696
+ midden_count=$(echo "$midden_result" | jq '.count // 0')
697
+
698
+ if [[ "$midden_count" -gt 0 ]]; then
699
+ recurring_categories=$(echo "$midden_result" | jq -r '
700
+ [.failures[] | .category]
701
+ | group_by(.)
702
+ | map(select(length >= 3))
703
+ | map({category: .[0], count: length})
704
+ | .[]
705
+ | @base64
706
+ ' 2>/dev/null || echo "")
707
+
708
+ redirect_emit_count=0
709
+ for encoded in $recurring_categories; do
710
+ [[ $redirect_emit_count -ge 3 ]] && break
711
+ [[ -z "$encoded" ]] && continue
712
+ category=$(echo "$encoded" | base64 -d | jq -r '.category')
713
+ count=$(echo "$encoded" | base64 -d | jq -r '.count')
714
+
715
+ existing=$(jq -r --arg cat "$category" '
716
+ [.signals[] | select(.active == true and .source == "auto:error" and (.content.text | contains($cat)))] | length
717
+ ' .aether/data/pheromones.json 2>/dev/null || echo "0")
718
+
719
+ if [[ "$existing" == "0" ]]; then
720
+ bash .aether/aether-utils.sh pheromone-write REDIRECT \
721
+ "[error-pattern] Category \"$category\" recurring ($count occurrences)" \
722
+ --strength 0.7 \
723
+ --source "auto:error" \
724
+ --reason "Auto-emitted: midden error pattern recurred 3+ times mid-build" \
725
+ --ttl "30d" 2>/dev/null || true
726
+ redirect_emit_count=$((redirect_emit_count + 1))
727
+ fi
728
+ done
729
+
730
+ if [[ $redirect_emit_count -gt 0 ]]; then
731
+ echo "Warning: Midden threshold triggered -- $redirect_emit_count REDIRECT pheromone(s) emitted mid-build"
732
+ fi
733
+ fi
734
+ ```
735
+
736
+ Display if any REDIRECT was emitted:
737
+ ```
738
+ Warning: Midden threshold: "{category}" recurring ({count}x) -- REDIRECT emitted mid-build
739
+ ```
740
+
741
+ ### Step 5.3: Spawn Wave 2+ Workers (Sequential Waves)
742
+
743
+ **Before each subsequent wave, display a wave separator:**
744
+ ```
745
+ ━━━ 🐜 Wave {X} of {N} ━━━
746
+ ```
747
+ Then display the spawn announcement (same format as Step 5.1).
748
+
749
+ Repeat Step 5.1-5.2 for each subsequent wave, waiting for previous wave to complete.