aether-colony 1.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 (207) hide show
  1. package/.aether/CONTEXT.md +160 -0
  2. package/.aether/QUEEN.md +84 -0
  3. package/.aether/aether-utils.sh +7749 -0
  4. package/.aether/docs/QUEEN-SYSTEM.md +211 -0
  5. package/.aether/docs/README.md +68 -0
  6. package/.aether/docs/caste-system.md +48 -0
  7. package/.aether/docs/disciplines/DISCIPLINES.md +93 -0
  8. package/.aether/docs/disciplines/coding-standards.md +197 -0
  9. package/.aether/docs/disciplines/debugging.md +207 -0
  10. package/.aether/docs/disciplines/learning.md +254 -0
  11. package/.aether/docs/disciplines/tdd.md +257 -0
  12. package/.aether/docs/disciplines/verification-loop.md +167 -0
  13. package/.aether/docs/disciplines/verification.md +116 -0
  14. package/.aether/docs/error-codes.md +268 -0
  15. package/.aether/docs/known-issues.md +233 -0
  16. package/.aether/docs/pheromones.md +205 -0
  17. package/.aether/docs/queen-commands.md +97 -0
  18. package/.aether/exchange/colony-registry.xml +11 -0
  19. package/.aether/exchange/pheromone-xml.sh +575 -0
  20. package/.aether/exchange/pheromones.xml +87 -0
  21. package/.aether/exchange/queen-wisdom.xml +14 -0
  22. package/.aether/exchange/registry-xml.sh +273 -0
  23. package/.aether/exchange/wisdom-xml.sh +319 -0
  24. package/.aether/midden/approach-changes.md +5 -0
  25. package/.aether/midden/build-failures.md +5 -0
  26. package/.aether/midden/test-failures.md +5 -0
  27. package/.aether/model-profiles.yaml +100 -0
  28. package/.aether/rules/aether-colony.md +134 -0
  29. package/.aether/schemas/aether-types.xsd +255 -0
  30. package/.aether/schemas/colony-registry.xsd +309 -0
  31. package/.aether/schemas/example-prompt-builder.xml +234 -0
  32. package/.aether/schemas/pheromone.xsd +163 -0
  33. package/.aether/schemas/prompt.xsd +416 -0
  34. package/.aether/schemas/queen-wisdom.xsd +325 -0
  35. package/.aether/schemas/worker-priming.xsd +276 -0
  36. package/.aether/templates/QUEEN.md.template +79 -0
  37. package/.aether/templates/colony-state-reset.jq.template +22 -0
  38. package/.aether/templates/colony-state.template.json +35 -0
  39. package/.aether/templates/constraints.template.json +9 -0
  40. package/.aether/templates/crowned-anthill.template.md +36 -0
  41. package/.aether/templates/handoff-build-error.template.md +30 -0
  42. package/.aether/templates/handoff-build-success.template.md +39 -0
  43. package/.aether/templates/handoff.template.md +40 -0
  44. package/.aether/templates/learning-observations.template.json +6 -0
  45. package/.aether/templates/midden.template.json +7 -0
  46. package/.aether/templates/pheromones.template.json +6 -0
  47. package/.aether/templates/session.template.json +9 -0
  48. package/.aether/utils/atomic-write.sh +219 -0
  49. package/.aether/utils/chamber-compare.sh +193 -0
  50. package/.aether/utils/chamber-utils.sh +297 -0
  51. package/.aether/utils/colorize-log.sh +132 -0
  52. package/.aether/utils/error-handler.sh +212 -0
  53. package/.aether/utils/file-lock.sh +158 -0
  54. package/.aether/utils/queen-to-md.xsl +395 -0
  55. package/.aether/utils/semantic-cli.sh +413 -0
  56. package/.aether/utils/spawn-tree.sh +428 -0
  57. package/.aether/utils/spawn-with-model.sh +56 -0
  58. package/.aether/utils/state-loader.sh +215 -0
  59. package/.aether/utils/swarm-display.sh +268 -0
  60. package/.aether/utils/watch-spawn-tree.sh +253 -0
  61. package/.aether/utils/xml-compose.sh +253 -0
  62. package/.aether/utils/xml-convert.sh +273 -0
  63. package/.aether/utils/xml-core.sh +186 -0
  64. package/.aether/utils/xml-query.sh +201 -0
  65. package/.aether/utils/xml-utils.sh +110 -0
  66. package/.aether/workers.md +765 -0
  67. package/.claude/agents/ant/aether-ambassador.md +264 -0
  68. package/.claude/agents/ant/aether-archaeologist.md +322 -0
  69. package/.claude/agents/ant/aether-auditor.md +266 -0
  70. package/.claude/agents/ant/aether-builder.md +187 -0
  71. package/.claude/agents/ant/aether-chaos.md +268 -0
  72. package/.claude/agents/ant/aether-chronicler.md +304 -0
  73. package/.claude/agents/ant/aether-gatekeeper.md +325 -0
  74. package/.claude/agents/ant/aether-includer.md +373 -0
  75. package/.claude/agents/ant/aether-keeper.md +271 -0
  76. package/.claude/agents/ant/aether-measurer.md +317 -0
  77. package/.claude/agents/ant/aether-probe.md +210 -0
  78. package/.claude/agents/ant/aether-queen.md +325 -0
  79. package/.claude/agents/ant/aether-route-setter.md +173 -0
  80. package/.claude/agents/ant/aether-sage.md +353 -0
  81. package/.claude/agents/ant/aether-scout.md +142 -0
  82. package/.claude/agents/ant/aether-surveyor-disciplines.md +416 -0
  83. package/.claude/agents/ant/aether-surveyor-nest.md +354 -0
  84. package/.claude/agents/ant/aether-surveyor-pathogens.md +288 -0
  85. package/.claude/agents/ant/aether-surveyor-provisions.md +359 -0
  86. package/.claude/agents/ant/aether-tracker.md +265 -0
  87. package/.claude/agents/ant/aether-watcher.md +244 -0
  88. package/.claude/agents/ant/aether-weaver.md +247 -0
  89. package/.claude/commands/ant/archaeology.md +341 -0
  90. package/.claude/commands/ant/build.md +1160 -0
  91. package/.claude/commands/ant/chaos.md +349 -0
  92. package/.claude/commands/ant/colonize.md +270 -0
  93. package/.claude/commands/ant/continue.md +1070 -0
  94. package/.claude/commands/ant/council.md +309 -0
  95. package/.claude/commands/ant/dream.md +265 -0
  96. package/.claude/commands/ant/entomb.md +487 -0
  97. package/.claude/commands/ant/feedback.md +78 -0
  98. package/.claude/commands/ant/flag.md +139 -0
  99. package/.claude/commands/ant/flags.md +155 -0
  100. package/.claude/commands/ant/focus.md +58 -0
  101. package/.claude/commands/ant/help.md +122 -0
  102. package/.claude/commands/ant/history.md +137 -0
  103. package/.claude/commands/ant/init.md +409 -0
  104. package/.claude/commands/ant/interpret.md +267 -0
  105. package/.claude/commands/ant/lay-eggs.md +201 -0
  106. package/.claude/commands/ant/maturity.md +102 -0
  107. package/.claude/commands/ant/memory-details.md +77 -0
  108. package/.claude/commands/ant/migrate-state.md +165 -0
  109. package/.claude/commands/ant/oracle.md +387 -0
  110. package/.claude/commands/ant/organize.md +227 -0
  111. package/.claude/commands/ant/pause-colony.md +247 -0
  112. package/.claude/commands/ant/phase.md +126 -0
  113. package/.claude/commands/ant/plan.md +544 -0
  114. package/.claude/commands/ant/redirect.md +58 -0
  115. package/.claude/commands/ant/resume-colony.md +182 -0
  116. package/.claude/commands/ant/resume.md +363 -0
  117. package/.claude/commands/ant/seal.md +306 -0
  118. package/.claude/commands/ant/status.md +272 -0
  119. package/.claude/commands/ant/swarm.md +361 -0
  120. package/.claude/commands/ant/tunnels.md +425 -0
  121. package/.claude/commands/ant/update.md +209 -0
  122. package/.claude/commands/ant/verify-castes.md +95 -0
  123. package/.claude/commands/ant/watch.md +238 -0
  124. package/.opencode/agents/aether-ambassador.md +140 -0
  125. package/.opencode/agents/aether-archaeologist.md +108 -0
  126. package/.opencode/agents/aether-auditor.md +144 -0
  127. package/.opencode/agents/aether-builder.md +184 -0
  128. package/.opencode/agents/aether-chaos.md +115 -0
  129. package/.opencode/agents/aether-chronicler.md +122 -0
  130. package/.opencode/agents/aether-gatekeeper.md +116 -0
  131. package/.opencode/agents/aether-includer.md +117 -0
  132. package/.opencode/agents/aether-keeper.md +177 -0
  133. package/.opencode/agents/aether-measurer.md +128 -0
  134. package/.opencode/agents/aether-probe.md +133 -0
  135. package/.opencode/agents/aether-queen.md +286 -0
  136. package/.opencode/agents/aether-route-setter.md +130 -0
  137. package/.opencode/agents/aether-sage.md +106 -0
  138. package/.opencode/agents/aether-scout.md +101 -0
  139. package/.opencode/agents/aether-surveyor-disciplines.md +386 -0
  140. package/.opencode/agents/aether-surveyor-nest.md +324 -0
  141. package/.opencode/agents/aether-surveyor-pathogens.md +259 -0
  142. package/.opencode/agents/aether-surveyor-provisions.md +329 -0
  143. package/.opencode/agents/aether-tracker.md +137 -0
  144. package/.opencode/agents/aether-watcher.md +174 -0
  145. package/.opencode/agents/aether-weaver.md +130 -0
  146. package/.opencode/commands/ant/archaeology.md +338 -0
  147. package/.opencode/commands/ant/build.md +1200 -0
  148. package/.opencode/commands/ant/chaos.md +346 -0
  149. package/.opencode/commands/ant/colonize.md +202 -0
  150. package/.opencode/commands/ant/continue.md +938 -0
  151. package/.opencode/commands/ant/council.md +305 -0
  152. package/.opencode/commands/ant/dream.md +262 -0
  153. package/.opencode/commands/ant/entomb.md +367 -0
  154. package/.opencode/commands/ant/feedback.md +80 -0
  155. package/.opencode/commands/ant/flag.md +137 -0
  156. package/.opencode/commands/ant/flags.md +153 -0
  157. package/.opencode/commands/ant/focus.md +56 -0
  158. package/.opencode/commands/ant/help.md +124 -0
  159. package/.opencode/commands/ant/history.md +127 -0
  160. package/.opencode/commands/ant/init.md +337 -0
  161. package/.opencode/commands/ant/interpret.md +256 -0
  162. package/.opencode/commands/ant/lay-eggs.md +141 -0
  163. package/.opencode/commands/ant/maturity.md +92 -0
  164. package/.opencode/commands/ant/memory-details.md +77 -0
  165. package/.opencode/commands/ant/migrate-state.md +153 -0
  166. package/.opencode/commands/ant/oracle.md +338 -0
  167. package/.opencode/commands/ant/organize.md +224 -0
  168. package/.opencode/commands/ant/pause-colony.md +220 -0
  169. package/.opencode/commands/ant/phase.md +123 -0
  170. package/.opencode/commands/ant/plan.md +531 -0
  171. package/.opencode/commands/ant/redirect.md +67 -0
  172. package/.opencode/commands/ant/resume-colony.md +178 -0
  173. package/.opencode/commands/ant/resume.md +363 -0
  174. package/.opencode/commands/ant/seal.md +247 -0
  175. package/.opencode/commands/ant/status.md +272 -0
  176. package/.opencode/commands/ant/swarm.md +357 -0
  177. package/.opencode/commands/ant/tunnels.md +406 -0
  178. package/.opencode/commands/ant/update.md +191 -0
  179. package/.opencode/commands/ant/verify-castes.md +85 -0
  180. package/.opencode/commands/ant/watch.md +220 -0
  181. package/.opencode/opencode.json +3 -0
  182. package/CHANGELOG.md +325 -0
  183. package/DISCLAIMER.md +74 -0
  184. package/LICENSE +21 -0
  185. package/README.md +258 -0
  186. package/bin/cli.js +2436 -0
  187. package/bin/generate-commands.sh +291 -0
  188. package/bin/lib/caste-colors.js +57 -0
  189. package/bin/lib/colors.js +76 -0
  190. package/bin/lib/errors.js +255 -0
  191. package/bin/lib/event-types.js +190 -0
  192. package/bin/lib/file-lock.js +695 -0
  193. package/bin/lib/init.js +454 -0
  194. package/bin/lib/logger.js +242 -0
  195. package/bin/lib/model-profiles.js +445 -0
  196. package/bin/lib/model-verify.js +288 -0
  197. package/bin/lib/nestmate-loader.js +130 -0
  198. package/bin/lib/proxy-health.js +253 -0
  199. package/bin/lib/spawn-logger.js +266 -0
  200. package/bin/lib/state-guard.js +602 -0
  201. package/bin/lib/state-sync.js +516 -0
  202. package/bin/lib/telemetry.js +441 -0
  203. package/bin/lib/update-transaction.js +1454 -0
  204. package/bin/npx-install.js +178 -0
  205. package/bin/sync-to-runtime.sh +6 -0
  206. package/bin/validate-package.sh +88 -0
  207. package/package.json +70 -0
@@ -0,0 +1,1070 @@
1
+ ---
2
+ name: ant:continue
3
+ description: "➡️🐜🚪🐜➡️ Detect build completion, reconcile state, and advance to next phase"
4
+ ---
5
+
6
+ You are the **Queen Ant Colony**. Reconcile completed work and advance to the next phase.
7
+
8
+ ## Instructions
9
+
10
+ Parse `$ARGUMENTS`:
11
+ - If contains `--no-visual`: set `visual_mode = false` (visual is ON by default)
12
+ - Otherwise: set `visual_mode = true`
13
+
14
+ ### Step 0: Initialize Visual Mode (if enabled)
15
+
16
+ If `visual_mode` is true:
17
+ Run using the Bash tool with description "Initializing continue display...": `continue_id="continue-$(date +%s)" && bash .aether/aether-utils.sh swarm-display-init "$continue_id" && bash .aether/aether-utils.sh swarm-display-update "Queen" "prime" "excavating" "Phase continuation" "Colony" '{"read":0,"grep":0,"edit":0,"bash":0}' 0 "fungus_garden" 0`
18
+
19
+ ### Step 0.5: Version Check (Non-blocking)
20
+
21
+ Run using the Bash tool with description "Checking colony version...": `bash .aether/aether-utils.sh version-check-cached 2>/dev/null || true`
22
+
23
+ If the command succeeds and the JSON result contains a non-empty string, display it as a one-line notice. Proceed regardless of outcome.
24
+
25
+ ### Step 1: Read State + Version Check
26
+
27
+ Read `.aether/data/COLONY_STATE.json`.
28
+
29
+ **Auto-upgrade old state:**
30
+ If `version` field is missing, "1.0", or "2.0":
31
+ 1. Preserve: `goal`, `state`, `current_phase`, `plan.phases`
32
+ 2. Write upgraded v3.0 state (same structure as /ant:init but preserving data)
33
+ 3. Output: `State auto-upgraded to v3.0`
34
+ 4. Continue with command.
35
+
36
+ Extract: `goal`, `state`, `current_phase`, `plan.phases`, `errors`, `memory`, `events`, `build_started_at`.
37
+
38
+ **Validation:**
39
+ - If `goal: null` -> output "No colony initialized. Run /ant:init first." and stop.
40
+ - If `plan.phases` is empty -> output "No project plan. Run /ant:plan first." and stop.
41
+
42
+ ### Step 1.5: Load State and Show Resumption Context
43
+
44
+ Run using the Bash tool with description "Loading colony state...": `bash .aether/aether-utils.sh load-state`
45
+
46
+ If successful and goal is not null:
47
+ 1. Extract current_phase from state
48
+ 2. Get phase name from plan.phases[current_phase - 1].name (or "(unnamed)")
49
+ 3. Display brief resumption context:
50
+ ```
51
+ 🔄 Resuming: Phase X - Name
52
+ ```
53
+
54
+ If .aether/HANDOFF.md exists (detected in load-state output):
55
+ - Display "Resuming from paused session"
56
+ - Read .aether/HANDOFF.md for additional context
57
+ - Remove .aether/HANDOFF.md after display (cleanup)
58
+
59
+ Run using the Bash tool with description "Releasing colony lock...": `bash .aether/aether-utils.sh unload-state` to release lock.
60
+
61
+ **Error handling:**
62
+ - If E_FILE_NOT_FOUND: "No colony initialized. Run /ant:init first." and stop
63
+ - If validation error: Display error details with recovery suggestion and stop
64
+ - For other errors: Display generic error and suggest /ant:status for diagnostics
65
+
66
+ **Completion Detection:**
67
+
68
+ If `state == "EXECUTING"`:
69
+ 1. Check if `build_started_at` exists
70
+ 2. Look for phase completion evidence:
71
+ - Activity log entries showing task completion
72
+ - Files created/modified matching phase tasks
73
+ 3. If no evidence and build started > 30 min ago:
74
+ - Display "Stale EXECUTING state. Build may have been interrupted."
75
+ - Offer: continue anyway or rollback to git checkpoint
76
+ - Rollback procedure: `git stash list | grep "aether-checkpoint"` to find ref, then `git stash pop <ref>` to restore
77
+
78
+ If `state != "EXECUTING"`:
79
+ - Normal continue flow (no build to reconcile)
80
+
81
+ ### Step 1.5: Verification Loop Gate (MANDATORY)
82
+
83
+ **The Iron Law:** No phase advancement without fresh verification evidence.
84
+
85
+ Before ANY phase can advance, execute the 6-phase verification loop. See `.aether/docs/disciplines/verification-loop.md` for full reference.
86
+
87
+ #### 1. Command Resolution (Priority Chain)
88
+
89
+ Resolve each command (build, test, types, lint) using this priority chain. Stop at the first source that provides a value for each command:
90
+
91
+ **Priority 1 — CLAUDE.md (System Context):**
92
+ 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.
93
+
94
+ **Priority 2 — codebase.md `## Commands`:**
95
+ Read `.aether/data/codebase.md` and look for the `## Commands` section. Use any commands listed there for slots not yet filled by Priority 1.
96
+
97
+ **Priority 3 — Fallback Heuristic Table:**
98
+ For any commands still unresolved, check for these files in order, use first match:
99
+
100
+ | File | Build | Test | Types | Lint |
101
+ |------|-------|------|-------|------|
102
+ | `package.json` | `npm run build` | `npm test` | `npx tsc --noEmit` | `npm run lint` |
103
+ | `Cargo.toml` | `cargo build` | `cargo test` | (built-in) | `cargo clippy` |
104
+ | `go.mod` | `go build ./...` | `go test ./...` | `go vet ./...` | `golangci-lint run` |
105
+ | `pyproject.toml` | `python -m build` | `pytest` | `pyright .` | `ruff check .` |
106
+ | `Makefile` | `make build` | `make test` | (check targets) | `make lint` |
107
+
108
+ If no build system detected, skip build/test/type/lint checks but still verify success criteria.
109
+
110
+ #### 2. Run 6-Phase Verification Loop
111
+
112
+ Execute all applicable phases and capture output:
113
+
114
+ ```
115
+ ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
116
+ 👁️🐜 V E R I F I C A T I O N L O O P
117
+ ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
118
+ Phase {id} — Checking colony work...
119
+ ```
120
+
121
+ **Phase 1: Build Check** (if command exists):
122
+ Run using the Bash tool with description "Running build check...": `{build_command} 2>&1 | tail -30`
123
+ Record: exit code, any errors. **STOP if fails.**
124
+
125
+ **Phase 2: Type Check** (if command exists):
126
+ Run using the Bash tool with description "Running type check...": `{type_command} 2>&1 | head -30`
127
+ Record: error count. Report all type errors.
128
+
129
+ **Phase 3: Lint Check** (if command exists):
130
+ Run using the Bash tool with description "Running lint check...": `{lint_command} 2>&1 | head -30`
131
+ Record: warning count, error count.
132
+
133
+ **Phase 4: Test Check** (if command exists):
134
+ Run using the Bash tool with description "Running test suite...": `{test_command} 2>&1 | tail -50`
135
+ Record: pass count, fail count, exit code. **STOP if fails.**
136
+
137
+ **Coverage Check** (if coverage command exists):
138
+ Run using the Bash tool with description "Checking test coverage...": `{coverage_command} # e.g., npm run test:coverage`
139
+ Record: coverage percentage (target: 80%+ for new code)
140
+
141
+ **Phase 5: Security Scan**:
142
+ Run using the Bash tool with description "Scanning for exposed secrets...": `grep -rn "sk-\|api_key\|password\s*=" --include="*.ts" --include="*.js" --include="*.py" src/ 2>/dev/null | head -10`
143
+ Run using the Bash tool with description "Scanning for debug artifacts...": `grep -rn "console\.log\|debugger" --include="*.ts" --include="*.tsx" --include="*.js" src/ 2>/dev/null | head -10`
144
+ Record: potential secrets (critical), debug artifacts (warning).
145
+
146
+ **Phase 6: Diff Review**:
147
+ Run using the Bash tool with description "Reviewing file changes...": `git diff --stat`
148
+ Review changed files for unintended modifications.
149
+
150
+ **Success Criteria Check:**
151
+ Read phase success criteria from `plan.phases[current].success_criteria`.
152
+ For EACH criterion:
153
+ 1. Identify what proves it (file exists? test passes? output shows X?)
154
+ 2. Run the check
155
+ 3. Record evidence or gap
156
+
157
+ Display:
158
+ ```
159
+ ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
160
+ 👁️🐜 V E R I F I C A T I O N R E P O R T
161
+ ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
162
+
163
+ 🔨 Build [PASS/FAIL/SKIP]
164
+ 🔍 Types [PASS/FAIL/SKIP] (X errors)
165
+ 🧹 Lint [PASS/FAIL/SKIP] (X warnings)
166
+ 🧪 Tests [PASS/FAIL/SKIP] (X/Y passed)
167
+ Coverage {percent}% (target: 80%)
168
+ 🔒 Security [PASS/FAIL] (X issues)
169
+ 📋 Diff [X files changed]
170
+
171
+ ──────────────────────────────────────────────────
172
+ 🐜 Success Criteria
173
+ ──────────────────────────────────────────────────
174
+ ✅ {criterion 1}: {specific evidence}
175
+ ✅ {criterion 2}: {specific evidence}
176
+ ❌ {criterion 3}: {what's missing}
177
+
178
+ ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
179
+ Overall: READY / NOT READY
180
+ ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
181
+ ```
182
+
183
+ #### 3. Gate Decision
184
+
185
+ **If NOT READY (any of: build fails, tests fail, critical security issues, success criteria unmet):**
186
+
187
+ ```
188
+ ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
189
+ ⛔🐜 V E R I F I C A T I O N F A I L E D
190
+ ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
191
+
192
+ Phase {id} cannot advance until issues are resolved.
193
+
194
+ 🚨 Issues Found:
195
+ {list each failure with specific evidence}
196
+
197
+ 🔧 Required Actions:
198
+ 1. Fix the issues listed above
199
+ 2. Run /ant:continue again to re-verify
200
+
201
+ The phase will NOT advance until verification passes.
202
+ ```
203
+
204
+ **CRITICAL:** Do NOT proceed to Step 2. Do NOT advance the phase.
205
+ Do NOT offer workarounds. Verification is mandatory.
206
+
207
+ Use AskUserQuestion to confirm they understand what needs to be fixed:
208
+ - Show the specific failures
209
+ - Ask if they want to fix now or need help
210
+
211
+ **If READY (all checks pass with evidence):**
212
+
213
+ ```
214
+ ✅🐜 VERIFICATION PASSED
215
+
216
+ All checks completed with evidence:
217
+ {list each check and its evidence}
218
+
219
+ Proceeding to gate checks...
220
+ ```
221
+
222
+ Continue to Step 1.6.
223
+
224
+ ### Step 1.6: Spawn Enforcement Gate (MANDATORY)
225
+
226
+ **The Iron Law:** No phase advancement without worker spawning for non-trivial phases.
227
+
228
+ Read `.aether/data/spawn-tree.txt` to count spawns for this phase.
229
+
230
+ Run using the Bash tool with description "Verifying spawn requirements...": `spawn_count=$(grep -c "spawned" .aether/data/spawn-tree.txt 2>/dev/null || echo "0") && watcher_count=$(grep -c "watcher" .aether/data/spawn-tree.txt 2>/dev/null || echo "0") && echo "{\"spawn_count\": $spawn_count, \"watcher_count\": $watcher_count}"`
231
+
232
+ **HARD REJECTION - If spawn_count == 0 and phase had 3+ tasks:**
233
+
234
+ ```
235
+ ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
236
+ ⛔🐜 S P A W N G A T E F A I L E D
237
+ ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
238
+
239
+ This phase had {task_count} tasks but spawn_count: 0
240
+ The Prime Worker violated the spawn protocol.
241
+
242
+ 🐜 The colony requires actual parallelism:
243
+ - Prime Worker MUST spawn specialists for non-trivial work
244
+ - A single agent doing everything is NOT a colony
245
+ - "Justifications" for not spawning are not accepted
246
+
247
+ 🔧 Required Actions:
248
+ 1. Run /ant:build {phase} again
249
+ 2. Prime Worker MUST spawn at least 1 specialist
250
+ 3. Re-run /ant:continue after spawns complete
251
+
252
+ The phase will NOT advance until spawning occurs.
253
+ ```
254
+
255
+ **CRITICAL:** Do NOT proceed to Step 1.7. Do NOT advance the phase.
256
+ Log the violation:
257
+ ```bash
258
+ bash .aether/aether-utils.sh activity-log "BLOCKED" "colony" "Spawn gate failed: {task_count} tasks, 0 spawns"
259
+ bash .aether/aether-utils.sh error-flag-pattern "no-spawn-violation" "Prime Worker completed phase without spawning specialists" "critical"
260
+ ```
261
+
262
+ **HARD REJECTION - If watcher_count == 0 (no testing separation):**
263
+
264
+ ```
265
+ ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
266
+ ⛔👁️🐜 W A T C H E R G A T E F A I L E D
267
+ ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
268
+
269
+ No Watcher ant was spawned for testing/verification.
270
+ Testing MUST be performed by a separate agent, not the builder.
271
+
272
+ 🐜 Why this matters:
273
+ - Builders verify their own work = confirmation bias
274
+ - Independent Watchers catch bugs builders miss
275
+ - "Build passing" ≠ "App working"
276
+
277
+ 🔧 Required Actions:
278
+ 1. Run /ant:build {phase} again
279
+ 2. Prime Worker MUST spawn at least 1 Watcher
280
+ 3. Watcher must independently verify the work
281
+
282
+ The phase will NOT advance until a Watcher validates.
283
+ ```
284
+
285
+ **CRITICAL:** Do NOT proceed. Log the violation.
286
+
287
+ **If spawn_count >= 1 AND watcher_count >= 1:**
288
+
289
+ ```
290
+ ✅🐜 SPAWN GATE PASSED — {spawn_count} workers | {watcher_count} watchers
291
+ ```
292
+
293
+ Continue to Step 1.7.
294
+
295
+ ### Step 1.7: Anti-Pattern Gate
296
+
297
+ Scan all modified/created files for known anti-patterns. This catches recurring bugs before they reach production.
298
+
299
+ For each file, run using the Bash tool with description "Scanning for anti-patterns...": `bash .aether/aether-utils.sh check-antipattern "{file_path}"`
300
+
301
+ Run for each file in `files_created` and `files_modified` from Prime Worker output.
302
+
303
+ **Anti-Pattern Report:**
304
+
305
+ ```
306
+ 🔍🐜 Anti-Pattern Scan — {count} files scanned
307
+
308
+ {if critical issues:}
309
+ 🛑 CRITICAL (must fix):
310
+ {list each with file:line and description}
311
+
312
+ {if warnings:}
313
+ ⚠️ WARNINGS:
314
+ {list each with file:line and description}
315
+
316
+ {if clean:}
317
+ ✅🐜 No anti-patterns detected
318
+ ```
319
+
320
+ **CRITICAL issues block phase advancement:**
321
+ - Swift didSet infinite recursion
322
+ - Exposed secrets/credentials
323
+ - SQL injection patterns
324
+ - Known crash patterns
325
+
326
+ **WARNINGS are logged but don't block:**
327
+ - TypeScript `any` usage
328
+ - Console.log in production code
329
+ - TODO/FIXME comments
330
+
331
+ If CRITICAL issues found, display:
332
+
333
+ ```
334
+ ⛔🐜 ANTI-PATTERN GATE FAILED
335
+
336
+ Critical anti-patterns detected:
337
+ {list issues with file paths}
338
+
339
+ Run /ant:build {phase} again after fixing.
340
+ ```
341
+
342
+ Do NOT proceed to Step 2.
343
+
344
+ If no CRITICAL issues, continue to Step 1.8.
345
+
346
+ ### Step 1.8: TDD Evidence Gate (MANDATORY)
347
+
348
+ **The Iron Law:** No TDD claims without actual test files.
349
+
350
+ If Prime Worker reported TDD metrics (tests_added, tests_total, coverage_percent), verify test files exist:
351
+
352
+ Run using the Bash tool with description "Locating test files...": `find . -name "*.test.*" -o -name "*_test.*" -o -name "*Tests.swift" -o -name "test_*.py" 2>/dev/null | head -10`
353
+
354
+ **If Prime Worker claimed tests_added > 0 but no test files found:**
355
+
356
+ ```
357
+ ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
358
+ ⛔🧪🐜 T D D G A T E F A I L E D
359
+ ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
360
+
361
+ Prime Worker claimed:
362
+ tests_added: {claimed_count}
363
+ tests_total: {claimed_total}
364
+ coverage: {claimed_coverage}%
365
+
366
+ But no test files were found in the codebase.
367
+
368
+ 🚨 CRITICAL violation — fabricated TDD metrics.
369
+
370
+ 🔧 Required Actions:
371
+ 1. Run /ant:build {phase} again
372
+ 2. Actually write test files (not just claim them)
373
+ 3. Tests must exist and be runnable
374
+
375
+ The phase will NOT advance with fabricated metrics.
376
+ ```
377
+
378
+ **CRITICAL:** Do NOT proceed. Log the violation:
379
+ ```bash
380
+ bash .aether/aether-utils.sh error-flag-pattern "fabricated-tdd" "Prime Worker reported TDD metrics without creating test files" "critical"
381
+ ```
382
+
383
+ **If tests_added == 0 or test files exist matching claims:**
384
+
385
+ Continue to Step 1.9.
386
+
387
+ ### Step 1.9: Runtime Verification Gate (MANDATORY)
388
+
389
+ **The Iron Law:** Build passing ≠ App working.
390
+
391
+ Before advancing, the user must confirm the application actually runs.
392
+
393
+ Use AskUserQuestion:
394
+
395
+ ```
396
+ ──────────────────────────────────────────────────
397
+ 🐜 Runtime Verification Required
398
+ ──────────────────────────────────────────────────
399
+
400
+ Build checks passed — but does the app actually work?
401
+
402
+ Have you tested the application at runtime?
403
+ ```
404
+
405
+ Options:
406
+ 1. **Yes, tested and working** - App runs correctly, features work
407
+ 2. **Yes, tested but has issues** - App runs but has bugs (describe)
408
+ 3. **No, haven't tested yet** - Need to test before continuing
409
+ 4. **Skip (not applicable)** - No runnable app in this phase (e.g., library code)
410
+
411
+ **If "Yes, tested and working":**
412
+ ```
413
+ ✅🐜 RUNTIME VERIFIED — User confirmed app works.
414
+ ```
415
+ Continue to Step 2.
416
+
417
+ **If "Yes, tested but has issues":**
418
+ ```
419
+ ⛔🐜 RUNTIME GATE FAILED — User reported issues.
420
+
421
+ Please describe the issues so they can be addressed:
422
+ ```
423
+
424
+ Use AskUserQuestion to get issue details. Log to errors.records:
425
+ ```bash
426
+ bash .aether/aether-utils.sh error-add "runtime" "critical" "{user_description}" {phase}
427
+ ```
428
+
429
+ Do NOT proceed to Step 2.
430
+
431
+ **If "No, haven't tested yet":**
432
+ ```
433
+ ⏸️🐜 RUNTIME PENDING — Test the app, then run /ant:continue again.
434
+
435
+ - [ ] App launches without crashing
436
+ - [ ] Core features work as expected
437
+ - [ ] UI responds to user interaction
438
+ - [ ] No freezes or hangs
439
+ ```
440
+
441
+ Do NOT proceed to Step 2.
442
+
443
+ **If "Skip (not applicable)":**
444
+
445
+ Only valid for phases that don't produce runnable code (e.g., documentation, config files, library code with no entry point).
446
+
447
+ ```
448
+ ⏭️ RUNTIME CHECK SKIPPED
449
+
450
+ User indicated no runnable app for this phase.
451
+ Proceeding to phase advancement.
452
+ ```
453
+
454
+ Continue to Step 1.10.
455
+
456
+ ### Step 1.10: Flags Gate (MANDATORY)
457
+
458
+ **The Iron Law:** No phase advancement with unresolved blockers.
459
+
460
+ First, auto-resolve any flags eligible for resolution now that verification has passed:
461
+ Run using the Bash tool with description "Auto-resolving flags...": `bash .aether/aether-utils.sh flag-auto-resolve "build_pass"`
462
+
463
+ Then check for remaining blocking flags:
464
+ Run using the Bash tool with description "Checking for blockers...": `bash .aether/aether-utils.sh flag-check-blockers {current_phase}`
465
+
466
+ Parse result for `blockers`, `issues`, and `notes` counts.
467
+
468
+ **If blockers > 0:**
469
+
470
+ ```
471
+ ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
472
+ ⛔🚩🐜 F L A G S G A T E F A I L E D
473
+ ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
474
+
475
+ {blockers} blocker(s) must be resolved first.
476
+
477
+ 🚩 Active Blockers:
478
+ {list each blocker flag with ID, title, and description}
479
+
480
+ 🔧 Required Actions:
481
+ 1. Fix the issues described in each blocker
482
+ 2. Resolve flags: /ant:flags --resolve {flag_id} "resolution message"
483
+ 3. Run /ant:continue again after resolving all blockers
484
+ ```
485
+
486
+ **CRITICAL:** Do NOT proceed to Step 2. Do NOT advance the phase.
487
+
488
+ **If blockers == 0 but issues > 0:**
489
+
490
+ ```
491
+ ⚠️🐜 FLAGS: {issues} issue(s) noted (non-blocking)
492
+
493
+ {list each issue flag}
494
+
495
+ Use /ant:flags to review.
496
+ ```
497
+
498
+ Continue to Step 2.
499
+
500
+ **If all clear (no blockers or issues):**
501
+
502
+ ```
503
+ ✅🐜 FLAGS GATE PASSED — No blockers.
504
+ ```
505
+
506
+ Continue to Step 2.
507
+
508
+ ### Step 2: Update State
509
+
510
+ Find current phase in `plan.phases`.
511
+ Determine next phase (`current_phase + 1`).
512
+
513
+ **If no next phase (all complete):** Skip to Step 2.4 (commit suggestion), then Step 2.7 (completion).
514
+
515
+ Update COLONY_STATE.json:
516
+
517
+ 1. **Mark current phase completed:**
518
+ - Set `plan.phases[current].status` to `"completed"`
519
+ - Set all tasks in phase to `"completed"`
520
+
521
+ 2. **Extract learnings (with validation status):**
522
+
523
+ **CRITICAL: Learnings start as HYPOTHESES until verified.**
524
+
525
+ A learning is only "validated" if:
526
+ - The code was actually run and tested
527
+ - The feature works in practice, not just in theory
528
+ - User has confirmed the behavior
529
+
530
+ Append to `memory.phase_learnings`:
531
+ ```json
532
+ {
533
+ "id": "learning_<unix_timestamp>",
534
+ "phase": <phase_number>,
535
+ "phase_name": "<name>",
536
+ "learnings": [
537
+ {
538
+ "claim": "<specific actionable learning>",
539
+ "status": "hypothesis",
540
+ "tested": false,
541
+ "evidence": "<what observation led to this>",
542
+ "disproven_by": null
543
+ }
544
+ ],
545
+ "timestamp": "<ISO-8601>"
546
+ }
547
+ ```
548
+
549
+ **Status values:**
550
+ - `hypothesis` - Recorded but not verified (DEFAULT)
551
+ - `validated` - Tested and confirmed working
552
+ - `disproven` - Found to be incorrect
553
+
554
+ **Do NOT record a learning if:**
555
+ - It wasn't actually tested
556
+ - It's stating the obvious
557
+ - There's no evidence it works
558
+
559
+ 2.5. **Record learning observations for threshold tracking:**
560
+
561
+ For each learning extracted, record an observation to enable threshold-based wisdom promotion.
562
+
563
+ Run using the Bash tool with description "Recording learning observations...":
564
+ ```bash
565
+ colony_name=$(jq -r '.session_id | split("_")[1] // "unknown"' .aether/data/COLONY_STATE.json 2>/dev/null || echo "unknown")
566
+
567
+ # Get learnings from the current phase
568
+ current_phase_learnings=$(jq -r --argjson phase "$current_phase" '.memory.phase_learnings[] | select(.phase == $phase)' .aether/data/COLONY_STATE.json 2>/dev/null || echo "")
569
+
570
+ if [[ -n "$current_phase_learnings" ]]; then
571
+ echo "$current_phase_learnings" | jq -r '.learnings[]?.claim // empty' 2>/dev/null | while read -r claim; do
572
+ if [[ -n "$claim" ]]; then
573
+ # Default wisdom_type to "pattern" (threshold: 3 observations)
574
+ bash .aether/aether-utils.sh learning-observe "$claim" "pattern" "$colony_name" 2>/dev/null || true
575
+ fi
576
+ done
577
+ echo "Recorded observations for threshold tracking"
578
+ else
579
+ echo "No learnings to record"
580
+ fi
581
+ ```
582
+
583
+ This records each learning in `learning-observations.json` with:
584
+ - Content hash for deduplication (same claim across phases increments count)
585
+ - Observation count (increments if seen before)
586
+ - Colony name for cross-colony tracking
587
+
588
+ When observations reach threshold (default: 3 for "pattern" type), they become eligible for promotion in Step 2.1.5.
589
+
590
+ 3. **Extract instincts from patterns:**
591
+
592
+ Read activity.log for patterns from this phase's build.
593
+
594
+ For each pattern observed (success, error_resolution, user_feedback):
595
+
596
+ **If pattern matches existing instinct:**
597
+ - Update confidence: +0.1 for success outcome, -0.1 for failure
598
+ - Increment applications count
599
+ - Update last_applied timestamp
600
+
601
+ **If new pattern:**
602
+ - Create new instinct with initial confidence:
603
+ - success: 0.4
604
+ - error_resolution: 0.5
605
+ - user_feedback: 0.7
606
+
607
+ Append to `memory.instincts`:
608
+ ```json
609
+ {
610
+ "id": "instinct_<unix_timestamp>",
611
+ "trigger": "<when X>",
612
+ "action": "<do Y>",
613
+ "confidence": 0.5,
614
+ "status": "hypothesis",
615
+ "domain": "<testing|architecture|code-style|debugging|workflow>",
616
+ "source": "phase-<id>",
617
+ "evidence": ["<specific observation that led to this>"],
618
+ "tested": false,
619
+ "created_at": "<ISO-8601>",
620
+ "last_applied": null,
621
+ "applications": 0,
622
+ "successes": 0,
623
+ "failures": 0
624
+ }
625
+ ```
626
+
627
+ **Instinct confidence updates:**
628
+ - Success when applied: +0.1, increment `successes`
629
+ - Failure when applied: -0.15, increment `failures`
630
+ - If `failures` >= 2 and `successes` == 0: mark `status: "disproven"`
631
+ - If `successes` >= 2 and tested: mark `status: "validated"`
632
+
633
+ Cap: Keep max 30 instincts (remove lowest confidence when exceeded).
634
+
635
+ 4. **Advance state:**
636
+ - Set `current_phase` to next phase number
637
+ - Set `state` to `"READY"`
638
+ - Set `build_started_at` to null
639
+ - Append event: `"<timestamp>|phase_advanced|continue|Completed Phase <id>, advancing to Phase <next>"`
640
+
641
+ 5. **Cap enforcement:**
642
+ - Keep max 20 phase_learnings
643
+ - Keep max 30 decisions
644
+ - Keep max 30 instincts (remove lowest confidence)
645
+ - Keep max 100 events
646
+
647
+ Write COLONY_STATE.json.
648
+
649
+ Validate the state file:
650
+ Run using the Bash tool with description "Validating colony state...": `bash .aether/aether-utils.sh validate-state colony`
651
+
652
+ ### Step 2.1: Auto-Emit Phase Pheromones (SILENT)
653
+
654
+ **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.
655
+
656
+ #### 2.1a: Auto-emit FEEDBACK pheromone for phase outcome
657
+
658
+ After learning extraction completes in Step 2, auto-emit a FEEDBACK signal summarizing the phase:
659
+
660
+ ```bash
661
+ # phase_id and phase_name come from Step 2 state update
662
+ # Take the top 1-3 learnings by evidence strength from memory.phase_learnings
663
+ # Compress into a single summary sentence
664
+
665
+ # If learnings were extracted, build a brief summary from them (first 1-3 claims)
666
+ # Otherwise use the minimal fallback
667
+ phase_feedback="Phase $phase_id ($phase_name) completed. Key patterns: {brief summary of 1-3 learnings from Step 2}"
668
+ # Fallback if no learnings: "Phase $phase_id ($phase_name) completed without notable patterns."
669
+
670
+ bash .aether/aether-utils.sh pheromone-write FEEDBACK "$phase_feedback" \
671
+ --strength 0.6 \
672
+ --source "worker:continue" \
673
+ --reason "Auto-emitted on phase advance: captures what worked and what was learned" \
674
+ --ttl "phase_end" 2>/dev/null || true
675
+ ```
676
+
677
+ 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 "phase_end" so the signal survives through the NEXT phase and expires when THAT phase advances.
678
+
679
+ #### 2.1b: Auto-emit REDIRECT for recurring error patterns
680
+
681
+ Check `errors.flagged_patterns[]` in COLONY_STATE.json for patterns that have appeared in 2+ phases:
682
+
683
+ ```bash
684
+ flagged_patterns=$(jq -r '.errors.flagged_patterns[]? | select(.count >= 2) | .pattern' .aether/data/COLONY_STATE.json 2>/dev/null || true)
685
+ ```
686
+
687
+ For each pattern returned by the above query, emit a REDIRECT signal:
688
+
689
+ ```bash
690
+ bash .aether/aether-utils.sh pheromone-write REDIRECT "$pattern_text" \
691
+ --strength 0.7 \
692
+ --source "system" \
693
+ --reason "Auto-emitted: error pattern recurred across 2+ phases" \
694
+ --ttl "30d" 2>/dev/null || true
695
+ ```
696
+
697
+ REDIRECT strength is 0.7 (higher than auto FEEDBACK 0.6 — anti-patterns produce stronger signals than successes). TTL is 30d (not phase_end) because recurring errors should persist across multiple phases.
698
+
699
+ If `errors.flagged_patterns` doesn't exist or is empty, skip silently.
700
+
701
+ #### 2.1c: Expire phase_end signals and archive to midden
702
+
703
+ After auto-emission, expire all signals with `expires_at == "phase_end"`. The newly-emitted FEEDBACK from 2.1a will survive this call (it was just written and is active) — it will expire when the NEXT phase advances.
704
+
705
+ 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`
706
+
707
+ This is idempotent — runs every time continue fires but only creates the directory/file once.
708
+
709
+ ### Step 2.1.5: Check for Promotion Proposals (PHER-EVOL-02)
710
+
711
+ After extracting learnings, check for observations that have met promotion thresholds and present the tick-to-approve UX.
712
+
713
+ **Check for --deferred flag:**
714
+
715
+ If `$ARGUMENTS` contains `--deferred`:
716
+ ```bash
717
+ if [[ "$ARGUMENTS" == *"--deferred"* ]] && [[ -f .aether/data/learning-deferred.json ]]; then
718
+ echo "📦 Reviewing deferred proposals..."
719
+ bash .aether/aether-utils.sh learning-approve-proposals --deferred ${verbose:+--verbose}
720
+ fi
721
+ ```
722
+
723
+ **Normal proposal flow (MEM-01: Silent skip if empty):**
724
+
725
+ 1. **Check for proposals:**
726
+ ```bash
727
+ proposals=$(bash .aether/aether-utils.sh learning-check-promotion 2>/dev/null || echo '{"proposals":[]}')
728
+ proposal_count=$(echo "$proposals" | jq '.proposals | length')
729
+ ```
730
+
731
+ 2. **If proposals exist, invoke the approval workflow:**
732
+
733
+ Only show the approval UI when there are actual proposals to review:
734
+
735
+ ```bash
736
+ if [[ "$proposal_count" -gt 0 ]]; then
737
+ verbose_flag=""
738
+ [[ "$ARGUMENTS" == *"--verbose"* ]] && verbose_flag="--verbose"
739
+ bash .aether/aether-utils.sh learning-approve-proposals $verbose_flag
740
+ fi
741
+ # If no proposals, silently skip without notice (per user decision)
742
+ ```
743
+
744
+ The learning-approve-proposals function handles:
745
+ - Displaying proposals with checkbox UI
746
+ - Capturing user selection
747
+ - Executing batch promotions via queen-promote
748
+ - Deferring unselected proposals
749
+ - Offering undo after successful promotions
750
+ - Logging PROMOTED activity
751
+
752
+ **Skip conditions:**
753
+ - learning-check-promotion returns empty or fails
754
+ - No proposals to review (silent skip - no output)
755
+ - QUEEN.md does not exist
756
+
757
+ ### Step 2.2: Update Handoff Document
758
+
759
+ After advancing the phase, update the handoff document with the new current state:
760
+
761
+ ```bash
762
+ # Determine if there's a next phase
763
+ next_phase_id=$((current_phase + 1))
764
+ has_next_phase=$(jq --arg next "$next_phase_id" '.plan.phases | map(select(.id == ($next | tonumber))) | length' .aether/data/COLONY_STATE.json)
765
+
766
+ # Write updated handoff
767
+ cat > .aether/HANDOFF.md << 'HANDOFF_EOF'
768
+ # Colony Session — Phase Advanced
769
+
770
+ ## Quick Resume
771
+ Run `/ant:build {next_phase_id}` to start working on the current phase.
772
+
773
+ ## State at Advancement
774
+ - Goal: "$(jq -r '.goal' .aether/data/COLONY_STATE.json)"
775
+ - Completed Phase: {completed_phase_id} — {completed_phase_name}
776
+ - Current Phase: {next_phase_id} — {next_phase_name}
777
+ - State: READY
778
+ - Updated: $(date -u +%Y-%m-%dT%H:%M:%SZ)
779
+
780
+ ## What Was Completed
781
+ - Phase {completed_phase_id} marked as completed
782
+ - Learnings extracted: {learning_count}
783
+ - Instincts updated: {instinct_count}
784
+ - Wisdom promoted to QUEEN.md: {promoted_count}
785
+
786
+ ## Current Phase Tasks
787
+ $(jq -r '.plan.phases[] | select(.id == next_phase_id) | .tasks[] | "- [ ] \(.id): \(.description)"' .aether/data/COLONY_STATE.json)
788
+
789
+ ## Next Steps
790
+ - Build current phase: `/ant:build {next_phase_id}`
791
+ - Review phase details: `/ant:phase {next_phase_id}`
792
+ - Pause colony: `/ant:pause-colony`
793
+
794
+ ## Session Note
795
+ Phase advanced successfully. Colony is READY to build Phase {next_phase_id}.
796
+ HANDOFF_EOF
797
+ ```
798
+
799
+ This handoff reflects the post-advancement state, allowing seamless resumption even if the session is lost.
800
+
801
+ ### Step 2.3: Update Changelog
802
+
803
+ **Append a changelog entry for the completed phase.**
804
+
805
+ If `CHANGELOG.md` exists in the project root:
806
+
807
+ 1. Read the file
808
+ 2. Find the `## [Unreleased]` section
809
+ 3. Under the appropriate sub-heading (`### Added`, `### Changed`, or `### Fixed`), append a bullet for the completed phase:
810
+
811
+ ```
812
+ - **Phase {id}: {phase_name}** — {one-line summary of what was accomplished}. ({list of key files modified})
813
+ ```
814
+
815
+ **Determining the sub-heading:**
816
+ - If the phase created new features/commands → `### Added`
817
+ - If the phase modified existing behavior → `### Changed`
818
+ - If the phase fixed bugs → `### Fixed`
819
+ - If unclear, default to `### Changed`
820
+
821
+ **The one-line summary** should describe the user-visible outcome, not implementation details. Derive it from the phase description and task summaries.
822
+
823
+ **If no `## [Unreleased]` section exists**, create one at the top of the file (after the header).
824
+
825
+ **If no `CHANGELOG.md` exists**, skip this step silently.
826
+
827
+ ### Step 2.4: Commit Suggestion (Optional)
828
+
829
+ **This step is non-blocking. Skipping does not affect phase advancement or any subsequent steps. Failure to commit has zero consequences.**
830
+
831
+ After the phase is advanced and changelog updated, suggest a commit to preserve the milestone.
832
+
833
+ #### Step 2.4.1: Capture AI Description
834
+
835
+ **As the AI, briefly describe what was accomplished in this phase.**
836
+
837
+ Look at:
838
+ 1. The phase PLAN.md `<objective>` section (what we set out to do)
839
+ 2. Tasks that were marked complete
840
+ 3. Files that were modified (from git diff --stat)
841
+ 4. Any patterns or decisions recorded
842
+
843
+ **Provide a brief, memorable description** (10-15 words, imperative mood):
844
+ - Good: "Implement task-based model routing with keyword detection and precedence chain"
845
+ - Good: "Fix build timing by removing background execution from worker spawns"
846
+ - Bad: "Phase complete" (too vague)
847
+ - Bad: "Modified files in bin/lib" (too mechanical)
848
+
849
+ Store this as `ai_description` for the commit message.
850
+
851
+ #### Step 2.4.2: Generate Enhanced Commit Message
852
+
853
+ ```bash
854
+ bash .aether/aether-utils.sh generate-commit-message "contextual" {phase_id} "{phase_name}" "{ai_description}" {plan_number}
855
+ ```
856
+
857
+ Parse the returned JSON to extract:
858
+ - `message` - the commit subject line
859
+ - `body` - structured metadata (Scope, Files)
860
+ - `files_changed` - file count
861
+ - `subsystem` - derived subsystem name
862
+ - `scope` - phase.plan format
863
+
864
+ **Check files changed:**
865
+ ```bash
866
+ git diff --stat HEAD 2>/dev/null | tail -5
867
+ ```
868
+ If not in a git repo or no changes detected, skip this step silently.
869
+
870
+ **Display the enhanced suggestion:**
871
+ ```
872
+ ──────────────────────────────────────────────────
873
+ Commit Suggestion
874
+ ──────────────────────────────────────────────────
875
+
876
+ AI Description: {ai_description}
877
+
878
+ Formatted Message:
879
+ {message}
880
+
881
+ Metadata:
882
+ Scope: {scope}
883
+ Files: {files_changed} files changed
884
+ Preview: {first 5 lines of git diff --stat}
885
+
886
+ ──────────────────────────────────────────────────
887
+ ```
888
+
889
+ **Use AskUserQuestion:**
890
+ ```
891
+ Commit this milestone?
892
+
893
+ 1. Yes, commit with this message
894
+ 2. Yes, but let me edit the description
895
+ 3. No, I'll commit later
896
+ ```
897
+
898
+ **If option 1 ("Yes, commit with this message"):**
899
+ ```bash
900
+ git add -A && git commit -m "{message}" -m "{body}"
901
+ ```
902
+ Display: `Committed: {message} ({files_changed} files)`
903
+
904
+ **If option 2 ("Yes, but let me edit"):**
905
+ Use AskUserQuestion to get the user's custom description:
906
+ ```
907
+ Enter your description (or press Enter to keep: '{ai_description}'):
908
+ ```
909
+ Then regenerate the commit message with the new description and commit.
910
+
911
+ **If option 3 ("No, I'll commit later"):**
912
+ Display: `Skipped. Your changes are saved on disk but not committed.`
913
+
914
+ **Record the suggestion to prevent double-prompting:**
915
+ Set `last_commit_suggestion_phase` to `{phase_id}` in COLONY_STATE.json (add the field at the top level if it does not exist).
916
+
917
+ **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.
918
+
919
+ Continue to Step 2.5 (Context Clear Suggestion), then to Step 2.7 (Project Completion) or Step 3 (Display Result).
920
+
921
+ ### Step 2.5: Context Clear Suggestion (Optional)
922
+
923
+ **This step is non-blocking. Skipping does not affect phase advancement.**
924
+
925
+ After committing (or skipping commit), suggest clearing context to refresh before the next phase.
926
+
927
+ 1. **Display the suggestion:**
928
+ ```
929
+ ──────────────────────────────────────────────────
930
+ Context Refresh
931
+ ──────────────────────────────────────────────────
932
+
933
+ State is fully persisted and committed.
934
+ Phase {next_id} is ready to build.
935
+
936
+ ──────────────────────────────────────────────────
937
+ ```
938
+
939
+ 2. **Use AskUserQuestion:**
940
+ ```
941
+ Clear context now?
942
+
943
+ 1. Yes, clear context then run /ant:build {next_id}
944
+ 2. No, continue in current context
945
+ ```
946
+
947
+ 3. **If option 1 ("Yes, clear context"):**
948
+
949
+ **IMPORTANT:** Claude Code does not support programmatic /clear. Display instructions:
950
+ ```
951
+ Please type: /clear
952
+
953
+ Then run: /ant:build {next_id}
954
+ ```
955
+
956
+ Record the suggestion: Set `context_clear_suggested` to `true` in COLONY_STATE.json.
957
+
958
+ 4. **If option 2 ("No, continue in current context"):**
959
+ Display: `Continuing in current context. State is saved.`
960
+
961
+ Continue to Step 2.7 (Project Completion) or Step 3 (Display Result).
962
+
963
+ ### Step 2.6: Update Context Document
964
+
965
+ After phase advancement is complete, update `.aether/CONTEXT.md`:
966
+
967
+ **Log the activity:**
968
+ ```bash
969
+ bash .aether/aether-utils.sh context-update activity "continue" "Phase {prev_id} completed, advanced to {next_id}" "—"
970
+ ```
971
+
972
+ **Update the phase:**
973
+ ```bash
974
+ bash .aether/aether-utils.sh context-update update-phase {next_id} "{next_phase_name}" "YES" "Phase advanced, ready to build"
975
+ ```
976
+
977
+ **Log any decisions from this session:**
978
+ If any architectural decisions were made during verification, also run:
979
+ ```bash
980
+ bash .aether/aether-utils.sh context-update decision "{decision_description}" "{rationale}" "Queen"
981
+ ```
982
+
983
+ ### Step 2.7: Project Completion
984
+
985
+ Runs ONLY when all phases complete.
986
+
987
+ 1. Read activity.log and errors.records
988
+ 2. Display tech debt report:
989
+
990
+ ```
991
+ ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
992
+ 🎉 P R O J E C T C O M P L E T E 🎉
993
+ ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
994
+
995
+ 👑 Goal Achieved: {goal}
996
+ 📍 Phases Completed: {total}
997
+
998
+ {if flagged_patterns:}
999
+ ⚠️ Persistent Issues:
1000
+ {list any flagged_patterns}
1001
+ {end if}
1002
+
1003
+ 🧠 Colony Learnings:
1004
+ {condensed learnings from memory.phase_learnings}
1005
+
1006
+ 👑 Wisdom Added to QUEEN.md:
1007
+ {count} patterns/redirects/philosophies promoted across all phases
1008
+
1009
+ 🐜 The colony rests. Well done!
1010
+ ```
1011
+
1012
+ 3. Write summary to `.aether/data/completion-report.md`
1013
+ 4. Display next commands and stop.
1014
+
1015
+ ### Step 3: Display Result
1016
+
1017
+ **If visual_mode is true, render final swarm display:**
1018
+ Run using the Bash tool with description "Rendering advancement summary...": `bash .aether/aether-utils.sh swarm-display-update "Queen" "prime" "completed" "Phase advanced" "Colony" '{"read":5,"grep":2,"edit":3,"bash":2}' 100 "fungus_garden" 100 && bash .aether/aether-utils.sh swarm-display-text "$continue_id"`
1019
+
1020
+ Output:
1021
+
1022
+ ```
1023
+ ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
1024
+ P H A S E A D V A N C E M E N T
1025
+ ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
1026
+
1027
+ ✅ Phase {prev_id}: {prev_name} -- COMPLETED
1028
+
1029
+ 🧠 Learnings Extracted:
1030
+ {list learnings added}
1031
+
1032
+ 👑 Wisdom Promoted to QUEEN.md:
1033
+ {for each promoted learning:}
1034
+ [{type}] {brief claim}
1035
+ {end for}
1036
+
1037
+ 🐜 Instincts Updated:
1038
+ {for each instinct created or updated:}
1039
+ [{confidence}] {domain}: {action}
1040
+ {end for}
1041
+
1042
+ ─────────────────────────────────────────────────────
1043
+
1044
+ ➡️ Advancing to Phase {next_id}: {next_name}
1045
+ {next_description}
1046
+ 📋 Tasks: {task_count}
1047
+ 📊 State: READY
1048
+
1049
+ ──────────────────────────────────────────────────
1050
+ 🐜 Next Up
1051
+ ──────────────────────────────────────────────────
1052
+ /ant:build {next_id} 🔨 Build next phase
1053
+ /ant:status 📊 Check progress
1054
+
1055
+ 💾 State persisted — context clear suggested above
1056
+
1057
+ 📋 Context document updated at `.aether/CONTEXT.md`
1058
+ ```
1059
+
1060
+ **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}`.
1061
+
1062
+ ### Step 4: Update Session
1063
+
1064
+ Update the session tracking file to enable `/ant:resume` after context clear:
1065
+
1066
+ ```bash
1067
+ bash .aether/aether-utils.sh session-update "/ant:continue" "/ant:build {next_id}" "Phase {prev_id} completed, advanced to Phase {next_id}"
1068
+ ```
1069
+
1070
+ 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}"`