aether-colony 5.2.1 → 5.3.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (143) hide show
  1. package/.aether/aether-utils.sh +35 -0
  2. package/.aether/agents/aether-ambassador.md +140 -0
  3. package/.aether/agents/aether-archaeologist.md +108 -0
  4. package/.aether/agents/aether-architect.md +133 -0
  5. package/.aether/agents/aether-auditor.md +144 -0
  6. package/.aether/agents/aether-builder.md +184 -0
  7. package/.aether/agents/aether-chaos.md +115 -0
  8. package/.aether/agents/aether-chronicler.md +122 -0
  9. package/.aether/agents/aether-gatekeeper.md +116 -0
  10. package/.aether/agents/aether-includer.md +117 -0
  11. package/.aether/agents/aether-keeper.md +177 -0
  12. package/.aether/agents/aether-measurer.md +128 -0
  13. package/.aether/agents/aether-oracle.md +137 -0
  14. package/.aether/agents/aether-probe.md +133 -0
  15. package/.aether/agents/aether-queen.md +286 -0
  16. package/.aether/agents/aether-route-setter.md +130 -0
  17. package/.aether/agents/aether-sage.md +106 -0
  18. package/.aether/agents/aether-scout.md +101 -0
  19. package/.aether/agents/aether-surveyor-disciplines.md +391 -0
  20. package/.aether/agents/aether-surveyor-nest.md +329 -0
  21. package/.aether/agents/aether-surveyor-pathogens.md +264 -0
  22. package/.aether/agents/aether-surveyor-provisions.md +334 -0
  23. package/.aether/agents/aether-tracker.md +137 -0
  24. package/.aether/agents/aether-watcher.md +174 -0
  25. package/.aether/agents/aether-weaver.md +130 -0
  26. package/.aether/commands/claude/archaeology.md +334 -0
  27. package/.aether/commands/claude/build.md +65 -0
  28. package/.aether/commands/claude/chaos.md +336 -0
  29. package/.aether/commands/claude/colonize.md +259 -0
  30. package/.aether/commands/claude/continue.md +60 -0
  31. package/.aether/commands/claude/council.md +507 -0
  32. package/.aether/commands/claude/data-clean.md +81 -0
  33. package/.aether/commands/claude/dream.md +268 -0
  34. package/.aether/commands/claude/entomb.md +498 -0
  35. package/.aether/commands/claude/export-signals.md +57 -0
  36. package/.aether/commands/claude/feedback.md +96 -0
  37. package/.aether/commands/claude/flag.md +151 -0
  38. package/.aether/commands/claude/flags.md +169 -0
  39. package/.aether/commands/claude/focus.md +76 -0
  40. package/.aether/commands/claude/help.md +154 -0
  41. package/.aether/commands/claude/history.md +140 -0
  42. package/.aether/commands/claude/import-signals.md +71 -0
  43. package/.aether/commands/claude/init.md +505 -0
  44. package/.aether/commands/claude/insert-phase.md +105 -0
  45. package/.aether/commands/claude/interpret.md +278 -0
  46. package/.aether/commands/claude/lay-eggs.md +210 -0
  47. package/.aether/commands/claude/maturity.md +113 -0
  48. package/.aether/commands/claude/memory-details.md +77 -0
  49. package/.aether/commands/claude/migrate-state.md +171 -0
  50. package/.aether/commands/claude/oracle.md +642 -0
  51. package/.aether/commands/claude/organize.md +232 -0
  52. package/.aether/commands/claude/patrol.md +620 -0
  53. package/.aether/commands/claude/pause-colony.md +233 -0
  54. package/.aether/commands/claude/phase.md +115 -0
  55. package/.aether/commands/claude/pheromones.md +156 -0
  56. package/.aether/commands/claude/plan.md +693 -0
  57. package/.aether/commands/claude/preferences.md +65 -0
  58. package/.aether/commands/claude/quick.md +100 -0
  59. package/.aether/commands/claude/redirect.md +76 -0
  60. package/.aether/commands/claude/resume-colony.md +197 -0
  61. package/.aether/commands/claude/resume.md +388 -0
  62. package/.aether/commands/claude/run.md +231 -0
  63. package/.aether/commands/claude/seal.md +774 -0
  64. package/.aether/commands/claude/skill-create.md +286 -0
  65. package/.aether/commands/claude/status.md +410 -0
  66. package/.aether/commands/claude/swarm.md +349 -0
  67. package/.aether/commands/claude/tunnels.md +426 -0
  68. package/.aether/commands/claude/update.md +132 -0
  69. package/.aether/commands/claude/verify-castes.md +143 -0
  70. package/.aether/commands/claude/watch.md +239 -0
  71. package/.aether/commands/opencode/archaeology.md +331 -0
  72. package/.aether/commands/opencode/build.md +1168 -0
  73. package/.aether/commands/opencode/chaos.md +329 -0
  74. package/.aether/commands/opencode/colonize.md +195 -0
  75. package/.aether/commands/opencode/continue.md +1436 -0
  76. package/.aether/commands/opencode/council.md +437 -0
  77. package/.aether/commands/opencode/data-clean.md +77 -0
  78. package/.aether/commands/opencode/dream.md +260 -0
  79. package/.aether/commands/opencode/entomb.md +377 -0
  80. package/.aether/commands/opencode/export-signals.md +54 -0
  81. package/.aether/commands/opencode/feedback.md +99 -0
  82. package/.aether/commands/opencode/flag.md +149 -0
  83. package/.aether/commands/opencode/flags.md +167 -0
  84. package/.aether/commands/opencode/focus.md +73 -0
  85. package/.aether/commands/opencode/help.md +157 -0
  86. package/.aether/commands/opencode/history.md +136 -0
  87. package/.aether/commands/opencode/import-signals.md +68 -0
  88. package/.aether/commands/opencode/init.md +518 -0
  89. package/.aether/commands/opencode/insert-phase.md +111 -0
  90. package/.aether/commands/opencode/interpret.md +272 -0
  91. package/.aether/commands/opencode/lay-eggs.md +213 -0
  92. package/.aether/commands/opencode/maturity.md +108 -0
  93. package/.aether/commands/opencode/memory-details.md +83 -0
  94. package/.aether/commands/opencode/migrate-state.md +165 -0
  95. package/.aether/commands/opencode/oracle.md +593 -0
  96. package/.aether/commands/opencode/organize.md +226 -0
  97. package/.aether/commands/opencode/patrol.md +626 -0
  98. package/.aether/commands/opencode/pause-colony.md +203 -0
  99. package/.aether/commands/opencode/phase.md +113 -0
  100. package/.aether/commands/opencode/pheromones.md +162 -0
  101. package/.aether/commands/opencode/plan.md +684 -0
  102. package/.aether/commands/opencode/preferences.md +71 -0
  103. package/.aether/commands/opencode/quick.md +91 -0
  104. package/.aether/commands/opencode/redirect.md +84 -0
  105. package/.aether/commands/opencode/resume-colony.md +190 -0
  106. package/.aether/commands/opencode/resume.md +394 -0
  107. package/.aether/commands/opencode/run.md +237 -0
  108. package/.aether/commands/opencode/seal.md +452 -0
  109. package/.aether/commands/opencode/skill-create.md +63 -0
  110. package/.aether/commands/opencode/status.md +307 -0
  111. package/.aether/commands/opencode/swarm.md +15 -0
  112. package/.aether/commands/opencode/tunnels.md +400 -0
  113. package/.aether/commands/opencode/update.md +127 -0
  114. package/.aether/commands/opencode/verify-castes.md +139 -0
  115. package/.aether/commands/opencode/watch.md +227 -0
  116. package/.aether/docs/command-playbooks/build-full.md +1 -1
  117. package/.aether/docs/command-playbooks/build-prep.md +10 -3
  118. package/.aether/docs/command-playbooks/build-verify.md +51 -0
  119. package/.aether/docs/command-playbooks/continue-advance.md +115 -6
  120. package/.aether/docs/command-playbooks/continue-verify.md +32 -0
  121. package/.aether/utils/clash-detect.sh +239 -0
  122. package/.aether/utils/hooks/clash-pre-tool-use.js +99 -0
  123. package/.aether/utils/merge-driver-lockfile.sh +35 -0
  124. package/.aether/utils/midden.sh +534 -0
  125. package/.aether/utils/pheromone.sh +1376 -108
  126. package/.aether/utils/queen.sh +2 -4
  127. package/.aether/utils/state-api.sh +25 -4
  128. package/.aether/utils/swarm.sh +1 -1
  129. package/.aether/utils/worktree.sh +189 -0
  130. package/CHANGELOG.md +26 -0
  131. package/README.md +161 -161
  132. package/bin/cli.js +103 -61
  133. package/bin/lib/banner.js +14 -0
  134. package/bin/lib/init.js +8 -7
  135. package/bin/lib/interactive-setup.js +251 -0
  136. package/bin/npx-entry.js +21 -0
  137. package/bin/npx-install.js +9 -167
  138. package/bin/validate-package.sh +23 -0
  139. package/package.json +2 -2
  140. package/.aether/docs/plans/pheromone-display-plan.md +0 -257
  141. package/.aether/schemas/example-prompt-builder.xml +0 -234
  142. package/.aether/scripts/incident-test-add.sh +0 -47
  143. package/.aether/scripts/weekly-audit.sh +0 -79
@@ -0,0 +1,227 @@
1
+ <!-- Generated from .aether/commands/watch.yaml - DO NOT EDIT DIRECTLY -->
2
+ ---
3
+ name: ant:watch
4
+ description: "👁️🔄🐜🏠🔄👁️ Set up tmux session to watch ants working in real-time"
5
+ ---
6
+
7
+ ### Step -1: Normalize Arguments
8
+
9
+ Run: `normalized_args=$(bash .aether/aether-utils.sh normalize-args "$@")`
10
+
11
+ This ensures arguments work correctly in both Claude Code and OpenCode. Use `$normalized_args` throughout this command.
12
+
13
+ You are the **Queen**. Set up live visibility into colony activity.
14
+
15
+ ## Instructions
16
+
17
+ ### Step 1: Check Prerequisites
18
+
19
+ Use Bash to check if tmux is available:
20
+ ```bash
21
+ command -v tmux >/dev/null 2>&1 && echo "tmux_available" || echo "tmux_missing"
22
+ ```
23
+
24
+ If tmux is missing:
25
+ ```
26
+ tmux is required for live colony viewing.
27
+
28
+ Install with:
29
+ macOS: brew install tmux
30
+ Ubuntu: sudo apt install tmux
31
+ Fedora: sudo dnf install tmux
32
+ ```
33
+ Stop here.
34
+
35
+ ### Step 2: Initialize Activity Log
36
+
37
+ Ensure activity log exists:
38
+ ```bash
39
+ mkdir -p .aether/data
40
+ touch .aether/data/activity.log
41
+ ```
42
+
43
+ ### Step 3: Create Status File
44
+
45
+ Write initial status to `.aether/data/watch-status.txt`:
46
+
47
+ ```
48
+ .-.
49
+ (o o) AETHER COLONY
50
+ | O | Live Status
51
+ `-`
52
+ ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
53
+
54
+ State: IDLE
55
+ Phase: -/-
56
+
57
+ Active Workers:
58
+ (none)
59
+
60
+ Last Activity:
61
+ (waiting for colony activity)
62
+ ```
63
+
64
+ ### Step 4: Create or Attach to tmux Session
65
+
66
+ Check if session exists:
67
+ ```bash
68
+ tmux has-session -t aether-colony 2>/dev/null && echo "exists" || echo "new"
69
+ ```
70
+
71
+ **If session exists:** Attach to it
72
+ ```bash
73
+ tmux attach-session -t aether-colony
74
+ ```
75
+ Output: `Attached to existing aether-colony session.`
76
+ Stop here.
77
+
78
+ **If session is new:** Create the layout.
79
+
80
+ ### Step 5: Create tmux Layout (4-Pane)
81
+
82
+ Use Bash to create the session with 4 panes in a 2x2 grid:
83
+
84
+ ```bash
85
+ # Create session with first pane
86
+ tmux new-session -d -s aether-colony -n colony
87
+
88
+ # Split into 4 panes (2x2 grid)
89
+ # First split horizontally (left|right)
90
+ tmux split-window -h -t aether-colony:colony
91
+
92
+ # Split left side vertically (top-left, bottom-left)
93
+ tmux split-window -v -t aether-colony:colony.0
94
+
95
+ # Split right side vertically (top-right, bottom-right)
96
+ tmux split-window -v -t aether-colony:colony.2
97
+
98
+ # Set pane contents:
99
+ # Pane 0 (top-left): Status display
100
+ tmux send-keys -t aether-colony:colony.0 'watch -n 1 cat .aether/data/watch-status.txt' C-m
101
+
102
+ # Pane 1 (bottom-left): Progress bar
103
+ tmux send-keys -t aether-colony:colony.1 'watch -n 1 cat .aether/data/watch-progress.txt' C-m
104
+
105
+ # Pane 2 (top-right): Spawn tree visualization
106
+ tmux send-keys -t aether-colony:colony.2 'bash .aether/utils/watch-spawn-tree.sh .aether/data' C-m
107
+
108
+ # Pane 3 (bottom-right): Colorized activity log stream
109
+ tmux send-keys -t aether-colony:colony.3 'bash .aether/utils/colorize-log.sh .aether/data/activity.log' C-m
110
+
111
+ # Set pane titles (if supported)
112
+ tmux select-pane -t aether-colony:colony.0 -T "Status"
113
+ tmux select-pane -t aether-colony:colony.1 -T "Progress"
114
+ tmux select-pane -t aether-colony:colony.2 -T "Spawn Tree"
115
+ tmux select-pane -t aether-colony:colony.3 -T "Activity Log"
116
+
117
+ # Balance panes for even 2x2 grid
118
+ tmux select-layout -t aether-colony:colony tiled
119
+
120
+ echo "Session created"
121
+ ```
122
+
123
+ ### Step 6: Create Progress File
124
+
125
+ Write initial progress to `.aether/data/watch-progress.txt`:
126
+
127
+ ```
128
+ .-.
129
+ (o o) AETHER COLONY
130
+ | O | Progress
131
+ `-`
132
+ ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
133
+
134
+ Phase: -/-
135
+
136
+ [░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░] 0%
137
+
138
+ ⏳ Waiting for build...
139
+
140
+ Target: 95% confidence
141
+ ```
142
+
143
+ ### Step 7: Attach and Display
144
+
145
+ ```bash
146
+ tmux attach-session -t aether-colony
147
+ ```
148
+
149
+ Before attaching, output:
150
+
151
+ ```
152
+ .-.
153
+ (o o) AETHER COLONY :: WATCH
154
+ | O |
155
+ `-`
156
+ ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
157
+
158
+ tmux session 'aether-colony' created.
159
+
160
+ Layout (4-pane 2x2 grid):
161
+ +------------------+------------------+
162
+ | Status | Spawn Tree |
163
+ | Colony state | Worker hierarchy |
164
+ +------------------+------------------+
165
+ | Progress | Activity Log |
166
+ | Phase progress | Live stream |
167
+ +------------------+------------------+
168
+
169
+ Commands:
170
+ Ctrl+B D Detach from session
171
+ Ctrl+B [ Scroll mode (q to exit)
172
+ Ctrl+B Arrow Navigate between panes
173
+ tmux kill-session -t aether-colony Stop watching
174
+
175
+ The session will update in real-time as colony works.
176
+ Attaching now...
177
+ ```
178
+
179
+ ---
180
+
181
+ ## Status Update Protocol
182
+
183
+ Workers and commands update watch files as they work:
184
+
185
+ ### Activity Log
186
+ Workers write via: `bash .aether/aether-utils.sh activity-log "ACTION" "caste" "description"`
187
+
188
+ For named ants (recommended):
189
+ ```bash
190
+ # Generate a name first
191
+ ant_name=$(bash .aether/aether-utils.sh generate-ant-name "builder" | jq -r '.result')
192
+ # Log with ant name
193
+ bash .aether/aether-utils.sh activity-log "CREATED" "$ant_name (Builder)" "Implemented auth module"
194
+ ```
195
+
196
+ ### Spawn Tracking
197
+ Log spawns for tree visualization:
198
+ ```bash
199
+ bash .aether/aether-utils.sh spawn-log "Prime" "builder" "Hammer-42" "implementing auth"
200
+ bash .aether/aether-utils.sh spawn-complete "Hammer-42" "completed" "auth module done"
201
+ ```
202
+
203
+ ### Status File
204
+ Commands update `.aether/data/watch-status.txt` with current state:
205
+ - State: PLANNING, EXECUTING, READY
206
+ - Phase: current/total
207
+ - Active Workers: list of named ants
208
+ - Last Activity: most recent log entry
209
+
210
+ ### Progress File
211
+ Update via: `bash .aether/aether-utils.sh update-progress <percent> "<message>" <phase> <total>`
212
+
213
+ Example:
214
+ ```bash
215
+ bash .aether/aether-utils.sh update-progress 45 "Building auth module..." 2 5
216
+ ```
217
+
218
+ ---
219
+
220
+ ## Cleanup
221
+
222
+ To stop watching:
223
+ ```bash
224
+ tmux kill-session -t aether-colony
225
+ ```
226
+
227
+ This stops the session but preserves all log files.
@@ -254,7 +254,7 @@ git rev-parse --git-dir 2>/dev/null
254
254
 
255
255
  - **If succeeds** (is a git repo):
256
256
  1. Check for changes in Aether-managed directories only: `.aether .claude/commands/ant .claude/commands/st .opencode bin`
257
- 2. **If changes exist**: Run using the Bash tool with description "Creating git checkpoint...": `git stash push -m "aether-checkpoint: pre-phase-$PHASE_NUMBER" -- .aether .claude/commands/ant .claude/commands/st .opencode bin`
257
+ 2. **If changes exist**: Run using the Bash tool with description "Creating git checkpoint...": `git stash push -m "aether-checkpoint: pre-phase-$PHASE_NUMBER" -- .aether .claude/commands/ant .claude/commands/st .opencode bin ":(exclude).aether/data/"`
258
258
  - IMPORTANT: Never use `--include-untracked` — it stashes ALL files including user work!
259
259
  - Run using the Bash tool with description "Verifying checkpoint...": `git stash list | head -1 | grep "aether-checkpoint"` — warn if empty
260
260
  - Store checkpoint as `{type: "stash", ref: "aether-checkpoint: pre-phase-$PHASE_NUMBER"}`
@@ -226,7 +226,7 @@ Parse the JSON result (`.result.blockers`):
226
226
 
227
227
  ### Step 2: Update State
228
228
 
229
- Read then update `.aether/data/COLONY_STATE.json`:
229
+ Update `.aether/data/COLONY_STATE.json` using state-mutate (atomic, locked, validated):
230
230
  - Set `state` to `"EXECUTING"`
231
231
  - Set `current_phase` to the phase number
232
232
  - Set the phase's `status` to `"in_progress"` in `plan.phases[N]`
@@ -235,7 +235,14 @@ Read then update `.aether/data/COLONY_STATE.json`:
235
235
 
236
236
  If `events` exceeds 100 entries, keep only the last 100.
237
237
 
238
- Write COLONY_STATE.json.
238
+ Run using the Bash tool with description "Updating colony state for build...":
239
+ ```bash
240
+ bash .aether/aether-utils.sh state-mutate \
241
+ --argjson phase "$PHASE_NUMBER" \
242
+ --arg phase_name "$PHASE_NAME" \
243
+ --arg timestamp "$(date -u +%Y-%m-%dT%H:%M:%SZ)" \
244
+ '.state = "EXECUTING" | .current_phase = $phase | .plan.phases |= map(if .id == $phase then .status = "in_progress" else . end) | .build_started_at = $timestamp | .events = ((.events[-99:]) + [$timestamp + "|phase_started|build|Phase " + ($phase|tostring) + ": " + $phase_name + " started"])'
245
+ ```
239
246
 
240
247
  Validate the state file:
241
248
  Run using the Bash tool with description "Validating colony state...":
@@ -254,7 +261,7 @@ git rev-parse --git-dir 2>/dev/null
254
261
 
255
262
  - **If succeeds** (is a git repo):
256
263
  1. Check for changes in Aether-managed directories only: `.aether .claude/commands/ant .claude/commands/st .opencode bin`
257
- 2. **If changes exist**: Run using the Bash tool with description "Creating git checkpoint...": `git stash push -m "aether-checkpoint: pre-phase-$PHASE_NUMBER" -- .aether .claude/commands/ant .claude/commands/st .opencode bin`
264
+ 2. **If changes exist**: Run using the Bash tool with description "Creating git checkpoint...": `git stash push -m "aether-checkpoint: pre-phase-$PHASE_NUMBER" -- .aether .claude/commands/ant .claude/commands/st .opencode bin ":(exclude).aether/data/"`
258
265
  - IMPORTANT: Never use `--include-untracked` — it stashes ALL files including user work!
259
266
  - Run using the Bash tool with description "Verifying checkpoint...": `git stash list | head -1 | grep "aether-checkpoint"` — warn if empty
260
267
  - Store checkpoint as `{type: "stash", ref: "aether-checkpoint: pre-phase-$PHASE_NUMBER"}`
@@ -1,3 +1,16 @@
1
+ ### Step 5.3.5: Generate Compact Review Context for Review Cycles
2
+
3
+ Before spawning review agents, generate compact colony context for CI/autopilot agent review cycles.
4
+
5
+ Run using the Bash tool with description "Generating compact review context...":
6
+ ```bash
7
+ REVIEW_CONTEXT=$(bash "$AETHER_UTILS" pr-context --compact 2>/dev/null) || true
8
+ ```
9
+
10
+ - If empty, continue without review context (non-blocking)
11
+ - Provides compact colony context for CI/autopilot agent review cycles
12
+ - Output is available for Watcher and subsequent review agents but does not gate them
13
+
1
14
  ### Step 5.4: Spawn Watcher for Verification
2
15
 
3
16
  **MANDATORY: Always spawn a Watcher — testing must be independent.**
@@ -403,3 +416,41 @@ bash .aether/aether-utils.sh memory-capture \
403
416
  ```
404
417
 
405
418
  This ensures verification failures are persisted as blockers that survive context resets. Chaos Ant findings are flagged in Step 5.7.
419
+
420
+ ### Step 5.9: Midden Collection for Merged Branches (NON-BLOCKING)
421
+
422
+ **Per D-04: Wire midden-collect into /ant:run flow (build-verify phase).**
423
+
424
+ If this build is running on main after a merge (detected via COLONY_STATE or git log), attempt midden collection:
425
+
426
+ Run using the Bash tool with description "Collecting midden from merged branch...":
427
+ ```bash
428
+ # Only runs if merge context is available
429
+ if [[ -n "${last_merged_branch:-}" && -n "${last_merge_sha:-}" ]]; then
430
+ collect_result=$(bash .aether/aether-utils.sh midden-collect \
431
+ --branch "$last_merged_branch" --merge-sha "$last_merge_sha" \
432
+ 2>/dev/null || echo '{"ok":false}')
433
+ collect_ok=$(echo "$collect_result" | jq -r '.ok // false' 2>/dev/null)
434
+ if [[ "$collect_ok" == "true" ]]; then
435
+ collect_status=$(echo "$collect_result" | jq -r '.result.status // "unknown"' 2>/dev/null)
436
+ new_entries=$(echo "$collect_result" | jq -r '.result.entries_collected // 0' 2>/dev/null)
437
+ if [[ "$collect_status" == "collected" && "$new_entries" -gt 0 ]]; then
438
+ echo "Midden: collected $new_entries entries from $last_merged_branch"
439
+ fi
440
+ fi
441
+
442
+ # Run cross-PR analysis after collection (per D-05)
443
+ analysis_result=$(bash .aether/aether-utils.sh midden-cross-pr-analysis --window 14 \
444
+ 2>/dev/null || echo '{"ok":false}')
445
+ analysis_ok=$(echo "$analysis_result" | jq -r '.ok // false' 2>/dev/null)
446
+ if [[ "$analysis_ok" == "true" ]]; then
447
+ systemic=$(echo "$analysis_result" | jq -r '.result.systemic_categories // [] | length' 2>/dev/null || echo "0")
448
+ if [[ "$systemic" -gt 0 ]]; then
449
+ categories=$(echo "$analysis_result" | jq -r '.result.systemic_categories | join(", ")' 2>/dev/null)
450
+ echo "Midden: cross-PR systemic: $categories"
451
+ fi
452
+ fi
453
+ fi
454
+ ```
455
+
456
+ This step is NON-BLOCKING -- build verification proceeds regardless of collection or analysis outcome.
@@ -1,3 +1,16 @@
1
+ ### Step 2.0.7: Generate Review Context (pr-context)
2
+
3
+ After verification passes, generate structured colony context for the review and learning steps that follow.
4
+
5
+ Run using the Bash tool with description "Generating review context...":
6
+ ```bash
7
+ REVIEW_CONTEXT=$(bash "$AETHER_UTILS" pr-context 2>/dev/null) || true
8
+ ```
9
+
10
+ - If REVIEW_CONTEXT is empty or fails, continue without it (non-blocking)
11
+ - This provides structured colony context for review/learning steps
12
+ - Output is available for subsequent steps but does not gate them
13
+
1
14
  ### Step 2: Update State
2
15
 
3
16
  Find current phase in `plan.phases`.
@@ -285,20 +298,116 @@ Update COLONY_STATE.json:
285
298
  - Keep max 30 instincts (remove lowest confidence)
286
299
  - Keep max 100 events
287
300
 
288
- Write the updated state through the locked subcommand. Construct the full updated COLONY_STATE.json content as a variable, then pipe it to state-write:
301
+ Write the updated state through targeted `state-mutate` calls. Each call acquires a lock, creates a backup, applies the jq expression, validates, and writes atomically. Do NOT use the Write tool or `state-write` with full JSON content — always use `state-mutate` to avoid stale-context corruption.
289
302
 
290
- Run using the Bash tool with description "Writing colony state...":
303
+ Run using the Bash tool with description "Advancing colony state...":
291
304
  ```bash
292
- cat << 'STATEOF' | bash .aether/aether-utils.sh state-write
293
- <the full JSON content>
294
- STATEOF
305
+ # Mark current phase completed
306
+ bash .aether/aether-utils.sh state-mutate --argjson pid "$current_phase" \
307
+ '.plan.phases |= map(if .id == $pid then .status = "completed" else . end)'
308
+
309
+ # Append learning (if any — skip if no learnings were extracted in Step 2)
310
+ # bash .aether/aether-utils.sh state-mutate --argjson learning "$learning_json" \
311
+ # '.memory.phase_learnings += [$learning]'
312
+
313
+ # Advance to next phase
314
+ bash .aether/aether-utils.sh state-mutate \
315
+ --argjson pid "$current_phase" \
316
+ --argjson next "$next_phase" \
317
+ --arg timestamp "$(date -u +%Y-%m-%dT%H:%M:%SZ)" \
318
+ '.current_phase = $next | .state = "READY" | .build_started_at = null | .events += [$timestamp + "|phase_advanced|continue|Completed Phase " + ($pid|tostring) + ", advancing to Phase " + ($next|tostring)]'
295
319
  ```
296
320
 
297
- This acquires a lock, creates a rolling backup, validates JSON, and writes atomically. Do NOT use the Write tool to write COLONY_STATE.json directly — always go through state-write.
321
+ Run using the Bash tool with description "Enforcing memory caps...":
322
+ ```bash
323
+ # Cap enforcement — keep arrays bounded
324
+ bash .aether/aether-utils.sh state-mutate \
325
+ '.memory.phase_learnings = (.memory.phase_learnings[-20:]) | .memory.decisions = (.memory.decisions[-30:]) | .memory.instincts = (.memory.instincts | sort_by(.confidence) | .[-30:]) | .events = (.events[-100:])'
326
+ ```
298
327
 
299
328
  Validate the state file:
300
329
  Run using the Bash tool with description "Validating colony state...": `bash .aether/aether-utils.sh validate-state colony`
301
330
 
331
+ ### Step 2.0.5: Pheromone Merge-Back (SILENT, NON-BLOCKING)
332
+
333
+ If a `pheromone-branch-export.json` exists in `.aether/exchange/` (written by seal ceremony on a PR branch and merged to main), run merge-back to collect branch-discovered signals into main's pheromone store. This entire step is silent and non-blocking -- continue proceeds even if merge-back fails.
334
+
335
+ Run using the Bash tool with description "Checking for pheromone merge-back file...":
336
+ ```bash
337
+ # Check if a branch pheromone export was merged into main
338
+ export_file=".aether/exchange/pheromone-branch-export.json"
339
+ if [[ -f "$export_file" ]]; then
340
+ merge_result=$(bash .aether/aether-utils.sh pheromone-merge-back --export-file "$export_file" 2>/dev/null || echo '{"ok":false}')
341
+ merge_ok=$(echo "$merge_result" | jq -r '.ok // false' 2>/dev/null)
342
+ if [[ "$merge_ok" == "true" ]]; then
343
+ new_count=$(echo "$merge_result" | jq -r '.result.new_signals_written // 0' 2>/dev/null)
344
+ skipped=$(echo "$merge_result" | jq -r '.result.skipped_count // 0' 2>/dev/null)
345
+ conflicts=$(echo "$merge_result" | jq -r '.result.conflicts_resolved // [] | length' 2>/dev/null)
346
+ if [[ "$new_count" -gt 0 || "$conflicts" -gt 0 ]]; then
347
+ echo "Pheromone merge-back: $new_count new, $conflicts conflicts resolved, $skipped skipped (from merged branch)"
348
+ fi
349
+ # Clean up export file after successful merge
350
+ rm -f "$export_file" 2>/dev/null || true
351
+ else
352
+ echo "Pheromone merge-back: failed (non-blocking)"
353
+ fi
354
+ fi
355
+ ```
356
+
357
+ ### Step 2.0.6: Midden Collection (NON-BLOCKING)
358
+
359
+ After pheromone merge-back, collect failure records from any recently merged branch worktrees. This step is silent and non-blocking -- continue proceeds even if collection fails.
360
+
361
+ **Per D-04: Wire midden-collect into /ant:continue flow.**
362
+
363
+ If the colony uses a PR-based workflow and a merge just happened, attempt to collect the branch's midden entries:
364
+
365
+ Run using the Bash tool with description "Collecting branch midden entries...":
366
+ ```bash
367
+ # Check if there's a recently merged branch to collect from
368
+ # The merge info comes from git log or COLONY_STATE context
369
+ last_merge_branch="${last_merged_branch:-}"
370
+ last_merge_sha="${last_merge_sha:-}"
371
+
372
+ if [[ -n "$last_merge_branch" && -n "$last_merge_sha" ]]; then
373
+ collect_result=$(bash .aether/aether-utils.sh midden-collect \
374
+ --branch "$last_merge_branch" --merge-sha "$last_merge_sha" \
375
+ 2>/dev/null || echo '{"ok":false}')
376
+ collect_ok=$(echo "$collect_result" | jq -r '.ok // false' 2>/dev/null)
377
+ if [[ "$collect_ok" == "true" ]]; then
378
+ collect_status=$(echo "$collect_result" | jq -r '.result.status // "unknown"' 2>/dev/null)
379
+ if [[ "$collect_status" == "collected" ]]; then
380
+ new_entries=$(echo "$collect_result" | jq -r '.result.entries_collected // 0' 2>/dev/null)
381
+ echo "Midden: collected $new_entries failure entries from branch $last_merge_branch"
382
+ fi
383
+ fi
384
+ fi
385
+ ```
386
+
387
+ This step is NON-BLOCKING -- continue proceeds regardless of collection outcome. If `last_merge_branch` and `last_merge_sha` are not set (e.g., no recent merge), this step is silently skipped.
388
+
389
+ ### Step 2.0.7: Cross-PR Midden Analysis (NON-BLOCKING)
390
+
391
+ After midden collection (Step 2.0.6), run cross-PR analysis to detect systemic failure patterns across multiple merged branches. Auto-emits REDIRECT pheromones to hub if systemic patterns found.
392
+
393
+ **Per D-05: Wire midden-cross-pr-analysis into /ant:continue flow.**
394
+
395
+ Run using the Bash tool with description "Running cross-PR midden analysis...":
396
+ ```bash
397
+ analysis_result=$(bash .aether/aether-utils.sh midden-cross-pr-analysis --window 14 \
398
+ 2>/dev/null || echo '{"ok":false}')
399
+ analysis_ok=$(echo "$analysis_result" | jq -r '.ok // false' 2>/dev/null)
400
+ if [[ "$analysis_ok" == "true" ]]; then
401
+ systemic=$(echo "$analysis_result" | jq -r '.result.systemic_categories // [] | length' 2>/dev/null || echo "0")
402
+ if [[ "$systemic" -gt 0 ]]; then
403
+ categories=$(echo "$analysis_result" | jq -r '.result.systemic_categories | join(", ")' 2>/dev/null)
404
+ echo "Midden: cross-PR systemic pattern detected in: $categories (REDIRECT emitted)"
405
+ fi
406
+ fi
407
+ ```
408
+
409
+ This step is NON-BLOCKING -- advance proceeds regardless of analysis outcome.
410
+
302
411
  ### Step 2.1: Auto-Emit Phase Pheromones (SILENT)
303
412
 
304
413
  **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.
@@ -405,3 +405,35 @@ Cross-reference worker claims against reality. This step catches fabricated succ
405
405
  **CRITICAL:** Do NOT proceed to Step 1.6. Do NOT advance the phase. The verification failure is a hard block just like a test failure.
406
406
 
407
407
  Continue to Step 1.6.
408
+
409
+ ### Step 2.0.6: Midden Collection (NON-BLOCKING)
410
+
411
+ After verification passes, collect failure records from any recently merged branch worktrees. This step is silent and non-blocking -- continue proceeds even if collection fails.
412
+
413
+ **Per D-04: Wire midden-collect into /ant:continue flow.**
414
+
415
+ If the colony uses a PR-based workflow and a merge just happened, attempt to collect the branch's midden entries:
416
+
417
+ Run using the Bash tool with description "Collecting branch midden entries...":
418
+ ```bash
419
+ # Check if there's a recently merged branch to collect from
420
+ # The merge info comes from git log or COLONY_STATE context
421
+ last_merge_branch="${last_merged_branch:-}"
422
+ last_merge_sha="${last_merge_sha:-}"
423
+
424
+ if [[ -n "$last_merge_branch" && -n "$last_merge_sha" ]]; then
425
+ collect_result=$(bash .aether/aether-utils.sh midden-collect \
426
+ --branch "$last_merge_branch" --merge-sha "$last_merge_sha" \
427
+ 2>/dev/null || echo '{"ok":false}')
428
+ collect_ok=$(echo "$collect_result" | jq -r '.ok // false' 2>/dev/null)
429
+ if [[ "$collect_ok" == "true" ]]; then
430
+ collect_status=$(echo "$collect_result" | jq -r '.result.status // "unknown"' 2>/dev/null)
431
+ if [[ "$collect_status" == "collected" ]]; then
432
+ new_entries=$(echo "$collect_result" | jq -r '.result.entries_collected // 0' 2>/dev/null)
433
+ echo "Midden: collected $new_entries failure entries from branch $last_merge_branch"
434
+ fi
435
+ fi
436
+ fi
437
+ ```
438
+
439
+ This step is NON-BLOCKING -- continue proceeds regardless of collection outcome. If `last_merge_branch` and `last_merge_sha` are not set (e.g., no recent merge), this step is silently skipped.