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,202 @@
1
+ /**
2
+ * Simple Neural Router - Extracted from neural-tiny-dancer-router.ts
3
+ *
4
+ * Lightweight feedforward neural network for routing decisions.
5
+ * Uses Xavier initialization and simple policy gradient updates.
6
+ *
7
+ * Architecture:
8
+ * Input(4) -> Dense(32, ReLU) -> Dense(3, Softmax) -> [p_haiku, p_sonnet, p_opus]
9
+ *
10
+ * @module routing/simple-neural-router
11
+ */
12
+ // ============================================================================
13
+ // Constants
14
+ // ============================================================================
15
+ /** Number of input features for the neural network */
16
+ export const INPUT_SIZE = 4;
17
+ /** Number of hidden units */
18
+ export const HIDDEN_SIZE = 32;
19
+ /** Number of output classes (tier1=haiku, tier2=sonnet, tier3=opus) */
20
+ export const OUTPUT_SIZE = 3;
21
+ /** Default learning rate for weight updates */
22
+ export const DEFAULT_LEARNING_RATE = 0.01;
23
+ // ============================================================================
24
+ // SimpleNeuralRouter
25
+ // ============================================================================
26
+ /**
27
+ * Lightweight feedforward neural network for routing decisions.
28
+ * Uses Xavier initialization and simple policy gradient updates.
29
+ *
30
+ * Architecture:
31
+ * Input(4) -> Dense(32, ReLU) -> Dense(3, Softmax) -> [p_haiku, p_sonnet, p_opus]
32
+ */
33
+ export class SimpleNeuralRouter {
34
+ weightsInputHidden;
35
+ weightsHiddenOutput;
36
+ biasHidden;
37
+ biasOutput;
38
+ learningRate;
39
+ constructor(learningRate = DEFAULT_LEARNING_RATE) {
40
+ this.learningRate = learningRate;
41
+ this.weightsInputHidden = this.xavierInit(INPUT_SIZE, HIDDEN_SIZE);
42
+ this.weightsHiddenOutput = this.xavierInit(HIDDEN_SIZE, OUTPUT_SIZE);
43
+ this.biasHidden = new Float32Array(HIDDEN_SIZE);
44
+ this.biasOutput = new Float32Array(OUTPUT_SIZE);
45
+ }
46
+ /**
47
+ * Xavier/Glorot initialization for weight matrices
48
+ */
49
+ xavierInit(fanIn, fanOut) {
50
+ const scale = Math.sqrt(2.0 / (fanIn + fanOut));
51
+ const weights = new Float32Array(fanIn * fanOut);
52
+ for (let i = 0; i < weights.length; i++) {
53
+ // Box-Muller transform for normal distribution
54
+ const u1 = Math.random();
55
+ const u2 = Math.random();
56
+ const z = Math.sqrt(-2 * Math.log(Math.max(u1, 1e-10))) * Math.cos(2 * Math.PI * u2);
57
+ weights[i] = z * scale;
58
+ }
59
+ return weights;
60
+ }
61
+ /**
62
+ * Forward pass through the network
63
+ *
64
+ * @param features - Input feature vector [complexityScore, tokenEstimate, domainIndex, successRate]
65
+ * @returns Probability distribution over tiers [p_haiku, p_sonnet, p_opus]
66
+ */
67
+ forward(features) {
68
+ if (features.length !== INPUT_SIZE) {
69
+ throw new Error(`Expected ${INPUT_SIZE} features, got ${features.length}`);
70
+ }
71
+ // Input -> Hidden (matmul + bias + ReLU)
72
+ const hidden = new Float32Array(HIDDEN_SIZE);
73
+ for (let h = 0; h < HIDDEN_SIZE; h++) {
74
+ let sum = this.biasHidden[h];
75
+ for (let i = 0; i < INPUT_SIZE; i++) {
76
+ sum += features[i] * this.weightsInputHidden[i * HIDDEN_SIZE + h];
77
+ }
78
+ hidden[h] = Math.max(0, sum); // ReLU
79
+ }
80
+ // Hidden -> Output (matmul + bias)
81
+ const logits = new Float32Array(OUTPUT_SIZE);
82
+ for (let o = 0; o < OUTPUT_SIZE; o++) {
83
+ let sum = this.biasOutput[o];
84
+ for (let h = 0; h < HIDDEN_SIZE; h++) {
85
+ sum += hidden[h] * this.weightsHiddenOutput[h * OUTPUT_SIZE + o];
86
+ }
87
+ logits[o] = sum;
88
+ }
89
+ // Softmax
90
+ return this.softmax(logits);
91
+ }
92
+ /**
93
+ * Numerically stable softmax
94
+ */
95
+ softmax(logits) {
96
+ const maxLogit = Math.max(...logits);
97
+ const expValues = new Float32Array(logits.length);
98
+ let sumExp = 0;
99
+ for (let i = 0; i < logits.length; i++) {
100
+ expValues[i] = Math.exp(logits[i] - maxLogit);
101
+ sumExp += expValues[i];
102
+ }
103
+ const result = [];
104
+ for (let i = 0; i < logits.length; i++) {
105
+ result.push(expValues[i] / sumExp);
106
+ }
107
+ return result;
108
+ }
109
+ /**
110
+ * Update weights using simple policy gradient (REINFORCE)
111
+ *
112
+ * @param features - Input features used for the decision
113
+ * @param chosenTierIndex - Index of the tier that was chosen (0=haiku, 1=sonnet, 2=opus)
114
+ * @param reward - Reward signal (-1 to 1, where 1 = perfect, -1 = total failure)
115
+ */
116
+ updateWeights(features, chosenTierIndex, reward) {
117
+ // Forward pass to get current probabilities and hidden activations
118
+ const hidden = new Float32Array(HIDDEN_SIZE);
119
+ for (let h = 0; h < HIDDEN_SIZE; h++) {
120
+ let sum = this.biasHidden[h];
121
+ for (let i = 0; i < INPUT_SIZE; i++) {
122
+ sum += features[i] * this.weightsInputHidden[i * HIDDEN_SIZE + h];
123
+ }
124
+ hidden[h] = Math.max(0, sum);
125
+ }
126
+ const logits = new Float32Array(OUTPUT_SIZE);
127
+ for (let o = 0; o < OUTPUT_SIZE; o++) {
128
+ let sum = this.biasOutput[o];
129
+ for (let h = 0; h < HIDDEN_SIZE; h++) {
130
+ sum += hidden[h] * this.weightsHiddenOutput[h * OUTPUT_SIZE + o];
131
+ }
132
+ logits[o] = sum;
133
+ }
134
+ const probs = this.softmax(logits);
135
+ // Policy gradient: d log(pi) / d theta * reward
136
+ // For softmax output, gradient of log(pi_chosen) w.r.t. logits is:
137
+ // (1{i=chosen} - pi_i) for each output i
138
+ const outputGrad = new Float32Array(OUTPUT_SIZE);
139
+ for (let o = 0; o < OUTPUT_SIZE; o++) {
140
+ outputGrad[o] = (o === chosenTierIndex ? 1 : 0) - probs[o];
141
+ outputGrad[o] *= reward * this.learningRate;
142
+ }
143
+ // Update output weights and biases
144
+ for (let h = 0; h < HIDDEN_SIZE; h++) {
145
+ for (let o = 0; o < OUTPUT_SIZE; o++) {
146
+ this.weightsHiddenOutput[h * OUTPUT_SIZE + o] += hidden[h] * outputGrad[o];
147
+ }
148
+ }
149
+ for (let o = 0; o < OUTPUT_SIZE; o++) {
150
+ this.biasOutput[o] += outputGrad[o];
151
+ }
152
+ // Backpropagate to hidden layer
153
+ const hiddenGrad = new Float32Array(HIDDEN_SIZE);
154
+ for (let h = 0; h < HIDDEN_SIZE; h++) {
155
+ if (hidden[h] <= 0)
156
+ continue; // ReLU derivative
157
+ let grad = 0;
158
+ for (let o = 0; o < OUTPUT_SIZE; o++) {
159
+ grad += outputGrad[o] * this.weightsHiddenOutput[h * OUTPUT_SIZE + o];
160
+ }
161
+ hiddenGrad[h] = grad;
162
+ }
163
+ // Update input weights and biases
164
+ for (let i = 0; i < INPUT_SIZE; i++) {
165
+ for (let h = 0; h < HIDDEN_SIZE; h++) {
166
+ this.weightsInputHidden[i * HIDDEN_SIZE + h] += features[i] * hiddenGrad[h];
167
+ }
168
+ }
169
+ for (let h = 0; h < HIDDEN_SIZE; h++) {
170
+ this.biasHidden[h] += hiddenGrad[h];
171
+ }
172
+ }
173
+ /**
174
+ * Serialize weights for persistence
175
+ */
176
+ serialize() {
177
+ return {
178
+ weightsInputHidden: Array.from(this.weightsInputHidden),
179
+ weightsHiddenOutput: Array.from(this.weightsHiddenOutput),
180
+ biasHidden: Array.from(this.biasHidden),
181
+ biasOutput: Array.from(this.biasOutput),
182
+ };
183
+ }
184
+ /**
185
+ * Deserialize weights from persistence
186
+ */
187
+ deserialize(data) {
188
+ if (data.weightsInputHidden.length === INPUT_SIZE * HIDDEN_SIZE) {
189
+ this.weightsInputHidden = new Float32Array(data.weightsInputHidden);
190
+ }
191
+ if (data.weightsHiddenOutput.length === HIDDEN_SIZE * OUTPUT_SIZE) {
192
+ this.weightsHiddenOutput = new Float32Array(data.weightsHiddenOutput);
193
+ }
194
+ if (data.biasHidden.length === HIDDEN_SIZE) {
195
+ this.biasHidden = new Float32Array(data.biasHidden);
196
+ }
197
+ if (data.biasOutput.length === OUTPUT_SIZE) {
198
+ this.biasOutput = new Float32Array(data.biasOutput);
199
+ }
200
+ }
201
+ }
202
+ //# sourceMappingURL=simple-neural-router.js.map
@@ -178,10 +178,29 @@ export declare class TinyDancerRouter {
178
178
  getConfig(): TinyDancerConfig;
179
179
  }
180
180
  /**
181
- * Create a new TinyDancer router instance
181
+ * Create a new TinyDancer router instance (rule-based)
182
182
  *
183
183
  * @param config - Router configuration
184
184
  * @returns Configured TinyDancer router
185
185
  */
186
186
  export declare function createTinyDancerRouter(config?: TinyDancerConfig): TinyDancerRouter;
187
+ /**
188
+ * Create a TinyDancer router, selecting rule-based or neural based on feature flag.
189
+ *
190
+ * When `useNeuralRouting` is enabled in RuVector feature flags, returns a
191
+ * NeuralTinyDancerRouter that wraps the rule-based router with a neural network.
192
+ * Otherwise returns the standard rule-based TinyDancerRouter.
193
+ *
194
+ * Both implement the same `route()` interface returning `RouteResult`.
195
+ *
196
+ * @param config - Router configuration
197
+ * @returns Either a TinyDancerRouter or NeuralTinyDancerRouter
198
+ */
199
+ /** Shared router interface for both rule-based and neural routers */
200
+ export interface ITaskRouter {
201
+ route(task: QETask | ClassifiableTask): Promise<RouteResult>;
202
+ recordOutcome?(...args: unknown[]): void;
203
+ reset?(): void;
204
+ }
205
+ export declare function createSmartTinyDancerRouter(config?: TinyDancerConfig): ITaskRouter;
187
206
  //# sourceMappingURL=tiny-dancer-router.d.ts.map
@@ -330,10 +330,10 @@ export class TinyDancerRouter {
330
330
  }
331
331
  }
332
332
  // ============================================================================
333
- // Factory Function
333
+ // Factory Functions
334
334
  // ============================================================================
335
335
  /**
336
- * Create a new TinyDancer router instance
336
+ * Create a new TinyDancer router instance (rule-based)
337
337
  *
338
338
  * @param config - Router configuration
339
339
  * @returns Configured TinyDancer router
@@ -341,4 +341,23 @@ export class TinyDancerRouter {
341
341
  export function createTinyDancerRouter(config) {
342
342
  return new TinyDancerRouter(config);
343
343
  }
344
+ export function createSmartTinyDancerRouter(config) {
345
+ try {
346
+ // Dynamically check feature flag to avoid circular imports
347
+ // eslint-disable-next-line @typescript-eslint/no-require-imports
348
+ const { getRuVectorFeatureFlags } = require('../integrations/ruvector/feature-flags.js');
349
+ const flags = getRuVectorFeatureFlags();
350
+ if (flags.useNeuralRouting) {
351
+ // eslint-disable-next-line @typescript-eslint/no-require-imports
352
+ const { NeuralTinyDancerRouter } = require('./neural-tiny-dancer-router.js');
353
+ return new NeuralTinyDancerRouter(config);
354
+ }
355
+ }
356
+ catch (err) {
357
+ // Feature flags or neural router not available - use rule-based
358
+ if (process.env.DEBUG)
359
+ console.debug('[Router] Neural router unavailable, using rule-based:', err instanceof Error ? err.message : err);
360
+ }
361
+ return new TinyDancerRouter(config);
362
+ }
344
363
  //# sourceMappingURL=tiny-dancer-router.js.map
@@ -0,0 +1,81 @@
1
+ /**
2
+ * DAG Attention Scheduler for Intelligent Test Execution Ordering
3
+ * RuVector Integration Plan - Phase 4, Task 4.2
4
+ *
5
+ * Uses DAG-based attention mechanisms to intelligently order test execution:
6
+ * - Critical Path Attention: Identifies the longest chain in the test dependency DAG
7
+ * - Parallel Branch Attention: Finds sets of tests that can run concurrently
8
+ * - MinCut-Gated Attention: Prunes low-value tests to speed up execution
9
+ *
10
+ * Self-learning: tracks execution times and improves ordering over runs.
11
+ * TypeScript implementation (no native package exists for DAG attention).
12
+ *
13
+ * @module test-scheduling/dag-attention-scheduler
14
+ */
15
+ import type { TestNode, TestDAG, ScheduledExecution, SchedulerStats } from './dag-attention-types.js';
16
+ export type { TestNode, TestDAG, SchedulePhase, ScheduledExecution, SchedulerStats, } from './dag-attention-types.js';
17
+ /**
18
+ * DAG-based test scheduler using attention mechanisms for intelligent ordering.
19
+ *
20
+ * Three attention types control scheduling:
21
+ * 1. Critical Path Attention - finds the longest dependency chain
22
+ * 2. Parallel Branch Attention - finds independent test groups
23
+ * 3. MinCut-Gated Attention - prunes low-value tests under a time budget
24
+ *
25
+ * Self-learning: records actual execution times and adjusts estimated
26
+ * durations over successive runs via exponential moving average.
27
+ */
28
+ export declare class DAGAttentionScheduler {
29
+ private executionHistory;
30
+ private learnedDurations;
31
+ private runCount;
32
+ private lastPrunedCount;
33
+ private readonly learningRate;
34
+ private readonly maxHistorySize;
35
+ constructor(options?: {
36
+ learningRate?: number;
37
+ maxHistorySize?: number;
38
+ });
39
+ /**
40
+ * Build the internal TestDAG from an array of test nodes.
41
+ * Validates dependencies, computes forward edges, critical path,
42
+ * and parallel groups.
43
+ * @throws Error if a dependency references a non-existent test ID
44
+ */
45
+ buildTestDAG(tests: TestNode[]): TestDAG;
46
+ /** Find the critical path (longest duration chain) through the DAG. */
47
+ findCriticalPath(dag: TestDAG): TestNode[];
48
+ /** Find groups of tests that can execute concurrently. */
49
+ findParallelBranches(dag: TestDAG): TestNode[][];
50
+ /**
51
+ * Prune low-value tests from the DAG to fit within a time budget.
52
+ * Tests are scored by attention weight (priority * failure weight *
53
+ * downstream impact). Lowest-scored tests are removed first, unless
54
+ * they are on the critical path or have active dependents.
55
+ */
56
+ pruneByMinCut(dag: TestDAG, budget: number): TestDAG;
57
+ /** Produce a complete execution schedule for the given tests. */
58
+ schedule(tests: TestNode[]): ScheduledExecution;
59
+ /** Return optimization statistics. */
60
+ getOptimizationStats(): SchedulerStats;
61
+ /** Record actual execution results for self-learning via EMA. */
62
+ recordExecution(testId: string, actualDuration: number, result: 'pass' | 'fail' | 'skip'): void;
63
+ /** Get learned duration for a test, or undefined if no history. */
64
+ getLearnedDuration(testId: string): number | undefined;
65
+ /** Check whether the native ruvector-dag-wasm backend is available. */
66
+ isNativeBackendAvailable(): boolean;
67
+ private computeCriticalPath;
68
+ private computeCriticalPathDuration;
69
+ private computeParallelGroups;
70
+ private computeAttentionScores;
71
+ private countTransitiveDependents;
72
+ private topologicalSort;
73
+ private applyLearnedDuration;
74
+ private sumDurations;
75
+ }
76
+ /** Create a DAGAttentionScheduler with optional configuration. */
77
+ export declare function createDAGAttentionScheduler(options?: {
78
+ learningRate?: number;
79
+ maxHistorySize?: number;
80
+ }): DAGAttentionScheduler;
81
+ //# sourceMappingURL=dag-attention-scheduler.d.ts.map