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,315 @@
1
+ /**
2
+ * Multi-Path Consensus Reasoning Validator - Task 4.5
3
+ *
4
+ * Applies error correction to AI reasoning using three independent paths.
5
+ * Generates multiple independent reasoning chains for critical decisions,
6
+ * extracts syndrome locations (disagreements between paths), and applies
7
+ * confidence-weighted voting to produce a high-confidence result.
8
+ *
9
+ * Use cases:
10
+ * - Test generation validation
11
+ * - Security audit consensus
12
+ * - Defect triage decisions
13
+ *
14
+ * TypeScript implementation (no native package exists for reasoning QEC —
15
+ * consensus logic doesn't benefit from native computation).
16
+ *
17
+ * @module coordination/reasoning-qec
18
+ * @see docs/research/ruvector-quantum-solvers.md
19
+ */
20
+ /**
21
+ * A problem requiring multi-path reasoning validation.
22
+ */
23
+ export interface ReasoningProblem {
24
+ /** Problem domain: 'test-generation', 'security-audit', 'defect-triage' */
25
+ type: string;
26
+ /** Domain-specific context data */
27
+ context: Record<string, unknown>;
28
+ /** Reasoning steps to validate */
29
+ steps: string[];
30
+ }
31
+ /**
32
+ * A single step within a reasoning path.
33
+ */
34
+ export interface ReasoningStep {
35
+ /** Zero-based step index within the path */
36
+ index: number;
37
+ /** Human-readable description of what this step does */
38
+ description: string;
39
+ /** The conclusion reached at this step */
40
+ conclusion: string;
41
+ /** Evidence supporting this conclusion */
42
+ evidence: string[];
43
+ }
44
+ /**
45
+ * An independent reasoning path through a problem.
46
+ */
47
+ export interface ReasoningPath {
48
+ /** Path identifier (0, 1, 2) */
49
+ id: number;
50
+ /** Ordered reasoning steps */
51
+ steps: ReasoningStep[];
52
+ /** Final conclusion of this path */
53
+ conclusion: string;
54
+ /** Confidence in the conclusion (0-1) */
55
+ confidence: number;
56
+ }
57
+ /**
58
+ * A syndrome identifies a disagreement location between paths.
59
+ */
60
+ export interface Syndrome {
61
+ /** Step index where disagreement occurs */
62
+ stepIndex: number;
63
+ /** Which paths disagree, and what each concluded */
64
+ disagreements: {
65
+ pathId: number;
66
+ conclusion: string;
67
+ }[];
68
+ /** How severe the disagreement is */
69
+ severity: 'minor' | 'major' | 'critical';
70
+ }
71
+ /**
72
+ * The result after error correction has been applied.
73
+ */
74
+ export interface CorrectedReasoning {
75
+ /** Corrected reasoning steps */
76
+ steps: ReasoningStep[];
77
+ /** Corrected final conclusion */
78
+ conclusion: string;
79
+ /** Confidence in the corrected reasoning (0-1) */
80
+ confidence: number;
81
+ /** List of corrections applied */
82
+ corrections: CorrectionEntry[];
83
+ /** Number of syndromes detected */
84
+ syndromeCount: number;
85
+ }
86
+ /**
87
+ * A single correction applied during error correction.
88
+ */
89
+ export interface CorrectionEntry {
90
+ /** Step index where the correction was applied */
91
+ stepIndex: number;
92
+ /** Original (minority) conclusion that was overridden */
93
+ original: string;
94
+ /** Corrected (majority) conclusion */
95
+ corrected: string;
96
+ /** Human-readable reason for the correction */
97
+ reason: string;
98
+ }
99
+ /**
100
+ * Result of validating a corrected reasoning chain.
101
+ */
102
+ export interface ValidationResult {
103
+ /** Whether the corrected reasoning passes validation */
104
+ valid: boolean;
105
+ /** Overall confidence in the validated result (0-1) */
106
+ confidence: number;
107
+ /** Issues discovered during validation */
108
+ issues: ValidationIssue[];
109
+ }
110
+ /**
111
+ * A single issue found during validation.
112
+ */
113
+ export interface ValidationIssue {
114
+ /** Step index where issue was found, or -1 for conclusion-level */
115
+ stepIndex: number;
116
+ /** Type of issue */
117
+ type: 'low-confidence' | 'no-majority' | 'inconsistent-evidence' | 'all-divergent';
118
+ /** Human-readable description */
119
+ description: string;
120
+ }
121
+ /**
122
+ * Configuration for the ReasoningQEC engine.
123
+ */
124
+ export interface ReasoningQECConfig {
125
+ /** Minimum number of reasoning paths (default: 3) */
126
+ minPaths: number;
127
+ /** Confidence threshold below which syndromes are flagged (default: 0.5) */
128
+ confidenceThreshold: number;
129
+ /** Minimum agreement ratio for a corrected step to be considered valid (default: 0.5) */
130
+ majorityThreshold: number;
131
+ /** Whether to attempt loading the native ruqu-exotic module (default: true) */
132
+ useNativeBackend: boolean;
133
+ /** Voting method for error correction: 'weighted' uses path confidence, 'majority' uses simple count (default: 'weighted') */
134
+ votingMethod: 'majority' | 'weighted';
135
+ }
136
+ /**
137
+ * Default configuration values.
138
+ */
139
+ export declare const DEFAULT_QEC_CONFIG: ReasoningQECConfig;
140
+ /**
141
+ * Multi-Path Consensus Reasoning Validator.
142
+ *
143
+ * Named QEC by analogy with quantum error correction; implements consensus
144
+ * voting across multiple reasoning paths, not quantum algorithms.
145
+ *
146
+ * Generates multiple independent reasoning paths for a given problem,
147
+ * extracts syndrome locations where paths disagree, and applies
148
+ * confidence-weighted (or simple majority) voting to produce a
149
+ * high-confidence result.
150
+ *
151
+ * @example
152
+ * ```typescript
153
+ * const qec = new ReasoningQEC();
154
+ *
155
+ * const problem: ReasoningProblem = {
156
+ * type: 'security-audit',
157
+ * context: { file: 'auth.ts', finding: 'potential XSS' },
158
+ * steps: ['Analyze input handling', 'Check sanitization', 'Evaluate risk'],
159
+ * };
160
+ *
161
+ * const paths = qec.generatePaths(problem);
162
+ * const syndromes = qec.extractSyndromes(paths);
163
+ * const corrected = qec.correctErrors(paths, syndromes);
164
+ * const validation = qec.validate(corrected);
165
+ * ```
166
+ */
167
+ export declare class ReasoningQEC {
168
+ private readonly config;
169
+ private nativeAvailable;
170
+ constructor(config?: Partial<ReasoningQECConfig>);
171
+ /**
172
+ * Initialize the engine, probing for the native backend if configured.
173
+ * Call this once before using generate/extract/correct methods.
174
+ * If not called, the engine works in pure TypeScript mode.
175
+ */
176
+ initialize(): Promise<void>;
177
+ /**
178
+ * Generate independent reasoning paths for a problem.
179
+ *
180
+ * Each path represents a different analytical perspective on the problem,
181
+ * producing its own step-by-step reasoning chain and conclusion.
182
+ *
183
+ * @param problem - The reasoning problem to analyze
184
+ * @returns Array of independent reasoning paths (minimum 3)
185
+ */
186
+ generatePaths(problem: ReasoningProblem): ReasoningPath[];
187
+ /**
188
+ * Extract syndromes (disagreement locations) from reasoning paths.
189
+ *
190
+ * Compares all paths step-by-step and identifies indices where
191
+ * paths reach different conclusions. Severity is classified as:
192
+ * - minor: only one path disagrees (easily correctable)
193
+ * - major: paths are split (no clear majority)
194
+ * - critical: all paths disagree (low confidence in any correction)
195
+ *
196
+ * @param paths - Array of reasoning paths to compare
197
+ * @returns Array of syndromes identifying disagreement locations
198
+ */
199
+ extractSyndromes(paths: ReasoningPath[]): Syndrome[];
200
+ /**
201
+ * Correct errors using voting across paths.
202
+ *
203
+ * For each step, the conclusion with the highest vote weight among paths
204
+ * is selected. When votingMethod is 'weighted', path confidence is used
205
+ * as vote weight. When 'majority', simple count-based voting is used.
206
+ * If no clear majority exists, the highest-weighted conclusion is used
207
+ * but confidence is reduced.
208
+ *
209
+ * @param paths - Array of reasoning paths
210
+ * @param syndromes - Array of extracted syndromes
211
+ * @returns Corrected reasoning with applied corrections
212
+ */
213
+ correctErrors(paths: ReasoningPath[], syndromes: Syndrome[]): CorrectedReasoning;
214
+ /**
215
+ * Validate a corrected reasoning chain.
216
+ *
217
+ * Checks for low confidence, missing majority, inconsistent evidence,
218
+ * and all-divergent conditions. Returns a validation result indicating
219
+ * whether the corrected reasoning is trustworthy.
220
+ *
221
+ * @param corrected - The corrected reasoning to validate
222
+ * @returns Validation result with confidence and any issues found
223
+ */
224
+ validate(corrected: CorrectedReasoning): ValidationResult;
225
+ /**
226
+ * Convenience method: run the full QEC pipeline on a problem.
227
+ *
228
+ * @param problem - The reasoning problem
229
+ * @returns Object containing paths, syndromes, corrected reasoning, and validation
230
+ */
231
+ process(problem: ReasoningProblem): {
232
+ paths: ReasoningPath[];
233
+ syndromes: Syndrome[];
234
+ corrected: CorrectedReasoning;
235
+ validation: ValidationResult;
236
+ };
237
+ /**
238
+ * Get current configuration.
239
+ */
240
+ getConfig(): Readonly<ReasoningQECConfig>;
241
+ /**
242
+ * Check if native backend is available.
243
+ */
244
+ isNativeAvailable(): boolean;
245
+ /**
246
+ * Generate steps for a single reasoning path from a given perspective.
247
+ */
248
+ private generatePathSteps;
249
+ /**
250
+ * Generate a conclusion for a step based on perspective and context.
251
+ *
252
+ * Each perspective prioritizes different aspects of the context, producing
253
+ * genuinely diverse conclusions rather than identical text with a path suffix.
254
+ *
255
+ * In production this would call an LLM or apply domain-specific heuristics.
256
+ * The TypeScript fallback uses deterministic derivation from inputs.
257
+ */
258
+ private generateStepConclusion;
259
+ /**
260
+ * Gather evidence for a step from the given perspective.
261
+ */
262
+ private gatherEvidence;
263
+ /**
264
+ * Derive a final conclusion from a set of completed steps.
265
+ */
266
+ private deriveConclusion;
267
+ /**
268
+ * Calculate confidence for a single path based on its steps.
269
+ */
270
+ private calculatePathConfidence;
271
+ /**
272
+ * Classify syndrome severity based on how many distinct conclusions exist.
273
+ */
274
+ private classifySyndromeSeverity;
275
+ /**
276
+ * Correct a single step by voting among paths.
277
+ *
278
+ * When votingMethod is 'weighted', each path's vote is weighted by its
279
+ * confidence score. When 'majority', simple count-based voting is used.
280
+ */
281
+ private correctStep;
282
+ /**
283
+ * Correct the final conclusion using voting among paths.
284
+ *
285
+ * When votingMethod is 'weighted', each path's vote is weighted by its
286
+ * confidence score. When 'majority', simple count-based voting is used.
287
+ */
288
+ private correctConclusion;
289
+ /**
290
+ * Calculate confidence for the corrected reasoning based on path agreement
291
+ * and syndrome severity.
292
+ */
293
+ private calculateCorrectedConfidence;
294
+ }
295
+ /**
296
+ * Create a new ReasoningQEC engine with optional configuration.
297
+ *
298
+ * @param config - Partial configuration overrides
299
+ * @returns Configured ReasoningQEC instance
300
+ */
301
+ export declare function createReasoningQEC(config?: Partial<ReasoningQECConfig>): ReasoningQEC;
302
+ /**
303
+ * Run the full QEC pipeline on a problem in one call.
304
+ *
305
+ * @param problem - The reasoning problem to process
306
+ * @param config - Optional configuration overrides
307
+ * @returns Pipeline result with paths, syndromes, corrected reasoning, and validation
308
+ */
309
+ export declare function processReasoning(problem: ReasoningProblem, config?: Partial<ReasoningQECConfig>): {
310
+ paths: ReasoningPath[];
311
+ syndromes: Syndrome[];
312
+ corrected: CorrectedReasoning;
313
+ validation: ValidationResult;
314
+ };
315
+ //# sourceMappingURL=reasoning-qec.d.ts.map