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.
- package/.aether/CONTEXT.md +160 -0
- package/.aether/QUEEN.md +84 -0
- package/.aether/aether-utils.sh +7749 -0
- package/.aether/docs/QUEEN-SYSTEM.md +211 -0
- package/.aether/docs/README.md +68 -0
- package/.aether/docs/caste-system.md +48 -0
- package/.aether/docs/disciplines/DISCIPLINES.md +93 -0
- package/.aether/docs/disciplines/coding-standards.md +197 -0
- package/.aether/docs/disciplines/debugging.md +207 -0
- package/.aether/docs/disciplines/learning.md +254 -0
- package/.aether/docs/disciplines/tdd.md +257 -0
- package/.aether/docs/disciplines/verification-loop.md +167 -0
- package/.aether/docs/disciplines/verification.md +116 -0
- package/.aether/docs/error-codes.md +268 -0
- package/.aether/docs/known-issues.md +233 -0
- package/.aether/docs/pheromones.md +205 -0
- package/.aether/docs/queen-commands.md +97 -0
- package/.aether/exchange/colony-registry.xml +11 -0
- package/.aether/exchange/pheromone-xml.sh +575 -0
- package/.aether/exchange/pheromones.xml +87 -0
- package/.aether/exchange/queen-wisdom.xml +14 -0
- package/.aether/exchange/registry-xml.sh +273 -0
- package/.aether/exchange/wisdom-xml.sh +319 -0
- package/.aether/midden/approach-changes.md +5 -0
- package/.aether/midden/build-failures.md +5 -0
- package/.aether/midden/test-failures.md +5 -0
- package/.aether/model-profiles.yaml +100 -0
- package/.aether/rules/aether-colony.md +134 -0
- package/.aether/schemas/aether-types.xsd +255 -0
- package/.aether/schemas/colony-registry.xsd +309 -0
- package/.aether/schemas/example-prompt-builder.xml +234 -0
- package/.aether/schemas/pheromone.xsd +163 -0
- package/.aether/schemas/prompt.xsd +416 -0
- package/.aether/schemas/queen-wisdom.xsd +325 -0
- package/.aether/schemas/worker-priming.xsd +276 -0
- package/.aether/templates/QUEEN.md.template +79 -0
- package/.aether/templates/colony-state-reset.jq.template +22 -0
- package/.aether/templates/colony-state.template.json +35 -0
- package/.aether/templates/constraints.template.json +9 -0
- package/.aether/templates/crowned-anthill.template.md +36 -0
- package/.aether/templates/handoff-build-error.template.md +30 -0
- package/.aether/templates/handoff-build-success.template.md +39 -0
- package/.aether/templates/handoff.template.md +40 -0
- package/.aether/templates/learning-observations.template.json +6 -0
- package/.aether/templates/midden.template.json +7 -0
- package/.aether/templates/pheromones.template.json +6 -0
- package/.aether/templates/session.template.json +9 -0
- package/.aether/utils/atomic-write.sh +219 -0
- package/.aether/utils/chamber-compare.sh +193 -0
- package/.aether/utils/chamber-utils.sh +297 -0
- package/.aether/utils/colorize-log.sh +132 -0
- package/.aether/utils/error-handler.sh +212 -0
- package/.aether/utils/file-lock.sh +158 -0
- package/.aether/utils/queen-to-md.xsl +395 -0
- package/.aether/utils/semantic-cli.sh +413 -0
- package/.aether/utils/spawn-tree.sh +428 -0
- package/.aether/utils/spawn-with-model.sh +56 -0
- package/.aether/utils/state-loader.sh +215 -0
- package/.aether/utils/swarm-display.sh +268 -0
- package/.aether/utils/watch-spawn-tree.sh +253 -0
- package/.aether/utils/xml-compose.sh +253 -0
- package/.aether/utils/xml-convert.sh +273 -0
- package/.aether/utils/xml-core.sh +186 -0
- package/.aether/utils/xml-query.sh +201 -0
- package/.aether/utils/xml-utils.sh +110 -0
- package/.aether/workers.md +765 -0
- package/.claude/agents/ant/aether-ambassador.md +264 -0
- package/.claude/agents/ant/aether-archaeologist.md +322 -0
- package/.claude/agents/ant/aether-auditor.md +266 -0
- package/.claude/agents/ant/aether-builder.md +187 -0
- package/.claude/agents/ant/aether-chaos.md +268 -0
- package/.claude/agents/ant/aether-chronicler.md +304 -0
- package/.claude/agents/ant/aether-gatekeeper.md +325 -0
- package/.claude/agents/ant/aether-includer.md +373 -0
- package/.claude/agents/ant/aether-keeper.md +271 -0
- package/.claude/agents/ant/aether-measurer.md +317 -0
- package/.claude/agents/ant/aether-probe.md +210 -0
- package/.claude/agents/ant/aether-queen.md +325 -0
- package/.claude/agents/ant/aether-route-setter.md +173 -0
- package/.claude/agents/ant/aether-sage.md +353 -0
- package/.claude/agents/ant/aether-scout.md +142 -0
- package/.claude/agents/ant/aether-surveyor-disciplines.md +416 -0
- package/.claude/agents/ant/aether-surveyor-nest.md +354 -0
- package/.claude/agents/ant/aether-surveyor-pathogens.md +288 -0
- package/.claude/agents/ant/aether-surveyor-provisions.md +359 -0
- package/.claude/agents/ant/aether-tracker.md +265 -0
- package/.claude/agents/ant/aether-watcher.md +244 -0
- package/.claude/agents/ant/aether-weaver.md +247 -0
- package/.claude/commands/ant/archaeology.md +341 -0
- package/.claude/commands/ant/build.md +1160 -0
- package/.claude/commands/ant/chaos.md +349 -0
- package/.claude/commands/ant/colonize.md +270 -0
- package/.claude/commands/ant/continue.md +1070 -0
- package/.claude/commands/ant/council.md +309 -0
- package/.claude/commands/ant/dream.md +265 -0
- package/.claude/commands/ant/entomb.md +487 -0
- package/.claude/commands/ant/feedback.md +78 -0
- package/.claude/commands/ant/flag.md +139 -0
- package/.claude/commands/ant/flags.md +155 -0
- package/.claude/commands/ant/focus.md +58 -0
- package/.claude/commands/ant/help.md +122 -0
- package/.claude/commands/ant/history.md +137 -0
- package/.claude/commands/ant/init.md +409 -0
- package/.claude/commands/ant/interpret.md +267 -0
- package/.claude/commands/ant/lay-eggs.md +201 -0
- package/.claude/commands/ant/maturity.md +102 -0
- package/.claude/commands/ant/memory-details.md +77 -0
- package/.claude/commands/ant/migrate-state.md +165 -0
- package/.claude/commands/ant/oracle.md +387 -0
- package/.claude/commands/ant/organize.md +227 -0
- package/.claude/commands/ant/pause-colony.md +247 -0
- package/.claude/commands/ant/phase.md +126 -0
- package/.claude/commands/ant/plan.md +544 -0
- package/.claude/commands/ant/redirect.md +58 -0
- package/.claude/commands/ant/resume-colony.md +182 -0
- package/.claude/commands/ant/resume.md +363 -0
- package/.claude/commands/ant/seal.md +306 -0
- package/.claude/commands/ant/status.md +272 -0
- package/.claude/commands/ant/swarm.md +361 -0
- package/.claude/commands/ant/tunnels.md +425 -0
- package/.claude/commands/ant/update.md +209 -0
- package/.claude/commands/ant/verify-castes.md +95 -0
- package/.claude/commands/ant/watch.md +238 -0
- package/.opencode/agents/aether-ambassador.md +140 -0
- package/.opencode/agents/aether-archaeologist.md +108 -0
- package/.opencode/agents/aether-auditor.md +144 -0
- package/.opencode/agents/aether-builder.md +184 -0
- package/.opencode/agents/aether-chaos.md +115 -0
- package/.opencode/agents/aether-chronicler.md +122 -0
- package/.opencode/agents/aether-gatekeeper.md +116 -0
- package/.opencode/agents/aether-includer.md +117 -0
- package/.opencode/agents/aether-keeper.md +177 -0
- package/.opencode/agents/aether-measurer.md +128 -0
- package/.opencode/agents/aether-probe.md +133 -0
- package/.opencode/agents/aether-queen.md +286 -0
- package/.opencode/agents/aether-route-setter.md +130 -0
- package/.opencode/agents/aether-sage.md +106 -0
- package/.opencode/agents/aether-scout.md +101 -0
- package/.opencode/agents/aether-surveyor-disciplines.md +386 -0
- package/.opencode/agents/aether-surveyor-nest.md +324 -0
- package/.opencode/agents/aether-surveyor-pathogens.md +259 -0
- package/.opencode/agents/aether-surveyor-provisions.md +329 -0
- package/.opencode/agents/aether-tracker.md +137 -0
- package/.opencode/agents/aether-watcher.md +174 -0
- package/.opencode/agents/aether-weaver.md +130 -0
- package/.opencode/commands/ant/archaeology.md +338 -0
- package/.opencode/commands/ant/build.md +1200 -0
- package/.opencode/commands/ant/chaos.md +346 -0
- package/.opencode/commands/ant/colonize.md +202 -0
- package/.opencode/commands/ant/continue.md +938 -0
- package/.opencode/commands/ant/council.md +305 -0
- package/.opencode/commands/ant/dream.md +262 -0
- package/.opencode/commands/ant/entomb.md +367 -0
- package/.opencode/commands/ant/feedback.md +80 -0
- package/.opencode/commands/ant/flag.md +137 -0
- package/.opencode/commands/ant/flags.md +153 -0
- package/.opencode/commands/ant/focus.md +56 -0
- package/.opencode/commands/ant/help.md +124 -0
- package/.opencode/commands/ant/history.md +127 -0
- package/.opencode/commands/ant/init.md +337 -0
- package/.opencode/commands/ant/interpret.md +256 -0
- package/.opencode/commands/ant/lay-eggs.md +141 -0
- package/.opencode/commands/ant/maturity.md +92 -0
- package/.opencode/commands/ant/memory-details.md +77 -0
- package/.opencode/commands/ant/migrate-state.md +153 -0
- package/.opencode/commands/ant/oracle.md +338 -0
- package/.opencode/commands/ant/organize.md +224 -0
- package/.opencode/commands/ant/pause-colony.md +220 -0
- package/.opencode/commands/ant/phase.md +123 -0
- package/.opencode/commands/ant/plan.md +531 -0
- package/.opencode/commands/ant/redirect.md +67 -0
- package/.opencode/commands/ant/resume-colony.md +178 -0
- package/.opencode/commands/ant/resume.md +363 -0
- package/.opencode/commands/ant/seal.md +247 -0
- package/.opencode/commands/ant/status.md +272 -0
- package/.opencode/commands/ant/swarm.md +357 -0
- package/.opencode/commands/ant/tunnels.md +406 -0
- package/.opencode/commands/ant/update.md +191 -0
- package/.opencode/commands/ant/verify-castes.md +85 -0
- package/.opencode/commands/ant/watch.md +220 -0
- package/.opencode/opencode.json +3 -0
- package/CHANGELOG.md +325 -0
- package/DISCLAIMER.md +74 -0
- package/LICENSE +21 -0
- package/README.md +258 -0
- package/bin/cli.js +2436 -0
- package/bin/generate-commands.sh +291 -0
- package/bin/lib/caste-colors.js +57 -0
- package/bin/lib/colors.js +76 -0
- package/bin/lib/errors.js +255 -0
- package/bin/lib/event-types.js +190 -0
- package/bin/lib/file-lock.js +695 -0
- package/bin/lib/init.js +454 -0
- package/bin/lib/logger.js +242 -0
- package/bin/lib/model-profiles.js +445 -0
- package/bin/lib/model-verify.js +288 -0
- package/bin/lib/nestmate-loader.js +130 -0
- package/bin/lib/proxy-health.js +253 -0
- package/bin/lib/spawn-logger.js +266 -0
- package/bin/lib/state-guard.js +602 -0
- package/bin/lib/state-sync.js +516 -0
- package/bin/lib/telemetry.js +441 -0
- package/bin/lib/update-transaction.js +1454 -0
- package/bin/npx-install.js +178 -0
- package/bin/sync-to-runtime.sh +6 -0
- package/bin/validate-package.sh +88 -0
- package/package.json +70 -0
|
@@ -0,0 +1,207 @@
|
|
|
1
|
+
# Systematic Debugging Discipline
|
|
2
|
+
|
|
3
|
+
## The Iron Law
|
|
4
|
+
|
|
5
|
+
```
|
|
6
|
+
NO FIXES WITHOUT ROOT CAUSE INVESTIGATION FIRST
|
|
7
|
+
```
|
|
8
|
+
|
|
9
|
+
If you haven't completed Phase 1, you cannot propose fixes. Symptom fixes are failure.
|
|
10
|
+
|
|
11
|
+
## When to Use
|
|
12
|
+
|
|
13
|
+
Use for ANY technical issue encountered during colony work:
|
|
14
|
+
- Test failures
|
|
15
|
+
- Build errors
|
|
16
|
+
- Unexpected behavior
|
|
17
|
+
- Performance problems
|
|
18
|
+
- Integration issues
|
|
19
|
+
|
|
20
|
+
**Use ESPECIALLY when:**
|
|
21
|
+
- Under time pressure (emergencies make guessing tempting)
|
|
22
|
+
- "Just one quick fix" seems obvious
|
|
23
|
+
- You've already tried multiple fixes
|
|
24
|
+
- Previous fix didn't work
|
|
25
|
+
|
|
26
|
+
## The Four Phases
|
|
27
|
+
|
|
28
|
+
Complete each phase before proceeding to the next.
|
|
29
|
+
|
|
30
|
+
### Phase 1: Root Cause Investigation
|
|
31
|
+
|
|
32
|
+
**BEFORE attempting ANY fix:**
|
|
33
|
+
|
|
34
|
+
1. **Read Error Messages Carefully**
|
|
35
|
+
- Don't skip past errors or warnings
|
|
36
|
+
- Read stack traces completely
|
|
37
|
+
- Note line numbers, file paths, error codes
|
|
38
|
+
|
|
39
|
+
2. **Reproduce Consistently**
|
|
40
|
+
- Can you trigger it reliably?
|
|
41
|
+
- What are the exact steps?
|
|
42
|
+
- If not reproducible โ gather more data, don't guess
|
|
43
|
+
|
|
44
|
+
3. **Check Recent Changes**
|
|
45
|
+
- What changed that could cause this?
|
|
46
|
+
- Git diff, recent commits
|
|
47
|
+
- New dependencies, config changes
|
|
48
|
+
|
|
49
|
+
4. **Gather Evidence in Multi-Component Systems**
|
|
50
|
+
```
|
|
51
|
+
For EACH component boundary:
|
|
52
|
+
- Log what data enters component
|
|
53
|
+
- Log what data exits component
|
|
54
|
+
- Verify environment/config propagation
|
|
55
|
+
|
|
56
|
+
Run once to gather evidence showing WHERE it breaks
|
|
57
|
+
THEN analyze to identify failing component
|
|
58
|
+
```
|
|
59
|
+
|
|
60
|
+
5. **Trace Data Flow (Root Cause Tracing)**
|
|
61
|
+
|
|
62
|
+
When error is deep in call stack:
|
|
63
|
+
- Where does bad value originate?
|
|
64
|
+
- What called this with bad value?
|
|
65
|
+
- Keep tracing UP until you find the source
|
|
66
|
+
- Fix at source, not at symptom
|
|
67
|
+
|
|
68
|
+
```
|
|
69
|
+
Symptom โ Immediate cause โ What called this? โ Keep tracing โ Original trigger โ FIX HERE
|
|
70
|
+
```
|
|
71
|
+
|
|
72
|
+
### Phase 2: Pattern Analysis
|
|
73
|
+
|
|
74
|
+
1. **Find Working Examples**
|
|
75
|
+
- Locate similar working code in same codebase
|
|
76
|
+
- What works that's similar to what's broken?
|
|
77
|
+
|
|
78
|
+
2. **Compare Against References**
|
|
79
|
+
- Read reference implementation COMPLETELY
|
|
80
|
+
- Don't skim - understand fully
|
|
81
|
+
|
|
82
|
+
3. **Identify Differences**
|
|
83
|
+
- What's different between working and broken?
|
|
84
|
+
- List every difference, however small
|
|
85
|
+
|
|
86
|
+
### Phase 3: Hypothesis and Testing
|
|
87
|
+
|
|
88
|
+
1. **Form Single Hypothesis**
|
|
89
|
+
- State clearly: "I think X is the root cause because Y"
|
|
90
|
+
- Be specific, not vague
|
|
91
|
+
|
|
92
|
+
2. **Test Minimally**
|
|
93
|
+
- Make SMALLEST possible change to test hypothesis
|
|
94
|
+
- One variable at a time
|
|
95
|
+
- Don't fix multiple things at once
|
|
96
|
+
|
|
97
|
+
3. **Verify Before Continuing**
|
|
98
|
+
- Did it work? โ Phase 4
|
|
99
|
+
- Didn't work? โ Form NEW hypothesis
|
|
100
|
+
- DON'T add more fixes on top
|
|
101
|
+
|
|
102
|
+
### Phase 4: Implementation
|
|
103
|
+
|
|
104
|
+
1. **Create Failing Test Case**
|
|
105
|
+
- Simplest possible reproduction
|
|
106
|
+
- MUST have before fixing
|
|
107
|
+
|
|
108
|
+
2. **Implement Single Fix**
|
|
109
|
+
- Address root cause identified
|
|
110
|
+
- ONE change at a time
|
|
111
|
+
- No "while I'm here" improvements
|
|
112
|
+
|
|
113
|
+
3. **Verify Fix**
|
|
114
|
+
- Test passes now?
|
|
115
|
+
- No other tests broken?
|
|
116
|
+
- Issue actually resolved?
|
|
117
|
+
|
|
118
|
+
4. **If Fix Doesn't Work**
|
|
119
|
+
- Count: How many fixes have you tried?
|
|
120
|
+
- If < 3: Return to Phase 1, re-analyze
|
|
121
|
+
- **If โฅ 3: STOP - question the architecture**
|
|
122
|
+
|
|
123
|
+
## The 3-Fix Rule
|
|
124
|
+
|
|
125
|
+
**If 3+ fixes have failed:**
|
|
126
|
+
|
|
127
|
+
Pattern indicating architectural problem:
|
|
128
|
+
- Each fix reveals new problem in different place
|
|
129
|
+
- Fixes require "massive refactoring"
|
|
130
|
+
- Each fix creates new symptoms elsewhere
|
|
131
|
+
|
|
132
|
+
**STOP and question fundamentals:**
|
|
133
|
+
- Is this pattern fundamentally sound?
|
|
134
|
+
- Should we refactor architecture vs. continue fixing symptoms?
|
|
135
|
+
|
|
136
|
+
Report to parent/Queen with architectural concern before attempting more fixes.
|
|
137
|
+
|
|
138
|
+
## Red Flags - STOP and Follow Process
|
|
139
|
+
|
|
140
|
+
If you catch yourself thinking:
|
|
141
|
+
- "Quick fix for now, investigate later"
|
|
142
|
+
- "Just try changing X and see if it works"
|
|
143
|
+
- "Add multiple changes, run tests"
|
|
144
|
+
- "It's probably X, let me fix that"
|
|
145
|
+
- "I don't fully understand but this might work"
|
|
146
|
+
- "One more fix attempt" (when already tried 2+)
|
|
147
|
+
|
|
148
|
+
**ALL of these mean: STOP. Return to Phase 1.**
|
|
149
|
+
|
|
150
|
+
## Common Rationalizations
|
|
151
|
+
|
|
152
|
+
| Excuse | Reality |
|
|
153
|
+
|--------|---------|
|
|
154
|
+
| "Issue is simple, don't need process" | Simple issues have root causes too |
|
|
155
|
+
| "Emergency, no time for process" | Systematic is FASTER than thrashing |
|
|
156
|
+
| "Just try this first, then investigate" | First fix sets the pattern. Do it right. |
|
|
157
|
+
| "Multiple fixes at once saves time" | Can't isolate what worked. Causes new bugs. |
|
|
158
|
+
| "I see the problem, let me fix it" | Seeing symptoms โ understanding root cause |
|
|
159
|
+
|
|
160
|
+
## Quick Reference
|
|
161
|
+
|
|
162
|
+
| Phase | Key Activities | Exit Criteria |
|
|
163
|
+
|-------|---------------|---------------|
|
|
164
|
+
| **1. Root Cause** | Read errors, reproduce, trace data flow | Understand WHAT and WHY |
|
|
165
|
+
| **2. Pattern** | Find working examples, compare | Identify differences |
|
|
166
|
+
| **3. Hypothesis** | Form theory, test minimally | Confirmed or new hypothesis |
|
|
167
|
+
| **4. Implementation** | Create test, fix, verify | Bug resolved, tests pass |
|
|
168
|
+
|
|
169
|
+
## Debugging Report Format
|
|
170
|
+
|
|
171
|
+
When reporting debugging work:
|
|
172
|
+
|
|
173
|
+
```
|
|
174
|
+
๐ Debug Report
|
|
175
|
+
===============
|
|
176
|
+
|
|
177
|
+
Issue: {what broke}
|
|
178
|
+
|
|
179
|
+
Phase 1 - Root Cause:
|
|
180
|
+
Error: {exact error message}
|
|
181
|
+
Reproduced: {yes/no, steps}
|
|
182
|
+
Trace: {call chain to source}
|
|
183
|
+
Root cause: {the actual source}
|
|
184
|
+
|
|
185
|
+
Phase 2 - Pattern:
|
|
186
|
+
Working example: {reference found}
|
|
187
|
+
Key difference: {what differs}
|
|
188
|
+
|
|
189
|
+
Phase 3 - Hypothesis:
|
|
190
|
+
Theory: {X causes Y because Z}
|
|
191
|
+
Test: {minimal change made}
|
|
192
|
+
Result: {confirmed/refuted}
|
|
193
|
+
|
|
194
|
+
Phase 4 - Fix:
|
|
195
|
+
Change: {what was changed}
|
|
196
|
+
Test: {failing test created}
|
|
197
|
+
Verified: {tests pass, issue resolved}
|
|
198
|
+
|
|
199
|
+
Fix count: {N}/3 max
|
|
200
|
+
```
|
|
201
|
+
|
|
202
|
+
## Real-World Impact
|
|
203
|
+
|
|
204
|
+
- Systematic approach: 15-30 minutes to fix
|
|
205
|
+
- Random fixes approach: 2-3 hours of thrashing
|
|
206
|
+
- First-time fix rate: 95% vs 40%
|
|
207
|
+
- New bugs introduced: Near zero vs common
|
|
@@ -0,0 +1,254 @@
|
|
|
1
|
+
# Colony Learning Discipline
|
|
2
|
+
|
|
3
|
+
## Overview
|
|
4
|
+
|
|
5
|
+
The colony learns from every phase. Patterns observed during builds become **instincts** - atomic learned behaviors with confidence scoring that improve future work.
|
|
6
|
+
|
|
7
|
+
## The Instinct Model
|
|
8
|
+
|
|
9
|
+
An instinct is a small learned behavior:
|
|
10
|
+
|
|
11
|
+
```yaml
|
|
12
|
+
id: prefer-composition
|
|
13
|
+
trigger: "when designing component architecture"
|
|
14
|
+
confidence: 0.7
|
|
15
|
+
domain: "architecture"
|
|
16
|
+
source: "phase-3-observation"
|
|
17
|
+
evidence:
|
|
18
|
+
- "Composition pattern succeeded in Phase 3"
|
|
19
|
+
- "User approved component structure"
|
|
20
|
+
action: "Use composition over inheritance for component reuse"
|
|
21
|
+
```
|
|
22
|
+
|
|
23
|
+
**Properties:**
|
|
24
|
+
- **Atomic** โ one trigger, one action
|
|
25
|
+
- **Confidence-weighted** โ 0.3 = tentative, 0.9 = near certain
|
|
26
|
+
- **Domain-tagged** โ architecture, testing, code-style, debugging, workflow
|
|
27
|
+
- **Evidence-backed** โ tracks what observations created it
|
|
28
|
+
|
|
29
|
+
## Confidence Scoring
|
|
30
|
+
|
|
31
|
+
| Score | Meaning | Behavior |
|
|
32
|
+
|-------|---------|----------|
|
|
33
|
+
| 0.3 | Tentative | Suggested but not enforced |
|
|
34
|
+
| 0.5 | Moderate | Applied when relevant |
|
|
35
|
+
| 0.7 | Strong | Auto-applied in matching contexts |
|
|
36
|
+
| 0.9 | Near-certain | Core colony behavior |
|
|
37
|
+
|
|
38
|
+
**Confidence increases when:**
|
|
39
|
+
- Pattern is repeatedly observed across phases
|
|
40
|
+
- Pattern leads to successful outcomes
|
|
41
|
+
- No corrections or rework needed
|
|
42
|
+
|
|
43
|
+
**Confidence decreases when:**
|
|
44
|
+
- Pattern leads to errors or rework
|
|
45
|
+
- User provides negative feedback
|
|
46
|
+
- Contradicting evidence appears
|
|
47
|
+
|
|
48
|
+
## Pattern Detection
|
|
49
|
+
|
|
50
|
+
During each phase, observe for:
|
|
51
|
+
|
|
52
|
+
### 1. Success Patterns
|
|
53
|
+
What worked well:
|
|
54
|
+
- Approaches that completed without issues
|
|
55
|
+
- Code structures that passed all tests
|
|
56
|
+
- Workflows that were efficient
|
|
57
|
+
|
|
58
|
+
### 2. Error Resolutions
|
|
59
|
+
What was learned from debugging:
|
|
60
|
+
- Root causes discovered
|
|
61
|
+
- Fixes that worked
|
|
62
|
+
- Architectural insights
|
|
63
|
+
|
|
64
|
+
### 3. User Corrections
|
|
65
|
+
What the user redirected:
|
|
66
|
+
- Feedback via `/ant:feedback`
|
|
67
|
+
- Redirects via `/ant:redirect`
|
|
68
|
+
- Explicit corrections
|
|
69
|
+
|
|
70
|
+
### 4. Tool Preferences
|
|
71
|
+
What tools/patterns were effective:
|
|
72
|
+
- Testing approaches that caught bugs
|
|
73
|
+
- File organization that worked
|
|
74
|
+
- Command sequences that succeeded
|
|
75
|
+
|
|
76
|
+
## Instinct Structure
|
|
77
|
+
|
|
78
|
+
Store in `memory.instincts`:
|
|
79
|
+
|
|
80
|
+
```json
|
|
81
|
+
{
|
|
82
|
+
"instincts": [
|
|
83
|
+
{
|
|
84
|
+
"id": "instinct_<timestamp>",
|
|
85
|
+
"trigger": "when X",
|
|
86
|
+
"action": "do Y",
|
|
87
|
+
"confidence": 0.5,
|
|
88
|
+
"domain": "testing",
|
|
89
|
+
"source": "phase-2",
|
|
90
|
+
"evidence": ["observation 1", "observation 2"],
|
|
91
|
+
"created_at": "<ISO-8601>",
|
|
92
|
+
"last_applied": null,
|
|
93
|
+
"applications": 0,
|
|
94
|
+
"successes": 0
|
|
95
|
+
}
|
|
96
|
+
]
|
|
97
|
+
}
|
|
98
|
+
```
|
|
99
|
+
|
|
100
|
+
## Instinct Lifecycle
|
|
101
|
+
|
|
102
|
+
```
|
|
103
|
+
Observation
|
|
104
|
+
โ
|
|
105
|
+
โผ
|
|
106
|
+
โโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโ
|
|
107
|
+
โ Pattern Detected โ
|
|
108
|
+
โ (success/error/feedback) โ
|
|
109
|
+
โโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโ
|
|
110
|
+
โ
|
|
111
|
+
โผ
|
|
112
|
+
โโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโ
|
|
113
|
+
โ Instinct Created โ
|
|
114
|
+
โ (confidence: 0.3-0.5) โ
|
|
115
|
+
โโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโ
|
|
116
|
+
โ
|
|
117
|
+
โ Applied in future phases
|
|
118
|
+
โผ
|
|
119
|
+
โโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโ
|
|
120
|
+
โ Confidence Adjusted โ
|
|
121
|
+
โ (+0.1 success, -0.1 fail) โ
|
|
122
|
+
โโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโ
|
|
123
|
+
โ
|
|
124
|
+
โ Reaches 0.9
|
|
125
|
+
โผ
|
|
126
|
+
โโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโ
|
|
127
|
+
โ Core Behavior โ
|
|
128
|
+
โ (always applied) โ
|
|
129
|
+
โโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโ
|
|
130
|
+
```
|
|
131
|
+
|
|
132
|
+
## Extracting Instincts
|
|
133
|
+
|
|
134
|
+
After each phase, the Prime Worker should identify:
|
|
135
|
+
|
|
136
|
+
1. **What patterns led to success?**
|
|
137
|
+
- Approach taken
|
|
138
|
+
- Tools used effectively
|
|
139
|
+
- Code structures that worked
|
|
140
|
+
|
|
141
|
+
2. **What was learned from errors?**
|
|
142
|
+
- Root causes found
|
|
143
|
+
- Fixes that worked
|
|
144
|
+
- What to avoid
|
|
145
|
+
|
|
146
|
+
3. **What feedback was received?**
|
|
147
|
+
- User corrections
|
|
148
|
+
- Focus areas emphasized
|
|
149
|
+
- Patterns to avoid
|
|
150
|
+
|
|
151
|
+
Format for extraction:
|
|
152
|
+
|
|
153
|
+
```json
|
|
154
|
+
"patterns_observed": [
|
|
155
|
+
{
|
|
156
|
+
"type": "success",
|
|
157
|
+
"trigger": "when implementing API endpoints",
|
|
158
|
+
"action": "use repository pattern with dependency injection",
|
|
159
|
+
"evidence": "All endpoint tests passed first try"
|
|
160
|
+
},
|
|
161
|
+
{
|
|
162
|
+
"type": "error_resolution",
|
|
163
|
+
"trigger": "when debugging async code",
|
|
164
|
+
"action": "check for missing await statements first",
|
|
165
|
+
"evidence": "Root cause was missing await in 3 cases"
|
|
166
|
+
},
|
|
167
|
+
{
|
|
168
|
+
"type": "user_feedback",
|
|
169
|
+
"trigger": "when structuring components",
|
|
170
|
+
"action": "prefer smaller, focused components",
|
|
171
|
+
"evidence": "User feedback: 'keep components small'"
|
|
172
|
+
}
|
|
173
|
+
]
|
|
174
|
+
```
|
|
175
|
+
|
|
176
|
+
## Applying Instincts
|
|
177
|
+
|
|
178
|
+
When starting a new phase, workers should:
|
|
179
|
+
|
|
180
|
+
1. **Check relevant instincts** for the task domain
|
|
181
|
+
2. **Apply high-confidence instincts** (โฅ0.7) automatically
|
|
182
|
+
3. **Consider moderate instincts** (0.5-0.7) as suggestions
|
|
183
|
+
4. **Log applications** for confidence tracking
|
|
184
|
+
|
|
185
|
+
Format in worker prompt:
|
|
186
|
+
|
|
187
|
+
```
|
|
188
|
+
--- COLONY INSTINCTS ---
|
|
189
|
+
Relevant learned patterns for this phase:
|
|
190
|
+
|
|
191
|
+
[0.9] testing: Always run tests before claiming completion
|
|
192
|
+
[0.7] architecture: Use composition over inheritance
|
|
193
|
+
[0.5] code-style: Prefer functional patterns (tentative)
|
|
194
|
+
```
|
|
195
|
+
|
|
196
|
+
## Reporting Learned Patterns
|
|
197
|
+
|
|
198
|
+
Prime Worker output should include:
|
|
199
|
+
|
|
200
|
+
```json
|
|
201
|
+
"learning": {
|
|
202
|
+
"patterns_observed": [
|
|
203
|
+
{
|
|
204
|
+
"type": "success|error_resolution|user_feedback",
|
|
205
|
+
"trigger": "when X",
|
|
206
|
+
"action": "do Y",
|
|
207
|
+
"evidence": "observation"
|
|
208
|
+
}
|
|
209
|
+
],
|
|
210
|
+
"instincts_applied": ["instinct_id_1", "instinct_id_2"],
|
|
211
|
+
"instinct_outcomes": [
|
|
212
|
+
{"id": "instinct_id_1", "success": true},
|
|
213
|
+
{"id": "instinct_id_2", "success": false}
|
|
214
|
+
]
|
|
215
|
+
}
|
|
216
|
+
```
|
|
217
|
+
|
|
218
|
+
## Colony Memory Evolution
|
|
219
|
+
|
|
220
|
+
Over time, instincts with high confidence become colony-wide behaviors:
|
|
221
|
+
|
|
222
|
+
| Threshold | Evolution |
|
|
223
|
+
|-----------|-----------|
|
|
224
|
+
| 0.9+ with 5+ applications | Core behavior - always applied |
|
|
225
|
+
| 3+ related instincts | Cluster into skill document |
|
|
226
|
+
| Domain-specific cluster | Specialist worker enhancement |
|
|
227
|
+
|
|
228
|
+
## Integration Points
|
|
229
|
+
|
|
230
|
+
### /ant:build
|
|
231
|
+
- Workers receive relevant instincts in prompt
|
|
232
|
+
- Workers report patterns observed
|
|
233
|
+
- Workers log instinct applications
|
|
234
|
+
|
|
235
|
+
### /ant:continue
|
|
236
|
+
- Extract patterns from build results
|
|
237
|
+
- Create/update instincts
|
|
238
|
+
- Adjust confidence based on outcomes
|
|
239
|
+
|
|
240
|
+
### /ant:status
|
|
241
|
+
- Show learned instincts with confidence
|
|
242
|
+
- Show application statistics
|
|
243
|
+
- Show recent pattern discoveries
|
|
244
|
+
|
|
245
|
+
### /ant:feedback
|
|
246
|
+
- Creates user_feedback instinct
|
|
247
|
+
- High initial confidence (0.7)
|
|
248
|
+
- Immediate application to current work
|
|
249
|
+
|
|
250
|
+
## Privacy
|
|
251
|
+
|
|
252
|
+
- Instincts stay local in `.aether/data/COLONY_STATE.json`
|
|
253
|
+
- Only patterns extracted, not raw code
|
|
254
|
+
- Export capability for sharing (future)
|
|
@@ -0,0 +1,257 @@
|
|
|
1
|
+
# Test-Driven Development Discipline
|
|
2
|
+
|
|
3
|
+
## The Iron Law
|
|
4
|
+
|
|
5
|
+
```
|
|
6
|
+
NO PRODUCTION CODE WITHOUT A FAILING TEST FIRST
|
|
7
|
+
```
|
|
8
|
+
|
|
9
|
+
If you didn't watch the test fail, you don't know if it tests the right thing.
|
|
10
|
+
|
|
11
|
+
Write code before the test? Delete it. Start over. No exceptions.
|
|
12
|
+
|
|
13
|
+
## When to Use
|
|
14
|
+
|
|
15
|
+
**Always:**
|
|
16
|
+
- New features
|
|
17
|
+
- Bug fixes
|
|
18
|
+
- Refactoring
|
|
19
|
+
- Behavior changes
|
|
20
|
+
|
|
21
|
+
**The only exceptions (must be explicit):**
|
|
22
|
+
- Throwaway prototypes (will be deleted)
|
|
23
|
+
- Generated/config code
|
|
24
|
+
- User explicitly opts out
|
|
25
|
+
|
|
26
|
+
Thinking "skip TDD just this once"? Stop. That's rationalization.
|
|
27
|
+
|
|
28
|
+
## Red-Green-Refactor Cycle
|
|
29
|
+
|
|
30
|
+
```
|
|
31
|
+
โโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโ
|
|
32
|
+
โ โ
|
|
33
|
+
โ RED โโโโโโโโโบ VERIFY RED โโโโโโโโโบ GREEN โ
|
|
34
|
+
โ Write (must fail Write minimal โ
|
|
35
|
+
โ failing correctly) code to pass โ
|
|
36
|
+
โ test โ โ
|
|
37
|
+
โ โผ โ
|
|
38
|
+
โ VERIFY GREEN โ
|
|
39
|
+
โ (must pass, โ
|
|
40
|
+
โ all green) โ
|
|
41
|
+
โ โ โ
|
|
42
|
+
โ โโโโโโโโโโโโโโ REFACTOR โโโโโโโโโโโโโโโโโ โ
|
|
43
|
+
โ Next test Clean up โ
|
|
44
|
+
โ (stay green) โ
|
|
45
|
+
โ โ
|
|
46
|
+
โโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโ
|
|
47
|
+
```
|
|
48
|
+
|
|
49
|
+
### RED - Write Failing Test
|
|
50
|
+
|
|
51
|
+
Write ONE minimal test showing desired behavior.
|
|
52
|
+
|
|
53
|
+
```typescript
|
|
54
|
+
// GOOD: Clear name, tests real behavior, one thing
|
|
55
|
+
test('rejects empty email with error message', async () => {
|
|
56
|
+
const result = await submitForm({ email: '' });
|
|
57
|
+
expect(result.error).toBe('Email required');
|
|
58
|
+
});
|
|
59
|
+
|
|
60
|
+
// BAD: Vague name, tests mock not code
|
|
61
|
+
test('validation works', async () => {
|
|
62
|
+
const mock = jest.fn();
|
|
63
|
+
// ...
|
|
64
|
+
});
|
|
65
|
+
```
|
|
66
|
+
|
|
67
|
+
**Requirements:**
|
|
68
|
+
- One behavior per test
|
|
69
|
+
- Clear descriptive name
|
|
70
|
+
- Real code (mocks only if unavoidable)
|
|
71
|
+
|
|
72
|
+
### VERIFY RED - Watch It Fail (MANDATORY)
|
|
73
|
+
|
|
74
|
+
```bash
|
|
75
|
+
npm test path/to/test.test.ts
|
|
76
|
+
```
|
|
77
|
+
|
|
78
|
+
Confirm:
|
|
79
|
+
- Test **fails** (not errors)
|
|
80
|
+
- Failure message is expected
|
|
81
|
+
- Fails because feature missing (not typos)
|
|
82
|
+
|
|
83
|
+
**Test passes immediately?** You're testing existing behavior. Fix test.
|
|
84
|
+
|
|
85
|
+
**Test errors?** Fix error, re-run until it fails correctly.
|
|
86
|
+
|
|
87
|
+
### GREEN - Minimal Code
|
|
88
|
+
|
|
89
|
+
Write **simplest** code to pass the test.
|
|
90
|
+
|
|
91
|
+
```typescript
|
|
92
|
+
// GOOD: Just enough to pass
|
|
93
|
+
function validateEmail(email: string): string | null {
|
|
94
|
+
if (!email?.trim()) return 'Email required';
|
|
95
|
+
return null;
|
|
96
|
+
}
|
|
97
|
+
|
|
98
|
+
// BAD: Over-engineered (YAGNI)
|
|
99
|
+
function validateEmail(
|
|
100
|
+
email: string,
|
|
101
|
+
options?: { customMessage?: string; allowEmpty?: boolean }
|
|
102
|
+
): ValidationResult { /* ... */ }
|
|
103
|
+
```
|
|
104
|
+
|
|
105
|
+
Don't add features beyond the test. Don't refactor other code. Don't "improve."
|
|
106
|
+
|
|
107
|
+
### VERIFY GREEN - Watch It Pass (MANDATORY)
|
|
108
|
+
|
|
109
|
+
```bash
|
|
110
|
+
npm test path/to/test.test.ts
|
|
111
|
+
```
|
|
112
|
+
|
|
113
|
+
Confirm:
|
|
114
|
+
- Test passes
|
|
115
|
+
- Other tests still pass
|
|
116
|
+
- Output pristine (no errors, warnings)
|
|
117
|
+
|
|
118
|
+
**Test fails?** Fix code, not test.
|
|
119
|
+
**Other tests fail?** Fix now.
|
|
120
|
+
|
|
121
|
+
### REFACTOR - Clean Up
|
|
122
|
+
|
|
123
|
+
Only after green:
|
|
124
|
+
- Remove duplication
|
|
125
|
+
- Improve names
|
|
126
|
+
- Extract helpers
|
|
127
|
+
|
|
128
|
+
**Keep tests green. Don't add behavior.**
|
|
129
|
+
|
|
130
|
+
### REPEAT
|
|
131
|
+
|
|
132
|
+
Next failing test for next behavior.
|
|
133
|
+
|
|
134
|
+
## Test Types
|
|
135
|
+
|
|
136
|
+
### Unit Tests
|
|
137
|
+
- Individual functions
|
|
138
|
+
- Component logic
|
|
139
|
+
- Pure functions
|
|
140
|
+
- < 50ms each
|
|
141
|
+
|
|
142
|
+
### Integration Tests
|
|
143
|
+
- API endpoints
|
|
144
|
+
- Database operations
|
|
145
|
+
- Service interactions
|
|
146
|
+
|
|
147
|
+
### E2E Tests
|
|
148
|
+
- Critical user flows
|
|
149
|
+
- Complete workflows
|
|
150
|
+
- Browser automation
|
|
151
|
+
|
|
152
|
+
## Coverage Requirements
|
|
153
|
+
|
|
154
|
+
- Minimum 80% coverage target
|
|
155
|
+
- All edge cases covered
|
|
156
|
+
- Error scenarios tested
|
|
157
|
+
- Boundary conditions verified
|
|
158
|
+
|
|
159
|
+
Verify with:
|
|
160
|
+
```bash
|
|
161
|
+
npm run test:coverage
|
|
162
|
+
```
|
|
163
|
+
|
|
164
|
+
## Common Rationalizations
|
|
165
|
+
|
|
166
|
+
| Excuse | Reality |
|
|
167
|
+
|--------|---------|
|
|
168
|
+
| "Too simple to test" | Simple code breaks. Test takes 30 seconds. |
|
|
169
|
+
| "I'll test after" | Tests passing immediately prove nothing. |
|
|
170
|
+
| "Already manually tested" | Ad-hoc โ systematic. No record, can't re-run. |
|
|
171
|
+
| "Deleting X hours is wasteful" | Sunk cost fallacy. Unverified code is debt. |
|
|
172
|
+
| "Need to explore first" | Fine. Throw away exploration, start with TDD. |
|
|
173
|
+
| "TDD will slow me down" | TDD faster than debugging. |
|
|
174
|
+
| "Keep as reference" | You'll adapt it. That's testing after. Delete. |
|
|
175
|
+
|
|
176
|
+
## Red Flags - STOP and Start Over
|
|
177
|
+
|
|
178
|
+
If you catch yourself:
|
|
179
|
+
- Writing code before test
|
|
180
|
+
- Test passes immediately (didn't fail first)
|
|
181
|
+
- Can't explain why test failed
|
|
182
|
+
- Rationalizing "just this once"
|
|
183
|
+
- "I already manually tested it"
|
|
184
|
+
- "Keep as reference"
|
|
185
|
+
- "This is different because..."
|
|
186
|
+
|
|
187
|
+
**ALL mean: Delete code. Start over with TDD.**
|
|
188
|
+
|
|
189
|
+
## Testing Anti-Patterns
|
|
190
|
+
|
|
191
|
+
| Anti-Pattern | Problem | Fix |
|
|
192
|
+
|--------------|---------|-----|
|
|
193
|
+
| Testing implementation | Breaks on refactor | Test behavior/output |
|
|
194
|
+
| Brittle selectors | `.css-class-xyz` | `[data-testid="x"]` |
|
|
195
|
+
| Test interdependence | Tests depend on order | Each test sets up own data |
|
|
196
|
+
| Mock everything | Tests mock, not code | Real code, inject deps |
|
|
197
|
+
| One giant test | Can't isolate failure | One behavior per test |
|
|
198
|
+
|
|
199
|
+
## TDD Report Format
|
|
200
|
+
|
|
201
|
+
When reporting TDD work:
|
|
202
|
+
|
|
203
|
+
```
|
|
204
|
+
๐งช TDD Report
|
|
205
|
+
=============
|
|
206
|
+
|
|
207
|
+
Feature: {what was implemented}
|
|
208
|
+
|
|
209
|
+
Cycle 1:
|
|
210
|
+
RED: test('rejects empty email')
|
|
211
|
+
Verified: โ Failed with "undefined is not 'Email required'"
|
|
212
|
+
GREEN: Added email validation
|
|
213
|
+
Verified: โ Passes
|
|
214
|
+
|
|
215
|
+
Cycle 2:
|
|
216
|
+
RED: test('rejects invalid format')
|
|
217
|
+
Verified: โ Failed with expected message
|
|
218
|
+
GREEN: Added regex check
|
|
219
|
+
Verified: โ Passes
|
|
220
|
+
|
|
221
|
+
Coverage: 87% (target: 80%)
|
|
222
|
+
All tests: 47/47 passing
|
|
223
|
+
```
|
|
224
|
+
|
|
225
|
+
## Bug Fix with TDD
|
|
226
|
+
|
|
227
|
+
1. Write failing test reproducing bug
|
|
228
|
+
2. Verify it fails (proves bug exists)
|
|
229
|
+
3. Fix bug
|
|
230
|
+
4. Verify test passes
|
|
231
|
+
5. Test now prevents regression
|
|
232
|
+
|
|
233
|
+
**Never fix bugs without a test.**
|
|
234
|
+
|
|
235
|
+
## Integration with Debugging
|
|
236
|
+
|
|
237
|
+
When debugging reveals root cause:
|
|
238
|
+
1. Write test that would have caught it
|
|
239
|
+
2. Verify test fails
|
|
240
|
+
3. Apply fix
|
|
241
|
+
4. Verify test passes
|
|
242
|
+
|
|
243
|
+
This ensures the bug never returns.
|
|
244
|
+
|
|
245
|
+
## Verification Checklist
|
|
246
|
+
|
|
247
|
+
Before marking work complete:
|
|
248
|
+
|
|
249
|
+
- [ ] Every new function has a test
|
|
250
|
+
- [ ] Watched each test fail before implementing
|
|
251
|
+
- [ ] Each test failed for expected reason
|
|
252
|
+
- [ ] Wrote minimal code to pass
|
|
253
|
+
- [ ] All tests pass
|
|
254
|
+
- [ ] Coverage meets threshold
|
|
255
|
+
- [ ] No skipped/disabled tests
|
|
256
|
+
|
|
257
|
+
Can't check all boxes? You skipped TDD. Start over.
|