aether-colony 5.0.0 → 5.1.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (312) hide show
  1. package/.aether/aether-utils.sh +3150 -3349
  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 +438 -0
  30. package/.aether/commands/continue.yaml +1484 -0
  31. package/.aether/commands/council.yaml +304 -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 +469 -0
  44. package/.aether/commands/insert-phase.yaml +98 -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 +1313 -0
  57. package/.aether/commands/preferences.yaml +63 -0
  58. package/.aether/commands/redirect.yaml +123 -0
  59. package/.aether/commands/resume-colony.yaml +373 -0
  60. package/.aether/commands/resume.yaml +398 -0
  61. package/.aether/commands/run.yaml +193 -0
  62. package/.aether/commands/seal.yaml +1205 -0
  63. package/.aether/commands/skill-create.yaml +337 -0
  64. package/.aether/commands/status.yaml +364 -0
  65. package/.aether/commands/swarm.yaml +352 -0
  66. package/.aether/commands/tunnels.yaml +814 -0
  67. package/.aether/commands/update.yaml +131 -0
  68. package/.aether/commands/verify-castes.yaml +159 -0
  69. package/.aether/commands/watch.yaml +454 -0
  70. package/.aether/docs/INCIDENT_TEMPLATE.md +32 -0
  71. package/.aether/docs/QUEEN-SYSTEM.md +11 -11
  72. package/.aether/docs/README.md +32 -2
  73. package/.aether/docs/command-playbooks/README.md +23 -0
  74. package/.aether/docs/command-playbooks/build-complete.md +349 -0
  75. package/.aether/docs/command-playbooks/build-context.md +282 -0
  76. package/.aether/docs/command-playbooks/build-full.md +1682 -0
  77. package/.aether/docs/command-playbooks/build-prep.md +283 -0
  78. package/.aether/docs/command-playbooks/build-verify.md +405 -0
  79. package/.aether/docs/command-playbooks/build-wave.md +749 -0
  80. package/.aether/docs/command-playbooks/continue-advance.md +524 -0
  81. package/.aether/docs/command-playbooks/continue-finalize.md +447 -0
  82. package/.aether/docs/command-playbooks/continue-full.md +1724 -0
  83. package/.aether/docs/command-playbooks/continue-gates.md +686 -0
  84. package/.aether/docs/command-playbooks/continue-verify.md +406 -0
  85. package/.aether/docs/context-continuity.md +84 -0
  86. package/.aether/docs/disciplines/DISCIPLINES.md +9 -7
  87. package/.aether/docs/error-codes.md +1 -1
  88. package/.aether/docs/known-issues.md +34 -173
  89. package/.aether/docs/pheromones.md +86 -6
  90. package/.aether/docs/plans/pheromone-display-plan.md +257 -0
  91. package/.aether/docs/queen-commands.md +10 -9
  92. package/.aether/docs/source-of-truth-map.md +132 -0
  93. package/.aether/docs/xml-utilities.md +47 -0
  94. package/.aether/rules/aether-colony.md +23 -13
  95. package/.aether/scripts/incident-test-add.sh +47 -0
  96. package/.aether/scripts/weekly-audit.sh +79 -0
  97. package/.aether/skills/.index.json +649 -0
  98. package/.aether/skills/colony/.manifest.json +16 -0
  99. package/.aether/skills/colony/build-discipline/SKILL.md +78 -0
  100. package/.aether/skills/colony/colony-interaction/SKILL.md +56 -0
  101. package/.aether/skills/colony/colony-lifecycle/SKILL.md +77 -0
  102. package/.aether/skills/colony/colony-visuals/SKILL.md +112 -0
  103. package/.aether/skills/colony/context-management/SKILL.md +80 -0
  104. package/.aether/skills/colony/error-presentation/SKILL.md +99 -0
  105. package/.aether/skills/colony/pheromone-protocol/SKILL.md +79 -0
  106. package/.aether/skills/colony/pheromone-visibility/SKILL.md +81 -0
  107. package/.aether/skills/colony/state-safety/SKILL.md +84 -0
  108. package/.aether/skills/colony/worker-priming/SKILL.md +82 -0
  109. package/.aether/skills/domain/.manifest.json +24 -0
  110. package/.aether/skills/domain/README.md +33 -0
  111. package/.aether/skills/domain/django/SKILL.md +49 -0
  112. package/.aether/skills/domain/docker/SKILL.md +52 -0
  113. package/.aether/skills/domain/golang/SKILL.md +52 -0
  114. package/.aether/skills/domain/graphql/SKILL.md +51 -0
  115. package/.aether/skills/domain/html-css/SKILL.md +48 -0
  116. package/.aether/skills/domain/nextjs/SKILL.md +45 -0
  117. package/.aether/skills/domain/nodejs/SKILL.md +53 -0
  118. package/.aether/skills/domain/postgresql/SKILL.md +53 -0
  119. package/.aether/skills/domain/prisma/SKILL.md +59 -0
  120. package/.aether/skills/domain/python/SKILL.md +50 -0
  121. package/.aether/skills/domain/rails/SKILL.md +52 -0
  122. package/.aether/skills/domain/react/SKILL.md +45 -0
  123. package/.aether/skills/domain/rest-api/SKILL.md +58 -0
  124. package/.aether/skills/domain/svelte/SKILL.md +47 -0
  125. package/.aether/skills/domain/tailwind/SKILL.md +45 -0
  126. package/.aether/skills/domain/testing/SKILL.md +53 -0
  127. package/.aether/skills/domain/typescript/SKILL.md +58 -0
  128. package/.aether/skills/domain/vue/SKILL.md +49 -0
  129. package/.aether/templates/QUEEN.md.template +23 -41
  130. package/.aether/templates/colony-state-reset.jq.template +1 -0
  131. package/.aether/templates/colony-state.template.json +4 -0
  132. package/.aether/templates/learning-observations.template.json +6 -0
  133. package/.aether/templates/midden.template.json +13 -0
  134. package/.aether/templates/pheromones.template.json +6 -0
  135. package/.aether/templates/session.template.json +9 -0
  136. package/.aether/utils/atomic-write.sh +63 -17
  137. package/.aether/utils/chamber-utils.sh +145 -2
  138. package/.aether/utils/emoji-audit.sh +166 -0
  139. package/.aether/utils/error-handler.sh +21 -7
  140. package/.aether/utils/file-lock.sh +182 -27
  141. package/.aether/utils/flag.sh +267 -0
  142. package/.aether/utils/hive.sh +572 -0
  143. package/.aether/utils/learning.sh +1928 -0
  144. package/.aether/utils/midden.sh +342 -0
  145. package/.aether/utils/oracle/oracle.md +168 -0
  146. package/.aether/utils/oracle/oracle.sh +1023 -0
  147. package/.aether/utils/pheromone.sh +2029 -0
  148. package/.aether/utils/queen.sh +1698 -0
  149. package/.aether/utils/scan.sh +860 -0
  150. package/.aether/utils/semantic-cli.sh +10 -8
  151. package/.aether/utils/session.sh +552 -0
  152. package/.aether/utils/skills.sh +509 -0
  153. package/.aether/utils/spawn-tree.sh +103 -271
  154. package/.aether/utils/spawn.sh +260 -0
  155. package/.aether/utils/state-api.sh +199 -0
  156. package/.aether/utils/state-loader.sh +8 -6
  157. package/.aether/utils/suggest.sh +611 -0
  158. package/.aether/utils/swarm-display.sh +10 -1
  159. package/.aether/utils/swarm.sh +1004 -0
  160. package/.aether/utils/watch-spawn-tree.sh +11 -2
  161. package/.aether/utils/xml-compose.sh +2 -2
  162. package/.aether/utils/xml-convert.sh +9 -5
  163. package/.aether/utils/xml-core.sh +5 -9
  164. package/.aether/utils/xml-query.sh +4 -4
  165. package/.aether/workers.md +86 -67
  166. package/.claude/agents/ant/aether-ambassador.md +2 -1
  167. package/.claude/agents/ant/aether-archaeologist.md +6 -1
  168. package/.claude/agents/ant/aether-architect.md +236 -0
  169. package/.claude/agents/ant/aether-auditor.md +6 -1
  170. package/.claude/agents/ant/aether-builder.md +38 -1
  171. package/.claude/agents/ant/aether-chaos.md +2 -1
  172. package/.claude/agents/ant/aether-chronicler.md +1 -0
  173. package/.claude/agents/ant/aether-gatekeeper.md +6 -1
  174. package/.claude/agents/ant/aether-includer.md +1 -0
  175. package/.claude/agents/ant/aether-keeper.md +1 -0
  176. package/.claude/agents/ant/aether-measurer.md +6 -1
  177. package/.claude/agents/ant/aether-oracle.md +237 -0
  178. package/.claude/agents/ant/aether-probe.md +2 -1
  179. package/.claude/agents/ant/aether-queen.md +6 -1
  180. package/.claude/agents/ant/aether-route-setter.md +6 -1
  181. package/.claude/agents/ant/aether-sage.md +68 -3
  182. package/.claude/agents/ant/aether-scout.md +38 -1
  183. package/.claude/agents/ant/aether-surveyor-disciplines.md +2 -1
  184. package/.claude/agents/ant/aether-surveyor-nest.md +2 -1
  185. package/.claude/agents/ant/aether-surveyor-pathogens.md +2 -1
  186. package/.claude/agents/ant/aether-surveyor-provisions.md +2 -1
  187. package/.claude/agents/ant/aether-tracker.md +6 -1
  188. package/.claude/agents/ant/aether-watcher.md +37 -1
  189. package/.claude/agents/ant/aether-weaver.md +2 -1
  190. package/.claude/commands/ant/archaeology.md +1 -8
  191. package/.claude/commands/ant/build.md +43 -1159
  192. package/.claude/commands/ant/chaos.md +1 -14
  193. package/.claude/commands/ant/colonize.md +1 -14
  194. package/.claude/commands/ant/continue.md +40 -1026
  195. package/.claude/commands/ant/council.md +9 -16
  196. package/.claude/commands/ant/data-clean.md +81 -0
  197. package/.claude/commands/ant/dream.md +12 -9
  198. package/.claude/commands/ant/entomb.md +62 -87
  199. package/.claude/commands/ant/export-signals.md +57 -0
  200. package/.claude/commands/ant/feedback.md +18 -0
  201. package/.claude/commands/ant/flag.md +12 -0
  202. package/.claude/commands/ant/flags.md +22 -8
  203. package/.claude/commands/ant/focus.md +18 -0
  204. package/.claude/commands/ant/help.md +40 -8
  205. package/.claude/commands/ant/history.md +3 -0
  206. package/.claude/commands/ant/import-signals.md +71 -0
  207. package/.claude/commands/ant/init.md +316 -191
  208. package/.claude/commands/ant/insert-phase.md +101 -0
  209. package/.claude/commands/ant/interpret.md +11 -0
  210. package/.claude/commands/ant/lay-eggs.md +167 -158
  211. package/.claude/commands/ant/maturity.md +22 -11
  212. package/.claude/commands/ant/memory-details.md +77 -0
  213. package/.claude/commands/ant/migrate-state.md +6 -0
  214. package/.claude/commands/ant/oracle.md +317 -62
  215. package/.claude/commands/ant/organize.md +10 -5
  216. package/.claude/commands/ant/patrol.md +620 -0
  217. package/.claude/commands/ant/pause-colony.md +8 -22
  218. package/.claude/commands/ant/phase.md +26 -37
  219. package/.claude/commands/ant/pheromones.md +156 -0
  220. package/.claude/commands/ant/plan.md +175 -52
  221. package/.claude/commands/ant/preferences.md +65 -0
  222. package/.claude/commands/ant/redirect.md +18 -0
  223. package/.claude/commands/ant/resume-colony.md +34 -20
  224. package/.claude/commands/ant/resume.md +51 -7
  225. package/.claude/commands/ant/run.md +195 -0
  226. package/.claude/commands/ant/seal.md +497 -78
  227. package/.claude/commands/ant/skill-create.md +286 -0
  228. package/.claude/commands/ant/status.md +127 -1
  229. package/.claude/commands/ant/swarm.md +11 -23
  230. package/.claude/commands/ant/tunnels.md +1 -0
  231. package/.claude/commands/ant/update.md +58 -135
  232. package/.claude/commands/ant/verify-castes.md +90 -42
  233. package/.claude/commands/ant/watch.md +1 -0
  234. package/.opencode/agents/aether-ambassador.md +1 -1
  235. package/.opencode/agents/aether-architect.md +133 -0
  236. package/.opencode/agents/aether-builder.md +3 -3
  237. package/.opencode/agents/aether-oracle.md +137 -0
  238. package/.opencode/agents/aether-queen.md +1 -1
  239. package/.opencode/agents/aether-route-setter.md +1 -1
  240. package/.opencode/agents/aether-scout.md +1 -1
  241. package/.opencode/agents/aether-surveyor-disciplines.md +6 -1
  242. package/.opencode/agents/aether-surveyor-nest.md +6 -1
  243. package/.opencode/agents/aether-surveyor-pathogens.md +6 -1
  244. package/.opencode/agents/aether-surveyor-provisions.md +6 -1
  245. package/.opencode/agents/aether-tracker.md +1 -1
  246. package/.opencode/agents/aether-watcher.md +1 -1
  247. package/.opencode/agents/aether-weaver.md +1 -1
  248. package/.opencode/commands/ant/archaeology.md +7 -14
  249. package/.opencode/commands/ant/build.md +54 -88
  250. package/.opencode/commands/ant/chaos.md +7 -24
  251. package/.opencode/commands/ant/colonize.md +8 -17
  252. package/.opencode/commands/ant/continue.md +595 -66
  253. package/.opencode/commands/ant/council.md +11 -22
  254. package/.opencode/commands/ant/data-clean.md +77 -0
  255. package/.opencode/commands/ant/dream.md +15 -17
  256. package/.opencode/commands/ant/entomb.md +28 -18
  257. package/.opencode/commands/ant/export-signals.md +54 -0
  258. package/.opencode/commands/ant/feedback.md +24 -5
  259. package/.opencode/commands/ant/flag.md +16 -4
  260. package/.opencode/commands/ant/flags.md +24 -10
  261. package/.opencode/commands/ant/focus.md +22 -5
  262. package/.opencode/commands/ant/help.md +41 -8
  263. package/.opencode/commands/ant/history.md +9 -0
  264. package/.opencode/commands/ant/import-signals.md +68 -0
  265. package/.opencode/commands/ant/init.md +365 -156
  266. package/.opencode/commands/ant/insert-phase.md +107 -0
  267. package/.opencode/commands/ant/interpret.md +16 -0
  268. package/.opencode/commands/ant/lay-eggs.md +184 -112
  269. package/.opencode/commands/ant/maturity.md +18 -2
  270. package/.opencode/commands/ant/memory-details.md +83 -0
  271. package/.opencode/commands/ant/migrate-state.md +12 -0
  272. package/.opencode/commands/ant/oracle.md +322 -67
  273. package/.opencode/commands/ant/organize.md +14 -12
  274. package/.opencode/commands/ant/patrol.md +626 -0
  275. package/.opencode/commands/ant/pause-colony.md +12 -29
  276. package/.opencode/commands/ant/phase.md +30 -40
  277. package/.opencode/commands/ant/pheromones.md +162 -0
  278. package/.opencode/commands/ant/plan.md +184 -56
  279. package/.opencode/commands/ant/preferences.md +71 -0
  280. package/.opencode/commands/ant/redirect.md +22 -5
  281. package/.opencode/commands/ant/resume-colony.md +38 -27
  282. package/.opencode/commands/ant/resume.md +71 -20
  283. package/.opencode/commands/ant/run.md +201 -0
  284. package/.opencode/commands/ant/seal.md +230 -25
  285. package/.opencode/commands/ant/skill-create.md +63 -0
  286. package/.opencode/commands/ant/status.md +124 -31
  287. package/.opencode/commands/ant/swarm.md +3 -345
  288. package/.opencode/commands/ant/tunnels.md +3 -9
  289. package/.opencode/commands/ant/update.md +63 -127
  290. package/.opencode/commands/ant/verify-castes.md +96 -42
  291. package/.opencode/commands/ant/watch.md +7 -0
  292. package/CHANGELOG.md +278 -1
  293. package/README.md +188 -340
  294. package/bin/cli.js +236 -429
  295. package/bin/generate-commands.js +186 -0
  296. package/bin/generate-commands.sh +128 -89
  297. package/bin/lib/spawn-logger.js +0 -15
  298. package/bin/lib/update-transaction.js +285 -35
  299. package/bin/npx-install.js +178 -0
  300. package/bin/validate-package.sh +85 -3
  301. package/package.json +7 -3
  302. package/.aether/CONTEXT.md +0 -160
  303. package/.aether/docs/QUEEN.md +0 -84
  304. package/.aether/exchange/colony-registry.xml +0 -11
  305. package/.aether/exchange/pheromones.xml +0 -87
  306. package/.aether/exchange/queen-wisdom.xml +0 -14
  307. package/.aether/model-profiles.yaml +0 -100
  308. package/.aether/utils/spawn-with-model.sh +0 -56
  309. package/bin/lib/model-profiles.js +0 -445
  310. package/bin/lib/model-verify.js +0 -288
  311. package/bin/lib/proxy-health.js +0 -253
  312. package/bin/lib/telemetry.js +0 -441
@@ -0,0 +1,524 @@
1
+ ### Step 2: Update State
2
+
3
+ Find current phase in `plan.phases`.
4
+ Determine next phase (`current_phase + 1`).
5
+
6
+ **If no next phase (all complete):** Skip to Step 2.4 (commit suggestion), then Step 2.7 (completion).
7
+
8
+ Update COLONY_STATE.json:
9
+
10
+ 1. **Mark current phase completed:**
11
+ - Set `plan.phases[current].status` to `"completed"`
12
+ - Set all tasks in phase to `"completed"`
13
+
14
+ 2. **Extract learnings (with validation status):**
15
+
16
+ **CRITICAL: Learnings start as HYPOTHESES until verified.**
17
+
18
+ A learning is only "validated" if:
19
+ - The code was actually run and tested
20
+ - The feature works in practice, not just in theory
21
+ - User has confirmed the behavior
22
+
23
+ Append to `memory.phase_learnings`:
24
+ ```json
25
+ {
26
+ "id": "learning_<unix_timestamp>",
27
+ "phase": <phase_number>,
28
+ "phase_name": "<name>",
29
+ "learnings": [
30
+ {
31
+ "claim": "<specific actionable learning>",
32
+ "status": "hypothesis",
33
+ "tested": false,
34
+ "evidence": "<what observation led to this>",
35
+ "disproven_by": null
36
+ }
37
+ ],
38
+ "timestamp": "<ISO-8601>"
39
+ }
40
+ ```
41
+
42
+ **Status values:**
43
+ - `hypothesis` - Recorded but not verified (DEFAULT)
44
+ - `validated` - Tested and confirmed working
45
+ - `disproven` - Found to be incorrect
46
+
47
+ **Do NOT record a learning if:**
48
+ - It wasn't actually tested
49
+ - It's stating the obvious
50
+ - There's no evidence it works
51
+
52
+ 2.4. **Deterministic fallback extraction (when AI learnings are empty):**
53
+
54
+ If the builder produced no learnings (empty or missing `learning.patterns_observed` in synthesis JSON),
55
+ fire the git-diff-based fallback to extract learnings deterministically.
56
+
57
+ ```bash
58
+ # Check if learnings were extracted from synthesis
59
+ patterns_count=$(jq '[.memory.phase_learnings[-1].learnings // []] | add | length' .aether/data/COLONY_STATE.json 2>/dev/null || echo "0")
60
+ fallback_count=0
61
+
62
+ if [[ "$patterns_count" -eq 0 ]]; then
63
+ # Builder skipped learning output -- fire deterministic fallback
64
+ fallback_result=$(bash .aether/aether-utils.sh learning-extract-fallback 2>/dev/null || echo '{"learnings":[],"count":0}')
65
+ fallback_count=$(echo "$fallback_result" | jq '.result.count // 0')
66
+ fi
67
+
68
+ # Echo for cross-stage capture (same pattern as hive_promoted_count)
69
+ echo "fallback_count=$fallback_count"
70
+ ```
71
+
72
+ This is NON-BLOCKING -- if learning-extract-fallback fails, fallback_count stays 0 and no learnings are lost (they just aren't recorded this time).
73
+
74
+ **Cross-stage variable passing:** The `fallback_count` value is output via echo for capture in continue-finalize.md's wisdom summary.
75
+
76
+ 2.5. **Capture learnings through memory pipeline:**
77
+
78
+ For each learning extracted, run the memory pipeline (observation + auto-pheromone + auto-promotion check).
79
+
80
+ Run using the Bash tool with description "Recording learning observations...":
81
+ ```bash
82
+ colony_name=$(bash .aether/aether-utils.sh colony-name 2>/dev/null | jq -r '.result.name // ""')
83
+ [[ -z "$colony_name" ]] && colony_name="unknown"
84
+
85
+ # Get learnings from the current phase
86
+ current_phase_learnings=$(jq -r --argjson phase "$current_phase" '.memory.phase_learnings[] | select(.phase == $phase)' .aether/data/COLONY_STATE.json 2>/dev/null || echo "")
87
+
88
+ if [[ -n "$current_phase_learnings" ]]; then
89
+ echo "$current_phase_learnings" | jq -r '.learnings[]?.claim // empty' 2>/dev/null | while read -r claim; do
90
+ if [[ -n "$claim" ]]; then
91
+ bash .aether/aether-utils.sh memory-capture "learning" "$claim" "pattern" "worker:continue" 2>/dev/null || true
92
+ fi
93
+ done
94
+ echo "Recorded observations for threshold tracking"
95
+ else
96
+ echo "No learnings to record"
97
+ fi
98
+ ```
99
+
100
+ This records each learning in `learning-observations.json` with:
101
+ - Content hash for deduplication (same claim across phases increments count)
102
+ - Observation count (increments if seen before)
103
+ - Colony name for cross-colony tracking
104
+
105
+ Memory capture also auto-emits a FEEDBACK pheromone and attempts auto-promotion when recurrence policy is met.
106
+
107
+ 3. **Extract instincts from phase patterns:**
108
+
109
+ Review the completed phase for repeating patterns. For each pattern observed:
110
+
111
+ Run using the Bash tool with description "Creating instinct from pattern...":
112
+ ```bash
113
+ bash .aether/aether-utils.sh instinct-create \
114
+ --trigger "<when this situation arises>" \
115
+ --action "<what worked or should be done>" \
116
+ --confidence <0.7-0.9 based on evidence strength> \
117
+ --domain "<testing|architecture|code-style|debugging|workflow>" \
118
+ --source "phase-{id}" \
119
+ --evidence "<specific observation>" 2>/dev/null || true
120
+ ```
121
+
122
+ Confidence guidelines:
123
+ - Base 0.7 for observation_count=1, increasing by 0.05 per additional observation, cap 0.9
124
+ - 0.8: error_resolution (fixed a recurring problem, or observation_count=3)
125
+ - 0.9: user_feedback (explicit user guidance, or observation_count=5+)
126
+ - When observation count is available from learning-observations.json, use formula: min(0.7 + (count-1)*0.05, 0.9)
127
+
128
+ If pattern matches existing instinct, confidence will be boosted automatically.
129
+ Cap: max 30 instincts enforced by `instinct-create` (lowest confidence evicted).
130
+
131
+ 3a. **Extract instincts from recurring error patterns (midden):**
132
+
133
+ Query the midden for recent failures and create instincts from recurring patterns:
134
+
135
+ Run using the Bash tool with description "Checking midden for error patterns...":
136
+ ```bash
137
+ midden_result=$(bash .aether/aether-utils.sh midden-recent-failures 10 2>/dev/null || echo '{"count":0,"failures":[]}')
138
+ midden_count=$(echo "$midden_result" | jq '.count // 0')
139
+ ```
140
+
141
+ If `midden_count` > 0, review the failure entries for recurring patterns (same category or similar message appearing 2+ times). For each recurring error pattern found:
142
+
143
+ Run using the Bash tool with description "Creating instinct from error pattern...":
144
+ ```bash
145
+ bash .aether/aether-utils.sh instinct-create \
146
+ --trigger "<when this error condition arises>" \
147
+ --action "<how to avoid or handle this error>" \
148
+ --confidence 0.8 \
149
+ --domain "<testing|architecture|debugging>" \
150
+ --source "midden-phase-{id}" \
151
+ --evidence "<failure message and recurrence count>" 2>/dev/null || true
152
+ ```
153
+
154
+ Error pattern confidence is 0.8 (higher than success patterns) because recurring failures are strong negative signals.
155
+ If no recurring patterns found, skip silently.
156
+
157
+ 3b. **Extract instincts from success patterns:**
158
+
159
+ Review the completed phase for approaches that succeeded on the first attempt or produced notably clean results. For each success pattern:
160
+
161
+ Run using the Bash tool with description "Creating instinct from success pattern...":
162
+ ```bash
163
+ bash .aether/aether-utils.sh instinct-create \
164
+ --trigger "<when this type of task arises>" \
165
+ --action "<the approach that worked well>" \
166
+ --confidence 0.7 \ # Base value; increase if observation_count > 1 per formula
167
+ --domain "<testing|architecture|code-style|workflow>" \
168
+ --source "success-phase-{id}" \
169
+ --evidence "<what succeeded and why>" 2>/dev/null || true
170
+ ```
171
+
172
+ Success pattern confidence is 0.7 (base; calibrate with observation count if available). Only create success instincts for genuinely noteworthy approaches, not routine completions.
173
+ Cap: limit to 2 success instincts per phase to avoid noise.
174
+
175
+ 3c. **Promote high-confidence instincts to QUEEN.md (QUEEN-02):**
176
+
177
+ After instinct creation (Steps 3/3a/3b), sweep all instincts for confidence >= 0.8
178
+ and promote to the QUEEN.md Instincts section. This runs every /ant:continue to catch
179
+ newly boosted instincts.
180
+
181
+ Run using the Bash tool with description "Promoting high-confidence instincts to QUEEN.md...":
182
+ ```bash
183
+ instinct_data=$(jq -r '.memory.instincts // []' .aether/data/COLONY_STATE.json 2>/dev/null || echo '[]')
184
+ promoted_instinct_count=0
185
+
186
+ for encoded in $(echo "$instinct_data" | jq -r '.[] | select(.confidence >= 0.8) | @base64'); do
187
+ trigger=$(echo "$encoded" | base64 -d | jq -r '.trigger')
188
+ action=$(echo "$encoded" | base64 -d | jq -r '.action')
189
+ confidence=$(echo "$encoded" | base64 -d | jq -r '.confidence')
190
+ domain=$(echo "$encoded" | base64 -d | jq -r '.domain // "workflow"')
191
+
192
+ # queen-promote-instinct handles dedup internally (skips if already in QUEEN.md)
193
+ result=$(bash .aether/aether-utils.sh queen-promote-instinct \
194
+ "$trigger" "$action" "$confidence" "$domain" 2>/dev/null || echo '{"ok":false}')
195
+
196
+ was_promoted=$(echo "$result" | jq -r '.result.promoted // false' 2>/dev/null || echo "false")
197
+ if [[ "$was_promoted" == "true" ]]; then
198
+ promoted_instinct_count=$((promoted_instinct_count + 1))
199
+ fi
200
+ done
201
+
202
+ if [[ $promoted_instinct_count -gt 0 ]]; then
203
+ echo "Promoted $promoted_instinct_count instinct(s) to QUEEN.md"
204
+ fi
205
+ ```
206
+
207
+ This step is NON-BLOCKING -- if queen-promote-instinct fails for any entry, log and continue.
208
+ The dedup check inside queen-promote-instinct ensures idempotency (safe to run repeatedly).
209
+
210
+ 3d. **Hive Promotion (NON-BLOCKING):**
211
+
212
+ After QUEEN.md promotion, promote abstracted instincts to the cross-colony hive.
213
+
214
+ Run using the Bash tool with description "Promoting high-confidence instincts to hive...":
215
+ ```bash
216
+ # Get instincts with confidence >= 0.8
217
+ high_conf_instincts=$(jq -r '.memory.instincts[] | select(.confidence >= 0.8) | @base64' .aether/data/COLONY_STATE.json 2>/dev/null || echo "")
218
+
219
+ # Derive source repo name from current directory
220
+ source_repo="$(pwd)"
221
+
222
+ # Read domain tags from registry (NOT from instinct.domain which is a category, not a repo domain)
223
+ repo_domain_tags=$(jq -r --arg repo "$(pwd)" \
224
+ '[.repos[] | select(.path == $repo) | .domain_tags // []] | .[0] // [] | join(",")' \
225
+ "$HOME/.aether/registry.json" 2>/dev/null || echo "")
226
+
227
+ hive_promoted_count=0
228
+ hive_errors=0
229
+ for encoded in $high_conf_instincts; do
230
+ [[ -z "$encoded" ]] && continue
231
+
232
+ # Extract trigger and action fields from the instinct object
233
+ trigger=$(echo "$encoded" | base64 -d | jq -r '.trigger // empty')
234
+ action=$(echo "$encoded" | base64 -d | jq -r '.action // empty')
235
+ confidence=$(echo "$encoded" | base64 -d | jq -r '.confidence // 0.7')
236
+
237
+ [[ -z "$trigger" || -z "$action" ]] && continue
238
+
239
+ # Strip leading "When " or "when " from trigger to avoid "When When..." stutter
240
+ trigger_clean=$(echo "$trigger" | sed 's/^[Ww]hen //')
241
+
242
+ # Build the promotion text in "When {trigger}: {action}" format
243
+ promote_text="When ${trigger_clean}: ${action}"
244
+
245
+ # Build hive-promote args with --text and --source-repo (required)
246
+ promote_args=(hive-promote --text "$promote_text" --source-repo "$source_repo" --confidence "$confidence")
247
+ [[ -n "$repo_domain_tags" ]] && promote_args+=(--domain "$repo_domain_tags")
248
+
249
+ # Call hive-promote which orchestrates abstract + store
250
+ result=$(bash .aether/aether-utils.sh "${promote_args[@]}" 2>/dev/null || echo '{}')
251
+ was_promoted=$(echo "$result" | jq -r '.result.action // "skipped"' 2>/dev/null || echo "skipped")
252
+
253
+ if [[ "$was_promoted" == "promoted" || "$was_promoted" == "merged" ]]; then
254
+ hive_promoted_count=$((hive_promoted_count + 1))
255
+ else
256
+ hive_errors=$((hive_errors + 1))
257
+ fi
258
+ done
259
+
260
+ if [[ "$hive_promoted_count" -gt 0 ]]; then
261
+ echo "Hive promotion: $hive_promoted_count instinct(s) promoted to cross-colony hive"
262
+ fi
263
+
264
+ # Store results for cross-stage summary line
265
+ echo "hive_promoted_count=$hive_promoted_count"
266
+ hive_error=$([[ $hive_errors -gt 0 ]] && echo 'true' || echo 'false')
267
+ echo "hive_error=$hive_error"
268
+ ```
269
+
270
+ This step promotes high-confidence instincts to the cross-colony hive. It runs every /ant:continue and is idempotent -- hive-store deduplicates via SHA-256, so re-promoting existing instincts is safe.
271
+
272
+ NON-BLOCKING: hive promotion failures never stop the continue flow.
273
+
274
+ **Cross-stage variable passing:** The `hive_promoted_count` and `hive_error` values are output via echo for cross-stage capture. **IMPORTANT:** When executing continue-finalize.md after this step, Claude must capture these echoed values from the advance output and pass them as variables when running the finalize wisdom summary code. Shell variables do not persist between Bash tool invocations, so this explicit capture-and-forward step is required.
275
+
276
+ 4. **Advance state:**
277
+ - Set `current_phase` to next phase number
278
+ - Set `state` to `"READY"`
279
+ - Set `build_started_at` to null
280
+ - Append event: `"<timestamp>|phase_advanced|continue|Completed Phase <id>, advancing to Phase <next>"`
281
+
282
+ 5. **Cap enforcement:**
283
+ - Keep max 20 phase_learnings
284
+ - Keep max 30 decisions
285
+ - Keep max 30 instincts (remove lowest confidence)
286
+ - Keep max 100 events
287
+
288
+ Write the updated state through the locked subcommand. Construct the full updated COLONY_STATE.json content as a variable, then pipe it to state-write:
289
+
290
+ Run using the Bash tool with description "Writing colony state...":
291
+ ```bash
292
+ cat << 'STATEOF' | bash .aether/aether-utils.sh state-write
293
+ <the full JSON content>
294
+ STATEOF
295
+ ```
296
+
297
+ This acquires a lock, creates a rolling backup, validates JSON, and writes atomically. Do NOT use the Write tool to write COLONY_STATE.json directly — always go through state-write.
298
+
299
+ Validate the state file:
300
+ Run using the Bash tool with description "Validating colony state...": `bash .aether/aether-utils.sh validate-state colony`
301
+
302
+ ### Step 2.1: Auto-Emit Phase Pheromones (SILENT)
303
+
304
+ **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.
305
+
306
+ #### 2.1a: Auto-emit FEEDBACK pheromone for phase outcome
307
+
308
+ After learning extraction completes in Step 2, auto-emit a FEEDBACK signal summarizing the phase:
309
+
310
+ ```bash
311
+ # phase_id and phase_name come from Step 2 state update
312
+ # Take the top 1-3 learnings by evidence strength from memory.phase_learnings
313
+ # Compress into a single summary sentence
314
+
315
+ # If learnings were extracted, build a brief summary from them (first 1-3 claims)
316
+ # Otherwise use the minimal fallback
317
+ phase_feedback="Phase $phase_id ($phase_name) completed. Key patterns: {brief summary of 1-3 learnings from Step 2}"
318
+ # Fallback if no learnings: "Phase $phase_id ($phase_name) completed without notable patterns."
319
+
320
+ bash .aether/aether-utils.sh pheromone-write FEEDBACK "$phase_feedback" \
321
+ --strength 0.6 \
322
+ --source "worker:continue" \
323
+ --reason "Auto-emitted on phase advance: captures what worked and what was learned" \
324
+ --ttl "30d" 2>/dev/null || true
325
+ ```
326
+
327
+ 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.
328
+
329
+ #### 2.1b: Auto-emit FEEDBACK for phase decisions (PHER-01)
330
+
331
+ Extract recent decisions from CONTEXT.md "Recent Decisions" table and emit FEEDBACK pheromones for each. This ensures key decisions propagate as signals to guide future phases.
332
+
333
+ ```bash
334
+ decisions=$(awk '
335
+ /^## .*Recent Decisions/ { in_section=1; next }
336
+ in_section && /^\| Date / { next }
337
+ in_section && /^\|[-]+/ { next }
338
+ in_section && /^---/ { exit }
339
+ in_section && /^\| [0-9]{4}-[0-9]{2}/ {
340
+ split($0, fields, "|")
341
+ decision = fields[3]
342
+ gsub(/^[[:space:]]+|[[:space:]]+$/, "", decision)
343
+ if (decision != "") print decision
344
+ }
345
+ ' .aether/CONTEXT.md 2>/dev/null || echo "")
346
+
347
+ if [[ -n "$decisions" ]]; then
348
+ emit_count=0
349
+ while IFS= read -r dec && [[ $emit_count -lt 3 ]]; do
350
+ [[ -z "$dec" ]] && continue
351
+ # Deduplication: check if auto:decision or system:decision pheromone with this text already exists
352
+ existing=$(jq -r --arg text "$dec" '
353
+ [.signals[] | select(.active == true and (.source == "auto:decision" or .source == "system:decision") and (.content.text | contains($text)))] | length
354
+ ' .aether/data/pheromones.json 2>/dev/null || echo "0")
355
+ if [[ "$existing" == "0" ]]; then
356
+ bash .aether/aether-utils.sh pheromone-write FEEDBACK \
357
+ "[decision] $dec" \
358
+ --strength 0.6 \
359
+ --source "auto:decision" \
360
+ --reason "Auto-emitted from phase decision during continue" \
361
+ --ttl "30d" 2>/dev/null || true
362
+ emit_count=$((emit_count + 1))
363
+ fi
364
+ done <<< "$decisions"
365
+ fi
366
+ ```
367
+
368
+ Strength is 0.6 (auto-emitted = lower than user-emitted). Source is `"auto:decision"` to distinguish from manual pheromones. Cap: max 3 decision pheromones per continue run. Both `context-update decision` and Step 2.1b now use the same format (`[decision] ...`, source `auto:decision`, strength 0.6), so the dedup `contains()` check reliably catches signals emitted by either path. The dedup query also checks `system:decision` for backward compatibility with any pre-existing signals from before the format alignment.
369
+
370
+ #### 2.1c: Auto-emit REDIRECT for midden error patterns (PHER-02)
371
+
372
+ Query the actual failure store (`midden.json`) for recurring error categories. Categories with 3+ occurrences indicate persistent issues that should steer workers away from known failure modes.
373
+
374
+ ```bash
375
+ midden_result=$(bash .aether/aether-utils.sh midden-recent-failures 50 2>/dev/null || echo '{"count":0,"failures":[]}')
376
+ midden_count=$(echo "$midden_result" | jq '.count // 0')
377
+
378
+ if [[ "$midden_count" -gt 0 ]]; then
379
+ # Group by category, find categories with 3+ occurrences
380
+ recurring_categories=$(echo "$midden_result" | jq -r '
381
+ [.failures[] | .category]
382
+ | group_by(.)
383
+ | map(select(length >= 3))
384
+ | map({category: .[0], count: length})
385
+ | .[]
386
+ | @base64
387
+ ' 2>/dev/null || echo "")
388
+
389
+ emit_count=0
390
+ for encoded in $recurring_categories; do
391
+ [[ $emit_count -ge 3 ]] && break
392
+ [[ -z "$encoded" ]] && continue
393
+ category=$(echo "$encoded" | base64 -d | jq -r '.category')
394
+ count=$(echo "$encoded" | base64 -d | jq -r '.count')
395
+
396
+ # Deduplication check
397
+ existing=$(jq -r --arg cat "$category" '
398
+ [.signals[] | select(.active == true and .source == "auto:error" and (.content.text | contains($cat)))] | length
399
+ ' .aether/data/pheromones.json 2>/dev/null || echo "0")
400
+
401
+ if [[ "$existing" == "0" ]]; then
402
+ bash .aether/aether-utils.sh pheromone-write REDIRECT \
403
+ "[error-pattern] Category \"$category\" recurring ($count occurrences)" \
404
+ --strength 0.7 \
405
+ --source "auto:error" \
406
+ --reason "Auto-emitted: midden error pattern recurred 3+ times" \
407
+ --ttl "30d" 2>/dev/null || true
408
+ emit_count=$((emit_count + 1))
409
+
410
+ # Capture as resolution candidate for promotion tracking
411
+ bash .aether/aether-utils.sh memory-capture \
412
+ "resolution" \
413
+ "Recurring error pattern: $category ($count occurrences)" \
414
+ "pattern" \
415
+ "worker:continue" 2>/dev/null || true
416
+ fi
417
+ done
418
+ fi
419
+ ```
420
+
421
+ REDIRECT strength is 0.7 (higher than auto FEEDBACK 0.6 — anti-patterns produce stronger signals). Source is `"auto:error"`. Cap: max 3 error pattern pheromones per continue run. Uses `midden-recent-failures` subcommand (actual failure store) instead of `errors.flagged_patterns` (which may be empty). Threshold is 3+ occurrences for high confidence in recurrence.
422
+
423
+ #### 2.1d: Auto-emit FEEDBACK for recurring success criteria (PHER-03)
424
+
425
+ Compare success criteria text across all completed phases. Criteria appearing in 2+ completed phases indicate recurring quality patterns worth reinforcing as signals.
426
+
427
+ ```bash
428
+ recurring_criteria=$(jq -r '
429
+ [.plan.phases[]
430
+ | select(.status == "completed")
431
+ | .id as $phase_id
432
+ | (
433
+ (.success_criteria // [])[] ,
434
+ (.tasks // [] | .[].success_criteria // [])[]
435
+ )
436
+ | {phase: $phase_id, text: (. | ascii_downcase | gsub("^\\s+|\\s+$"; ""))}
437
+ ]
438
+ | group_by(.text)
439
+ | map(select(length >= 2))
440
+ | map({text: .[0].text, phases: [.[].phase] | unique, count: length})
441
+ | .[:2]
442
+ | .[]
443
+ | @base64
444
+ ' .aether/data/COLONY_STATE.json 2>/dev/null || echo "")
445
+
446
+ for encoded in $recurring_criteria; do
447
+ [[ -z "$encoded" ]] && continue
448
+ text=$(echo "$encoded" | base64 -d | jq -r '.text')
449
+ count=$(echo "$encoded" | base64 -d | jq -r '.count')
450
+ phases=$(echo "$encoded" | base64 -d | jq -r '.phases | join(", ")')
451
+
452
+ # Deduplication check
453
+ existing=$(jq -r --arg text "$text" '
454
+ [.signals[] | select(.active == true and .source == "auto:success" and (.content.text | ascii_downcase | contains($text)))] | length
455
+ ' .aether/data/pheromones.json 2>/dev/null || echo "0")
456
+
457
+ if [[ "$existing" == "0" ]]; then
458
+ bash .aether/aether-utils.sh pheromone-write FEEDBACK \
459
+ "[success-pattern] \"$text\" recurs across phases $phases" \
460
+ --strength 0.6 \
461
+ --source "auto:success" \
462
+ --reason "Auto-emitted: success criteria pattern recurred across $count phases" \
463
+ --ttl "30d" 2>/dev/null || true
464
+ fi
465
+ done
466
+ ```
467
+
468
+ Strength is 0.6 (auto-emitted). Source is `"auto:success"`. Cap: max 2 success criteria pheromones per continue run (enforced by `.[:2]` in the jq query). Extracts from both phase-level `.success_criteria` and task-level `.tasks[].success_criteria` across all completed phases. Normalizes text with `ascii_downcase` and whitespace trimming for reliable matching.
469
+
470
+ #### 2.1e: Expire phase_end signals and archive to midden
471
+
472
+ After auto-emission, expire all signals with `expires_at == "phase_end"`. The FEEDBACK from 2.1a uses a 30d TTL and is not affected by this step.
473
+
474
+ 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`
475
+
476
+ This is idempotent — runs every time continue fires but only creates the directory/file once.
477
+
478
+ ### Step 2.1.5: Check for Promotion Proposals (PHER-EVOL-02)
479
+
480
+ After extracting learnings, check for observations that have met promotion thresholds and present the tick-to-approve UX.
481
+
482
+ **Check for --deferred flag:**
483
+
484
+ If `$ARGUMENTS` contains `--deferred`:
485
+ ```bash
486
+ if [[ "$ARGUMENTS" == *"--deferred"* ]] && [[ -f .aether/data/learning-deferred.json ]]; then
487
+ echo "📦 Reviewing deferred proposals..."
488
+ bash .aether/aether-utils.sh learning-approve-proposals --deferred ${verbose:+--verbose}
489
+ fi
490
+ ```
491
+
492
+ **Normal proposal flow (MEM-01: Silent skip if empty):**
493
+
494
+ 1. **Check for proposals:**
495
+ ```bash
496
+ proposals=$(bash .aether/aether-utils.sh learning-check-promotion 2>/dev/null || echo '{"proposals":[]}')
497
+ proposal_count=$(echo "$proposals" | jq '.proposals | length')
498
+ ```
499
+
500
+ 2. **If proposals exist, invoke the approval workflow:**
501
+
502
+ Only show the approval UI when there are actual proposals to review:
503
+
504
+ ```bash
505
+ if [[ "$proposal_count" -gt 0 ]]; then
506
+ verbose_flag=""
507
+ [[ "$ARGUMENTS" == *"--verbose"* ]] && verbose_flag="--verbose"
508
+ bash .aether/aether-utils.sh learning-approve-proposals $verbose_flag
509
+ fi
510
+ # If no proposals, silently skip without notice (per user decision)
511
+ ```
512
+
513
+ The learning-approve-proposals function handles:
514
+ - Displaying proposals with checkbox UI
515
+ - Capturing user selection
516
+ - Executing batch promotions via queen-promote
517
+ - Deferring unselected proposals
518
+ - Offering undo after successful promotions
519
+ - Logging PROMOTED activity
520
+
521
+ **Skip conditions:**
522
+ - learning-check-promotion returns empty or fails
523
+ - No proposals to review (silent skip - no output)
524
+ - QUEEN.md does not exist