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,309 @@
1
+ /**
2
+ * Coherence Gate (Task 3.1, ADR-083)
3
+ *
4
+ * Validates AI-generated test artifacts using heuristic coherence scoring
5
+ * based on word-level feature similarity. Detects hallucinated or inconsistent
6
+ * test outputs by measuring the energy deviation from expected pattern consistency.
7
+ *
8
+ * Compute ladder:
9
+ * - Reflex (<1ms): Simple heuristic checks (assertion count, coverage overlap)
10
+ * - Retrieval (~10ms): Full word-frequency coherence computation
11
+ *
12
+ * Implements ITransferCoherenceGate for cross-domain transfer validation.
13
+ * Uses Blake3 hash-chained witness records for audit trail.
14
+ *
15
+ * @module integrations/ruvector/coherence-gate
16
+ * @see ADR-083-coherence-gated-agent-actions.md
17
+ */
18
+ import type { ITransferCoherenceGate, CoherenceValidation } from './transfer-coherence-stub.js';
19
+ /**
20
+ * Reset the CohomologyEngine loader state (for testing).
21
+ */
22
+ export declare function resetCohomologyEngineLoader(): void;
23
+ /**
24
+ * Test artifact to validate for coherence.
25
+ */
26
+ export interface TestArtifact {
27
+ /** Assertions made by the generated test */
28
+ assertions: string[];
29
+ /** Observed behaviors from actual execution */
30
+ observedBehavior: string[];
31
+ /** Code coverage ratio (0-1) */
32
+ coverage: number;
33
+ /** Domain the test belongs to */
34
+ domain: string;
35
+ /** Confidence score of the generator (0-1) */
36
+ confidence: number;
37
+ }
38
+ /**
39
+ * Result of coherence energy computation.
40
+ */
41
+ export interface CoherenceResult {
42
+ /** Coherence energy score (0-1, lower = more coherent) */
43
+ energy: number;
44
+ /** Which compute tier was used */
45
+ tier: 'reflex' | 'retrieval';
46
+ /** Breakdown of energy components */
47
+ components: EnergyComponents;
48
+ /** Computation latency in milliseconds */
49
+ latencyMs: number;
50
+ }
51
+ /**
52
+ * Breakdown of energy components for explainability.
53
+ */
54
+ export interface EnergyComponents {
55
+ /** Energy from assertion-observation mismatch (0-1) */
56
+ assertionCoverage: number;
57
+ /** Energy from low code coverage (0-1) */
58
+ codeCoverage: number;
59
+ /** Energy from low confidence (0-1) */
60
+ confidencePenalty: number;
61
+ /** Energy from contradiction detection (0-1, retrieval only) */
62
+ contradictionScore: number;
63
+ /** Energy from sheaf Laplacian deviation (0-1, retrieval only) */
64
+ laplacianDeviation: number;
65
+ }
66
+ /**
67
+ * Result of validation against a threshold.
68
+ */
69
+ export interface ValidationResult {
70
+ /** Whether the artifact passes coherence validation */
71
+ passed: boolean;
72
+ /** The coherence energy score */
73
+ energy: number;
74
+ /** The threshold used for validation */
75
+ threshold: number;
76
+ /** Human-readable reason if validation failed */
77
+ reason?: string;
78
+ /** The witness record for this decision */
79
+ witness: WitnessRecord;
80
+ }
81
+ /**
82
+ * Hash-chained witness record for audit trail.
83
+ */
84
+ export interface WitnessRecord {
85
+ /** Unique record identifier */
86
+ id: string;
87
+ /** Timestamp of the decision */
88
+ timestamp: number;
89
+ /** Hash of the artifact that was validated */
90
+ artifactHash: string;
91
+ /** The coherence energy computed */
92
+ energy: number;
93
+ /** The threshold applied */
94
+ threshold: number;
95
+ /** Whether validation passed */
96
+ passed: boolean;
97
+ /** Hash of the previous witness record */
98
+ previousHash: string;
99
+ /** Hash of this record (chained) */
100
+ recordHash: string;
101
+ }
102
+ /**
103
+ * Decision log entry for observability.
104
+ */
105
+ export interface CoherenceDecision {
106
+ /** Unique decision identifier */
107
+ id: string;
108
+ /** Timestamp */
109
+ timestamp: number;
110
+ /** Domain of the artifact */
111
+ domain: string;
112
+ /** Computed energy */
113
+ energy: number;
114
+ /** Compute tier used */
115
+ tier: 'reflex' | 'retrieval';
116
+ /** Whether validation passed */
117
+ passed: boolean;
118
+ /** Threshold used */
119
+ threshold: number;
120
+ }
121
+ /** Default coherence threshold (Normal regime) */
122
+ export declare const DEFAULT_COHERENCE_THRESHOLD = 0.4;
123
+ /**
124
+ * Coherence gate for validating AI-generated test artifacts.
125
+ *
126
+ * Uses word-level heuristic coherence scoring to detect hallucinated or
127
+ * inconsistent test outputs. Implements ITransferCoherenceGate for
128
+ * cross-domain transfer validation compatibility.
129
+ *
130
+ * @example
131
+ * ```typescript
132
+ * const gate = new CoherenceGate();
133
+ * const result = gate.validate({
134
+ * assertions: ['expect(result).toBe(true)'],
135
+ * observedBehavior: ['result was true'],
136
+ * coverage: 0.85,
137
+ * domain: 'test-generation',
138
+ * confidence: 0.9,
139
+ * });
140
+ * if (!result.passed) {
141
+ * console.warn('Artifact may be hallucinated:', result.reason);
142
+ * }
143
+ * ```
144
+ */
145
+ export declare class CoherenceGate implements ITransferCoherenceGate {
146
+ private readonly threshold;
147
+ private decisionLog;
148
+ private witnessChain;
149
+ private lastWitnessHash;
150
+ private nativeAvailable;
151
+ constructor(threshold?: number);
152
+ /**
153
+ * Compute coherence energy for a test artifact.
154
+ *
155
+ * Uses a two-tier compute ladder:
156
+ * - Reflex (<1ms): Simple heuristic checks
157
+ * - Retrieval (~10ms): Full sheaf Laplacian computation
158
+ *
159
+ * @param artifact - The test artifact to evaluate
160
+ * @param forceRetrieval - If true, skip reflex and go straight to retrieval
161
+ * @returns Coherence result with energy score and component breakdown
162
+ */
163
+ computeEnergy(artifact: TestArtifact, forceRetrieval?: boolean): CoherenceResult;
164
+ /**
165
+ * Validate a test artifact against the coherence threshold.
166
+ *
167
+ * @param artifact - The test artifact to validate
168
+ * @param threshold - Optional override for the default threshold
169
+ * @returns Validation result with witness record
170
+ */
171
+ validate(artifact: TestArtifact, threshold?: number): ValidationResult;
172
+ /**
173
+ * Get the decision log for observability.
174
+ */
175
+ getDecisionLog(): CoherenceDecision[];
176
+ /**
177
+ * Get the witness chain for audit purposes.
178
+ */
179
+ getWitnessChain(): WitnessRecord[];
180
+ /**
181
+ * Get the current threshold.
182
+ */
183
+ getThreshold(): number;
184
+ /**
185
+ * Clear the decision log (for testing).
186
+ */
187
+ clearDecisionLog(): void;
188
+ /**
189
+ * Validate whether a pattern can be transferred to a target domain
190
+ * without introducing coherence violations.
191
+ *
192
+ * Converts the pattern into a TestArtifact and runs coherence validation.
193
+ */
194
+ validateTransfer(pattern: {
195
+ id?: string;
196
+ domain?: string;
197
+ confidence?: number;
198
+ [key: string]: unknown;
199
+ }, targetDomain: string): CoherenceValidation;
200
+ /**
201
+ * Reflex-tier energy computation using simple heuristics.
202
+ * Must complete in <1ms.
203
+ */
204
+ private computeReflexEnergy;
205
+ /**
206
+ * Retrieval-tier energy computation using sheaf Laplacian.
207
+ * Includes contradiction detection and Laplacian deviation.
208
+ */
209
+ private computeRetrievalEnergy;
210
+ /**
211
+ * Compute assertion coverage energy.
212
+ * High energy when assertions far exceed observed behavior (hallucination signal).
213
+ */
214
+ private computeAssertionCoverageEnergy;
215
+ /**
216
+ * Compute code coverage energy.
217
+ * Higher energy for lower coverage.
218
+ */
219
+ private computeCodeCoverageEnergy;
220
+ /**
221
+ * Compute confidence penalty.
222
+ * Higher energy for lower confidence.
223
+ */
224
+ private computeConfidencePenalty;
225
+ /**
226
+ * Detect contradictions between assertions and observed behavior.
227
+ *
228
+ * Simple heuristic: look for negation patterns and semantic opposites
229
+ * in the assertion/behavior pairing.
230
+ */
231
+ private detectContradictions;
232
+ /**
233
+ * Compute coherence deviation using sheaf Laplacian energy.
234
+ *
235
+ * When `prime-radiant-advanced-wasm` CohomologyEngine is available,
236
+ * builds a sheaf graph from assertion vectors and computes real sheaf
237
+ * Laplacian consistency energy. Falls back to pairwise word-frequency
238
+ * cosine similarity when the WASM module is unavailable.
239
+ *
240
+ * Uses 64-dim word-level feature hashing with FNV-1a for bucket assignment
241
+ * and L2-normalized term-frequency vectors.
242
+ */
243
+ private computeLaplacianDeviation;
244
+ /**
245
+ * Compute Laplacian deviation using the native CohomologyEngine.
246
+ * Builds a sheaf graph where each assertion is a node and related
247
+ * assertion pairs form edges with identity restriction maps.
248
+ */
249
+ private computeNativeLaplacianDeviation;
250
+ /**
251
+ * Fallback: compute pairwise word-frequency cosine consistency score.
252
+ */
253
+ private computeFallbackLaplacianDeviation;
254
+ /**
255
+ * Hash a word to a bucket index 0-63 using FNV-1a.
256
+ */
257
+ private hashWord;
258
+ /**
259
+ * Convert text to a 64-dim word-level feature vector using feature hashing.
260
+ *
261
+ * Tokenizes on whitespace and punctuation, hashes each word to one of 64
262
+ * buckets via FNV-1a, builds a term-frequency vector, and L2-normalizes it.
263
+ */
264
+ private textToWordFeatureVector;
265
+ /**
266
+ * Compute cosine similarity between two vectors.
267
+ */
268
+ private cosineSimilarity;
269
+ /**
270
+ * Build a human-readable failure reason from coherence results.
271
+ */
272
+ private buildFailureReason;
273
+ /**
274
+ * Create a Blake3-style hash-chained witness record.
275
+ * Falls back to SHA-256 when Blake3 is unavailable.
276
+ */
277
+ private createWitnessRecord;
278
+ /**
279
+ * Hash content using SHA-256 (Blake3 fallback).
280
+ */
281
+ private hashContent;
282
+ /**
283
+ * Log a coherence decision for observability.
284
+ */
285
+ private logDecision;
286
+ /**
287
+ * Extract assertions from a transfer pattern object.
288
+ */
289
+ private extractAssertions;
290
+ /**
291
+ * Extract observed behaviors from a transfer pattern object.
292
+ */
293
+ private extractObservedBehavior;
294
+ }
295
+ /**
296
+ * Create a coherence gate instance.
297
+ *
298
+ * @param threshold - Coherence energy threshold (default: 0.4)
299
+ * @returns A new CoherenceGate instance
300
+ */
301
+ export declare function createCoherenceGate(threshold?: number): CoherenceGate;
302
+ /**
303
+ * Create a transfer coherence gate.
304
+ *
305
+ * Returns the real CoherenceGate implementation (replacing the stub).
306
+ * The CoherenceGate implements ITransferCoherenceGate.
307
+ */
308
+ export declare function createRealTransferCoherenceGate(): ITransferCoherenceGate;
309
+ //# sourceMappingURL=coherence-gate.d.ts.map