universal-agent-memory 1.9.0 → 2.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.
@@ -1,7 +1,7 @@
1
1
  /**
2
2
  * Hybrid Adaptive Context Selector for UAM (Option 4)
3
3
  *
4
- * VERSION: 1.9.0 - 10 Model Outcome Success Optimizations
4
+ * VERSION: 2.0.0 - 21 Model Outcome Success Optimizations
5
5
  *
6
6
  * Combines task classification with time-budget awareness, runtime monitoring,
7
7
  * and historical benefit tracking for optimal context loading decisions.
@@ -1,7 +1,7 @@
1
1
  /**
2
2
  * Hybrid Adaptive Context Selector for UAM (Option 4)
3
3
  *
4
- * VERSION: 1.9.0 - 10 Model Outcome Success Optimizations
4
+ * VERSION: 2.0.0 - 21 Model Outcome Success Optimizations
5
5
  *
6
6
  * Combines task classification with time-budget awareness, runtime monitoring,
7
7
  * and historical benefit tracking for optimal context loading decisions.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "universal-agent-memory",
3
- "version": "1.9.0",
3
+ "version": "2.0.0",
4
4
  "description": "Universal AI agent memory system - CLAUDE.md templates, memory, worktrees for Claude Code, Factory.AI, VSCode, OpenCode",
5
5
  "type": "module",
6
6
  "main": "dist/index.js",
@@ -1,4 +1,4 @@
1
- <!-- CLAUDE.md v10.15-opt - 10 Model Outcome Success Optimizations -->
1
+ <!-- CLAUDE.md v2.0.0 - 21 Model Outcome Success Optimizations -->
2
2
  <coding_guidelines>
3
3
 
4
4
  # {{PROJECT_NAME}} - Autonomous Agent Guide
@@ -18,288 +18,269 @@
18
18
 
19
19
  ---
20
20
 
21
- ## CONTEXT PRIORITY (Optimization #2)
21
+ ## ENVIRONMENT SNAPSHOT (Optimization #21 - RUN FIRST)
22
22
 
23
- For time-sensitive tasks (scheduling, logic puzzles, math, <60s timeout):
24
- - SKIP pattern analysis, go STRAIGHT to implementation
25
- - Pattern Router is OPTIONAL for pure reasoning tasks
23
+ **First command in ANY task:**
24
+ ```bash
25
+ python3 --version 2>/dev/null; which pip3 gcc g++ make node npm git curl 2>/dev/null | head -10
26
+ ```
27
+ Takes <2s, prevents 30-60s of tool discovery later.
28
+
29
+ ---
30
+
31
+ ## CONTEXT BUDGET CONTROL (Optimization #14)
32
+
33
+ | Task Size | Action |
34
+ |-----------|--------|
35
+ | Simple (<200 words, 1 file) | Skip Pattern Router, go direct |
36
+ | Medium (multi-file, tests) | 1-line classification only |
37
+ | Complex (multi-service) | Full router with patterns |
38
+ | Timeout <120s | Skip all protocol blocks |
26
39
 
27
40
  ---
28
41
 
29
42
  ## VERIFIER-FIRST PRINCIPLE (Optimization #5 - HIGHEST IMPACT)
30
43
 
31
- **37% of failures are format/output mismatches. This fixes them.**
44
+ **37% of failures are format/output mismatches.**
32
45
 
33
46
  BEFORE implementing ANY task with tests/verifier:
34
- 1. **READ the verifier/test code FIRST** - understand exact expectations
47
+ 1. **READ the verifier/test code FIRST**
35
48
  2. **EXTRACT**: expected file paths, output format, return values
36
49
  3. **CREATE stub outputs** matching expected format immediately
37
- 4. **THEN implement** the actual logic
38
- 5. **RUN verifier after EACH change**
50
+ 4. **RUN verifier after EACH change**
39
51
 
40
52
  ```bash
41
- # Example: Task expects cli_tool and output.txt
42
53
  echo '#!/usr/bin/env python3\nprint("stub")' > cli_tool && chmod +x cli_tool
43
- echo '0' > output.txt
44
- ./verifier.sh # Confirm files detected BEFORE implementing
54
+ ./verifier.sh # Confirm detected BEFORE implementing
55
+ ```
56
+
57
+ ---
58
+
59
+ ## DEPENDENCY PRE-FLIGHT (Optimization #12)
60
+
61
+ **Before writing code, check and install:**
62
+ ```bash
63
+ # Check critical deps
64
+ which python3 pip3 gcc make cmake node npm git curl wget || echo "MISSING"
65
+ # Install missing (budget 20% of time for setup)
66
+ pip3 install -q numpy scipy 2>/dev/null # Example
45
67
  ```
46
68
 
47
69
  ---
48
70
 
49
71
  ## INSTANT REFUSE CHECK (Optimization #6)
50
72
 
51
- Before Pattern Router, check these IMPOSSIBLE conditions:
73
+ Before Pattern Router, check IMPOSSIBLE conditions:
52
74
  - "implement GPT/LLM in <10KB" → IMPOSSIBLE (weights exceed limit)
53
75
  - "compress X to Y bytes" where entropy(X) > Y → IMPOSSIBLE (Shannon limit)
54
76
  - "solve NP-hard optimally at scale" → IMPOSSIBLE (complexity)
55
77
 
56
- If matched: Create `IMPOSSIBLE.md` with explanation, move on. Do NOT attempt.
78
+ If matched: Create `IMPOSSIBLE.md`, move on. Do NOT attempt.
57
79
 
58
80
  ---
59
81
 
60
- ## CODE FIELD
82
+ ## DOMAIN RESEARCH FIRST (Optimization #16)
61
83
 
62
- **Before writing code:** State assumptions, bound scope, identify edge cases.
63
-
64
- ```
65
- Do not write code before stating assumptions.
66
- Do not claim correctness you haven't verified.
67
- Do not handle only the happy path.
68
- ```
69
-
70
- **Output:** Assumptions → Code (smaller than expected) → "Handles/Does NOT handle"
84
+ **For unfamiliar domains (games, crypto, rendering, compilers):**
85
+ 1. Search for EXISTING solutions/examples first (10% time budget)
86
+ 2. Adapt proven approach rather than inventing from scratch
87
+ 3. Only implement from theory if no examples found
71
88
 
72
89
  ---
73
90
 
74
- ## PATTERN ROUTER (MANDATORY FIRST)
91
+ ## PATTERN ROUTER (Optimization #20 - CONDITIONAL)
75
92
 
76
- Before ANY work, print:
93
+ **Simple tasks:** Skip entirely
94
+ **Medium tasks:** Print only:
77
95
  ```
78
- === PATTERN ROUTER ===
79
- Task: [summary]
80
- Classification: [file-creation|constraint|adversarial|pipeline|impossible]
81
- PATTERNS: P12:[Y/N] P17:[Y/N] P20:[Y/N] P11:[Y/N] P18:[Y/N]
82
- ACTIVE: [list YES only]
83
- === END ===
96
+ === TASK: [summary] | CLASS: [type] | ACTIVE: [P-numbers] ===
84
97
  ```
85
-
86
- **P11 ENFORCEMENT (Optimization #3):** If task involves chess/stats/crypto/compression → P11=Y is MANDATORY
87
- - Chess: python-chess + stockfish (NOT custom FEN parsing)
88
- - Statistics: scipy.stats, R CRAN packages (NOT custom implementations)
89
- - Compression: zlib, lz4, brotli (NOT custom Huffman/arithmetic)
90
- - Crypto: hashlib, pycryptodome (NOT custom implementations)
98
+ **Complex tasks:** Full router with pattern listing
91
99
 
92
100
  ---
93
101
 
94
- ## PATTERNS REFERENCE
102
+ ## CORE PATTERNS (P1-P11)
95
103
 
96
- ### Core (P1-P11)
97
104
  | P | Name | Trigger | Action |
98
105
  |---|------|---------|--------|
99
- | 1 | EnvIsolation | Any task | Check deps: `which tool` before use |
100
- | 2 | Recipe | Complex task | Convert to numbered steps |
106
+ | 1 | EnvIsolation | Any task | `which tool` before use |
101
107
  | 3 | StateProtect | Modifies config/db | `cp file file.bak` FIRST |
102
- | 4 | ToolSpec | Ambiguous how | Specify exact tool+flags |
103
108
  | 5 | Impossible | Compression/ML/search | Detect early, refuse |
104
- | 6 | RecencyBias | Critical rules | Put at END of context |
105
- | 7 | Classify | Any task | State-sensitive→backup, Tool→specify |
106
109
  | 8 | CLIoverLib | Uncertain env | `subprocess` > library import |
107
- | 9 | FormatPipeline | Non-text data | Convert→standard format first |
108
- | 10 | Whitelist | Security filter | Allow-list ONLY, never blacklist |
109
- | 11 | PreComputed | Chess/crypto/ML | **MANDATORY**: Use library, NOT custom |
110
+ | 11 | PreComputed | Chess/crypto/ML | **Use library, NOT custom**: python-chess, scipy, zlib, hashlib |
111
+
112
+ ---
113
+
114
+ ## OUTPUT PATTERNS (P12-P16)
110
115
 
111
- ### Output (P12-P16)
112
116
  | P | Name | Trigger | Action |
113
117
  |---|------|---------|--------|
114
- | 12 | **OEV** | Creates files | `ls -la` verify ALL outputs exist before done |
115
- | 13 | IRL | Tests partial pass | Fix specific failure, re-run, iterate |
116
- | 14 | OFV | Format specified | Validate output matches spec |
117
- | 15 | ER | Exception thrown | Read trace, fix error, re-run |
118
- | 16 | **TFE+** | Any output task | Create WORKING minimal outputs FIRST, then enhance |
118
+ | 12 | **OEV** | Creates files | `ls -la` verify ALL outputs exist |
119
+ | 13 | IRL | Tests partial pass | Fix specific failure, re-run |
120
+ | 16 | **TFE+** | Any output | Create WORKING minimal outputs FIRST |
121
+
122
+ ---
123
+
124
+ ## CONSTRAINT PATTERNS (P17-P20)
119
125
 
120
- ### Constraint (P17-P20)
121
126
  | P | Name | Trigger | Action |
122
127
  |---|------|---------|--------|
123
- | 17 | **CE** | "exactly/only/single/must" | Extract constraints, print checklist |
124
- | 18 | MTP | Multi-step | Identify tool per stage, chain |
125
- | 19 | ITR+ | Impossible markers | REFUSE immediately, create IMPOSSIBLE.md |
128
+ | 17 | **CE** | "exactly/only/must" | Extract constraints, print checklist |
126
129
  | 20 | **AT** | "bypass/break/exploit" | Attacker mindset, enumerate vectors |
127
130
 
128
- ### Domain (P21-P26)
129
- | P | Name | Trigger | Action |
130
- |---|------|---------|--------|
131
- | 21 | CEI | Chess | Use Stockfish: `echo "position fen $FEN\ngo depth 20" \| stockfish` |
132
- | 22 | GRF | Git recovery | `cp -r .git .git.bak` FIRST, then `git fsck` |
133
- | 23 | CID | Compress impossible | Refuse if target < Shannon limit |
134
- | 24 | PCC | Polyglot | Search existing examples first |
135
- | 25 | SCP | Multi-service | Configure in dependency order, test each |
136
- | 26 | NMI | >50% tests pass | Focus on specific failures, 30% time reserved |
137
-
138
- ### Verification (P27-P31)
131
+ ---
132
+
133
+ ## DOMAIN PATTERNS (P21-P26)
134
+
139
135
  | P | Name | Trigger | Action |
140
136
  |---|------|---------|--------|
141
- | 27 | ODC | Output dir constraint | Remove non-required files before done |
142
- | 28 | SST | Service task | `curl` test BEFORE claiming done |
143
- | 29 | MSD | "all/both/every" | Find ALL solutions, not just first |
144
- | 30 | PTT | "% threshold" | Iterate until threshold met |
145
- | 31 | RTV | Transform task | Verify round-trip: `original == decompress(compress(original))` |
137
+ | 21 | CEI | Chess | Use Stockfish, NOT custom FEN parsing |
138
+ | 22 | GRF | Git recovery | `cp -r .git .git.bak` FIRST |
139
+ | 26 | **NMI** | >50% tests pass | **MANDATORY**: Focus on specific failures |
140
+
141
+ ---
142
+
143
+ ## EXECUTION PATTERNS (P32-P36)
146
144
 
147
- ### Execution (P32-P36)
148
145
  | P | Name | Trigger | Action |
149
146
  |---|------|---------|--------|
150
147
  | 32 | CEV | CLI tool | Test `./script` not `python script` |
151
- | 33 | NST | Numerical | Multiple seeds, edge cases, tolerance 1e-6 |
152
- | 34 | ISP | Image analysis | Use recognition tools, not reasoning |
153
- | 35 | **DFA** | Encode+decoder given | Read decoder FIRST, match format exactly, test round-trip BEFORE optimizing |
148
+ | 35 | **DFA** | Decoder given | Read decoder FIRST, test round-trip |
154
149
  | 36 | CDR | Competition | Research strategies BEFORE implementing |
155
150
 
156
151
  ---
157
152
 
158
- ## OUTPUT-FIRST DEVELOPMENT (Optimization #8 - P16 Upgraded)
153
+ ## AGGRESSIVE NEAR-MISS ENFORCEMENT (Optimization #11 - CRITICAL)
159
154
 
160
- **BEFORE complex implementation:**
161
- 1. Create ALL expected output files with minimal valid content
162
- 2. Run verifier to confirm files are detected
163
- 3. THEN replace with real implementation
164
- 4. Run verifier after EACH replacement
155
+ **26% of failures are near-misses (60-89% tests pass). This fixes them.**
165
156
 
166
- ```bash
167
- # Example: Task says "create cli_tool and prediction.txt"
168
- echo '#!/usr/bin/env python3\nprint("hello")' > cli_tool && chmod +x cli_tool
169
- echo '0.5' > prediction.txt
170
- ./verifier.sh # Confirm both detected
171
- # THEN implement real logic
157
+ **HARD GATES - Cannot proceed if violated:**
158
+ 1. **If pass rate >60% but <100%: You are NOT done. ITERATE.**
159
+ 2. **Print after EVERY test run:** `TESTS: X/Y passed (Z% - need 100%)`
160
+ 3. **If remaining failures ≤2: Enter SINGLE-FAILURE-FOCUS mode**
161
+ 4. **NEVER say "done" with passing tests <100%**
162
+
163
+ **Time Budget:**
164
+ ```
165
+ Total: 300s → Reserve 90s minimum for iteration
166
+ Total: 120s → Reserve 36s minimum for iteration
167
+ Total: 60s → Reserve 18s minimum for iteration
172
168
  ```
173
169
 
174
170
  ---
175
171
 
176
- ## COMPLETION GATES (MANDATORY)
177
-
178
- **Cannot say "done" until ALL pass:**
172
+ ## SINGLE-ERROR FOCUS MODE (Optimization #13 - CRITICAL)
179
173
 
180
- | Gate | Check | If Fail |
181
- |------|-------|---------|
182
- | 1 | Output files exist | CREATE immediately |
183
- | 2 | Constraints satisfied | FIX violations |
184
- | 3 | Tests 100% pass | ITERATE |
174
+ **When exactly 1-2 tests fail:**
175
+ 1. **Copy the FULL failing test function source**
176
+ 2. **Copy the FULL error trace**
177
+ 3. **Diff:** What does test expect vs what you produce?
178
+ 4. **Fix ONLY that delta. Touch NOTHING else.**
179
+ 5. **Re-run immediately after fix**
185
180
 
186
181
  ```bash
187
- # Gate 1: for f in $EXPECTED; do [ -f "$f" ] || echo "MISSING: $f"; done
188
- # Gate 3: {{TEST_COMMAND}}
182
+ # NEVER do broad refactoring when close to passing
183
+ # ONLY fix the specific assertion that fails
189
184
  ```
190
185
 
191
186
  ---
192
187
 
193
- ## MANDATORY PRE-COMPLETION CHECKLIST (Optimization #1)
188
+ ## TEST OUTPUT DIFFING (Optimization #15)
194
189
 
195
- **BEFORE saying "done", PRINT this checklist:**
196
- ```
197
- === COMPLETION VERIFICATION ===
198
- ☑/☐ All output files verified with `ls -la`
199
- ☑/☐ Tests run and all pass
200
- ☑/☐ If compression: round-trip tested
201
- ☑/☐ If CLI tool: tested as `./script` not `python script`
202
- ☑/☐ Constraints from task satisfied
203
- === END ===
190
+ **When test fails with wrong output:**
191
+ ```bash
192
+ # Save and diff actual vs expected
193
+ ./program > /tmp/actual.out 2>&1
194
+ diff expected.out /tmp/actual.out | head -20
195
+ # Fix ONLY the differences shown
204
196
  ```
205
197
 
206
- **If ANY box is ☐, FIX IT before proceeding.**
207
-
208
198
  ---
209
199
 
210
- ## FAILURE TRIAGE LOOP (Optimization #4 - Prescriptive Iteration)
200
+ ## COMPLETION GATES (MANDATORY)
211
201
 
212
- When tests fail:
213
- 1. **Copy EXACT error message** (not paraphrase)
214
- 2. **Classify error type:**
215
- - `missing-file` create it immediately
216
- - `wrong-format` read expected format from test/verifier
217
- - `wrong-value` → check algorithm logic, add debug output
218
- - `timeout` → reduce scope, submit partial
219
- - `dependency` → pip install / apt-get
220
- 3. **Apply specific fix** for that error type
221
- 4. **Re-run ONLY the failing test**
222
- 5. **NEVER refactor passing code** while fixing failures
202
+ | Gate | Check | If Fail |
203
+ |------|-------|---------|
204
+ | 1 | Output files exist (`ls -la`) | CREATE immediately |
205
+ | 2 | Constraints satisfied | FIX violations |
206
+ | 3 | **Tests 100% pass** | **ITERATE - not done** |
223
207
 
224
208
  ---
225
209
 
226
- ## NEAR-MISS ITERATION PROTOCOL (P26 ENFORCED - MANDATORY)
227
-
228
- **CRITICAL: This protocol converted 2 failing tasks to passing in v1.3.0**
229
-
230
- When >50% of tests pass but not all:
231
- 1. **STOP and assess** - You are close to success, do NOT restart
232
- 2. **Read EXACT failure message** for each failing test - copy the error verbatim
233
- 3. **Fix ONLY the specific failing test** - do not refactor passing code
234
- 4. **Re-run tests IMMEDIATELY** after each single fix
235
- 5. **MANDATORY: Reserve 30% of time budget** for this iteration loop
236
- 6. **Repeat** until 100% pass or time exhausted
237
- 7. **Never give up** on a task that is >50% passing - small fixes flip outcomes
210
+ ## PRE-COMPLETION CHECKLIST (Optimization #1)
238
211
 
239
- **Time Budget Enforcement:**
212
+ **PRINT before saying "done":**
240
213
  ```
241
- Total time: 300s → Iteration budget: 90s minimum
242
- Total time: 120s → Iteration budget: 36s minimum
243
- Total time: 60s → Iteration budget: 18s minimum
214
+ === COMPLETION ===
215
+ ☑/☐ All outputs verified: `ls -la`
216
+ ☑/☐ Tests: X/Y passed (must be 100%)
217
+ ☑/☐ If CLI: tested as `./script`
218
+ ☑/☐ If compression: round-trip tested
219
+ === END ===
244
220
  ```
245
221
 
222
+ **If ANY ☐: FIX before proceeding.**
223
+
246
224
  ---
247
225
 
248
- ## ERROR FAST-PATHS (Optimization #10)
226
+ ## FAILURE TRIAGE (Optimization #4)
249
227
 
250
- | Error Pattern | Instant Fix |
251
- |---------------|-------------|
252
- | ModuleNotFoundError: X | `pip install X` |
253
- | Permission denied | `chmod +x file` |
254
- | command not found: X | `apt-get install X` or `which X` |
255
- | SyntaxError: shebang | Add `#!/usr/bin/env python3` as line 1 |
256
- | JSONDecodeError | Validate with `python -m json.tool file.json` |
257
- | Connection refused | Check service running, correct port |
258
- | No such file or directory | Create the file/directory first |
228
+ | Error Type | Instant Fix |
229
+ |------------|-------------|
230
+ | `missing-file` | Create it immediately |
231
+ | `wrong-format` | Read expected format from test |
232
+ | `wrong-value` | Add debug output, check algorithm |
233
+ | `timeout` | Reduce scope, submit partial |
234
+ | `ModuleNotFoundError: X` | `pip install X` |
235
+ | `Permission denied` | `chmod +x file` |
236
+ | `command not found: X` | `apt-get install X` |
237
+
238
+ **NEVER refactor passing code while fixing failures.**
259
239
 
260
240
  ---
261
241
 
262
- ## DECODER-FIRST & ROUND-TRIP PROTOCOL (P35 ENFORCED - MANDATORY)
242
+ ## PARTIAL CREDIT MAXIMIZATION (Optimization #17)
243
+
244
+ **When time running out (last 20%):**
245
+ 1. Do NOT start new approaches
246
+ 2. Ensure ALL passing tests still pass (regression check)
247
+ 3. Make ONE targeted fix for highest-likelihood failing test
248
+ 4. Submit current state rather than nothing
263
249
 
264
- **CRITICAL: write-compressor failed 2/3 tests due to decoder format mismatch**
250
+ ---
265
251
 
266
- When a task provides a decoder, validator, or expected output format:
267
- 1. **READ the decoder/validator source code FIRST** before writing any implementation
268
- 2. **Extract the exact format** it expects (headers, encoding, byte order, etc.)
269
- 3. **Implement encoder/generator** to match that exact format
270
- 4. **Test round-trip IMMEDIATELY**: `original == decode(encode(original))`
271
- 5. **Never optimize** until round-trip verification passes
272
- 6. **If round-trip fails**: debug the format mismatch, do NOT optimize for size/speed
252
+ ## DECODER-FIRST PROTOCOL (P35 - MANDATORY)
253
+
254
+ When a task provides a decoder/validator:
255
+ 1. **READ decoder source FIRST**
256
+ 2. **Extract exact format** (headers, encoding, byte order)
257
+ 3. **Test round-trip IMMEDIATELY**: `original == decode(encode(original))`
258
+ 4. **Never optimize until round-trip passes**
273
259
 
274
260
  ```bash
275
- # For CLI tools (P32): Always verify execution method matches verifier
276
- chmod +x ./script.py # Make executable
277
- head -1 ./script.py # Verify shebang exists: #!/usr/bin/env python3
278
- ./script.py --help # Test as verifier runs it (NOT python3 script.py)
261
+ chmod +x ./script.py
262
+ head -1 ./script.py # Verify shebang: #!/usr/bin/env python3
263
+ ./script.py --help # Test as verifier runs it
279
264
  ```
280
265
 
281
266
  ---
282
267
 
283
- ## ERROR RECOVERY ESCALATION
268
+ ## ERROR RECOVERY
284
269
 
285
- On any test failure or error:
286
270
  1. **Read exact error message** - do not guess
287
- 2. **If same error twice**: change approach completely, do not retry same fix
288
- 3. **If dependency missing**: install it (`pip install`, `npm install`, `apt-get`)
289
- 4. **If permission denied**: use alternative path or `chmod`
290
- 5. **If timeout**: reduce scope, submit partial solution
291
- 6. **Never repeat a failed command** without modification
271
+ 2. **Same error twice?** Change approach completely
272
+ 3. **Dependency missing?** Install it
273
+ 4. **Timeout approaching?** Submit best partial
292
274
 
293
275
  ---
294
276
 
295
- ## TIME BUDGET ALLOCATION
296
-
297
- For complex tasks (compilation, VM, multi-service):
298
- - **20%** - Environment assessment (deps, tools, constraints)
299
- - **50%** - Core implementation
300
- - **30%** - Iteration, debugging, test fixes
277
+ ## TIME BUDGET
301
278
 
302
- If timeout approaching: submit best partial solution rather than nothing.
279
+ | Phase | Allocation |
280
+ |-------|------------|
281
+ | Environment setup | 20% |
282
+ | Core implementation | 50% |
283
+ | **Iteration/debugging** | **30% (MANDATORY)** |
303
284
 
304
285
  ---
305
286
 
@@ -312,74 +293,45 @@ L3 Semantic │ {{LONG_TERM_BACKEND}}│ search │ ~50ms
312
293
  L4 Knowledge│ SQLite entities/rels │ graph │ <20ms
313
294
  ```
314
295
 
315
- **Commands:**
316
- ```bash
317
- sqlite3 {{MEMORY_DB_PATH}} "SELECT * FROM memories ORDER BY id DESC LIMIT 10;"
318
- {{MEMORY_QUERY_CMD}} "keywords"
319
- {{MEMORY_STORE_CMD}} "lesson" --importance 8
320
- ```
296
+ ---
297
+
298
+ ## FAILURE MEMORY (Optimization #19)
299
+
300
+ **If this exact task was attempted before:**
301
+ 1. Load previous failure report from memory
302
+ 2. Do NOT use the approach that failed
303
+ 3. Start from the approach that got closest to success
321
304
 
322
305
  ---
323
306
 
324
307
  {{#unless IS_BENCHMARK}}
325
308
  ## WORKTREE WORKFLOW
326
309
 
327
- **ALL changes use worktrees. NO EXCEPTIONS.**
328
-
329
310
  ```bash
330
- {{WORKTREE_CREATE_CMD}} <slug> # Creates {{WORKTREE_DIR}}/NNN-<slug>/
331
- cd {{WORKTREE_DIR}}/NNN-<slug>/
311
+ {{WORKTREE_CREATE_CMD}} <slug> # Creates worktree
332
312
  git add -A && git commit -m "type: description"
333
313
  {{WORKTREE_PR_CMD}} <id> # Creates PR
334
- {{WORKTREE_CLEANUP_CMD}} <id> # After merge
335
314
  ```
336
315
 
337
316
  ---
338
317
 
339
- ## MULTI-AGENT
340
-
341
- **Before claiming work:**
342
- ```bash
343
- uam agent overlaps --resource "<files>"
344
- ```
345
-
346
- | Risk | Action |
347
- |------|--------|
348
- | none/low | Proceed |
349
- | medium | Announce, coordinate |
350
- | high/critical | Wait or split |
351
-
352
- ---
353
-
354
318
  ## DROIDS
355
319
 
356
320
  | Droid | Use For |
357
321
  |-------|---------|
358
322
  | security-auditor | OWASP, secrets, injection |
359
323
  | code-quality-guardian | SOLID, complexity |
360
- | performance-optimizer | Algorithms, memory |
361
- | documentation-expert | JSDoc, README |
362
324
  | debug-expert | Dependency conflicts |
363
325
  | sysadmin-expert | Kernel, QEMU, networking |
364
- | ml-training-expert | Model training, MTEB |
365
326
 
366
327
  {{/unless}}
367
328
  ---
368
329
 
369
330
  {{#if HAS_INFRA}}
370
- ## INFRASTRUCTURE (IaC PARITY REQUIRED)
331
+ ## INFRASTRUCTURE
371
332
 
372
333
  **Secrets in GitHub → use pipelines for secret-dependent ops.**
373
-
374
- | Task | Pipeline |
375
- |------|----------|
376
- | Terraform | `iac-terraform-cicd.yml` |
377
- | kubectl ops | `ops-approved-operations.yml` |
378
- | One-time | `ops-create-ephemeral.yml` |
379
-
380
- **Two-phase:** Local proof (no secrets) → IaC parity (via pipeline)
381
-
382
- **PROHIBITED locally:** `terraform apply`, `kubectl apply/delete`, `kubectl create secret`
334
+ **PROHIBITED locally:** `terraform apply`, `kubectl apply/delete`
383
335
 
384
336
  {{/if}}
385
337
  ---
@@ -392,8 +344,6 @@ uam agent overlaps --resource "<files>"
392
344
  {{LINT_COMMAND}} # Lint
393
345
  ```
394
346
 
395
- **Paths:** Memory: `{{MEMORY_DB_PATH}}` | Skills: `{{SKILLS_PATH}}` | Droids: `{{DROIDS_PATH}}`
396
-
397
347
  ---
398
348
 
399
349
  {{#if HAS_PROJECT_MD}}
@@ -410,13 +360,6 @@ uam agent overlaps --resource "<files>"
410
360
  ## Architecture
411
361
  {{{ARCHITECTURE_OVERVIEW}}}
412
362
  {{/if}}
413
-
414
- {{#if ESSENTIAL_COMMANDS}}
415
- ## Commands
416
- ```bash
417
- {{{ESSENTIAL_COMMANDS}}}
418
- ```
419
- {{/if}}
420
363
  {{/if}}
421
364
 
422
365
  ---
@@ -425,15 +368,10 @@ uam agent overlaps --resource "<files>"
425
368
  ## COMPLETION CHECKLIST
426
369
 
427
370
  ```
428
- ☐ Tests pass
371
+ ☐ Tests 100% pass
429
372
  ☐ Lint/typecheck pass
430
373
  ☐ Worktree used (not {{DEFAULT_BRANCH}})
431
- ☐ Memory updated
432
374
  ☐ PR created
433
- ☐ Reviews passed
434
- {{#if HAS_INFRA}}
435
- ☐ IaC parity verified
436
- {{/if}}
437
375
  ☐ No secrets in code
438
376
  ```
439
377
 
@@ -443,15 +381,9 @@ uam agent overlaps --resource "<files>"
443
381
 
444
382
  ```
445
383
  MERGE → DEPLOY → MONITOR → FIX (iterate until 100%)
446
-
447
- 1. MERGE: PR approved → merge to {{DEFAULT_BRANCH}} → delete branch
448
- 2. DEPLOY: CI/CD runs → check status → confirm live
449
- 3. MONITOR: Check logs → verify functionality → smoke tests
450
- 4. FIX: New worktree → fix → GOTO 1
451
- 5. COMPLETE: Update memory → close tasks
452
384
  ```
453
385
 
454
- **Never "done" until:** PR merged + deployed + verified working
386
+ **Never "done" until:** PR merged + deployed + verified
455
387
  {{/unless}}
456
388
 
457
389
  ---
@@ -477,28 +409,16 @@ MERGE → DEPLOY → MONITOR → FIX (iterate until 100%)
477
409
 
478
410
  ---
479
411
 
480
- ## FINAL DIRECTIVES (Optimization #7 - HIGHEST PRIORITY, READ LAST)
412
+ ## FINAL DIRECTIVES (HIGHEST PRIORITY - READ LAST)
481
413
 
482
- 1. **READ verifier/test BEFORE implementing** - understand exact expected format
483
- 2. **`ls -la` ALL outputs BEFORE saying done** - 37% of failures are missing files
484
- 3. **If >50% tests pass, ITERATE** - do NOT restart, fix specific failures
485
- 4. **Use libraries, not custom implementations** - python-chess, scipy, zlib
486
- 5. **When same error twice, CHANGE APPROACH COMPLETELY** - don't retry same fix
414
+ 1. **READ verifier/test BEFORE implementing**
415
+ 2. **`ls -la` ALL outputs BEFORE saying done**
416
+ 3. **If >50% tests pass, ITERATE** - do NOT restart
417
+ 4. **Use libraries, not custom** - python-chess, scipy, zlib
418
+ 5. **Same error twice = CHANGE APPROACH**
419
+ 6. **NEVER say done if tests <100%** - iterate until pass
487
420
 
488
- **P17 Active? Print:**
489
- ```
490
- === CONSTRAINTS ===
491
- ☐ constraint1 ☐ constraint2
492
- ☑ constraint1: PASS/FAIL
493
- === END ===
494
- ```
495
-
496
- **P20 Active? Print:**
497
- ```
498
- === ADVERSARIAL ===
499
- Target: [filter/protection]
500
- Vectors: case, encoding, null, context-break
501
- === END ===
502
- ```
421
+ **P17 Active?** Print: `=== CONSTRAINTS: ☐ c1 ☐ c2 → ☑ c1: PASS ===`
422
+ **P20 Active?** Print: `=== ADVERSARIAL: Target: [X] Vectors: case,encoding,null ===`
503
423
 
504
424
  </coding_guidelines>