amalfa 1.0.0 → 1.0.2

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 (85) hide show
  1. package/README.md +226 -247
  2. package/amalfa.config.example.ts +8 -6
  3. package/docs/AGENT-METADATA-PATTERNS.md +1021 -0
  4. package/docs/CONFIG_E2E_VALIDATION.md +147 -0
  5. package/docs/CONFIG_UNIFICATION.md +187 -0
  6. package/docs/CONFIG_VALIDATION.md +103 -0
  7. package/docs/LEGACY_DEPRECATION.md +174 -0
  8. package/docs/MCP_SETUP.md +317 -0
  9. package/docs/QUICK_START_MCP.md +168 -0
  10. package/docs/SESSION-2026-01-06-METADATA-PATTERNS.md +346 -0
  11. package/docs/SETUP.md +464 -0
  12. package/docs/SETUP_COMPLETE.md +464 -0
  13. package/docs/VISION-AGENT-LEARNING.md +1242 -0
  14. package/docs/_current-config-status.md +93 -0
  15. package/package.json +6 -3
  16. package/polyvis.settings.json.bak +38 -0
  17. package/src/cli.ts +159 -31
  18. package/src/config/defaults.ts +73 -15
  19. package/src/core/VectorEngine.ts +18 -9
  20. package/src/daemon/index.ts +12 -8
  21. package/src/mcp/index.ts +62 -7
  22. package/src/pipeline/AmalfaIngestor.ts +22 -12
  23. package/src/pipeline/PreFlightAnalyzer.ts +434 -0
  24. package/src/resonance/DatabaseFactory.ts +3 -4
  25. package/src/resonance/db.ts +8 -6
  26. package/src/resonance/schema.ts +19 -1
  27. package/src/resonance/services/vector-daemon.ts +151 -0
  28. package/src/utils/DaemonManager.ts +147 -0
  29. package/src/utils/ZombieDefense.ts +5 -1
  30. package/:memory: +0 -0
  31. package/:memory:-shm +0 -0
  32. package/:memory:-wal +0 -0
  33. package/README.old.md +0 -112
  34. package/agents.config.json +0 -11
  35. package/drizzle/0000_minor_iron_fist.sql +0 -19
  36. package/drizzle/meta/0000_snapshot.json +0 -139
  37. package/drizzle/meta/_journal.json +0 -13
  38. package/example_usage.ts +0 -39
  39. package/experiment.sh +0 -35
  40. package/hello +0 -2
  41. package/index.html +0 -52
  42. package/knowledge/excalibur.md +0 -12
  43. package/plans/experience-graph-integration.md +0 -60
  44. package/prompts/gemini-king-mode-prompt.md +0 -46
  45. package/public/docs/MCP_TOOLS.md +0 -372
  46. package/schemas/README.md +0 -20
  47. package/schemas/cda.schema.json +0 -84
  48. package/schemas/conceptual-lexicon.schema.json +0 -75
  49. package/scratchpads/dummy-debrief-boxed.md +0 -39
  50. package/scratchpads/dummy-debrief.md +0 -27
  51. package/scratchpads/scratchpad-design.md +0 -50
  52. package/scratchpads/scratchpad-scrolling.md +0 -20
  53. package/scratchpads/scratchpad-toc-disappearance.md +0 -23
  54. package/scratchpads/scratchpad-toc.md +0 -28
  55. package/scratchpads/test_gardener.md +0 -7
  56. package/src/core/LLMClient.ts +0 -93
  57. package/src/core/TagEngine.ts +0 -56
  58. package/src/db/schema.ts +0 -46
  59. package/src/gardeners/AutoTagger.ts +0 -116
  60. package/src/pipeline/HarvesterPipeline.ts +0 -101
  61. package/src/pipeline/Ingestor.ts +0 -555
  62. package/src/resonance/cli/ingest.ts +0 -41
  63. package/src/resonance/cli/migrate.ts +0 -54
  64. package/src/resonance/config.ts +0 -40
  65. package/src/resonance/daemon.ts +0 -236
  66. package/src/resonance/pipeline/extract.ts +0 -89
  67. package/src/resonance/pipeline/transform_docs.ts +0 -60
  68. package/src/resonance/services/tokenizer.ts +0 -159
  69. package/src/resonance/transform/cda.ts +0 -393
  70. package/src/utils/EnvironmentVerifier.ts +0 -67
  71. package/substack/substack-playbook-1.md +0 -95
  72. package/substack/substack-playbook-2.md +0 -78
  73. package/tasks/ui-investigation.md +0 -26
  74. package/test-db +0 -0
  75. package/test-db-shm +0 -0
  76. package/test-db-wal +0 -0
  77. package/tests/canary/verify_pinch_check.ts +0 -44
  78. package/tests/fixtures/ingest_test.md +0 -12
  79. package/tests/fixtures/ingest_test_boxed.md +0 -13
  80. package/tests/fixtures/safety_test.md +0 -45
  81. package/tests/fixtures/safety_test_boxed.md +0 -49
  82. package/tests/fixtures/tagged_output.md +0 -49
  83. package/tests/fixtures/tagged_test.md +0 -49
  84. package/tests/mcp-server-settings.json +0 -8
  85. package/verify-embedder.ts +0 -54
@@ -0,0 +1,346 @@
1
+ # Session Summary: Agent-First Metadata & Latent Space Tagging
2
+
3
+ **Date:** 2026-01-06
4
+ **Duration:** ~1 hour
5
+ **Topic:** Agent autonomy in metadata generation
6
+
7
+ ---
8
+
9
+ ## Key Insights
10
+
11
+ ### 1. The Inversion: Agent Does, Human Audits
12
+
13
+ **Traditional model:**
14
+ - Human approves every tag, link, decision
15
+ - Bottleneck: O(N) human effort
16
+
17
+ **New model:**
18
+ - Agent auto-augments everything
19
+ - Human audits via git diff (O(log N) effort)
20
+ - Human corrects errors when found
21
+ - System learns from corrections
22
+
23
+ **Result:** Scales without human bottleneck.
24
+
25
+ ### 2. Latent Space Tagging
26
+
27
+ **Innovation:** Tags emerge from vector clustering, not predefined taxonomy.
28
+
29
+ **How it works:**
30
+ ```python
31
+ # Cluster documents in embedding space
32
+ clusters = cluster_embeddings(all_docs, min_size=3)
33
+
34
+ # Generate labels from cluster content
35
+ for cluster in clusters:
36
+ label = generate_label(cluster.documents)
37
+ # e.g., "auth-state-patterns"
38
+
39
+ # Tag all docs with confidence scores
40
+ for doc in cluster.documents:
41
+ doc.add_tag(f"latent:{label}", confidence)
42
+ ```
43
+
44
+ **Advantages:**
45
+ - No taxonomy to maintain
46
+ - Adapts as corpus grows
47
+ - Multi-cluster membership
48
+ - Confidence scores expose uncertainty
49
+
50
+ ### 3. Git as Safety Net
51
+
52
+ **All agent augmentations are git commits:**
53
+
54
+ ```bash
55
+ # Agent augments
56
+ [Amalfa: auto-tagged debrief-auth-refactor]
57
+
58
+ # Human reviews
59
+ $ git diff
60
+
61
+ # Human corrects if needed
62
+ $ vim debrief.md # remove incorrect tag
63
+ $ git commit -m "Remove incorrect tag"
64
+
65
+ # Daemon syncs automatically
66
+ [Amalfa: re-indexed, learned from correction]
67
+ ```
68
+
69
+ **Benefits:**
70
+ - Atomic (one commit per augmentation)
71
+ - Auditable (see what changed)
72
+ - Reversible (revert anytime)
73
+ - Non-destructive (history preserved)
74
+
75
+ ### 4. Seven Auto-Augmentation Patterns
76
+
77
+ 1. **Latent Space Tagging** - Cluster-based organization
78
+ 2. **Entity Extraction & Auto-Linking** - Wiki links inserted automatically
79
+ 3. **Topic Modeling** - High-level themes (LDA/BERTopic)
80
+ 4. **Similarity-Based Suggested Reading** - Context for new sessions
81
+ 5. **Temporal Sequences** - Track work evolution
82
+ 6. **Semantic Backlinks** - Bidirectional links maintained automatically
83
+ 7. **Confidence-Based Tag Weighting** - Express uncertainty, learn from removals
84
+
85
+ ---
86
+
87
+ ## Documents Created
88
+
89
+ ### 1. VISION-AGENT-LEARNING.md
90
+
91
+ **Purpose:** Vision document for agent-generated knowledge
92
+
93
+ **Key sections:**
94
+ - The brief-debrief-playbook flywheel
95
+ - Spec-driven vs. learning-driven development
96
+ - Human as reader, not writer
97
+ - Implications for Amalfa design
98
+ - Evolution path (manual → emergent)
99
+
100
+ **Size:** ~1200 lines
101
+
102
+ **Main insight:** Documentation is cognition, not just artifact. Writing forces reflection.
103
+
104
+ ### 2. AGENT-METADATA-PATTERNS.md
105
+
106
+ **Purpose:** Design document for auto-augmentation system
107
+
108
+ **Key sections:**
109
+ - Core principles (agent autonomy, git as truth, optimistic metadata)
110
+ - Pattern library (7 patterns with implementations)
111
+ - Daemon's role (continuous file watching)
112
+ - Human audit workflow
113
+ - Configuration & implementation phases
114
+
115
+ **Size:** ~1000 lines
116
+
117
+ **Main insight:** Metadata is optimistically generated, occasionally corrected (not pessimistically approved upfront).
118
+
119
+ ---
120
+
121
+ ## Folder Structure
122
+
123
+ Amalfa already has the brief-debrief-playbook pattern from PolyVis:
124
+
125
+ ```
126
+ amalfa/
127
+ ├── briefs/
128
+ │ ├── pending/ # Active work
129
+ │ ├── holding/ # Deferred work
130
+ │ ├── archive/ # Completed work
131
+ │ └── README.md # Workflow guide
132
+
133
+ ├── debriefs/ # ~100+ dated debriefs
134
+ │ ├── 2025-01-03-embedder-refactor.md
135
+ │ ├── 2025-01-02-...md
136
+ │ └── README.md # Debrief guide
137
+
138
+ ├── playbooks/ # ~30+ domain playbooks
139
+ │ ├── alpinejs-playbook.md
140
+ │ ├── embeddings-and-fafcas-protocol-playbook.md
141
+ │ ├── local-first-vector-db-playbook.md
142
+ │ ├── problem-solving-playbook.md
143
+ │ └── README.md # Playbook index
144
+
145
+ └── docs/
146
+ ├── VISION-AGENT-LEARNING.md
147
+ ├── AGENT-METADATA-PATTERNS.md
148
+ └── SETUP.md
149
+ ```
150
+
151
+ **Status:** Infrastructure already in place, ready for Amalfa enhancement.
152
+
153
+ ---
154
+
155
+ ## The Auto-Augmentation Workflow
156
+
157
+ ### Phase 1: Agent Writes
158
+
159
+ ```markdown
160
+ # Debrief: Auth Refactor
161
+
162
+ ## What Worked
163
+ - Alpine's x-data pattern eliminated manual state tracking
164
+
165
+ ## Lessons Learned
166
+ - Alpine for UI state, localStorage for persistence
167
+ ```
168
+
169
+ ### Phase 2: Agent Saves → Auto-Augmentation
170
+
171
+ ```bash
172
+ $ amalfa auto-augment debrief-auth-refactor.md
173
+
174
+ Processing...
175
+ ✓ Entity extraction (found: Alpine, x-data, localStorage)
176
+ ✓ Auto-linking (3 links inserted)
177
+ ✓ Clustering (auth-state-patterns, 0.91)
178
+ ✓ Similarity search (5 neighbors)
179
+ ✓ Tag extraction (6 tags)
180
+ ✓ Metadata generation
181
+
182
+ [Amalfa: auto-tagged debrief-auth-refactor]
183
+ ```
184
+
185
+ ### Phase 3: Result
186
+
187
+ ```markdown
188
+ ---
189
+ type: debrief
190
+ brief_id: brief-auth-refactor
191
+
192
+ # Auto-generated by Amalfa (edit freely)
193
+ tags:
194
+ explicit: [alpine.js, state-management, localStorage]
195
+ latent:
196
+ - auth-state-patterns (0.91)
197
+ - ui-reactivity (0.78)
198
+
199
+ links:
200
+ - playbook-alpine-patterns (uses-pattern, 0.89)
201
+ - debrief-session-management (similar-problem, 0.87)
202
+
203
+ suggested_reading:
204
+ - debrief-session-management (0.87)
205
+ - playbook-state-patterns (0.82)
206
+ ---
207
+
208
+ # Debrief: Auth Refactor
209
+
210
+ ## What Worked
211
+ - [[playbook-alpine-patterns|Alpine's x-data pattern]] eliminated state tracking
212
+ ...
213
+ ```
214
+
215
+ ### Phase 4: Human Audits (Weekly)
216
+
217
+ ```bash
218
+ $ git log --since="1 week ago" --grep="Amalfa:" --oneline
219
+
220
+ a7f3d2e Amalfa: auto-tagged debrief-auth-refactor
221
+ 8b2e4f1 Amalfa: re-clustered corpus (15 new docs)
222
+
223
+ # Review, correct if needed
224
+ $ vim debrief-auth-refactor.md # remove incorrect tag
225
+ $ git commit -m "Remove incorrect tag"
226
+
227
+ # Daemon learns from correction
228
+ ```
229
+
230
+ ---
231
+
232
+ ## Implementation Phases
233
+
234
+ ### Phase 1: Basic Auto-Augmentation (MVP)
235
+ - Entity extraction
236
+ - Auto-linking (high similarity)
237
+ - Tag extraction
238
+ - Embedding generation
239
+ - Git commits
240
+
241
+ **Result:** Agent writes → tags + links added automatically
242
+
243
+ ### Phase 2: Latent Space Tagging
244
+ - Document clustering
245
+ - Auto-generated cluster labels
246
+ - Confidence scores
247
+ - Topic modeling
248
+ - Re-clustering trigger
249
+
250
+ **Result:** Documents self-organize without predefined taxonomy
251
+
252
+ ### Phase 3: Semantic Relationships
253
+ - K-nearest neighbors
254
+ - Suggested reading
255
+ - Temporal sequences
256
+ - Backlink maintenance
257
+
258
+ **Result:** Agents get context quickly on new sessions
259
+
260
+ ### Phase 4: Learning from Corrections
261
+ - Track human edits
262
+ - Adjust confidence thresholds
263
+ - Improve extraction
264
+ - Weekly digest
265
+
266
+ **Result:** System improves over time
267
+
268
+ ---
269
+
270
+ ## Success Metrics
271
+
272
+ ### Agent Productivity
273
+
274
+ **Before:** 25 minutes (write 15m + tag 5m + link 5m)
275
+ **After:** 15 minutes (write 15m + auto-augment 2s)
276
+ **Gain:** 40% faster
277
+
278
+ ### Human Audit Overhead
279
+
280
+ **Target:** O(log N)
281
+
282
+ - 10 docs: 5 min weekly
283
+ - 100 docs: 15 min weekly
284
+ - 1000 docs: 30 min weekly
285
+
286
+ **Corrections needed:** <5% of augmentations
287
+
288
+ ### Knowledge Discovery
289
+
290
+ **Before:** 40 minutes (scan titles + read 5-10 docs)
291
+ **After:** 10 minutes (semantic search 5s + read top 3)
292
+ **Gain:** 75% faster
293
+
294
+ ---
295
+
296
+ ## Key Quotes
297
+
298
+ > "The main benefit from the tags and links is for the agent coming in to a new session and getting up to speed easily and quickly - so the more the agent can do the better."
299
+
300
+ > "If the human finds anything they object to they can remove or modify it - the daemon will pick up the changes and the ingestion will handle it as usual."
301
+
302
+ > "What you should do is provide a set of patterns the agent can use, EG a latent space tag system."
303
+
304
+ ---
305
+
306
+ ## Next Steps
307
+
308
+ 1. **Review existing briefs/debriefs/playbooks** - Understand current patterns
309
+ 2. **Design Amalfa schema** - Support brief-debrief-playbook types
310
+ 3. **Implement Phase 1** - Basic auto-augmentation (MVP)
311
+ 4. **Test on Amalfa corpus** - Use existing debriefs as test data
312
+ 5. **Iterate based on experience** - Learn from PolyVis migration
313
+
314
+ ---
315
+
316
+ ## Related Documents
317
+
318
+ - `VISION-AGENT-LEARNING.md` - Why agent-generated knowledge works
319
+ - `AGENT-METADATA-PATTERNS.md` - How to implement auto-augmentation
320
+ - `SETUP.md` - NPM/GitHub setup for publishing Amalfa
321
+ - `briefs/README.md` - Brief workflow guide
322
+ - `debriefs/README.md` - Debrief workflow guide
323
+ - `playbooks/README.md` - Playbook evolution guide
324
+
325
+ ---
326
+
327
+ ## Conversation Context
328
+
329
+ This session built on:
330
+ - Previous discussion: Agents using Amalfa for cross-session continuity
331
+ - PolyVis experience: Brief-debrief-playbook pattern proved effective
332
+ - Meta-insight: Agents spontaneously maintained docs without prompting
333
+
334
+ **The leap:** If agents naturally maintain docs when given structure, and Amalfa provides semantic infrastructure, then agents can achieve true cross-session continuity with minimal human overhead.
335
+
336
+ **The mechanism:** Latent space tagging + git-based auditing = agent autonomy at scale.
337
+
338
+ ---
339
+
340
+ **Status:** Vision and design documents complete
341
+ **Next:** Implementation planning and MVP development
342
+ **Timeline:** Phases 1-2 achievable in weeks, not months
343
+
344
+ ---
345
+
346
+ _Documentation is not an artifact of work - it's a cognitive tool. Auto-augmentation scales this tool to agent speed._