aether-colony 3.1.17 → 5.0.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 (183) hide show
  1. package/{runtime → .aether}/CONTEXT.md +1 -1
  2. package/{runtime → .aether}/aether-utils.sh +1772 -98
  3. package/.aether/docs/QUEEN-SYSTEM.md +211 -0
  4. package/.aether/docs/QUEEN.md +84 -0
  5. package/.aether/docs/README.md +68 -0
  6. package/.aether/docs/caste-system.md +48 -0
  7. package/{runtime → .aether/docs/disciplines}/DISCIPLINES.md +8 -8
  8. package/.aether/docs/error-codes.md +268 -0
  9. package/{runtime → .aether}/docs/known-issues.md +42 -26
  10. package/.aether/docs/queen-commands.md +97 -0
  11. package/.aether/exchange/colony-registry.xml +11 -0
  12. package/{runtime → .aether}/exchange/pheromone-xml.sh +2 -1
  13. package/.aether/exchange/pheromones.xml +87 -0
  14. package/.aether/exchange/queen-wisdom.xml +14 -0
  15. package/{runtime → .aether}/exchange/registry-xml.sh +7 -3
  16. package/{runtime → .aether}/exchange/wisdom-xml.sh +11 -4
  17. package/.aether/rules/aether-colony.md +134 -0
  18. package/.aether/schemas/example-prompt-builder.xml +234 -0
  19. package/.aether/templates/colony-state-reset.jq.template +22 -0
  20. package/.aether/templates/colony-state.template.json +35 -0
  21. package/.aether/templates/constraints.template.json +9 -0
  22. package/.aether/templates/crowned-anthill.template.md +36 -0
  23. package/.aether/templates/handoff-build-error.template.md +30 -0
  24. package/.aether/templates/handoff-build-success.template.md +39 -0
  25. package/.aether/templates/handoff.template.md +40 -0
  26. package/{runtime → .aether}/utils/atomic-write.sh +5 -5
  27. package/{runtime → .aether}/utils/chamber-compare.sh +23 -10
  28. package/{runtime → .aether}/utils/chamber-utils.sh +32 -20
  29. package/{runtime → .aether}/utils/error-handler.sh +13 -1
  30. package/{runtime → .aether}/utils/file-lock.sh +49 -13
  31. package/.aether/utils/semantic-cli.sh +413 -0
  32. package/{runtime → .aether}/utils/xml-compose.sh +7 -1
  33. package/.aether/utils/xml-convert.sh +273 -0
  34. package/.aether/utils/xml-query.sh +201 -0
  35. package/.aether/utils/xml-utils.sh +110 -0
  36. package/{runtime → .aether}/workers.md +14 -17
  37. package/.claude/agents/ant/aether-ambassador.md +264 -0
  38. package/.claude/agents/ant/aether-archaeologist.md +322 -0
  39. package/.claude/agents/ant/aether-auditor.md +266 -0
  40. package/.claude/agents/ant/aether-builder.md +187 -0
  41. package/.claude/agents/ant/aether-chaos.md +268 -0
  42. package/.claude/agents/ant/aether-chronicler.md +304 -0
  43. package/.claude/agents/ant/aether-gatekeeper.md +325 -0
  44. package/.claude/agents/ant/aether-includer.md +373 -0
  45. package/.claude/agents/ant/aether-keeper.md +271 -0
  46. package/.claude/agents/ant/aether-measurer.md +317 -0
  47. package/.claude/agents/ant/aether-probe.md +210 -0
  48. package/.claude/agents/ant/aether-queen.md +325 -0
  49. package/.claude/agents/ant/aether-route-setter.md +173 -0
  50. package/.claude/agents/ant/aether-sage.md +353 -0
  51. package/.claude/agents/ant/aether-scout.md +142 -0
  52. package/.claude/agents/ant/aether-surveyor-disciplines.md +416 -0
  53. package/.claude/agents/ant/aether-surveyor-nest.md +354 -0
  54. package/.claude/agents/ant/aether-surveyor-pathogens.md +288 -0
  55. package/.claude/agents/ant/aether-surveyor-provisions.md +359 -0
  56. package/.claude/agents/ant/aether-tracker.md +265 -0
  57. package/.claude/agents/ant/aether-watcher.md +244 -0
  58. package/.claude/agents/ant/aether-weaver.md +247 -0
  59. package/.claude/commands/ant/archaeology.md +16 -7
  60. package/.claude/commands/ant/build.md +415 -284
  61. package/.claude/commands/ant/chaos.md +19 -10
  62. package/.claude/commands/ant/colonize.md +58 -24
  63. package/.claude/commands/ant/continue.md +155 -145
  64. package/.claude/commands/ant/council.md +15 -5
  65. package/.claude/commands/ant/dream.md +16 -7
  66. package/.claude/commands/ant/entomb.md +274 -157
  67. package/.claude/commands/ant/feedback.md +33 -29
  68. package/.claude/commands/ant/flag.md +18 -10
  69. package/.claude/commands/ant/flags.md +14 -6
  70. package/.claude/commands/ant/focus.md +29 -21
  71. package/.claude/commands/ant/help.md +11 -1
  72. package/.claude/commands/ant/history.md +10 -0
  73. package/.claude/commands/ant/init.md +91 -65
  74. package/.claude/commands/ant/interpret.md +15 -4
  75. package/.claude/commands/ant/lay-eggs.md +55 -7
  76. package/.claude/commands/ant/maturity.md +11 -1
  77. package/.claude/commands/ant/migrate-state.md +14 -2
  78. package/.claude/commands/ant/oracle.md +23 -15
  79. package/.claude/commands/ant/organize.md +29 -20
  80. package/.claude/commands/ant/pause-colony.md +17 -7
  81. package/.claude/commands/ant/phase.md +17 -8
  82. package/.claude/commands/ant/plan.md +20 -9
  83. package/.claude/commands/ant/redirect.md +29 -32
  84. package/.claude/commands/ant/resume-colony.md +19 -9
  85. package/.claude/commands/ant/resume.md +272 -96
  86. package/.claude/commands/ant/seal.md +201 -191
  87. package/.claude/commands/ant/status.md +71 -32
  88. package/.claude/commands/ant/swarm.md +26 -44
  89. package/.claude/commands/ant/tunnels.md +279 -105
  90. package/.claude/commands/ant/update.md +81 -20
  91. package/.claude/commands/ant/verify-castes.md +14 -4
  92. package/.claude/commands/ant/watch.md +13 -12
  93. package/.opencode/agents/aether-ambassador.md +63 -20
  94. package/.opencode/agents/aether-archaeologist.md +29 -12
  95. package/.opencode/agents/aether-auditor.md +51 -18
  96. package/.opencode/agents/aether-builder.md +69 -19
  97. package/.opencode/agents/aether-chaos.md +29 -12
  98. package/.opencode/agents/aether-chronicler.md +60 -18
  99. package/.opencode/agents/aether-gatekeeper.md +27 -18
  100. package/.opencode/agents/aether-includer.md +27 -18
  101. package/.opencode/agents/aether-keeper.md +89 -18
  102. package/.opencode/agents/aether-measurer.md +27 -18
  103. package/.opencode/agents/aether-probe.md +60 -18
  104. package/.opencode/agents/aether-queen.md +172 -24
  105. package/.opencode/agents/aether-route-setter.md +57 -12
  106. package/.opencode/agents/aether-sage.md +26 -18
  107. package/.opencode/agents/aether-scout.md +27 -19
  108. package/.opencode/agents/aether-surveyor-disciplines.md +53 -1
  109. package/.opencode/agents/aether-surveyor-nest.md +53 -1
  110. package/.opencode/agents/aether-surveyor-pathogens.md +51 -1
  111. package/.opencode/agents/aether-surveyor-provisions.md +53 -1
  112. package/.opencode/agents/aether-tracker.md +64 -18
  113. package/.opencode/agents/aether-watcher.md +66 -19
  114. package/.opencode/agents/aether-weaver.md +61 -18
  115. package/.opencode/commands/ant/build.md +406 -192
  116. package/.opencode/commands/ant/continue.md +66 -76
  117. package/.opencode/commands/ant/entomb.md +106 -45
  118. package/.opencode/commands/ant/init.md +46 -48
  119. package/.opencode/commands/ant/organize.md +5 -5
  120. package/.opencode/commands/ant/resume.md +334 -0
  121. package/.opencode/commands/ant/seal.md +33 -24
  122. package/.opencode/commands/ant/status.md +11 -0
  123. package/.opencode/commands/ant/tunnels.md +149 -0
  124. package/.opencode/commands/ant/update.md +59 -16
  125. package/CHANGELOG.md +79 -0
  126. package/README.md +135 -353
  127. package/bin/cli.js +243 -122
  128. package/bin/generate-commands.sh +2 -2
  129. package/bin/lib/init.js +13 -3
  130. package/bin/lib/update-transaction.js +119 -117
  131. package/bin/sync-to-runtime.sh +5 -137
  132. package/bin/validate-package.sh +84 -0
  133. package/package.json +9 -6
  134. package/.opencode/agents/aether-architect.md +0 -66
  135. package/.opencode/agents/aether-guardian.md +0 -107
  136. package/.opencode/agents/workers.md +0 -1034
  137. package/runtime/QUEEN_ANT_ARCHITECTURE.md +0 -402
  138. package/runtime/data/signatures.json +0 -41
  139. package/runtime/docs/AETHER-2.0-IMPLEMENTATION-PLAN.md +0 -1343
  140. package/runtime/docs/AETHER-PHEROMONE-SYSTEM-MASTER-SPEC.md +0 -2642
  141. package/runtime/docs/PHEROMONE-INJECTION.md +0 -240
  142. package/runtime/docs/PHEROMONE-INTEGRATION.md +0 -192
  143. package/runtime/docs/PHEROMONE-SYSTEM-DESIGN.md +0 -426
  144. package/runtime/docs/README.md +0 -94
  145. package/runtime/docs/VISUAL-OUTPUT-SPEC.md +0 -219
  146. package/runtime/docs/biological-reference.md +0 -272
  147. package/runtime/docs/codebase-review.md +0 -399
  148. package/runtime/docs/command-sync.md +0 -164
  149. package/runtime/docs/constraints.md +0 -116
  150. package/runtime/docs/implementation-learnings.md +0 -89
  151. package/runtime/docs/namespace.md +0 -148
  152. package/runtime/docs/pathogen-schema-example.json +0 -36
  153. package/runtime/docs/pathogen-schema.md +0 -111
  154. package/runtime/docs/planning-discipline.md +0 -159
  155. package/runtime/docs/progressive-disclosure.md +0 -184
  156. package/runtime/lib/queen-utils.sh +0 -729
  157. package/runtime/planning.md +0 -159
  158. package/runtime/recover.sh +0 -136
  159. package/runtime/utils/xml-utils.sh +0 -2196
  160. package/runtime/workers-new-castes.md +0 -516
  161. /package/{runtime → .aether/docs/disciplines}/coding-standards.md +0 -0
  162. /package/{runtime → .aether/docs/disciplines}/debugging.md +0 -0
  163. /package/{runtime → .aether/docs/disciplines}/learning.md +0 -0
  164. /package/{runtime → .aether/docs/disciplines}/tdd.md +0 -0
  165. /package/{runtime → .aether/docs/disciplines}/verification-loop.md +0 -0
  166. /package/{runtime → .aether/docs/disciplines}/verification.md +0 -0
  167. /package/{runtime → .aether}/docs/pheromones.md +0 -0
  168. /package/{runtime → .aether}/model-profiles.yaml +0 -0
  169. /package/{runtime → .aether}/schemas/aether-types.xsd +0 -0
  170. /package/{runtime → .aether}/schemas/colony-registry.xsd +0 -0
  171. /package/{runtime → .aether}/schemas/pheromone.xsd +0 -0
  172. /package/{runtime → .aether}/schemas/prompt.xsd +0 -0
  173. /package/{runtime → .aether}/schemas/queen-wisdom.xsd +0 -0
  174. /package/{runtime → .aether}/schemas/worker-priming.xsd +0 -0
  175. /package/{runtime → .aether}/templates/QUEEN.md.template +0 -0
  176. /package/{runtime → .aether}/utils/colorize-log.sh +0 -0
  177. /package/{runtime → .aether}/utils/queen-to-md.xsl +0 -0
  178. /package/{runtime → .aether}/utils/spawn-tree.sh +0 -0
  179. /package/{runtime → .aether}/utils/spawn-with-model.sh +0 -0
  180. /package/{runtime → .aether}/utils/state-loader.sh +0 -0
  181. /package/{runtime → .aether}/utils/swarm-display.sh +0 -0
  182. /package/{runtime → .aether}/utils/watch-spawn-tree.sh +0 -0
  183. /package/{runtime → .aether}/utils/xml-core.sh +0 -0
@@ -0,0 +1,268 @@
1
+ # Aether Error Code Reference
2
+
3
+ This document is the complete reference for all `E_*` error constants used in Aether's bash utilities and Node.js CLI. When a command fails, the error output includes a `code` field that maps to one of the entries below.
4
+
5
+ **How to read this document:** Find the code you see in the error output, then check the meaning, when it happens, and what to do.
6
+
7
+ ---
8
+
9
+ ## File Errors
10
+
11
+ ### E_FILE_NOT_FOUND
12
+
13
+ - **Meaning:** A required file or directory doesn't exist at the expected path.
14
+ - **When it happens:**
15
+ - A command is invoked but the data file it needs (e.g., `COLONY_STATE.json`, `flags.json`, `CONTEXT.md`) hasn't been created yet.
16
+ - A directory path passed as an argument doesn't exist.
17
+ - **Suggested fix:** Check that `aether init` (or the relevant setup command) has been run. Verify the path exists and is spelled correctly.
18
+ - **Example output:**
19
+ ```json
20
+ {"ok":false,"error":{"code":"E_FILE_NOT_FOUND","message":"Couldn't find CONTEXT.md. Try: run context-update init first.","details":null,"recovery":"Check file path and permissions","timestamp":"2026-02-19T13:00:00Z"}}
21
+ ```
22
+
23
+ ---
24
+
25
+ ## Lock Errors
26
+
27
+ ### E_LOCK_FAILED
28
+
29
+ - **Meaning:** Couldn't acquire a file lock — another process is currently holding it.
30
+ - **When it happens:**
31
+ - Two commands try to write to the same file (e.g., `flags.json`) at the same time.
32
+ - A previous command crashed and didn't release its lock. Use `force-unlock` to clear stale locks.
33
+ - **Suggested fix:** Wait for any running operations to finish, then retry. If you're sure nothing else is running, use `aether force-unlock` to clear the lock manually.
34
+ - **Example output:**
35
+ ```json
36
+ {"ok":false,"error":{"code":"E_LOCK_FAILED","message":"Failed to acquire lock on flags.json","details":null,"recovery":"Wait for other operations to complete","timestamp":"2026-02-19T13:00:00Z"}}
37
+ ```
38
+
39
+ ### E_LOCK_STALE
40
+
41
+ - **Meaning:** A lock file exists but belongs to a process that is no longer running, or has exceeded the maximum lock timeout (5 minutes). This differs from `E_LOCK_FAILED` (which means another process holds a live lock) — `E_LOCK_STALE` means the lock is abandoned.
42
+ - **When it happens:**
43
+ - A previous command crashed without releasing its lock.
44
+ - The locking process was killed by the OS (e.g., OOM) or terminated by the user (Ctrl+C) before the trap handler could fire.
45
+ - The lock is older than the configured timeout (300 seconds).
46
+ - **Suggested fix:** Run `aether force-unlock` to clear stale locks, or manually remove the lock file shown in the error message.
47
+ - **Example output:**
48
+ ```json
49
+ {"ok":false,"error":{"code":"E_LOCK_STALE","message":"Stale lock found. Remove manually: .aether/locks/flags.json.lock"}}
50
+ ```
51
+
52
+ ---
53
+
54
+ ## Tool / Dependency Errors
55
+
56
+ ### E_FEATURE_UNAVAILABLE
57
+
58
+ - **Meaning:** A feature or optional tool required for this operation isn't installed or enabled.
59
+ - **When it happens:**
60
+ - XML operations are attempted but `xmllint` isn't installed.
61
+ - A feature has been disabled due to a missing dependency or configuration.
62
+ - **Suggested fix:** Install the required tool (e.g., `brew install libxml2` for xmllint on macOS) or check the feature's documentation for setup steps.
63
+ - **Example output:**
64
+ ```json
65
+ {"ok":false,"error":{"code":"E_FEATURE_UNAVAILABLE","message":"xmllint not available. Try: brew install libxml2","details":null,"recovery":null,"timestamp":"2026-02-19T13:00:00Z"}}
66
+ ```
67
+
68
+ ### E_DEPENDENCY_MISSING
69
+
70
+ - **Meaning:** A required utility script or binary is missing from the expected location.
71
+ - **When it happens:**
72
+ - A utility script in `.aether/utils/` (e.g., `error-handler.sh`, `file-lock.sh`) can't be found.
73
+ - A required binary (e.g., `jq`, `git`) isn't installed or isn't on `$PATH`.
74
+ - **Suggested fix:** Run `aether install` to restore missing system files, or install the missing binary via your system package manager.
75
+ - **Example output:**
76
+ ```json
77
+ {"ok":false,"error":{"code":"E_DEPENDENCY_MISSING","message":"Couldn't load error-handler.sh. Try: run aether install to restore system files.","details":null,"recovery":"Install the required dependency","timestamp":"2026-02-19T13:00:00Z"}}
78
+ ```
79
+
80
+ ---
81
+
82
+ ## JSON / Data Errors
83
+
84
+ ### E_JSON_INVALID
85
+
86
+ - **Meaning:** A JSON file is malformed or is missing required fields.
87
+ - **When it happens:**
88
+ - A data file (`COLONY_STATE.json`, `flags.json`, etc.) has been manually edited and contains a syntax error.
89
+ - A write operation was interrupted, leaving a partially-written file.
90
+ - **Suggested fix:** Open the file and fix the JSON syntax, or delete it and re-run the initialization command to regenerate a fresh copy.
91
+ - **Example output:**
92
+ ```json
93
+ {"ok":false,"error":{"code":"E_JSON_INVALID","message":"Failed to parse COLONY_STATE.json. Try: validate with jq '.'' .aether/data/COLONY_STATE.json","details":null,"recovery":"Validate JSON syntax","timestamp":"2026-02-19T13:00:00Z"}}
94
+ ```
95
+
96
+ ---
97
+
98
+ ## Validation Errors
99
+
100
+ ### E_VALIDATION_FAILED
101
+
102
+ - **Meaning:** The command was called with missing or invalid arguments.
103
+ - **When it happens:**
104
+ - A required argument (e.g., flag type, flag ID, spawn summary) is missing.
105
+ - An argument value is outside the allowed range or format.
106
+ - **Suggested fix:** Check the usage message in the error output. The error message typically includes the correct usage syntax.
107
+ - **Example output:**
108
+ ```json
109
+ {"ok":false,"error":{"code":"E_VALIDATION_FAILED","message":"Usage: flag-add <type> <title> <description> [source] [phase]","details":null,"recovery":null,"timestamp":"2026-02-19T13:00:00Z"}}
110
+ ```
111
+
112
+ ---
113
+
114
+ ## System Errors
115
+
116
+ ### E_BASH_ERROR
117
+
118
+ - **Meaning:** An unexpected system command failure occurred — a bash command returned a non-zero exit code where one wasn't expected.
119
+ - **When it happens:**
120
+ - A system command (e.g., `cp`, `mkdir`, `git`) fails unexpectedly.
121
+ - A script runs under `set -e` and a command exits non-zero.
122
+ - **Suggested fix:** Check the `details` field in the error output for the exact command and line number. Fix the underlying system issue (permissions, disk space, etc.) and retry.
123
+ - **Example output:**
124
+ ```json
125
+ {"ok":false,"error":{"code":"E_BASH_ERROR","message":"Bash command failed","details":{"line":42,"command":"cp src dst","exit_code":1},"recovery":null,"timestamp":"2026-02-19T13:00:00Z"}}
126
+ ```
127
+
128
+ ### E_UNKNOWN
129
+
130
+ - **Meaning:** An unclassified error occurred — something went wrong that doesn't fit a more specific category.
131
+ - **When it happens:**
132
+ - An error path that hasn't been given a specific code yet.
133
+ - A catch-all for unexpected failure conditions.
134
+ - **Suggested fix:** Check the error message for context. If you see this frequently, please report it so a specific code can be added.
135
+ - **Example output:**
136
+ ```json
137
+ {"ok":false,"error":{"code":"E_UNKNOWN","message":"An unknown error occurred","details":null,"recovery":null,"timestamp":"2026-02-19T13:00:00Z"}}
138
+ ```
139
+
140
+ ---
141
+
142
+ ## Hub / Repository Errors
143
+
144
+ ### E_HUB_NOT_FOUND
145
+
146
+ - **Meaning:** The Aether hub (`~/.aether/`) doesn't exist on this machine.
147
+ - **When it happens:**
148
+ - Aether hasn't been installed yet.
149
+ - The hub directory was accidentally deleted.
150
+ - **Suggested fix:** Run `npm install -g aether` to install Aether. This creates the hub at `~/.aether/`.
151
+ - **Example output:**
152
+ ```json
153
+ {"ok":false,"error":{"code":"E_HUB_NOT_FOUND","message":"Couldn't find the Aether hub. Try: npm install -g aether","details":null,"recovery":"Run: aether install","timestamp":"2026-02-19T13:00:00Z"}}
154
+ ```
155
+
156
+ ### E_REPO_NOT_INITIALIZED
157
+
158
+ - **Meaning:** The current repository hasn't been initialized with Aether.
159
+ - **When it happens:**
160
+ - Running an Aether command in a repo before running `/ant:init`.
161
+ - The `.aether/` directory or `COLONY_STATE.json` is missing from the current repo.
162
+ - **Suggested fix:** Run `/ant:init` in Claude Code to initialize Aether in this repository.
163
+ - **Example output:**
164
+ ```json
165
+ {"ok":false,"error":{"code":"E_REPO_NOT_INITIALIZED","message":"Couldn't find Aether initialization in this repo. Try: run /ant:init first.","details":null,"recovery":"Run /ant:init in this repo first","timestamp":"2026-02-19T13:00:00Z"}}
166
+ ```
167
+
168
+ ### E_GIT_ERROR
169
+
170
+ - **Meaning:** A git operation failed.
171
+ - **When it happens:**
172
+ - `git stash`, `git commit`, `git log`, or another git command returns an error.
173
+ - The directory isn't a git repository.
174
+ - There are merge conflicts or a detached HEAD state.
175
+ - **Suggested fix:** Run `git status` to see the current state of your repository. Resolve any conflicts or uncommitted changes, then retry the command.
176
+ - **Example output:**
177
+ ```json
178
+ {"ok":false,"error":{"code":"E_GIT_ERROR","message":"Git operation failed. Try: run git status to check repository state.","details":null,"recovery":"Check git status and resolve conflicts","timestamp":"2026-02-19T13:00:00Z"}}
179
+ ```
180
+
181
+ ---
182
+
183
+ ## Resource Errors
184
+
185
+ ### E_RESOURCE_NOT_FOUND
186
+
187
+ - **Meaning:** A runtime resource (e.g., an active session, a worker, a swarm) doesn't exist.
188
+ - **When it happens:**
189
+ - A command refers to a session ID, worker name, or swarm ID that doesn't exist or has already completed.
190
+ - Attempting to read or update a resource that hasn't been created yet.
191
+ - **Suggested fix:** Check that the resource was created first. List available resources with the relevant `list` command (e.g., `flag-list`, `swarm-findings-read`).
192
+ - **Example output:**
193
+ ```json
194
+ {"ok":false,"error":{"code":"E_RESOURCE_NOT_FOUND","message":"Couldn't find the requested resource. Try: check that it was created first.","details":null,"recovery":"Check that the resource exists and try again","timestamp":"2026-02-19T13:00:00Z"}}
195
+ ```
196
+
197
+ ---
198
+
199
+ ## For Contributors
200
+
201
+ ### Adding a New Error Code
202
+
203
+ When you need a new error code, follow this checklist:
204
+
205
+ 1. **Define the constant** in `.aether/utils/error-handler.sh` at the top of the file:
206
+ ```bash
207
+ E_MY_NEW_CODE="E_MY_NEW_CODE"
208
+ ```
209
+
210
+ 2. **Add a recovery function** in `error-handler.sh`:
211
+ ```bash
212
+ _recovery_my_new_code() { echo '"Description of how to fix this"'; }
213
+ ```
214
+
215
+ 3. **Add a case entry** in the `_get_recovery` function in `error-handler.sh`:
216
+ ```bash
217
+ "$E_MY_NEW_CODE") _recovery_my_new_code ;;
218
+ ```
219
+
220
+ 4. **Add a fallback definition** at the top of `aether-utils.sh` (in the fallback constants block):
221
+ ```bash
222
+ : "${E_MY_NEW_CODE:=E_MY_NEW_CODE}"
223
+ ```
224
+
225
+ 5. **Export the constant and function** at the bottom of `error-handler.sh`:
226
+ ```bash
227
+ export E_MY_NEW_CODE
228
+ export -f _recovery_my_new_code
229
+ ```
230
+
231
+ 6. **Document the code** in this file (`docs/error-codes.md`) following the existing format.
232
+
233
+ ### Naming Convention
234
+
235
+ - **Prefix:** Always start with `E_`
236
+ - **Case:** SCREAMING_SNAKE_CASE (e.g., `E_FILE_NOT_FOUND`, `E_LOCK_FAILED`)
237
+ - **Be specific:** Prefer `E_FILE_NOT_FOUND` over `E_ERROR` — the code should communicate the failure category
238
+
239
+ ### Category Selection Guide
240
+
241
+ | Category | Use when... |
242
+ |----------|-------------|
243
+ | File Errors | A file or directory path doesn't exist |
244
+ | Lock Errors | Lock acquisition fails |
245
+ | Tool/Dependency Errors | A required tool or script is missing |
246
+ | JSON/Data Errors | File content is malformed or invalid |
247
+ | Validation Errors | Arguments are wrong or missing |
248
+ | System Errors | Unexpected bash command failure |
249
+ | Hub/Repository Errors | Aether infrastructure is missing or not set up |
250
+ | Resource Errors | A named runtime object doesn't exist |
251
+
252
+ ### Message Style Requirements
253
+
254
+ Every `json_err` call **must** include a "Try:" suggestion in the message:
255
+
256
+ ```bash
257
+ # Correct — includes Try: suggestion
258
+ json_err "$E_FILE_NOT_FOUND" "Couldn't find flags.json. Try: run flag-add first to create it."
259
+
260
+ # Wrong — no actionable suggestion
261
+ json_err "$E_FILE_NOT_FOUND" "flags.json not found"
262
+ ```
263
+
264
+ **Tone:** Use plain, friendly language. "Couldn't find..." is better than "File not found". Users are not experts in bash internals.
265
+
266
+ ---
267
+
268
+ *Last updated: 2026-02-19*
@@ -23,7 +23,7 @@ Documented issues from Oracle research findings. These are known limitations and
23
23
  - `.aether/aether-utils.sh`, `.aether/workers.md`, `.aether/docs/**/*.md`
24
24
  - `.claude/commands/ant/**/*.md`, `.claude/commands/st/**/*.md`
25
25
  - `.opencode/commands/ant/**/*.md`, `.opencode/agents/**/*.md`
26
- - `runtime/**/*`, `bin/**/*`
26
+ - `bin/**/*`
27
27
 
28
28
  **User Data (Never Touch):**
29
29
  - `.aether/data/`, `.aether/dreams/`, `.aether/oracle/`
@@ -33,38 +33,42 @@ Documented issues from Oracle research findings. These are known limitations and
33
33
 
34
34
  ## Critical Issues (Fix Immediately)
35
35
 
36
- ### BUG-005: Missing lock release in flag-auto-resolve
36
+ ### BUG-005: Missing lock release in flag-auto-resolve — FIXED (Phase 16)
37
37
  **Location:** `.aether/aether-utils.sh:1022`
38
38
  **Severity:** HIGH
39
+ **Status:** FIXED — Fixed in Phase 16: unified trap pattern (`trap 'release_lock 2>/dev/null || true' EXIT`) applied across all flag commands ensures lock release on all exit paths including jq failure.
39
40
  **Symptom:** If jq command fails during flag resolution, lock is never released
40
41
  **Impact:** Deadlock on flags.json if jq fails (malformed JSON, disk full, etc.)
41
- **Workaround:** Restart the colony session if commands hang on flag operations
42
- **Fix:** Add error handling with lock release before json_err
42
+ **Workaround:** ~~Restart the colony session if commands hang on flag operations~~ — no longer needed
43
+ **Regression test:** `tests/bash/test-lock-lifecycle.sh` test_flag_auto_resolve_jq_failure_releases_lock
43
44
 
44
- ### BUG-011: Missing error handling in flag-auto-resolve jq
45
+ ### BUG-011: Missing error handling in flag-auto-resolve jq — FIXED (Phase 16)
45
46
  **Location:** `.aether/aether-utils.sh:1022`
46
47
  **Severity:** HIGH
48
+ **Status:** FIXED — Fixed in Phase 16: unified trap pattern across all flag commands. See BUG-005.
47
49
  **Symptom:** jq failure during auto-resolve not handled
48
50
  **Impact:** Combined with BUG-005, causes deadlock
49
- **Fix:** Add `|| { release_lock; json_err ... }` pattern
51
+ **Fix:** ~~Add `|| { release_lock; json_err ... }` pattern~~ — implemented via EXIT trap
50
52
 
51
53
  ---
52
54
 
53
55
  ## Medium Priority Issues
54
56
 
55
- ### BUG-002: Missing release_lock in flag-add error path
57
+ ### BUG-002: Missing release_lock in flag-add error path — FIXED (Phase 16)
56
58
  **Location:** `.aether/aether-utils.sh:814`
57
59
  **Severity:** MEDIUM
60
+ **Status:** FIXED — Fixed in Phase 16: trap-based EXIT cleanup (`trap 'release_lock 2>/dev/null || true' EXIT`) ensures lock release on all exit paths including jq failure. Trap is cleared on the success path.
58
61
  **Symptom:** If acquire_lock succeeds but jq fails, lock is never released
59
62
  **Impact:** Potential deadlock on file operations
60
- **Fix:** Use trap-based cleanup or ensure release_lock in all exit paths
63
+ **Regression test:** `tests/bash/test-lock-lifecycle.sh` test_flag_add_jq_failure_releases_lock
61
64
 
62
- ### BUG-003: Race condition in backup creation
65
+ ### BUG-003: Race condition in backup creation — FIXED (Phase 16)
63
66
  **Location:** `.aether/utils/atomic-write.sh:75`
64
67
  **Severity:** MEDIUM
68
+ **Status:** FIXED — Backup is now created BEFORE JSON validation in both `atomic_write` and `atomic_write_from_file`. Verified in Phase 16 with regression tests confirming backup contains pre-write content.
65
69
  **Symptom:** Backup created AFTER temp file validation but BEFORE atomic move
66
70
  **Impact:** If process crashes between validation and backup, inconsistent state
67
- **Fix:** Create backup BEFORE validation, or use transactional approach
71
+ **Regression test:** `tests/bash/test-lock-lifecycle.sh` test_atomic_write_backup_before_validate, test_atomic_write_from_file_backup_before_validate
68
72
 
69
73
  ### BUG-004: Missing error code in flag-acknowledge
70
74
  **Location:** `.aether/aether-utils.sh:930`
@@ -123,24 +127,27 @@ Documented issues from Oracle research findings. These are known limitations and
123
127
  **Description:** Some `json_err` calls use hardcoded strings instead of constants
124
128
  **Pattern:** Commands added early use strings; later commands use constants
125
129
 
126
- ### ISSUE-002: Missing exec error handling
130
+ ### ISSUE-002: Missing exec error handling — FIXED (Phase 18-02)
127
131
  **Location:** `.aether/aether-utils.sh:2132-2144`
128
132
  **Severity:** LOW
129
133
  **Description:** `model-get` and `model-list` use `exec` without fallback
130
134
  **Impact:** If exec fails, script continues to unknown command handler
135
+ **Status:** FIXED — Phase 18-02: subprocess error handling added to model-get and model-list with structured E_* error codes on failure.
131
136
 
132
- ### ISSUE-003: Incomplete help command
137
+ ### ISSUE-003: Incomplete help command — FIXED (Phase 18-03)
133
138
  **Location:** `.aether/aether-utils.sh:106-111`
134
139
  **Severity:** LOW
135
140
  **Description:** Help command missing newer commands like queen-*, view-state-*, swarm-timing-*
136
141
  **Impact:** Users cannot discover all available commands
142
+ **Status:** FIXED — Phase 18-03: help command sections key added with all command groups including Queen Commands, Model Routing, Swarm Operations, and all newer commands.
137
143
 
138
- ### ISSUE-004: Template path hardcoded to runtime/
144
+ ### ISSUE-004: Template path hardcoded to staging directory — FIXED (Phase 20)
139
145
  **Location:** `.aether/aether-utils.sh:2689`
140
146
  **Severity:** MEDIUM
141
- **Description:** queen-init uses runtime/ directory which may not exist in npm installs
142
- **Impact:** queen-init will fail when Aether is installed as npm package
143
- **Workaround:** Use git clone instead of npm install
147
+ **Status:** FIXED — Phase 20: stale staging template path removed from queen-init lookup array. Template is now found via hub path (`~/.aether/system/templates/`) or dev repo path (`.aether/templates/`) or legacy hub fallback.
148
+ **Description:** queen-init used a staging directory path that did not exist in npm installs
149
+ **Impact:** ~~queen-init will fail when Aether is installed as npm package~~
150
+ **~~Workaround:~~** ~~Use git clone instead of npm install~~ — no longer needed
144
151
 
145
152
  ### ISSUE-005: Potential infinite loop in spawn-tree
146
153
  **Location:** `.aether/aether-utils.sh:402-448`, `spawn-tree.sh:222-263`
@@ -154,38 +161,45 @@ Documented issues from Oracle research findings. These are known limitations and
154
161
  **Description:** Fallback json_err doesn't accept error code parameter
155
162
  **Impact:** If error-handler.sh fails to load, error codes are lost
156
163
 
157
- ### ISSUE-007: Feature detection race condition
164
+ ### ISSUE-007: Feature detection race condition — FIXED (Phase 18-01)
158
165
  **Location:** `.aether/aether-utils.sh:33-45`
159
166
  **Severity:** LOW
160
167
  **Description:** Feature detection runs before error handler fully sourced
168
+ **Status:** FIXED — Phase 18-01 (ARCH-09): feature detection block moved after fallback json_err definition (line 68 -> 81) so all fallback infrastructure available when feature detection runs.
161
169
 
162
170
  ---
163
171
 
164
172
  ## Architecture Gaps
165
173
 
166
- ### GAP-001: No schema version validation
174
+ ### GAP-001: No schema version validation — FIXED (Phase 18-04)
167
175
  **Description:** Commands assume state structure without validating version
168
176
  **Impact:** Silent failures when state structure changes
177
+ **Status:** FIXED — Phase 18-04: `_migrate_colony_state` added to validate-state colony; auto-migrates pre-3.0 state files to v3.0 (additive only), notifies via W_MIGRATED warning; corrupt state files backed up before error.
169
178
 
170
- ### GAP-002: No cleanup for stale spawn-tree entries
179
+ ### GAP-002: No cleanup for stale spawn-tree entries — FIXED (Phase 18-01)
171
180
  **Description:** spawn-tree.txt grows indefinitely
172
181
  **Impact:** File could grow very large over many sessions
182
+ **Status:** FIXED — Phase 18-01: `_rotate_spawn_tree` added to session-init; rotates spawn-tree.txt on each session start with timestamped archives; 5-archive cap; in-place truncation preserves tail -f file handles.
173
183
 
174
- ### GAP-003: No retry logic for failed spawns
184
+ ### GAP-003: No retry logic for failed spawns — RESOLVED (Phase 18-02)
175
185
  **Description:** Task tool calls don't have retry logic
176
186
  **Impact:** Transient failures cause build failures
187
+ **Status:** RESOLVED — User decision: fail-fast with rich error context (Phase 18-02). Retry logic adds complexity without clear benefit; subprocess errors now emit structured E_* codes with actionable Try: suggestions, allowing callers to decide on retry strategy.
177
188
 
178
- ### GAP-004: Missing queen-* documentation
189
+ ### GAP-004: Missing queen-* documentation — FIXED (Phase 18-03)
179
190
  **Description:** No docs for queen-init, queen-read, queen-promote
180
191
  **Impact:** Users cannot discover wisdom feedback loop
192
+ **Status:** FIXED — Phase 18-03: queen-commands.md created in .aether/docs/; help command sections key added with Queen Commands section listing all three commands with descriptions.
181
193
 
182
- ### GAP-005: No validation of queen-read JSON output
194
+ ### GAP-005: No validation of queen-read JSON output — FIXED (Phase 18-04)
183
195
  **Description:** queen-read builds JSON but doesn't validate before returning
184
196
  **Impact:** Could return malformed response
197
+ **Status:** FIXED — Phase 18-04: Two validation gates added to queen-read: Gate 1 validates METADATA JSON before --argjson use; Gate 2 validates assembled result before json_ok. Both emit E_JSON_INVALID with actionable Try: suggestion.
185
198
 
186
- ### GAP-006: Missing queen-* command documentation
199
+ ### GAP-006: Missing queen-* command documentation — FIXED (Phase 18-03)
187
200
  **Description:** Duplicate of GAP-004 - no documentation exists
188
201
  **Impact:** Commands are undiscoverable
202
+ **Status:** FIXED — Phase 18-03: See GAP-004.
189
203
 
190
204
  ### GAP-007: No error code standards documentation
191
205
  **Description:** Error codes exist but aren't documented
@@ -195,9 +209,11 @@ Documented issues from Oracle research findings. These are known limitations and
195
209
  **Description:** Error handling paths not tested
196
210
  **Impact:** Bugs in error handling go undetected
197
211
 
198
- ### GAP-009: context-update has no file locking
212
+ ### GAP-009: context-update has no file locking — FIXED (Phase 16)
199
213
  **Description:** Race condition possible during concurrent context updates
214
+ **Status:** FIXED — Fixed in Phase 16: context-update wraps all 11 action handlers in a single acquire_lock/release_lock pair. Lock is held for the duration of the update and released on both success and error paths via EXIT trap. force-unlock subcommand added for emergency recovery.
200
215
  **Impact:** Potential data corruption
216
+ **Regression test:** `tests/bash/test-lock-lifecycle.sh` — test_context_update_acquires_lock, test_force_unlock_clears_locks
201
217
 
202
218
  ### GAP-010: Missing error code standards documentation
203
219
  **Description:** Duplicate of GAP-007
@@ -208,8 +224,8 @@ Documented issues from Oracle research findings. These are known limitations and
208
224
 
209
225
  | Issue | Workaround |
210
226
  |-------|------------|
211
- | Lock-related deadlocks (BUG-005, BUG-002) | Restart colony session |
212
- | Template path issue (ISSUE-004) | Use git clone instead of npm |
227
+ | ~~Lock-related deadlocks (BUG-005, BUG-002)~~ | ~~Restart colony session~~ — FIXED in Phase 16 |
228
+ | ~~Template path issue (ISSUE-004)~~ | ~~Use git clone instead of npm~~ — FIXED in Phase 20 |
213
229
  | Missing command docs (GAP-004) | Read source code directly |
214
230
 
215
231
  ---
@@ -0,0 +1,97 @@
1
+ # Queen Commands Reference
2
+
3
+ The queen-* commands manage the QUEEN.md wisdom file — a persistent cross-colony knowledge base that accumulates philosophies, patterns, redirects, stack wisdom, and decrees across sessions.
4
+
5
+ For the QUEEN.md file format and wisdom feedback loop, see [QUEEN-SYSTEM.md](./QUEEN-SYSTEM.md).
6
+
7
+ ## Commands
8
+
9
+ ### queen-init
10
+
11
+ **Purpose:** Initialize a new QUEEN.md from the system template.
12
+
13
+ **Usage:**
14
+ ```bash
15
+ bash .aether/aether-utils.sh queen-init
16
+ ```
17
+
18
+ **Returns:** JSON with creation status, file path, and template source.
19
+
20
+ **Example output:**
21
+ ```json
22
+ {"ok":true,"result":{"created":true,"path":".aether/docs/QUEEN.md","source":"~/.aether/system/docs/QUEEN.md.template"}}
23
+ ```
24
+
25
+ **Behavior:**
26
+ - If QUEEN.md already exists, returns `{"created":false}` without overwriting
27
+ - Searches for template in: hub system path, then local .aether/templates/
28
+ - Creates `.aether/docs/` directory if it doesn't exist
29
+
30
+ ---
31
+
32
+ ### queen-read
33
+
34
+ **Purpose:** Read QUEEN.md wisdom as structured JSON for worker priming.
35
+
36
+ **Usage:**
37
+ ```bash
38
+ bash .aether/aether-utils.sh queen-read
39
+ ```
40
+
41
+ **Returns:** JSON with metadata, wisdom sections, and priming flags.
42
+
43
+ **Example output:**
44
+ ```json
45
+ {"ok":true,"result":{"metadata":{...},"wisdom":{"philosophies":"...","patterns":"...","redirects":"...","stack_wisdom":"...","decrees":"..."},"priming":{"has_philosophies":true,...}}}
46
+ ```
47
+
48
+ **Behavior:**
49
+ - Extracts METADATA JSON block from `<!-- METADATA ... -->` comment
50
+ - Parses each wisdom section (Philosophies, Patterns, Redirects, Stack Wisdom, Decrees)
51
+ - Returns priming flags indicating which sections have content
52
+ - Returns E_JSON_INVALID if METADATA block contains malformed JSON
53
+ - Returns E_FILE_NOT_FOUND if QUEEN.md doesn't exist
54
+
55
+ ---
56
+
57
+ ### queen-promote
58
+
59
+ **Purpose:** Promote a validated learning to QUEEN.md wisdom.
60
+
61
+ **Usage:**
62
+ ```bash
63
+ bash .aether/aether-utils.sh queen-promote <type> <content> <colony_name>
64
+ ```
65
+
66
+ **Arguments:**
67
+
68
+ | Argument | Required | Description |
69
+ |----------|----------|-------------|
70
+ | type | Yes | Wisdom category: `philosophy`, `pattern`, `redirect`, `stack`, `decree` |
71
+ | content | Yes | The wisdom text to add |
72
+ | colony_name | Yes | Name of the colony contributing the wisdom |
73
+
74
+ **Returns:** JSON confirming the promotion with details.
75
+
76
+ **Behavior:**
77
+ - Appends the wisdom entry to the appropriate section in QUEEN.md
78
+ - Includes attribution (colony name) and timestamp
79
+ - Updates the METADATA block's stats
80
+
81
+ ---
82
+
83
+ ## For Contributors
84
+
85
+ The queen commands are part of the colony lifecycle:
86
+
87
+ 1. **Colony startup:** `/ant:colonize` calls `queen-init` to ensure QUEEN.md exists
88
+ 2. **Worker priming:** `/ant:swarm` calls `queen-read` to inject wisdom into worker prompts
89
+ 3. **Colony end:** `/ant:seal` can call `queen-promote` to persist learnings
90
+
91
+ ### Adding a New Queen Command
92
+
93
+ 1. Add the case block in `aether-utils.sh` (alongside existing `queen-*` blocks)
94
+ 2. Add it to the flat `commands` array in the `help)` case block
95
+ 3. Add it to the "Queen Commands" section in help's `sections` JSON
96
+ 4. Update this file with usage documentation
97
+ 5. Add tests in `tests/bash/test-aether-utils.sh`
@@ -0,0 +1,11 @@
1
+ <?xml version="1.0" encoding="UTF-8"?>
2
+ <colony-registry xmlns="http://aether.colony/schemas/registry/1.0"
3
+ version="1.0.0"
4
+ generated_at="2026-02-18T01:48:47Z">
5
+ <colony id="Remove Aether developing Aether self-reference while preserving findings" status="active" created_at="2026-02-15T15:59:13Z">
6
+ <name>Remove Aether developing Aether self-reference while preserving findings</name>
7
+ </colony>
8
+ <colony id="v1.1 Bug Fixes &amp; Update System Repair" status="active" created_at="unknown">
9
+ <name>v1.1 Bug Fixes &amp; Update System Repair</name>
10
+ </colony>
11
+ </colony-registry>
@@ -126,8 +126,9 @@ xml-pheromone-export() {
126
126
  active=\"$active\">"
127
127
 
128
128
  # Content section
129
+ # Handle both string content (.content = "text") and object content (.content.text = "text")
129
130
  local content_text
130
- content_text=$(echo "$signal" | jq -r '.content.text // .message // ""')
131
+ content_text=$(echo "$signal" | jq -r 'if (.content | type) == "string" then .content elif .content.text then .content.text else .message // "" end')
131
132
  if [[ -n "$content_text" ]]; then
132
133
  xml_output="$xml_output
133
134
  <content>
@@ -0,0 +1,87 @@
1
+ <?xml version="1.0" encoding="UTF-8"?>
2
+ <pheromones xmlns="http://aether.colony/schemas/pheromones"
3
+ xmlns:ph="http://aether.colony/schemas/pheromones"
4
+ version="1.0.0"
5
+ generated_at="2026-02-17T23:51:44Z"
6
+ colony_id="aether-dev">
7
+ <metadata>
8
+ <source type="system">aether-pheromone-converter</source>
9
+ <context>Colony pheromone signals</context>
10
+ </metadata>
11
+ <signal id="sig_focus_001"
12
+ type="FOCUS"
13
+ priority="normal"
14
+ source="user"
15
+ created_at="2026-02-16T10:00:00Z"
16
+ expires_at="2026-02-17T10:00:00Z"
17
+ active="true">
18
+ <content>
19
+ <text>XML migration and pheromone system implementation</text>
20
+ </content>
21
+ </signal>
22
+ <signal id="sig_redirect_001"
23
+ type="REDIRECT"
24
+ priority="high"
25
+ source="system"
26
+ created_at="2026-02-16T08:00:00Z"
27
+ expires_at="2026-03-16T08:00:00Z"
28
+ active="true">
29
+ <content>
30
+ <text>Avoid editing runtime/ directly - edit .aether/ instead</text>
31
+ </content>
32
+ </signal>
33
+ <signal id="sig_feedback_001"
34
+ type="FEEDBACK"
35
+ priority="low"
36
+ source="worker_builder"
37
+ created_at="2026-02-16T12:00:00Z"
38
+ active="true">
39
+ <content>
40
+ <text>Test coverage is good, continue maintaining 80%+ coverage</text>
41
+ </content>
42
+ </signal>
43
+ <signal id="sig_focus_1771366307000"
44
+ type="FOCUS"
45
+ priority="normal"
46
+ source="user"
47
+ created_at="2026-02-17T22:11:47Z"
48
+ expires_at="phase_end"
49
+ active="true">
50
+ <content>
51
+ <text>test area for pheromone unification</text>
52
+ </content>
53
+ </signal>
54
+ <signal id="sig_focus_1771366386000"
55
+ type="FOCUS"
56
+ priority="normal"
57
+ source="user"
58
+ created_at="2026-02-17T22:13:06Z"
59
+ expires_at="phase_end"
60
+ active="true">
61
+ <content>
62
+ <text>test area</text>
63
+ </content>
64
+ </signal>
65
+ <signal id="sig_redirect_1771366398000"
66
+ type="REDIRECT"
67
+ priority="high"
68
+ source="user"
69
+ created_at="2026-02-17T22:13:18Z"
70
+ expires_at="phase_end"
71
+ active="true">
72
+ <content>
73
+ <text>avoid direct runtime edits</text>
74
+ </content>
75
+ </signal>
76
+ <signal id="sig_feedback_1771366398000"
77
+ type="FEEDBACK"
78
+ priority="low"
79
+ source="user"
80
+ created_at="2026-02-17T22:13:18Z"
81
+ expires_at="phase_end"
82
+ active="true">
83
+ <content>
84
+ <text>keep commits small</text>
85
+ </content>
86
+ </signal>
87
+ </pheromones>
@@ -0,0 +1,14 @@
1
+ <?xml version="1.0" encoding="UTF-8"?>
2
+ <queen-wisdom xmlns="http://aether.colony/schemas/queen-wisdom/1.0"
3
+ xmlns:qw="http://aether.colony/schemas/queen-wisdom/1.0">
4
+ <metadata>
5
+ <version>1.0.0</version>
6
+ <created>2026-02-18T01:48:47Z</created>
7
+ <modified>2026-02-18T01:48:47Z</modified>
8
+ <colony_id></colony_id>
9
+ </metadata>
10
+ <philosophies>
11
+ </philosophies>
12
+ <patterns>
13
+ </patterns>
14
+ </queen-wisdom>