agentdb 3.0.0-alpha.0 → 3.0.0-alpha.10

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 (781) hide show
  1. package/README.md +225 -2486
  2. package/dist/agentdb.browser.js +1685 -0
  3. package/dist/agentdb.browser.js.map +7 -0
  4. package/dist/agentdb.browser.min.js +3 -0
  5. package/dist/agentdb.browser.min.js.map +7 -0
  6. package/dist/agentdb.wasm-loader.js +207 -0
  7. package/dist/backends/VectorBackend.d.ts +120 -0
  8. package/dist/backends/VectorBackend.js +14 -0
  9. package/dist/backends/VectorBackend.js.map +1 -0
  10. package/dist/optimizations/RVFOptimizer.d.ts +225 -0
  11. package/dist/optimizations/RVFOptimizer.js +541 -0
  12. package/dist/optimizations/RVFOptimizer.js.map +1 -0
  13. package/dist/schemas/frontier-schema.sql +0 -7
  14. package/dist/schemas/schema.sql +0 -7
  15. package/dist/simulation/cli.d.ts +9 -0
  16. package/dist/simulation/cli.d.ts.map +1 -0
  17. package/dist/simulation/cli.js +68 -0
  18. package/dist/simulation/cli.js.map +1 -0
  19. package/dist/simulation/runner.d.ts +21 -0
  20. package/dist/simulation/runner.d.ts.map +1 -0
  21. package/dist/simulation/runner.js +241 -0
  22. package/dist/simulation/runner.js.map +1 -0
  23. package/dist/simulation/scenarios/aidefence-integration.d.ts +24 -0
  24. package/dist/simulation/scenarios/aidefence-integration.d.ts.map +1 -0
  25. package/dist/simulation/scenarios/aidefence-integration.js +124 -0
  26. package/dist/simulation/scenarios/aidefence-integration.js.map +1 -0
  27. package/dist/simulation/scenarios/bmssp-integration.d.ts +23 -0
  28. package/dist/simulation/scenarios/bmssp-integration.d.ts.map +1 -0
  29. package/dist/simulation/scenarios/bmssp-integration.js +104 -0
  30. package/dist/simulation/scenarios/bmssp-integration.js.map +1 -0
  31. package/dist/simulation/scenarios/causal-reasoning.d.ts +16 -0
  32. package/dist/simulation/scenarios/causal-reasoning.d.ts.map +1 -0
  33. package/dist/simulation/scenarios/causal-reasoning.js +108 -0
  34. package/dist/simulation/scenarios/causal-reasoning.js.map +1 -0
  35. package/dist/simulation/scenarios/consciousness-explorer.d.ts +25 -0
  36. package/dist/simulation/scenarios/consciousness-explorer.d.ts.map +1 -0
  37. package/dist/simulation/scenarios/consciousness-explorer.js +108 -0
  38. package/dist/simulation/scenarios/consciousness-explorer.js.map +1 -0
  39. package/dist/simulation/scenarios/domain-examples/e-commerce-recommendations.d.ts +135 -0
  40. package/dist/simulation/scenarios/domain-examples/e-commerce-recommendations.d.ts.map +1 -0
  41. package/dist/simulation/scenarios/domain-examples/e-commerce-recommendations.js +158 -0
  42. package/dist/simulation/scenarios/domain-examples/e-commerce-recommendations.js.map +1 -0
  43. package/dist/simulation/scenarios/domain-examples/index.d.ts +14 -0
  44. package/dist/simulation/scenarios/domain-examples/index.d.ts.map +1 -0
  45. package/dist/simulation/scenarios/domain-examples/index.js +14 -0
  46. package/dist/simulation/scenarios/domain-examples/index.js.map +1 -0
  47. package/dist/simulation/scenarios/domain-examples/iot-sensor-networks.d.ts +178 -0
  48. package/dist/simulation/scenarios/domain-examples/iot-sensor-networks.d.ts.map +1 -0
  49. package/dist/simulation/scenarios/domain-examples/iot-sensor-networks.js +218 -0
  50. package/dist/simulation/scenarios/domain-examples/iot-sensor-networks.js.map +1 -0
  51. package/dist/simulation/scenarios/domain-examples/medical-imaging.d.ts +122 -0
  52. package/dist/simulation/scenarios/domain-examples/medical-imaging.d.ts.map +1 -0
  53. package/dist/simulation/scenarios/domain-examples/medical-imaging.js +129 -0
  54. package/dist/simulation/scenarios/domain-examples/medical-imaging.js.map +1 -0
  55. package/dist/simulation/scenarios/domain-examples/robotics-navigation.d.ts +166 -0
  56. package/dist/simulation/scenarios/domain-examples/robotics-navigation.d.ts.map +1 -0
  57. package/dist/simulation/scenarios/domain-examples/robotics-navigation.js +161 -0
  58. package/dist/simulation/scenarios/domain-examples/robotics-navigation.js.map +1 -0
  59. package/dist/simulation/scenarios/domain-examples/scientific-research.d.ts +151 -0
  60. package/dist/simulation/scenarios/domain-examples/scientific-research.d.ts.map +1 -0
  61. package/dist/simulation/scenarios/domain-examples/scientific-research.js +187 -0
  62. package/dist/simulation/scenarios/domain-examples/scientific-research.js.map +1 -0
  63. package/dist/simulation/scenarios/domain-examples/trading-systems.d.ts +102 -0
  64. package/dist/simulation/scenarios/domain-examples/trading-systems.d.ts.map +1 -0
  65. package/dist/simulation/scenarios/domain-examples/trading-systems.js +100 -0
  66. package/dist/simulation/scenarios/domain-examples/trading-systems.js.map +1 -0
  67. package/dist/simulation/scenarios/goalie-integration.d.ts +24 -0
  68. package/dist/simulation/scenarios/goalie-integration.d.ts.map +1 -0
  69. package/dist/simulation/scenarios/goalie-integration.js +121 -0
  70. package/dist/simulation/scenarios/goalie-integration.js.map +1 -0
  71. package/dist/simulation/scenarios/graph-traversal.d.ts +17 -0
  72. package/dist/simulation/scenarios/graph-traversal.d.ts.map +1 -0
  73. package/dist/simulation/scenarios/graph-traversal.js +101 -0
  74. package/dist/simulation/scenarios/graph-traversal.js.map +1 -0
  75. package/dist/simulation/scenarios/latent-space/attention-analysis.d.ts +45 -0
  76. package/dist/simulation/scenarios/latent-space/attention-analysis.d.ts.map +1 -0
  77. package/dist/simulation/scenarios/latent-space/attention-analysis.js +435 -0
  78. package/dist/simulation/scenarios/latent-space/attention-analysis.js.map +1 -0
  79. package/dist/simulation/scenarios/latent-space/clustering-analysis.d.ts +55 -0
  80. package/dist/simulation/scenarios/latent-space/clustering-analysis.d.ts.map +1 -0
  81. package/dist/simulation/scenarios/latent-space/clustering-analysis.js +606 -0
  82. package/dist/simulation/scenarios/latent-space/clustering-analysis.js.map +1 -0
  83. package/dist/simulation/scenarios/latent-space/hnsw-exploration.d.ts +74 -0
  84. package/dist/simulation/scenarios/latent-space/hnsw-exploration.d.ts.map +1 -0
  85. package/dist/simulation/scenarios/latent-space/hnsw-exploration.js +391 -0
  86. package/dist/simulation/scenarios/latent-space/hnsw-exploration.js.map +1 -0
  87. package/dist/simulation/scenarios/latent-space/hypergraph-exploration.d.ts +51 -0
  88. package/dist/simulation/scenarios/latent-space/hypergraph-exploration.d.ts.map +1 -0
  89. package/dist/simulation/scenarios/latent-space/hypergraph-exploration.js +536 -0
  90. package/dist/simulation/scenarios/latent-space/hypergraph-exploration.js.map +1 -0
  91. package/dist/simulation/scenarios/latent-space/index.d.ts +35 -0
  92. package/dist/simulation/scenarios/latent-space/index.d.ts.map +1 -0
  93. package/dist/simulation/scenarios/latent-space/index.js +35 -0
  94. package/dist/simulation/scenarios/latent-space/index.js.map +1 -0
  95. package/dist/simulation/scenarios/latent-space/neural-augmentation.d.ts +52 -0
  96. package/dist/simulation/scenarios/latent-space/neural-augmentation.d.ts.map +1 -0
  97. package/dist/simulation/scenarios/latent-space/neural-augmentation.js +472 -0
  98. package/dist/simulation/scenarios/latent-space/neural-augmentation.js.map +1 -0
  99. package/dist/simulation/scenarios/latent-space/quantum-hybrid.d.ts +53 -0
  100. package/dist/simulation/scenarios/latent-space/quantum-hybrid.d.ts.map +1 -0
  101. package/dist/simulation/scenarios/latent-space/quantum-hybrid.js +391 -0
  102. package/dist/simulation/scenarios/latent-space/quantum-hybrid.js.map +1 -0
  103. package/dist/simulation/scenarios/latent-space/self-organizing-hnsw.d.ts +52 -0
  104. package/dist/simulation/scenarios/latent-space/self-organizing-hnsw.d.ts.map +1 -0
  105. package/dist/simulation/scenarios/latent-space/self-organizing-hnsw.js +514 -0
  106. package/dist/simulation/scenarios/latent-space/self-organizing-hnsw.js.map +1 -0
  107. package/dist/simulation/scenarios/latent-space/traversal-optimization.d.ts +53 -0
  108. package/dist/simulation/scenarios/latent-space/traversal-optimization.d.ts.map +1 -0
  109. package/dist/simulation/scenarios/latent-space/traversal-optimization.js +595 -0
  110. package/dist/simulation/scenarios/latent-space/traversal-optimization.js.map +1 -0
  111. package/dist/simulation/scenarios/lean-agentic-swarm.d.ts +18 -0
  112. package/dist/simulation/scenarios/lean-agentic-swarm.d.ts.map +1 -0
  113. package/dist/simulation/scenarios/lean-agentic-swarm.js +132 -0
  114. package/dist/simulation/scenarios/lean-agentic-swarm.js.map +1 -0
  115. package/dist/simulation/scenarios/multi-agent-swarm.d.ts +17 -0
  116. package/dist/simulation/scenarios/multi-agent-swarm.d.ts.map +1 -0
  117. package/dist/simulation/scenarios/multi-agent-swarm.js +111 -0
  118. package/dist/simulation/scenarios/multi-agent-swarm.js.map +1 -0
  119. package/dist/simulation/scenarios/psycho-symbolic-reasoner.d.ts +23 -0
  120. package/dist/simulation/scenarios/psycho-symbolic-reasoner.d.ts.map +1 -0
  121. package/dist/simulation/scenarios/psycho-symbolic-reasoner.js +98 -0
  122. package/dist/simulation/scenarios/psycho-symbolic-reasoner.js.map +1 -0
  123. package/dist/simulation/scenarios/reflexion-learning.d.ts +16 -0
  124. package/dist/simulation/scenarios/reflexion-learning.d.ts.map +1 -0
  125. package/dist/simulation/scenarios/reflexion-learning.js +98 -0
  126. package/dist/simulation/scenarios/reflexion-learning.js.map +1 -0
  127. package/dist/simulation/scenarios/research-swarm.d.ts +24 -0
  128. package/dist/simulation/scenarios/research-swarm.d.ts.map +1 -0
  129. package/dist/simulation/scenarios/research-swarm.js +146 -0
  130. package/dist/simulation/scenarios/research-swarm.js.map +1 -0
  131. package/dist/simulation/scenarios/skill-evolution.d.ts +16 -0
  132. package/dist/simulation/scenarios/skill-evolution.d.ts.map +1 -0
  133. package/dist/simulation/scenarios/skill-evolution.js +109 -0
  134. package/dist/simulation/scenarios/skill-evolution.js.map +1 -0
  135. package/dist/simulation/scenarios/stock-market-emergence.d.ts +33 -0
  136. package/dist/simulation/scenarios/stock-market-emergence.d.ts.map +1 -0
  137. package/dist/simulation/scenarios/stock-market-emergence.js +246 -0
  138. package/dist/simulation/scenarios/stock-market-emergence.js.map +1 -0
  139. package/dist/simulation/scenarios/strange-loops.d.ts +18 -0
  140. package/dist/simulation/scenarios/strange-loops.d.ts.map +1 -0
  141. package/dist/simulation/scenarios/strange-loops.js +133 -0
  142. package/dist/simulation/scenarios/strange-loops.js.map +1 -0
  143. package/dist/simulation/scenarios/sublinear-solver.d.ts +22 -0
  144. package/dist/simulation/scenarios/sublinear-solver.d.ts.map +1 -0
  145. package/dist/simulation/scenarios/sublinear-solver.js +82 -0
  146. package/dist/simulation/scenarios/sublinear-solver.js.map +1 -0
  147. package/dist/simulation/scenarios/temporal-lead-solver.d.ts +23 -0
  148. package/dist/simulation/scenarios/temporal-lead-solver.d.ts.map +1 -0
  149. package/dist/simulation/scenarios/temporal-lead-solver.js +90 -0
  150. package/dist/simulation/scenarios/temporal-lead-solver.js.map +1 -0
  151. package/dist/simulation/scenarios/voting-system-consensus.d.ts +27 -0
  152. package/dist/simulation/scenarios/voting-system-consensus.d.ts.map +1 -0
  153. package/dist/simulation/scenarios/voting-system-consensus.js +175 -0
  154. package/dist/simulation/scenarios/voting-system-consensus.js.map +1 -0
  155. package/dist/simulation/types.d.ts +162 -0
  156. package/dist/simulation/types.d.ts.map +1 -0
  157. package/dist/simulation/types.js +5 -0
  158. package/dist/simulation/types.js.map +1 -0
  159. package/dist/simulation/utils/PerformanceOptimizer.d.ts +115 -0
  160. package/dist/simulation/utils/PerformanceOptimizer.d.ts.map +1 -0
  161. package/dist/simulation/utils/PerformanceOptimizer.js +223 -0
  162. package/dist/simulation/utils/PerformanceOptimizer.js.map +1 -0
  163. package/dist/src/backends/GraphBackend.d.ts +8 -8
  164. package/dist/src/backends/GraphBackend.d.ts.map +1 -1
  165. package/dist/src/backends/GraphBackend.js +15 -16
  166. package/dist/src/backends/GraphBackend.js.map +1 -1
  167. package/dist/src/backends/LearningBackend.d.ts +2 -2
  168. package/dist/src/backends/LearningBackend.d.ts.map +1 -1
  169. package/dist/src/backends/LearningBackend.js +10 -11
  170. package/dist/src/backends/LearningBackend.js.map +1 -1
  171. package/dist/src/backends/VectorBackend.d.ts +6 -31
  172. package/dist/src/backends/VectorBackend.d.ts.map +1 -1
  173. package/dist/src/backends/detector.d.ts +3 -25
  174. package/dist/src/backends/detector.d.ts.map +1 -1
  175. package/dist/src/backends/detector.js +15 -119
  176. package/dist/src/backends/detector.js.map +1 -1
  177. package/dist/src/backends/factory.d.ts +33 -16
  178. package/dist/src/backends/factory.d.ts.map +1 -1
  179. package/dist/src/backends/factory.js +108 -138
  180. package/dist/src/backends/factory.js.map +1 -1
  181. package/dist/src/backends/graph/GraphDatabaseAdapter.d.ts +1 -1
  182. package/dist/src/backends/graph/GraphDatabaseAdapter.d.ts.map +1 -1
  183. package/dist/src/backends/graph/GraphDatabaseAdapter.js +1 -5
  184. package/dist/src/backends/graph/GraphDatabaseAdapter.js.map +1 -1
  185. package/dist/src/backends/hnswlib/HNSWLibBackend.d.ts +2 -2
  186. package/dist/src/backends/hnswlib/HNSWLibBackend.d.ts.map +1 -1
  187. package/dist/src/backends/hnswlib/HNSWLibBackend.js +13 -49
  188. package/dist/src/backends/hnswlib/HNSWLibBackend.js.map +1 -1
  189. package/dist/src/backends/index.cjs +6 -0
  190. package/dist/src/backends/index.d.ts +3 -25
  191. package/dist/src/backends/index.d.ts.map +1 -1
  192. package/dist/src/backends/index.js +1 -23
  193. package/dist/src/backends/index.js.map +1 -1
  194. package/dist/src/backends/ruvector/GuardedVectorBackend.d.ts +93 -0
  195. package/dist/src/backends/ruvector/GuardedVectorBackend.d.ts.map +1 -0
  196. package/dist/src/backends/ruvector/GuardedVectorBackend.js +182 -0
  197. package/dist/src/backends/ruvector/GuardedVectorBackend.js.map +1 -0
  198. package/dist/src/backends/ruvector/RuVectorBackend.d.ts +47 -200
  199. package/dist/src/backends/ruvector/RuVectorBackend.d.ts.map +1 -1
  200. package/dist/src/backends/ruvector/RuVectorBackend.js +277 -612
  201. package/dist/src/backends/ruvector/RuVectorBackend.js.map +1 -1
  202. package/dist/src/backends/ruvector/RuVectorLearning.d.ts +4 -0
  203. package/dist/src/backends/ruvector/RuVectorLearning.d.ts.map +1 -1
  204. package/dist/src/backends/ruvector/RuVectorLearning.js +11 -10
  205. package/dist/src/backends/ruvector/RuVectorLearning.js.map +1 -1
  206. package/dist/src/benchmarks/wasm-vector-benchmark.d.ts +10 -0
  207. package/dist/src/benchmarks/wasm-vector-benchmark.d.ts.map +1 -0
  208. package/dist/src/benchmarks/wasm-vector-benchmark.js +196 -0
  209. package/dist/src/benchmarks/wasm-vector-benchmark.js.map +1 -0
  210. package/dist/src/browser/AdvancedFeatures.d.ts.map +1 -1
  211. package/dist/src/browser/AdvancedFeatures.js +10 -3
  212. package/dist/src/browser/AdvancedFeatures.js.map +1 -1
  213. package/dist/src/browser/AttentionBrowser.d.ts.map +1 -1
  214. package/dist/src/browser/AttentionBrowser.js +12 -5
  215. package/dist/src/browser/AttentionBrowser.js.map +1 -1
  216. package/dist/src/browser/HNSWIndex.d.ts +1 -31
  217. package/dist/src/browser/HNSWIndex.d.ts.map +1 -1
  218. package/dist/src/browser/HNSWIndex.js +18 -136
  219. package/dist/src/browser/HNSWIndex.js.map +1 -1
  220. package/dist/src/browser/ProductQuantization.d.ts.map +1 -1
  221. package/dist/src/browser/ProductQuantization.js +1 -0
  222. package/dist/src/browser/ProductQuantization.js.map +1 -1
  223. package/dist/src/browser/index.d.ts +3 -3
  224. package/dist/src/browser/index.d.ts.map +1 -1
  225. package/dist/src/browser/index.js +1 -2
  226. package/dist/src/browser/index.js.map +1 -1
  227. package/dist/src/cli/agentdb-cli.d.ts +2 -16
  228. package/dist/src/cli/agentdb-cli.d.ts.map +1 -1
  229. package/dist/src/cli/agentdb-cli.js +215 -852
  230. package/dist/src/cli/agentdb-cli.js.map +1 -1
  231. package/dist/src/cli/commands/attention.js +3 -3
  232. package/dist/src/cli/commands/attention.js.map +1 -1
  233. package/dist/src/cli/commands/doctor.d.ts +0 -2
  234. package/dist/src/cli/commands/doctor.d.ts.map +1 -1
  235. package/dist/src/cli/commands/doctor.js +1 -106
  236. package/dist/src/cli/commands/doctor.js.map +1 -1
  237. package/dist/src/cli/commands/init.d.ts +1 -2
  238. package/dist/src/cli/commands/init.d.ts.map +1 -1
  239. package/dist/src/cli/commands/init.js +7 -30
  240. package/dist/src/cli/commands/init.js.map +1 -1
  241. package/dist/src/cli/commands/install-embeddings.d.ts.map +1 -1
  242. package/dist/src/cli/commands/install-embeddings.js.map +1 -1
  243. package/dist/src/cli/commands/migrate.d.ts +0 -2
  244. package/dist/src/cli/commands/migrate.d.ts.map +1 -1
  245. package/dist/src/cli/commands/migrate.js +5 -52
  246. package/dist/src/cli/commands/migrate.js.map +1 -1
  247. package/dist/src/cli/commands/simulate-report.js.map +1 -1
  248. package/dist/src/cli/commands/simulate-wizard.js.map +1 -1
  249. package/dist/src/cli/commands/simulate.d.ts +7 -0
  250. package/dist/src/cli/commands/simulate.d.ts.map +1 -0
  251. package/dist/src/cli/commands/simulate.js +100 -0
  252. package/dist/src/cli/commands/simulate.js.map +1 -0
  253. package/dist/src/cli/commands/status.js +1 -5
  254. package/dist/src/cli/commands/status.js.map +1 -1
  255. package/dist/src/cli/lib/attention-config.d.ts +2 -2
  256. package/dist/src/cli/lib/attention-config.d.ts.map +1 -1
  257. package/dist/src/cli/lib/attention-config.js +1 -2
  258. package/dist/src/cli/lib/attention-config.js.map +1 -1
  259. package/dist/src/cli/lib/config-manager.d.ts +110 -0
  260. package/dist/src/cli/lib/config-manager.d.ts.map +1 -0
  261. package/dist/src/cli/lib/config-manager.js +512 -0
  262. package/dist/src/cli/lib/config-manager.js.map +1 -0
  263. package/dist/src/cli/lib/config-validator.d.ts +1 -1
  264. package/dist/src/cli/lib/config-validator.d.ts.map +1 -1
  265. package/dist/src/cli/lib/health-monitor.d.ts +149 -0
  266. package/dist/src/cli/lib/health-monitor.d.ts.map +1 -0
  267. package/dist/src/cli/lib/health-monitor.js +380 -0
  268. package/dist/src/cli/lib/health-monitor.js.map +1 -0
  269. package/dist/src/cli/lib/history-tracker.d.ts +103 -0
  270. package/dist/src/cli/lib/history-tracker.d.ts.map +1 -0
  271. package/dist/src/cli/lib/history-tracker.js +352 -0
  272. package/dist/src/cli/lib/history-tracker.js.map +1 -0
  273. package/dist/src/cli/lib/report-store.d.ts +1 -2
  274. package/dist/src/cli/lib/report-store.d.ts.map +1 -1
  275. package/dist/src/cli/lib/report-store.js +65 -87
  276. package/dist/src/cli/lib/report-store.js.map +1 -1
  277. package/dist/src/cli/lib/simulation-registry.d.ts +1 -1
  278. package/dist/src/cli/lib/simulation-registry.d.ts.map +1 -1
  279. package/dist/src/cli/lib/simulation-registry.js +0 -1
  280. package/dist/src/cli/lib/simulation-registry.js.map +1 -1
  281. package/dist/src/cli/lib/simulation-runner.d.ts +4 -41
  282. package/dist/src/cli/lib/simulation-runner.d.ts.map +1 -1
  283. package/dist/src/cli/lib/simulation-runner.js +6 -251
  284. package/dist/src/cli/lib/simulation-runner.js.map +1 -1
  285. package/dist/src/consensus/RaftConsensus.d.ts +220 -0
  286. package/dist/src/consensus/RaftConsensus.d.ts.map +1 -0
  287. package/dist/src/consensus/RaftConsensus.js +762 -0
  288. package/dist/src/consensus/RaftConsensus.js.map +1 -0
  289. package/dist/src/controllers/AttentionService.d.ts +80 -1
  290. package/dist/src/controllers/AttentionService.d.ts.map +1 -1
  291. package/dist/src/controllers/AttentionService.js +349 -16
  292. package/dist/src/controllers/AttentionService.js.map +1 -1
  293. package/dist/src/controllers/CausalMemoryGraph.d.ts +8 -33
  294. package/dist/src/controllers/CausalMemoryGraph.d.ts.map +1 -1
  295. package/dist/src/controllers/CausalMemoryGraph.js +16 -93
  296. package/dist/src/controllers/CausalMemoryGraph.js.map +1 -1
  297. package/dist/src/controllers/CausalRecall.d.ts +3 -6
  298. package/dist/src/controllers/CausalRecall.d.ts.map +1 -1
  299. package/dist/src/controllers/CausalRecall.js +8 -14
  300. package/dist/src/controllers/CausalRecall.js.map +1 -1
  301. package/dist/src/controllers/ContextSynthesizer.d.ts +1 -1
  302. package/dist/src/controllers/ContextSynthesizer.d.ts.map +1 -1
  303. package/dist/src/controllers/EmbeddingService.d.ts.map +1 -1
  304. package/dist/src/controllers/EmbeddingService.js +3 -10
  305. package/dist/src/controllers/EmbeddingService.js.map +1 -1
  306. package/dist/src/controllers/EnhancedEmbeddingService.d.ts +0 -4
  307. package/dist/src/controllers/EnhancedEmbeddingService.d.ts.map +1 -1
  308. package/dist/src/controllers/EnhancedEmbeddingService.js +3 -10
  309. package/dist/src/controllers/EnhancedEmbeddingService.js.map +1 -1
  310. package/dist/src/controllers/ExplainableRecall.d.ts +6 -5
  311. package/dist/src/controllers/ExplainableRecall.d.ts.map +1 -1
  312. package/dist/src/controllers/ExplainableRecall.js +13 -21
  313. package/dist/src/controllers/ExplainableRecall.js.map +1 -1
  314. package/dist/src/controllers/HNSWIndex.d.ts +7 -24
  315. package/dist/src/controllers/HNSWIndex.d.ts.map +1 -1
  316. package/dist/src/controllers/HNSWIndex.js +10 -89
  317. package/dist/src/controllers/HNSWIndex.js.map +1 -1
  318. package/dist/src/controllers/HierarchicalMemory.d.ts +197 -0
  319. package/dist/src/controllers/HierarchicalMemory.d.ts.map +1 -0
  320. package/dist/src/controllers/HierarchicalMemory.js +519 -0
  321. package/dist/src/controllers/HierarchicalMemory.js.map +1 -0
  322. package/dist/src/controllers/LearningSystem.d.ts +27 -106
  323. package/dist/src/controllers/LearningSystem.d.ts.map +1 -1
  324. package/dist/src/controllers/LearningSystem.js +145 -39
  325. package/dist/src/controllers/LearningSystem.js.map +1 -1
  326. package/dist/src/controllers/MMRDiversityRanker.d.ts +1 -1
  327. package/dist/src/controllers/MMRDiversityRanker.d.ts.map +1 -1
  328. package/dist/src/controllers/MemoryConsolidation.d.ts +142 -0
  329. package/dist/src/controllers/MemoryConsolidation.d.ts.map +1 -0
  330. package/dist/src/controllers/MemoryConsolidation.js +479 -0
  331. package/dist/src/controllers/MemoryConsolidation.js.map +1 -0
  332. package/dist/src/controllers/MetadataFilter.d.ts +3 -3
  333. package/dist/src/controllers/MetadataFilter.d.ts.map +1 -1
  334. package/dist/src/controllers/MetadataFilter.js +6 -9
  335. package/dist/src/controllers/MetadataFilter.js.map +1 -1
  336. package/dist/src/controllers/NightlyLearner.d.ts +4 -9
  337. package/dist/src/controllers/NightlyLearner.d.ts.map +1 -1
  338. package/dist/src/controllers/NightlyLearner.js +9 -28
  339. package/dist/src/controllers/NightlyLearner.js.map +1 -1
  340. package/dist/src/controllers/QUICClient.d.ts +2 -50
  341. package/dist/src/controllers/QUICClient.d.ts.map +1 -1
  342. package/dist/src/controllers/QUICClient.js +3 -193
  343. package/dist/src/controllers/QUICClient.js.map +1 -1
  344. package/dist/src/controllers/QUICConnection.d.ts +122 -0
  345. package/dist/src/controllers/QUICConnection.d.ts.map +1 -0
  346. package/dist/src/controllers/QUICConnection.js +329 -0
  347. package/dist/src/controllers/QUICConnection.js.map +1 -0
  348. package/dist/src/controllers/QUICConnectionPool.d.ts +83 -0
  349. package/dist/src/controllers/QUICConnectionPool.d.ts.map +1 -0
  350. package/dist/src/controllers/QUICConnectionPool.js +256 -0
  351. package/dist/src/controllers/QUICConnectionPool.js.map +1 -0
  352. package/dist/src/controllers/QUICServer.d.ts +4 -4
  353. package/dist/src/controllers/QUICServer.d.ts.map +1 -1
  354. package/dist/src/controllers/QUICServer.js +14 -22
  355. package/dist/src/controllers/QUICServer.js.map +1 -1
  356. package/dist/src/controllers/QUICStreamManager.d.ts +114 -0
  357. package/dist/src/controllers/QUICStreamManager.d.ts.map +1 -0
  358. package/dist/src/controllers/QUICStreamManager.js +267 -0
  359. package/dist/src/controllers/QUICStreamManager.js.map +1 -0
  360. package/dist/src/controllers/ReasoningBank.d.ts +4 -14
  361. package/dist/src/controllers/ReasoningBank.d.ts.map +1 -1
  362. package/dist/src/controllers/ReasoningBank.js +46 -59
  363. package/dist/src/controllers/ReasoningBank.js.map +1 -1
  364. package/dist/src/controllers/ReflexionMemory.d.ts +7 -80
  365. package/dist/src/controllers/ReflexionMemory.d.ts.map +1 -1
  366. package/dist/src/controllers/ReflexionMemory.js +214 -372
  367. package/dist/src/controllers/ReflexionMemory.js.map +1 -1
  368. package/dist/src/controllers/SkillLibrary.d.ts +7 -37
  369. package/dist/src/controllers/SkillLibrary.d.ts.map +1 -1
  370. package/dist/src/controllers/SkillLibrary.js +96 -212
  371. package/dist/src/controllers/SkillLibrary.js.map +1 -1
  372. package/dist/src/controllers/StreamingEmbeddingService.d.ts +82 -0
  373. package/dist/src/controllers/StreamingEmbeddingService.d.ts.map +1 -0
  374. package/dist/src/controllers/StreamingEmbeddingService.js +243 -0
  375. package/dist/src/controllers/StreamingEmbeddingService.js.map +1 -0
  376. package/dist/src/controllers/SyncCoordinator.d.ts +3 -2
  377. package/dist/src/controllers/SyncCoordinator.d.ts.map +1 -1
  378. package/dist/src/controllers/SyncCoordinator.js +5 -117
  379. package/dist/src/controllers/SyncCoordinator.js.map +1 -1
  380. package/dist/src/controllers/WASMVectorSearch.d.ts +37 -18
  381. package/dist/src/controllers/WASMVectorSearch.d.ts.map +1 -1
  382. package/dist/src/controllers/WASMVectorSearch.js +95 -150
  383. package/dist/src/controllers/WASMVectorSearch.js.map +1 -1
  384. package/dist/src/controllers/frontier-index.d.ts +14 -0
  385. package/dist/src/controllers/frontier-index.d.ts.map +1 -0
  386. package/dist/src/controllers/frontier-index.js +10 -0
  387. package/dist/src/controllers/frontier-index.js.map +1 -0
  388. package/dist/src/controllers/index.cjs +6 -0
  389. package/dist/src/controllers/index.d.ts +27 -8
  390. package/dist/src/controllers/index.d.ts.map +1 -1
  391. package/dist/src/controllers/index.js +18 -6
  392. package/dist/src/controllers/index.js.map +1 -1
  393. package/dist/src/core/AgentDB.d.ts +21 -60
  394. package/dist/src/core/AgentDB.d.ts.map +1 -1
  395. package/dist/src/core/AgentDB.js +123 -133
  396. package/dist/src/core/AgentDB.js.map +1 -1
  397. package/dist/src/db-fallback.d.ts +1 -10
  398. package/dist/src/db-fallback.d.ts.map +1 -1
  399. package/dist/src/db-fallback.js +4 -171
  400. package/dist/src/db-fallback.js.map +1 -1
  401. package/dist/src/db-test.d.ts +13 -0
  402. package/dist/src/db-test.d.ts.map +1 -0
  403. package/dist/src/db-test.js +55 -0
  404. package/dist/src/db-test.js.map +1 -0
  405. package/dist/src/db-unified.d.ts +76 -0
  406. package/dist/src/db-unified.d.ts.map +1 -0
  407. package/dist/src/db-unified.js +279 -0
  408. package/dist/src/db-unified.js.map +1 -0
  409. package/dist/src/examples/quic-sync-example.d.ts +9 -0
  410. package/dist/src/examples/quic-sync-example.d.ts.map +1 -0
  411. package/dist/src/examples/quic-sync-example.js +169 -0
  412. package/dist/src/examples/quic-sync-example.js.map +1 -0
  413. package/dist/src/examples/wasm-vector-usage.d.ts +12 -0
  414. package/dist/src/examples/wasm-vector-usage.d.ts.map +1 -0
  415. package/dist/src/examples/wasm-vector-usage.js +190 -0
  416. package/dist/src/examples/wasm-vector-usage.js.map +1 -0
  417. package/dist/src/index.cjs +6 -0
  418. package/dist/src/index.d.ts +16 -38
  419. package/dist/src/index.d.ts.map +1 -1
  420. package/dist/src/index.js +13 -46
  421. package/dist/src/index.js.map +1 -1
  422. package/dist/src/mcp/agentdb-mcp-server.js +63 -219
  423. package/dist/src/mcp/agentdb-mcp-server.js.map +1 -1
  424. package/dist/src/mcp/learning-tools-handlers.d.ts +16 -0
  425. package/dist/src/mcp/learning-tools-handlers.d.ts.map +1 -0
  426. package/dist/src/mcp/learning-tools-handlers.js +105 -0
  427. package/dist/src/mcp/learning-tools-handlers.js.map +1 -0
  428. package/dist/src/optimizations/BatchOperations.d.ts +5 -52
  429. package/dist/src/optimizations/BatchOperations.d.ts.map +1 -1
  430. package/dist/src/optimizations/BatchOperations.js +33 -186
  431. package/dist/src/optimizations/BatchOperations.js.map +1 -1
  432. package/dist/src/optimizations/QueryOptimizer.d.ts +4 -4
  433. package/dist/src/optimizations/QueryOptimizer.d.ts.map +1 -1
  434. package/dist/src/optimizations/QueryOptimizer.js +1 -3
  435. package/dist/src/optimizations/QueryOptimizer.js.map +1 -1
  436. package/dist/src/optimizations/RVFOptimizer.d.ts +226 -0
  437. package/dist/src/optimizations/RVFOptimizer.d.ts.map +1 -0
  438. package/dist/src/optimizations/RVFOptimizer.js +541 -0
  439. package/dist/src/optimizations/RVFOptimizer.js.map +1 -0
  440. package/dist/src/optimizations/ToolCache.d.ts +4 -4
  441. package/dist/src/optimizations/ToolCache.d.ts.map +1 -1
  442. package/dist/src/optimizations/ToolCache.js.map +1 -1
  443. package/dist/src/optimizations/index.d.ts +3 -1
  444. package/dist/src/optimizations/index.d.ts.map +1 -1
  445. package/dist/src/optimizations/index.js +1 -0
  446. package/dist/src/optimizations/index.js.map +1 -1
  447. package/dist/src/security/AttestationLog.d.ts +70 -0
  448. package/dist/src/security/AttestationLog.d.ts.map +1 -0
  449. package/dist/src/security/AttestationLog.js +174 -0
  450. package/dist/src/security/AttestationLog.js.map +1 -0
  451. package/dist/src/security/MutationGuard.d.ts +83 -0
  452. package/dist/src/security/MutationGuard.d.ts.map +1 -0
  453. package/dist/src/security/MutationGuard.js +364 -0
  454. package/dist/src/security/MutationGuard.js.map +1 -0
  455. package/dist/src/security/index.cjs +6 -0
  456. package/dist/src/security/index.d.ts +15 -0
  457. package/dist/src/security/index.d.ts.map +1 -0
  458. package/dist/src/security/index.js +18 -0
  459. package/dist/src/security/index.js.map +1 -0
  460. package/dist/src/security/input-validation.d.ts +12 -12
  461. package/dist/src/security/input-validation.d.ts.map +1 -1
  462. package/dist/src/security/input-validation.js +0 -1
  463. package/dist/src/security/input-validation.js.map +1 -1
  464. package/dist/src/security/limits.d.ts +150 -0
  465. package/dist/src/security/limits.d.ts.map +1 -0
  466. package/dist/src/security/limits.js +288 -0
  467. package/dist/src/security/limits.js.map +1 -0
  468. package/dist/src/security/path-security.d.ts +100 -0
  469. package/dist/src/security/path-security.d.ts.map +1 -0
  470. package/dist/src/security/path-security.js +337 -0
  471. package/dist/src/security/path-security.js.map +1 -0
  472. package/dist/src/security/validation.d.ts +95 -0
  473. package/dist/src/security/validation.d.ts.map +1 -0
  474. package/dist/src/security/validation.js +315 -0
  475. package/dist/src/security/validation.js.map +1 -0
  476. package/dist/src/services/GNNService.d.ts +173 -0
  477. package/dist/src/services/GNNService.d.ts.map +1 -0
  478. package/dist/src/services/GNNService.js +639 -0
  479. package/dist/src/services/GNNService.js.map +1 -0
  480. package/dist/src/services/GraphTransformerService.d.ts +80 -0
  481. package/dist/src/services/GraphTransformerService.d.ts.map +1 -0
  482. package/dist/src/services/GraphTransformerService.js +369 -0
  483. package/dist/src/services/GraphTransformerService.js.map +1 -0
  484. package/dist/src/services/LLMRouter.d.ts +7 -61
  485. package/dist/src/services/LLMRouter.d.ts.map +1 -1
  486. package/dist/src/services/LLMRouter.js +25 -295
  487. package/dist/src/services/LLMRouter.js.map +1 -1
  488. package/dist/src/services/SemanticRouter.d.ts +83 -0
  489. package/dist/src/services/SemanticRouter.d.ts.map +1 -0
  490. package/dist/src/services/SemanticRouter.js +160 -0
  491. package/dist/src/services/SemanticRouter.js.map +1 -0
  492. package/dist/src/services/SonaTrajectoryService.d.ts +224 -0
  493. package/dist/src/services/SonaTrajectoryService.d.ts.map +1 -0
  494. package/dist/src/services/SonaTrajectoryService.js +539 -0
  495. package/dist/src/services/SonaTrajectoryService.js.map +1 -0
  496. package/dist/src/types/attention.d.ts +249 -0
  497. package/dist/src/types/attention.d.ts.map +1 -0
  498. package/dist/src/types/attention.js +43 -0
  499. package/dist/src/types/attention.js.map +1 -0
  500. package/dist/src/types/quic.d.ts +518 -0
  501. package/dist/src/types/quic.d.ts.map +1 -0
  502. package/dist/src/types/quic.js +272 -0
  503. package/dist/src/types/quic.js.map +1 -0
  504. package/dist/src/utils/LegacyAttentionAdapter.d.ts +93 -0
  505. package/dist/src/utils/LegacyAttentionAdapter.d.ts.map +1 -0
  506. package/dist/src/utils/LegacyAttentionAdapter.js +241 -0
  507. package/dist/src/utils/LegacyAttentionAdapter.js.map +1 -0
  508. package/dist/src/utils/attention-metrics.d.ts +76 -0
  509. package/dist/src/utils/attention-metrics.d.ts.map +1 -0
  510. package/dist/src/utils/attention-metrics.js +178 -0
  511. package/dist/src/utils/attention-metrics.js.map +1 -0
  512. package/dist/src/utils/vector-math.d.ts +29 -0
  513. package/dist/src/utils/vector-math.d.ts.map +1 -0
  514. package/dist/src/utils/vector-math.js +66 -0
  515. package/dist/src/utils/vector-math.js.map +1 -0
  516. package/package.json +75 -59
  517. package/LICENSE +0 -21
  518. package/dist/src/backends/rvf/AdaptiveIndexTuner.d.ts +0 -175
  519. package/dist/src/backends/rvf/AdaptiveIndexTuner.d.ts.map +0 -1
  520. package/dist/src/backends/rvf/AdaptiveIndexTuner.js +0 -559
  521. package/dist/src/backends/rvf/AdaptiveIndexTuner.js.map +0 -1
  522. package/dist/src/backends/rvf/ContrastiveTrainer.d.ts +0 -148
  523. package/dist/src/backends/rvf/ContrastiveTrainer.d.ts.map +0 -1
  524. package/dist/src/backends/rvf/ContrastiveTrainer.js +0 -438
  525. package/dist/src/backends/rvf/ContrastiveTrainer.js.map +0 -1
  526. package/dist/src/backends/rvf/FederatedSessionManager.d.ts +0 -211
  527. package/dist/src/backends/rvf/FederatedSessionManager.d.ts.map +0 -1
  528. package/dist/src/backends/rvf/FederatedSessionManager.js +0 -389
  529. package/dist/src/backends/rvf/FederatedSessionManager.js.map +0 -1
  530. package/dist/src/backends/rvf/FilterBuilder.d.ts +0 -136
  531. package/dist/src/backends/rvf/FilterBuilder.d.ts.map +0 -1
  532. package/dist/src/backends/rvf/FilterBuilder.js +0 -157
  533. package/dist/src/backends/rvf/FilterBuilder.js.map +0 -1
  534. package/dist/src/backends/rvf/NativeAccelerator.d.ts +0 -140
  535. package/dist/src/backends/rvf/NativeAccelerator.d.ts.map +0 -1
  536. package/dist/src/backends/rvf/NativeAccelerator.js +0 -630
  537. package/dist/src/backends/rvf/NativeAccelerator.js.map +0 -1
  538. package/dist/src/backends/rvf/RvfBackend.d.ts +0 -194
  539. package/dist/src/backends/rvf/RvfBackend.d.ts.map +0 -1
  540. package/dist/src/backends/rvf/RvfBackend.js +0 -607
  541. package/dist/src/backends/rvf/RvfBackend.js.map +0 -1
  542. package/dist/src/backends/rvf/RvfSolver.d.ts +0 -175
  543. package/dist/src/backends/rvf/RvfSolver.d.ts.map +0 -1
  544. package/dist/src/backends/rvf/RvfSolver.js +0 -176
  545. package/dist/src/backends/rvf/RvfSolver.js.map +0 -1
  546. package/dist/src/backends/rvf/SelfLearningRvfBackend.d.ts +0 -143
  547. package/dist/src/backends/rvf/SelfLearningRvfBackend.d.ts.map +0 -1
  548. package/dist/src/backends/rvf/SelfLearningRvfBackend.js +0 -569
  549. package/dist/src/backends/rvf/SelfLearningRvfBackend.js.map +0 -1
  550. package/dist/src/backends/rvf/SemanticQueryRouter.d.ts +0 -128
  551. package/dist/src/backends/rvf/SemanticQueryRouter.d.ts.map +0 -1
  552. package/dist/src/backends/rvf/SemanticQueryRouter.js +0 -415
  553. package/dist/src/backends/rvf/SemanticQueryRouter.js.map +0 -1
  554. package/dist/src/backends/rvf/SimdFallbacks.d.ts +0 -25
  555. package/dist/src/backends/rvf/SimdFallbacks.d.ts.map +0 -1
  556. package/dist/src/backends/rvf/SimdFallbacks.js +0 -287
  557. package/dist/src/backends/rvf/SimdFallbacks.js.map +0 -1
  558. package/dist/src/backends/rvf/SolverBandit.d.ts +0 -100
  559. package/dist/src/backends/rvf/SolverBandit.d.ts.map +0 -1
  560. package/dist/src/backends/rvf/SolverBandit.js +0 -216
  561. package/dist/src/backends/rvf/SolverBandit.js.map +0 -1
  562. package/dist/src/backends/rvf/SonaLearningBackend.d.ts +0 -157
  563. package/dist/src/backends/rvf/SonaLearningBackend.d.ts.map +0 -1
  564. package/dist/src/backends/rvf/SonaLearningBackend.js +0 -283
  565. package/dist/src/backends/rvf/SonaLearningBackend.js.map +0 -1
  566. package/dist/src/backends/rvf/SqlJsRvfBackend.d.ts +0 -77
  567. package/dist/src/backends/rvf/SqlJsRvfBackend.d.ts.map +0 -1
  568. package/dist/src/backends/rvf/SqlJsRvfBackend.js +0 -382
  569. package/dist/src/backends/rvf/SqlJsRvfBackend.js.map +0 -1
  570. package/dist/src/backends/rvf/WasmStoreBridge.d.ts +0 -27
  571. package/dist/src/backends/rvf/WasmStoreBridge.d.ts.map +0 -1
  572. package/dist/src/backends/rvf/WasmStoreBridge.js +0 -87
  573. package/dist/src/backends/rvf/WasmStoreBridge.js.map +0 -1
  574. package/dist/src/backends/rvf/validation.d.ts +0 -20
  575. package/dist/src/backends/rvf/validation.d.ts.map +0 -1
  576. package/dist/src/backends/rvf/validation.js +0 -78
  577. package/dist/src/backends/rvf/validation.js.map +0 -1
  578. package/dist/src/benchmark/BenchmarkSuite.d.ts +0 -318
  579. package/dist/src/benchmark/BenchmarkSuite.d.ts.map +0 -1
  580. package/dist/src/benchmark/BenchmarkSuite.js +0 -986
  581. package/dist/src/benchmark/BenchmarkSuite.js.map +0 -1
  582. package/dist/src/benchmark/index.d.ts +0 -29
  583. package/dist/src/benchmark/index.d.ts.map +0 -1
  584. package/dist/src/benchmark/index.js +0 -39
  585. package/dist/src/benchmark/index.js.map +0 -1
  586. package/dist/src/cli/commands/hyperbolic.d.ts +0 -11
  587. package/dist/src/cli/commands/hyperbolic.d.ts.map +0 -1
  588. package/dist/src/cli/commands/hyperbolic.js +0 -428
  589. package/dist/src/cli/commands/hyperbolic.js.map +0 -1
  590. package/dist/src/cli/commands/learn.d.ts +0 -11
  591. package/dist/src/cli/commands/learn.d.ts.map +0 -1
  592. package/dist/src/cli/commands/learn.js +0 -404
  593. package/dist/src/cli/commands/learn.js.map +0 -1
  594. package/dist/src/cli/commands/route.d.ts +0 -11
  595. package/dist/src/cli/commands/route.d.ts.map +0 -1
  596. package/dist/src/cli/commands/route.js +0 -414
  597. package/dist/src/cli/commands/route.js.map +0 -1
  598. package/dist/src/cli/commands/rvf.d.ts +0 -21
  599. package/dist/src/cli/commands/rvf.d.ts.map +0 -1
  600. package/dist/src/cli/commands/rvf.js +0 -448
  601. package/dist/src/cli/commands/rvf.js.map +0 -1
  602. package/dist/src/cli/tests/agentdb-cli.test.d.ts +0 -8
  603. package/dist/src/cli/tests/agentdb-cli.test.d.ts.map +0 -1
  604. package/dist/src/cli/tests/agentdb-cli.test.js +0 -50
  605. package/dist/src/cli/tests/agentdb-cli.test.js.map +0 -1
  606. package/dist/src/cli/tests/attention-cli.test.d.ts +0 -5
  607. package/dist/src/cli/tests/attention-cli.test.d.ts.map +0 -1
  608. package/dist/src/cli/tests/attention-cli.test.js +0 -257
  609. package/dist/src/cli/tests/attention-cli.test.js.map +0 -1
  610. package/dist/src/compatibility/DeprecationWarnings.d.ts +0 -54
  611. package/dist/src/compatibility/DeprecationWarnings.d.ts.map +0 -1
  612. package/dist/src/compatibility/DeprecationWarnings.js +0 -131
  613. package/dist/src/compatibility/DeprecationWarnings.js.map +0 -1
  614. package/dist/src/compatibility/MigrationUtilities.d.ts +0 -30
  615. package/dist/src/compatibility/MigrationUtilities.d.ts.map +0 -1
  616. package/dist/src/compatibility/MigrationUtilities.js +0 -184
  617. package/dist/src/compatibility/MigrationUtilities.js.map +0 -1
  618. package/dist/src/compatibility/V1toV2Adapter.d.ts +0 -76
  619. package/dist/src/compatibility/V1toV2Adapter.d.ts.map +0 -1
  620. package/dist/src/compatibility/V1toV2Adapter.js +0 -198
  621. package/dist/src/compatibility/V1toV2Adapter.js.map +0 -1
  622. package/dist/src/compatibility/VersionDetector.d.ts +0 -32
  623. package/dist/src/compatibility/VersionDetector.d.ts.map +0 -1
  624. package/dist/src/compatibility/VersionDetector.js +0 -144
  625. package/dist/src/compatibility/VersionDetector.js.map +0 -1
  626. package/dist/src/compatibility/index.d.ts +0 -11
  627. package/dist/src/compatibility/index.d.ts.map +0 -1
  628. package/dist/src/compatibility/index.js +0 -10
  629. package/dist/src/compatibility/index.js.map +0 -1
  630. package/dist/src/compatibility/types.d.ts +0 -103
  631. package/dist/src/compatibility/types.d.ts.map +0 -1
  632. package/dist/src/compatibility/types.js +0 -5
  633. package/dist/src/compatibility/types.js.map +0 -1
  634. package/dist/src/controllers/MemoryController.d.ts +0 -161
  635. package/dist/src/controllers/MemoryController.d.ts.map +0 -1
  636. package/dist/src/controllers/MemoryController.js +0 -290
  637. package/dist/src/controllers/MemoryController.js.map +0 -1
  638. package/dist/src/controllers/attention/CrossAttentionController.d.ts +0 -141
  639. package/dist/src/controllers/attention/CrossAttentionController.d.ts.map +0 -1
  640. package/dist/src/controllers/attention/CrossAttentionController.js +0 -325
  641. package/dist/src/controllers/attention/CrossAttentionController.js.map +0 -1
  642. package/dist/src/controllers/attention/MultiHeadAttentionController.d.ts +0 -137
  643. package/dist/src/controllers/attention/MultiHeadAttentionController.d.ts.map +0 -1
  644. package/dist/src/controllers/attention/MultiHeadAttentionController.js +0 -339
  645. package/dist/src/controllers/attention/MultiHeadAttentionController.js.map +0 -1
  646. package/dist/src/controllers/attention/SelfAttentionController.d.ts +0 -117
  647. package/dist/src/controllers/attention/SelfAttentionController.d.ts.map +0 -1
  648. package/dist/src/controllers/attention/SelfAttentionController.js +0 -205
  649. package/dist/src/controllers/attention/SelfAttentionController.js.map +0 -1
  650. package/dist/src/controllers/attention/index.d.ts +0 -15
  651. package/dist/src/controllers/attention/index.d.ts.map +0 -1
  652. package/dist/src/controllers/attention/index.js +0 -12
  653. package/dist/src/controllers/attention/index.js.map +0 -1
  654. package/dist/src/core/QueryCache.d.ts +0 -138
  655. package/dist/src/core/QueryCache.d.ts.map +0 -1
  656. package/dist/src/core/QueryCache.js +0 -313
  657. package/dist/src/core/QueryCache.js.map +0 -1
  658. package/dist/src/observability/index.d.ts +0 -8
  659. package/dist/src/observability/index.d.ts.map +0 -1
  660. package/dist/src/observability/index.js +0 -8
  661. package/dist/src/observability/index.js.map +0 -1
  662. package/dist/src/observability/integration.d.ts +0 -32
  663. package/dist/src/observability/integration.d.ts.map +0 -1
  664. package/dist/src/observability/integration.js +0 -157
  665. package/dist/src/observability/integration.js.map +0 -1
  666. package/dist/src/observability/telemetry.d.ts +0 -137
  667. package/dist/src/observability/telemetry.d.ts.map +0 -1
  668. package/dist/src/observability/telemetry.js +0 -420
  669. package/dist/src/observability/telemetry.js.map +0 -1
  670. package/dist/src/quantization/index.d.ts +0 -7
  671. package/dist/src/quantization/index.d.ts.map +0 -1
  672. package/dist/src/quantization/index.js +0 -15
  673. package/dist/src/quantization/index.js.map +0 -1
  674. package/dist/src/quantization/vector-quantization.d.ts +0 -388
  675. package/dist/src/quantization/vector-quantization.d.ts.map +0 -1
  676. package/dist/src/quantization/vector-quantization.js +0 -1136
  677. package/dist/src/quantization/vector-quantization.js.map +0 -1
  678. package/dist/src/search/HybridSearch.d.ts +0 -311
  679. package/dist/src/search/HybridSearch.d.ts.map +0 -1
  680. package/dist/src/search/HybridSearch.js +0 -712
  681. package/dist/src/search/HybridSearch.js.map +0 -1
  682. package/dist/src/search/index.d.ts +0 -12
  683. package/dist/src/search/index.d.ts.map +0 -1
  684. package/dist/src/search/index.js +0 -16
  685. package/dist/src/search/index.js.map +0 -1
  686. package/dist/src/services/AttentionService.d.ts +0 -303
  687. package/dist/src/services/AttentionService.d.ts.map +0 -1
  688. package/dist/src/services/AttentionService.js +0 -1167
  689. package/dist/src/services/AttentionService.js.map +0 -1
  690. package/dist/src/simd/index.d.ts +0 -9
  691. package/dist/src/simd/index.d.ts.map +0 -1
  692. package/dist/src/simd/index.js +0 -27
  693. package/dist/src/simd/index.js.map +0 -1
  694. package/dist/src/simd/simd-vector-ops.d.ts +0 -332
  695. package/dist/src/simd/simd-vector-ops.d.ts.map +0 -1
  696. package/dist/src/simd/simd-vector-ops.js +0 -947
  697. package/dist/src/simd/simd-vector-ops.js.map +0 -1
  698. package/dist/src/tests/attention-service.test.d.ts +0 -7
  699. package/dist/src/tests/attention-service.test.d.ts.map +0 -1
  700. package/dist/src/tests/attention-service.test.js +0 -401
  701. package/dist/src/tests/attention-service.test.js.map +0 -1
  702. package/dist/src/tests/integration/compatibility/backwards-compat.integration.test.d.ts +0 -7
  703. package/dist/src/tests/integration/compatibility/backwards-compat.integration.test.d.ts.map +0 -1
  704. package/dist/src/tests/integration/compatibility/backwards-compat.integration.test.js +0 -283
  705. package/dist/src/tests/integration/compatibility/backwards-compat.integration.test.js.map +0 -1
  706. package/dist/src/tests/query-cache.test.d.ts +0 -7
  707. package/dist/src/tests/query-cache.test.d.ts.map +0 -1
  708. package/dist/src/tests/query-cache.test.js +0 -343
  709. package/dist/src/tests/query-cache.test.js.map +0 -1
  710. package/dist/src/tests/ruvector-integration.test.d.ts +0 -14
  711. package/dist/src/tests/ruvector-integration.test.d.ts.map +0 -1
  712. package/dist/src/tests/ruvector-integration.test.js +0 -1156
  713. package/dist/src/tests/ruvector-integration.test.js.map +0 -1
  714. package/dist/src/tests/unit/auth/crypto.utils.test.d.ts +0 -6
  715. package/dist/src/tests/unit/auth/crypto.utils.test.d.ts.map +0 -1
  716. package/dist/src/tests/unit/auth/crypto.utils.test.js +0 -310
  717. package/dist/src/tests/unit/auth/crypto.utils.test.js.map +0 -1
  718. package/dist/src/tests/unit/compatibility/deprecation-warnings.test.d.ts +0 -5
  719. package/dist/src/tests/unit/compatibility/deprecation-warnings.test.d.ts.map +0 -1
  720. package/dist/src/tests/unit/compatibility/deprecation-warnings.test.js +0 -207
  721. package/dist/src/tests/unit/compatibility/deprecation-warnings.test.js.map +0 -1
  722. package/dist/src/tests/unit/compatibility/migration-utils.test.d.ts +0 -5
  723. package/dist/src/tests/unit/compatibility/migration-utils.test.d.ts.map +0 -1
  724. package/dist/src/tests/unit/compatibility/migration-utils.test.js +0 -264
  725. package/dist/src/tests/unit/compatibility/migration-utils.test.js.map +0 -1
  726. package/dist/src/tests/unit/compatibility/v1-adapter.test.d.ts +0 -7
  727. package/dist/src/tests/unit/compatibility/v1-adapter.test.d.ts.map +0 -1
  728. package/dist/src/tests/unit/compatibility/v1-adapter.test.js +0 -228
  729. package/dist/src/tests/unit/compatibility/v1-adapter.test.js.map +0 -1
  730. package/dist/src/tests/unit/compatibility/version-detector.test.d.ts +0 -10
  731. package/dist/src/tests/unit/compatibility/version-detector.test.d.ts.map +0 -1
  732. package/dist/src/tests/unit/compatibility/version-detector.test.js +0 -162
  733. package/dist/src/tests/unit/compatibility/version-detector.test.js.map +0 -1
  734. package/dist/src/tests/vector-quantization.test.d.ts +0 -5
  735. package/dist/src/tests/vector-quantization.test.d.ts.map +0 -1
  736. package/dist/src/tests/vector-quantization.test.js +0 -338
  737. package/dist/src/tests/vector-quantization.test.js.map +0 -1
  738. package/dist/src/tests/wasm-vector-search.test.d.ts +0 -7
  739. package/dist/src/tests/wasm-vector-search.test.d.ts.map +0 -1
  740. package/dist/src/tests/wasm-vector-search.test.js +0 -193
  741. package/dist/src/tests/wasm-vector-search.test.js.map +0 -1
  742. package/dist/src/types/database.types.d.ts +0 -275
  743. package/dist/src/types/database.types.d.ts.map +0 -1
  744. package/dist/src/types/database.types.js +0 -57
  745. package/dist/src/types/database.types.js.map +0 -1
  746. package/dist/src/utils/chalk-fallback.d.ts +0 -3
  747. package/dist/src/utils/chalk-fallback.d.ts.map +0 -1
  748. package/dist/src/utils/chalk-fallback.js +0 -20
  749. package/dist/src/utils/chalk-fallback.js.map +0 -1
  750. package/dist/src/utils/crypto.utils.d.ts +0 -122
  751. package/dist/src/utils/crypto.utils.d.ts.map +0 -1
  752. package/dist/src/utils/crypto.utils.js +0 -296
  753. package/dist/src/utils/crypto.utils.js.map +0 -1
  754. package/dist/src/utils/similarity.d.ts +0 -11
  755. package/dist/src/utils/similarity.d.ts.map +0 -1
  756. package/dist/src/utils/similarity.js +0 -25
  757. package/dist/src/utils/similarity.js.map +0 -1
  758. package/dist/src/wasm-loader.d.ts +0 -67
  759. package/dist/src/wasm-loader.d.ts.map +0 -1
  760. package/dist/src/wasm-loader.js +0 -78
  761. package/dist/src/wasm-loader.js.map +0 -1
  762. package/dist/src/wrappers/agentdb-fast.d.ts +0 -139
  763. package/dist/src/wrappers/agentdb-fast.d.ts.map +0 -1
  764. package/dist/src/wrappers/agentdb-fast.js +0 -316
  765. package/dist/src/wrappers/agentdb-fast.js.map +0 -1
  766. package/dist/src/wrappers/attention-fallbacks.d.ts +0 -351
  767. package/dist/src/wrappers/attention-fallbacks.d.ts.map +0 -1
  768. package/dist/src/wrappers/attention-fallbacks.js +0 -1487
  769. package/dist/src/wrappers/attention-fallbacks.js.map +0 -1
  770. package/dist/src/wrappers/embedding-service.d.ts +0 -117
  771. package/dist/src/wrappers/embedding-service.d.ts.map +0 -1
  772. package/dist/src/wrappers/embedding-service.js +0 -376
  773. package/dist/src/wrappers/embedding-service.js.map +0 -1
  774. package/dist/src/wrappers/gnn-wrapper.d.ts +0 -71
  775. package/dist/src/wrappers/gnn-wrapper.d.ts.map +0 -1
  776. package/dist/src/wrappers/gnn-wrapper.js +0 -240
  777. package/dist/src/wrappers/gnn-wrapper.js.map +0 -1
  778. package/dist/src/wrappers/index.d.ts +0 -48
  779. package/dist/src/wrappers/index.d.ts.map +0 -1
  780. package/dist/src/wrappers/index.js +0 -83
  781. package/dist/src/wrappers/index.js.map +0 -1
package/README.md CHANGED
@@ -1,2605 +1,344 @@
1
1
  # AgentDB v3
2
2
 
3
- > Intelligent agentic vector database learns from experience, optimizes itself, runs anywhere
3
+ > **Proof-gated graph intelligence for AI agents every mutation requires cryptographic proof**
4
4
 
5
5
  [![npm version](https://img.shields.io/npm/v/agentdb.svg?style=flat-square)](https://www.npmjs.com/package/agentdb)
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
- [![MCP Compatible](https://img.shields.io/badge/MCP-41%20tools-blueviolet?style=flat-square)](docs/guides/)
10
9
 
11
- ---
12
-
13
- ## What is AgentDB?
14
-
15
- **AgentDB is a vector database that gets smarter every time you use it.**
16
-
17
- Most vector databases store and retrieve embeddings. AgentDB does that too — 150x faster — but it also watches which results your AI agent actually used, learns from that feedback, and returns better results next time. Search quality improves by up to **36% automatically**, with zero manual tuning.
18
-
19
- Everything lives in a **single Cognitive Container** (`.rvf` file) — vectors, indexes, learning state, and a cryptographic audit trail. No external services. No API keys. No monthly bills.
20
-
21
- > **3 lines to self-learning search:**
22
- > ```typescript
23
- > const backend = await SelfLearningRvfBackend.create({ learning: true, storagePath: './my.rvf' });
24
- > const results = await backend.searchAsync(query, 10); // search
25
- > backend.recordFeedback('q1', 0.9); // learn — next search is smarter
26
- > ```
27
-
28
- ### Who is it for?
29
-
30
- | If you're building... | AgentDB gives you... |
31
- | --- | --- |
32
- | **A RAG chatbot** | Search that learns which documents actually answer user questions |
33
- | **A code review agent** | Pattern memory that remembers what worked across 1000s of reviews |
34
- | **A research assistant** | Skill library that builds reusable tools from successful strategies |
35
- | **An RL-powered agent** | 9 algorithms from Q-Learning to PPO, with bandit-guided algorithm selection and transfer learning |
36
- | **A Claude Code / MCP tool** | 41 tools that plug in with one command |
37
- | **An offline or edge app** | Full vector DB in the browser via WASM — no server needed |
38
- | **An enterprise platform** | JWT auth, API key rotation, Argon2id hashing, SOC2/GDPR audit logs |
39
-
40
- ---
41
-
42
- ## Features
43
-
44
- ### Intelligence
45
-
46
- | | |
47
- | --- | --- |
48
- | **Self-Learning Search** | Gets 36% better over time — learns from feedback, no manual tuning |
49
- | **Cognitive Memory** | 6 human-inspired patterns: learn from mistakes, build reusable skills, discover what causes what |
50
- | **Decision Intelligence** | Thompson Sampling bandit auto-tunes skill selection, pattern ranking, compression tiers, and RL algorithm choice |
51
- | **9 RL Algorithms** | Q-Learning, SARSA, DQN, PPO, Actor-Critic, Policy Gradient, Decision Transformer, MCTS, Model-Based RL |
52
- | **Hybrid Search** | BM25 keyword + vector with Reciprocal Rank Fusion — exact matches + semantic understanding |
53
- | **Graph Intelligence** | Cypher queries, causal reasoning, GNN 8-head attention (+12.4% recall) |
54
-
55
- ### Performance
56
-
57
- | | |
58
- | --- | --- |
59
- | **150x Faster** | 61us search with Rust+SIMD — 800x faster than Pinecone, 160x faster than Chroma |
60
- | **4 Backends** | Auto-selects best available: RuVector (Rust) > RVF > HNSWLib (C++) > sql.js (WASM) |
61
- | **Runs Anywhere** | Node.js, browsers (WASM), edge functions, fully offline |
62
- | **AgentDBFast** | 50-200x faster programmatic API — skip CLI overhead for production workloads |
63
-
64
- ### Storage & Data
65
-
66
- | | |
67
- | --- | --- |
68
- | **Cognitive Container (RVF)** | Single `.rvf` file — vectors, index, learning state, SHAKE-256 witness chain |
69
- | **COW Branching** | Instant copy-on-write branches for experiments, with full lineage tracking |
70
- | **Compression** | 5-tier auto-tiering (hot/warm/cool/cold/archive), scalar 8-bit/4-bit, product quantization |
71
- | **Metadata Filtering** | 10 MongoDB-style operators ($eq, $gt, $in, $contains, $exists, etc.) |
72
-
73
- ### Integration & Tools
74
-
75
- | | |
76
- | --- | --- |
77
- | **41 MCP Tools** | One command to connect to Claude Code, Cursor, or any MCP-compatible assistant |
78
- | **Chat UI** | `@agentdb/chat` — deploy a self-learning RAG chatbot in one line |
79
- | **LLM Router** | Auto-selects best provider: RuvLLM (local), OpenRouter (200+ models), Gemini, Claude, ONNX |
80
- | **Real-Time Sync** | QUIC transport, multi-instance replication, 4 conflict resolution strategies |
81
-
82
- ### Enterprise & Security
83
-
84
- | | |
85
- | --- | --- |
86
- | **Auth & Audit** | JWT tokens, Argon2id hashing, API key rotation, SOC2/GDPR/HIPAA logging |
87
- | **Security** | Input validation, XSS/injection prevention, Cypher sanitization, witness chain verification |
88
- | **Observability** | OpenTelemetry traces, Prometheus metrics, structured logging |
89
- | **Benchmarking** | 5 built-in benchmarks, custom benchmark classes, Markdown/JSON reports |
90
-
91
- > **Zero config, zero cost.** `npm install agentdb` and go — fully local, no API keys, no cloud fees.
92
-
93
- ---
94
-
95
- ## Comparison
96
-
97
- > **61 microseconds.** That's 800x faster than Pinecone, 160x faster than Chroma, and the only vector database that learns from your usage and gets better over time.
98
-
99
- ### vs. Other Vector Databases
100
-
101
- #### Intelligence
102
-
103
- | Feature | AgentDB v3 | Pinecone | Chroma | Weaviate | pgvector |
104
- | --- | --- | --- | --- | --- | --- |
105
- | Self-learning pipeline | SONA + contrastive + federated + bandit | No | No | No | No |
106
- | Reinforcement learning | 9 algorithms (Q-Learning to MCTS) | No | No | No | No |
107
- | Cognitive memory | 6 patterns | No | No | No | No |
108
- | Hybrid search | BM25 + vector (RRF fusion) | No | No | BM25 only | No |
109
- | Graph queries | Cypher | No | No | GraphQL | No |
110
-
111
- #### Performance & Deployment
112
-
113
- | Feature | AgentDB v3 | Pinecone | Chroma | Weaviate | pgvector |
114
- | --- | --- | --- | --- | --- | --- |
115
- | Search latency | **61us** | ~50ms | ~10ms | ~5ms | ~2ms |
116
- | Runs offline | Full | No | Yes | Yes | Yes |
117
- | Browser (WASM) | Yes | No | No | No | No |
118
-
119
- #### Storage
120
-
121
- | Feature | AgentDB v3 | Pinecone | Chroma | Weaviate | pgvector |
122
- | --- | --- | --- | --- | --- | --- |
123
- | Cognitive Container | Single `.rvf` file + COW branching | No | No | No | No |
124
- | Monthly cost | **$0** | $70+ | $0 | $0+ | $0+ |
125
-
126
- #### Integration & Security
127
-
128
- | Feature | AgentDB v3 | Pinecone | Chroma | Weaviate | pgvector |
129
- | --- | --- | --- | --- | --- | --- |
130
- | MCP integration | 41 tools | No | No | No | No |
131
- | Auth & audit | JWT + Argon2id + compliance logs | No | No | No | No |
132
- | Local-first | Yes | Cloud only | Yes | Self-host | Postgres |
133
-
134
- ### Backend Performance
135
-
136
- | Backend | Latency | Recall@10 | Native | Best For |
137
- | --- | --- | --- | --- | --- |
138
- | **RuVector** (Rust + SIMD) | 61us | 96.8% | Yes | Production, high throughput |
139
- | **Cognitive Container** (RVF) | ~100us | 96.8% | Yes | Portable, branching, lineage |
140
- | **HNSWLib** (C++) | ~500us | 95%+ | Yes | Compatibility |
141
- | **sql.js** (WASM) | ~5ms | 90%+ | No | Zero-dependency fallback |
142
-
143
- AgentDB auto-selects the best available: RuVector > Cognitive Container (RVF) > HNSWLib > sql.js
144
-
145
- ---
146
-
147
- ## Quick Start
148
-
149
- ```bash
150
- npm install agentdb
151
- ```
152
-
153
- ### CLI — try it in 10 seconds
154
-
155
- ```bash
156
- npx agentdb init # Initialize a new database
157
- npx agentdb doctor # Check system health
158
- npx agentdb rvf status ./store.rvf # Inspect a Cognitive Container
159
- npx agentdb rvf derive ./prod.rvf ./experiment.rvf # Branch for experiments (instant, COW)
160
- npx agentdb mcp start # Start MCP server (41 tools)
161
- npx @agentdb/chat serve --rvf ./kb.rvf --port 3000 # Launch chat UI
162
- ```
163
-
164
- <details>
165
- <summary><strong>Complete CLI Reference</strong> — 60+ commands across 8 categories</summary>
166
-
167
- #### Core
168
-
169
- ```bash
170
- npx agentdb init # Initialize database
171
- npx agentdb status # System status and diagnostics
172
- npx agentdb doctor [--fix] [--verbose] # Health check with auto-fix
173
- ```
174
-
175
- #### Cognitive Container (RVF) Management
176
-
177
- ```bash
178
- npx agentdb rvf status ./store.rvf # Container statistics
179
- npx agentdb rvf compact ./store.rvf # Reclaim space
180
- npx agentdb rvf derive ./src.rvf ./dst.rvf # COW branch
181
- npx agentdb rvf segments ./store.rvf # Segment introspection
182
- npx agentdb rvf detect # SDK availability
183
- ```
184
-
185
- #### Learning & Training
186
-
187
- ```bash
188
- npx agentdb learn --session <id> --train # Train a learning session
189
- npx agentdb learn --status # Learning system status
190
- ```
191
-
192
- #### Routing
193
-
194
- ```bash
195
- npx agentdb route --query "search term" # Test semantic routing
196
- npx agentdb route --list # Show learned intents
197
- ```
198
-
199
- #### Attention & Hyperbolic
200
-
201
- ```bash
202
- npx agentdb attention --benchmark # Attention performance test
203
- npx agentdb hyperbolic --test # Hyperbolic embedding test
204
- ```
205
-
206
- #### Simulation
207
-
208
- ```bash
209
- npx agentdb simulate hnsw --iterations 3 # HNSW optimization
210
- npx agentdb simulate attention --iterations 3 # GNN attention
211
- npx agentdb simulate self-organizing --days 30 # Self-healing
212
- npx agentdb simulate --wizard # Interactive wizard
213
- npx agentdb simulate --custom ./my-scenario.json # Custom simulation
214
- npx agentdb simulate --report ./output.md # Generate report
215
- ```
216
-
217
- #### Migration & Import
218
-
219
- ```bash
220
- npx agentdb migrate --source ./old.db --target ./new.db # Full migration
221
- npx agentdb migrate --to rvf --rvf-path ./out.rvf # Export to Cognitive Container
222
- npx agentdb migrate --dry-run --verbose # Preview changes
223
- ```
224
-
225
- #### MCP Server
226
-
227
- ```bash
228
- npx agentdb mcp start # Start MCP server (41 tools)
229
- npx agentdb mcp start --port 8080 # Custom port
230
- ```
231
-
232
- </details>
233
-
234
- ### Self-Learning Vector Search (the differentiator)
235
-
236
- Most vector databases return the same results no matter how many times you query them. AgentDB closes the loop: after every search, you tell it which results were actually useful. A contrastive trainer (InfoNCE + hard-negative mining) adjusts a lightweight LoRA adapter in under 1 ms, and EWC++ consolidation keeps old knowledge intact. Over 500 feedback cycles, recall jumps from 54% to 90% — automatically.
237
-
238
- ```typescript
239
- import { SelfLearningRvfBackend } from 'agentdb/backends/rvf/SelfLearningRvfBackend';
240
-
241
- // Create a self-learning Cognitive Container
242
- const backend = await SelfLearningRvfBackend.create({
243
- dimension: 384,
244
- metric: 'cosine',
245
- storagePath: './knowledge.rvf',
246
- learning: true, // enable the learning pipeline
247
- });
248
-
249
- // Insert documents
250
- await backend.insertAsync('doc-1', embedding, { title: 'Auth Guide' });
251
- await backend.insertAsync('doc-2', embedding2, { title: 'API Reference' });
252
-
253
- // Search — automatically routed through the learning pipeline
254
- const results = await backend.searchAsync(queryEmbedding, 10);
255
-
256
- // Tell AgentDB which results were useful — this drives learning
257
- backend.recordFeedback('query-1', 0.95); // great result
258
- backend.recordFeedback('query-2', 0.2); // poor result
259
-
260
- // Run a learning tick — trains the model, updates adapters
261
- await backend.tick();
262
- // Next search will be smarter based on your feedback
263
- ```
264
-
265
- ### Cognitive Memory (pattern learning)
266
-
267
- Store and retrieve reasoning patterns — your agent remembers what worked:
268
-
269
- ```typescript
270
- import { createDatabase, ReasoningBank, EmbeddingService } from 'agentdb';
271
-
272
- const db = await createDatabase('./agent-memory.db');
273
- const embedder = new EmbeddingService({ model: 'Xenova/all-MiniLM-L6-v2' });
274
- await embedder.initialize();
275
-
276
- const reasoningBank = new ReasoningBank(db, embedder);
277
-
278
- // Store what your agent learned
279
- await reasoningBank.storePattern({
280
- taskType: 'code_review',
281
- approach: 'Security-first analysis',
282
- successRate: 0.95,
283
- });
284
-
285
- // Find similar successful patterns
286
- const patterns = await reasoningBank.searchPatterns({
287
- task: 'security code review',
288
- k: 10,
289
- });
290
- ```
291
-
292
- ### Chat UI (one-line deployment)
293
-
294
- Deploy a self-learning RAG chatbot over any Cognitive Container:
295
-
296
- ```bash
297
- npx @agentdb/chat serve --rvf ./kb.rvf --port 3000
298
- ```
299
-
300
- ---
301
-
302
- ## How the Learning Loop Works
303
-
304
- Every search automatically triggers a learning cycle. No configuration needed — just call `recordFeedback()` after using results:
305
-
306
- ```mermaid
307
- graph LR
308
- A["Your Query"] --> B["Semantic Router<br/>classifies intent"]
309
- B --> C["Embedding Adapter<br/>adjusts in <1ms"]
310
- C --> D["HNSW Search<br/>61us, 96.8% recall"]
311
- D --> E["Results"]
312
- E --> F["Your Feedback<br/>0.0 - 1.0"]
313
- F --> G["Contrastive Trainer<br/>learns what's good"]
314
- G --> C
315
- style G fill:#2d6,stroke:#1a4,color:#fff
316
- style A fill:#36f,stroke:#24d,color:#fff
317
- ```
318
-
319
- > **Result:** Over 10 sessions with 50 episodes each, search quality improved from 54% to 90% — a 36% gain with zero manual tuning.
320
-
321
- ## Architecture
322
-
323
- ```mermaid
324
- graph TD
325
- A[Your Application] --> B[AgentDB Core]
326
- B --> C[Cognitive Memory<br/>6 patterns]
327
- B --> D[Self-Learning Pipeline<br/>SONA + Contrastive + Federated]
328
- B --> E[Backend Auto-Selection]
329
- E --> F[RuVector<br/>Rust+SIMD 61us]
330
- E --> G[Cognitive Container<br/>RVF single-file COW]
331
- E --> H[HNSWLib<br/>C++ HNSW]
332
- E --> I[sql.js<br/>WASM fallback]
333
- B --> J[NativeAccelerator<br/>15 capability groups]
334
- B --> K[MCP Server<br/>41 tools]
335
- B --> L[Graph Intelligence<br/>Cypher + GNN]
336
- ```
337
-
338
- ---
339
-
340
- ## MCP Integration
341
-
342
- > **One command** to give any AI assistant access to self-learning vector search, cognitive memory, and 37 specialized tools.
343
-
344
- Connect AgentDB to Claude Code, Cursor, or any MCP-compatible AI assistant:
345
-
346
- ```bash
347
- claude mcp add agentdb npx agentdb mcp start
348
- ```
349
-
350
- Or add to `~/.config/claude/claude_desktop_config.json`:
351
-
352
- ```json
353
- {
354
- "mcpServers": {
355
- "agentdb": {
356
- "command": "npx",
357
- "args": ["agentdb", "mcp", "start"],
358
- "env": { "AGENTDB_PATH": "./agentdb.db" }
359
- }
360
- }
361
- }
362
- ```
363
-
364
- ### MCP Tools Overview
365
-
366
- | Category | Tools | Examples |
367
- | --- | --- | --- |
368
- | **Core DB** | 6 | init, insert, batch insert, search, delete, stats |
369
- | **Patterns** | 4 | store, search, batch store, statistics |
370
- | **Memory** | 9 | reflexion store/retrieve/batch, skill create/search/batch, causal edges/queries, nightly learner |
371
- | **Learning** | 10 | RL sessions, predictions, feedback, training, transfer learning, explainability |
372
- | **Recall** | 2 | explainable recall with provenance certificates, cache management |
373
- | **Solver** | 4 | solver train, acceptance testing, policy inspection, witness chain audit |
374
- | **Admin** | 6 | diagnostics, migration, pruning, experience recording, reward signals, legacy stats |
375
-
376
- All 41 tools support parallel execution markers, batch operations, intelligent caching, and format parameters for token reduction.
377
-
378
- ---
379
-
380
- ## Chat Ecosystem
381
-
382
- The `@agentdb/chat` package provides a one-line chat UI with self-learning RAG built on top of AgentDB:
383
-
384
- ```bash
385
- # Serve a chat interface over your knowledge base
386
- npx @agentdb/chat serve --rvf ./kb.rvf --port 3000
387
- ```
388
-
389
- Programmatic usage:
390
-
391
- ```typescript
392
- import { createChatServer } from '@agentdb/chat';
393
-
394
- const server = await createChatServer('./kb.rvf', {
395
- port: 3000,
396
- learning: true,
397
- });
398
- ```
399
-
400
- The chat ecosystem includes:
401
- - **Chat Server** — streaming inference with any LLM provider
402
- - **Chat Persistence** — conversation history stored in Cognitive Containers
403
- - **MCP Bridge** — expose all 37 AgentDB tools through chat
404
- - **Chat UI** (`@agentdb/chat-ui`) — SvelteKit frontend with real-time tool invocation
405
-
406
- See the [@agentdb/chat README](../agentdb-chat/README.md) for full documentation.
407
-
408
- ---
409
-
410
- ## Deep Dives
411
-
412
- > Expand any section below for code examples, configuration, and architecture details.
413
-
414
- **Getting Started** | [Guides](#guides) | [Tutorials](#tutorials) | [Advanced Usage](#advanced-usage)
415
-
416
- **Intelligence & Learning** | [Self-Learning Pipeline](#self-learning-pipeline) | [Cognitive Memory](#cognitive-memory-patterns) | [Reinforcement Learning](#reinforcement-learning) | [Hybrid Search](#hybrid-search) | [Graph Intelligence](#graph-intelligence) | [Query Lifecycle](#query-lifecycle)
417
-
418
- **Performance & Architecture** | [SIMD Acceleration](#simd--native-acceleration) | [Browser & WASM](#browser--wasm-deployment) | [Benchmarks](#performance--benchmarks) | [AgentDBFast](#agentdbfast) | [Benchmark Suite](#benchmark-suite)
419
-
420
- **Storage & Data** | [Cognitive Container (RVF)](#cognitive-container-rvf-format) | [Quantization](#quantization--compression) | [Metadata Filtering](#metadata-filtering)
421
-
422
- **Integration & Tools** | [LLM Router](#llm-router) | [Model Import/Export](#model-importexport--embedding-models) | [Multi-Database Sync](#multi-database-coordination) | [Real-Time Sync](#real-time-sync-quic)
423
-
424
- **Enterprise & Security** | [Security](#security) | [Auth & Audit](#auth--audit) | [Observability](#observability)
425
-
426
- ---
427
-
428
- ### Getting Started
429
-
430
- Step-by-step guides, tutorials, and advanced configuration for every skill level.
431
-
432
- <details>
433
- <summary><strong>Guides</strong> — backend selection, migration, health checks, federated learning</summary>
434
-
435
- #### Backend Selection
436
-
437
- ```bash
438
- # Auto-detect best backend (recommended)
439
- npx agentdb init --backend auto
440
-
441
- # Force RuVector (fastest, requires native bindings)
442
- npx agentdb init --backend ruvector
443
-
444
- # Force Cognitive Container (single-file, portable)
445
- npx agentdb init --backend rvf --rvf-path ./vectors.rvf
446
-
447
- # Force HNSWLib (C++ HNSW)
448
- npx agentdb init --backend hnswlib
449
- ```
450
-
451
- #### Migration
452
-
453
- ```bash
454
- # Migrate v1 -> v2 -> v3
455
- npx agentdb migrate --source ./old.db --target ./new.db
456
-
457
- # Export to Cognitive Container
458
- npx agentdb migrate --to rvf --rvf-path ./vectors.rvf
459
-
460
- # Dry-run migration
461
- npx agentdb migrate --dry-run --verbose
462
- ```
463
-
464
- #### Health Checks
465
-
466
- ```bash
467
- # Full diagnostic
468
- npx agentdb doctor --verbose
469
-
470
- # Check specific Cognitive Container
471
- npx agentdb doctor --rvf-path ./vectors.rvf
472
-
473
- # Auto-fix issues
474
- npx agentdb doctor --fix
475
- ```
476
-
477
- #### Federated Learning Setup
478
-
479
- Configure cross-session federated learning for continuous improvement:
480
-
481
- ```typescript
482
- import { FederatedLearningCoordinator, EphemeralLearningAgent } from 'agentdb/services/federated-learning';
483
-
484
- const coordinator = new FederatedLearningCoordinator({
485
- agentId: 'coordinator-1',
486
- minQuality: 0.7,
487
- maxAgents: 100,
488
- });
489
-
490
- const agent = new EphemeralLearningAgent({
491
- agentId: 'session-agent-1',
492
- qualityFiltering: true,
493
- });
494
-
495
- const state = agent.exportState();
496
- await coordinator.aggregate(state);
497
- const merged = await coordinator.consolidate();
498
- ```
499
-
500
- </details>
501
-
502
- ---
503
-
504
- <details>
505
- <summary><strong>Tutorials</strong> — 6 step-by-step walkthroughs from beginner to advanced</summary>
506
-
507
- #### Tutorial 1: Build a Learning Code Review Agent
508
-
509
- ```typescript
510
- import { createDatabase, ReasoningBank, ReflexionMemory, EmbeddingService } from 'agentdb';
511
-
512
- const db = await createDatabase('./code-reviewer.db');
513
- const embedder = new EmbeddingService({ model: 'Xenova/all-MiniLM-L6-v2' });
514
- await embedder.initialize();
515
-
516
- const reasoningBank = new ReasoningBank(db, embedder);
517
- const reflexion = new ReflexionMemory(db, embedder);
518
-
519
- await reasoningBank.storePattern({
520
- taskType: 'code_review',
521
- approach: 'Security scan > Type safety > Code quality > Performance',
522
- successRate: 0.94,
523
- });
524
-
525
- const result = await performCodeReview(code);
526
- await reflexion.storeEpisode({
527
- sessionId: 'review-1',
528
- task: 'Review authentication PR',
529
- reward: result.issuesFound > 0 ? 0.9 : 0.6,
530
- success: true,
531
- critique: 'Found SQL injection — security checks work!',
532
- input: code,
533
- output: result.findings,
534
- });
535
-
536
- const pastReviews = await reflexion.retrieveRelevant({
537
- task: 'authentication code review',
538
- k: 5,
539
- onlySuccesses: true,
540
- });
541
- ```
542
-
543
- #### Tutorial 2: RAG with Self-Learning Skills
544
-
545
- ```typescript
546
- import { createDatabase, SkillLibrary, EmbeddingService } from 'agentdb';
547
-
548
- const db = await createDatabase('./rag-system.db');
549
- const embedder = new EmbeddingService({ model: 'Xenova/all-MiniLM-L6-v2' });
550
- await embedder.initialize();
551
-
552
- const skills = new SkillLibrary(db, embedder);
553
-
554
- await skills.createSkill({
555
- name: 'expand_query',
556
- description: 'Expand user query with domain-specific synonyms',
557
- signature: { inputs: { query: 'string' }, outputs: { expanded: 'string[]' } },
558
- code: `const map = { 'bug': ['issue', 'defect', 'error'] }; ...`,
559
- successRate: 0.92,
560
- });
561
-
562
- const applicable = await skills.searchSkills({ task: 'find technical documentation', k: 10 });
563
- ```
564
-
565
- #### Tutorial 3: Run Latent Space Simulations
566
-
567
- ```bash
568
- npx agentdb simulate hnsw --iterations 3
569
- npx agentdb simulate attention --iterations 3
570
- npx agentdb simulate self-organizing --days 30
571
- npx agentdb simulate --wizard
572
- ```
573
-
574
- #### Tutorial 4: Cognitive Container Branching
575
-
576
- ```typescript
577
- import { RvfBackend } from 'agentdb/backends/rvf/RvfBackend';
578
-
579
- const main = new RvfBackend({ dimension: 384, metric: 'cosine', storagePath: './main.rvf' });
580
- await main.initialize();
581
- await main.insertAsync('doc-1', embedding1, { source: 'production' });
582
- await main.flush();
583
-
584
- // Branch for experiment (copy-on-write, near-instant)
585
- const experiment = await main.derive('./experiment.rvf');
586
- await experiment.insertAsync('doc-exp-1', experimentEmbedding);
587
- console.log(`Lineage depth: ${await experiment.lineageDepth()}`);
588
- ```
589
-
590
- #### Tutorial 5: Self-Learning RAG Pipeline
591
-
592
- ```typescript
593
- import { SelfLearningRvfBackend } from 'agentdb/backends/rvf/SelfLearningRvfBackend';
594
-
595
- const backend = await SelfLearningRvfBackend.create({
596
- dimension: 384, metric: 'cosine', storagePath: './rag-vectors.rvf',
597
- learning: true, federated: true,
598
- });
599
-
600
- for (const doc of documents) {
601
- await backend.insertAsync(doc.id, doc.embedding, { title: doc.title });
602
- }
603
-
604
- const results = await backend.searchAsync(queryEmbedding, 10);
605
- backend.recordFeedback('query-1', 0.95);
606
- await backend.tick();
607
- ```
608
-
609
- #### Tutorial 6: Chat UI with Custom Knowledge Base
610
-
611
- ```bash
612
- npx agentdb init --backend rvf --rvf-path ./docs.rvf
613
- npx agentdb import ./docs/ --rvf-path ./docs.rvf
614
- npx @agentdb/chat serve --rvf ./docs.rvf --port 3000
615
- ```
616
-
617
- </details>
618
-
619
- ---
620
-
621
- <details>
622
- <summary><strong>Advanced Usage</strong> — batch ops, caching, solver tuning, GNN training, context synthesis</summary>
623
-
624
- #### Batch Operations
625
-
626
- ```typescript
627
- import { BatchOperations } from 'agentdb/optimizations/BatchOperations';
628
-
629
- const batchOps = new BatchOperations(db, embedder, {
630
- batchSize: 100, parallelism: 4,
631
- progressCallback: (done, total) => console.log(`${done}/${total}`),
632
- });
633
-
634
- await batchOps.insertSkills([...skills]);
635
- await batchOps.insertEpisodes([...episodes]);
636
- await batchOps.insertPatterns([...patterns]);
637
- ```
638
-
639
- #### Custom Backend Selection
640
-
641
- ```typescript
642
- import { createBackend, detectBackends } from 'agentdb/backends/factory';
643
-
644
- const detection = await detectBackends();
645
- // { ruvector: { available, native, gnn }, rvf: { sdk, node, wasm }, hnswlib: { available } }
646
-
647
- const backend = await createBackend({ type: 'rvf', dimension: 384, metric: 'cosine', storagePath: './vectors.rvf' });
648
- ```
649
-
650
- #### Adaptive Index Tuning
651
-
652
- ```typescript
653
- import { AgentDBSolver } from 'agentdb/backends/rvf/RvfSolver';
654
-
655
- const solver = await AgentDBSolver.create();
656
- const trainResult = solver.train({ count: 50, minDifficulty: 1, maxDifficulty: 10 });
657
- const policy = solver.policy();
658
- // 18 context buckets (3 range x 3 distractor x 2 noise)
659
- ```
660
-
661
- #### Federated Session Manager
662
-
663
- ```typescript
664
- import { FederatedLearningCoordinator, EphemeralLearningAgent } from 'agentdb/services/federated-learning';
665
-
666
- const coordinator = new FederatedLearningCoordinator({ agentId: 'coord-main', minQuality: 0.7, maxAgents: 100 });
667
- const sessionAgent = new EphemeralLearningAgent({ agentId: `session-${Date.now()}`, qualityFiltering: true });
668
-
669
- await sessionAgent.processTask(embedding, 0.9);
670
- const state = sessionAgent.exportState();
671
- await coordinator.aggregate(state);
672
- const merged = await coordinator.consolidate();
673
- ```
674
-
675
- #### Context Synthesizer
676
-
677
- ```typescript
678
- import { ContextSynthesizer } from 'agentdb/controllers/ContextSynthesizer';
679
-
680
- const synthesizer = new ContextSynthesizer();
681
- const context = await synthesizer.synthesize(memories);
682
- // { summary, patterns, successRate, averageReward, recommendations, keyInsights }
683
- ```
684
-
685
- #### GNN Learning Backend
686
-
687
- ```typescript
688
- import { LearningBackend } from 'agentdb/backends/LearningBackend';
689
-
690
- const learner = new LearningBackend({ dimension: 384 });
691
- const enhanced = learner.enhance(queryEmbedding, neighborEmbeddings, weights);
692
- learner.addSample(embedding, 'positive', 1.0, { source: 'feedback' });
693
- const result = await learner.train(10);
694
- // { epochs: 10, finalLoss: 0.023, improvement: 15.2, durationMs: 340 }
695
- ```
696
-
697
- </details>
698
-
699
- ---
700
-
701
- ### Intelligence & Learning
702
-
703
- How AgentDB learns, reasons, and improves over time — from self-learning search to reinforcement learning and causal graphs.
704
-
705
- <details>
706
- <summary><strong>Self-Learning Pipeline</strong> — how search improves 36% automatically</summary>
707
-
708
- AgentDB's self-learning pipeline continuously improves search quality through a six-phase cycle:
709
-
710
- ```mermaid
711
- flowchart LR
712
- Q[Query] --> R[Semantic Router]
713
- R --> S[SONA Enhancement]
714
- S --> T[HNSW Search]
715
- T --> U[Results]
716
- U --> V[Feedback]
717
- V --> W[Contrastive Trainer<br/>InfoNCE + Hard Negatives]
718
- W --> X[Micro-LoRA Update]
719
- X --> Y[EWC++ Consolidation]
720
- Y --> Z[Federated Aggregation]
721
- ```
722
-
723
- ### 1. Semantic Query Routing
724
-
725
- The `SemanticQueryRouter` classifies query intent by comparing against learned intent centroids using efficient min-heap top-k selection (O(n log k)). It lazily loads `@ruvector/router` for sub-millisecond HNSW routing and falls back to brute-force cosine with pre-computed norms when native bindings aren't available.
726
-
727
- The router also selects the adaptive ef-search arm for the query. Four ef-search levels (50, 100, 200, 400) are chosen based on the solver's Thompson Sampling policy for the matching context bucket.
728
-
729
- ```typescript
730
- // Router learns intents from usage patterns
731
- router.addIntent('technical_search', embedding); // up to 100 exemplars per intent
732
- router.addIntent('conversational', embedding);
733
- const { intent, confidence } = await router.route(queryEmbedding, k);
734
-
735
- // Router state persists across restarts (debounced 5s save)
736
- // Max 1,000 intents, JSON fallback or native persistence
737
- ```
738
-
739
- ### 2. SONA Enhancement
740
-
741
- Context enrichment from trajectory history. The SONA engine (`@ruvector/sona`) tracks query trajectories and enriches embeddings with session context before search. SONA also applies the base LoRA adapter to the query embedding, adjusting it in sub-millisecond time based on learned patterns.
742
-
743
- ### 3. Contrastive Training
744
-
745
- InfoNCE contrastive loss with hard negative mining inspired by NV-Retriever's positive-aware filtering:
746
-
747
- - **Loss function:** `L = -log(exp(sim(anchor, positive) / τ) / Σ exp(sim(anchor, negative_i) / τ))`
748
- - **Hard negative filtering:** Rejects candidates where `sim(candidate, positive) > 0.85`, eliminating ~70% of false negatives
749
- - **3-stage curriculum:** Progressively increases difficulty — negatives per sample (4 → 8 → 16), hardness threshold (0.5 → 0.3 → 0.1), 100 batches per stage
750
- - **AdamW optimizer:** β1=0.9, β2=0.999, decoupled weight decay, full bias correction
751
- - **Temperature:** Bounded 0.01-1.0 (default: 0.07)
752
-
753
- ```typescript
754
- // ContrastiveTrainer handles hard negative mining automatically
755
- const result = trainer.trainBatch([
756
- { anchor: queryEmb, positive: goodResultEmb, negatives: [badResult1, badResult2] },
757
- ]);
758
- // result: { loss, gradients, batchSize }
759
- ```
760
-
761
- When native SIMD is available, cosine similarity and AdamW steps delegate to the NativeAccelerator for hardware-accelerated computation.
762
-
763
- ### 4. Micro-LoRA Adaptation
764
-
765
- Sub-millisecond embedding adjustment per query. A lightweight projection matrix (W: d×d + bias: d) is applied to the query embedding before search, specializing for each user's query patterns without modifying the base model. LoRA adapters are updated after each contrastive training batch.
766
-
767
- ### 5. EWC++ Consolidation
768
-
769
- Elastic Weight Consolidation prevents catastrophic forgetting by penalizing changes to important parameters. The Fisher information matrix is updated incrementally via the NativeAccelerator's `ewcUpdateFisher()` and penalty is computed via `ewcPenalty()`, ensuring previously learned patterns survive new training.
770
-
771
- ### 6. Federated Session Aggregation
772
-
773
- Cross-session LoRA merging for continuous improvement. Lightweight `EphemeralLearningAgent` instances (~5MB each) export their state to a `FederatedLearningCoordinator` for quality-filtered aggregation (minimum quality threshold: 0.7, up to 100 agents).
774
-
775
- ### How `tick()` Works
776
-
777
- Each learning tick performs these steps in sequence:
778
-
779
- 1. **Flush SONA** — persist trajectory context
780
- 2. **Train contrastive batch** — 32 samples from recorded feedback
781
- 3. **Train solver** — 50 puzzles to update Thompson Sampling policy
782
- 4. **Decay access frequencies** — multiply by 0.99, prune entries below 0.001 (every 50 ticks)
783
- 5. **Update temporal compressor** — adjust compression tiers
784
- 6. **Assess health** — latency tracking via health monitor
785
- 7. **Consolidate federated state** — merge distributed agent states
786
- 8. **Acceptance check** — every 100 ticks, run A/B/C ablation (mode A: fixed heuristic, mode B: compiler-suggested, mode C: learned Thompson Sampling) to validate adaptive ef-search
787
-
788
- ### Full Example
789
-
790
- ```typescript
791
- import { SelfLearningRvfBackend } from 'agentdb/backends/rvf/SelfLearningRvfBackend';
792
-
793
- const backend = await SelfLearningRvfBackend.create({
794
- dimension: 384,
795
- metric: 'cosine',
796
- storagePath: './vectors.rvf',
797
- learning: true,
798
- federated: true,
799
- positiveThreshold: 0.7,
800
- negativeThreshold: 0.3,
801
- trainingBatchSize: 32,
802
- tickIntervalMs: 5000,
803
- });
804
-
805
- // Insert vectors
806
- await backend.insertAsync('doc-1', embedding, { source: 'docs' });
807
-
808
- // Search (automatically enhanced by SONA + router)
809
- const results = await backend.searchAsync(queryEmbedding, 10);
810
-
811
- // Record feedback to drive learning
812
- backend.recordFeedback('query-123', 0.9); // high quality result
813
-
814
- // Run a learning tick (contrastive training + LoRA update + EWC consolidation)
815
- await backend.tick();
816
-
817
- // Check learning progress
818
- const stats = backend.getLearningStats();
819
- console.log(`Trajectories: ${stats.trajectoryCount}, LoRA rank: ${stats.loraRank}`);
820
- ```
821
-
822
- </details>
823
-
824
- ---
825
-
826
- <details>
827
- <summary><strong>Cognitive Memory Patterns</strong> — 6 ways your agent learns like a human</summary>
828
-
829
- AgentDB implements six cognitive memory patterns inspired by how humans learn:
830
-
831
- ### 1. ReasoningBank — Pattern Learning
832
-
833
- Store successful reasoning patterns and retrieve them by semantic similarity. The system learns which approaches work best for different task types.
834
-
835
- ```typescript
836
- await reasoningBank.storePattern({
837
- taskType: 'bug_investigation',
838
- approach: 'Check logs > Reproduce > Binary search for root cause',
839
- successRate: 0.92,
840
- tags: ['debugging', 'systematic'],
841
- });
842
-
843
- const patterns = await reasoningBank.searchPatterns({
844
- task: 'debug memory leak',
845
- k: 10,
846
- threshold: 0.7,
847
- });
848
- ```
849
-
850
- ### 2. Reflexion Memory — Learn from Experience
851
-
852
- Store complete task episodes with self-generated critiques, then replay them to improve future performance. Based on Shinn et al., 2023.
853
-
854
- ```typescript
855
- await reflexion.storeEpisode({
856
- sessionId: 'session-1',
857
- task: 'Fix authentication bug',
858
- reward: 0.95,
859
- success: true,
860
- critique: 'OAuth2 PKCE flow was more secure than basic flow',
861
- input: 'Users cannot log in',
862
- output: 'Working OAuth2 implementation',
863
- latencyMs: 1200,
864
- tokensUsed: 500,
865
- });
866
-
867
- const similar = await reflexion.retrieveRelevant({
868
- task: 'authentication issues',
869
- k: 10,
870
- onlySuccesses: true,
871
- });
872
- ```
873
-
874
- ### 3. Skill Library — Lifelong Learning
875
-
876
- Transform successful patterns into reusable, composable skills that improve over time.
877
-
878
- ```typescript
879
- await skills.createSkill({
880
- name: 'jwt_authentication',
881
- description: 'Generate and validate JWT tokens',
882
- signature: { inputs: { userId: 'string' }, outputs: { token: 'string' } },
883
- code: 'implementation...',
884
- successRate: 0.92,
885
- });
886
-
887
- const applicable = await skills.searchSkills({
888
- task: 'user authentication',
889
- k: 5,
890
- minSuccessRate: 0.7,
891
- });
892
- ```
893
-
894
- ### 4. Causal Memory Graph — Intervention Causality
895
-
896
- Track `p(y|do(x))` using doubly robust estimation. Learn what interventions cause what outcomes.
897
-
898
- ```typescript
899
- import { CausalMemoryGraph } from 'agentdb';
900
-
901
- const causalGraph = new CausalMemoryGraph(db);
902
-
903
- const experimentId = causalGraph.createExperiment({
904
- name: 'test_error_handling',
905
- hypothesis: 'Try-catch reduces crash rate',
906
- treatmentId: 123,
907
- treatmentType: 'episode',
908
- controlId: 124,
909
- startTime: Date.now(),
910
- sampleSize: 0,
911
- status: 'running',
912
- });
913
-
914
- const { uplift, pValue } = causalGraph.calculateUplift(experimentId);
915
- ```
916
-
917
- ### 5. Explainable Recall — Provenance Certificates
918
-
919
- Every retrieval comes with a cryptographic Merkle proof explaining why specific memories were selected.
920
-
921
- ```typescript
922
- const result = await causalRecall.recall(
923
- 'query-123',
924
- 'How to optimize API response time',
925
- 12,
926
- ['performance'],
927
- 'internal',
928
- );
929
-
930
- console.log(`Certificate: ${result.certificate.id}`);
931
- console.log(`Completeness: ${result.certificate.completenessScore}`);
932
- ```
933
-
934
- ### 6. Nightly Learner — Automated Discovery
935
-
936
- Background process that discovers causal patterns, consolidates skills, and prunes low-quality data automatically.
937
-
938
- ```typescript
939
- const learner = new NightlyLearner(db, embedder);
940
- const discovered = await learner.discover({
941
- minAttempts: 3,
942
- minSuccessRate: 0.6,
943
- minConfidence: 0.7,
944
- dryRun: false,
945
- });
946
- ```
947
-
948
- </details>
949
-
950
- ---
951
-
952
- ### Storage & Data
953
-
954
- How AgentDB stores vectors, manages compression tiers, and provides MongoDB-style filtering — all in a single Cognitive Container.
955
-
956
- <details>
957
- <summary><strong>Cognitive Container (RVF Format)</strong> — single-file storage with crash safety and branching</summary>
958
-
959
- The **Cognitive Container** is AgentDB's native storage format (`.rvf` — RuVector Format). It packs vectors, indexes, learning state, and a cryptographic witness chain into a single file with crash safety, progressive indexing, and full lineage tracking.
960
-
961
- ### Structure
962
-
963
- ```mermaid
964
- graph TB
965
- subgraph "store.rvf"
966
- H[Header + Magic Bytes]
967
- S1[Segment 1<br/>Vectors + Metadata]
968
- S2[Segment 2]
969
- IX[HNSW Index<br/>Progressive]
970
- WC[Witness Chain<br/>SHAKE-256]
971
- LN[Lineage Record<br/>Parent ID + Depth]
972
- end
973
- H --> S1
974
- S1 --> S2
975
- S2 --> IX
976
- IX --> WC
977
- WC --> LN
978
- ```
979
-
980
- ### Key Capabilities
981
-
982
- | Feature | Description |
983
- | --- | --- |
984
- | **Single-file** | Everything in one Cognitive Container (`.rvf`) — vectors, index, metadata |
985
- | **Crash-safe** | Append-only log with checksums, safe concurrent access |
986
- | **COW Branching** | Create copy-on-write branches for experiments (near-instant) |
987
- | **Lineage Tracking** | `fileId()`, `parentId()`, `lineageDepth()` for file-level provenance |
988
- | **Progressive Indexing** | 3-layer HNSW quality tiers, index builds incrementally as data arrives |
989
- | **Witness Chains** | SHAKE-256 cryptographic verification (73 bytes per entry) |
990
- | **Filter Expressions** | 11 operators for metadata filtering, max 64 depth |
991
- | **Auto-Compaction** | `compact()` reclaims space, reports segments compacted & bytes reclaimed |
992
- | **Readonly Mode** | `openReadonly()` for concurrent readers without locks |
993
- | **Segment Introspection** | `segments()` returns id, type, and payload length per segment |
994
- | **Kernel Embedding** | Embed unikernel images directly into Cognitive Containers |
995
- | **eBPF Embedding** | Embed and extract eBPF bytecode for programmable queries |
996
-
997
- ### Configuration
998
-
999
- ```typescript
1000
- const backend = new RvfBackend({
1001
- dimension: 384,
1002
- metric: 'cosine', // 'cosine' | 'l2' | 'dotproduct'
1003
- storagePath: './vectors.rvf',
1004
- rvfBackend: 'auto', // 'auto' | 'node' (N-API) | 'wasm' (browser)
1005
- batchThreshold: 100, // Auto-flush after N sync inserts (1-10,000)
1006
- compression: 'none', // 'none' (fp32) | 'scalar' (int8) | 'product' (PQ)
1007
- hardwareProfile: 0, // 0=Generic | 1=Core | 2=Hot | 3=Full
1008
- enableStats: true, // Track insert/search/flush/compaction timing
1009
- });
1010
- ```
1011
-
1012
- **Hardware profiles** tune internal parameters for your deployment:
1013
-
1014
- | Profile | Level | Best For |
1015
- | --- | --- | --- |
1016
- | Generic (0) | Conservative defaults | Unknown hardware |
1017
- | Core (1) | Balanced throughput/latency | Developer machines |
1018
- | Hot (2) | Aggressive caching | High-throughput servers |
1019
- | Full (3) | Maximum parallelism | Dedicated vector search |
1020
-
1021
- ### Witness Chains
1022
-
1023
- Every mutation is recorded in a tamper-evident SHAKE-256 witness chain (73 bytes per entry). This provides cryptographic proof that data has not been modified after the fact:
1024
-
1025
- ```typescript
1026
- const result = backend.verifyWitnessChain();
1027
- // { valid: true, entries: 1042, algorithm: 'SHAKE-256' }
1028
-
1029
- // Verification uses @ruvector/rvf-wasm: rvf_witness_verify(), rvf_witness_count()
1030
- ```
1031
-
1032
- ### Filter Expressions
1033
-
1034
- RVF supports 11 filter operators for metadata-filtered search. Filters are serialized to a compact field-ID format with a maximum depth of 64 expressions for security:
1035
-
1036
- ```typescript
1037
- import { FilterBuilder } from 'agentdb/backends/rvf/FilterBuilder';
1038
-
1039
- const filter = new FilterBuilder()
1040
- .eq('status', 'active')
1041
- .gt('score', 0.5)
1042
- .range('timestamp', startDate, endDate)
1043
- .in('category', ['research', 'engineering'])
1044
- .build();
1045
-
1046
- const results = await backend.searchAsync(queryVector, 10, { filter });
1047
-
1048
- // Also supports filter-based deletion
1049
- await backend.deleteByFilter(filter);
1050
- ```
1051
-
1052
- **Available operators:** `eq`, `ne`, `lt`, `le`, `gt`, `ge`, `in`, `range`, `and`, `or`, `not`
1053
-
1054
- ### Performance Stats
1055
-
1056
- The RVF backend tracks detailed performance counters:
1057
-
1058
- ```typescript
1059
- const stats = backend.getPerformanceStats();
1060
- // {
1061
- // insertCount: 10432, insertTotalMs: 521.6, avgInsertMs: 0.05,
1062
- // searchCount: 8891, searchTotalMs: 178.2, avgSearchMs: 0.02,
1063
- // flushCount: 104, compactionCount: 3
1064
- // }
1065
- ```
1066
-
1067
- ### Kernel & eBPF Embedding
1068
-
1069
- Cognitive Containers can embed unikernel images and eBPF bytecode directly, enabling self-contained deployable artifacts:
1070
-
1071
- ```typescript
1072
- // Embed a kernel image into the Cognitive Container
1073
- await backend.embedKernel({
1074
- arch: 'x86_64', // 'x86_64' | 'aarch64' | 'riscv64'
1075
- type: 'firecracker', // 'firecracker' | 'qemu' | 'cloud-hypervisor'
1076
- flags: 0,
1077
- image: kernelBuffer,
1078
- apiPort: 8080,
1079
- cmdline: 'console=ttyS0',
1080
- });
1081
-
1082
- // Extract it later
1083
- const kernel = await backend.extractKernel();
1084
- // { header: { arch, type, ... }, image: Uint8Array }
1085
-
1086
- // eBPF bytecode for programmable query filters
1087
- await backend.embedEbpf(ebpfBytecode);
1088
- const ebpf = await backend.extractEbpf();
1089
- ```
1090
-
1091
- ### CLI Commands
1092
-
1093
- ```bash
1094
- # Show store status
1095
- npx agentdb rvf status ./store.rvf
1096
-
1097
- # Compact to reclaim space
1098
- npx agentdb rvf compact ./store.rvf
1099
-
1100
- # Create a branch (copy-on-write)
1101
- npx agentdb rvf derive ./parent.rvf ./experiment.rvf
1102
-
1103
- # List segments
1104
- npx agentdb rvf segments ./store.rvf
1105
-
1106
- # Detect SDK availability
1107
- npx agentdb rvf detect
1108
- ```
1109
-
1110
- ### Programmatic Usage
1111
-
1112
- ```typescript
1113
- import { RvfBackend } from 'agentdb/backends/rvf/RvfBackend';
1114
-
1115
- const backend = new RvfBackend({
1116
- dimension: 384,
1117
- metric: 'cosine',
1118
- storagePath: './vectors.rvf',
1119
- rvfBackend: 'auto', // 'node' for N-API, 'wasm' for browser
1120
- });
1121
- await backend.initialize();
1122
-
1123
- // Async operations (native)
1124
- await backend.insertAsync('vec-1', embedding, { tag: 'example' });
1125
- const results = await backend.searchAsync(queryVector, 10);
1126
- await backend.flush();
1127
-
1128
- // COW branching
1129
- const branch = await backend.derive('./experiment.rvf');
1130
- const lineage = await backend.lineageDepth();
1131
- ```
1132
-
1133
- ### Backend Selection
1134
-
1135
- ```bash
1136
- # Initialize with RVF backend
1137
- npx agentdb init --backend rvf --rvf-path ./vectors.rvf
1138
-
1139
- # Migrate existing data to RVF
1140
- npx agentdb migrate --to rvf --rvf-path ./vectors.rvf
1141
-
1142
- # Check RVF in diagnostics
1143
- npx agentdb doctor --rvf-path ./vectors.rvf
1144
- ```
1145
-
1146
- </details>
1147
-
1148
- ---
1149
-
1150
- ### Performance & Architecture
1151
-
1152
- The engine behind AgentDB's speed — SIMD acceleration, graph intelligence, browser WASM, and benchmarking.
1153
-
1154
- <details>
1155
- <summary><strong>SIMD & Native Acceleration</strong> — 15 capability groups with automatic fallbacks</summary>
1156
-
1157
- The `NativeAccelerator` provides 15 capability groups bridging 11 `@ruvector` packages, with pure-JS fallbacks for every operation via `SimdFallbacks`.
1158
-
1159
- ### Capability Groups
1160
-
1161
- | Group | Operations | Package |
1162
- | --- | --- | --- |
1163
- | **Vector Distance & Math** | cosine, dot, L2, hamming, add, mul, scale, normalize | `ruvector` |
1164
- | **Activations** | softmax, relu, gelu, sigmoid, layerNorm | `@ruvector/ruvllm` |
1165
- | **Loss Functions** | InfoNCE (contrastive) | `@ruvector/sona` |
1166
- | **Optimizers** | AdamW step | `@ruvector/sona` |
1167
- | **Quantization** | scalar 8-bit/4-bit, product quantization | `@ruvector/rvf` |
1168
- | **WASM Store** | create, ingest, query, export, close | `@ruvector/rvf-wasm` |
1169
- | **Verification** | witness chain, segment header | `@ruvector/rvf-node` |
1170
- | **Graph Transactions** | begin, commit, rollback | `@ruvector/graph-node` |
1171
- | **Graph Batch Insert** | high-throughput node/edge ingestion | `@ruvector/graph-node` |
1172
- | **Graph Cypher** | pattern matching, path queries | `@ruvector/graph-node` |
1173
- | **Core Batch Insert** | native vector batch ingestion | `ruvector` |
1174
- | **EWC Memory** | penalty calculation, Fisher update | `@ruvector/sona` |
1175
- | **Router** | save/load state persistence | `@ruvector/router` |
1176
- | **SONA** | context addition, flush, base LoRA | `@ruvector/sona` |
1177
- | **Compression** | tensor compress/decompress | `@ruvector/rvf` |
1178
-
1179
- ### Auto-Detection
1180
-
1181
- Each capability group is lazily loaded — only the packages actually installed on the system are loaded, and each load is tried independently so a missing package never blocks others:
1182
-
1183
- ```typescript
1184
- import { NativeAccelerator } from 'agentdb/backends/rvf/NativeAccelerator';
1185
-
1186
- const accel = new NativeAccelerator();
1187
- const stats = await accel.initialize();
1188
-
1189
- console.log(stats);
1190
- // AcceleratorStats:
1191
- // {
1192
- // simdAvailable: true, // Vector distance + element-wise math
1193
- // simdActivationsAvailable: true, // softmax, relu, gelu, sigmoid, layerNorm
1194
- // wasmVerifyAvailable: true, // Witness chain & header verification
1195
- // wasmStoreAvailable: true, // In-browser HNSW store
1196
- // wasmQuantizationAvailable: true, // Scalar/product quantization ops
1197
- // nativeInfoNceAvailable: true, // Hardware-accelerated InfoNCE loss
1198
- // nativeAdamWAvailable: true, // Hardware-accelerated AdamW optimizer
1199
- // nativeTensorCompressAvailable: true, // SVD tensor compression
1200
- // routerPersistAvailable: true, // Semantic router state persistence
1201
- // sonaExtendedAvailable: true, // SONA trajectory context & base LoRA
1202
- // }
1203
- // Additional capabilities (probed separately):
1204
- // accel.graphTxAvailable // Graph transactions
1205
- // accel.graphBatchInsertAvailable // Graph batch insert
1206
- // accel.graphCypherAvailable // Cypher query engine
1207
- // accel.coreBatchInsertAvailable // Native vector batch insert
1208
- // accel.ewcManagerAvailable // EWC++ memory consolidation
1209
- ```
1210
-
1211
- ### Pure-JS Fallbacks
1212
-
1213
- Every SIMD operation has a pure-JS fallback with 4-wide loop unrolling for reasonable performance even without native bindings:
1214
-
1215
- ```typescript
1216
- import { SimdFallbacks } from 'agentdb/backends/rvf/SimdFallbacks';
1217
-
1218
- // Same API as native, ~10-50x slower but always available
1219
- const similarity = SimdFallbacks.jsCosineSimilarity(vecA, vecB);
1220
- const loss = SimdFallbacks.jsInfoNceLoss(anchor, positive, negatives, temperature);
1221
- const result = SimdFallbacks.jsAdamWStep(params, grads, m, v, lr, beta1, beta2, weightDecay, t);
1222
- ```
1223
-
1224
- ### Additional SIMD Operations
1225
-
1226
- The `SIMDVectorOps` class provides batch operations and platform-specific detection:
1227
-
1228
- ```typescript
1229
- import { SIMDVectorOps, detectSIMDSupport } from 'agentdb/simd';
1230
-
1231
- const simd = new SIMDVectorOps();
1232
- const support = detectSIMDSupport();
1233
- // { wasm: true, x64: false, avx2: false, neon: false }
1234
-
1235
- const similarities = simd.batchCosineSimilarity(query, [vec1, vec2, vec3]);
1236
- ```
1237
-
1238
- </details>
1239
-
1240
- ---
1241
-
1242
- <details>
1243
- <summary><strong>Graph Intelligence</strong> — Cypher queries, causal reasoning, GNN attention</summary>
1244
-
1245
- AgentDB integrates `@ruvector/graph-node` for a full graph database with Cypher query support, transactional batch inserts, and GNN-powered attention.
1246
-
1247
- ### Cypher Queries
1248
-
1249
- Full Neo4j-compatible Cypher syntax including MATCH, RETURN, WHERE, ORDER BY, LIMIT, relationship patterns, and graph traversal:
1250
-
1251
- ```typescript
1252
- import { GraphDatabaseAdapter } from 'agentdb/backends/graph/GraphDatabaseAdapter';
1253
-
1254
- const graph = new GraphDatabaseAdapter({
1255
- storagePath: './graph.db',
1256
- dimensions: 384,
1257
- distanceMetric: 'Cosine', // 'Cosine' | 'Euclidean' | 'DotProduct' | 'Manhattan'
1258
- });
1259
- await graph.initialize();
1260
-
1261
- // Create nodes and edges
1262
- await graph.storeEpisode(episode, embedding);
1263
- await graph.storeSkill(skill, embedding);
1264
- await graph.createCausalEdge(edge, embedding);
1265
-
1266
- // Cypher queries
1267
- const results = await graph.query(`
1268
- MATCH (e:Episode)-[:CAUSED]->(s:Skill)
1269
- WHERE e.reward > 0.8
1270
- RETURN e, s
1271
- ORDER BY e.reward DESC
1272
- LIMIT 10
1273
- `);
1274
- ```
1275
-
1276
- ### Graph Traversal
1277
-
1278
- Traverse relationships with direction control, depth limits, and label filtering:
1279
-
1280
- ```typescript
1281
- const paths = await graph.traverse({
1282
- startNodeId: 'episode-42',
1283
- pattern: '()-[:RELATES_TO]->(:Skill)',
1284
- direction: 'outgoing', // 'outgoing' | 'incoming' | 'both'
1285
- maxDepth: 3,
1286
- relationshipTypes: ['CAUSED', 'RELATES_TO'],
1287
- nodeLabels: ['Episode', 'Skill'],
1288
- });
1289
- ```
1290
-
1291
- ### Hybrid Vector + Graph Search
1292
-
1293
- Combine vector similarity with graph context filtering — find semantically similar nodes that are also connected in the knowledge graph:
1294
-
1295
- ```typescript
1296
- // Vector similarity within graph structure
1297
- const results = await graph.vectorSearch(queryEmbedding, 10);
1298
- // Returns nodes ranked by embedding similarity with graph context
1299
-
1300
- // Nodes support multi-label classification
1301
- await graph.createNode({
1302
- id: 'analysis-1',
1303
- label: ['Episode', 'Analyzed', 'Security'],
1304
- properties: { reward: 0.95, task: 'auth review' },
1305
- embedding: embeddingVector,
1306
- });
1307
- ```
1308
-
1309
- ### Transactional Batch Inserts
1310
-
1311
- ACID-guaranteed batch operations with rollback support:
1312
-
1313
- ```typescript
1314
- const txId = await graph.beginTransaction();
1315
- try {
1316
- await graph.batchInsert(
1317
- nodes.map(n => ({ id: n.id, label: n.type, properties: n.data })),
1318
- edges.map(e => ({ from: e.source, to: e.target, label: e.type, properties: e.data })),
1319
- );
1320
- await graph.commitTransaction(txId);
1321
- } catch (err) {
1322
- await graph.rollbackTransaction(txId);
1323
- }
1324
- ```
1325
-
1326
- ### GNN 8-Head Attention
1327
-
1328
- The GNN attention mechanism improves recall by +12.4% with a 3.8ms forward pass and 91% transfer learning retention. Three attention types are available:
1329
-
1330
- | Type | Algorithm | Best For |
1331
- | --- | --- | --- |
1332
- | `gat` | Graph Attention Network | Weighted neighbor aggregation |
1333
- | `gcn` | Graph Convolutional Network | Uniform message passing |
1334
- | `sage` | GraphSAGE | Inductive learning on unseen nodes |
1335
-
1336
- ```typescript
1337
- import { AttentionService } from 'agentdb/controllers/AttentionService';
1338
-
1339
- const attention = new AttentionService({
1340
- numHeads: 8,
1341
- dimension: 384,
1342
- attentionType: 'gat', // 'gat' | 'gcn' | 'sage'
1343
- });
1344
- const enhanced = await attention.forward(queryEmbedding, neighborEmbeddings);
1345
- ```
1346
-
1347
- ### Causal Memory Graph
1348
-
1349
- Track interventions with `p(y|do(x))` doubly robust estimation and optional Poincare embeddings for hierarchical relationships:
1350
-
1351
- ```typescript
1352
- import { CausalMemoryGraph } from 'agentdb';
1353
-
1354
- const causal = new CausalMemoryGraph(db, graph, embedder, {
1355
- ENABLE_HYPERBOLIC_ATTENTION: true, // Poincaré ball distance for hierarchies
1356
- });
1357
-
1358
- await causal.addCausalEdge({
1359
- fromMemoryId: 'episode-1',
1360
- toMemoryType: 'skill', // 'episode' | 'skill' | 'note' | 'fact'
1361
- uplift: 0.15, // E[y|do(x)] - E[y]
1362
- confidence: 0.92,
1363
- mechanism: 'error-handling improvement',
1364
- sampleSize: 50,
1365
- confounderScore: 0.03,
1366
- });
1367
- ```
1368
-
1369
- </details>
1370
-
1371
- ---
1372
-
1373
- <details>
1374
- <summary><strong>Browser & WASM Deployment</strong> — full vector DB in the browser, no server needed</summary>
1375
-
1376
- AgentDB runs fully in the browser with WASM-backed vector storage, GNN attention, product quantization, and pure-JS fallbacks.
1377
-
1378
- ### WasmStoreBridge
1379
-
1380
- The `WasmStoreBridge` provides a full HNSW vector database in the browser by wrapping `@ruvector/rvf-wasm`:
1381
-
1382
- ```typescript
1383
- import { WasmStoreBridge } from 'agentdb/backends/rvf/WasmStoreBridge';
1384
-
1385
- const bridge = new WasmStoreBridge();
1386
- await bridge.initialize();
1387
-
1388
- // Create an in-browser vector store
1389
- const handle = bridge.wasmStoreCreate(384, 0); // 384 dims, cosine metric
1390
-
1391
- // Ingest vectors
1392
- bridge.wasmStoreIngest(handle, vectors, ids, count);
1393
-
1394
- // Query
1395
- const results = bridge.wasmStoreQuery(handle, queryVector, 10, 0);
1396
- // [{ id: 42, distance: 0.12 }, ...]
1397
-
1398
- // Export to transferable binary (share between tabs/workers)
1399
- const bytes = bridge.wasmStoreExport(handle);
1400
-
1401
- bridge.wasmStoreClose(handle);
1402
- ```
1403
-
1404
- ### Browser Attention Mechanisms
1405
-
1406
- The `AttentionBrowser` provides three advanced attention types compiled to WASM:
1407
-
1408
- ```typescript
1409
- import { AttentionBrowser } from 'agentdb/browser/AttentionBrowser';
1410
-
1411
- const attention = new AttentionBrowser({ numHeads: 8 });
1412
- // Loading states: 'idle' → 'loading' → 'loaded' | 'error'
1413
-
1414
- // Standard multi-head attention
1415
- const enhanced = await attention.forward(query, neighbors);
1416
-
1417
- // Flash Attention — O(N) memory instead of O(N²)
1418
- const flash = await attention.flashAttention(query, keys, values);
1419
-
1420
- // Hyperbolic Attention — Poincaré ball distance for hierarchical data
1421
- const hyper = await attention.hyperbolicAttention(query, neighbors);
1422
-
1423
- // Memory Consolidation — agglomerative clustering to merge similar memories
1424
- const consolidated = await attention.consolidateMemories(memories, {
1425
- threshold: 0.85,
1426
- minClusterSize: 3,
1427
- });
1428
- ```
1429
-
1430
- ### Product Quantization (Browser)
1431
-
1432
- Memory-efficient vector storage with three PQ compression levels:
1433
-
1434
- | Variant | Compression | Subvectors | Centroids | Best For |
1435
- | --- | --- | --- | --- | --- |
1436
- | **PQ8** | 4x | 8 | 256 | Balanced quality/memory |
1437
- | **PQ16** | 8x | 16 | 256 | Medium datasets |
1438
- | **PQ32** | 16x | 32 | 256 | Maximum compression |
1439
-
1440
- ```typescript
1441
- import { createProductQuantizedStore, createScalar8BitStore } from 'agentdb/browser/ProductQuantization';
1442
-
1443
- // Product quantization with asymmetric distance computation (ADC)
1444
- const pq = createProductQuantizedStore(384, {
1445
- numSubvectors: 16,
1446
- bitsPerCode: 8,
1447
- // Uses K-means++ initialization for codebook training
1448
- });
1449
- pq.add('doc-1', embedding);
1450
- const results = pq.search(query, 10);
1451
- ```
1452
-
1453
- ### Browser Configuration Presets
1454
-
1455
- Pre-tuned configurations for common scenarios:
1456
-
1457
- | Preset | Features | Target |
1458
- | --- | --- | --- |
1459
- | `SMALL_DATASET` | GNN only | <1K vectors |
1460
- | `MEDIUM_DATASET` | HNSW + PQ8 | 1K-10K vectors |
1461
- | `LARGE_DATASET` | Aggressive compression + HNSW | 10K-100K vectors |
1462
- | `MEMORY_OPTIMIZED` | PQ32 + SVD (dim 64) | Memory-constrained |
1463
- | `SPEED_OPTIMIZED` | HNSW max quality | Latency-critical |
1464
- | `QUALITY_OPTIMIZED` | No compression, max attention heads | Accuracy-critical |
1465
-
1466
- ### Maximal Marginal Relevance (MMR)
1467
-
1468
- Diversify search results to avoid returning near-duplicate items:
1469
-
1470
- ```typescript
1471
- import { MMRDiversityRanker } from 'agentdb/controllers/MMRDiversityRanker';
1472
-
1473
- const ranker = new MMRDiversityRanker({
1474
- lambda: 0.7, // 0=max diversity, 1=max relevance
1475
- metric: 'cosine', // 'cosine' | 'euclidean' | 'dot'
1476
- });
1477
-
1478
- // Rerank results: MMR = λ × Sim(Di,Q) - (1-λ) × max Sim(Di,Dj)
1479
- const diverse = ranker.rerank(queryEmbedding, candidates, 10);
1480
- const score = ranker.diversityScore(diverse); // average pairwise distance
1481
- ```
1482
-
1483
- ### Browser Bundle
1484
-
1485
- ```typescript
1486
- import { AgentDB } from 'agentdb/browser';
1487
-
1488
- const db = new AgentDB({ dimension: 384 });
1489
- await db.initialize();
1490
-
1491
- await db.insert('doc-1', embedding, { title: 'Getting Started' });
1492
- const results = await db.search(queryEmbedding, 5);
1493
- ```
1494
-
1495
- ### sql.js & SIMD Fallbacks
1496
-
1497
- For zero-dependency environments, AgentDB falls back to `sql.js` (SQLite compiled to WASM) automatically. Non-WASM browsers get pure-JS implementations with 4-wide loop unrolling (~10-50x slower than native SIMD but fully functional):
1498
-
1499
- ```typescript
1500
- import { createDatabase } from 'agentdb';
1501
- import { detectSIMDSupport } from 'agentdb/simd';
1502
-
1503
- // In browsers, automatically uses sql.js WASM backend
1504
- const db = await createDatabase(':memory:');
1505
-
1506
- const support = detectSIMDSupport();
1507
- // { wasm: true, x64: false, avx2: false, neon: false }
1508
- ```
1509
-
1510
- </details>
1511
-
1512
- ---
1513
-
1514
- <details>
1515
- <summary><strong>Performance & Benchmarks</strong> — 61us latency, 96.8% recall, 32.6M ops/sec</summary>
1516
-
1517
- ### Core Operations
1518
-
1519
- | Operation | Throughput | Latency |
1520
- | --- | --- | --- |
1521
- | Pattern search | 32.6M ops/sec | <1ms |
1522
- | Pattern storage | 388K ops/sec | ~2.5us |
1523
- | Episode retrieval | 957 ops/sec | ~1ms |
1524
- | Skill search | 694 ops/sec | ~1.4ms |
1525
- | Batch insert | 5,556-7,692 ops/sec | 3-4x faster than sequential |
1526
-
1527
- ### Scaling Behavior
1528
-
1529
- ```
1530
- 500 patterns: 1,475/sec, 2MB memory
1531
- 2,000 patterns: 3,818/sec, 0MB delta
1532
- 5,000 patterns: 4,536/sec, 4MB memory (super-linear)
1533
- ```
1534
-
1535
- ### Self-Learning Improvement
1536
-
1537
- ```
1538
- Adaptive Learning (10 sessions, 50 episodes each)
1539
- Initial success rate: 54%
1540
- Final success rate: 90%
1541
- Improvement: +36%
1542
- ```
1543
-
1544
- ### Latent Space Validation (31 scenarios, 98.2% reproducibility)
1545
-
1546
- | Scenario | Result |
1547
- | --- | --- |
1548
- | HNSW Optimization | 61us p50, 96.8% recall@10, 8.2x vs hnswlib |
1549
- | GNN Attention | +12.4% recall, 3.8ms forward pass, 91% transfer |
1550
- | Self-Healing | 97.9% degradation prevention, <100ms repair |
1551
- | Neural Augmentation | +29.4% improvement, -32% memory, -52% hops |
1552
-
1553
- ### Adaptive Solver (Thompson Sampling)
1554
-
1555
- The solver uses 18 context-bucketed bandits (3 range x 3 distractor x 2 noise levels) to dynamically tune search parameters:
1556
-
1557
- ```typescript
1558
- const solver = await AgentDBSolver.create();
1559
-
1560
- // Train the solver with puzzles of varying difficulty
1561
- const result = solver.train({ count: 50, minDifficulty: 1, maxDifficulty: 10 });
1562
-
1563
- // Inspect the policy — shows Thompson Sampling alpha/beta per context bucket
1564
- const policy = solver.policy();
1565
- console.log(policy.contextStats);
1566
- // { '0_0_0': { alphaSafety: 12.5, betaSafety: 2.1, costEma: 0.03 }, ... }
1567
-
1568
- // A/B/C acceptance testing
1569
- const manifest = solver.acceptance({ holdoutSize: 100, cycles: 3 });
1570
- console.log(`Passed: ${manifest.passed}, Score: ${manifest.score}`);
1571
-
1572
- // SHAKE-256 witness chain for audit
1573
- const chain = solver.witnessChain();
1574
- ```
1575
-
1576
- Three-loop architecture:
1577
- 1. **Fast loop** — constraint propagation (~0.1ms)
1578
- 2. **Medium loop** — PolicyKernel with Thompson Sampling (~1ms)
1579
- 3. **Slow loop** — KnowledgeCompiler for long-term patterns (~10ms)
1580
-
1581
- ### SolverBandit — Decision Intelligence Across Controllers (ADR-010)
1582
-
1583
- The `SolverBandit` is a general-purpose Thompson Sampling bandit that provides explore/exploit decisions for any context-dependent selection problem. It powers adaptive decision-making in 5 AgentDB controllers:
1584
-
1585
- | Controller | What the Bandit Decides | Context Key |
1586
- | --- | --- | --- |
1587
- | **SkillLibrary** | Rerank retrieved skills by task type | `taskType` string |
1588
- | **ReasoningBank** | Rerank matching patterns by task type | query text |
1589
- | **NightlyLearner** | Prioritize experiment candidates | `'experiment'` |
1590
- | **LearningSystem** | Select best RL algorithm (9 options) | task description |
1591
- | **TemporalCompressor** | Choose compression tier (none/half/pq8/pq4/binary) | `hot`/`warm`/`cold` |
1592
-
1593
- Each controller uses the bandit optionally — when no bandit is provided, behavior is unchanged from v2. When present, the bandit reranks results using Thompson-sampled Beta distributions, and controllers feed outcomes back via `recordReward()`.
1594
-
1595
- ```typescript
1596
- import { SolverBandit } from 'agentdb/backends/rvf/SolverBandit';
1597
-
1598
- const bandit = new SolverBandit();
1599
-
1600
- // Select best arm for a context
1601
- const skill = bandit.selectArm('code_review', ['lint_first', 'test_first', 'security_scan']);
1602
-
1603
- // Record outcome
1604
- bandit.recordReward('code_review', skill, 0.85, /* latencyMs */ 120);
1605
-
1606
- // Rerank candidates by learned performance
1607
- const ranked = bandit.rerank('code_review', ['lint_first', 'test_first', 'security_scan']);
1608
-
1609
- // Serialize for cross-session persistence
1610
- const state = bandit.serialize(); // JSON-safe
1611
- const restored = SolverBandit.deserialize(state);
1612
- ```
1613
-
1614
- **Performance:** 100K `selectArm` calls in <200ms, 100K `recordReward` calls in <100ms.
1615
-
1616
- **Wire into AgentDB controllers:**
1617
-
1618
- ```typescript
1619
- import { SolverBandit, SkillLibrary, ReasoningBank, LearningSystem } from 'agentdb';
1620
-
1621
- const bandit = new SolverBandit({ costWeight: 0.01, explorationBonus: 0.1 });
1622
-
1623
- // Pass as optional last parameter to any controller
1624
- const skills = new SkillLibrary(db, embedder, undefined, bandit);
1625
- const patterns = new ReasoningBank(db, embedder, undefined, bandit);
1626
- const learning = new LearningSystem(db, undefined, bandit);
1627
-
1628
- // Controllers automatically rerank results and accept feedback
1629
- const algorithm = learning.recommendAlgorithm('navigation task');
1630
- learning.recordAlgorithmOutcome('navigation task', algorithm, 0.92, 340);
1631
- ```
1632
-
1633
- </details>
1634
-
1635
- ---
1636
-
1637
- ### Enterprise & Security
1638
-
1639
- Production-ready authentication, audit logging, and defense-in-depth security with cryptographic verification.
1640
-
1641
- <details>
1642
- <summary><strong>Security</strong> — defense-in-depth with cryptographic audit trails</summary>
1643
-
1644
- AgentDB provides defense-in-depth security with validation at every system boundary.
1645
-
1646
- ### Input Validation
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.
1647
11
 
1648
- ```typescript
1649
- import {
1650
- validateVector,
1651
- validateVectorId,
1652
- validateSearchOptions,
1653
- validateHNSWParams,
1654
- sanitizeMetadata,
1655
- validateCypherParams,
1656
- validateLabel,
1657
- validateBatchSize,
1658
- } from 'agentdb/security/validation';
1659
-
1660
- // Vector validation — prevents NaN/Infinity injection
1661
- validateVector(embedding, 384, 'embedding');
1662
-
1663
- // ID validation — prevents path traversal (../, etc.)
1664
- validateVectorId('doc-123', 'id');
1665
-
1666
- // Search bounds — k, threshold, efSearch range checking
1667
- validateSearchOptions({ k: 10, threshold: 0.7 });
1668
-
1669
- // HNSW parameter validation — M, efConstruction, efSearch
1670
- validateHNSWParams({ M: 16, efConstruction: 200, efSearch: 100 });
1671
-
1672
- // Metadata sanitization — strips password, token, key, apiKey, auth fields
1673
- const safe = sanitizeMetadata(userInput);
1674
-
1675
- // Cypher injection prevention
1676
- validateCypherParams(params);
1677
- ```
1678
-
1679
- ### XSS & Injection Prevention
1680
-
1681
- ```typescript
1682
- import {
1683
- validateTaskString,
1684
- validateNumericRange,
1685
- validateEnum,
1686
- } from 'agentdb/security/input-validation';
1687
-
1688
- const task = validateTaskString(input, 'task'); // XSS pattern detection
1689
- const k = validateNumericRange(kVal, 'k', 1, 100);
1690
- const format = validateEnum(fmt, 'format', ['json', 'concise', 'detailed']);
1691
- ```
1692
-
1693
- ### Security Limits
1694
-
1695
- | Parameter | Limit |
1696
- | --- | --- |
1697
- | Max vectors | 10,000,000 |
1698
- | Max dimension | 4,096 |
1699
- | Max batch size | 10,000 |
1700
- | Max k | 10,000 |
1701
- | Max metadata size | 64 KB |
1702
- | Max ID length | 256 chars |
1703
- | Filter expression depth | 64 |
1704
- | ef-search range | 1 - 1,000 |
1705
- | ef-construction range | 4 - 500 |
1706
- | M range | 2 - 64 |
1707
-
1708
- ### Witness Chain Verification
1709
-
1710
- SHAKE-256 cryptographic witness chains provide tamper-evident audit trails:
1711
-
1712
- ```typescript
1713
- const result = backend.verifyWitnessChain();
1714
- if (!result.valid) {
1715
- console.error('Data integrity compromised!');
1716
- }
1717
- ```
1718
-
1719
- ### Provenance Certificates (Explainable Recall)
1720
-
1721
- Every search result can include a Merkle proof explaining why it was selected:
1722
-
1723
- ```typescript
1724
- const { results, certificate } = await causalRecall.recall(
1725
- 'query-id',
1726
- 'optimization strategies',
1727
- 10,
1728
- ['performance'],
1729
- 'internal',
1730
- );
1731
- console.log(`Certificate ID: ${certificate.id}`);
1732
- console.log(`Completeness: ${certificate.completenessScore}`);
1733
- ```
1734
-
1735
- </details>
1736
-
1737
- ---
1738
-
1739
- <details>
1740
- <summary><strong>Quantization & Compression</strong> — up to 32x memory reduction with 5-tier auto-tiering</summary>
1741
-
1742
- AgentDB supports multiple quantization strategies to reduce memory footprint while maintaining search quality.
1743
-
1744
- ### Scalar Quantization
1745
-
1746
- 8-bit and 4-bit scalar quantization for memory-efficient storage:
1747
-
1748
- ```typescript
1749
- import { createScalar8BitStore, createProductQuantizedStore } from 'agentdb/browser/ProductQuantization';
1750
-
1751
- // 8-bit quantization — 4x memory reduction
1752
- const store8 = createScalar8BitStore(384);
1753
- store8.add('doc-1', embedding);
1754
- const results = store8.search(query, 10);
1755
-
1756
- // Product quantization — up to 32x memory reduction
1757
- const storePQ = createProductQuantizedStore(384, { numSubvectors: 48, bitsPerCode: 8 });
1758
- storePQ.add('doc-1', embedding);
1759
- const results = storePQ.search(query, 10);
1760
- ```
1761
-
1762
- ### 5-Tier Temporal Compression
1763
-
1764
- Vectors are automatically compressed based on age and access frequency:
1765
-
1766
- | Tier | Compression | Memory | Quality | Trigger |
1767
- | --- | --- | --- | --- | --- |
1768
- | **Hot** | None | 100% | 100% | Recent / frequently accessed |
1769
- | **Warm** | Half-precision | 50% | ~99% | Moderate age |
1770
- | **Cool** | PQ-8 | ~12% | ~95% | Older data |
1771
- | **Cold** | PQ-4 | ~6% | ~90% | Rarely accessed |
1772
- | **Archive** | Binary | ~3% | ~80% | Archival storage |
1773
-
1774
- ### Matryoshka Dimension Truncation
1775
-
1776
- Reduce embedding dimensions while preserving the most important features:
1777
-
1778
- ```typescript
1779
- // Models trained with Matryoshka loss support dimension truncation
1780
- // 384d -> 128d with minimal quality loss
1781
- const truncated = embedding.slice(0, 128);
1782
- ```
1783
-
1784
- ### NativeAccelerator Quantization
1785
-
1786
- The NativeAccelerator provides hardware-accelerated quantization/dequantization:
1787
-
1788
- ```typescript
1789
- const accel = new NativeAccelerator();
1790
- await accel.initialize();
1791
-
1792
- // Load scalar quantization parameters
1793
- accel.loadSqParams(mins, scales);
1794
- const restored = accel.dequantI8(quantizedBytes);
1795
-
1796
- // Product quantization with codebook
1797
- accel.loadPqCodebook(codebook, numSubvectors, bitsPerCode);
1798
- const distances = accel.pqDistances(query, codes);
1799
- ```
1800
-
1801
- </details>
1802
-
1803
- ---
1804
-
1805
- ### Integration & Tools
1806
-
1807
- Connect AgentDB to LLM providers, embedding models, and distributed systems with real-time sync.
1808
-
1809
- <details>
1810
- <summary><strong>Model Import/Export & Embedding Models</strong> — 5 local models, no API keys</summary>
1811
-
1812
- ### Embedding Models
1813
-
1814
- AgentDB supports multiple embedding models. No API key required — all Xenova models run locally.
1815
-
1816
- | Model | Dimension | Quality | Speed | Best For |
1817
- | --- | --- | --- | --- | --- |
1818
- | **all-MiniLM-L6-v2** (default) | 384 | Good | Fastest | Prototyping |
1819
- | **bge-small-en-v1.5** | 384 | Excellent | Fast | Best 384d quality |
1820
- | **bge-base-en-v1.5** | 768 | Excellent | Moderate | Production |
1821
- | **all-mpnet-base-v2** | 768 | Excellent | Moderate | All-around |
1822
- | **e5-base-v2** | 768 | Excellent | Moderate | Multilingual |
1823
-
1824
- ```bash
1825
- # Default (384d, fast)
1826
- npx agentdb init
1827
-
1828
- # Production (768d, high quality)
1829
- npx agentdb init --dimension 768 --model "Xenova/bge-base-en-v1.5"
1830
- ```
1831
-
1832
- ### LLM Router for Multi-Provider Integration
1833
-
1834
- AgentDB can route queries through multiple LLM providers via `@ruvector/ruvllm`:
1835
-
1836
- ```typescript
1837
- import { isRuvLLMInstalled } from 'agentdb/wrappers';
12
+ ## What's New in v3
1838
13
 
1839
- if (await isRuvLLMInstalled()) {
1840
- // LLM router available for enrichment and reranking
1841
- }
1842
- ```
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
1843
21
 
1844
- ### RVF Export/Import
1845
-
1846
- Export vector stores to the portable Cognitive Container format:
22
+ ## Quick Start
1847
23
 
1848
24
  ```bash
1849
- # Export existing database to Cognitive Container
1850
- npx agentdb migrate --to rvf --rvf-path ./vectors.rvf
1851
-
1852
- # Import from Cognitive Container into a new backend
1853
- npx agentdb migrate --from rvf --rvf-path ./vectors.rvf --target ./new.db
1854
- ```
1855
-
1856
- ### WASM Export
1857
-
1858
- Export a WASM store to a transferable binary for sharing between browser tabs or workers:
25
+ # Install v3 Alpha
26
+ npm install agentdb@v3
1859
27
 
1860
- ```typescript
1861
- const bytes = bridge.wasmStoreExport(handle); // Uint8Array
1862
- // Transfer to another worker or save to IndexedDB
1863
- ```
1864
-
1865
- </details>
1866
-
1867
- ---
1868
-
1869
- <details>
1870
- <summary><strong>Query Lifecycle</strong> — what happens when you call searchAsync()</summary>
1871
-
1872
- The full lifecycle of a query through AgentDB's self-learning pipeline:
1873
-
1874
- ```mermaid
1875
- sequenceDiagram
1876
- participant App
1877
- participant Router as Semantic Router
1878
- participant SONA
1879
- participant HNSW as HNSW Index
1880
- participant Trainer as Contrastive Trainer
1881
-
1882
- App->>Router: query(embedding)
1883
- Router->>Router: classify intent
1884
- Router->>SONA: enhance(embedding, trajectories)
1885
- SONA->>SONA: apply micro-LoRA
1886
- SONA->>HNSW: searchAsync(enhanced, k, ef)
1887
- HNSW-->>App: results[]
1888
- App->>Trainer: recordFeedback(quality)
1889
- Trainer->>Trainer: InfoNCE + hard negatives
1890
- Trainer->>SONA: updateLoRA(gradients)
1891
- Note over SONA: EWC++ consolidation<br/>prevents forgetting
28
+ # Or use stable v2
29
+ npm install agentdb@latest
1892
30
  ```
1893
31
 
1894
- ### Phase Breakdown
1895
-
1896
- 1. **Routing** — `SemanticQueryRouter` classifies query intent via HNSW-indexed embeddings and selects the optimal search strategy
1897
- 2. **Enhancement** — SONA engine enriches the query embedding using trajectory history and context
1898
- 3. **LoRA Application** — Micro-LoRA adapter adjusts the embedding in sub-millisecond time
1899
- 4. **Search** — HNSW index returns top-k results with adaptive ef-search
1900
- 5. **Feedback** — Application records result quality (0.0-1.0)
1901
- 6. **Training** — Contrastive trainer runs InfoNCE loss with hard negative mining
1902
- 7. **Update** — LoRA gradients update the adapter weights
1903
- 8. **Consolidation** — EWC++ prevents catastrophic forgetting of previously learned patterns
1904
-
1905
- </details>
1906
-
1907
- ---
1908
-
1909
- ### Distributed Systems
1910
-
1911
- Multi-database coordination, real-time replication, and production observability.
1912
-
1913
- <details>
1914
- <summary><strong>Multi-Database Coordination</strong> — distributed sync with conflict resolution</summary>
1915
-
1916
- The `MultiDatabaseCoordinator` enables distributed sync between multiple AgentDB instances with configurable conflict resolution.
32
+ ## Basic Usage
1917
33
 
1918
34
  ```typescript
1919
- import { MultiDatabaseCoordinator } from 'agentdb/coordination/MultiDatabaseCoordinator';
1920
-
1921
- const coordinator = new MultiDatabaseCoordinator({
1922
- replicationFactor: 3,
1923
- syncIntervalMs: 5000,
1924
- conflictResolution: 'merge', // 'last-write-wins' | 'merge' | 'manual'
1925
- autoFailover: true,
1926
- maxRetries: 3,
1927
- });
1928
-
1929
- // Register database instances
1930
- await coordinator.registerInstance({
1931
- id: 'primary',
1932
- url: 'file:///data/primary.rvf',
1933
- role: 'primary',
1934
- });
1935
- await coordinator.registerInstance({
1936
- id: 'replica-1',
1937
- url: 'file:///data/replica-1.rvf',
1938
- role: 'replica',
1939
- });
1940
-
1941
- // Sync a specific instance
1942
- const result = await coordinator.syncInstance('replica-1');
1943
- console.log(`Synced: ${result.recordsSynced}, Conflicts: ${result.conflicts}`);
1944
-
1945
- // Broadcast operations to all instances
1946
- await coordinator.broadcast('insertAsync', ['doc-1', embedding, { source: 'api' }]);
35
+ import { AgentDB } from 'agentdb';
1947
36
 
1948
- // Monitor instance status
1949
- coordinator.onStatusChange((instanceId, status) => {
1950
- console.log(`${instanceId}: ${status.state}`); // 'healthy' | 'degraded' | 'offline'
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
1951
43
  });
1952
- ```
1953
-
1954
- ### Conflict Resolution Strategies
1955
-
1956
- | Strategy | Description | Best For |
1957
- | --- | --- | --- |
1958
- | **last-write-wins** | Most recent write wins (LWW) | Simple setups, eventual consistency |
1959
- | **merge** | Quality-based weighted average | Learning systems, federated aggregation |
1960
- | **manual** | Returns conflicts for user resolution | Critical data, compliance requirements |
1961
44
 
1962
- </details>
1963
-
1964
- ---
1965
-
1966
- <details>
1967
- <summary><strong>Real-Time Sync (QUIC)</strong> — bidirectional replication with 0-RTT resumption</summary>
1968
-
1969
- AgentDB supports real-time bidirectional sync between instances using QUIC transport and a high-level `SyncCoordinator`.
45
+ await db.initialize();
1970
46
 
1971
- ### QUIC Transport
47
+ // Access controllers
48
+ const reflexion = db.getController('reflexion');
49
+ const reasoning = db.getController('reasoning');
50
+ const causalGraph = db.getController('causalGraph');
1972
51
 
1973
- QUIC provides multiplexed streams over a single connection with zero head-of-line blocking, connection migration between networks, and 0-RTT session resumption:
52
+ // Check proof engine status
53
+ const guard = db.getMutationGuard();
54
+ console.log(guard?.getStats());
55
+ // Output: { engineType: 'native', proofsGenerated: 42, denials: 0 }
1974
56
 
1975
- ```typescript
1976
- import { QUICServer } from 'agentdb/controllers/QUICServer';
1977
-
1978
- const server = new QUICServer({
1979
- port: 4433,
1980
- maxConnections: 100,
1981
- rateLimit: {
1982
- requestsPerMin: 1000,
1983
- bytesPerMin: 10_000_000,
1984
- },
1985
- authToken: 'secret', // optional token validation
57
+ // Store episode with automatic proof generation
58
+ await reflexion.storeEpisode({
59
+ sessionId: 'session-1',
60
+ task: 'Debug authentication bug',
61
+ reward: 0.95,
62
+ success: true,
63
+ critique: 'OAuth2 PKCE flow was more secure than basic flow',
64
+ input: 'Users cannot log in',
65
+ output: 'Working OAuth2 implementation'
1986
66
  });
1987
67
 
1988
- // Stale connections auto-cleaned after 5 minutes idle
1989
- // Sync types: 'episodes' | 'skills' | 'edges' | 'full'
1990
- // Incremental sync via `since` parameter and cursor-based pagination
1991
- ```
1992
-
1993
- ### Sync Coordinator
1994
-
1995
- High-level bidirectional sync with conflict resolution, progress tracking, and auto-sync:
1996
-
1997
- ```typescript
1998
- import { SyncCoordinator } from 'agentdb/controllers/SyncCoordinator';
1999
-
2000
- const sync = new SyncCoordinator({
2001
- conflictStrategy: 'latest-wins', // 'local-wins' | 'remote-wins' | 'latest-wins' | 'merge'
2002
- batchSize: 100,
2003
- autoSyncInterval: 60000, // Auto-sync every 60 seconds
68
+ // Search patterns (proof-validated)
69
+ const patterns = await reasoning.searchPatterns({
70
+ task: 'authentication security',
71
+ k: 10,
72
+ threshold: 0.7
2004
73
  });
2005
-
2006
- // Push local changes, pull remote changes, resolve conflicts
2007
- const report = await sync.sync();
2008
- console.log(report);
2009
- // {
2010
- // success: true,
2011
- // durationMs: 342,
2012
- // itemsPushed: 15,
2013
- // itemsPulled: 8,
2014
- // conflictsResolved: 2,
2015
- // bytesTransferred: 48200,
2016
- // errors: [],
2017
- // }
2018
-
2019
- // Progress tracking through 5 phases:
2020
- // detecting → pushing → pulling → resolving → applying
2021
-
2022
- // Sync state persists across restarts
2023
- await sync.saveSyncState();
2024
- // Tracks: lastSyncAt, lastEpisodeSync, lastSkillSync, lastEdgeSync,
2025
- // totalItemsSynced, totalBytesSynced, syncCount
2026
74
  ```
2027
75
 
2028
- ### Conflict Resolution
2029
-
2030
- | Strategy | Behavior |
2031
- | --- | --- |
2032
- | `local-wins` | Local version always kept |
2033
- | `remote-wins` | Remote version always accepted |
2034
- | `latest-wins` | Most recent timestamp wins |
2035
- | `merge` | Quality-weighted merge of both versions |
2036
-
2037
- </details>
2038
-
2039
- ---
2040
-
2041
- <details>
2042
- <summary><strong>Observability</strong> — OpenTelemetry traces and Prometheus metrics built in</summary>
2043
-
2044
- AgentDB integrates with OpenTelemetry for production monitoring.
2045
-
2046
- ### Traces
2047
-
2048
- Automatic span creation for search, insert, and sync operations:
2049
-
2050
- ```typescript
2051
- import { initTelemetry } from 'agentdb/observability';
76
+ ## Architecture
2052
77
 
2053
- initTelemetry({
2054
- serviceName: 'my-agent',
2055
- exporterUrl: 'http://localhost:4318', // OTLP HTTP endpoint
2056
- });
78
+ AgentDB v3 introduces a 3-layer architecture:
2057
79
 
2058
- // All AgentDB operations automatically generate spans:
2059
- // - agentdb.search (with k, backend, latency attributes)
2060
- // - agentdb.insert (with batchSize, backend)
2061
- // - agentdb.sync (with itemsSynced, conflicts)
2062
80
  ```
2063
-
2064
- ### Metrics
2065
-
2066
- Prometheus-compatible metrics for latency, throughput, and error rates:
2067
-
2068
- - `agentdb_search_duration_ms` — search latency histogram
2069
- - `agentdb_insert_duration_ms` — insert latency histogram
2070
- - `agentdb_cache_hit_ratio` MCP tool cache effectiveness
2071
- - `agentdb_learning_loss` — contrastive training loss
2072
- - `agentdb_vector_count` — total vectors stored
2073
-
2074
- </details>
2075
-
2076
- ---
2077
-
2078
- ### Additional Capabilities
2079
-
2080
- Reinforcement learning, hybrid search, LLM routing, authentication, and high-performance wrappers.
2081
-
2082
- <details>
2083
- <summary><strong>Reinforcement Learning</strong> — 9 algorithms from Q-Learning to Monte Carlo Tree Search</summary>
2084
-
2085
- AgentDB includes a complete reinforcement learning system with 9 algorithms for building agents that learn optimal strategies through interaction:
2086
-
2087
- ### Available Algorithms
2088
-
2089
- | Algorithm | Type | Best For |
2090
- | --- | --- | --- |
2091
- | **Q-Learning** | Value-based | Simple discrete action spaces |
2092
- | **SARSA** | Value-based | On-policy learning, safer exploration |
2093
- | **Deep Q-Network (DQN)** | Value-based | Complex state spaces with neural function approximation |
2094
- | **Policy Gradient** | Policy-based | Continuous action spaces |
2095
- | **Actor-Critic** | Hybrid | Balances value and policy learning |
2096
- | **PPO** | Policy-based | Stable training with clipped objectives |
2097
- | **Decision Transformer** | Sequence-based | Offline RL from logged trajectories |
2098
- | **Monte Carlo Tree Search** | Planning | Game-like decision trees, look-ahead planning |
2099
- | **Model-Based RL** | Model-based | Sample-efficient learning with world models |
2100
-
2101
- ### Usage
2102
-
2103
- ```typescript
2104
- import { LearningSystem } from 'agentdb';
2105
-
2106
- const learner = new LearningSystem(db, {
2107
- algorithm: 'ppo', // any of the 9 algorithms
2108
- learningRate: 0.001,
2109
- discountFactor: 0.99,
2110
- explorationRate: 0.1,
2111
- });
2112
-
2113
- // Start a learning session
2114
- const session = await learner.createSession({
2115
- task: 'optimize_api_responses',
2116
- maxEpisodes: 100,
2117
- });
2118
-
2119
- // Predict next action
2120
- const prediction = await learner.predict(session.id, currentState);
2121
- // { action, confidence, explorationUsed }
2122
-
2123
- // Record outcome
2124
- await learner.recordReward(session.id, prediction.action, reward);
2125
-
2126
- // Train on accumulated experience
2127
- await learner.train(session.id);
2128
-
2129
- // Transfer learning to new tasks
2130
- await learner.transfer(sourceSessionId, targetSessionId);
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
+ └─────────────────────────────────────────────────────┘
2131
95
  ```
2132
96
 
2133
- ### MCP Tools for RL
2134
-
2135
- All 9 algorithms are accessible through MCP tools:
2136
- - `agentdb_rl_create_session` — start a new learning session
2137
- - `agentdb_rl_predict` — get next action recommendation
2138
- - `agentdb_rl_record_reward` — record outcome feedback
2139
- - `agentdb_rl_train` — trigger training round
2140
- - `agentdb_rl_transfer` — transfer learned policy to new task
2141
- - `agentdb_rl_explain` — explain why a prediction was made
97
+ Every mutation flows through the proof validation layer:
2142
98
 
2143
- </details>
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
2144
104
 
2145
- ---
105
+ ## Key Features
2146
106
 
2147
- <details>
2148
- <summary><strong>Hybrid Search</strong> — BM25 keyword + vector fusion for best-of-both-worlds retrieval</summary>
107
+ ### 1. Proof-Gated Mutations (ADR-060)
2149
108
 
2150
- Combine traditional keyword search (BM25) with vector similarity for retrieval that handles both exact matches and semantic meaning:
109
+ Every state mutation requires a cryptographic proof:
2151
110
 
2152
111
  ```typescript
2153
- import { createHybridSearch, createKeywordIndex } from 'agentdb';
2154
-
2155
- // Create keyword index (BM25)
2156
- const keywordIndex = createKeywordIndex({
2157
- k1: 1.2, // term frequency saturation
2158
- b: 0.75, // document length normalization
2159
- avgDocLength: 100,
2160
- });
2161
-
2162
- // Index documents
2163
- keywordIndex.add('doc-1', 'JWT authentication with refresh token rotation');
2164
- keywordIndex.add('doc-2', 'OAuth2 PKCE flow for mobile applications');
2165
-
2166
- // Create hybrid search (keyword + vector)
2167
- const hybrid = createHybridSearch(keywordIndex, vectorBackend, {
2168
- fusion: 'rrf', // 'rrf' (Reciprocal Rank Fusion) | 'linear' | 'max'
2169
- keywordWeight: 0.3, // 30% keyword, 70% vector
2170
- vectorWeight: 0.7,
2171
- });
2172
-
2173
- // Search with both keyword and semantic matching
2174
- const results = await hybrid.search({
2175
- text: 'JWT refresh token', // keyword query
2176
- embedding: queryEmbedding, // vector query
2177
- k: 10,
2178
- });
2179
- // Results fused from both sources — exact term matches + semantic similarity
2180
- ```
2181
-
2182
- ### Fusion Strategies
2183
-
2184
- | Strategy | How it works | Best For |
2185
- | --- | --- | --- |
2186
- | **RRF** (default) | `1/(k + rank)` — rank-based fusion, no score calibration needed | General use |
2187
- | **Linear** | `α × keyword_score + β × vector_score` — weighted score combination | When you know the right balance |
2188
- | **Max** | `max(keyword_score, vector_score)` — takes highest signal | When either source is sufficient |
2189
-
2190
- > **When to use hybrid search:** When your data contains domain-specific terms (function names, error codes, product IDs) that vector embeddings might miss, but you also want semantic understanding for natural language queries.
2191
-
2192
- </details>
2193
-
2194
- ---
112
+ import { MutationGuard } from 'agentdb/security';
2195
113
 
2196
- <details>
2197
- <summary><strong>LLM Router</strong> — auto-select from 5 providers based on cost, quality, and privacy</summary>
2198
-
2199
- AgentDB can route LLM queries to the optimal provider based on your constraints:
2200
-
2201
- ```typescript
2202
- import { LLMRouter } from 'agentdb';
2203
-
2204
- const router = new LLMRouter({
2205
- providers: {
2206
- ruvllm: { enabled: true }, // Local, SIMD-optimized, free
2207
- openrouter: { apiKey: process.env.OPENROUTER_KEY }, // 200+ models, 99% cost savings
2208
- gemini: { apiKey: process.env.GEMINI_KEY }, // Free tier available
2209
- anthropic: { apiKey: process.env.ANTHROPIC_KEY }, // Claude models
2210
- onnx: { enabled: true }, // Local models via transformers.js
2211
- },
2212
- strategy: 'auto', // auto-selects based on constraints below
2213
- constraints: {
2214
- maxCostPerQuery: 0.001, // max $0.001 per query
2215
- minQuality: 0.8, // minimum quality score
2216
- preferLocal: true, // prefer local models when possible
2217
- requirePrivacy: false, // if true, only uses local providers
2218
- },
114
+ const guard = new MutationGuard({
115
+ strictMode: true,
116
+ enableNative: true // Prefer native proofs
2219
117
  });
2220
118
 
2221
- const response = await router.generate('Summarize this document...', {
2222
- maxTokens: 500,
2223
- temperature: 0.7,
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' }
2224
125
  });
2225
- ```
2226
126
 
2227
- ### Provider Comparison
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
2228
132
 
2229
- | Provider | Latency | Cost | Privacy | Models |
2230
- | --- | --- | --- | --- | --- |
2231
- | **RuvLLM** | Fastest | Free | Full (local) | SIMD-optimized local models |
2232
- | **ONNX** | Fast | Free | Full (local) | transformers.js models |
2233
- | **OpenRouter** | ~500ms | $0.0001+ | Cloud | 200+ models (GPT-4, Claude, Llama, etc.) |
2234
- | **Gemini** | ~300ms | Free tier | Cloud | Gemini Pro, Flash |
2235
- | **Anthropic** | ~1s | $0.003+ | Cloud | Claude Opus, Sonnet, Haiku |
2236
-
2237
- ```typescript
2238
- // Check what's available locally
2239
- import { isRuvLLMInstalled } from 'agentdb';
2240
- if (await isRuvLLMInstalled()) {
2241
- // Local inference available — no API keys needed
133
+ // Backend validates before execution
134
+ if (guard.validateProof(proof)) {
135
+ backend.insert(proof.vectorId, proof.embedding, proof.metadata);
2242
136
  }
2243
137
  ```
2244
138
 
2245
- </details>
2246
-
2247
- ---
2248
-
2249
- <details>
2250
- <summary><strong>Auth & Audit</strong> — JWT, API keys, Argon2id, and compliance-ready logging</summary>
2251
-
2252
- Enterprise-ready authentication and audit logging for production deployments.
2253
-
2254
- ### Authentication
2255
-
2256
- ```typescript
2257
- import { AuthService } from 'agentdb/services/auth';
2258
-
2259
- const auth = new AuthService(db, {
2260
- jwtSecret: process.env.JWT_SECRET,
2261
- accessTokenTTL: '15m',
2262
- refreshTokenTTL: '7d',
2263
- maxLoginAttempts: 5, // account lockout after 5 failures
2264
- lockoutDuration: '30m',
2265
- });
2266
-
2267
- // User registration (Argon2id password hashing)
2268
- const user = await auth.register({ email, password, role: 'user' });
2269
-
2270
- // Login — returns access + refresh token pair
2271
- const { accessToken, refreshToken } = await auth.login(email, password);
139
+ ### 2. Eight Graph-Transformer Modules
2272
140
 
2273
- // Token verification
2274
- const payload = await auth.verifyAccessToken(accessToken);
141
+ Native Rust implementations via `@ruvector/graph-transformer`:
2275
142
 
2276
- // API key management
2277
- const apiKey = await auth.generateApiKey(userId, { name: 'prod-key', scopes: ['read', 'write'] });
2278
- await auth.rotateApiKey(apiKey.id); // automatic rotation
2279
- ```
2280
-
2281
- ### Audit Logging
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
2282
151
 
2283
152
  ```typescript
2284
- import { AuditLogger } from 'agentdb/services/audit-logger';
153
+ import { GraphTransformerService } from 'agentdb';
2285
154
 
2286
- const audit = new AuditLogger({
2287
- retention: '90d', // log retention period
2288
- compliance: ['SOC2', 'GDPR'], // compliance frameworks
2289
- autoRotate: true, // automatic log rotation
155
+ const transformer = new GraphTransformerService({
156
+ enableNative: true,
157
+ modules: ['sublinear', 'causal', 'verified']
2290
158
  });
2291
159
 
2292
- // 13 audit event types tracked automatically:
2293
- // - jwt_auth, api_key_create, api_key_rotate, api_key_revoke
2294
- // - login_success, login_failure, registration
2295
- // - config_change, permission_change
2296
- // - rate_limit_exceeded, sensitive_data_access
2297
- // - data_export, data_deletion
2298
- ```
2299
-
2300
- ### Security Utilities
160
+ await transformer.initialize();
2301
161
 
2302
- ```typescript
2303
- import { hashPassword, verifyPassword, generateApiKey } from 'agentdb/utils/crypto';
162
+ // Use sublinear attention (O(n log n))
163
+ const attended = await transformer.sublinearAttention(
164
+ queryVector,
165
+ keyMatrix,
166
+ valueMatrix
167
+ );
2304
168
 
2305
- const hash = await hashPassword('user-password'); // Argon2id
2306
- const valid = await verifyPassword('user-password', hash);
2307
- const key = generateApiKey(); // cryptographically random
169
+ // Verify training step
170
+ const trainingProof = await transformer.verifiedTraining(
171
+ weights,
172
+ gradients,
173
+ learningRate
174
+ );
2308
175
  ```
2309
176
 
2310
- </details>
177
+ ### 3. Twenty-One Active Controllers
2311
178
 
2312
- ---
179
+ All cognitive memory patterns are production-ready:
2313
180
 
2314
- <details>
2315
- <summary><strong>Metadata Filtering</strong>10 MongoDB-style query operators</summary>
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)
2316
194
 
2317
- Filter search results and database queries using MongoDB-style operators:
195
+ ## Installation
2318
196
 
2319
- ```typescript
2320
- import { MetadataFilter } from 'agentdb';
197
+ ```bash
198
+ # v3 Alpha (proof-gated mutations)
199
+ npm install agentdb@v3
2321
200
 
2322
- const filter = new MetadataFilter();
201
+ # Stable v2 (production-ready)
202
+ npm install agentdb@latest
2323
203
 
2324
- // Episodes with reward > 0.8 and specific tags
2325
- const episodes = await filter.filterEpisodes(db, {
2326
- reward: { $gt: 0.8 },
2327
- tags: { $contains: 'security' },
2328
- status: { $in: ['success', 'partial'] },
2329
- archived: { $exists: false },
2330
- });
204
+ # With optional native addons for 150x performance
205
+ npm install agentdb@v3 ruvector@latest
2331
206
 
2332
- // Patterns matching complex criteria
2333
- const patterns = await filter.filterPatterns(db, {
2334
- successRate: { $gte: 0.7, $lte: 1.0 },
2335
- taskType: { $ne: 'deprecated' },
2336
- createdAt: { $gt: lastWeekTimestamp },
2337
- });
207
+ # For browser environments (WASM only)
208
+ npm install agentdb@v3
209
+ # Native addons will be skipped automatically
2338
210
  ```
2339
211
 
2340
- ### Supported Operators
2341
-
2342
- | Operator | Description | Example |
2343
- | --- | --- | --- |
2344
- | `$eq` | Equal | `{ status: { $eq: 'active' } }` |
2345
- | `$ne` | Not equal | `{ role: { $ne: 'admin' } }` |
2346
- | `$gt` | Greater than | `{ reward: { $gt: 0.5 } }` |
2347
- | `$gte` | Greater than or equal | `{ score: { $gte: 0.8 } }` |
2348
- | `$lt` | Less than | `{ age: { $lt: 90 } }` |
2349
- | `$lte` | Less than or equal | `{ priority: { $lte: 3 } }` |
2350
- | `$in` | In array | `{ type: { $in: ['a', 'b'] } }` |
2351
- | `$nin` | Not in array | `{ status: { $nin: ['deleted'] } }` |
2352
- | `$contains` | Contains substring | `{ tags: { $contains: 'auth' } }` |
2353
- | `$exists` | Field exists | `{ metadata: { $exists: true } }` |
2354
-
2355
- </details>
2356
-
2357
- ---
2358
-
2359
- <details>
2360
- <summary><strong>AgentDBFast</strong> — 50-200x faster programmatic API (skip the CLI overhead)</summary>
212
+ ## API Overview
2361
213
 
2362
- The `AgentDBFast` wrapper provides direct programmatic access that's 50-200x faster than going through the CLI:
214
+ ### Core Class
2363
215
 
2364
216
  ```typescript
2365
- import { createFastAgentDB } from 'agentdb/wrappers/agentdb-fast';
217
+ import { AgentDB } from 'agentdb';
2366
218
 
2367
- const db = await createFastAgentDB({
2368
- path: './agent-memory.db',
219
+ const db = new AgentDB({
220
+ dbPath: './memory.db',
2369
221
  dimension: 384,
2370
- model: 'Xenova/all-MiniLM-L6-v2',
222
+ vectorBackend: 'ruvector', // or 'hnswlib' | 'sqlite'
223
+ enableProofGate: true,
224
+ strictMode: true
2371
225
  });
2372
226
 
2373
- // All operations bypass CLI parsing overhead
2374
- await db.insert('doc-1', embedding, metadata);
2375
- const results = await db.search(queryEmbedding, 10);
2376
- await db.batchInsert(documents);
2377
-
2378
- // Performance wrapper includes:
2379
- // - Direct function calls (no CLI arg parsing)
2380
- // - Pre-initialized connections (no startup cost per call)
2381
- // - Batched operations
2382
- // - Connection pooling
2383
- ```
2384
-
2385
- ### Wrapper Performance vs CLI
2386
-
2387
- | Operation | CLI | AgentDBFast | Speedup |
2388
- | --- | --- | --- | --- |
2389
- | Single insert | ~20ms | ~0.1ms | 200x |
2390
- | Search (k=10) | ~15ms | ~0.08ms | 187x |
2391
- | Batch insert (100) | ~500ms | ~10ms | 50x |
2392
-
2393
- ### Attention Wrappers
2394
-
2395
- Production-ready attention implementations with 11-22x speedup over naive:
2396
-
2397
- ```typescript
2398
- import {
2399
- MultiHeadAttention,
2400
- FlashAttention,
2401
- LinearAttention,
2402
- HyperbolicAttention,
2403
- MoEAttention,
2404
- } from 'agentdb/wrappers';
2405
-
2406
- // Flash Attention — O(N) memory instead of O(N^2)
2407
- const flash = new FlashAttention({ numHeads: 8 });
2408
- const result = await flash.forward(query, keys, values);
2409
-
2410
- // Mixture of Experts — routes to specialized attention heads
2411
- const moe = new MoEAttention({ numExperts: 4, topK: 2 });
2412
- const result = await moe.forward(query, keys, values);
227
+ await db.initialize();
2413
228
  ```
2414
229
 
2415
- ### Embedding Providers
2416
-
2417
- Multiple embedding backends with automatic fallback:
230
+ ### Controller Access
2418
231
 
2419
232
  ```typescript
2420
- import {
2421
- OpenAIEmbeddingService,
2422
- TransformersEmbeddingService,
2423
- MockEmbeddingService,
2424
- } from 'agentdb/wrappers';
2425
-
2426
- // OpenAI (cloud)
2427
- const openai = new OpenAIEmbeddingService({ apiKey: process.env.OPENAI_KEY });
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');
2428
238
 
2429
- // Transformers.js (local, free)
2430
- const local = new TransformersEmbeddingService({ model: 'Xenova/all-MiniLM-L6-v2' });
2431
-
2432
- // Mock (testing)
2433
- const mock = new MockEmbeddingService({ dimension: 384 });
239
+ // Access proof engine
240
+ const guard = db.getMutationGuard();
241
+ const stats = guard?.getStats();
2434
242
  ```
2435
243
 
2436
- </details>
2437
-
2438
- ---
2439
-
2440
- <details>
2441
- <summary><strong>Benchmark Suite</strong> — 5 built-in benchmarks with custom benchmark support</summary>
2442
-
2443
- Run performance benchmarks to validate your deployment:
244
+ ### Security Primitives
2444
245
 
2445
246
  ```typescript
2446
- import { BenchmarkSuite, runBenchmarks, formatReportAsMarkdown } from 'agentdb';
247
+ import { MutationGuard, AttestationLog } from 'agentdb/security';
2447
248
 
2448
- // Run all built-in benchmarks
2449
- const report = await runBenchmarks({
2450
- dimension: 384,
2451
- iterations: 100,
2452
- warmup: 10,
249
+ // Create guard
250
+ const guard = new MutationGuard({
251
+ strictMode: true,
252
+ enableNative: true,
253
+ logPath: './attestations.log'
2453
254
  });
2454
255
 
2455
- console.log(formatReportAsMarkdown(report));
2456
- ```
2457
-
2458
- ### Built-in Benchmarks
256
+ // Generate proof
257
+ const proof = guard.generateProof({
258
+ operation: 'insert',
259
+ vectorId: 'vec-123',
260
+ embedding: embedding,
261
+ metadata: { source: 'test' }
262
+ });
2459
263
 
2460
- | Benchmark | Measures | Key Metrics |
2461
- | --- | --- | --- |
2462
- | **VectorInsertBenchmark** | Insert throughput | ops/sec, p50/p99 latency |
2463
- | **VectorSearchBenchmark** | Search performance | ops/sec, recall@k, latency distribution |
2464
- | **MemoryUsageBenchmark** | RAM consumption | bytes per vector, total footprint |
2465
- | **ConcurrencyBenchmark** | Parallel performance | throughput under load, contention |
2466
- | **QuantizationBenchmark** | Compression tradeoffs | quality loss vs memory savings |
264
+ // Access attestation log
265
+ const log = guard.getAttestationLog();
266
+ const recentProofs = await log.query({ limit: 10 });
267
+ ```
2467
268
 
2468
- ### Custom Benchmarks
269
+ ### Backend Integration
2469
270
 
2470
271
  ```typescript
2471
- import { Benchmark, BenchmarkSuite } from 'agentdb';
2472
-
2473
- class MyBenchmark extends Benchmark {
2474
- name = 'my-custom-benchmark';
2475
-
2476
- async setup() { /* prepare data */ }
2477
- async run() { /* measure this */ }
2478
- async teardown() { /* cleanup */ }
2479
- }
2480
-
2481
- const suite = new BenchmarkSuite();
2482
- suite.add(new MyBenchmark());
2483
- const report = await suite.run({ iterations: 50 });
2484
-
2485
- // Compare reports across runs
2486
- import { formatComparisonAsMarkdown } from 'agentdb';
2487
- console.log(formatComparisonAsMarkdown(reportBefore, reportAfter));
2488
- ```
272
+ import { GuardedVectorBackend } from 'agentdb/backends';
2489
273
 
2490
- ### CLI Benchmarks
274
+ // Wrap any backend with proof validation
275
+ const guardedBackend = new GuardedVectorBackend(rawBackend, guard);
2491
276
 
2492
- ```bash
2493
- npm run benchmark # Quick benchmark
2494
- npm run benchmark:full # Full suite
2495
- npm run benchmark:attention # Attention mechanism performance
2496
- npm run benchmark:backends # Compare all backends
2497
- npm run benchmark:ruvector # RuVector-specific benchmarks
2498
- npm run benchmark:all # Everything
277
+ // All operations require proof
278
+ await guardedBackend.insert(proof);
279
+ await guardedBackend.search(query, k, proof);
2499
280
  ```
2500
281
 
2501
- </details>
2502
-
2503
- ---
2504
-
2505
- ## Testing
282
+ ## Performance
2506
283
 
2507
- <details>
2508
- <summary><strong>Test Suite</strong> unit, integration, performance, security, and browser tests</summary>
284
+ **Proof Generation:**
285
+ - Native (NAPI-RS): ~50μs per proof
286
+ - WASM: ~200μs per proof
287
+ - JavaScript: ~500μs per proof
2509
288
 
2510
- AgentDB ships with a comprehensive test suite covering every layer of the stack. All tests run via [Vitest](https://vitest.dev/) with parallel execution.
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
2511
293
 
2512
- ### Quick Commands
294
+ **Package Size:**
295
+ - v2: 50.1MB (with unused native binaries)
296
+ - v3: 1.4MB (zero-native regression fixed)
2513
297
 
2514
- ```bash
2515
- npm test # Run all tests (watch mode)
2516
- npm run test:unit # Unit tests only (single run)
2517
- npm run test:browser # Browser bundle + WASM tests
2518
- npm run test:ci # CI pipeline: browser tests + build + bundle verification
2519
- ```
298
+ ## Documentation
2520
299
 
2521
- ### What's Tested
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
2522
305
 
2523
- | Suite | Coverage | What it validates |
2524
- | --- | --- | --- |
2525
- | **Unit tests** | Core controllers, memory patterns, embedding service, quantization | All 6 cognitive memory patterns, 9 RL algorithms, filter expressions, security validators |
2526
- | **Browser tests** | WASM store, attention mechanisms, product quantization, SIMD fallbacks | Full vector DB in browser, Flash/Hyperbolic/MoE attention, PQ8/PQ16/PQ32 compression |
2527
- | **Integration tests** | End-to-end flows, backend auto-selection, MCP tool execution | Self-learning pipeline, Cognitive Container operations, federated aggregation |
2528
- | **Performance tests** | Latency benchmarks, throughput, scaling behavior | 61us search target, 32.6M ops/sec pattern search, batch insert speedup |
2529
- | **Security tests** | Input validation, injection prevention, witness chain verification | XSS patterns, SQL injection, path traversal, Cypher sanitization, SHAKE-256 |
306
+ ## MCP Integration (Claude Code)
2530
307
 
2531
- ### Benchmarks
308
+ Zero-code integration with AI coding assistants:
2532
309
 
2533
310
  ```bash
2534
- npm run benchmark # Quick benchmark (insert + search)
2535
- npm run benchmark:full # Full suite with all backends
2536
- npm run benchmark:attention # Attention mechanism performance
2537
- npm run benchmark:backends # Compare RuVector vs RVF vs HNSWLib vs sql.js
2538
- npm run benchmark:ruvector # RuVector-specific benchmarks
2539
- npm run benchmark:all # Run everything
2540
- ```
2541
-
2542
- ### CI Pipeline
2543
-
2544
- The CI pipeline runs `test:ci` which executes:
2545
- 1. **Browser bundle tests** — verifies WASM and JS fallbacks work
2546
- 2. **TypeScript build** — full `tsc` compilation
2547
- 3. **Bundle verification** — ensures all export paths resolve correctly
2548
-
2549
- ### Writing Custom Tests
2550
-
2551
- ```typescript
2552
- import { describe, it, expect } from 'vitest';
2553
- import { createDatabase, ReasoningBank, EmbeddingService } from 'agentdb';
2554
-
2555
- describe('My Agent Memory', () => {
2556
- it('stores and retrieves patterns', async () => {
2557
- const db = await createDatabase(':memory:');
2558
- const embedder = new EmbeddingService({ model: 'Xenova/all-MiniLM-L6-v2' });
2559
- await embedder.initialize();
311
+ # One-command setup
312
+ claude mcp add agentdb npx agentdb@v3 mcp start
2560
313
 
2561
- const bank = new ReasoningBank(db, embedder);
2562
- await bank.storePattern({ taskType: 'test', approach: 'TDD', successRate: 0.95 });
2563
-
2564
- const results = await bank.searchPatterns({ task: 'testing', k: 5 });
2565
- expect(results.length).toBeGreaterThan(0);
2566
- });
2567
- });
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
2568
319
  ```
2569
320
 
2570
- </details>
2571
-
2572
- ---
2573
-
2574
- ## Documentation
321
+ ## License
2575
322
 
2576
- | Document | Description |
2577
- | --- | --- |
2578
- | [MCP Tool Optimization Guide](docs/guides/) | Comprehensive MCP patterns |
2579
- | [Embedding Models Guide](docs/guides/) | Model selection and benchmarks |
2580
- | [Simulation System](simulation/README.md) | 31 scenarios, interactive wizard |
2581
- | [Security Hardening](docs/guides/) | Input validation and security patterns |
2582
- | [Chat Ecosystem](../agentdb-chat/README.md) | `@agentdb/chat` integration guide |
2583
- | [ADR-010: Solver Integration](docs/adrs/ADR-010-rvf-solver-v014-deep-integration.md) | SolverBandit + rvf-solver deep integration |
323
+ MIT OR Apache-2.0
2584
324
 
2585
- ---
325
+ See [LICENSE-MIT](LICENSE-MIT) and [LICENSE-APACHE](LICENSE-APACHE) for details.
2586
326
 
2587
327
  ## Contributing
2588
328
 
2589
- See [CONTRIBUTING.md](CONTRIBUTING.md) for guidelines. Areas of interest: additional RL algorithms, performance optimizations, new backend integrations, documentation improvements.
2590
-
2591
- ---
329
+ We welcome contributions! See [CONTRIBUTING.md](CONTRIBUTING.md) for guidelines.
2592
330
 
2593
- ## License
331
+ ## Acknowledgments
2594
332
 
2595
- MIT OR Apache-2.0 See [LICENSE-MIT](LICENSE-MIT) and [LICENSE-APACHE](LICENSE-APACHE).
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
2596
339
 
2597
340
  ---
2598
341
 
2599
- **The only vector database that learns.** Start in 30 seconds:
2600
-
2601
- ```bash
2602
- npm install agentdb
2603
- ```
342
+ **Built with ❤️ for the agentic era**
2604
343
 
2605
- [Quick Start](#quick-start) | [Tutorials](#tutorials) | [MCP Integration](#mcp-integration) | [GitHub](https://github.com/ruvnet/agentic-flow/tree/main/packages/agentdb) | [npm](https://www.npmjs.com/package/agentdb)
344
+ [Documentation](./docs/) | [GitHub](https://github.com/ruvnet/agentic-flow/tree/main/packages/agentdb) | [npm](https://www.npmjs.com/package/agentdb)