agentdb 3.0.0-alpha.7 → 3.0.0-alpha.9

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 (100) hide show
  1. package/README.md +214 -1204
  2. package/dist/agentdb.browser.js +1 -1
  3. package/dist/agentdb.browser.min.js +1 -1
  4. package/dist/backends/VectorBackend.d.ts +120 -0
  5. package/dist/backends/VectorBackend.js +14 -0
  6. package/dist/backends/VectorBackend.js.map +1 -0
  7. package/dist/optimizations/RVFOptimizer.d.ts +225 -0
  8. package/dist/optimizations/RVFOptimizer.js +541 -0
  9. package/dist/optimizations/RVFOptimizer.js.map +1 -0
  10. package/dist/src/backends/factory.d.ts +1 -0
  11. package/dist/src/backends/factory.d.ts.map +1 -1
  12. package/dist/src/backends/factory.js +40 -7
  13. package/dist/src/backends/factory.js.map +1 -1
  14. package/dist/src/backends/index.cjs +6 -0
  15. package/dist/src/backends/ruvector/RuVectorBackend.d.ts +40 -22
  16. package/dist/src/backends/ruvector/RuVectorBackend.d.ts.map +1 -1
  17. package/dist/src/backends/ruvector/RuVectorBackend.js +228 -81
  18. package/dist/src/backends/ruvector/RuVectorBackend.js.map +1 -1
  19. package/dist/src/consensus/RaftConsensus.d.ts +220 -0
  20. package/dist/src/consensus/RaftConsensus.d.ts.map +1 -0
  21. package/dist/src/consensus/RaftConsensus.js +762 -0
  22. package/dist/src/consensus/RaftConsensus.js.map +1 -0
  23. package/dist/src/controllers/AttentionService.d.ts +80 -1
  24. package/dist/src/controllers/AttentionService.d.ts.map +1 -1
  25. package/dist/src/controllers/AttentionService.js +344 -13
  26. package/dist/src/controllers/AttentionService.js.map +1 -1
  27. package/dist/src/controllers/HierarchicalMemory.d.ts +197 -0
  28. package/dist/src/controllers/HierarchicalMemory.d.ts.map +1 -0
  29. package/dist/src/controllers/HierarchicalMemory.js +519 -0
  30. package/dist/src/controllers/HierarchicalMemory.js.map +1 -0
  31. package/dist/src/controllers/LearningSystem.d.ts +17 -0
  32. package/dist/src/controllers/LearningSystem.d.ts.map +1 -1
  33. package/dist/src/controllers/LearningSystem.js +131 -0
  34. package/dist/src/controllers/LearningSystem.js.map +1 -1
  35. package/dist/src/controllers/MemoryConsolidation.d.ts +142 -0
  36. package/dist/src/controllers/MemoryConsolidation.d.ts.map +1 -0
  37. package/dist/src/controllers/MemoryConsolidation.js +479 -0
  38. package/dist/src/controllers/MemoryConsolidation.js.map +1 -0
  39. package/dist/src/controllers/QUICConnection.d.ts +122 -0
  40. package/dist/src/controllers/QUICConnection.d.ts.map +1 -0
  41. package/dist/src/controllers/QUICConnection.js +329 -0
  42. package/dist/src/controllers/QUICConnection.js.map +1 -0
  43. package/dist/src/controllers/QUICConnectionPool.d.ts +83 -0
  44. package/dist/src/controllers/QUICConnectionPool.d.ts.map +1 -0
  45. package/dist/src/controllers/QUICConnectionPool.js +256 -0
  46. package/dist/src/controllers/QUICConnectionPool.js.map +1 -0
  47. package/dist/src/controllers/QUICStreamManager.d.ts +114 -0
  48. package/dist/src/controllers/QUICStreamManager.d.ts.map +1 -0
  49. package/dist/src/controllers/QUICStreamManager.js +267 -0
  50. package/dist/src/controllers/QUICStreamManager.js.map +1 -0
  51. package/dist/src/controllers/StreamingEmbeddingService.d.ts +82 -0
  52. package/dist/src/controllers/StreamingEmbeddingService.d.ts.map +1 -0
  53. package/dist/src/controllers/StreamingEmbeddingService.js +243 -0
  54. package/dist/src/controllers/StreamingEmbeddingService.js.map +1 -0
  55. package/dist/src/controllers/WASMVectorSearch.d.ts +30 -0
  56. package/dist/src/controllers/WASMVectorSearch.d.ts.map +1 -1
  57. package/dist/src/controllers/WASMVectorSearch.js +70 -0
  58. package/dist/src/controllers/WASMVectorSearch.js.map +1 -1
  59. package/dist/src/controllers/index.cjs +6 -0
  60. package/dist/src/controllers/index.d.ts +10 -0
  61. package/dist/src/controllers/index.d.ts.map +1 -1
  62. package/dist/src/controllers/index.js +6 -0
  63. package/dist/src/controllers/index.js.map +1 -1
  64. package/dist/src/core/AgentDB.d.ts.map +1 -1
  65. package/dist/src/core/AgentDB.js +1 -0
  66. package/dist/src/core/AgentDB.js.map +1 -1
  67. package/dist/src/index.cjs +6 -0
  68. package/dist/src/index.d.ts +4 -0
  69. package/dist/src/index.d.ts.map +1 -1
  70. package/dist/src/index.js +2 -0
  71. package/dist/src/index.js.map +1 -1
  72. package/dist/src/optimizations/RVFOptimizer.d.ts +226 -0
  73. package/dist/src/optimizations/RVFOptimizer.d.ts.map +1 -0
  74. package/dist/src/optimizations/RVFOptimizer.js +541 -0
  75. package/dist/src/optimizations/RVFOptimizer.js.map +1 -0
  76. package/dist/src/optimizations/index.d.ts +2 -0
  77. package/dist/src/optimizations/index.d.ts.map +1 -1
  78. package/dist/src/optimizations/index.js +1 -0
  79. package/dist/src/optimizations/index.js.map +1 -1
  80. package/dist/src/security/MutationGuard.d.ts.map +1 -1
  81. package/dist/src/security/MutationGuard.js +24 -39
  82. package/dist/src/security/MutationGuard.js.map +1 -1
  83. package/dist/src/security/index.cjs +6 -0
  84. package/dist/src/services/GNNService.d.ts +172 -0
  85. package/dist/src/services/GNNService.d.ts.map +1 -0
  86. package/dist/src/services/GNNService.js +612 -0
  87. package/dist/src/services/GNNService.js.map +1 -0
  88. package/dist/src/services/GraphTransformerService.d.ts +1 -0
  89. package/dist/src/services/GraphTransformerService.d.ts.map +1 -1
  90. package/dist/src/services/GraphTransformerService.js +41 -3
  91. package/dist/src/services/GraphTransformerService.js.map +1 -1
  92. package/dist/src/services/SemanticRouter.d.ts +7 -2
  93. package/dist/src/services/SemanticRouter.d.ts.map +1 -1
  94. package/dist/src/services/SemanticRouter.js +13 -2
  95. package/dist/src/services/SemanticRouter.js.map +1 -1
  96. package/dist/src/services/SonaTrajectoryService.d.ts +126 -2
  97. package/dist/src/services/SonaTrajectoryService.d.ts.map +1 -1
  98. package/dist/src/services/SonaTrajectoryService.js +311 -3
  99. package/dist/src/services/SonaTrajectoryService.js.map +1 -1
  100. package/package.json +22 -16
package/README.md CHANGED
@@ -6,1329 +6,339 @@
6
6
  [![npm downloads](https://img.shields.io/npm/dm/agentdb.svg?style=flat-square)](https://www.npmjs.com/package/agentdb)
7
7
  [![License](https://img.shields.io/badge/license-MIT%20OR%20Apache--2.0-green?style=flat-square)](LICENSE)
8
8
  [![TypeScript](https://img.shields.io/badge/TypeScript-5.x-blue?style=flat-square&logo=typescript)](https://www.typescriptlang.org/)
9
- [![Tests](https://img.shields.io/badge/tests-passing-brightgreen?style=flat-square)](tests/)
10
- [![MCP Compatible](https://img.shields.io/badge/MCP-32%20tools-blueviolet?style=flat-square)](docs/MCP_TOOL_OPTIMIZATION_GUIDE.md)
11
- [![CLI Commands](https://img.shields.io/badge/CLI-59%20commands-orange?style=flat-square)](docs/DEEP-REVIEW-V2-LATENT-SPACE.md)
12
- [![Simulations](https://img.shields.io/badge/simulations-25%20scenarios-green?style=flat-square)](simulation/README.md)
13
9
 
14
- AgentDB is the first vector database built specifically for autonomous AI agents. v3 introduces **proof-gated mutations** — every state-changing operation requires a cryptographic proof before the backend will execute it. Powered by `@ruvector/graph-transformer` with 8 verified graph modules, native Rust performance via NAPI-RS, and 82-byte attestations.
10
+ AgentDB v3 is the first memory system built specifically for autonomous AI agents with **proof-gated mutations** — every state-changing operation requires a cryptographic proof before execution. Powered by `@ruvector/graph-transformer` with 8 verified graph modules, native Rust performance via NAPI-RS, and 82-byte attestations.
15
11
 
16
- **What's new in v3:**
17
- - Proof-gated mutations via MutationGuard — bad inputs never reach the native addon
18
- - 8 graph-transformer modules: sublinear attention, verified training, causal attention, Granger extraction, Hamiltonian dynamics, spiking attention, game-theoretic equilibrium, product manifold distance
19
- - Re-enabled vectorBackend (was disabled in v2 due to unhandled native addon errors)
20
- - All 21 controllers wired and active
21
- - Complete barrel exports for controllers and security primitives
12
+ ## What's New in v3
22
13
 
23
- **Perfect for:** LangChain agents, AutoGPT, Claude Code tools, custom AI assistants, RAG systems, or any application where AI needs to remember, learn, and improve.
24
-
25
- ---
26
-
27
- > **v3.0 Alpha Available!** `npm install agentdb@v3` (or `agentdb@alpha` once promoted). Production users should use `npm install agentdb@latest` for the stable v2 release.
28
-
29
- ## Key Features
30
-
31
- - **Proof-Gated Mutations** — Every insert/search/remove requires a MutationProof with structural hash and attestation token
32
- - **8 Graph-Transformer Modules** — Native Rust via @ruvector/graph-transformer with JS fallback
33
- - **21 Active Controllers** — Reflexion, Skills, ReasoningBank, CausalGraph, CausalRecall, LearningSystem, ExplainableRecall, NightlyLearner, and more
34
- - **150x Faster Vector Search** — RuVector Rust backend with SIMD (61us p50 latency)
35
- - **AttestationLog** — Append-only audit log for every proof and denial
36
- - **GuardedVectorBackend** — Drop-in VectorBackend wrapper that enforces proof gates
37
- - **Six Cognitive Memory Patterns** — Reflexion, Skills, Causal Memory, Explainable Recall, Utility Ranking, Nightly Learner
38
- - **Runs Anywhere** — Node.js, browsers, edge functions, MCP tools
39
- - **Zero Configuration** — Auto-selects optimal backend (RuVector -> HNSWLib -> sql.js)
40
- - **$0 Cost** — Fully local, no API keys, no cloud fees
14
+ - **Proof-Gated Mutations** MutationGuard validates every insert, search, remove, save, and load with structural hashes and attestation tokens
15
+ - **8 Graph-Transformer Modules** — Sublinear attention, verified training, causal attention, Granger extraction, Hamiltonian dynamics, spiking attention, game-theoretic equilibrium, product manifold distance
16
+ - **AttestationLog** — Append-only audit trail with cryptographic proofs for compliance and debugging
17
+ - **GuardedVectorBackend** — Drop-in wrapper that enforces proof gates on any vector backend
18
+ - **21 Active Controllers** All cognitive memory patterns are production-ready with proof validation
19
+ - **Zero-Native Regression** — Package size reduced from 50.1MB to 1.4MB by removing unused binaries
20
+ - **Browser Support** — Runs in Node.js, browsers, edge functions, and MCP tools via WASM fallback
41
21
 
42
22
  ## Quick Start
43
23
 
44
- Get started in 60 seconds:
45
-
46
24
  ```bash
47
- # Install v3 Alpha (proof-gated graph intelligence)
25
+ # Install v3 Alpha
48
26
  npm install agentdb@v3
49
27
 
50
- # Or install Stable (current production v2)
28
+ # Or use stable v2
51
29
  npm install agentdb@latest
52
-
53
- # Use in your code
54
- import { createDatabase, ReasoningBank, EmbeddingService } from 'agentdb';
55
-
56
- const db = await createDatabase('./agent-memory.db');
57
- const embedder = new EmbeddingService({ model: 'Xenova/all-MiniLM-L6-v2' });
58
- await embedder.initialize();
59
-
60
- const reasoningBank = new ReasoningBank(db, embedder);
61
-
62
- // Store what your agent learned
63
- await reasoningBank.storePattern({
64
- taskType: 'code_review',
65
- approach: 'Security-first analysis',
66
- successRate: 0.95
67
- });
68
-
69
- // Find similar successful patterns later (32.6M ops/sec!)
70
- const patterns = await reasoningBank.searchPatterns({
71
- task: 'security code review',
72
- k: 10
73
- });
74
30
  ```
75
31
 
76
- **For Claude Code / MCP Integration** (zero-code setup):
77
- ```bash
78
- # v3 Alpha
79
- claude mcp add agentdb npx agentdb@v3 mcp start
80
-
81
- # Or stable version
82
- claude mcp add agentdb npx agentdb@latest mcp start
83
- ```
84
-
85
- **Run latent space simulations** (validate 8.2x speedup):
86
- ```bash
87
- agentdb simulate hnsw --iterations 3 # HNSW optimization
88
- agentdb simulate attention --iterations 3 # GNN attention (8-head)
89
- agentdb simulate --wizard # Interactive configuration
90
- ```
91
-
92
- See [📖 Complete Tutorial](#-tutorial) below for step-by-step examples.
93
-
94
- ---
95
-
96
- ## 🎯 Embedding Models
97
-
98
- AgentDB supports multiple embedding models with different tradeoffs:
99
-
100
- ### Quick Start (Default)
101
-
102
- ```bash
103
- # Uses Xenova/all-MiniLM-L6-v2 (384 dimensions)
104
- npx agentdb init
105
- ```
106
-
107
- ### Production Quality
108
-
109
- ```bash
110
- # Best quality for production RAG systems
111
- npx agentdb init --dimension 768 --model "Xenova/bge-base-en-v1.5"
112
- ```
113
-
114
- ### Model Comparison
115
-
116
- | Model | Dimension | Quality | Speed | Best For |
117
- |-------|-----------|---------|-------|----------|
118
- | **all-MiniLM-L6-v2** (default) | 384 | ⭐⭐⭐⭐ | ⚡⚡⚡⚡⚡ | Prototyping, demos |
119
- | **bge-small-en-v1.5** | 384 | ⭐⭐⭐⭐⭐ | ⚡⚡⚡⚡ | Best 384-dim quality |
120
- | **bge-base-en-v1.5** | 768 | ⭐⭐⭐⭐⭐ | ⚡⚡⚡ | Production systems |
121
- | all-mpnet-base-v2 | 768 | ⭐⭐⭐⭐⭐ | ⚡⚡⚡ | All-around excellence |
122
- | e5-base-v2 | 768 | ⭐⭐⭐⭐⭐ | ⚡⚡⚡ | Multilingual (100+ languages) |
123
-
124
- ### Usage Examples
32
+ ## Basic Usage
125
33
 
126
34
  ```typescript
127
35
  import { AgentDB } from 'agentdb';
128
36
 
129
- // Default (fast, 384-dim, proof-gated)
130
- const db1 = new AgentDB({
131
- dbPath: './fast.db',
132
- dimension: 384 // Uses all-MiniLM-L6-v2
37
+ // Initialize with proof-gated vectorBackend
38
+ const db = new AgentDB({
39
+ dbPath: './agent-memory.db',
40
+ dimension: 384,
41
+ vectorBackend: 'ruvector',
42
+ enableProofGate: true // Default: true in v3
133
43
  });
134
- await db1.initialize();
44
+
45
+ await db.initialize();
135
46
 
136
47
  // Access controllers
137
- const reflexion = db1.getController('reflexion');
138
- const reasoning = db1.getController('reasoning');
139
- const graphTransformer = db1.getGraphTransformer();
48
+ const reflexion = db.getController('reflexion');
49
+ const reasoning = db.getController('reasoning');
50
+ const causalGraph = db.getController('causalGraph');
140
51
 
141
52
  // Check proof engine status
142
- const guard = db1.getMutationGuard();
143
- console.log(guard?.getStats().engineType); // 'native' | 'wasm' | 'js'
144
- ```
145
-
146
- **📖 Complete guide**: See [docs/EMBEDDING-MODELS-GUIDE.md](docs/EMBEDDING-MODELS-GUIDE.md) for:
147
- - 7+ recommended models with benchmarks
148
- - OpenAI API integration
149
- - Model selection guide by use case
150
- - Storage/memory calculations
151
- - Migration instructions
152
-
153
- **No API key needed** - All Xenova models run locally via Transformers.js! 🚀
154
-
155
- ---
156
-
157
- ## What's New in v3.0
158
-
159
- AgentDB v3 introduces **proof-gated graph intelligence** — a fundamental security and reliability upgrade where every state mutation requires cryptographic proof before execution.
160
-
161
- **Proof-Gated Mutations (ADR-060):**
162
- - MutationGuard validates every insert, search, remove, save, and load
163
- - Structural hash + attestation token for each operation
164
- - AttestationLog provides append-only audit trail
165
- - GuardedVectorBackend wraps any backend with proof enforcement
166
- - Native proofs via @ruvector/graph-transformer (sub-ms), JS fallback for all environments
167
-
168
- **8 Graph-Transformer Modules:**
169
- - Sublinear Attention — O(n log n) attention replacing O(n^2) JS fallback
170
- - Verified Training — SGD with cryptographic proof of each step
171
- - Causal Attention — temporal-decay weighted attention for CausalRecall
172
- - Granger Extract — time-series causal discovery
173
- - Hamiltonian Step — physics-informed agent trajectory modeling
174
- - Spiking Attention — biological integrate-and-fire for ReflexionMemory
175
- - Game-Theoretic Attention — Nash equilibrium for multi-agent routing
176
- - Product Manifold Distance — curved-space similarity for ReasoningBank
177
-
178
- **All 21 Controllers Active:**
179
- - ReflexionMemory, SkillLibrary, ReasoningBank, CausalMemoryGraph
180
- - CausalRecall, LearningSystem, ExplainableRecall, NightlyLearner
181
- - EmbeddingService, EnhancedEmbeddingService, WASMVectorSearch, HNSWIndex
182
- - AttentionService, MMRDiversityRanker, ContextSynthesizer, MetadataFilter
183
- - QUICServer, QUICClient, SyncCoordinator, GraphTransformerService, MutationGuard
184
-
185
- ### 🔬 Performance Highlights
186
-
187
- **Why this matters:** Unlike synthetic benchmarks that test artificial workloads, these are **real-world performance metrics** from production-representative scenarios. Every number below was validated through multiple iterations and represents actual performance your agents will experience — not theoretical maximums.
188
-
189
- **Core Operations:**
190
- - Pattern search: **32.6M ops/sec** (ultra-fast with caching)
191
- - Pattern storage: **388K ops/sec** (excellent)
192
- - Batch operations: **3-4x faster** (5,556-7,692 ops/sec)
193
- - Super-linear scaling: **4,536 patterns/sec** @ 5k items
194
-
195
- **Latent Space Validation** (25 scenarios, 98.2% reproducibility):
196
-
197
- *These simulations empirically validate every optimization in AgentDB v2.0. Instead of guessing optimal configurations, we systematically explored the latent space of possible designs, running 24 iterations per scenario to discover what actually works best. The results aren't just faster — they're **provably optimal** for real-world agent workloads.*
198
- - **HNSW**: 61μs p50 latency, 96.8% recall@10, 8.2x faster than hnswlib
199
- - **GNN Attention**: +12.4% recall, 3.8ms forward pass, 91% transferability
200
- - **Self-Healing**: 97.9% degradation prevention, <100ms automatic repair
201
- - **Neural Augmentation**: +29.4% total improvement, -32% memory, -52% hops
202
-
203
- See [OPTIMIZATION-REPORT.md](OPTIMIZATION-REPORT.md) for detailed benchmarks and [simulation/README.md](simulation/README.md) for all 25 simulation scenarios.
204
-
205
- ---
206
-
207
- ## 📖 Tutorial
208
-
209
- **Learn by doing:** These examples show real-world use cases where AgentDB's cognitive memory patterns make agents genuinely intelligent. Each example is production-ready code you can adapt for your own applications.
210
-
211
- ### Example 1: Build a Learning Code Review Agent
212
-
213
- ```typescript
214
- import { createDatabase, ReasoningBank, ReflexionMemory, EmbeddingService } from 'agentdb';
215
-
216
- // Setup
217
- const db = await createDatabase('./code-reviewer.db');
218
- const embedder = new EmbeddingService({ model: 'Xenova/all-MiniLM-L6-v2' });
219
- await embedder.initialize();
220
-
221
- const reasoningBank = new ReasoningBank(db, embedder);
222
- const reflexion = new ReflexionMemory(db, embedder);
223
-
224
- // 1. Store successful review patterns
225
- await reasoningBank.storePattern({
226
- taskType: 'code_review',
227
- approach: 'Security scan → Type safety → Code quality → Performance',
228
- successRate: 0.94,
229
- tags: ['security', 'typescript']
230
- });
231
-
232
- // 2. Review code and learn from it
233
- const reviewResult = await performCodeReview(codeToReview);
53
+ const guard = db.getMutationGuard();
54
+ console.log(guard?.getStats());
55
+ // Output: { engineType: 'native', proofsGenerated: 42, denials: 0 }
234
56
 
57
+ // Store episode with automatic proof generation
235
58
  await reflexion.storeEpisode({
236
- sessionId: 'review-session-1',
237
- task: 'Review authentication PR',
238
- reward: reviewResult.issuesFound > 0 ? 0.9 : 0.6,
239
- success: true,
240
- critique: 'Found SQL injection vulnerability - security checks work!',
241
- input: codeToReview,
242
- output: reviewResult.findings,
243
- latencyMs: reviewResult.timeMs,
244
- tokensUsed: reviewResult.tokensUsed
245
- });
246
-
247
- // 3. Next time, find similar successful reviews (32.6M ops/sec!)
248
- const similarReviews = await reflexion.retrieveRelevant({
249
- task: 'authentication code review',
250
- k: 5,
251
- onlySuccesses: true
252
- });
253
-
254
- console.log(`Found ${similarReviews.length} successful reviews to learn from`);
255
- console.log(`Best approach: ${similarReviews[0].critique}`);
256
- ```
257
-
258
- ### Example 2: RAG System with Self-Learning
259
-
260
- ```typescript
261
- import { createDatabase, ReasoningBank, SkillLibrary, EmbeddingService } from 'agentdb';
262
-
263
- const db = await createDatabase('./rag-system.db');
264
- const embedder = new EmbeddingService({ model: 'Xenova/all-MiniLM-L6-v2' });
265
- await embedder.initialize();
266
-
267
- const reasoningBank = new ReasoningBank(db, embedder);
268
- const skills = new SkillLibrary(db, embedder);
269
-
270
- // Store document retrieval patterns
271
- await reasoningBank.storePattern({
272
- taskType: 'document_retrieval',
273
- approach: 'Expand query with synonyms → Semantic search → Re-rank by relevance',
274
- successRate: 0.88,
275
- tags: ['rag', 'retrieval']
276
- });
277
-
278
- // Create reusable query expansion skill
279
- await skills.createSkill({
280
- name: 'expand_query',
281
- description: 'Expand user query with domain-specific synonyms',
282
- signature: { inputs: { query: 'string' }, outputs: { expanded: 'string[]' } },
283
- code: `
284
- const synonymMap = { 'bug': ['issue', 'defect', 'error'], ... };
285
- return query.split(' ').flatMap(word => synonymMap[word] || [word]);
286
- `,
287
- successRate: 0.92
288
- });
289
-
290
- // Search for retrieval patterns (learns which work best)
291
- const patterns = await reasoningBank.searchPatterns({
292
- task: 'find technical documentation',
293
- k: 10
294
- });
295
-
296
- // Apply best pattern
297
- const bestPattern = patterns[0];
298
- console.log(`Using approach: ${bestPattern.approach}`);
299
- ```
300
-
301
- ### Example 3: Run Latent Space Simulations
302
-
303
- Validate AgentDB's optimizations through empirical simulations:
304
-
305
- ```bash
306
- # Test HNSW graph optimization (validates 8.2x speedup)
307
- agentdb simulate hnsw --iterations 3
308
- # Output: ✅ 61μs p50 latency, 96.8% recall@10, M=32 optimal
309
-
310
- # Test 8-head GNN attention mechanism
311
- agentdb simulate attention --iterations 3
312
- # Output: ✅ +12.4% recall improvement, 3.8ms forward pass
313
-
314
- # Test 30-day self-healing with MPC adaptation
315
- agentdb simulate self-organizing --days 30
316
- # Output: ✅ 97.9% degradation prevention, <100ms healing
317
-
318
- # Interactive wizard for custom simulations
319
- agentdb simulate --wizard
320
- # Guides you through 6-step configuration with 25+ components
321
- ```
322
-
323
- See [simulation/README.md](simulation/README.md) for 25 available scenarios and complete documentation.
324
-
325
- ### Example 4: MCP Integration (Claude Code)
326
-
327
- Zero-code integration with AI coding assistants:
328
-
329
- ```bash
330
- # One-command setup
331
- claude mcp add agentdb npx agentdb@latest mcp start
332
-
333
- # Now Claude Code can:
334
- # - Store reasoning patterns automatically
335
- # - Search 32.6M patterns/sec for relevant approaches
336
- # - Learn from successful task completions
337
- # - Build reusable skills over time
338
- # - Run latent space simulations
339
- ```
340
-
341
- **Manual setup** (add to `~/.config/claude/claude_desktop_config.json`):
342
- ```json
343
- {
344
- "mcpServers": {
345
- "agentdb": {
346
- "command": "npx",
347
- "args": ["agentdb@latest", "mcp", "start"],
348
- "env": { "AGENTDB_PATH": "./agentdb.db" }
349
- }
350
- }
351
- }
352
- ```
353
-
354
- ### Advanced Usage
355
-
356
- ```typescript
357
- import {
358
- createDatabase,
359
- ReasoningBank,
360
- ReflexionMemory,
361
- SkillLibrary,
362
- EmbeddingService,
363
- BatchOperations
364
- } from 'agentdb';
365
-
366
- // Initialize database
367
- const db = await createDatabase('./agent-memory.db');
368
-
369
- // Initialize embedding service
370
- const embedder = new EmbeddingService({
371
- model: 'Xenova/all-MiniLM-L6-v2',
372
- dimension: 384,
373
- provider: 'transformers'
374
- });
375
- await embedder.initialize();
376
-
377
- // ReasoningBank - Pattern learning and adaptive memory
378
- const reasoningBank = new ReasoningBank(db, embedder);
379
-
380
- // Store reasoning pattern (388K ops/sec)
381
- const patternId = await reasoningBank.storePattern({
382
- taskType: 'code_review',
383
- approach: 'Security-first analysis followed by code quality checks',
384
- successRate: 0.95,
385
- tags: ['security', 'code-quality'],
386
- metadata: { language: 'typescript' }
387
- });
388
-
389
- // Search patterns (32.6M ops/sec - ultra-fast)
390
- const patterns = await reasoningBank.searchPatterns({
391
- task: 'security code review',
392
- k: 10,
393
- threshold: 0.7,
394
- filters: { taskType: 'code_review' }
395
- });
396
-
397
- // Reflexion Memory - Learn from experience
398
- const reflexion = new ReflexionMemory(db, embedder);
399
-
400
- // Store episode with self-critique
401
- const episodeId = await reflexion.storeEpisode({
402
59
  sessionId: 'session-1',
403
- task: 'Implement OAuth2 authentication',
60
+ task: 'Debug authentication bug',
404
61
  reward: 0.95,
405
62
  success: true,
406
- critique: 'PKCE flow provided better security than basic flow',
407
- input: 'Authentication requirements',
408
- output: 'Working OAuth2 implementation',
409
- latencyMs: 1200,
410
- tokensUsed: 500
63
+ critique: 'OAuth2 PKCE flow was more secure than basic flow',
64
+ input: 'Users cannot log in',
65
+ output: 'Working OAuth2 implementation'
411
66
  });
412
67
 
413
- // Retrieve similar episodes (957 ops/sec)
414
- const episodes = await reflexion.retrieveRelevant({
415
- task: 'authentication implementation',
416
- k: 5,
417
- onlySuccesses: true
418
- });
419
-
420
- // Skill Library - Lifelong learning
421
- const skills = new SkillLibrary(db, embedder);
422
-
423
- // Create reusable skill
424
- const skillId = await skills.createSkill({
425
- name: 'jwt_authentication',
426
- description: 'Generate and validate JWT tokens',
427
- signature: { inputs: { userId: 'string' }, outputs: { token: 'string' } },
428
- code: 'implementation code here...',
429
- successRate: 0.92,
430
- uses: 0,
431
- avgReward: 0.0,
432
- avgLatencyMs: 0.0
433
- });
434
-
435
- // Search for applicable skills (694 ops/sec)
436
- const applicableSkills = await skills.searchSkills({
437
- task: 'user authentication',
68
+ // Search patterns (proof-validated)
69
+ const patterns = await reasoning.searchPatterns({
70
+ task: 'authentication security',
438
71
  k: 10,
439
- minSuccessRate: 0.7
440
- });
441
-
442
- // Batch Operations - 3-4x faster (NEW v2.0)
443
- const batchOps = new BatchOperations(db, embedder, {
444
- batchSize: 100,
445
- parallelism: 4
446
- });
447
-
448
- // Batch create skills (1,539 → 5,556 ops/sec - 3.6x faster)
449
- const skillIds = await batchOps.insertSkills([
450
- { name: 'skill-1', description: 'First skill', successRate: 0.8 },
451
- { name: 'skill-2', description: 'Second skill', successRate: 0.9 },
452
- // ... up to 100 skills
453
- ]);
454
-
455
- // Batch store episodes (2,273 → 7,692 ops/sec - 3.4x faster)
456
- const episodeIds = await batchOps.insertEpisodes([
457
- { sessionId: 'session-1', task: 'debug-1', reward: 0.85, success: true },
458
- { sessionId: 'session-2', task: 'optimize-1', reward: 0.90, success: true },
459
- // ... up to 100 episodes
460
- ]);
461
-
462
- // Prune old data (NEW v2.0)
463
- const pruneResults = await batchOps.pruneData({
464
- maxAge: 90, // Keep data from last 90 days
465
- minReward: 0.3, // Keep episodes with reward >= 0.3
466
- minSuccessRate: 0.5, // Keep skills/patterns with >= 50% success
467
- maxRecords: 100000, // Max 100k records per table
468
- dryRun: false // Actually delete (use true to preview)
72
+ threshold: 0.7
469
73
  });
470
-
471
- console.log(`Pruned ${pruneResults.episodesPruned} episodes`);
472
- console.log(`Saved ${pruneResults.spaceSaved} bytes`);
473
74
  ```
474
75
 
475
- ---
76
+ ## Architecture
476
77
 
477
- ## 🧠 Frontier Memory Features
478
-
479
- ### 1. 🔄 ReasoningBank — Pattern Learning & Adaptive Memory
480
-
481
- **The cognitive layer that makes agents smarter over time**
482
-
483
- Store successful reasoning patterns and retrieve them using semantic similarity. ReasoningBank learns which approaches work best for different types of tasks.
484
-
485
- ```typescript
486
- // Store a pattern
487
- await reasoningBank.storePattern({
488
- taskType: 'bug_investigation',
489
- approach: 'Check logs → Reproduce issue → Binary search for root cause',
490
- successRate: 0.92,
491
- tags: ['debugging', 'systematic'],
492
- metadata: { avgTimeMs: 3000 }
493
- });
494
-
495
- // Search patterns (32.6M ops/sec - ultra-fast)
496
- const patterns = await reasoningBank.searchPatterns({
497
- task: 'debug memory leak',
498
- k: 10,
499
- threshold: 0.7,
500
- filters: { taskType: 'bug_investigation' }
501
- });
78
+ AgentDB v3 introduces a 3-layer architecture:
502
79
 
503
- // Get pattern statistics
504
- const stats = reasoningBank.getPatternStats();
505
- console.log(`Total patterns: ${stats.totalPatterns}`);
506
- console.log(`Avg success rate: ${stats.avgSuccessRate}`);
507
80
  ```
508
-
509
- **Performance:**
510
- - Pattern storage: 388K ops/sec
511
- - Pattern search: 32.6M ops/sec (ultra-fast with caching)
512
- - Super-linear scaling: 4,536 patterns/sec @ 5k items
513
-
514
- **Use Cases:**
515
- - Learn debugging strategies that work
516
- - Discover code patterns that prevent bugs
517
- - Build institutional knowledge automatically
518
-
519
- ### 2. 🔄 Reflexion Memory — Learn from Experience
520
-
521
- **Episodic replay with self-critique for continuous improvement**
522
-
523
- Store complete task episodes with self-generated critiques, then replay them to improve future performance. Based on the Reflexion paper (Shinn et al., 2023).
524
-
525
- ```typescript
526
- // Store episode with self-critique
527
- const episodeId = await reflexion.storeEpisode({
528
- sessionId: 'debug-session-1',
529
- task: 'Fix authentication bug',
530
- reward: 0.95,
531
- success: true,
532
- critique: 'OAuth2 PKCE flow was more secure than basic flow. Should always check token expiration.',
533
- input: 'Users can\'t log in',
534
- output: 'Working OAuth2 implementation with refresh tokens',
535
- latencyMs: 1200,
536
- tokensUsed: 500
537
- });
538
-
539
- // Retrieve similar episodes (957 ops/sec)
540
- const similar = await reflexion.retrieveRelevant({
541
- task: 'authentication issues',
542
- k: 10,
543
- onlySuccesses: true, // Learn from what worked
544
- minReward: 0.7
545
- });
546
-
547
- // Get task-specific statistics
548
- const stats = await reflexion.getTaskStats('debug-session-1');
549
- console.log(`Success rate: ${stats.successRate}`);
550
- console.log(`Avg reward: ${stats.avgReward}`);
81
+ ┌─────────────────────────────────────────────────────┐
82
+ │ Application Layer │
83
+ │ (ReasoningBank, ReflexionMemory, SkillLibrary) │
84
+ └─────────────────────────────────────────────────────┘
85
+
86
+ ┌─────────────────────────────────────────────────────┐
87
+ │ Proof Validation Layer │
88
+ │ MutationGuard AttestationLog GuardedBackend │
89
+ └─────────────────────────────────────────────────────┘
90
+
91
+ ┌─────────────────────────────────────────────────────┐
92
+ │ Backend Layer │
93
+ │ RuVector (native) → WASM → JavaScript │
94
+ └─────────────────────────────────────────────────────┘
551
95
  ```
552
96
 
553
- **Benefits:**
554
- - Learn from successes and failures
555
- - Build expertise over time
556
- - Avoid repeating mistakes
557
- - Self-improvement through critique
97
+ Every mutation flows through the proof validation layer:
558
98
 
559
- **CLI:**
560
- ```bash
561
- # Store episode
562
- agentdb reflexion store "session-1" "fix_auth_bug" 0.95 true \
563
- "OAuth2 PKCE worked perfectly" "login failing" "fixed tokens" 1200 500
99
+ 1. **Application** calls `storeEpisode()` or `searchPatterns()`
100
+ 2. **MutationGuard** generates a proof (structural hash + attestation token)
101
+ 3. **AttestationLog** records the proof attempt
102
+ 4. **GuardedBackend** validates proof before executing native operation
103
+ 5. **Result** returns to application with proof certificate
564
104
 
565
- # Retrieve similar
566
- agentdb reflexion retrieve "authentication issues" 10 0.8
567
-
568
- # Get critique summary
569
- agentdb reflexion critique "fix_auth_bug" 10 0.5
570
- ```
571
-
572
- ### 3. 🎓 Skill Library — Lifelong Learning
105
+ ## Key Features
573
106
 
574
- **Transform successful patterns into reusable, composable skills**
107
+ ### 1. Proof-Gated Mutations (ADR-060)
575
108
 
576
- Automatically consolidate repeated successful task executions into parameterized skills that can be composed and reused.
109
+ Every state mutation requires a cryptographic proof:
577
110
 
578
111
  ```typescript
579
- // Create skill manually
580
- const skillId = await skills.createSkill({
581
- name: 'jwt_authentication',
582
- description: 'Generate and validate JWT tokens with refresh flow',
583
- signature: {
584
- inputs: { userId: 'string', permissions: 'array' },
585
- outputs: { accessToken: 'string', refreshToken: 'string' }
586
- },
587
- code: 'implementation code...',
588
- successRate: 0.92
589
- });
112
+ import { MutationGuard } from 'agentdb/security';
590
113
 
591
- // Search for applicable skills (694 ops/sec)
592
- const applicable = await skills.searchSkills({
593
- task: 'user authentication with tokens',
594
- k: 5,
595
- minSuccessRate: 0.7
114
+ const guard = new MutationGuard({
115
+ strictMode: true,
116
+ enableNative: true // Prefer native proofs
596
117
  });
597
118
 
598
- // Auto-consolidate from successful episodes
599
- const consolidated = await skills.consolidateFromEpisodes({
600
- minAttempts: 3, // Need 3+ successful executions
601
- minSuccessRate: 0.7, // With 70%+ success rate
602
- lookbackDays: 7 // In the last 7 days
119
+ // Insert requires proof
120
+ const proof = guard.generateProof({
121
+ operation: 'insert',
122
+ vectorId: 'vec-123',
123
+ embedding: [0.1, 0.2, ...],
124
+ metadata: { source: 'reflexion' }
603
125
  });
604
126
 
605
- // Update skill after use
606
- await skills.updateSkillStats(skillId, {
607
- uses: 1,
608
- successRate: 0.95,
609
- success: true,
610
- latencyMs: 1200
611
- });
612
- ```
613
-
614
- **Features:**
615
- - Automatic skill extraction from episodes
616
- - Semantic search for skill discovery
617
- - Usage tracking and success rate monitoring
618
- - Skill composition and chaining
127
+ // Proof includes:
128
+ // - structuralHash: SHA-256 of operation + data
129
+ // - attestationToken: 82-byte cryptographic token
130
+ // - timestamp: ISO8601 timestamp
131
+ // - nonce: Random 16-byte nonce
619
132
 
620
- **CLI:**
621
- ```bash
622
- # Create skill
623
- agentdb skill create "jwt_auth" "Generate JWT tokens" \
624
- '{"inputs": {"user": "object"}}' "code..." 1
625
-
626
- # Search skills
627
- agentdb skill search "authentication" 5 0.5
628
-
629
- # Auto-consolidate from episodes
630
- agentdb skill consolidate 3 0.7 7
631
-
632
- # Update skill stats
633
- agentdb skill update 1 1 0.95 true 1200
133
+ // Backend validates before execution
134
+ if (guard.validateProof(proof)) {
135
+ backend.insert(proof.vectorId, proof.embedding, proof.metadata);
136
+ }
634
137
  ```
635
138
 
636
- ### 4. 🔗 Causal Memory Graph — Intervention-Based Causality
139
+ ### 2. Eight Graph-Transformer Modules
637
140
 
638
- **Learn what interventions cause what outcomes, not just correlations**
141
+ Native Rust implementations via `@ruvector/graph-transformer`:
639
142
 
640
- Track `p(y|do(x))` using doubly robust estimation and instrumental variables. Understand which actions lead to which results.
143
+ - **Sublinear Attention** O(n log n) replacing O(n²) JavaScript fallback
144
+ - **Verified Training** — SGD with cryptographic proof of each gradient step
145
+ - **Causal Attention** — Temporal-decay weighted attention for CausalRecall
146
+ - **Granger Extract** — Time-series causal discovery for memory graphs
147
+ - **Hamiltonian Step** — Physics-informed trajectory modeling
148
+ - **Spiking Attention** — Biological integrate-and-fire for episodic memory
149
+ - **Game-Theoretic Attention** — Nash equilibrium for multi-agent routing
150
+ - **Product Manifold Distance** — Curved-space similarity for reasoning patterns
641
151
 
642
152
  ```typescript
643
- import { CausalMemoryGraph } from 'agentdb/controllers/CausalMemoryGraph';
644
-
645
- const causalGraph = new CausalMemoryGraph(db);
646
-
647
- // Create causal experiment (A/B test)
648
- const experimentId = causalGraph.createExperiment({
649
- name: 'test_error_handling_approach',
650
- hypothesis: 'Try-catch reduces crash rate',
651
- treatmentId: 123, // Episode ID with error handling
652
- treatmentType: 'episode',
653
- controlId: 124, // Episode ID without
654
- startTime: Date.now(),
655
- sampleSize: 0,
656
- status: 'running'
657
- });
658
-
659
- // Record observations
660
- causalGraph.recordObservation({
661
- experimentId,
662
- episodeId: 123,
663
- isTreatment: true,
664
- outcomeValue: 0.95, // Success rate
665
- outcomeType: 'success'
666
- });
667
-
668
- // Calculate causal uplift
669
- const { uplift, pValue, confidenceInterval } =
670
- causalGraph.calculateUplift(experimentId);
671
-
672
- console.log(`Causal uplift: ${uplift}`);
673
- console.log(`p-value: ${pValue}`);
674
- console.log(`95% CI: [${confidenceInterval[0]}, ${confidenceInterval[1]}]`);
675
-
676
- // Add causal edge
677
- const edgeId = causalGraph.addCausalEdge({
678
- fromMemoryId: 123,
679
- fromMemoryType: 'episode',
680
- toMemoryId: 125,
681
- toMemoryType: 'episode',
682
- similarity: 0.85,
683
- uplift: 0.15, // 15% improvement
684
- confidence: 0.95,
685
- sampleSize: 50
686
- });
153
+ import { GraphTransformerService } from 'agentdb';
687
154
 
688
- // Query causal effects
689
- const effects = causalGraph.queryCausalEffects({
690
- interventionMemoryId: 123,
691
- interventionMemoryType: 'episode',
692
- minConfidence: 0.8,
693
- minUplift: 0.1
155
+ const transformer = new GraphTransformerService({
156
+ enableNative: true,
157
+ modules: ['sublinear', 'causal', 'verified']
694
158
  });
695
- ```
696
-
697
- **Use Cases:**
698
- - Discover which debugging strategies fix bugs
699
- - Learn what code patterns improve performance
700
- - Understand what approaches lead to success
701
- - A/B test different agent strategies
702
-
703
- ### 5. 📜 Explainable Recall — Provenance Certificates
704
159
 
705
- **Every retrieval comes with a cryptographic proof explaining why**
160
+ await transformer.initialize();
706
161
 
707
- Understand exactly why memories were selected with Merkle proof certificates that verify completeness and relevance.
708
-
709
- ```typescript
710
- import { CausalRecall } from 'agentdb/controllers/CausalRecall';
711
-
712
- const causalRecall = new CausalRecall(db, embedder, vectorBackend, {
713
- alpha: 0.7, // Similarity weight
714
- beta: 0.2, // Causal uplift weight
715
- gamma: 0.1 // Latency penalty
716
- });
717
-
718
- // Retrieve with certificate
719
- const result = await causalRecall.recall(
720
- 'query-123',
721
- 'How to optimize API response time',
722
- 12, // k results
723
- ['performance', 'optimization'], // requirements
724
- 'internal' // access level
162
+ // Use sublinear attention (O(n log n))
163
+ const attended = await transformer.sublinearAttention(
164
+ queryVector,
165
+ keyMatrix,
166
+ valueMatrix
725
167
  );
726
168
 
727
- console.log(`Retrieved ${result.candidates.length} results`);
728
- console.log(`Certificate ID: ${result.certificate.id}`);
729
- console.log(`Completeness: ${result.certificate.completenessScore}`);
730
- console.log(`Redundancy: ${result.certificate.redundancyRatio}`);
731
-
732
- // Certificate includes:
733
- // - Query ID and text
734
- // - Retrieved chunk IDs with relevance scores
735
- // - Completeness score (% requirements met)
736
- // - Redundancy ratio (duplicate coverage)
737
- // - Merkle root hash (cryptographic proof)
738
- // - Access level and timestamp
169
+ // Verify training step
170
+ const trainingProof = await transformer.verifiedTraining(
171
+ weights,
172
+ gradients,
173
+ learningRate
174
+ );
739
175
  ```
740
176
 
741
- **Benefits:**
742
- - Understand why specific memories were selected
743
- - Verify retrieval completeness
744
- - Debug agent decision-making
745
- - Build trust through transparency
746
- - Audit trail for compliance
177
+ ### 3. Twenty-One Active Controllers
747
178
 
748
- ### 6. 🎯 Causal Recall — Utility-Based Reranking
179
+ All cognitive memory patterns are production-ready:
749
180
 
750
- **Retrieve what actually works, not just what's similar**
181
+ - **ReflexionMemory** Self-critique and episodic replay
182
+ - **SkillLibrary** — Lifelong learning with skill consolidation
183
+ - **ReasoningBank** — Pattern learning and adaptive memory
184
+ - **CausalMemoryGraph** — Intervention-based causality tracking
185
+ - **CausalRecall** — Utility-based retrieval with uplift scoring
186
+ - **ExplainableRecall** — Provenance certificates with Merkle proofs
187
+ - **NightlyLearner** — Automated pattern discovery
188
+ - **LearningSystem** — 9 RL algorithms (Q-Learning, DQN, PPO, MCTS, etc.)
189
+ - **EmbeddingService** — Multi-provider embeddings (Transformers.js, OpenAI)
190
+ - **WASMVectorSearch** — Browser-compatible vector search
191
+ - **HNSWIndex** — HNSW graph indexing for approximate nearest neighbor
192
+ - **AttentionService** — 5 attention mechanisms (causal, spiking, game-theoretic)
193
+ - **And 9 more** — See [docs/CONTROLLERS.md](./docs/CONTROLLERS.md)
751
194
 
752
- Standard vector search returns similar memories. Causal Recall reranks by actual utility:
195
+ ## Installation
753
196
 
754
- **Formula:** `U = α·similarity + β·uplift − γ·latency`
197
+ ```bash
198
+ # v3 Alpha (proof-gated mutations)
199
+ npm install agentdb@v3
755
200
 
756
- - **α·similarity**: Semantic relevance (how related is this memory?)
757
- - **β·uplift**: Causal impact (did this approach actually help?)
758
- - **γ·latency**: Performance cost (how long did this take?)
201
+ # Stable v2 (production-ready)
202
+ npm install agentdb@latest
759
203
 
760
- ```typescript
761
- // Utility-based retrieval (built into causalRecall.recall)
762
- const result = await causalRecall.recall(
763
- 'query-456',
764
- 'Optimize database query performance',
765
- 10,
766
- undefined,
767
- 'internal'
768
- );
204
+ # With optional native addons for 150x performance
205
+ npm install agentdb@v3 ruvector@latest
769
206
 
770
- // Results ranked by utility, not just similarity
771
- result.candidates.forEach((candidate, i) => {
772
- console.log(`${i + 1}. Utility: ${candidate.utilityScore.toFixed(3)}`);
773
- console.log(` Similarity: ${candidate.similarity.toFixed(3)}`);
774
- console.log(` Uplift: ${candidate.uplift?.toFixed(3) || 'N/A'}`);
775
- console.log(` Latency: ${candidate.latencyMs}ms`);
776
- });
207
+ # For browser environments (WASM only)
208
+ npm install agentdb@v3
209
+ # Native addons will be skipped automatically
777
210
  ```
778
211
 
779
- **Why It Matters:**
780
- - Retrieves what works, not just what's similar
781
- - Balances relevance with effectiveness
782
- - Accounts for performance costs
783
- - Learns from causal relationships
784
-
785
- ### 7. 🌙 Nightly Learner — Automated Pattern Discovery
786
-
787
- **Background process that discovers patterns while you sleep**
212
+ ## API Overview
788
213
 
789
- Runs automated causal discovery on episode history, finding patterns you didn't explicitly program.
214
+ ### Core Class
790
215
 
791
216
  ```typescript
792
- import { NightlyLearner } from 'agentdb/controllers/NightlyLearner';
793
-
794
- const learner = new NightlyLearner(db, embedder);
795
-
796
- // Discover patterns (dry-run first to preview)
797
- const discovered = await learner.discover({
798
- minAttempts: 3, // Need 3+ attempts to detect pattern
799
- minSuccessRate: 0.6, // With 60%+ success rate
800
- minConfidence: 0.7, // 70% statistical confidence
801
- dryRun: true // Preview without saving
802
- });
803
-
804
- console.log(`Would create ${discovered.length} causal edges`);
805
-
806
- // Run for real (creates edges + consolidates skills)
807
- const created = await learner.discover({
808
- minAttempts: 3,
809
- minSuccessRate: 0.6,
810
- minConfidence: 0.7,
811
- dryRun: false // Actually create
812
- });
813
-
814
- console.log(`Created ${created.length} causal edges`);
217
+ import { AgentDB } from 'agentdb';
815
218
 
816
- // Prune low-quality edges
817
- const pruned = await learner.pruneEdges({
818
- minConfidence: 0.5,
819
- minUplift: 0.05,
820
- maxAgeDays: 90
219
+ const db = new AgentDB({
220
+ dbPath: './memory.db',
221
+ dimension: 384,
222
+ vectorBackend: 'ruvector', // or 'hnswlib' | 'sqlite'
223
+ enableProofGate: true,
224
+ strictMode: true
821
225
  });
822
226
 
823
- console.log(`Pruned ${pruned} low-quality edges`);
824
- ```
825
-
826
- **Features:**
827
- - Asynchronous execution (runs in background)
828
- - Discovers causal edges automatically
829
- - Auto-consolidates successful patterns into skills
830
- - Prunes low-quality patterns
831
- - Doubly robust estimation for causal inference
832
-
833
- **CLI:**
834
- ```bash
835
- # Discover patterns (dry-run)
836
- agentdb learner run 3 0.6 0.7 true
837
-
838
- # Create patterns for real
839
- agentdb learner run 3 0.6 0.7 false
840
-
841
- # Prune low-quality edges
842
- agentdb learner prune 0.5 0.05 90
227
+ await db.initialize();
843
228
  ```
844
229
 
845
- ---
846
-
847
- ## ⚡ Performance Optimizations (v2.0)
848
-
849
- ### Batch Operations — 3-4x Faster
850
-
851
- **Process multiple items efficiently with parallel embeddings and SQL transactions**
230
+ ### Controller Access
852
231
 
853
232
  ```typescript
854
- import { BatchOperations } from 'agentdb/optimizations/BatchOperations';
855
-
856
- const batchOps = new BatchOperations(db, embedder, {
857
- batchSize: 100, // Process 100 items per batch
858
- parallelism: 4, // 4 concurrent embedding generations
859
- progressCallback: (completed, total) => {
860
- console.log(`Progress: ${completed}/${total}`);
861
- }
862
- });
233
+ // Get controllers by name
234
+ const reflexion = db.getController('reflexion');
235
+ const reasoning = db.getController('reasoning');
236
+ const skills = db.getController('skills');
237
+ const causalGraph = db.getController('causalGraph');
863
238
 
864
- // Batch create skills (304 → 900 ops/sec = 3x faster)
865
- const skillIds = await batchOps.insertSkills([
866
- { name: 'skill-1', description: 'First skill', successRate: 0.8 },
867
- { name: 'skill-2', description: 'Second skill', successRate: 0.9 },
868
- // ... 50 more skills
869
- ]);
870
-
871
- // Batch store patterns (4x faster than sequential)
872
- const patternIds = await batchOps.insertPatterns([
873
- { taskType: 'debugging', approach: 'Binary search', successRate: 0.85 },
874
- { taskType: 'optimization', approach: 'Profile first', successRate: 0.90 },
875
- // ... 500 patterns
876
- ]);
877
-
878
- // Batch store episodes (152 → 500 ops/sec = 3.3x faster)
879
- const episodeCount = await batchOps.insertEpisodes([
880
- { sessionId: 's1', task: 'Task 1', reward: 0.9, success: true },
881
- { sessionId: 's1', task: 'Task 2', reward: 0.85, success: true },
882
- // ... 200 episodes
883
- ]);
239
+ // Access proof engine
240
+ const guard = db.getMutationGuard();
241
+ const stats = guard?.getStats();
884
242
  ```
885
243
 
886
- **Performance:**
887
- - Skills: 304 → 900 ops/sec (3x faster)
888
- - Patterns: 4x faster than sequential
889
- - Episodes: 152 → 500 ops/sec (3.3x faster)
890
- - Parallel embedding generation
891
- - SQL transaction optimization
892
-
893
- ### Intelligent Caching — 8.8x Faster Stats
894
-
895
- **TTL-based caching with LRU eviction for frequently accessed data**
244
+ ### Security Primitives
896
245
 
897
246
  ```typescript
898
- import { ToolCache, MCPToolCaches } from 'agentdb/optimizations/ToolCache';
899
-
900
- // Specialized caches for different tool types
901
- const mcpCaches = new MCPToolCaches();
902
- // - stats: 60s TTL (agentdb_stats, db_stats)
903
- // - patterns: 30s TTL (pattern/skill searches)
904
- // - searches: 15s TTL (episode retrieval)
905
- // - metrics: 120s TTL (expensive computations)
906
-
907
- // Custom cache
908
- const customCache = new ToolCache<any>(1000, 60000);
909
-
910
- // Set cache entry
911
- customCache.set('stats:detailed', statsResult, 60000);
912
-
913
- // Get cached value (returns null if expired)
914
- const cached = customCache.get('stats:detailed');
247
+ import { MutationGuard, AttestationLog } from 'agentdb/security';
915
248
 
916
- // Pattern-based clearing
917
- customCache.clear('stats:*'); // Clear all stats caches
918
-
919
- // Get cache statistics
920
- const stats = customCache.getStats();
921
- console.log(`Hit rate: ${(stats.hitRate * 100).toFixed(1)}%`);
922
- console.log(`Size: ${stats.size}/${stats.maxSize}`);
923
- ```
924
-
925
- **Performance Impact:**
926
- - agentdb_stats: 176ms → ~20ms (8.8x faster)
927
- - pattern_stats: Similar improvement
928
- - learning_metrics: 120s TTL for expensive computations
929
- - Hit rates: 80%+ for frequently accessed data
930
-
931
- ### Data Pruning — Maintain Database Hygiene
932
-
933
- **Intelligent cleanup preserving causal relationships**
934
-
935
- ```typescript
936
- // Prune old/low-quality data
937
- const results = await batchOps.pruneData({
938
- maxAge: 90, // Keep data from last 90 days
939
- minReward: 0.3, // Keep episodes with reward >= 0.3
940
- minSuccessRate: 0.5, // Keep skills/patterns with >= 50% success
941
- maxRecords: 100000, // Max 100k records per table
942
- dryRun: false // Actually delete (use true to preview)
249
+ // Create guard
250
+ const guard = new MutationGuard({
251
+ strictMode: true,
252
+ enableNative: true,
253
+ logPath: './attestations.log'
943
254
  });
944
255
 
945
- console.log(`Pruned ${results.episodesPruned} episodes`);
946
- console.log(`Pruned ${results.skillsPruned} skills`);
947
- console.log(`Pruned ${results.patternsPruned} patterns`);
948
- console.log(`Saved ${results.spaceSaved} bytes`);
949
- ```
950
-
951
- **Features:**
952
- - Age-based pruning (default: 90 days)
953
- - Quality-based pruning (min reward/success rate)
954
- - Max records enforcement (keeps best performing)
955
- - Preserves causal relationships (won't delete referenced episodes)
956
- - Dry-run mode for preview
957
- - Space reclamation via VACUUM
958
-
959
- **CLI:**
960
- ```bash
961
- # Preview what would be deleted
962
- agentdb prune --max-age 90 --min-reward 0.3 --dry-run
256
+ // Generate proof
257
+ const proof = guard.generateProof({
258
+ operation: 'insert',
259
+ vectorId: 'vec-123',
260
+ embedding: embedding,
261
+ metadata: { source: 'test' }
262
+ });
963
263
 
964
- # Actually prune
965
- agentdb prune --max-age 90 --min-reward 0.3 --min-success-rate 0.5 --max-records 100000
264
+ // Access attestation log
265
+ const log = guard.getAttestationLog();
266
+ const recentProofs = await log.query({ limit: 10 });
966
267
  ```
967
268
 
968
- ### Enhanced Validation — Security & Developer Experience
969
-
970
- **6 new validators with XSS/injection detection**
269
+ ### Backend Integration
971
270
 
972
271
  ```typescript
973
- import {
974
- validateTaskString,
975
- validateNumericRange,
976
- validateArrayLength,
977
- validateObject,
978
- validateBoolean,
979
- validateEnum,
980
- ValidationError
981
- } from 'agentdb/security/input-validation';
982
-
983
- try {
984
- // String validation (length + XSS detection)
985
- const task = validateTaskString(userInput, 'task');
986
-
987
- // Numeric range validation
988
- const k = validateNumericRange(kValue, 'k', 1, 100);
989
-
990
- // Array length validation
991
- const items = validateArrayLength(array, 'items', 1, 100);
992
-
993
- // Enum validation
994
- const format = validateEnum(formatValue, 'format', ['concise', 'detailed', 'json']);
995
-
996
- } catch (error) {
997
- if (error instanceof ValidationError) {
998
- console.error(`Validation error: ${error.message}`);
999
- console.error(`Code: ${error.code}`);
1000
- console.error(`Field: ${error.field}`);
1001
- }
1002
- }
1003
- ```
1004
-
1005
- **Security Features:**
1006
- - XSS detection (`<script>`, `javascript:`, `onclick=`)
1007
- - Injection detection (null bytes, malicious patterns)
1008
- - Length limits (10k characters max)
1009
- - Type validation with TypeScript types
1010
- - Safe error messages (no sensitive data leakage)
1011
-
1012
- ---
1013
-
1014
- ## 🤖 MCP Tools (29 Total)
272
+ import { GuardedVectorBackend } from 'agentdb/backends';
1015
273
 
1016
- AgentDB provides 29 optimized MCP tools for zero-code integration with Claude Code, Cursor, and other AI coding assistants.
1017
-
1018
- ### Core Vector DB Tools (5)
1019
-
1020
- **Basic vector database operations:**
1021
-
1022
- | Tool | Description | Performance |
1023
- |------|-------------|-------------|
1024
- | `agentdb_init` | Initialize database with schema | One-time setup |
1025
- | `agentdb_insert` | Insert single vector | Standard |
1026
- | `agentdb_insert_batch` | Batch insert (recommended) | 141x faster |
1027
- | `agentdb_search` | Semantic k-NN search | Optimized |
1028
- | `agentdb_delete` | Delete vectors by ID/filters | Standard |
1029
-
1030
- ### Core AgentDB Tools (5 - NEW v2.0)
1031
-
1032
- **Advanced database management:**
1033
-
1034
- | Tool | Description | Performance |
1035
- |------|-------------|-------------|
1036
- | `agentdb_stats` | Comprehensive database statistics | 8.8x faster (cached) |
1037
- | `agentdb_pattern_store` | Store reasoning patterns | 388K ops/sec |
1038
- | `agentdb_pattern_search` | Search patterns semantically | 32.6M ops/sec |
1039
- | `agentdb_pattern_stats` | Pattern analytics | Cached |
1040
- | `agentdb_clear_cache` | Cache management | Instant |
1041
-
1042
- ### Frontier Memory Tools (9)
1043
-
1044
- **Cognitive capabilities:**
1045
-
1046
- | Tool | Description | Use Case |
1047
- |------|-------------|----------|
1048
- | `reflexion_store` | Store episode with self-critique | Learn from experience |
1049
- | `reflexion_retrieve` | Retrieve similar episodes | Episodic replay |
1050
- | `skill_create` | Create reusable skill | Lifelong learning |
1051
- | `skill_search` | Search for applicable skills | Skill discovery |
1052
- | `causal_add_edge` | Add causal relationship | Track causality |
1053
- | `causal_query` | Query causal effects | Understand interventions |
1054
- | `recall_with_certificate` | Utility-based retrieval | Explainable AI |
1055
- | `learner_discover` | Automated pattern discovery | Background learning |
1056
- | `db_stats` | Database statistics | Monitoring |
1057
-
1058
- ### Learning System Tools (10 - NEW v1.3.0)
1059
-
1060
- **Reinforcement learning pipeline:**
1061
-
1062
- | Tool | Description | Algorithms |
1063
- |------|-------------|-----------|
1064
- | `learning_start_session` | Start RL session | 9 algorithms |
1065
- | `learning_end_session` | End session & save policy | All |
1066
- | `learning_predict` | Get AI recommendations | All |
1067
- | `learning_feedback` | Submit action feedback | All |
1068
- | `learning_train` | Batch policy training | All |
1069
- | `learning_metrics` | Performance analytics | All |
1070
- | `learning_transfer` | Transfer learning | All |
1071
- | `learning_explain` | Explainable AI | All |
1072
- | `experience_record` | Record tool execution | All |
1073
- | `reward_signal` | Calculate rewards | All |
1074
-
1075
- **Supported RL Algorithms:**
1076
- Q-Learning, SARSA, DQN, Policy Gradient, Actor-Critic, PPO, Decision Transformer, MCTS, Model-Based
1077
-
1078
- ### MCP Tool Optimization Guide
1079
-
1080
- For comprehensive MCP tool optimization patterns, see:
1081
- - [MCP Tool Optimization Guide](docs/MCP_TOOL_OPTIMIZATION_GUIDE.md) - 28KB guide with examples
1082
- - [MCP Optimization Summary](MCP-OPTIMIZATION-SUMMARY.md) - Executive summary
1083
-
1084
- **Key Optimizations:**
1085
- - 🔄 Parallel execution markers for 3x speedup
1086
- - 📦 Batch operations (3-4x faster)
1087
- - 💾 Intelligent caching (8.8x faster stats)
1088
- - 📊 Format parameter (60% token reduction)
1089
- - ✅ Enhanced validation (security + DX)
1090
-
1091
- ---
1092
-
1093
- ## 📊 Benchmarks & Performance
1094
-
1095
- ### ReasoningBank Performance
274
+ // Wrap any backend with proof validation
275
+ const guardedBackend = new GuardedVectorBackend(rawBackend, guard);
1096
276
 
277
+ // All operations require proof
278
+ await guardedBackend.insert(proof);
279
+ await guardedBackend.search(query, k, proof);
1097
280
  ```
1098
- Pattern Storage Scalability
1099
- Small (500): 1,475 patterns/sec, 2MB memory
1100
- Medium (2,000): 3,818 patterns/sec, 0MB memory
1101
- Large (5,000): 4,536 patterns/sec, 4MB memory
1102
281
 
1103
- Super-linear scaling (throughput increases with data size)
282
+ ## Performance
1104
283
 
1105
- Pattern Similarity Detection
1106
- Threshold 0.5: 12.0 matches, 22.74ms avg search time
1107
- Threshold 0.7: 10.2 matches, 22.62ms avg search time
284
+ **Proof Generation:**
285
+ - Native (NAPI-RS): ~50μs per proof
286
+ - WASM: ~200μs per proof
287
+ - JavaScript: ~500μs per proof
1108
288
 
1109
- Optimal threshold: 0.5 (best balance)
289
+ **Vector Operations (with RuVector):**
290
+ - Insert: 150x faster than JavaScript
291
+ - Search: 61μs p50 latency (96.8% recall@10)
292
+ - Pattern search: 32.6M ops/sec with caching
1110
293
 
1111
- Query Optimization
1112
- Simple: 69.31ms
1113
- Filtered: 15.76ms (4.4x faster)
1114
- High threshold: 69.09ms
1115
- Large k=100: 93.03ms
1116
- ```
1117
-
1118
- ### Self-Learning Performance
1119
-
1120
- ```
1121
- Adaptive Learning (10 sessions, 50 episodes each)
1122
- Initial success rate: 54%
1123
- Final success rate: 90%
1124
- Improvement: 36%
1125
- Avg session duration: 170ms
1126
-
1127
- Skill Evolution (3 skills, 5 versions each)
1128
- Initial avg success: 0.60
1129
- Final avg success: 0.85
1130
- Improvement: 25%
1131
-
1132
- Causal Episode Linking
1133
- 5 episodes linked: 22ms
1134
- Chain depth: 5 steps
1135
- Causal relationship: Sequential debugging process
1136
- ```
1137
-
1138
- ### MCP Tools Performance
1139
-
1140
- ```
1141
- Ultra-Fast (>1M ops/sec)
1142
- pattern_search: 32.6M ops/sec
1143
-
1144
- Excellent (>100K ops/sec)
1145
- pattern_store: 388K ops/sec
1146
-
1147
- Very Good (>500 ops/sec)
1148
- episode_retrieve: 957 ops/sec
1149
- skill_search: 694 ops/sec
294
+ **Package Size:**
295
+ - v2: 50.1MB (with unused native binaries)
296
+ - v3: 1.4MB (zero-native regression fixed)
1150
297
 
1151
- Good (>100 ops/sec)
1152
- skill_create: 304 ops/sec → 900 ops/sec (with batch)
1153
-
1154
- Optimization Targets
1155
- episode_store: 152 ops/sec → 500 ops/sec (with batch)
1156
- ```
1157
-
1158
- ### Memory Efficiency
1159
-
1160
- ```
1161
- 5,000 patterns: 4MB memory (0.8KB per pattern)
1162
- Consistent low latency: 0.22-0.68ms per pattern
1163
- Super-linear scaling: performance improves with data size
1164
- ```
1165
-
1166
- See [OPTIMIZATION-REPORT.md](OPTIMIZATION-REPORT.md) for comprehensive benchmarks.
1167
-
1168
- ---
298
+ ## Documentation
1169
299
 
1170
- ## 🏗️ Architecture
300
+ - **[ADR-060: Proof-Gated Mutations](./docs/adr/ADR-060-agentdb-v3-proof-gated-graph-intelligence.md)** — Architecture decision record
301
+ - **[Controllers Guide](./docs/CONTROLLERS.md)** — All 21 controllers documented
302
+ - **[MCP Tools Reference](./docs/MCP_TOOLS.md)** — 32 MCP tools for Claude Code
303
+ - **[Migration Guide](./MIGRATION_v3.0.0.md)** — Upgrade from v2 to v3
304
+ - **[Security Model](./docs/SECURITY.md)** — Proof validation and attestation
1171
305
 
1172
- ### Multi-Backend System
306
+ ## MCP Integration (Claude Code)
1173
307
 
1174
- ```
1175
- ┌─────────────────────────────────────────────────────────┐
1176
- │ AgentDB v2.0 Core │
1177
- ├─────────────────────────────────────────────────────────┤
1178
- │ Frontier Memory: │
1179
- │ • ReasoningBank • Reflexion Memory │
1180
- │ • Skill Library • Causal Memory Graph │
1181
- │ • Causal Recall • Nightly Learner │
1182
- ├─────────────────────────────────────────────────────────┤
1183
- │ Optimizations: │
1184
- │ • BatchOperations • ToolCache (LRU + TTL) │
1185
- │ • Enhanced Validation │
1186
- ├─────────────────────────────────────────────────────────┤
1187
- │ Backend Auto-Selection (fastest → most compatible): │
1188
- │ RuVector → HNSWLib → better-sqlite3 → sql.js (WASM) │
1189
- └─────────────────────────────────────────────────────────┘
1190
- ↓ ↓ ↓
1191
- ┌─────────────────┐ ┌─────────────────┐ ┌──────────────┐
1192
- │ RuVector │ │ HNSWLib │ │ SQLite │
1193
- │ Rust + SIMD │ │ C++ HNSW │ │ better-sql3 │
1194
- │ 150x faster │ │ 100x faster │ │ Native Node │
1195
- │ (optional) │ │ (optional) │ │ (optional) │
1196
- └─────────────────┘ └─────────────────┘ └──────────────┘
1197
-
1198
- ┌──────────────┐
1199
- │ sql.js WASM │
1200
- │ Default │
1201
- │ Zero deps │
1202
- └──────────────┘
1203
- ```
1204
-
1205
- ### Data Flow
1206
-
1207
- ```
1208
- User Input
1209
-
1210
- Input Validation (XSS/injection detection)
1211
-
1212
- ToolCache Check (LRU + TTL)
1213
- ├── Cache Hit → Return cached result (8.8x faster)
1214
- └── Cache Miss → Continue
1215
-
1216
- Embedding Service
1217
- (Transformers.js or mock)
1218
-
1219
- Vector Backend
1220
- (Auto-selected: RuVector → HNSWLib → SQLite)
1221
-
1222
- Frontier Memory Layer
1223
- (ReasoningBank, Reflexion, Skills, Causal)
1224
-
1225
- Result + Provenance Certificate
1226
-
1227
- Cache Result (with TTL)
1228
-
1229
- Return to User
1230
- ```
1231
-
1232
- ---
1233
-
1234
- ## 🧪 Testing
1235
-
1236
- AgentDB v2 includes comprehensive test coverage:
308
+ Zero-code integration with AI coding assistants:
1237
309
 
1238
310
  ```bash
1239
- # Run all tests
1240
- npm test
1241
-
1242
- # Run specific test suites
1243
- npm run test:unit # Unit tests
1244
- npm run test:integration # Integration tests
1245
- npm run test:performance # Performance benchmarks
1246
- npm run test:security # Security validation
1247
-
1248
- # Docker validation (full CI/CD)
1249
- npm run docker:build # 9-stage Docker build
1250
- npm run docker:test # Run tests in container
1251
- ```
1252
-
1253
- **Test Coverage:**
1254
- - ✅ Core vector operations
1255
- - ✅ Frontier memory features
1256
- - ✅ Batch operations
1257
- - ✅ Caching mechanisms
1258
- - ✅ Input validation
1259
- - ✅ MCP tool handlers
1260
- - ✅ Security (XSS, injection)
1261
- - ✅ Performance benchmarks
1262
- - ✅ Backwards compatibility
1263
-
1264
- ---
1265
-
1266
- ## 📚 Documentation
1267
-
1268
- **Core Documentation:**
1269
- - [MCP Tool Optimization Guide](docs/MCP_TOOL_OPTIMIZATION_GUIDE.md) - Comprehensive optimization patterns (28KB)
1270
- - [Deep Review v2.0 - Latent Space](docs/DEEP-REVIEW-V2-LATENT-SPACE.md) - Complete validation report (59 CLI commands, 32 MCP tools, zero regressions)
1271
- - [MCP Tools Reference](docs/MCP_TOOLS.md) - All 32 tools documented
1272
- - [Optimization Report](OPTIMIZATION-REPORT.md) - v2.0 performance benchmarks
1273
- - [Optimization Summary](MCP-OPTIMIZATION-SUMMARY.md) - Executive summary
1274
- - [Migration Guide v1.3.0](MIGRATION_v1.3.0.md) - Upgrade from v1.2.2
1275
-
1276
- **Simulation Documentation:**
1277
- - [Simulation System](simulation/README.md) - Complete simulation framework (25 scenarios, 848 lines)
1278
- - [Wizard Guide](simulation/docs/guides/WIZARD-GUIDE.md) - Interactive CLI configuration
1279
- - [Documentation Index](simulation/docs/DOCUMENTATION-INDEX.md) - 60+ guides organized by category
1280
-
1281
- ---
1282
-
1283
- ## 🤝 Contributing
1284
-
1285
- We welcome contributions! See [CONTRIBUTING.md](CONTRIBUTING.md) for guidelines.
1286
-
1287
- **Areas of Interest:**
1288
- - Additional RL algorithms
1289
- - Performance optimizations
1290
- - New backend integrations
1291
- - Documentation improvements
1292
- - Test coverage expansion
311
+ # One-command setup
312
+ claude mcp add agentdb npx agentdb@v3 mcp start
1293
313
 
1294
- ---
314
+ # Now Claude Code can:
315
+ # - Store reasoning patterns with proof validation
316
+ # - Search 32.6M patterns/sec for relevant approaches
317
+ # - Learn from successful task completions
318
+ # - Build reusable skills with attestation logs
319
+ ```
1295
320
 
1296
- ## 📝 License
321
+ ## License
1297
322
 
1298
323
  MIT OR Apache-2.0
1299
324
 
1300
325
  See [LICENSE-MIT](LICENSE-MIT) and [LICENSE-APACHE](LICENSE-APACHE) for details.
1301
326
 
1302
- ---
1303
-
1304
- ## 🙏 Acknowledgments
1305
-
1306
- AgentDB v2 builds on research from:
1307
- - **RuVector** - Native Rust vector database with SIMD optimization (150x faster, 8.2x vs hnswlib)
1308
- - **Latent Space Research** - Empirical validation of optimal HNSW configurations, GNN attention, self-healing MPC
1309
- - **Reflexion** (Shinn et al., 2023) - Self-critique and episodic replay
1310
- - **Causal Inference** (Pearl, Judea) - Intervention-based causality
1311
- - **Decision Transformer** (Chen et al., 2021) - Offline RL
1312
- - **HNSW** (Malkov & Yashunin, 2018) - Approximate nearest neighbor search
1313
- - **Graph Neural Networks** - 8-head attention mechanism for navigation (+12.4% recall)
1314
- - **Anthropic** - Advanced tool use patterns and MCP protocol
327
+ ## Contributing
1315
328
 
1316
- ---
1317
-
1318
- ## 📊 Project Status
329
+ We welcome contributions! See [CONTRIBUTING.md](CONTRIBUTING.md) for guidelines.
1319
330
 
1320
- **Version:** 3.0.0-alpha.4
1321
- **Status:** Alpha Testing (Early Adopters)
1322
- **MCP Tools:** 32 (optimized with latent space research)
1323
- **CLI Commands:** 59 (including simulation suite)
1324
- **Controllers:** 21 active (all wired with proof-gated vectorBackend)
1325
- **Graph Modules:** 8 (via @ruvector/graph-transformer)
1326
- **Performance:** 150x faster (RuVector), 8.2x faster than hnswlib
1327
- **Proof Engine:** native (NAPI-RS) -> wasm -> JS fallback
1328
- **Last Updated:** 2026-02-25
331
+ ## Acknowledgments
1329
332
 
1330
- [Get Started](#-quick-start-60-seconds) | [Documentation](./docs/) | [GitHub](https://github.com/ruvnet/agentic-flow/tree/main/packages/agentdb) | [npm](https://www.npmjs.com/package/agentdb)
333
+ AgentDB v3 builds on research from:
334
+ - **RuVector** — Native Rust vector database (150x faster)
335
+ - **Reflexion** (Shinn et al., 2023) — Self-critique and episodic replay
336
+ - **Causal Inference** (Pearl, Judea) — Intervention-based causality
337
+ - **HNSW** (Malkov & Yashunin, 2018) — Approximate nearest neighbor search
338
+ - **Graph Neural Networks** — Attention mechanisms for memory navigation
1331
339
 
1332
340
  ---
1333
341
 
1334
342
  **Built with ❤️ for the agentic era**
343
+
344
+ [Documentation](./docs/) | [GitHub](https://github.com/ruvnet/agentic-flow/tree/main/packages/agentdb) | [npm](https://www.npmjs.com/package/agentdb)