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,1484 @@
1
+ name: "ant:continue"
2
+ description: "➡️🐜🚪🐜➡️ Detect build completion, reconcile state, and advance to next phase"
3
+ body_claude: |
4
+ You are the **Queen Ant Colony**. Execute `/ant:continue` through modular playbooks.
5
+
6
+ ## Purpose
7
+
8
+ This command is intentionally short. It orchestrates verification and phase
9
+ advancement via smaller playbooks. This improves instruction-following reliability
10
+ without changing continue behavior.
11
+
12
+ ## Rules
13
+
14
+ 1. Do **not** invoke nested slash commands like `/ant:continue-verify`.
15
+ 2. Use the Read tool to load each playbook file, then execute it.
16
+ 3. Preserve variables/results from prior stages and pass them forward.
17
+ 4. Enforce all gate stops exactly as defined in the playbooks.
18
+ 5. Keep existing behavior and output format from the playbooks.
19
+
20
+ ## Stage Order
21
+
22
+ Run these stages in order:
23
+
24
+ 1. `.aether/docs/command-playbooks/continue-verify.md`
25
+ 2. `.aether/docs/command-playbooks/continue-gates.md`
26
+ 3. `.aether/docs/command-playbooks/continue-advance.md`
27
+ 4. `.aether/docs/command-playbooks/continue-finalize.md`
28
+
29
+ ## Execution Contract
30
+
31
+ For each stage:
32
+
33
+ 1. Read the file with the Read tool.
34
+ 2. Execute the instructions exactly as written.
35
+ 3. Keep an in-memory stage result record:
36
+ - `stage_name`
37
+ - `status` (`ok` or `failed`)
38
+ - `key_outputs` (values needed downstream)
39
+ 4. If `status == failed`, halt and report the failure with recovery options.
40
+
41
+ ## Required Cross-Stage State
42
+
43
+ Carry these values forward when produced:
44
+
45
+ - `visual_mode`
46
+ - `state`
47
+ - `current_phase`
48
+ - `verification_results`
49
+ - `gate_results`
50
+ - `advancement_result`
51
+ - `next_phase_id`
52
+ - `completion_state`
53
+
54
+ ## Final Output
55
+
56
+ After `continue-finalize.md` finishes, return the normal continue summary and
57
+ next-step routing exactly as defined there.
58
+
59
+ body_opencode: |
60
+ You are the **Queen Ant Colony**. Reconcile completed work and advance to the next phase.
61
+
62
+ ## Instructions
63
+
64
+ Parse `$normalized_args`:
65
+ - If contains `--no-visual`: set `visual_mode = false` (visual is ON by default)
66
+ - Otherwise: set `visual_mode = true`
67
+
68
+ ### Step 1: Read State
69
+
70
+ Read `.aether/data/COLONY_STATE.json`.
71
+
72
+ **Auto-upgrade old state:**
73
+ If `version` field is missing, "1.0", or "2.0":
74
+ 1. Preserve: `goal`, `state`, `current_phase`, `plan.phases`
75
+ 2. Write upgraded v3.0 state (same structure as /ant:init but preserving data)
76
+ 3. Output: `State auto-upgraded to v3.0`
77
+ 4. Continue with command.
78
+
79
+ Extract: `goal`, `state`, `current_phase`, `plan.phases`, `errors`, `memory`, `events`, `build_started_at`.
80
+
81
+ **Validation:**
82
+ - If `goal: null` -> output "No colony initialized. Run /ant:init first." and stop.
83
+ - If `plan.phases` is empty -> output "No project plan. Run /ant:plan first." and stop.
84
+
85
+ ### Step 1.5: Load State and Show Resumption Context
86
+
87
+ Run using Bash tool: `bash .aether/aether-utils.sh load-state`
88
+
89
+ If successful and goal is not null:
90
+ 1. Extract current_phase from state
91
+ 2. Get phase name from plan.phases[current_phase - 1].name (or "(unnamed)")
92
+ 3. Display brief resumption context:
93
+ ```
94
+ 🔄 Resuming: Phase X - Name
95
+ ```
96
+
97
+ If .aether/HANDOFF.md exists (detected in load-state output):
98
+ - Display "Resuming from paused session"
99
+ - Read .aether/HANDOFF.md for additional context
100
+ - Remove .aether/HANDOFF.md after display (cleanup)
101
+
102
+ Run: `bash .aether/aether-utils.sh unload-state` to release lock.
103
+
104
+ **Error handling:**
105
+ - If E_FILE_NOT_FOUND: "No colony initialized. Run /ant:init first." and stop
106
+ - If validation error: Display error details with recovery suggestion and stop
107
+ - For other errors: Display generic error and suggest /ant:status for diagnostics
108
+
109
+ **Completion Detection:**
110
+
111
+ If `state == "EXECUTING"`:
112
+ 1. Check if `build_started_at` exists
113
+ 2. Look for phase completion evidence:
114
+ - Activity log entries showing task completion
115
+ - Files created/modified matching phase tasks
116
+ 3. If no evidence and build started > 30 min ago:
117
+ - Display "Stale EXECUTING state. Build may have been interrupted."
118
+ - Offer: continue anyway or rollback to git checkpoint
119
+ - Rollback procedure: `git stash list | grep "aether-checkpoint"` to find ref, then `git stash pop <ref>` to restore
120
+
121
+ If `state != "EXECUTING"`:
122
+ - Normal continue flow (no build to reconcile)
123
+
124
+ ### Step 1.5.2: Load Survey Context (Non-blocking)
125
+
126
+ Run:
127
+ ```bash
128
+ survey_check=$(bash .aether/aether-utils.sh survey-verify 2>/dev/null || true)
129
+ survey_docs=$(ls -1 .aether/data/survey/*.md 2>/dev/null | wc -l | tr -d ' ')
130
+ survey_latest=$(ls -t .aether/data/survey/*.md 2>/dev/null | head -1)
131
+ if [[ -n "$survey_latest" ]]; then
132
+ now_epoch=$(date +%s)
133
+ modified_epoch=$(stat -f %m "$survey_latest" 2>/dev/null || stat -c %Y "$survey_latest" 2>/dev/null || echo 0)
134
+ survey_age_days=$(( (now_epoch - modified_epoch) / 86400 ))
135
+ else
136
+ survey_age_days=-1
137
+ fi
138
+ echo "{\"docs\":$survey_docs,\"age_days\":$survey_age_days,\"verify\":$survey_check}"
139
+ ```
140
+
141
+ Interpretation:
142
+ - If `docs == 0`: display `🗺️ Survey: not found (run /ant:colonize for stronger context)` and continue.
143
+ - If `age_days > 14`: display `🗺️ Survey: {docs} docs loaded ({age_days}d old, consider /ant:colonize --force-resurvey)` and continue.
144
+ - Otherwise: display `🗺️ Survey: {docs} docs loaded ({age_days}d old)` and continue.
145
+
146
+ Survey context is advisory only and must not block advancement by itself.
147
+
148
+ ### Step 1.5.3: Verification Loop Gate (MANDATORY)
149
+
150
+ **The Iron Law:** No phase advancement without fresh verification evidence.
151
+
152
+ Before ANY phase can advance, execute the 6-phase verification loop. See `.aether/docs/disciplines/verification-loop.md` for full reference.
153
+
154
+ #### 1. Command Resolution (Priority Chain)
155
+
156
+ Resolve each command (build, test, types, lint) using this priority chain. Stop at the first source that provides a value for each command:
157
+
158
+ **Priority 1 — CLAUDE.md (System Context):**
159
+ Check the CLAUDE.md instructions already loaded in your system context for explicit build, test, type-check, or lint commands. These are authoritative and override all other sources.
160
+
161
+ **Priority 2 — codebase.md `## Commands`:**
162
+ Read `.aether/data/codebase.md` and look for the `## Commands` section. Use any commands listed there for slots not yet filled by Priority 1.
163
+
164
+ **Priority 3 — Fallback Heuristic Table:**
165
+ For any commands still unresolved, check for these files in order, use first match:
166
+
167
+ | File | Build | Test | Types | Lint |
168
+ |------|-------|------|-------|------|
169
+ | `package.json` | `npm run build` | `npm test` | `npx tsc --noEmit` | `npm run lint` |
170
+ | `Cargo.toml` | `cargo build` | `cargo test` | (built-in) | `cargo clippy` |
171
+ | `go.mod` | `go build ./...` | `go test ./...` | `go vet ./...` | `golangci-lint run` |
172
+ | `pyproject.toml` | `python -m build` | `pytest` | `pyright .` | `ruff check .` |
173
+ | `Makefile` | `make build` | `make test` | (check targets) | `make lint` |
174
+
175
+ If no build system detected, skip build/test/type/lint checks but still verify success criteria.
176
+
177
+ #### 2. Run 6-Phase Verification Loop
178
+
179
+ Execute all applicable phases and capture output:
180
+
181
+ ```
182
+ ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
183
+ 👁️🐜 V E R I F I C A T I O N L O O P
184
+ ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
185
+ Phase {id} — Checking colony work...
186
+ ```
187
+
188
+ **Phase 1: Build Check** (if command exists):
189
+ ```bash
190
+ {build_command} 2>&1 | tail -30
191
+ ```
192
+ Record: exit code, any errors. **STOP if fails.**
193
+
194
+ **Phase 2: Type Check** (if command exists):
195
+ ```bash
196
+ {type_command} 2>&1 | head -30
197
+ ```
198
+ Record: error count. Report all type errors.
199
+
200
+ **Phase 3: Lint Check** (if command exists):
201
+ ```bash
202
+ {lint_command} 2>&1 | head -30
203
+ ```
204
+ Record: warning count, error count.
205
+
206
+ **Phase 4: Test Check** (if command exists):
207
+ ```bash
208
+ {test_command} 2>&1 | tail -50
209
+ ```
210
+ Record: pass count, fail count, exit code. **STOP if fails.**
211
+
212
+ **Coverage Check** (if coverage command exists):
213
+ ```bash
214
+ {coverage_command} # e.g., npm run test:coverage
215
+ ```
216
+ Record: coverage percentage (target: 80%+ for new code)
217
+
218
+ #### Step 1.5.1: Probe Coverage Agent (Conditional)
219
+
220
+ **Test coverage improvement -- runs when coverage < 80% AND tests pass.**
221
+
222
+ 1. **Check coverage threshold condition:**
223
+ - Coverage data is already available from Phase 4 coverage check
224
+ - If tests failed: Skip Probe silently (coverage data unreliable)
225
+ - If coverage_percent >= 80%: Skip Probe silently, continue to Phase 5
226
+ - If coverage_percent < 80% AND tests passed: Proceed to spawn Probe
227
+
228
+ 2. **If skipping Probe:**
229
+ ```
230
+ Probe: Coverage at {coverage_percent}% -- {reason_for_skip}
231
+ ```
232
+ Continue to Phase 5: Secrets Scan.
233
+
234
+ 3. **If spawning Probe:**
235
+
236
+ a. Generate Probe name and dispatch:
237
+ Run using the Bash tool with description "Generating Probe name...": `probe_name=$(bash .aether/aether-utils.sh generate-ant-name "probe") && bash .aether/aether-utils.sh spawn-log "Queen" "probe" "$probe_name" "Coverage improvement: ${coverage_percent}%" && echo "{\"name\":\"$probe_name\"}"`
238
+
239
+ b. Display:
240
+ ```
241
+ ━━━ 🧪🐜 P R O B E ━━━
242
+ ──── 🧪🐜 Spawning {probe_name} — Coverage improvement ────
243
+ ```
244
+
245
+ d. Determine uncovered files:
246
+ Run using the Bash tool with description "Getting modified source files...": `modified_source_files=$(git diff --name-only HEAD~1 2>/dev/null || git diff --name-only) && source_files=$(echo "$modified_source_files" | grep -v "\.test\." | grep -v "\.spec\." | grep -v "__tests__") && echo "$source_files"`
247
+
248
+ e. Spawn Probe agent:
249
+
250
+ > **Platform note**: In Claude Code, use `Task tool with subagent_type="aether-probe"`. In OpenCode, use the equivalent agent spawning mechanism for your platform (e.g., invoke the aether-probe agent definition from `.opencode/agents/aether-probe.md`).
251
+
252
+ Probe mission: Improve test coverage for uncovered code paths in the modified files.
253
+ - Analyze the modified source files for uncovered branches and edge cases
254
+ - Identify which paths lack test coverage
255
+ - Generate test cases that exercise uncovered code paths
256
+ - Run the new tests to verify they pass
257
+ - Report coverage improvements and edge cases discovered
258
+
259
+ Constraints:
260
+ - Test files ONLY -- never modify source code
261
+ - Follow existing test conventions in the codebase
262
+ - Do NOT delete or modify existing tests
263
+
264
+ f. Parse Probe JSON output and log completion:
265
+ Extract: `tests_added`, `coverage.lines`, `coverage.branches`, `coverage.functions`, `edge_cases_discovered`
266
+
267
+ Run using the Bash tool with description "Logging Probe completion...": `bash .aether/aether-utils.sh spawn-complete "$probe_name" "completed" "{probe_summary}"`
268
+
269
+ g. Log findings to midden:
270
+ Run using the Bash tool with description "Logging Probe findings to midden...": `bash .aether/aether-utils.sh midden-write "coverage" "Probe generated tests, coverage: ${coverage_lines}%/${coverage_branches}%/${coverage_functions}%" "probe"`
271
+
272
+ 4. **NON-BLOCKING continuation:**
273
+ Display Probe findings summary:
274
+ ```
275
+ Probe complete -- Findings logged to midden, continuing verification...
276
+ Tests added: {count}
277
+ Edge cases discovered: {count}
278
+ ```
279
+
280
+ **CRITICAL:** ALWAYS continue to Phase 5 (Secrets Scan) regardless of Probe results. Probe is strictly non-blocking.
281
+
282
+ 5. **Record Probe status for verification report:**
283
+ Set `probe_status = "ACTIVE"` and store tests_added count and edge_cases count for the verification report.
284
+
285
+ **Phase 5: Secrets Scan**:
286
+ ```bash
287
+ # Check for exposed secrets
288
+ grep -rn "sk-\|api_key\|password\s*=" --include="*.ts" --include="*.js" --include="*.py" src/ 2>/dev/null | head -10
289
+
290
+ # Check for debug artifacts
291
+ grep -rn "console\.log\|debugger" --include="*.ts" --include="*.tsx" --include="*.js" src/ 2>/dev/null | head -10
292
+ ```
293
+ Record: potential secrets (critical), debug artifacts (warning).
294
+
295
+ **Phase 6: Diff Review**:
296
+ ```bash
297
+ git diff --stat
298
+ ```
299
+ Review changed files for unintended modifications.
300
+
301
+ **Success Criteria Check:**
302
+ Read phase success criteria from `plan.phases[current].success_criteria`.
303
+ For EACH criterion:
304
+ 1. Identify what proves it (file exists? test passes? output shows X?)
305
+ 2. Run the check
306
+ 3. Record evidence or gap
307
+
308
+ Display:
309
+ ```
310
+ ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
311
+ 👁️🐜 V E R I F I C A T I O N R E P O R T
312
+ ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
313
+
314
+ 🔨 Build [PASS/FAIL/SKIP]
315
+ 🔍 Types [PASS/FAIL/SKIP] (X errors)
316
+ 🧹 Lint [PASS/FAIL/SKIP] (X warnings)
317
+ 🧪 Tests [PASS/FAIL/SKIP] (X/Y passed)
318
+ Coverage {percent}% (target: 80%)
319
+ 🧪 Probe [ACTIVE/SKIP] (tests added: X, edge cases: Y)
320
+ 🔒 Secrets [PASS/FAIL] (X issues)
321
+ 📦 Gatekeeper [PASS/WARN/SKIP] (X critical, X high)
322
+ 👥 Auditor [PASS/FAIL] (score: X/100)
323
+ 📋 Diff [X files changed]
324
+
325
+ ──────────────────────────────────────────────────
326
+ 🐜 Success Criteria
327
+ ──────────────────────────────────────────────────
328
+ ✅ {criterion 1}: {specific evidence}
329
+ ✅ {criterion 2}: {specific evidence}
330
+ ❌ {criterion 3}: {what's missing}
331
+
332
+ ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
333
+ Overall: READY / NOT READY
334
+ ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
335
+ ```
336
+
337
+ #### 3. Gate Decision
338
+
339
+ **If NOT READY (any of: build fails, tests fail, critical security issues, success criteria unmet):**
340
+
341
+ ```
342
+ ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
343
+ ⛔🐜 V E R I F I C A T I O N F A I L E D
344
+ ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
345
+
346
+ Phase {id} cannot advance until issues are resolved.
347
+
348
+ 🚨 Issues Found:
349
+ {list each failure with specific evidence}
350
+
351
+ 🔧 Required Actions:
352
+ 1. Fix the issues listed above
353
+ 2. Run /ant:continue again to re-verify
354
+
355
+ The phase will NOT advance until verification passes.
356
+ ```
357
+
358
+ **CRITICAL:** Do NOT proceed to Step 2. Do NOT advance the phase.
359
+ Do NOT offer workarounds. Verification is mandatory.
360
+
361
+ Use AskUserQuestion to confirm they understand what needs to be fixed:
362
+ - Show the specific failures
363
+ - Ask if they want to fix now or need help
364
+
365
+ **If READY (all checks pass with evidence):**
366
+
367
+ ```
368
+ ✅🐜 VERIFICATION PASSED
369
+
370
+ All checks completed with evidence:
371
+ {list each check and its evidence}
372
+
373
+ Proceeding to gate checks...
374
+ ```
375
+
376
+ Continue to Step 1.6.
377
+
378
+ ### Step 1.6: Spawn Enforcement Gate (MANDATORY)
379
+
380
+ **The Iron Law:** No phase advancement without worker spawning for non-trivial phases.
381
+
382
+ Read `.aether/data/spawn-tree.txt` to count spawns for this phase.
383
+
384
+ ```bash
385
+ grep -c "spawned" .aether/data/spawn-tree.txt 2>/dev/null || echo "0"
386
+ ```
387
+
388
+ Also check for Watcher spawns specifically:
389
+ ```bash
390
+ grep -c "watcher" .aether/data/spawn-tree.txt 2>/dev/null || echo "0"
391
+ ```
392
+
393
+ **HARD REJECTION - If spawn_count == 0 and phase had 3+ tasks:**
394
+
395
+ ```
396
+ ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
397
+ ⛔🐜 S P A W N G A T E F A I L E D
398
+ ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
399
+
400
+ This phase had {task_count} tasks but spawn_count: 0
401
+ The Prime Worker violated the spawn protocol.
402
+
403
+ 🐜 The colony requires actual parallelism:
404
+ - Prime Worker MUST spawn specialists for non-trivial work
405
+ - A single agent doing everything is NOT a colony
406
+ - "Justifications" for not spawning are not accepted
407
+
408
+ 🔧 Required Actions:
409
+ 1. Run /ant:build {phase} again
410
+ 2. Prime Worker MUST spawn at least 1 specialist
411
+ 3. Re-run /ant:continue after spawns complete
412
+
413
+ The phase will NOT advance until spawning occurs.
414
+ ```
415
+
416
+ **CRITICAL:** Do NOT proceed to Step 1.7. Do NOT advance the phase.
417
+ Log the violation:
418
+ ```bash
419
+ bash .aether/aether-utils.sh activity-log "BLOCKED" "colony" "Spawn gate failed: {task_count} tasks, 0 spawns"
420
+ bash .aether/aether-utils.sh error-flag-pattern "no-spawn-violation" "Prime Worker completed phase without spawning specialists" "critical"
421
+ ```
422
+
423
+ **HARD REJECTION - If watcher_count == 0 (no testing separation):**
424
+
425
+ ```
426
+ ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
427
+ ⛔👁️🐜 W A T C H E R G A T E F A I L E D
428
+ ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
429
+
430
+ No Watcher ant was spawned for testing/verification.
431
+ Testing MUST be performed by a separate agent, not the builder.
432
+
433
+ 🐜 Why this matters:
434
+ - Builders verify their own work = confirmation bias
435
+ - Independent Watchers catch bugs builders miss
436
+ - "Build passing" ≠ "App working"
437
+
438
+ 🔧 Required Actions:
439
+ 1. Run /ant:build {phase} again
440
+ 2. Prime Worker MUST spawn at least 1 Watcher
441
+ 3. Watcher must independently verify the work
442
+
443
+ The phase will NOT advance until a Watcher validates.
444
+ ```
445
+
446
+ **CRITICAL:** Do NOT proceed. Log the violation.
447
+
448
+ **If spawn_count >= 1 AND watcher_count >= 1:**
449
+
450
+ ```
451
+ ✅🐜 SPAWN GATE PASSED — {spawn_count} workers | {watcher_count} watchers
452
+ ```
453
+
454
+ Continue to Step 1.7.
455
+
456
+ ### Step 1.7: Anti-Pattern Gate
457
+
458
+ Scan all modified/created files for known anti-patterns. This catches recurring bugs before they reach production.
459
+
460
+ ```bash
461
+ bash .aether/aether-utils.sh check-antipattern "{file_path}"
462
+ ```
463
+
464
+ Run for each file in `files_created` and `files_modified` from Prime Worker output.
465
+
466
+ **Anti-Pattern Report:**
467
+
468
+ ```
469
+ 🔍🐜 Anti-Pattern Scan — {count} files scanned
470
+
471
+ {if critical issues:}
472
+ 🛑 CRITICAL (must fix):
473
+ {list each with file:line and description}
474
+
475
+ {if warnings:}
476
+ ⚠️ WARNINGS:
477
+ {list each with file:line and description}
478
+
479
+ {if clean:}
480
+ ✅🐜 No anti-patterns detected
481
+ ```
482
+
483
+ **CRITICAL issues block phase advancement:**
484
+ - Swift didSet infinite recursion
485
+ - Exposed secrets/credentials
486
+ - SQL injection patterns
487
+ - Known crash patterns
488
+
489
+ **WARNINGS are logged but don't block:**
490
+ - TypeScript `any` usage
491
+ - Console.log in production code
492
+ - TODO/FIXME comments
493
+
494
+ If CRITICAL issues found, display:
495
+
496
+ ```
497
+ ⛔🐜 ANTI-PATTERN GATE FAILED
498
+
499
+ Critical anti-patterns detected:
500
+ {list issues with file paths}
501
+
502
+ Run /ant:build {phase} again after fixing.
503
+ ```
504
+
505
+ Do NOT proceed to Step 2.
506
+
507
+ If no CRITICAL issues, continue to Step 1.7.1.
508
+
509
+ ### Step 1.7.1: Proactive Refactoring Gate (Conditional)
510
+
511
+ **Complexity-based refactoring -- runs when code exceeds maintainability thresholds.**
512
+
513
+ 1. **Get modified/created files from recent work:**
514
+ Run using the Bash tool with description "Getting modified files for complexity check...": `modified_files=$(git diff --name-only HEAD~1 2>/dev/null || git diff --name-only) && echo "$modified_files"`
515
+
516
+ 2. **Check complexity thresholds for each file:**
517
+
518
+ For each file, check:
519
+ - Line count > 300 lines
520
+ - Long functions > 50 lines (simplified heuristic)
521
+ - Directory density > 10 new files
522
+
523
+ Run using the Bash tool with description "Checking complexity thresholds...":
524
+ ```bash
525
+ modified_files=$(git diff --name-only HEAD~1 2>/dev/null || git diff --name-only)
526
+
527
+ complexity_trigger=false
528
+ files_needing_refactor=""
529
+
530
+ for file in $modified_files; do
531
+ if [[ -f "$file" ]]; then
532
+ line_count=$(wc -l < "$file" 2>/dev/null || echo "0")
533
+ if [[ "$line_count" -gt 300 ]]; then
534
+ complexity_trigger=true
535
+ files_needing_refactor="$files_needing_refactor $file"
536
+ continue
537
+ fi
538
+
539
+ long_funcs=$(grep -c "^[[:space:]]*[a-zA-Z_][a-zA-Z0-9_]*[[:space:]]*(" "$file" 2>/dev/null || echo "0")
540
+ if [[ "$long_funcs" -gt 50 ]]; then
541
+ complexity_trigger=true
542
+ files_needing_refactor="$files_needing_refactor $file"
543
+ fi
544
+ fi
545
+ done
546
+
547
+ if [[ -n "$modified_files" ]]; then
548
+ dir_counts=$(echo "$modified_files" | xargs -I {} dirname {} 2>/dev/null | sort | uniq -c | sort -rn)
549
+ high_density_dir=$(echo "$dir_counts" | awk '$1 > 10 {print $2}' | head -1)
550
+ if [[ -n "$high_density_dir" ]]; then
551
+ complexity_trigger=true
552
+ fi
553
+ fi
554
+
555
+ echo "{\"complexity_trigger\": \"$complexity_trigger\", \"files_needing_refactor\": \"$files_needing_refactor\"}"
556
+ ```
557
+
558
+ 3. **If complexity thresholds NOT exceeded:**
559
+ ```
560
+ Weaver: Complexity thresholds not exceeded -- skipping proactive refactoring
561
+ ```
562
+ Continue to Step 1.8.
563
+
564
+ 4. **If complexity thresholds exceeded:**
565
+
566
+ a. **Establish test baseline before refactoring:**
567
+ Run using the Bash tool with description "Establishing test baseline...": `test_output_before=$(npm test 2>&1 || echo "TEST_FAILED") && tests_passing_before=$(echo "$test_output_before" | grep -oE '[0-9]+ passing' | grep -oE '[0-9]+' || echo "0") && echo "Baseline: $tests_passing_before tests passing"`
568
+
569
+ b. **Generate Weaver name and dispatch:**
570
+ Run using the Bash tool with description "Generating Weaver name...": `weaver_name=$(bash .aether/aether-utils.sh generate-ant-name "weaver") && bash .aether/aether-utils.sh spawn-log "Queen" "weaver" "$weaver_name" "Proactive refactoring" && echo "{\"name\":\"$weaver_name\"}"`
571
+
572
+ c. **Display:**
573
+ ```
574
+ ━━━ 🔄🐜 W E A V E R ━━━
575
+ ──── 🔄🐜 Spawning {weaver_name} — Proactive refactoring ────
576
+ ```
577
+
578
+ e. **Spawn Weaver agent:**
579
+
580
+ > **Platform note**: In Claude Code, use `Task tool with subagent_type="aether-weaver"`. In OpenCode, use the equivalent agent spawning mechanism for your platform (e.g., invoke the aether-weaver agent definition from `.opencode/agents/aether-weaver.md`).
581
+
582
+ Weaver mission: Refactor complex code to improve maintainability while preserving behavior.
583
+ - Analyze target files for complexity issues
584
+ - Plan incremental refactoring steps
585
+ - Execute one step at a time
586
+ - Run tests after each step
587
+ - If tests pass, continue; if fail, revert and try smaller step
588
+ - Report all changes made
589
+
590
+ Constraints:
591
+ - NEVER change behavior -- only structure
592
+ - Run tests after each refactoring step
593
+ - If tests fail, revert immediately
594
+ - Do NOT modify test expectations to make tests pass
595
+ - Do NOT modify .aether/ system files
596
+
597
+ f. **Parse Weaver JSON output and verify tests:**
598
+ Extract: `files_refactored`, `tests_all_passing`, `complexity_before`, `complexity_after`
599
+
600
+ Run using the Bash tool with description "Verifying tests after refactoring...":
601
+ ```bash
602
+ test_output_after=$(npm test 2>&1 || echo "TEST_FAILED")
603
+ tests_passing_after=$(echo "$test_output_after" | grep -oE '[0-9]+ passing' | grep -oE '[0-9]+' || echo "0")
604
+
605
+ if [[ "$tests_passing_after" -lt "$tests_passing_before" ]]; then
606
+ echo "REVERT_NEEDED: Tests failed after refactoring"
607
+ git checkout -- $files_needing_refactor
608
+ weaver_status="reverted"
609
+ else
610
+ echo "PASSING: Tests passing after refactoring ($tests_passing_after)"
611
+ weaver_status="completed"
612
+ fi
613
+ ```
614
+
615
+ g. **Log completion:**
616
+ Run using the Bash tool with description "Logging Weaver completion...": `bash .aether/aether-utils.sh spawn-complete "$weaver_name" "$weaver_status" "Refactoring $weaver_status"`
617
+
618
+ h. **Log to midden:**
619
+ Run using the Bash tool with description "Logging refactoring activity to midden...": `bash .aether/aether-utils.sh midden-write "refactoring" "Weaver refactored files, complexity before/after: ${complexity_before}/${complexity_after}" "weaver"`
620
+
621
+ 5. **Display completion:**
622
+ ```
623
+ Weaver: Proactive refactoring {weaver_status}
624
+ Files refactored: {count} | Complexity: {before} -> {after}
625
+ ```
626
+
627
+ 6. **NON-BLOCKING continuation:**
628
+ The Weaver step is NON-BLOCKING -- continue to Step 1.8 regardless of refactoring results.
629
+
630
+ Continue to Step 1.8.
631
+
632
+ ### Step 1.8: Gatekeeper Security Gate (Conditional)
633
+
634
+ **Supply chain security audit -- runs only when package.json exists.**
635
+
636
+ First, check for package.json:
637
+ Run using the Bash tool with description "Checking for package.json...": `test -f package.json && echo "exists" || echo "missing"`
638
+
639
+ **If package.json is missing:**
640
+ ```
641
+ Gatekeeper: No package.json found -- skipping supply chain audit
642
+ ```
643
+ Continue to Step 1.9.
644
+
645
+ **If package.json exists:**
646
+
647
+ 1. Generate Gatekeeper name and log spawn:
648
+ Run using the Bash tool with description "Generating Gatekeeper name...": `gatekeeper_name=$(bash .aether/aether-utils.sh generate-ant-name "gatekeeper") && bash .aether/aether-utils.sh spawn-log "Queen" "gatekeeper" "$gatekeeper_name" "Supply chain security audit" && echo "{\"name\":\"$gatekeeper_name\"}"`
649
+
650
+ 2. Display:
651
+ ```
652
+ ━━━ 📦🐜 G A T E K E E P E R ━━━
653
+ ──── 📦🐜 Spawning {gatekeeper_name} — Supply chain security audit ────
654
+ ```
655
+
656
+ 4. Spawn Gatekeeper agent:
657
+
658
+ > **Platform note**: In Claude Code, use `Task tool with subagent_type="aether-gatekeeper"`. In OpenCode, use the equivalent agent spawning mechanism for your platform (e.g., invoke the aether-gatekeeper agent definition from `.opencode/agents/aether-gatekeeper.md`).
659
+
660
+ Gatekeeper mission: Perform supply chain security audit on this codebase.
661
+ - Inventory all dependencies from package.json
662
+ - Scan for known CVEs using npm audit or equivalent
663
+ - Check license compliance for all packages
664
+ - Assess dependency health (outdated, deprecated, maintenance status)
665
+ - Report findings with severity levels
666
+
667
+ 5. Parse Gatekeeper JSON output and log completion:
668
+ Extract: `security.critical`, `security.high`, `status`
669
+
670
+ Run using the Bash tool with description "Logging Gatekeeper completion...": `bash .aether/aether-utils.sh spawn-complete "$gatekeeper_name" "completed" "{gatekeeper_summary}"`
671
+
672
+ **Gate Decision Logic:**
673
+
674
+ - **If `security.critical > 0`:**
675
+ ```
676
+ GATEKEEPER GATE FAILED
677
+
678
+ Critical security vulnerabilities detected: {critical_count}
679
+
680
+ CRITICAL CVEs must be fixed before phase advancement.
681
+
682
+ Required Actions:
683
+ 1. Run `npm audit` to see full details
684
+ 2. Fix or update vulnerable dependencies
685
+ 3. Run /ant:continue again after resolving
686
+
687
+ The phase will NOT advance with critical CVEs.
688
+ ```
689
+ **CRITICAL:** Do NOT proceed to Step 1.9. Stop here.
690
+
691
+ - **If `security.high > 0`:**
692
+ ```
693
+ Gatekeeper: {high_count} high-severity issues found
694
+
695
+ Security warnings logged to midden for later review.
696
+ Proceeding with caution...
697
+ ```
698
+ Run using the Bash tool with description "Logging high-severity warnings...": `bash .aether/aether-utils.sh midden-write "security" "High CVEs found: $high_count" "gatekeeper"`
699
+ Continue to Step 1.9.
700
+
701
+ - **If clean (no critical or high):**
702
+ ```
703
+ Gatekeeper: No critical security issues found
704
+ ```
705
+ Continue to Step 1.9.
706
+
707
+ ### Step 1.9: Auditor Quality Gate (MANDATORY)
708
+
709
+ **Code quality audit -- runs on every `/ant:continue` for consistent coverage.**
710
+
711
+ 1. Generate Auditor name and log spawn:
712
+ Run using the Bash tool with description "Generating Auditor name...": `auditor_name=$(bash .aether/aether-utils.sh generate-ant-name "auditor") && bash .aether/aether-utils.sh spawn-log "Queen" "auditor" "$auditor_name" "Code quality audit" && echo "{\"name\":\"$auditor_name\"}"`
713
+
714
+ 2. Display:
715
+ ```
716
+ ━━━ 👥🐜 A U D I T O R ━━━
717
+ ──── 👥🐜 Spawning {auditor_name} — Code quality audit ────
718
+ ```
719
+
720
+ 4. Get modified files for audit context:
721
+ Run using the Bash tool with description "Getting modified files...": `modified_files=$(git diff --name-only HEAD~1 2>/dev/null || git diff --name-only) && echo "$modified_files"`
722
+
723
+ 5. Spawn Auditor agent:
724
+
725
+ > **Platform note**: In Claude Code, use `Task tool with subagent_type="aether-auditor"`. In OpenCode, use the equivalent agent spawning mechanism for your platform (e.g., invoke the aether-auditor agent definition from `.opencode/agents/aether-auditor.md`).
726
+
727
+ Auditor mission: Perform comprehensive code quality audit on this codebase.
728
+ - Review all modified files from the recent commit(s)
729
+ - Apply all 4 audit lenses: security, performance, quality, maintainability
730
+ - Score each finding by severity (CRITICAL/HIGH/MEDIUM/LOW/INFO)
731
+ - Calculate overall quality score (0-100)
732
+ - Document specific issues with file:line references and fix suggestions
733
+
734
+ 6. Parse Auditor JSON output and log completion:
735
+ Extract: `findings.critical`, `findings.high`, `findings.medium`, `findings.low`, `findings.info`, `overall_score`, `dimensions_audited`
736
+
737
+ Run using the Bash tool with description "Logging Auditor completion...": `bash .aether/aether-utils.sh spawn-complete "$auditor_name" "completed" "{auditor_summary}"`
738
+
739
+ **Gate Decision Logic:**
740
+
741
+ - **If `findings.critical > 0`:**
742
+ ```
743
+ AUDITOR GATE FAILED
744
+
745
+ Critical code quality issues detected: {critical_count}
746
+
747
+ CRITICAL findings must be fixed before phase advancement.
748
+
749
+ Required Actions:
750
+ 1. Review the critical issues listed below
751
+ 2. Fix each critical finding
752
+ 3. Run /ant:continue again after resolving
753
+
754
+ Critical Findings:
755
+ {list each critical finding with file:line and description}
756
+
757
+ The phase will NOT advance with critical quality issues.
758
+ ```
759
+ Run using the Bash tool with description "Logging critical quality block...": `bash .aether/aether-utils.sh error-flag-pattern "auditor-critical-findings" "$critical_count critical quality issues found" "critical"`
760
+ **CRITICAL:** Do NOT proceed to Step 1.10. Stop here.
761
+
762
+ - **Else if `overall_score < 60`:**
763
+ ```
764
+ AUDITOR GATE FAILED
765
+
766
+ Code quality score below threshold: {overall_score}/100 (threshold: 60)
767
+
768
+ Quality score must reach 60+ before phase advancement.
769
+
770
+ Required Actions:
771
+ 1. Address the top issues preventing score improvement
772
+ 2. Focus on HIGH severity items first
773
+ 3. Run /ant:continue again after improving quality
774
+
775
+ The phase will NOT advance with quality score below 60.
776
+ ```
777
+ Run using the Bash tool with description "Logging quality score block...": `bash .aether/aether-utils.sh error-flag-pattern "auditor-quality-score" "Score $overall_score below threshold 60" "critical"`
778
+ **CRITICAL:** Do NOT proceed to Step 1.10. Stop here.
779
+
780
+ - **Else if `findings.high > 0`:**
781
+ ```
782
+ Auditor: Quality score {overall_score}/100 -- PASSED with warnings
783
+
784
+ {high_count} high-severity quality issues found:
785
+ {list high findings}
786
+
787
+ Quality warnings logged to midden for later review.
788
+ Proceeding with caution...
789
+ ```
790
+ Run using the Bash tool with description "Logging high-quality warnings...": `bash .aether/aether-utils.sh midden-write "quality" "High severity issues: $high_count (score: $overall_score)" "auditor"`
791
+ Continue to Step 1.10.
792
+
793
+ - **If clean (score >= 60, no critical):**
794
+ ```
795
+ Auditor: Quality score {overall_score}/100 -- PASSED
796
+ ```
797
+ Continue to Step 1.10.
798
+
799
+ ### Step 1.10: TDD Evidence Gate (MANDATORY)
800
+
801
+ **The Iron Law:** No TDD claims without actual test files.
802
+
803
+ If Prime Worker reported TDD metrics (tests_added, tests_total, coverage_percent), verify test files exist:
804
+
805
+ ```bash
806
+ # Check for test files based on project type
807
+ find . -name "*.test.*" -o -name "*_test.*" -o -name "*Tests.swift" -o -name "test_*.py" 2>/dev/null | head -10
808
+ ```
809
+
810
+ **If Prime Worker claimed tests_added > 0 but no test files found:**
811
+
812
+ ```
813
+ ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
814
+ ⛔🧪🐜 T D D G A T E F A I L E D
815
+ ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
816
+
817
+ Prime Worker claimed:
818
+ tests_added: {claimed_count}
819
+ tests_total: {claimed_total}
820
+ coverage: {claimed_coverage}%
821
+
822
+ But no test files were found in the codebase.
823
+
824
+ 🚨 CRITICAL violation — fabricated TDD metrics.
825
+
826
+ 🔧 Required Actions:
827
+ 1. Run /ant:build {phase} again
828
+ 2. Actually write test files (not just claim them)
829
+ 3. Tests must exist and be runnable
830
+
831
+ The phase will NOT advance with fabricated metrics.
832
+ ```
833
+
834
+ **CRITICAL:** Do NOT proceed. Log the violation:
835
+ ```bash
836
+ bash .aether/aether-utils.sh error-flag-pattern "fabricated-tdd" "Prime Worker reported TDD metrics without creating test files" "critical"
837
+ ```
838
+
839
+ **If tests_added == 0 or test files exist matching claims:**
840
+
841
+ Continue to Step 1.11.
842
+
843
+ ### Step 1.11: Runtime Verification Gate (MANDATORY)
844
+
845
+ **The Iron Law:** Build passing ≠ App working.
846
+
847
+ Before advancing, the user must confirm the application actually runs.
848
+
849
+ Use AskUserQuestion:
850
+
851
+ ```
852
+ ──────────────────────────────────────────────────
853
+ 🐜 Runtime Verification Required
854
+ ──────────────────────────────────────────────────
855
+
856
+ Build checks passed — but does the app actually work?
857
+
858
+ Have you tested the application at runtime?
859
+ ```
860
+
861
+ Options:
862
+ 1. **Yes, tested and working** - App runs correctly, features work
863
+ 2. **Yes, tested but has issues** - App runs but has bugs (describe)
864
+ 3. **No, haven't tested yet** - Need to test before continuing
865
+ 4. **Skip (not applicable)** - No runnable app in this phase (e.g., library code)
866
+
867
+ **If "Yes, tested and working":**
868
+ ```
869
+ ✅🐜 RUNTIME VERIFIED — User confirmed app works.
870
+ ```
871
+ Continue to Step 1.12.
872
+
873
+ **If "Yes, tested but has issues":**
874
+ ```
875
+ ⛔🐜 RUNTIME GATE FAILED — User reported issues.
876
+
877
+ Please describe the issues so they can be addressed:
878
+ ```
879
+
880
+ Use AskUserQuestion to get issue details. Log to errors.records:
881
+ ```bash
882
+ bash .aether/aether-utils.sh error-add "runtime" "critical" "{user_description}" {phase}
883
+ ```
884
+
885
+ Do NOT proceed to Step 2.
886
+
887
+ **If "No, haven't tested yet":**
888
+ ```
889
+ ⏸️🐜 RUNTIME PENDING — Test the app, then run /ant:continue again.
890
+
891
+ - [ ] App launches without crashing
892
+ - [ ] Core features work as expected
893
+ - [ ] UI responds to user interaction
894
+ - [ ] No freezes or hangs
895
+ ```
896
+
897
+ Do NOT proceed to Step 2.
898
+
899
+ **If "Skip (not applicable)":**
900
+
901
+ Only valid for phases that don't produce runnable code (e.g., documentation, config files, library code with no entry point).
902
+
903
+ ```
904
+ ⏭️ RUNTIME CHECK SKIPPED
905
+
906
+ User indicated no runnable app for this phase.
907
+ Proceeding to phase advancement.
908
+ ```
909
+
910
+ Continue to Step 1.12.
911
+
912
+ ### Step 1.12: Flags Gate (MANDATORY)
913
+
914
+ **The Iron Law:** No phase advancement with unresolved blockers.
915
+
916
+ First, auto-resolve any flags eligible for resolution now that verification has passed:
917
+ ```bash
918
+ bash .aether/aether-utils.sh flag-auto-resolve "build_pass"
919
+ ```
920
+
921
+ Then check for remaining blocking flags:
922
+ ```bash
923
+ bash .aether/aether-utils.sh flag-check-blockers {current_phase}
924
+ ```
925
+
926
+ Parse result for `blockers`, `issues`, and `notes` counts.
927
+
928
+ **If blockers > 0:**
929
+
930
+ ```
931
+ ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
932
+ ⛔🚩🐜 F L A G S G A T E F A I L E D
933
+ ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
934
+
935
+ {blockers} blocker(s) must be resolved first.
936
+
937
+ 🚩 Active Blockers:
938
+ {list each blocker flag with ID, title, and description}
939
+
940
+ 🔧 Required Actions:
941
+ 1. Fix the issues described in each blocker
942
+ 2. Resolve flags: /ant:flags --resolve {flag_id} "resolution message"
943
+ 3. Run /ant:continue again after resolving all blockers
944
+ ```
945
+
946
+ **CRITICAL:** Do NOT proceed to Step 2. Do NOT advance the phase.
947
+
948
+ **If blockers == 0 but issues > 0:**
949
+
950
+ ```
951
+ ⚠️🐜 FLAGS: {issues} issue(s) noted (non-blocking)
952
+
953
+ {list each issue flag}
954
+
955
+ Use /ant:flags to review.
956
+ ```
957
+
958
+ Continue to Step 2.
959
+
960
+ **If all clear (no blockers or issues):**
961
+
962
+ ```
963
+ ✅🐜 FLAGS GATE PASSED — No blockers.
964
+ ```
965
+
966
+ Continue to Step 2.
967
+
968
+ ### Step 2: Update State
969
+
970
+ Find current phase in `plan.phases`.
971
+ Determine next phase (`current_phase + 1`).
972
+
973
+ **If no next phase (all complete):** Skip to Step 2.6 (commit suggestion), then Step 2.5 (completion).
974
+
975
+ Update COLONY_STATE.json:
976
+
977
+ 1. **Mark current phase completed:**
978
+ - Set `plan.phases[current].status` to `"completed"`
979
+ - Set all tasks in phase to `"completed"`
980
+
981
+ 2. **Extract learnings (with validation status):**
982
+
983
+ **CRITICAL: Learnings start as HYPOTHESES until verified.**
984
+
985
+ A learning is only "validated" if:
986
+ - The code was actually run and tested
987
+ - The feature works in practice, not just in theory
988
+ - User has confirmed the behavior
989
+
990
+ Append to `memory.phase_learnings`:
991
+ ```json
992
+ {
993
+ "id": "learning_<unix_timestamp>",
994
+ "phase": <phase_number>,
995
+ "phase_name": "<name>",
996
+ "learnings": [
997
+ {
998
+ "claim": "<specific actionable learning>",
999
+ "status": "hypothesis",
1000
+ "tested": false,
1001
+ "evidence": "<what observation led to this>",
1002
+ "disproven_by": null
1003
+ }
1004
+ ],
1005
+ "timestamp": "<ISO-8601>"
1006
+ }
1007
+ ```
1008
+
1009
+ **Status values:**
1010
+ - `hypothesis` - Recorded but not verified (DEFAULT)
1011
+ - `validated` - Tested and confirmed working
1012
+ - `disproven` - Found to be incorrect
1013
+
1014
+ **Do NOT record a learning if:**
1015
+ - It wasn't actually tested
1016
+ - It's stating the obvious
1017
+ - There's no evidence it works
1018
+
1019
+ 2.5. **Record learning observations for threshold tracking:**
1020
+
1021
+ For each learning extracted, record an observation to enable threshold-based wisdom promotion.
1022
+
1023
+ Run using the Bash tool with description "Recording learning observations...":
1024
+ ```bash
1025
+ colony_name=$(bash .aether/aether-utils.sh colony-name 2>/dev/null | jq -r '.result.name // ""')
1026
+ [[ -z "$colony_name" ]] && colony_name="unknown"
1027
+
1028
+ # Get learnings from the current phase
1029
+ current_phase_learnings=$(jq -r --argjson phase "$current_phase" '.memory.phase_learnings[] | select(.phase == $phase)' .aether/data/COLONY_STATE.json 2>/dev/null || echo "")
1030
+
1031
+ if [[ -n "$current_phase_learnings" ]]; then
1032
+ echo "$current_phase_learnings" | jq -r '.learnings[]?.claim // empty' 2>/dev/null | while read -r claim; do
1033
+ if [[ -n "$claim" ]]; then
1034
+ # Default wisdom_type to "pattern" (threshold: 3 observations)
1035
+ bash .aether/aether-utils.sh memory-capture "learning" "$claim" "pattern" "worker:continue" 2>/dev/null || true
1036
+ fi
1037
+ done
1038
+ echo "Recorded observations for threshold tracking"
1039
+ else
1040
+ echo "No learnings to record"
1041
+ fi
1042
+ ```
1043
+
1044
+ This records each learning in `learning-observations.json` with:
1045
+ - Content hash for deduplication (same claim across phases increments count)
1046
+ - Observation count (increments if seen before)
1047
+ - Colony name for cross-colony tracking
1048
+
1049
+ When observations reach threshold (default: 3 for "pattern" type), they become eligible for promotion in Step 2.1.5.
1050
+
1051
+ 3. **Extract instincts from patterns:**
1052
+
1053
+ Read activity.log for patterns from this phase's build.
1054
+
1055
+ For each pattern observed (success, error_resolution, user_feedback):
1056
+
1057
+ **If pattern matches existing instinct:**
1058
+ - Update confidence: +0.1 for success outcome, -0.1 for failure
1059
+ - Increment applications count
1060
+ - Update last_applied timestamp
1061
+
1062
+ **If new pattern:**
1063
+ - Create new instinct with initial confidence:
1064
+ - success: 0.4
1065
+ - error_resolution: 0.5
1066
+ - user_feedback: 0.7
1067
+
1068
+ Append to `memory.instincts`:
1069
+ ```json
1070
+ {
1071
+ "id": "instinct_<unix_timestamp>",
1072
+ "trigger": "<when X>",
1073
+ "action": "<do Y>",
1074
+ "confidence": 0.5,
1075
+ "status": "hypothesis",
1076
+ "domain": "<testing|architecture|code-style|debugging|workflow>",
1077
+ "source": "phase-<id>",
1078
+ "evidence": ["<specific observation that led to this>"],
1079
+ "tested": false,
1080
+ "created_at": "<ISO-8601>",
1081
+ "last_applied": null,
1082
+ "applications": 0,
1083
+ "successes": 0,
1084
+ "failures": 0
1085
+ }
1086
+ ```
1087
+
1088
+ **Instinct confidence updates:**
1089
+ - Success when applied: +0.1, increment `successes`
1090
+ - Failure when applied: -0.15, increment `failures`
1091
+ - If `failures` >= 2 and `successes` == 0: mark `status: "disproven"`
1092
+ - If `successes` >= 2 and tested: mark `status: "validated"`
1093
+
1094
+ Cap: Keep max 30 instincts (remove lowest confidence when exceeded).
1095
+
1096
+ 4. **Advance state:**
1097
+ - Set `current_phase` to next phase number
1098
+ - Set `state` to `"READY"`
1099
+ - Set `build_started_at` to null
1100
+ - Append event: `"<timestamp>|phase_advanced|continue|Completed Phase <id>, advancing to Phase <next>"`
1101
+
1102
+ 5. **Cap enforcement:**
1103
+ - Keep max 20 phase_learnings
1104
+ - Keep max 30 decisions
1105
+ - Keep max 30 instincts (remove lowest confidence)
1106
+ - Keep max 100 events
1107
+
1108
+ Write COLONY_STATE.json.
1109
+
1110
+ Validate the state file:
1111
+ Run using the Bash tool with description "Validating colony state...": `bash .aether/aether-utils.sh validate-state colony`
1112
+
1113
+ ### Step 2.1: Auto-Emit Phase Pheromones (SILENT)
1114
+
1115
+ **This entire step produces NO user-visible output.** All pheromone operations run silently -- learnings are deposited in the background. If any pheromone call fails, log the error and continue. Phase advancement must never fail due to pheromone errors.
1116
+
1117
+ #### 2.1a: Auto-emit FEEDBACK pheromone for phase outcome
1118
+
1119
+ After learning extraction completes in Step 2, auto-emit a FEEDBACK signal summarizing the phase:
1120
+
1121
+ ```bash
1122
+ # phase_id and phase_name come from Step 2 state update
1123
+ # Take the top 1-3 learnings by evidence strength from memory.phase_learnings
1124
+ # Compress into a single summary sentence
1125
+
1126
+ phase_feedback="Phase $phase_id ($phase_name) completed. Key patterns: {brief summary of 1-3 learnings from Step 2}"
1127
+ # Fallback if no learnings: "Phase $phase_id ($phase_name) completed without notable patterns."
1128
+
1129
+ bash .aether/aether-utils.sh pheromone-write FEEDBACK "$phase_feedback" \
1130
+ --strength 0.6 \
1131
+ --source "worker:continue" \
1132
+ --reason "Auto-emitted on phase advance: captures what worked and what was learned" \
1133
+ --ttl "30d" 2>/dev/null || true
1134
+ ```
1135
+
1136
+ The strength is 0.6 (auto-emitted = lower than user-emitted 0.7). Source is "worker:continue" to distinguish from user-emitted feedback. TTL is 30d so it survives phase transitions and can guide subsequent work.
1137
+
1138
+ #### 2.1b: Auto-emit REDIRECT for recurring error patterns
1139
+
1140
+ Check `errors.flagged_patterns[]` in COLONY_STATE.json for patterns that have appeared in 2+ phases:
1141
+
1142
+ ```bash
1143
+ flagged_patterns=$(jq -r '.errors.flagged_patterns[]? | select(.count >= 2) | .pattern' .aether/data/COLONY_STATE.json 2>/dev/null || true)
1144
+ ```
1145
+
1146
+ For each pattern returned by the above query, emit a REDIRECT signal:
1147
+
1148
+ ```bash
1149
+ bash .aether/aether-utils.sh pheromone-write REDIRECT "$pattern_text" \
1150
+ --strength 0.7 \
1151
+ --source "system" \
1152
+ --reason "Auto-emitted: error pattern recurred across 2+ phases" \
1153
+ --ttl "30d" 2>/dev/null || true
1154
+ ```
1155
+
1156
+ Also capture each recurring pattern as a resolution candidate:
1157
+
1158
+ ```bash
1159
+ bash .aether/aether-utils.sh memory-capture \
1160
+ "resolution" \
1161
+ "$pattern_text" \
1162
+ "pattern" \
1163
+ "worker:continue" 2>/dev/null || true
1164
+ ```
1165
+
1166
+ If `errors.flagged_patterns` doesn't exist or is empty, skip silently.
1167
+
1168
+ #### 2.1c: Expire phase_end signals and archive to midden
1169
+
1170
+ After auto-emission, expire all signals with `expires_at == "phase_end"`:
1171
+
1172
+ Run using the Bash tool with description "Maintaining pheromone memory...": `bash .aether/aether-utils.sh pheromone-expire --phase-end-only 2>/dev/null && bash .aether/aether-utils.sh eternal-init 2>/dev/null`
1173
+
1174
+ ### Step 2.1.5: Check for Promotion Proposals
1175
+
1176
+ After extracting learnings, check for observations that have met promotion thresholds and present the tick-to-approve UX.
1177
+
1178
+ **Normal proposal flow (MEM-01: Silent skip if empty):**
1179
+
1180
+ 1. **Check for proposals:**
1181
+ ```bash
1182
+ proposals=$(bash .aether/aether-utils.sh learning-check-promotion 2>/dev/null || echo '{"proposals":[]}')
1183
+ proposal_count=$(echo "$proposals" | jq '.proposals | length')
1184
+ ```
1185
+
1186
+ 2. **If proposals exist, invoke the approval workflow:**
1187
+
1188
+ Only show the approval UI when there are actual proposals to review:
1189
+
1190
+ ```bash
1191
+ if [[ "$proposal_count" -gt 0 ]]; then
1192
+ bash .aether/aether-utils.sh learning-approve-proposals
1193
+ fi
1194
+ # If no proposals, silently skip without notice
1195
+ ```
1196
+
1197
+ The learning-approve-proposals function handles:
1198
+ - Displaying proposals with checkbox UI
1199
+ - Capturing user selection
1200
+ - Executing batch promotions via queen-promote
1201
+ - Deferring unselected proposals
1202
+ - Offering undo after successful promotions
1203
+
1204
+ **Skip conditions:**
1205
+ - learning-check-promotion returns empty or fails
1206
+ - No proposals to review (silent skip - no output)
1207
+ - QUEEN.md does not exist
1208
+
1209
+ ### Step 2.2: Update Handoff Document
1210
+
1211
+ After advancing the phase, update the handoff document with the new current state:
1212
+
1213
+ ```bash
1214
+ # Determine if there's a next phase
1215
+ next_phase_id=$((current_phase + 1))
1216
+ has_next_phase=$(jq --arg next "$next_phase_id" '.plan.phases | map(select(.id == ($next | tonumber))) | length' .aether/data/COLONY_STATE.json)
1217
+
1218
+ # Write updated handoff
1219
+ cat > .aether/HANDOFF.md << 'HANDOFF_EOF'
1220
+ # Colony Session — Phase Advanced
1221
+
1222
+ ## Quick Resume
1223
+ Run `/ant:build {next_phase_id}` to start working on the current phase.
1224
+
1225
+ ## State at Advancement
1226
+ - Goal: "$(jq -r '.goal' .aether/data/COLONY_STATE.json)"
1227
+ - Completed Phase: {completed_phase_id} — {completed_phase_name}
1228
+ - Current Phase: {next_phase_id} — {next_phase_name}
1229
+ - State: READY
1230
+ - Updated: $(date -u +%Y-%m-%dT%H:%M:%SZ)
1231
+
1232
+ ## What Was Completed
1233
+ - Phase {completed_phase_id} marked as completed
1234
+ - Learnings extracted: {learning_count}
1235
+ - Instincts updated: {instinct_count}
1236
+
1237
+ ## Current Phase Tasks
1238
+ $(jq -r '.plan.phases[] | select(.id == next_phase_id) | .tasks[] | "- [ ] \(.id): \(.description)"' .aether/data/COLONY_STATE.json)
1239
+
1240
+ ## Next Steps
1241
+ - Build current phase: `/ant:build {next_phase_id}`
1242
+ - Review phase details: `/ant:phase {next_phase_id}`
1243
+ - Pause colony: `/ant:pause-colony`
1244
+
1245
+ ## Session Note
1246
+ Phase advanced successfully. Colony is READY to build Phase {next_phase_id}.
1247
+ HANDOFF_EOF
1248
+ ```
1249
+
1250
+ This handoff reflects the post-advancement state, allowing seamless resumption even if the session is lost.
1251
+
1252
+ ### Step 2.3: Update Changelog
1253
+
1254
+ **MANDATORY: Append a changelog entry for the completed phase. This step is never skipped.**
1255
+
1256
+ If no `CHANGELOG.md` exists, `changelog-append` creates one automatically.
1257
+
1258
+ **Step 2.3.1: Collect plan data**
1259
+
1260
+ ```bash
1261
+ bash .aether/aether-utils.sh changelog-collect-plan-data "{phase_identifier}" "{plan_number}"
1262
+ ```
1263
+
1264
+ Parse the returned JSON to extract `files`, `decisions`, `worked`, and `requirements` arrays.
1265
+
1266
+ - `{phase_identifier}` is the full phase name (e.g., `36-memory-capture`)
1267
+ - `{plan_number}` is the plan number (e.g., `01`)
1268
+
1269
+ If the command fails (e.g., no plan file found), fall back to collecting data manually:
1270
+ - Files: from `git diff --stat` of the completed phase
1271
+ - Decisions: from COLONY_STATE.json `memory.decisions` (last 5)
1272
+ - Worked/requirements: leave empty
1273
+
1274
+ **Step 2.3.2: Append changelog entry**
1275
+
1276
+ ```bash
1277
+ bash .aether/aether-utils.sh changelog-append \
1278
+ "$(date +%Y-%m-%d)" \
1279
+ "{phase_identifier}" \
1280
+ "{plan_number}" \
1281
+ "{files_csv}" \
1282
+ "{decisions_semicolon_separated}" \
1283
+ "{worked_semicolon_separated}" \
1284
+ "{requirements_csv}"
1285
+ ```
1286
+
1287
+ This atomically writes the entry. If the project already has a Keep a Changelog format, it adds a "Colony Work Log" separator section to keep both formats clean.
1288
+
1289
+ **Error handling:** If `changelog-append` fails, log to midden and continue — changelog failure never blocks phase advancement.
1290
+
1291
+ ### Step 2.4: Commit Suggestion (Optional)
1292
+
1293
+ **This step is non-blocking. Skipping does not affect phase advancement or any subsequent steps. Failure to commit has zero consequences.**
1294
+
1295
+ After the phase is advanced and changelog updated, suggest a commit to preserve the milestone.
1296
+
1297
+ 1. **Generate the commit message:**
1298
+ ```bash
1299
+ bash .aether/aether-utils.sh generate-commit-message "milestone" {phase_id} "{phase_name}" "{one_line_summary}"
1300
+ ```
1301
+ Parse the returned JSON to extract `message` and `files_changed`.
1302
+
1303
+ 2. **Check files changed:**
1304
+ ```bash
1305
+ git diff --stat HEAD 2>/dev/null | tail -5
1306
+ ```
1307
+ If not in a git repo or no changes detected, skip this step silently.
1308
+
1309
+ 3. **Display the suggestion:**
1310
+ ```
1311
+ ──────────────────────────────────────────────────
1312
+ Commit Suggestion
1313
+ ──────────────────────────────────────────────────
1314
+
1315
+ Message: {generated_message}
1316
+ Files: {files_changed} files changed
1317
+ Preview: {first 5 lines of git diff --stat}
1318
+
1319
+ ──────────────────────────────────────────────────
1320
+ ```
1321
+
1322
+ 4. **Use AskUserQuestion:**
1323
+ ```
1324
+ Commit this milestone?
1325
+
1326
+ 1. Yes, commit with this message
1327
+ 2. Yes, but let me write the message
1328
+ 3. No, I'll commit later
1329
+ ```
1330
+
1331
+ 5. **If option 1 ("Yes, commit with this message"):**
1332
+ ```bash
1333
+ git add -A && git commit -m "{generated_message}"
1334
+ ```
1335
+ Display: `Committed: {generated_message} ({files_changed} files)`
1336
+
1337
+ 6. **If option 2 ("Yes, but let me write the message"):**
1338
+ Use AskUserQuestion to get the user's custom commit message, then:
1339
+ ```bash
1340
+ git add -A && git commit -m "{custom_message}"
1341
+ ```
1342
+ Display: `Committed: {custom_message} ({files_changed} files)`
1343
+
1344
+ 7. **If option 3 ("No, I'll commit later"):**
1345
+ Display: `Skipped. Your changes are saved on disk but not committed.`
1346
+
1347
+ 8. **Record the suggestion to prevent double-prompting:**
1348
+ Set `last_commit_suggestion_phase` to `{phase_id}` in COLONY_STATE.json (add the field at the top level if it does not exist).
1349
+
1350
+ **Error handling:** If any git command fails (not a repo, merge conflict, pre-commit hook rejection), display the error output and continue to the next step. The commit suggestion is advisory only -- it never blocks the flow.
1351
+
1352
+ Continue to Step 2.5 (Context Clear Suggestion), then to Step 2.7 (Project Completion) or Step 3 (Display Result).
1353
+
1354
+ ### Step 2.5: Context Clear Suggestion (Optional)
1355
+
1356
+ **This step is non-blocking. Skipping does not affect phase advancement.**
1357
+
1358
+ After committing (or skipping commit), suggest clearing context to refresh before the next phase.
1359
+
1360
+ 1. **Display the suggestion:**
1361
+ ```
1362
+ ──────────────────────────────────────────────────
1363
+ Context Refresh
1364
+ ──────────────────────────────────────────────────
1365
+
1366
+ State is fully persisted and committed.
1367
+ Phase {next_id} is ready to build.
1368
+
1369
+ ──────────────────────────────────────────────────
1370
+ ```
1371
+
1372
+ 2. **Use AskUserQuestion:**
1373
+ ```
1374
+ Clear context now?
1375
+
1376
+ 1. Yes, clear context then run /ant:build {next_id}
1377
+ 2. No, continue in current context
1378
+ ```
1379
+
1380
+ 3. **If option 1 ("Yes, clear context"):**
1381
+
1382
+ **IMPORTANT:** Most AI platforms do not support programmatic context clearing. Display instructions:
1383
+ ```
1384
+ Please clear your context/conversation, then run: /ant:build {next_id}
1385
+ ```
1386
+
1387
+ Record the suggestion: Set `context_clear_suggested` to `true` in COLONY_STATE.json.
1388
+
1389
+ 4. **If option 2 ("No, continue in current context"):**
1390
+ Display: `Continuing in current context. State is saved.`
1391
+
1392
+ Continue to Step 2.6 (Context Update), then Step 2.7 (Project Completion) or Step 3 (Display Result).
1393
+
1394
+ ### Step 2.6: Update Context Document
1395
+
1396
+ After phase advancement is complete, update `.aether/CONTEXT.md`:
1397
+
1398
+ **Log the activity:**
1399
+ ```bash
1400
+ bash .aether/aether-utils.sh context-update activity "continue" "Phase {prev_id} completed, advanced to {next_id}" "---"
1401
+ ```
1402
+
1403
+ **Update the phase:**
1404
+ ```bash
1405
+ bash .aether/aether-utils.sh context-update update-phase {next_id} "{next_phase_name}" "YES" "Phase advanced, ready to build"
1406
+ ```
1407
+
1408
+ **Log any decisions from this session:**
1409
+ If any architectural decisions were made during verification, also run:
1410
+ ```bash
1411
+ bash .aether/aether-utils.sh context-update decision "{decision_description}" "{rationale}" "Queen"
1412
+ ```
1413
+
1414
+ ### Step 2.7: Project Completion
1415
+
1416
+ Runs ONLY when all phases complete.
1417
+
1418
+ 1. Read activity.log and errors.records
1419
+ 2. Display tech debt report:
1420
+
1421
+ ```
1422
+ 🐜 ═══════════════════════════════════════════════════
1423
+ 🎉 P R O J E C T C O M P L E T E 🎉
1424
+ ═══════════════════════════════════════════════════ 🐜
1425
+
1426
+ 👑 Goal Achieved: {goal}
1427
+ 📍 Phases Completed: {total}
1428
+
1429
+ {if flagged_patterns:}
1430
+ ⚠️ Persistent Issues:
1431
+ {list any flagged_patterns}
1432
+ {end if}
1433
+
1434
+ 🧠 Colony Learnings:
1435
+ {condensed learnings from memory.phase_learnings}
1436
+
1437
+ 🐜 The colony rests. Well done!
1438
+ ```
1439
+
1440
+ 3. Write summary to `.aether/data/completion-report.md`
1441
+ 4. Display next commands and stop.
1442
+
1443
+ ### Step 3: Display Result
1444
+
1445
+ Output:
1446
+
1447
+ ```
1448
+ 🐜 ═══════════════════════════════════════════════════
1449
+ P H A S E A D V A N C E M E N T
1450
+ ═══════════════════════════════════════════════════ 🐜
1451
+
1452
+ ✅ Phase {prev_id}: {prev_name} -- COMPLETED
1453
+
1454
+ 🧠 Learnings Extracted:
1455
+ {list learnings added}
1456
+
1457
+ 🐜 Instincts Updated:
1458
+ {for each instinct created or updated:}
1459
+ [{confidence}] {domain}: {action}
1460
+ {end for}
1461
+
1462
+ ─────────────────────────────────────────────────────
1463
+
1464
+ ➡️ Advancing to Phase {next_id}: {next_name}
1465
+ {next_description}
1466
+ 📋 Tasks: {task_count}
1467
+ 📊 State: READY
1468
+
1469
+ 🐜 Next Steps:
1470
+ /ant:build {next_id} 🔨 Start building Phase {next_id}: {next_name}
1471
+ /ant:phase {next_id} 📋 Review phase details first
1472
+ /ant:focus "<area>" 🎯 Guide colony attention
1473
+
1474
+ 💾 State persisted — context clear suggested above
1475
+ ```
1476
+
1477
+ **IMPORTANT:** In the "Next Steps" section above, substitute the actual phase number for `{next_id}` (calculated in Step 2 as `current_phase + 1`). For example, if advancing to phase 4, output `/ant:build 4` not `/ant:build {next_id}`.
1478
+
1479
+ ### Step 4: Update Session
1480
+
1481
+ Update the session tracking file to enable `/ant:resume` after context clear:
1482
+
1483
+ Run using the Bash tool with description "Saving session state...": `bash .aether/aether-utils.sh session-update "/ant:continue" "/ant:build {next_id}" "Phase {prev_id} completed, advanced to Phase {next_id}"`
1484
+