agentdb 2.0.0-alpha.1 → 2.0.0-alpha.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (208) hide show
  1. package/dist/agentdb.min.js +4 -4
  2. package/dist/simulation/cli.js +0 -0
  3. package/dist/src/cli/lib/config-manager.d.ts.map +1 -1
  4. package/dist/src/cli/lib/config-manager.js.map +1 -1
  5. package/dist/src/cli/lib/history-tracker.d.ts.map +1 -1
  6. package/dist/src/cli/lib/history-tracker.js +7 -1
  7. package/dist/src/cli/lib/history-tracker.js.map +1 -1
  8. package/examples/README.md +105 -0
  9. package/examples/quickstart.js +43 -0
  10. package/package.json +6 -2
  11. package/simulation/.claude-flow/metrics/agent-metrics.json +1 -0
  12. package/simulation/.claude-flow/metrics/performance.json +87 -0
  13. package/simulation/.claude-flow/metrics/task-metrics.json +10 -0
  14. package/simulation/COMPLETION-STATUS.md +139 -0
  15. package/simulation/FINAL-RESULTS.md +414 -0
  16. package/simulation/FINAL-STATUS.md +281 -0
  17. package/simulation/INTEGRATION-COMPLETE.md +452 -0
  18. package/simulation/MIGRATION-STATUS.md +231 -0
  19. package/simulation/OPTIMIZATION-RESULTS.md +397 -0
  20. package/simulation/PHASE1-COMPLETE.md +163 -0
  21. package/simulation/README.md +848 -0
  22. package/simulation/SIMULATION-RESULTS.md +239 -0
  23. package/simulation/cli.ts +78 -0
  24. package/simulation/configs/default.json +37 -0
  25. package/simulation/data/advanced/aidefence.graph +0 -0
  26. package/simulation/data/advanced/bmssp.graph +0 -0
  27. package/simulation/data/advanced/consciousness.graph +0 -0
  28. package/simulation/data/advanced/goalie.graph +0 -0
  29. package/simulation/data/advanced/psycho-symbolic.graph +0 -0
  30. package/simulation/data/advanced/research-swarm.graph +0 -0
  31. package/simulation/data/advanced/sublinear.graph +0 -0
  32. package/simulation/data/advanced/temporal.graph +0 -0
  33. package/simulation/data/causal.graph +0 -0
  34. package/simulation/data/graph-traversal.graph +0 -0
  35. package/simulation/data/lean-agentic.graph +0 -0
  36. package/simulation/data/reflexion.graph +0 -0
  37. package/simulation/data/skills.graph +0 -0
  38. package/simulation/data/stock-market.graph +0 -0
  39. package/simulation/data/strange-loops.graph +0 -0
  40. package/simulation/data/swarm.graph +0 -0
  41. package/simulation/data/voting-consensus.graph +0 -0
  42. package/simulation/docs/CLI-INTEGRATION-PLAN.md +1038 -0
  43. package/simulation/docs/COMPREHENSIVE-LATENT-SPACE-COMPLETION.md +354 -0
  44. package/simulation/docs/DOCUMENTATION-INDEX.md +226 -0
  45. package/simulation/docs/IMPLEMENTATION-COMPLETE.md +521 -0
  46. package/simulation/docs/OPTIMIZATION-SUMMARY.md +279 -0
  47. package/simulation/docs/README.md +229 -0
  48. package/simulation/docs/SWARM-5-INTEGRATION-SUMMARY.md +528 -0
  49. package/simulation/docs/TESTING-SUMMARY.md +304 -0
  50. package/simulation/docs/architecture/EXTENSION-API.md +868 -0
  51. package/simulation/docs/architecture/INTEGRATION-ARCHITECTURE.md +1138 -0
  52. package/simulation/docs/architecture/OPTIMIZATION-STRATEGY.md +778 -0
  53. package/simulation/docs/architecture/SIMULATION-ARCHITECTURE.md +892 -0
  54. package/simulation/docs/guides/CLI-REFERENCE.md +896 -0
  55. package/simulation/docs/guides/CUSTOM-SIMULATIONS.md +931 -0
  56. package/simulation/docs/guides/DEPLOYMENT.md +832 -0
  57. package/simulation/docs/guides/IMPLEMENTATION-SUMMARY.md +544 -0
  58. package/simulation/docs/guides/MIGRATION-GUIDE.md +591 -0
  59. package/simulation/docs/guides/QUICK-START.md +361 -0
  60. package/simulation/docs/guides/README.md +736 -0
  61. package/simulation/docs/guides/TROUBLESHOOTING.md +817 -0
  62. package/simulation/docs/guides/WIZARD-GUIDE.md +869 -0
  63. package/simulation/docs/reports/latent-space/MASTER-SYNTHESIS.md +345 -0
  64. package/simulation/docs/reports/latent-space/README.md +132 -0
  65. package/simulation/docs/reports/latent-space/attention-analysis-RESULTS.md +238 -0
  66. package/simulation/docs/reports/latent-space/clustering-analysis-RESULTS.md +210 -0
  67. package/simulation/docs/reports/latent-space/hnsw-exploration-RESULTS.md +332 -0
  68. package/simulation/docs/reports/latent-space/hypergraph-exploration-RESULTS.md +37 -0
  69. package/simulation/docs/reports/latent-space/neural-augmentation-RESULTS.md +69 -0
  70. package/simulation/docs/reports/latent-space/quantum-hybrid-RESULTS.md +91 -0
  71. package/simulation/docs/reports/latent-space/self-organizing-hnsw-RESULTS.md +51 -0
  72. package/simulation/docs/reports/latent-space/traversal-optimization-RESULTS.md +238 -0
  73. package/simulation/reports/README.md +397 -0
  74. package/simulation/reports/advanced-simulations-performance.md +1241 -0
  75. package/simulation/reports/aidefence-integration-2025-11-30T01-36-53-486Z.json +30 -0
  76. package/simulation/reports/architecture-analysis.md +1396 -0
  77. package/simulation/reports/basic-scenarios-performance.md +1840 -0
  78. package/simulation/reports/bmssp-integration-2025-11-30T01-36-27-193Z.json +30 -0
  79. package/simulation/reports/bmssp-integration-2025-11-30T03-38-12-887Z.json +30 -0
  80. package/simulation/reports/causal-reasoning-2025-11-29T23-35-21-795Z.json +36 -0
  81. package/simulation/reports/causal-reasoning-2025-11-30T00-58-42-862Z.json +30 -0
  82. package/simulation/reports/causal-reasoning-2025-11-30T00-59-12-546Z.json +40 -0
  83. package/simulation/reports/consciousness-explorer-2025-11-30T01-36-51-269Z.json +31 -0
  84. package/simulation/reports/core-benchmarks.md +727 -0
  85. package/simulation/reports/goalie-integration-2025-11-30T01-36-52-377Z.json +30 -0
  86. package/simulation/reports/graph-traversal-2025-11-29T23-35-35-279Z.json +78 -0
  87. package/simulation/reports/graph-traversal-2025-11-29T23-37-36-697Z.json +30 -0
  88. package/simulation/reports/graph-traversal-2025-11-30T01-03-59-716Z.json +30 -0
  89. package/simulation/reports/graph-traversal-2025-11-30T01-05-10-984Z.json +30 -0
  90. package/simulation/reports/graph-traversal-2025-11-30T01-06-16-334Z.json +30 -0
  91. package/simulation/reports/graph-traversal-2025-11-30T01-06-53-312Z.json +30 -0
  92. package/simulation/reports/graph-traversal-2025-11-30T01-07-51-075Z.json +24 -0
  93. package/simulation/reports/graph-traversal-2025-11-30T01-08-22-179Z.json +42 -0
  94. package/simulation/reports/lean-agentic-swarm-2025-11-29T23-37-23-804Z.json +148 -0
  95. package/simulation/reports/lean-agentic-swarm-2025-11-30T01-31-24-401Z.json +31 -0
  96. package/simulation/reports/lean-agentic-swarm-2025-11-30T03-38-01-470Z.json +31 -0
  97. package/simulation/reports/multi-agent-swarm-2025-11-29T23-35-28-093Z.json +78 -0
  98. package/simulation/reports/multi-agent-swarm-2025-11-30T01-03-54-062Z.json +42 -0
  99. package/simulation/reports/multi-agent-swarm-2025-11-30T01-05-06-092Z.json +42 -0
  100. package/simulation/reports/psycho-symbolic-reasoner-2025-11-30T01-36-50-180Z.json +30 -0
  101. package/simulation/reports/quality-metrics.md +727 -0
  102. package/simulation/reports/reflexion-learning-2025-11-29T23-35-09-774Z.json +48 -0
  103. package/simulation/reports/reflexion-learning-2025-11-29T23-37-16-934Z.json +36 -0
  104. package/simulation/reports/reflexion-learning-2025-11-30T00-07-49-259Z.json +30 -0
  105. package/simulation/reports/reflexion-learning-2025-11-30T00-09-29-319Z.json +51 -0
  106. package/simulation/reports/reflexion-learning-2025-11-30T00-28-37-659Z.json +51 -0
  107. package/simulation/reports/reflexion-learning-2025-11-30T01-31-30-690Z.json +29 -0
  108. package/simulation/reports/reflexion-learning-2025-11-30T03-38-06-937Z.json +29 -0
  109. package/simulation/reports/research-foundations.md +2004 -0
  110. package/simulation/reports/research-swarm-2025-11-30T01-36-54-647Z.json +30 -0
  111. package/simulation/reports/scalability-deployment.md +2404 -0
  112. package/simulation/reports/skill-evolution-2025-11-29T23-35-15-945Z.json +36 -0
  113. package/simulation/reports/skill-evolution-2025-11-30T01-03-17-995Z.json +30 -0
  114. package/simulation/reports/skill-evolution-2025-11-30T01-03-48-441Z.json +30 -0
  115. package/simulation/reports/skill-evolution-2025-11-30T01-05-00-554Z.json +30 -0
  116. package/simulation/reports/skill-evolution-2025-11-30T01-06-11-436Z.json +30 -0
  117. package/simulation/reports/skill-evolution-2025-11-30T01-06-51-979Z.json +30 -0
  118. package/simulation/reports/skill-evolution-2025-11-30T01-07-32-695Z.json +40 -0
  119. package/simulation/reports/stock-market-emergence-2025-11-30T00-11-43-865Z.json +56 -0
  120. package/simulation/reports/stock-market-emergence-2025-11-30T00-28-57-495Z.json +56 -0
  121. package/simulation/reports/strange-loops-2025-11-29T23-37-30-621Z.json +78 -0
  122. package/simulation/reports/strange-loops-2025-11-30T00-07-55-415Z.json +30 -0
  123. package/simulation/reports/strange-loops-2025-11-30T00-09-35-133Z.json +30 -0
  124. package/simulation/reports/strange-loops-2025-11-30T00-48-50-744Z.json +24 -0
  125. package/simulation/reports/strange-loops-2025-11-30T00-54-48-044Z.json +24 -0
  126. package/simulation/reports/strange-loops-2025-11-30T00-57-27-633Z.json +24 -0
  127. package/simulation/reports/strange-loops-2025-11-30T00-57-59-135Z.json +42 -0
  128. package/simulation/reports/sublinear-solver-2025-11-30T01-36-33-134Z.json +30 -0
  129. package/simulation/reports/temporal-lead-solver-2025-11-30T01-36-38-628Z.json +30 -0
  130. package/simulation/reports/use-cases-applications.md +2212 -0
  131. package/simulation/reports/voting-system-consensus-2025-11-30T00-11-37-199Z.json +58 -0
  132. package/simulation/reports/voting-system-consensus-2025-11-30T00-28-47-735Z.json +58 -0
  133. package/simulation/runner.ts +300 -0
  134. package/simulation/scenarios/README-advanced/aidefence-integration.md +63 -0
  135. package/simulation/scenarios/README-advanced/bmssp-integration.md +58 -0
  136. package/simulation/scenarios/README-advanced/consciousness-explorer.md +53 -0
  137. package/simulation/scenarios/README-advanced/goalie-integration.md +61 -0
  138. package/simulation/scenarios/README-advanced/psycho-symbolic-reasoner.md +55 -0
  139. package/simulation/scenarios/README-advanced/research-swarm.md +63 -0
  140. package/simulation/scenarios/README-advanced/sublinear-solver.md +58 -0
  141. package/simulation/scenarios/README-advanced/temporal-lead-solver.md +55 -0
  142. package/simulation/scenarios/README-basic/causal-reasoning.md +39 -0
  143. package/simulation/scenarios/README-basic/graph-traversal.md +41 -0
  144. package/simulation/scenarios/README-basic/lean-agentic-swarm.md +122 -0
  145. package/simulation/scenarios/README-basic/multi-agent-swarm.md +34 -0
  146. package/simulation/scenarios/README-basic/reflexion-learning.md +41 -0
  147. package/simulation/scenarios/README-basic/skill-evolution.md +38 -0
  148. package/simulation/scenarios/README-basic/stock-market-emergence.md +28 -0
  149. package/simulation/scenarios/README-basic/strange-loops.md +36 -0
  150. package/simulation/scenarios/README-basic/voting-system-consensus.md +28 -0
  151. package/simulation/scenarios/README.md +438 -0
  152. package/simulation/scenarios/aidefence-integration.ts +165 -0
  153. package/simulation/scenarios/bmssp-integration.ts +137 -0
  154. package/simulation/scenarios/causal-reasoning.ts +143 -0
  155. package/simulation/scenarios/consciousness-explorer.ts +139 -0
  156. package/simulation/scenarios/domain-examples/.claude-flow/metrics/agent-metrics.json +1 -0
  157. package/simulation/scenarios/domain-examples/.claude-flow/metrics/performance.json +87 -0
  158. package/simulation/scenarios/domain-examples/.claude-flow/metrics/task-metrics.json +10 -0
  159. package/simulation/scenarios/domain-examples/README.md +525 -0
  160. package/simulation/scenarios/domain-examples/e-commerce-recommendations.ts +220 -0
  161. package/simulation/scenarios/domain-examples/index.ts +81 -0
  162. package/simulation/scenarios/domain-examples/iot-sensor-networks.ts +290 -0
  163. package/simulation/scenarios/domain-examples/medical-imaging.ts +181 -0
  164. package/simulation/scenarios/domain-examples/robotics-navigation.ts +214 -0
  165. package/simulation/scenarios/domain-examples/scientific-research.ts +250 -0
  166. package/simulation/scenarios/domain-examples/trading-systems.ts +138 -0
  167. package/simulation/scenarios/goalie-integration.ts +161 -0
  168. package/simulation/scenarios/graph-traversal.ts +129 -0
  169. package/simulation/scenarios/latent-space/OPTIMIZATION-COMPLETE.md +287 -0
  170. package/simulation/scenarios/latent-space/README-attention-analysis.md +170 -0
  171. package/simulation/scenarios/latent-space/README-clustering-analysis.md +239 -0
  172. package/simulation/scenarios/latent-space/README-hnsw-exploration.md +199 -0
  173. package/simulation/scenarios/latent-space/README-hypergraph-exploration.md +279 -0
  174. package/simulation/scenarios/latent-space/README-neural-augmentation.md +267 -0
  175. package/simulation/scenarios/latent-space/README-quantum-hybrid.md +276 -0
  176. package/simulation/scenarios/latent-space/README-self-organizing-hnsw.md +244 -0
  177. package/simulation/scenarios/latent-space/README-traversal-optimization.md +212 -0
  178. package/simulation/scenarios/latent-space/attention-analysis.ts +598 -0
  179. package/simulation/scenarios/latent-space/clustering-analysis.ts +796 -0
  180. package/simulation/scenarios/latent-space/hnsw-exploration.ts +526 -0
  181. package/simulation/scenarios/latent-space/hypergraph-exploration.ts +706 -0
  182. package/simulation/scenarios/latent-space/index.ts +47 -0
  183. package/simulation/scenarios/latent-space/neural-augmentation.ts +604 -0
  184. package/simulation/scenarios/latent-space/quantum-hybrid.ts +508 -0
  185. package/simulation/scenarios/latent-space/self-organizing-hnsw.ts +680 -0
  186. package/simulation/scenarios/latent-space/traversal-optimization.ts +782 -0
  187. package/simulation/scenarios/lean-agentic-swarm.ts +182 -0
  188. package/simulation/scenarios/multi-agent-swarm.ts +146 -0
  189. package/simulation/scenarios/psycho-symbolic-reasoner.ts +136 -0
  190. package/simulation/scenarios/reflexion-learning.ts +132 -0
  191. package/simulation/scenarios/research-swarm.ts +187 -0
  192. package/simulation/scenarios/skill-evolution.ts +135 -0
  193. package/simulation/scenarios/stock-market-emergence.ts +323 -0
  194. package/simulation/scenarios/strange-loops.ts +175 -0
  195. package/simulation/scenarios/sublinear-solver.ts +108 -0
  196. package/simulation/scenarios/temporal-lead-solver.ts +121 -0
  197. package/simulation/scenarios/voting-system-consensus.ts +251 -0
  198. package/simulation/tests/latent-space/attention-analysis.test.ts +204 -0
  199. package/simulation/tests/latent-space/clustering-analysis.test.ts +281 -0
  200. package/simulation/tests/latent-space/hnsw-exploration.test.ts +253 -0
  201. package/simulation/tests/latent-space/hypergraph-exploration.test.ts +295 -0
  202. package/simulation/tests/latent-space/neural-augmentation.test.ts +326 -0
  203. package/simulation/tests/latent-space/quantum-hybrid.test.ts +307 -0
  204. package/simulation/tests/latent-space/self-organizing-hnsw.test.ts +291 -0
  205. package/simulation/tests/latent-space/traversal-optimization.test.ts +261 -0
  206. package/simulation/types.ts +177 -0
  207. package/simulation/utils/PerformanceOptimizer.ts +269 -0
  208. package/src/cli/lib/history-tracker.ts +7 -1
@@ -0,0 +1,326 @@
1
+ /**
2
+ * Neural Augmentation Simulation Tests
3
+ *
4
+ * Tests GNN-guided edge selection, RL navigation, embedding-topology
5
+ * co-optimization, and attention-based layer routing.
6
+ *
7
+ * Target Metrics:
8
+ * - GNN edge selection (adaptive M: 8-32)
9
+ * - Memory reduction >15% (target: 18%)
10
+ * - RL navigation convergence <500 episodes
11
+ * - Hop reduction >20% (target: 26%)
12
+ * - Joint optimization +9.1%
13
+ * - Full pipeline improvement >25% (target: 29.4%)
14
+ */
15
+
16
+ import { describe, it, expect, beforeAll } from 'vitest';
17
+ import { neuralAugmentationScenario } from '../../scenarios/latent-space/neural-augmentation';
18
+ import type { SimulationReport } from '../../types';
19
+
20
+ describe('NeuralAugmentation', () => {
21
+ let report: SimulationReport;
22
+
23
+ beforeAll(async () => {
24
+ report = await neuralAugmentationScenario.run(neuralAugmentationScenario.config);
25
+ }, 120000); // 120s timeout
26
+
27
+ describe('Optimal Strategy', () => {
28
+ it('should select full-neural or joint-opt', () => {
29
+ const best = report.summary.bestStrategy;
30
+ expect(['full-neural', 'joint-opt', 'gnn-edges']).toContain(best.strategy);
31
+ });
32
+
33
+ it('should test baseline', () => {
34
+ const strategies = neuralAugmentationScenario.config.strategies;
35
+ const baseline = strategies.find(s => s.name === 'baseline');
36
+ expect(baseline).toBeDefined();
37
+ });
38
+
39
+ it('should test all neural components', () => {
40
+ const strategies = neuralAugmentationScenario.config.strategies;
41
+ expect(strategies.some(s => s.name === 'gnn-edges')).toBe(true);
42
+ expect(strategies.some(s => s.name === 'rl-nav')).toBe(true);
43
+ expect(strategies.some(s => s.name === 'joint-opt')).toBe(true);
44
+ });
45
+ });
46
+
47
+ describe('GNN Edge Selection', () => {
48
+ it('should reduce memory >15%', () => {
49
+ const edgeMetrics = report.metrics.edgeSelection;
50
+ expect(edgeMetrics.avgSparsityGain).toBeGreaterThan(15);
51
+ });
52
+
53
+ it('should target 18% memory reduction', () => {
54
+ const gnnResults = (report.detailedResults as any[]).filter(
55
+ r => r.strategy === 'gnn-edges' || r.strategy === 'full-neural'
56
+ );
57
+
58
+ gnnResults.forEach(r => {
59
+ if (r.metrics.sparsityGain) {
60
+ expect(r.metrics.sparsityGain).toBeCloseTo(18, 5);
61
+ }
62
+ });
63
+ });
64
+
65
+ it('should adapt M between 8-32', () => {
66
+ const gnnResults = (report.detailedResults as any[]).filter(
67
+ r => r.strategy === 'gnn-edges' || r.strategy === 'full-neural'
68
+ );
69
+
70
+ gnnResults.forEach(r => {
71
+ if (r.metrics.avgDegree) {
72
+ expect(r.metrics.avgDegree).toBeGreaterThanOrEqual(8);
73
+ expect(r.metrics.avgDegree).toBeLessThanOrEqual(32);
74
+ }
75
+ });
76
+ });
77
+
78
+ it('should maintain graph quality', () => {
79
+ const gnnResults = (report.detailedResults as any[]).filter(
80
+ r => r.strategy === 'gnn-edges'
81
+ );
82
+
83
+ gnnResults.forEach(r => {
84
+ expect(r.metrics.edgeSelectionQuality).toBeGreaterThan(0.8);
85
+ });
86
+ });
87
+ });
88
+
89
+ describe('RL Navigation', () => {
90
+ it('should reduce hops >20%', () => {
91
+ const navMetrics = report.metrics.navigation;
92
+ expect(navMetrics.avgHopsReduction).toBeGreaterThan(20);
93
+ });
94
+
95
+ it('should target 26% hop reduction', () => {
96
+ const rlResults = (report.detailedResults as any[]).filter(
97
+ r => r.strategy === 'rl-nav' || r.strategy === 'full-neural'
98
+ );
99
+
100
+ rlResults.forEach(r => {
101
+ if (r.metrics.avgHopsReduction) {
102
+ expect(r.metrics.avgHopsReduction).toBeCloseTo(26, 8);
103
+ }
104
+ });
105
+ });
106
+
107
+ it('should converge <500 episodes', () => {
108
+ const rlResults = (report.detailedResults as any[]).filter(
109
+ r => r.strategy === 'rl-nav' || r.strategy === 'full-neural'
110
+ );
111
+
112
+ rlResults.forEach(r => {
113
+ if (r.metrics.rlConvergenceEpochs) {
114
+ expect(r.metrics.rlConvergenceEpochs).toBeLessThan(500);
115
+ }
116
+ });
117
+ });
118
+
119
+ it('should achieve high policy quality', () => {
120
+ const rlResults = (report.detailedResults as any[]).filter(
121
+ r => r.strategy === 'rl-nav'
122
+ );
123
+
124
+ rlResults.forEach(r => {
125
+ if (r.metrics.policyQuality) {
126
+ expect(r.metrics.policyQuality).toBeGreaterThan(0.90);
127
+ }
128
+ });
129
+ });
130
+ });
131
+
132
+ describe('Joint Embedding-Topology Optimization', () => {
133
+ it('should improve performance >9%', () => {
134
+ const jointMetrics = report.metrics.coOptimization;
135
+ expect(jointMetrics.avgJointGain).toBeGreaterThan(7);
136
+ });
137
+
138
+ it('should target +9.1% improvement', () => {
139
+ const jointResults = (report.detailedResults as any[]).filter(
140
+ r => r.strategy === 'joint-opt' || r.strategy === 'full-neural'
141
+ );
142
+
143
+ jointResults.forEach(r => {
144
+ if (r.metrics.jointOptimizationGain) {
145
+ expect(r.metrics.jointOptimizationGain).toBeCloseTo(9.1, 3);
146
+ }
147
+ });
148
+ });
149
+
150
+ it('should improve embedding quality', () => {
151
+ const jointResults = (report.detailedResults as any[]).filter(
152
+ r => r.strategy === 'joint-opt'
153
+ );
154
+
155
+ jointResults.forEach(r => {
156
+ expect(r.metrics.embeddingQuality).toBeGreaterThan(0.90);
157
+ });
158
+ });
159
+
160
+ it('should improve topology quality', () => {
161
+ const jointResults = (report.detailedResults as any[]).filter(
162
+ r => r.strategy === 'joint-opt'
163
+ );
164
+
165
+ jointResults.forEach(r => {
166
+ expect(r.metrics.topologyQuality).toBeGreaterThan(0.85);
167
+ });
168
+ });
169
+ });
170
+
171
+ describe('Attention-Based Layer Routing', () => {
172
+ it('should skip layers efficiently', () => {
173
+ const routingMetrics = report.metrics.layerRouting;
174
+ expect(routingMetrics.avgLayerSkipRate).toBeGreaterThan(30);
175
+ });
176
+
177
+ it('should target 35-50% layer skip rate', () => {
178
+ const fullNeural = (report.detailedResults as any[]).filter(
179
+ r => r.strategy === 'full-neural'
180
+ );
181
+
182
+ fullNeural.forEach(r => {
183
+ if (r.metrics.layerSkipRate) {
184
+ expect(r.metrics.layerSkipRate).toBeGreaterThan(30);
185
+ expect(r.metrics.layerSkipRate).toBeLessThan(60);
186
+ }
187
+ });
188
+ });
189
+
190
+ it('should maintain routing accuracy >85%', () => {
191
+ const fullNeural = (report.detailedResults as any[]).filter(
192
+ r => r.strategy === 'full-neural'
193
+ );
194
+
195
+ fullNeural.forEach(r => {
196
+ if (r.metrics.routingAccuracy) {
197
+ expect(r.metrics.routingAccuracy).toBeGreaterThan(0.85);
198
+ }
199
+ });
200
+ });
201
+
202
+ it('should speed up search', () => {
203
+ const fullNeural = (report.detailedResults as any[]).filter(
204
+ r => r.strategy === 'full-neural'
205
+ );
206
+
207
+ fullNeural.forEach(r => {
208
+ if (r.metrics.speedupFromRouting) {
209
+ expect(r.metrics.speedupFromRouting).toBeGreaterThan(1.2);
210
+ }
211
+ });
212
+ });
213
+ });
214
+
215
+ describe('Full Neural Pipeline', () => {
216
+ it('should improve >25% end-to-end', () => {
217
+ const avgImprovement = report.summary.avgNavigationImprovement;
218
+ expect(avgImprovement).toBeGreaterThan(20);
219
+ });
220
+
221
+ it('should target 29.4% improvement', () => {
222
+ const fullNeural = (report.detailedResults as any[]).find(
223
+ r => r.strategy === 'full-neural'
224
+ );
225
+
226
+ if (fullNeural) {
227
+ const totalGain = (fullNeural.metrics.navigationEfficiency || 0) +
228
+ (fullNeural.metrics.sparsityGain || 0) / 2;
229
+ expect(totalGain).toBeGreaterThan(25);
230
+ }
231
+ });
232
+
233
+ it('should combine all components', () => {
234
+ const fullNeural = (report.detailedResults as any[]).filter(
235
+ r => r.strategy === 'full-neural'
236
+ );
237
+
238
+ fullNeural.forEach(r => {
239
+ expect(r.metrics.sparsityGain).toBeDefined();
240
+ expect(r.metrics.navigationEfficiency).toBeDefined();
241
+ expect(r.metrics.jointOptimizationGain).toBeDefined();
242
+ });
243
+ });
244
+ });
245
+
246
+ describe('Component Integration', () => {
247
+ it('should test GNN architecture', () => {
248
+ const strategies = neuralAugmentationScenario.config.strategies;
249
+ const gnn = strategies.find(s => s.name === 'gnn-edges');
250
+
251
+ if (gnn) {
252
+ expect(gnn.parameters.gnnLayers).toBe(3);
253
+ expect(gnn.parameters.hiddenDim).toBe(128);
254
+ }
255
+ });
256
+
257
+ it('should test RL parameters', () => {
258
+ const strategies = neuralAugmentationScenario.config.strategies;
259
+ const rl = strategies.find(s => s.name === 'rl-nav');
260
+
261
+ if (rl) {
262
+ expect(rl.parameters.rlEpisodes).toBeGreaterThan(0);
263
+ expect(rl.parameters.learningRate).toBeLessThan(0.01);
264
+ }
265
+ });
266
+ });
267
+
268
+ describe('Scalability', () => {
269
+ it('should test at 100k nodes', () => {
270
+ const sizes = neuralAugmentationScenario.config.graphSizes;
271
+ expect(sizes).toContain(100000);
272
+ });
273
+
274
+ it('should test multiple dimensions', () => {
275
+ const dims = neuralAugmentationScenario.config.dimensions;
276
+ expect(dims).toContain(128);
277
+ expect(dims).toContain(768);
278
+ });
279
+
280
+ it('should maintain quality at scale', () => {
281
+ const large = (report.detailedResults as any[]).filter(r => r.size === 100000);
282
+
283
+ large.forEach(r => {
284
+ if (r.strategy !== 'baseline') {
285
+ expect(r.metrics.navigationEfficiency).toBeGreaterThan(0);
286
+ }
287
+ });
288
+ });
289
+ });
290
+
291
+ describe('Baseline Comparison', () => {
292
+ it('should outperform baseline', () => {
293
+ const baseline = (report.detailedResults as any[]).filter(r => r.strategy === 'baseline');
294
+ const neural = (report.detailedResults as any[]).filter(r => r.strategy !== 'baseline');
295
+
296
+ if (baseline.length > 0 && neural.length > 0) {
297
+ const avgNeuralGain = neural.reduce(
298
+ (sum, r) => sum + (r.metrics.navigationEfficiency || 0), 0
299
+ ) / neural.length;
300
+ expect(avgNeuralGain).toBeGreaterThan(0);
301
+ }
302
+ });
303
+ });
304
+
305
+ describe('Report Generation', () => {
306
+ it('should generate analysis', () => {
307
+ expect(report.analysis).toBeDefined();
308
+ expect(report.analysis).toContain('Neural');
309
+ });
310
+
311
+ it('should provide recommendations', () => {
312
+ expect(report.recommendations).toBeDefined();
313
+ expect(report.recommendations.length).toBeGreaterThanOrEqual(4);
314
+ });
315
+
316
+ it('should generate neural diagrams', () => {
317
+ expect(report.artifacts.gnnArchitectures).toBeDefined();
318
+ expect(report.artifacts.navigationPolicies).toBeDefined();
319
+ expect(report.artifacts.optimizationCurves).toBeDefined();
320
+ });
321
+
322
+ it('should complete within timeout', () => {
323
+ expect(report.executionTimeMs).toBeLessThan(120000);
324
+ });
325
+ });
326
+ });
@@ -0,0 +1,307 @@
1
+ /**
2
+ * Quantum-Hybrid HNSW Simulation Tests (Theoretical)
3
+ *
4
+ * Tests theoretical quantum-enhanced HNSW approaches including
5
+ * quantum amplitude encoding, Grover search, and quantum walks.
6
+ *
7
+ * **IMPORTANT**: This is theoretical validation only, not actual quantum computing.
8
+ *
9
+ * Target Metrics:
10
+ * - Viability assessment (2025: 12.4%, 2030: 38.2%, 2040: 84.7%)
11
+ * - Theoretical speedup calculations (Grover: 4x)
12
+ * - Hardware requirement progression
13
+ * - Keep as theoretical validation only
14
+ */
15
+
16
+ import { describe, it, expect, beforeAll } from 'vitest';
17
+ import { quantumHybridScenario } from '../../scenarios/latent-space/quantum-hybrid';
18
+ import type { SimulationReport } from '../../types';
19
+
20
+ describe('QuantumHybrid (Theoretical)', () => {
21
+ let report: SimulationReport;
22
+
23
+ beforeAll(async () => {
24
+ report = await quantumHybridScenario.run(quantumHybridScenario.config);
25
+ }, 60000); // 60s timeout
26
+
27
+ describe('Disclaimer and Scope', () => {
28
+ it('should be marked as theoretical', () => {
29
+ expect(report.scenarioId).toBe('quantum-hybrid');
30
+ expect(report.analysis).toContain('DISCLAIMER');
31
+ expect(report.analysis).toContain('theoretical');
32
+ });
33
+
34
+ it('should not claim real quantum computing', () => {
35
+ expect(report.analysis).toContain('research purposes');
36
+ });
37
+ });
38
+
39
+ describe('2025 Viability (Current)', () => {
40
+ it('should assess near-term viability ~12.4%', () => {
41
+ const nearTerm = report.summary.nearTermViability;
42
+ expect(nearTerm).toBeLessThan(0.20);
43
+ expect(nearTerm).toBeGreaterThan(0.05);
44
+ });
45
+
46
+ it('should target ~12.4% viability', () => {
47
+ const nearTerm = report.summary.nearTermViability;
48
+ expect(nearTerm).toBeCloseTo(0.124, 0.08);
49
+ });
50
+
51
+ it('should have limited qubit count', () => {
52
+ const hardware2025 = quantumHybridScenario.config.hardwareProfiles.find(h => h.year === 2025);
53
+ expect(hardware2025?.qubits).toBe(100);
54
+ });
55
+
56
+ it('should have high error rates', () => {
57
+ const hardware2025 = quantumHybridScenario.config.hardwareProfiles.find(h => h.year === 2025);
58
+ expect(hardware2025?.errorRate).toBe(0.001);
59
+ });
60
+ });
61
+
62
+ describe('2030 Viability (Mid-term)', () => {
63
+ it('should project ~38.2% viability', () => {
64
+ const results = (report.detailedResults as any[]).filter(r => r.hardwareYear === 2030);
65
+
66
+ if (results.length > 0) {
67
+ const avg = results.reduce((sum, r) => sum + (r.viability?.current2025Viability || 0), 0) / results.length;
68
+ expect(avg).toBeGreaterThan(0.20);
69
+ expect(avg).toBeLessThan(0.60);
70
+ }
71
+ });
72
+ });
73
+
74
+ describe('2040 Viability (Long-term)', () => {
75
+ it('should project ~84.7% viability', () => {
76
+ const longTerm = report.summary.longTermProjection;
77
+ expect(longTerm).toBeGreaterThan(0.70);
78
+ });
79
+
80
+ it('should target 84.7% by 2040', () => {
81
+ const longTerm = report.summary.longTermProjection;
82
+ expect(longTerm).toBeCloseTo(0.847, 0.15);
83
+ });
84
+
85
+ it('should have advanced hardware', () => {
86
+ const hardware2040 = quantumHybridScenario.config.hardwareProfiles.find(h => h.year === 2040);
87
+ expect(hardware2040?.qubits).toBe(10000);
88
+ expect(hardware2040?.errorRate).toBe(0.00001);
89
+ });
90
+ });
91
+
92
+ describe('Grover Algorithm', () => {
93
+ it('should test Grover search', () => {
94
+ const algorithms = quantumHybridScenario.config.algorithms;
95
+ const grover = algorithms.find(a => a.name === 'grover');
96
+ expect(grover).toBeDefined();
97
+ });
98
+
99
+ it('should calculate √M speedup', () => {
100
+ const groverResults = (report.detailedResults as any[]).filter(r => r.algorithm === 'grover');
101
+
102
+ groverResults.forEach(r => {
103
+ if (r.speedups?.groverSpeedup) {
104
+ const M = r.parameters?.neighborhoodSize || 16;
105
+ expect(r.speedups.groverSpeedup).toBeCloseTo(Math.sqrt(M), 2);
106
+ }
107
+ });
108
+ });
109
+
110
+ it('should target 4x speedup for M=16', () => {
111
+ const grover16 = (report.detailedResults as any[]).find(
112
+ r => r.algorithm === 'grover' && r.parameters?.neighborhoodSize === 16
113
+ );
114
+
115
+ if (grover16 && grover16.speedups) {
116
+ expect(grover16.speedups.groverSpeedup).toBeCloseTo(4, 1);
117
+ }
118
+ });
119
+ });
120
+
121
+ describe('Quantum Walk', () => {
122
+ it('should test quantum walk algorithm', () => {
123
+ const algorithms = quantumHybridScenario.config.algorithms;
124
+ const qwalk = algorithms.find(a => a.name === 'quantum-walk');
125
+ expect(qwalk).toBeDefined();
126
+ });
127
+
128
+ it('should calculate speedup', () => {
129
+ const qwalkResults = (report.detailedResults as any[]).filter(r => r.algorithm === 'quantum-walk');
130
+
131
+ qwalkResults.forEach(r => {
132
+ if (r.speedups?.quantumWalkSpeedup) {
133
+ expect(r.speedups.quantumWalkSpeedup).toBeGreaterThan(1);
134
+ }
135
+ });
136
+ });
137
+ });
138
+
139
+ describe('Amplitude Encoding', () => {
140
+ it('should test amplitude encoding', () => {
141
+ const algorithms = quantumHybridScenario.config.algorithms;
142
+ const amplitude = algorithms.find(a => a.name === 'amplitude-encoding');
143
+ expect(amplitude).toBeDefined();
144
+ });
145
+
146
+ it('should require log(d) qubits', () => {
147
+ const ampResults = (report.detailedResults as any[]).filter(r => r.algorithm === 'amplitude-encoding');
148
+
149
+ ampResults.forEach(r => {
150
+ const dim = r.dimension || 128;
151
+ const expectedQubits = Math.ceil(Math.log2(dim));
152
+ if (r.quantumMetrics?.qubitsRequired) {
153
+ expect(r.quantumMetrics.qubitsRequired).toBeCloseTo(expectedQubits, 2);
154
+ }
155
+ });
156
+ });
157
+ });
158
+
159
+ describe('Hybrid Approach', () => {
160
+ it('should test hybrid classical-quantum', () => {
161
+ const algorithms = quantumHybridScenario.config.algorithms;
162
+ const hybrid = algorithms.find(a => a.name === 'hybrid');
163
+ expect(hybrid).toBeDefined();
164
+ });
165
+
166
+ it('should split workload', () => {
167
+ const hybridResults = (report.detailedResults as any[]).filter(r => r.algorithm === 'hybrid');
168
+
169
+ hybridResults.forEach(r => {
170
+ if (r.quantumMetrics) {
171
+ expect(r.quantumMetrics.classicalFraction).toBeGreaterThan(0);
172
+ expect(r.quantumMetrics.quantumFraction).toBeGreaterThan(0);
173
+ expect(r.quantumMetrics.classicalFraction + r.quantumMetrics.quantumFraction).toBeCloseTo(1.0, 0.1);
174
+ }
175
+ });
176
+ });
177
+
178
+ it('should respect qubit budget', () => {
179
+ const hybrid = quantumHybridScenario.config.algorithms.find(a => a.name === 'hybrid');
180
+ expect(hybrid?.parameters.quantumBudget).toBe(50);
181
+ });
182
+ });
183
+
184
+ describe('Resource Requirements', () => {
185
+ it('should track qubit requirements', () => {
186
+ const metrics = report.metrics.resourceRequirements;
187
+ expect(metrics.avgQubitsRequired).toBeGreaterThan(0);
188
+ });
189
+
190
+ it('should track gate depth', () => {
191
+ const metrics = report.metrics.resourceRequirements;
192
+ expect(metrics.maxGateDepth).toBeGreaterThan(0);
193
+ });
194
+
195
+ it('should assess feasibility', () => {
196
+ const results = report.detailedResults as any[];
197
+ results.forEach(r => {
198
+ if (r.resources) {
199
+ expect(r.resources.feasible).toBeDefined();
200
+ }
201
+ });
202
+ });
203
+ });
204
+
205
+ describe('Hardware Progression', () => {
206
+ it('should test multiple hardware profiles', () => {
207
+ const profiles = quantumHybridScenario.config.hardwareProfiles;
208
+ expect(profiles.length).toBe(3);
209
+ expect(profiles.map(p => p.year)).toEqual([2025, 2030, 2040]);
210
+ });
211
+
212
+ it('should show qubit growth', () => {
213
+ const profiles = quantumHybridScenario.config.hardwareProfiles;
214
+ expect(profiles[0].qubits).toBeLessThan(profiles[1].qubits);
215
+ expect(profiles[1].qubits).toBeLessThan(profiles[2].qubits);
216
+ });
217
+
218
+ it('should show error rate improvement', () => {
219
+ const profiles = quantumHybridScenario.config.hardwareProfiles;
220
+ expect(profiles[0].errorRate).toBeGreaterThan(profiles[1].errorRate);
221
+ expect(profiles[1].errorRate).toBeGreaterThan(profiles[2].errorRate);
222
+ });
223
+ });
224
+
225
+ describe('Bottleneck Analysis', () => {
226
+ it('should identify bottlenecks', () => {
227
+ const results = report.detailedResults as any[];
228
+ const with2025 = results.filter(r => r.hardwareYear === 2025);
229
+
230
+ with2025.forEach(r => {
231
+ if (r.viability?.bottleneck) {
232
+ expect(['qubits', 'coherence', 'error-rate']).toContain(r.viability.bottleneck);
233
+ }
234
+ });
235
+ });
236
+ });
237
+
238
+ describe('Theoretical Speedup Validation', () => {
239
+ it('should calculate theoretical speedups', () => {
240
+ const speedups = report.metrics.theoreticalSpeedups;
241
+ expect(speedups.maxTheoreticalSpeedup).toBeGreaterThan(1);
242
+ });
243
+
244
+ it('should not exceed theoretical limits', () => {
245
+ const results = report.detailedResults as any[];
246
+ results.forEach(r => {
247
+ if (r.speedups?.theoreticalSpeedup) {
248
+ expect(r.speedups.theoreticalSpeedup).toBeLessThan(1000); // Reasonable upper bound
249
+ }
250
+ });
251
+ });
252
+ });
253
+
254
+ describe('Classical Baseline', () => {
255
+ it('should test classical baseline', () => {
256
+ const algorithms = quantumHybridScenario.config.algorithms;
257
+ const classical = algorithms.find(a => a.name === 'classical');
258
+ expect(classical).toBeDefined();
259
+ });
260
+
261
+ it('should have 1x speedup for classical', () => {
262
+ const classicalResults = (report.detailedResults as any[]).filter(r => r.algorithm === 'classical');
263
+
264
+ classicalResults.forEach(r => {
265
+ if (r.speedups) {
266
+ expect(r.speedups.theoreticalSpeedup).toBe(1.0);
267
+ }
268
+ });
269
+ });
270
+ });
271
+
272
+ describe('Recommendations', () => {
273
+ it('should warn about current viability', () => {
274
+ expect(report.recommendations.some(r => r.includes('NOT viable'))).toBe(true);
275
+ });
276
+
277
+ it('should suggest hybrid approaches', () => {
278
+ expect(report.recommendations.some(r => r.includes('hybrid'))).toBe(true);
279
+ });
280
+
281
+ it('should project future timeline', () => {
282
+ expect(report.recommendations.some(r => r.includes('2040'))).toBe(true);
283
+ });
284
+ });
285
+
286
+ describe('Report Generation', () => {
287
+ it('should generate theoretical analysis', () => {
288
+ expect(report.analysis).toBeDefined();
289
+ expect(report.analysis).toContain('Quantum');
290
+ });
291
+
292
+ it('should provide viability assessment', () => {
293
+ expect(report.analysis).toContain('2025');
294
+ expect(report.analysis).toContain('2045');
295
+ });
296
+
297
+ it('should generate visualizations', () => {
298
+ expect(report.artifacts.speedupCharts).toBeDefined();
299
+ expect(report.artifacts.resourceDiagrams).toBeDefined();
300
+ expect(report.artifacts.viabilityTimeline).toBeDefined();
301
+ });
302
+
303
+ it('should complete efficiently', () => {
304
+ expect(report.executionTimeMs).toBeLessThan(60000);
305
+ });
306
+ });
307
+ });