agentic-qe 3.7.21 → 3.8.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (164) hide show
  1. package/.claude/helpers/brain-checkpoint.cjs +4 -1
  2. package/.claude/helpers/statusline-v3.cjs +3 -1
  3. package/.claude/skills/skills-manifest.json +1 -1
  4. package/CHANGELOG.md +45 -0
  5. package/README.md +2 -14
  6. package/assets/helpers/statusline-v3.cjs +3 -1
  7. package/dist/cli/brain-commands.js +6 -10
  8. package/dist/cli/bundle.js +7441 -4327
  9. package/dist/cli/commands/audit.d.ts +43 -0
  10. package/dist/cli/commands/audit.js +125 -0
  11. package/dist/cli/commands/hooks.js +29 -6
  12. package/dist/cli/commands/init.js +1 -73
  13. package/dist/cli/commands/learning.js +270 -13
  14. package/dist/cli/commands/ruvector-commands.d.ts +15 -0
  15. package/dist/cli/commands/ruvector-commands.js +271 -0
  16. package/dist/cli/handlers/init-handler.d.ts +0 -1
  17. package/dist/cli/handlers/init-handler.js +0 -6
  18. package/dist/cli/index.js +4 -2
  19. package/dist/context/sources/defect-source.js +2 -2
  20. package/dist/context/sources/memory-source.js +2 -2
  21. package/dist/context/sources/requirements-source.js +2 -2
  22. package/dist/coordination/behavior-tree/decorators.d.ts +108 -0
  23. package/dist/coordination/behavior-tree/decorators.js +251 -0
  24. package/dist/coordination/behavior-tree/index.d.ts +12 -0
  25. package/dist/coordination/behavior-tree/index.js +15 -0
  26. package/dist/coordination/behavior-tree/nodes.d.ts +165 -0
  27. package/dist/coordination/behavior-tree/nodes.js +338 -0
  28. package/dist/coordination/behavior-tree/qe-trees.d.ts +105 -0
  29. package/dist/coordination/behavior-tree/qe-trees.js +181 -0
  30. package/dist/coordination/coherence-action-gate.d.ts +284 -0
  31. package/dist/coordination/coherence-action-gate.js +512 -0
  32. package/dist/coordination/index.d.ts +4 -0
  33. package/dist/coordination/index.js +8 -0
  34. package/dist/coordination/reasoning-qec.d.ts +315 -0
  35. package/dist/coordination/reasoning-qec.js +585 -0
  36. package/dist/coordination/task-executor.d.ts +16 -0
  37. package/dist/coordination/task-executor.js +99 -0
  38. package/dist/coordination/workflow-orchestrator.d.ts +29 -0
  39. package/dist/coordination/workflow-orchestrator.js +42 -0
  40. package/dist/domains/visual-accessibility/cnn-visual-regression.d.ts +135 -0
  41. package/dist/domains/visual-accessibility/cnn-visual-regression.js +327 -0
  42. package/dist/domains/visual-accessibility/index.d.ts +1 -0
  43. package/dist/domains/visual-accessibility/index.js +4 -0
  44. package/dist/governance/coherence-validator.d.ts +112 -0
  45. package/dist/governance/coherence-validator.js +180 -0
  46. package/dist/governance/index.d.ts +1 -0
  47. package/dist/governance/index.js +2 -0
  48. package/dist/governance/witness-chain.d.ts +311 -0
  49. package/dist/governance/witness-chain.js +509 -0
  50. package/dist/init/index.d.ts +0 -2
  51. package/dist/init/index.js +0 -1
  52. package/dist/init/init-wizard-steps.d.ts +10 -0
  53. package/dist/init/init-wizard-steps.js +87 -1
  54. package/dist/init/init-wizard.d.ts +1 -9
  55. package/dist/init/init-wizard.js +3 -69
  56. package/dist/init/orchestrator.js +0 -1
  57. package/dist/init/phases/01-detection.js +0 -27
  58. package/dist/init/phases/07-hooks.js +6 -4
  59. package/dist/init/phases/phase-interface.d.ts +0 -1
  60. package/dist/init/settings-merge.js +1 -1
  61. package/dist/integrations/browser/qe-dashboard/clustering.d.ts +48 -0
  62. package/dist/integrations/browser/qe-dashboard/clustering.js +183 -0
  63. package/dist/integrations/browser/qe-dashboard/index.d.ts +12 -0
  64. package/dist/integrations/browser/qe-dashboard/index.js +15 -0
  65. package/dist/integrations/browser/qe-dashboard/pattern-explorer.d.ts +165 -0
  66. package/dist/integrations/browser/qe-dashboard/pattern-explorer.js +260 -0
  67. package/dist/integrations/browser/qe-dashboard/wasm-vector-store.d.ts +144 -0
  68. package/dist/integrations/browser/qe-dashboard/wasm-vector-store.js +277 -0
  69. package/dist/integrations/ruvector/cognitive-container-codec.d.ts +51 -0
  70. package/dist/integrations/ruvector/cognitive-container-codec.js +180 -0
  71. package/dist/integrations/ruvector/cognitive-container.d.ts +125 -0
  72. package/dist/integrations/ruvector/cognitive-container.js +306 -0
  73. package/dist/integrations/ruvector/coherence-gate.d.ts +309 -0
  74. package/dist/integrations/ruvector/coherence-gate.js +631 -0
  75. package/dist/integrations/ruvector/compressed-hnsw-integration.d.ts +176 -0
  76. package/dist/integrations/ruvector/compressed-hnsw-integration.js +301 -0
  77. package/dist/integrations/ruvector/dither-adapter.d.ts +122 -0
  78. package/dist/integrations/ruvector/dither-adapter.js +295 -0
  79. package/dist/integrations/ruvector/domain-transfer.d.ts +129 -0
  80. package/dist/integrations/ruvector/domain-transfer.js +220 -0
  81. package/dist/integrations/ruvector/feature-flags.d.ts +214 -2
  82. package/dist/integrations/ruvector/feature-flags.js +167 -2
  83. package/dist/integrations/ruvector/filter-adapter.d.ts +71 -0
  84. package/dist/integrations/ruvector/filter-adapter.js +285 -0
  85. package/dist/integrations/ruvector/gnn-wrapper.d.ts +20 -0
  86. package/dist/integrations/ruvector/gnn-wrapper.js +40 -0
  87. package/dist/integrations/ruvector/hnsw-health-monitor.d.ts +237 -0
  88. package/dist/integrations/ruvector/hnsw-health-monitor.js +394 -0
  89. package/dist/integrations/ruvector/index.d.ts +8 -2
  90. package/dist/integrations/ruvector/index.js +18 -2
  91. package/dist/integrations/ruvector/interfaces.d.ts +40 -0
  92. package/dist/integrations/ruvector/sona-persistence.d.ts +54 -0
  93. package/dist/integrations/ruvector/sona-persistence.js +162 -0
  94. package/dist/integrations/ruvector/sona-three-loop.d.ts +392 -0
  95. package/dist/integrations/ruvector/sona-three-loop.js +814 -0
  96. package/dist/integrations/ruvector/sona-wrapper.d.ts +97 -0
  97. package/dist/integrations/ruvector/sona-wrapper.js +147 -3
  98. package/dist/integrations/ruvector/spectral-math.d.ts +101 -0
  99. package/dist/integrations/ruvector/spectral-math.js +254 -0
  100. package/dist/integrations/ruvector/temporal-compression.d.ts +163 -0
  101. package/dist/integrations/ruvector/temporal-compression.js +318 -0
  102. package/dist/integrations/ruvector/thompson-sampler.d.ts +61 -0
  103. package/dist/integrations/ruvector/thompson-sampler.js +118 -0
  104. package/dist/integrations/ruvector/transfer-coherence-stub.d.ts +80 -0
  105. package/dist/integrations/ruvector/transfer-coherence-stub.js +63 -0
  106. package/dist/integrations/ruvector/transfer-verification.d.ts +119 -0
  107. package/dist/integrations/ruvector/transfer-verification.js +115 -0
  108. package/dist/kernel/hnsw-adapter.d.ts +52 -1
  109. package/dist/kernel/hnsw-adapter.js +139 -4
  110. package/dist/kernel/hnsw-index-provider.d.ts +5 -0
  111. package/dist/kernel/native-hnsw-backend.d.ts +110 -0
  112. package/dist/kernel/native-hnsw-backend.js +408 -0
  113. package/dist/kernel/unified-memory.js +5 -6
  114. package/dist/learning/aqe-learning-engine.d.ts +2 -0
  115. package/dist/learning/aqe-learning-engine.js +65 -0
  116. package/dist/learning/experience-capture-middleware.js +20 -0
  117. package/dist/learning/experience-capture.d.ts +10 -0
  118. package/dist/learning/experience-capture.js +34 -0
  119. package/dist/learning/index.d.ts +2 -2
  120. package/dist/learning/index.js +4 -4
  121. package/dist/learning/metrics-tracker.d.ts +11 -0
  122. package/dist/learning/metrics-tracker.js +29 -13
  123. package/dist/learning/pattern-lifecycle.d.ts +30 -1
  124. package/dist/learning/pattern-lifecycle.js +92 -20
  125. package/dist/learning/pattern-store.d.ts +8 -0
  126. package/dist/learning/pattern-store.js +8 -2
  127. package/dist/learning/qe-unified-memory.js +1 -28
  128. package/dist/learning/regret-tracker.d.ts +201 -0
  129. package/dist/learning/regret-tracker.js +361 -0
  130. package/dist/mcp/bundle.js +5915 -474
  131. package/dist/routing/index.d.ts +4 -2
  132. package/dist/routing/index.js +3 -1
  133. package/dist/routing/neural-tiny-dancer-router.d.ts +268 -0
  134. package/dist/routing/neural-tiny-dancer-router.js +514 -0
  135. package/dist/routing/queen-integration.js +5 -5
  136. package/dist/routing/routing-config.d.ts +6 -0
  137. package/dist/routing/routing-config.js +1 -0
  138. package/dist/routing/simple-neural-router.d.ts +76 -0
  139. package/dist/routing/simple-neural-router.js +202 -0
  140. package/dist/routing/tiny-dancer-router.d.ts +20 -1
  141. package/dist/routing/tiny-dancer-router.js +21 -2
  142. package/dist/test-scheduling/dag-attention-scheduler.d.ts +81 -0
  143. package/dist/test-scheduling/dag-attention-scheduler.js +358 -0
  144. package/dist/test-scheduling/dag-attention-types.d.ts +81 -0
  145. package/dist/test-scheduling/dag-attention-types.js +10 -0
  146. package/dist/test-scheduling/index.d.ts +1 -0
  147. package/dist/test-scheduling/index.js +4 -0
  148. package/dist/test-scheduling/pipeline.d.ts +8 -0
  149. package/dist/test-scheduling/pipeline.js +28 -0
  150. package/package.json +6 -2
  151. package/dist/cli/commands/migrate.d.ts +0 -9
  152. package/dist/cli/commands/migrate.js +0 -566
  153. package/dist/init/init-wizard-migration.d.ts +0 -52
  154. package/dist/init/init-wizard-migration.js +0 -345
  155. package/dist/init/migration/config-migrator.d.ts +0 -31
  156. package/dist/init/migration/config-migrator.js +0 -149
  157. package/dist/init/migration/data-migrator.d.ts +0 -72
  158. package/dist/init/migration/data-migrator.js +0 -232
  159. package/dist/init/migration/detector.d.ts +0 -44
  160. package/dist/init/migration/detector.js +0 -105
  161. package/dist/init/migration/index.d.ts +0 -8
  162. package/dist/init/migration/index.js +0 -8
  163. package/dist/learning/v2-to-v3-migration.d.ts +0 -86
  164. package/dist/learning/v2-to-v3-migration.js +0 -529
@@ -0,0 +1,394 @@
1
+ /**
2
+ * HNSW Health Monitor - Spectral Health Monitoring
3
+ *
4
+ * Monitors the structural health of HNSW indexes using spectral graph
5
+ * theory metrics. Computes Fiedler value (algebraic connectivity),
6
+ * spectral gap, effective resistance, and a combined coherence score.
7
+ *
8
+ * Uses TypeScript power iteration and sample-based estimation for
9
+ * spectral computation. No native package exists for this — the
10
+ * TypeScript implementation is the production implementation.
11
+ *
12
+ * @see Task 3.4: HNSW Health Monitoring
13
+ * @module integrations/ruvector/hnsw-health-monitor
14
+ */
15
+ // Re-export spectral math utilities for backward compatibility
16
+ export { buildLaplacian, laplacianMultiply, vectorNorm, normalizeInPlace, deflateVector, approximateFiedlerValue, approximateSpectralGap, estimateEffectiveResistance, computeCoherenceScore, } from './spectral-math.js';
17
+ import { approximateFiedlerValue, approximateSpectralGap, estimateEffectiveResistance, computeCoherenceScore, } from './spectral-math.js';
18
+ /**
19
+ * Default health monitor configuration.
20
+ */
21
+ export const DEFAULT_HNSW_HEALTH_CONFIG = {
22
+ fiedlerThreshold: 0.01,
23
+ spectralGapThreshold: 0.1,
24
+ resistanceThreshold: 10.0,
25
+ coherenceThreshold: 0.3,
26
+ maxPowerIterations: 100,
27
+ convergenceTolerance: 1e-6,
28
+ resistanceSampleSize: 50,
29
+ maxHistoryEntries: 200,
30
+ minIndexSize: 3,
31
+ };
32
+ // ============================================================================
33
+ // Thresholds (exported for tests)
34
+ // ============================================================================
35
+ export const ALERT_THRESHOLDS = {
36
+ FragileIndex: 0.01,
37
+ PoorExpansion: 0.1,
38
+ HighResistance: 10.0,
39
+ LowCoherence: 0.3,
40
+ };
41
+ let nativeCoherence = null;
42
+ let nativeLoadAttempted = false;
43
+ /**
44
+ * Check for native coherence module.
45
+ * No native package exists — always returns null.
46
+ * The TypeScript power iteration implementation is used.
47
+ */
48
+ function loadNativeCoherence() {
49
+ if (nativeLoadAttempted)
50
+ return nativeCoherence;
51
+ nativeLoadAttempted = true;
52
+ nativeCoherence = null;
53
+ return null;
54
+ }
55
+ /** Reset native loader state (for testing) */
56
+ export function _resetNativeLoader() {
57
+ nativeCoherence = null;
58
+ nativeLoadAttempted = false;
59
+ }
60
+ /**
61
+ * Build an adjacency list from an HNSW-like index by using similarity
62
+ * between stored vectors. When stored vectors are provided, each vector
63
+ * is searched against the index to discover real neighbors. Otherwise,
64
+ * falls back to a circular approximation.
65
+ *
66
+ * @param index - The HNSW index provider
67
+ * @param maxNeighbors - Maximum neighbors per node to consider
68
+ * @param storedVectors - Optional map of id to vector for real neighbor discovery
69
+ * @returns Adjacency list, node count, and adjacency source
70
+ */
71
+ export function buildAdjacencyFromIndex(index, maxNeighbors = 16, storedVectors) {
72
+ const n = index.size();
73
+ if (n === 0)
74
+ return { adjacency: [], nodeCount: 0, adjacencySource: 'approximate' };
75
+ const adjacency = Array.from({ length: n }, () => []);
76
+ const k = Math.min(maxNeighbors, n - 1);
77
+ if (k === 0)
78
+ return { adjacency, nodeCount: n, adjacencySource: 'approximate' };
79
+ // If stored vectors are provided and non-empty, use real search
80
+ if (storedVectors && storedVectors.size > 0) {
81
+ // Build a mapping from vector IDs to adjacency indices (0..n-1)
82
+ const ids = Array.from(storedVectors.keys()).slice(0, n);
83
+ const idToIdx = new Map();
84
+ for (let i = 0; i < ids.length; i++) {
85
+ idToIdx.set(ids[i], i);
86
+ }
87
+ for (let i = 0; i < ids.length; i++) {
88
+ const vec = storedVectors.get(ids[i]);
89
+ if (!vec)
90
+ continue;
91
+ // Search for k+1 neighbors (the query itself may be returned)
92
+ const results = index.search(vec, k + 1);
93
+ for (const result of results) {
94
+ // Skip self
95
+ if (result.id === ids[i])
96
+ continue;
97
+ const neighborIdx = idToIdx.get(result.id);
98
+ if (neighborIdx === undefined)
99
+ continue;
100
+ // Add bidirectional edge
101
+ if (!adjacency[i].includes(neighborIdx)) {
102
+ adjacency[i].push(neighborIdx);
103
+ }
104
+ if (!adjacency[neighborIdx].includes(i)) {
105
+ adjacency[neighborIdx].push(i);
106
+ }
107
+ }
108
+ }
109
+ return { adjacency, nodeCount: n, adjacencySource: 'actual-search' };
110
+ }
111
+ // Fallback: circular approximation when no stored vectors available
112
+ console.warn('[HnswHealthMonitor] No stored vectors provided — using approximate circular adjacency. ' +
113
+ 'Pass stored vectors for accurate health metrics.');
114
+ for (let i = 0; i < n; i++) {
115
+ for (let j = 0; j < k; j++) {
116
+ const neighbor = (i + j + 1) % n;
117
+ if (!adjacency[i].includes(neighbor)) {
118
+ adjacency[i].push(neighbor);
119
+ }
120
+ if (!adjacency[neighbor].includes(i)) {
121
+ adjacency[neighbor].push(i);
122
+ }
123
+ }
124
+ }
125
+ return { adjacency, nodeCount: n, adjacencySource: 'approximate' };
126
+ }
127
+ // ============================================================================
128
+ // HnswHealthMonitor
129
+ // ============================================================================
130
+ /**
131
+ * HNSW Health Monitor
132
+ *
133
+ * Monitors the spectral health of HNSW indexes by computing graph-theoretic
134
+ * metrics. Uses ruvector-coherence for native computation when available,
135
+ * falling back to TypeScript approximations.
136
+ *
137
+ * Health checks are designed to be lightweight enough for periodic use
138
+ * without blocking search operations.
139
+ *
140
+ * @example
141
+ * ```typescript
142
+ * const monitor = new HnswHealthMonitor();
143
+ * const report = monitor.checkHealth(hnswIndex);
144
+ * if (!report.healthy) {
145
+ * console.warn('HNSW index unhealthy:', report.alerts);
146
+ * }
147
+ * ```
148
+ */
149
+ export class HnswHealthMonitor {
150
+ config;
151
+ alerts = [];
152
+ history = [];
153
+ lastReport = null;
154
+ useNative = false;
155
+ nativeChecked = false;
156
+ constructor(config) {
157
+ this.config = { ...DEFAULT_HNSW_HEALTH_CONFIG, ...config };
158
+ }
159
+ /**
160
+ * Perform a health check on an HNSW index.
161
+ *
162
+ * Computes spectral metrics and generates alerts if thresholds are
163
+ * exceeded. Results are recorded in the metrics history.
164
+ *
165
+ * @param index - The HNSW index to check
166
+ * @returns Health report with metrics and alerts
167
+ */
168
+ checkHealth(index) {
169
+ const start = performance.now();
170
+ const indexSize = index.size();
171
+ // Too small for meaningful spectral analysis
172
+ if (indexSize < this.config.minIndexSize) {
173
+ return this.createSmallIndexReport(indexSize, performance.now() - start);
174
+ }
175
+ // Try native backend on first call
176
+ if (!this.nativeChecked) {
177
+ this.nativeChecked = true;
178
+ this.useNative = loadNativeCoherence() !== null;
179
+ }
180
+ // Build adjacency from index
181
+ const { adjacency, nodeCount, adjacencySource } = buildAdjacencyFromIndex(index);
182
+ // Compute spectral metrics
183
+ const metrics = this.useNative
184
+ ? this.computeNativeMetrics(adjacency)
185
+ : this.computeApproximateMetrics(adjacency, nodeCount);
186
+ // Generate alerts
187
+ const newAlerts = this.generateAlerts(metrics);
188
+ // Update persistent alerts list
189
+ this.alerts.length = 0;
190
+ this.alerts.push(...newAlerts);
191
+ const elapsed = performance.now() - start;
192
+ const report = {
193
+ healthy: newAlerts.length === 0,
194
+ metrics,
195
+ alerts: newAlerts,
196
+ indexSize,
197
+ usedNativeBackend: this.useNative,
198
+ adjacencySource,
199
+ checkDurationMs: elapsed,
200
+ checkedAt: new Date(),
201
+ };
202
+ // Record in history
203
+ this.addHistoryPoint({
204
+ coherenceScore: metrics.coherenceScore,
205
+ fiedlerValue: metrics.fiedlerValue,
206
+ indexSize,
207
+ healthy: report.healthy,
208
+ timestamp: report.checkedAt,
209
+ });
210
+ this.lastReport = report;
211
+ return report;
212
+ }
213
+ /**
214
+ * Get current active alerts.
215
+ *
216
+ * @returns Array of active health alerts
217
+ */
218
+ getAlerts() {
219
+ return [...this.alerts];
220
+ }
221
+ /**
222
+ * Get health metrics history.
223
+ *
224
+ * @param limit - Maximum entries to return (most recent)
225
+ * @returns Array of metric points, most recent last
226
+ */
227
+ getMetricsHistory(limit) {
228
+ const entries = [...this.history];
229
+ if (limit !== undefined && limit < entries.length) {
230
+ return entries.slice(-limit);
231
+ }
232
+ return entries;
233
+ }
234
+ /**
235
+ * Check whether the index is currently healthy (no alerts).
236
+ *
237
+ * If no health check has been performed yet, returns true (optimistic).
238
+ *
239
+ * @returns true if the last health check found no alerts
240
+ */
241
+ isHealthy() {
242
+ if (this.lastReport === null)
243
+ return true;
244
+ return this.lastReport.healthy;
245
+ }
246
+ /**
247
+ * Get the last health report, or null if no check has been performed.
248
+ */
249
+ getLastReport() {
250
+ return this.lastReport;
251
+ }
252
+ /**
253
+ * Clear all history and alerts.
254
+ */
255
+ clearHistory() {
256
+ this.history.length = 0;
257
+ this.alerts.length = 0;
258
+ this.lastReport = null;
259
+ }
260
+ // ==========================================================================
261
+ // Private: Metric Computation
262
+ // ==========================================================================
263
+ /**
264
+ * Compute metrics using the native ruvector-coherence module.
265
+ */
266
+ computeNativeMetrics(adjacency) {
267
+ const native = nativeCoherence;
268
+ const fiedlerValue = native.computeFiedlerValue(adjacency);
269
+ const spectralGap = native.computeSpectralGap(adjacency);
270
+ const effectiveResistance = native.computeEffectiveResistance(adjacency);
271
+ const coherenceScore = computeCoherenceScore(fiedlerValue, spectralGap, effectiveResistance);
272
+ return { fiedlerValue, spectralGap, effectiveResistance, coherenceScore };
273
+ }
274
+ /**
275
+ * Compute metrics using TypeScript approximations.
276
+ */
277
+ computeApproximateMetrics(adjacency, n) {
278
+ const fiedlerValue = approximateFiedlerValue(adjacency, n, this.config.maxPowerIterations, this.config.convergenceTolerance);
279
+ const spectralGap = approximateSpectralGap(adjacency, n, this.config.maxPowerIterations, this.config.convergenceTolerance);
280
+ const effectiveResistance = estimateEffectiveResistance(adjacency, n, this.config.resistanceSampleSize, fiedlerValue);
281
+ const coherenceScore = computeCoherenceScore(fiedlerValue, spectralGap, effectiveResistance);
282
+ return { fiedlerValue, spectralGap, effectiveResistance, coherenceScore };
283
+ }
284
+ // ==========================================================================
285
+ // Private: Alert Generation
286
+ // ==========================================================================
287
+ /**
288
+ * Generate alerts based on metric thresholds.
289
+ */
290
+ generateAlerts(metrics) {
291
+ const alerts = [];
292
+ const now = new Date();
293
+ if (metrics.fiedlerValue < this.config.fiedlerThreshold) {
294
+ alerts.push({
295
+ type: 'FragileIndex',
296
+ message: `Fiedler value ${metrics.fiedlerValue.toFixed(6)} is below ` +
297
+ `threshold ${this.config.fiedlerThreshold}. ` +
298
+ `The index graph has weak algebraic connectivity.`,
299
+ value: metrics.fiedlerValue,
300
+ threshold: this.config.fiedlerThreshold,
301
+ timestamp: now,
302
+ });
303
+ }
304
+ if (metrics.spectralGap < this.config.spectralGapThreshold) {
305
+ alerts.push({
306
+ type: 'PoorExpansion',
307
+ message: `Spectral gap ${metrics.spectralGap.toFixed(6)} is below ` +
308
+ `threshold ${this.config.spectralGapThreshold}. ` +
309
+ `The index graph has poor expansion properties.`,
310
+ value: metrics.spectralGap,
311
+ threshold: this.config.spectralGapThreshold,
312
+ timestamp: now,
313
+ });
314
+ }
315
+ if (metrics.effectiveResistance > this.config.resistanceThreshold) {
316
+ alerts.push({
317
+ type: 'HighResistance',
318
+ message: `Average effective resistance ${metrics.effectiveResistance.toFixed(4)} ` +
319
+ `exceeds threshold ${this.config.resistanceThreshold}. ` +
320
+ `Nodes are poorly connected.`,
321
+ value: metrics.effectiveResistance,
322
+ threshold: this.config.resistanceThreshold,
323
+ timestamp: now,
324
+ });
325
+ }
326
+ if (metrics.coherenceScore < this.config.coherenceThreshold) {
327
+ alerts.push({
328
+ type: 'LowCoherence',
329
+ message: `Coherence score ${metrics.coherenceScore.toFixed(4)} is below ` +
330
+ `threshold ${this.config.coherenceThreshold}. ` +
331
+ `Overall index health is degraded.`,
332
+ value: metrics.coherenceScore,
333
+ threshold: this.config.coherenceThreshold,
334
+ timestamp: now,
335
+ });
336
+ }
337
+ return alerts;
338
+ }
339
+ // ==========================================================================
340
+ // Private: Helpers
341
+ // ==========================================================================
342
+ /**
343
+ * Create a report for indexes too small for spectral analysis.
344
+ */
345
+ createSmallIndexReport(indexSize, durationMs) {
346
+ const metrics = {
347
+ fiedlerValue: indexSize > 0 ? 1.0 : 0,
348
+ spectralGap: indexSize > 0 ? 1.0 : 0,
349
+ effectiveResistance: indexSize > 0 ? 0.5 : 0,
350
+ coherenceScore: indexSize > 0 ? 1.0 : 0,
351
+ };
352
+ const report = {
353
+ healthy: true,
354
+ metrics,
355
+ alerts: [],
356
+ indexSize,
357
+ usedNativeBackend: false,
358
+ adjacencySource: 'approximate',
359
+ checkDurationMs: durationMs,
360
+ checkedAt: new Date(),
361
+ };
362
+ this.addHistoryPoint({
363
+ coherenceScore: metrics.coherenceScore,
364
+ fiedlerValue: metrics.fiedlerValue,
365
+ indexSize,
366
+ healthy: true,
367
+ timestamp: report.checkedAt,
368
+ });
369
+ this.lastReport = report;
370
+ return report;
371
+ }
372
+ /**
373
+ * Add a history point, trimming if over limit.
374
+ */
375
+ addHistoryPoint(point) {
376
+ this.history.push(point);
377
+ if (this.history.length > this.config.maxHistoryEntries) {
378
+ this.history.splice(0, this.history.length - this.config.maxHistoryEntries);
379
+ }
380
+ }
381
+ }
382
+ // ============================================================================
383
+ // Factory
384
+ // ============================================================================
385
+ /**
386
+ * Create an HnswHealthMonitor instance.
387
+ *
388
+ * @param config - Optional configuration overrides
389
+ * @returns A new HnswHealthMonitor
390
+ */
391
+ export function createHnswHealthMonitor(config) {
392
+ return new HnswHealthMonitor(config);
393
+ }
394
+ //# sourceMappingURL=hnsw-health-monitor.js.map
@@ -46,7 +46,8 @@ export { RuVectorDiffRiskClassifier, type RiskPatterns } from './diff-risk-class
46
46
  export { RuVectorCoverageRouter, type CoverageThresholds } from './coverage-router';
47
47
  export { RuVectorGraphBoundariesAnalyzer, type GraphConfig } from './graph-boundaries';
48
48
  export { PersistentQLearningRouter, DEFAULT_EWC_CONFIG, DEFAULT_PERSISTENT_CONFIG, type EWCConfig, type PersistentQLearningRouterConfig, } from './persistent-q-router';
49
- export { PersistentSONAEngine, DEFAULT_PERSISTENT_SONA_CONFIG, SONA_PATTERNS_SCHEMA, type PersistentSONAConfig, } from './sona-persistence';
49
+ export { PersistentSONAEngine, DEFAULT_PERSISTENT_SONA_CONFIG, SONA_PATTERNS_SCHEMA, SONA_FISHER_SCHEMA, type PersistentSONAConfig, } from './sona-persistence';
50
+ export { SONAThreeLoopEngine, MicroLoRA, EWCPlusPlus, createSONAThreeLoopEngine, DEFAULT_THREE_LOOP_CONFIG, type AdaptationResult, type ConsolidationResult, type PeerState, type EWCMetrics, type ThreeLoopConfig, } from './sona-three-loop';
50
51
  export { FallbackQLearningRouter, FallbackASTComplexityAnalyzer, FallbackDiffRiskClassifier, FallbackCoverageRouter, FallbackGraphBoundariesAnalyzer, } from './fallback';
51
52
  import type { RuVectorConfig, RuVectorClient } from './interfaces';
52
53
  /**
@@ -85,7 +86,11 @@ export declare function getRuVectorStatus(config?: Partial<RuVectorConfig>): Pro
85
86
  }>;
86
87
  export * from './wrappers';
87
88
  export { RuVectorServiceProvider, getDomainRuVectorServices, getRuVectorProvider, getRuVectorServiceAvailability, type RuVectorServiceConfig, } from './provider';
88
- export { getRuVectorFeatureFlags, setRuVectorFeatureFlags, resetRuVectorFeatureFlags, isSONAEnabled, isFlashAttentionEnabled, isGNNIndexEnabled, shouldLogMigrationMetrics, initFeatureFlagsFromEnv, DEFAULT_FEATURE_FLAGS, type RuVectorFeatureFlags, } from './feature-flags';
89
+ export { getRuVectorFeatureFlags, setRuVectorFeatureFlags, resetRuVectorFeatureFlags, isSONAEnabled, isFlashAttentionEnabled, isGNNIndexEnabled, isTemporalCompressionEnabled, isCrossDomainTransferEnabled, shouldLogMigrationMetrics, initFeatureFlagsFromEnv, DEFAULT_FEATURE_FLAGS, type RuVectorFeatureFlags, } from './feature-flags';
90
+ export { DomainTransferEngine, ThompsonSampler, createDomainTransferEngine, DEFAULT_DOMAIN_TRANSFER_CONFIG, type TransferCandidate, type TransferResult, type TransferRecord, type DomainTransferConfig, } from './domain-transfer';
91
+ export { TransferCoherenceStub, createTransferCoherenceGate, type ITransferCoherenceGate, type CoherenceValidation, } from './transfer-coherence-stub';
92
+ export { TransferVerifier, createTransferVerifier, DEFAULT_VERIFICATION_CONFIG, type DomainPerformanceSnapshot, type TransferResultForVerification, type VerificationResult, type TransferVerificationConfig, } from './transfer-verification';
93
+ export { TemporalCompressionService, getTemporalCompressionService, createTemporalCompressionService, resetTemporalCompressionService, cosineSimilarity, TIER_CONFIG, THEORETICAL_COMPRESSION_RATIOS, ACTUAL_FALLBACK_RATIO, EXPECTED_COMPRESSION_RATIOS, HOT_THRESHOLD_DAYS, WARM_THRESHOLD_DAYS, type CompressionTier, type CompressedVector, type CompressionStats, } from './temporal-compression';
89
94
  export { HypergraphSchemaManager, nodeToRow, rowToNode, edgeToRow, rowToEdge, generateEdgeId, NODE_TYPES, EDGE_TYPES, type HypergraphNode, type HypergraphEdge, type HypergraphNodeRow, type HypergraphEdgeRow, type NodeType, type EdgeType, } from './hypergraph-schema';
90
95
  export { HypergraphEngine, createHypergraphEngine, createHypergraphEngineSync, DEFAULT_HYPERGRAPH_ENGINE_CONFIG, type HypergraphEngineConfig, type NodeCriteria, type EdgeCriteria, type TraversalResult, type ModuleDependencyResult, type BuildResult, type SyncResult, type HypergraphStats, type CodeIndexResult, } from './hypergraph-engine';
91
96
  export { RuVectorObservability, getRuVectorObservability, recordMLUsage, recordFallback, getObservabilityReport, type RuVectorComponent, type FallbackReason, type ComponentMetrics, type MLObservabilityMetrics, type MLUsageAlert, type MLObservabilityConfig, type ObservabilityReport, } from './observability';
@@ -95,5 +100,6 @@ export type { RvfNativeAdapter, RvfSearchResult as RvfNativeSearchResult, RvfSta
95
100
  export { RvfDualWriter, createDualWriter } from './rvf-dual-writer.js';
96
101
  export type { DualWriteConfig, DualWriteResult, DivergenceReport } from './rvf-dual-writer.js';
97
102
  export { getSharedRvfDualWriter, getSharedRvfDualWriterSync, resetSharedRvfDualWriter, } from './shared-rvf-dual-writer.js';
103
+ export { CognitiveContainer, createCognitiveContainer, generateSigningKeyPair, type ContainerSegment, type ContainerManifest, type ExportOptions, type ImportOptions, type ImportResult, type VerificationResult as CognitiveContainerVerificationResult, type ContainerInfo, type Ed25519KeyPair, } from './cognitive-container';
98
104
  export { initializeSharedMemory, getSharedServerClient as getFleetSharedClient, setSharedServerClient, isSharedMemoryAvailable, getSharedMemoryStatus, getLastInitResult, shutdownSharedMemory, resetSharedMemoryState, integrateWithFleet, DEFAULT_SHARED_MEMORY_CONFIG, type SharedMemoryConfig, type SharedMemoryResult, type SharedMemoryStatus, } from './shared-memory';
99
105
  //# sourceMappingURL=index.d.ts.map
@@ -57,7 +57,9 @@ export { RuVectorGraphBoundariesAnalyzer } from './graph-boundaries';
57
57
  // Persistent Q-Learning Router (ADR-046: Q-value persistence)
58
58
  export { PersistentQLearningRouter, DEFAULT_EWC_CONFIG, DEFAULT_PERSISTENT_CONFIG, } from './persistent-q-router';
59
59
  // Persistent SONA Engine (ADR-046: SONA pattern persistence)
60
- export { PersistentSONAEngine, DEFAULT_PERSISTENT_SONA_CONFIG, SONA_PATTERNS_SCHEMA, } from './sona-persistence';
60
+ export { PersistentSONAEngine, DEFAULT_PERSISTENT_SONA_CONFIG, SONA_PATTERNS_SCHEMA, SONA_FISHER_SCHEMA, } from './sona-persistence';
61
+ // SONA Three-Loop Engine (Task 2.2: EWC++ & MicroLoRA)
62
+ export { SONAThreeLoopEngine, MicroLoRA, EWCPlusPlus, createSONAThreeLoopEngine, DEFAULT_THREE_LOOP_CONFIG, } from './sona-three-loop';
61
63
  // Fallback implementations
62
64
  export { FallbackQLearningRouter, FallbackASTComplexityAnalyzer, FallbackDiffRiskClassifier, FallbackCoverageRouter, FallbackGraphBoundariesAnalyzer, } from './fallback';
63
65
  import { DEFAULT_RUVECTOR_CONFIG, RuVectorUnavailableError } from './interfaces';
@@ -285,7 +287,17 @@ export { RuVectorServiceProvider, getDomainRuVectorServices, getRuVectorProvider
285
287
  // ============================================================================
286
288
  // Feature Flags
287
289
  // ============================================================================
288
- export { getRuVectorFeatureFlags, setRuVectorFeatureFlags, resetRuVectorFeatureFlags, isSONAEnabled, isFlashAttentionEnabled, isGNNIndexEnabled, shouldLogMigrationMetrics, initFeatureFlagsFromEnv, DEFAULT_FEATURE_FLAGS, } from './feature-flags';
290
+ export { getRuVectorFeatureFlags, setRuVectorFeatureFlags, resetRuVectorFeatureFlags, isSONAEnabled, isFlashAttentionEnabled, isGNNIndexEnabled, isTemporalCompressionEnabled, isCrossDomainTransferEnabled, shouldLogMigrationMetrics, initFeatureFlagsFromEnv, DEFAULT_FEATURE_FLAGS, } from './feature-flags';
291
+ // ============================================================================
292
+ // Cross-Domain Transfer Learning (ADR-084, Task 2.3)
293
+ // ============================================================================
294
+ export { DomainTransferEngine, ThompsonSampler, createDomainTransferEngine, DEFAULT_DOMAIN_TRANSFER_CONFIG, } from './domain-transfer';
295
+ export { TransferCoherenceStub, createTransferCoherenceGate, } from './transfer-coherence-stub';
296
+ export { TransferVerifier, createTransferVerifier, DEFAULT_VERIFICATION_CONFIG, } from './transfer-verification';
297
+ // ============================================================================
298
+ // Temporal Tensor Compression (ADR-085)
299
+ // ============================================================================
300
+ export { TemporalCompressionService, getTemporalCompressionService, createTemporalCompressionService, resetTemporalCompressionService, cosineSimilarity, TIER_CONFIG, THEORETICAL_COMPRESSION_RATIOS, ACTUAL_FALLBACK_RATIO, EXPECTED_COMPRESSION_RATIOS, HOT_THRESHOLD_DAYS, WARM_THRESHOLD_DAYS, } from './temporal-compression';
289
301
  // ============================================================================
290
302
  // Hypergraph Schema (Neural Backbone)
291
303
  // ============================================================================
@@ -309,6 +321,10 @@ export { createRvfStore, openRvfStore, isRvfNativeAvailable } from './rvf-native
309
321
  export { RvfDualWriter, createDualWriter } from './rvf-dual-writer.js';
310
322
  export { getSharedRvfDualWriter, getSharedRvfDualWriterSync, resetSharedRvfDualWriter, } from './shared-rvf-dual-writer.js';
311
323
  // ============================================================================
324
+ // Cognitive Container Export/Import (Task 4.1: RVF v2)
325
+ // ============================================================================
326
+ export { CognitiveContainer, createCognitiveContainer, generateSigningKeyPair, } from './cognitive-container';
327
+ // ============================================================================
312
328
  // Shared Memory Integration (Fleet Integration)
313
329
  // ============================================================================
314
330
  export { initializeSharedMemory, getSharedServerClient as getFleetSharedClient, setSharedServerClient, isSharedMemoryAvailable, getSharedMemoryStatus, getLastInitResult, shutdownSharedMemory, resetSharedMemoryState, integrateWithFleet, DEFAULT_SHARED_MEMORY_CONFIG, } from './shared-memory';
@@ -493,4 +493,44 @@ export declare class RuVectorTimeoutError extends RuVectorError {
493
493
  export declare class RuVectorConfigError extends RuVectorError {
494
494
  constructor(message: string, cause?: Error);
495
495
  }
496
+ /**
497
+ * Supported filter comparison operators
498
+ */
499
+ export type FilterOperator = 'eq' | 'gt' | 'lt' | 'gte' | 'lte' | 'in' | 'contains' | 'between';
500
+ /**
501
+ * A FIELD-level filter expression that tests a single field
502
+ */
503
+ export interface FieldFilterExpression {
504
+ type: 'FIELD';
505
+ /** Dot-separated field path (e.g., "qeDomain", "confidence", "context.tags") */
506
+ field: string;
507
+ /** Comparison operator */
508
+ operator: FilterOperator;
509
+ /** Value to compare against */
510
+ value: unknown;
511
+ }
512
+ /**
513
+ * Composable filter expression supporting AND/OR/NOT/FIELD.
514
+ *
515
+ * Examples:
516
+ * - Single field: { type: 'FIELD', field: 'qeDomain', operator: 'eq', value: 'test-generation' }
517
+ * - AND: { type: 'AND', children: [fieldFilter1, fieldFilter2] }
518
+ * - OR: { type: 'OR', children: [fieldFilter1, fieldFilter2] }
519
+ * - NOT: { type: 'NOT', child: fieldFilter }
520
+ * - Nested: { type: 'AND', children: [{ type: 'OR', children: [...] }, fieldFilter] }
521
+ */
522
+ export interface FilterExpression {
523
+ /** Expression type: AND, OR, NOT, or FIELD */
524
+ type: 'AND' | 'OR' | 'NOT' | 'FIELD';
525
+ /** Child expressions for AND/OR composites */
526
+ children?: FilterExpression[];
527
+ /** Child expression for NOT */
528
+ child?: FilterExpression;
529
+ /** Field path for FIELD type (dot-separated, e.g., "context.tags") */
530
+ field?: string;
531
+ /** Comparison operator for FIELD type */
532
+ operator?: FilterOperator;
533
+ /** Comparison value for FIELD type */
534
+ value?: unknown;
535
+ }
496
536
  //# sourceMappingURL=interfaces.d.ts.map
@@ -30,6 +30,10 @@ import type { RuVectorServerClient } from './server-client.js';
30
30
  * SONA patterns table schema - for documentation and migrations
31
31
  */
32
32
  export declare const SONA_PATTERNS_SCHEMA = "\n -- SONA Patterns table (ADR-046: Pattern Persistence)\n CREATE TABLE IF NOT EXISTS sona_patterns (\n id TEXT PRIMARY KEY,\n type TEXT NOT NULL,\n domain TEXT NOT NULL,\n state_embedding BLOB,\n action_embedding BLOB,\n action_type TEXT NOT NULL,\n action_value TEXT,\n outcome_reward REAL NOT NULL DEFAULT 0.0,\n outcome_success INTEGER NOT NULL DEFAULT 0,\n outcome_quality REAL NOT NULL DEFAULT 0.0,\n confidence REAL DEFAULT 0.5,\n usage_count INTEGER DEFAULT 0,\n success_count INTEGER DEFAULT 0,\n failure_count INTEGER DEFAULT 0,\n metadata TEXT,\n created_at TEXT DEFAULT (datetime('now')),\n updated_at TEXT DEFAULT (datetime('now')),\n last_used_at TEXT\n );\n CREATE INDEX IF NOT EXISTS idx_sona_patterns_type ON sona_patterns(type);\n CREATE INDEX IF NOT EXISTS idx_sona_patterns_domain ON sona_patterns(domain);\n CREATE INDEX IF NOT EXISTS idx_sona_patterns_confidence ON sona_patterns(confidence DESC);\n CREATE INDEX IF NOT EXISTS idx_sona_patterns_updated ON sona_patterns(updated_at DESC);\n";
33
+ /**
34
+ * SONA Fisher matrices table schema - stores EWC++ state per domain
35
+ */
36
+ export declare const SONA_FISHER_SCHEMA = "\n -- SONA Fisher Information Matrices (Task 2.2: EWC++ Persistence)\n CREATE TABLE IF NOT EXISTS sona_fisher_matrices (\n domain TEXT PRIMARY KEY,\n fisher_diagonal BLOB NOT NULL,\n optimal_params BLOB NOT NULL,\n base_weights BLOB,\n dimension INTEGER NOT NULL,\n task_boundaries INTEGER NOT NULL DEFAULT 0,\n consolidation_cycles INTEGER NOT NULL DEFAULT 0,\n request_count INTEGER NOT NULL DEFAULT 0,\n ewc_lambda REAL NOT NULL DEFAULT 1000.0,\n created_at TEXT DEFAULT (datetime('now')),\n updated_at TEXT DEFAULT (datetime('now'))\n );\n";
33
37
  /**
34
38
  * Configuration for persistent SONA engine
35
39
  */
@@ -263,6 +267,48 @@ export declare class PersistentSONAEngine {
263
267
  * Close the engine
264
268
  */
265
269
  close(): Promise<void>;
270
+ /**
271
+ * Save Fisher Information Matrix and optimal parameters to SQLite.
272
+ *
273
+ * Persists the EWC++ state for a domain so it survives across sessions.
274
+ * This includes the Fisher diagonal, optimal parameters, base weights,
275
+ * and metadata about task boundaries and consolidation cycles.
276
+ *
277
+ * @param domain - Domain identifier for the Fisher state
278
+ * @param fisherDiagonal - Fisher Information Matrix diagonal
279
+ * @param optimalParams - Optimal parameters at last task boundary
280
+ * @param baseWeights - Current base weights (optional)
281
+ * @param metadata - Additional metadata (task boundaries, cycles, etc.)
282
+ */
283
+ saveFisherMatrix(domain: string, fisherDiagonal: Float32Array, optimalParams: Float32Array, baseWeights?: Float32Array, metadata?: {
284
+ taskBoundaries?: number;
285
+ consolidationCycles?: number;
286
+ requestCount?: number;
287
+ ewcLambda?: number;
288
+ }): void;
289
+ /**
290
+ * Load Fisher Information Matrix and optimal parameters from SQLite.
291
+ *
292
+ * @param domain - Domain identifier to load Fisher state for
293
+ * @returns Fisher state or null if not found
294
+ */
295
+ loadFisherMatrix(domain: string): {
296
+ fisherDiagonal: Float32Array;
297
+ optimalParams: Float32Array;
298
+ baseWeights: Float32Array | null;
299
+ dimension: number;
300
+ taskBoundaries: number;
301
+ consolidationCycles: number;
302
+ requestCount: number;
303
+ ewcLambda: number;
304
+ } | null;
305
+ /**
306
+ * Delete Fisher matrix for a domain.
307
+ *
308
+ * @param domain - Domain identifier
309
+ * @returns true if a row was deleted
310
+ */
311
+ deleteFisherMatrix(domain: string): boolean;
266
312
  /**
267
313
  * Set or update the server client for cross-process pattern sharing
268
314
  */
@@ -319,6 +365,14 @@ export declare class PersistentSONAEngine {
319
365
  * Convert buffer to float array
320
366
  */
321
367
  private bufferToFloatArray;
368
+ /**
369
+ * Convert Float32Array to Buffer (for Fisher matrix persistence)
370
+ */
371
+ private float32ToBuffer;
372
+ /**
373
+ * Convert Buffer to Float32Array (for Fisher matrix loading)
374
+ */
375
+ private bufferToFloat32;
322
376
  }
323
377
  /**
324
378
  * Create a persistent SONA engine