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,284 @@
1
+ /**
2
+ * Coherence-Gated Agent Actions (Task 3.2, ADR-083)
3
+ *
4
+ * Evaluates agent actions through three stacked filters with
5
+ * heuristic scoring with CUSUM drift detection:
6
+ * 1. Structural filter: Action type familiarity and context completeness check
7
+ * 2. Shift filter: Confidence-risk alignment with CUSUM change detection
8
+ * 3. Evidence filter: Multiplicative context evidence accumulation score
9
+ *
10
+ * Decisions: PERMIT / DEFER / DENY
11
+ * - PERMIT: all filters pass (scores above permit thresholds)
12
+ * - DEFER: one or more filters marginal (needs human review)
13
+ * - DENY: one or more filters clearly fail
14
+ *
15
+ * Advisory mode by default: logs decisions but does not block execution.
16
+ *
17
+ * TypeScript implementation (no native package exists for this —
18
+ * heuristic filters work well without native computation).
19
+ *
20
+ * @module coordination/coherence-action-gate
21
+ * @see ADR-083-coherence-gated-agent-actions.md
22
+ */
23
+ /**
24
+ * An action that an agent intends to perform.
25
+ */
26
+ export interface AgentAction {
27
+ /** Action type identifier */
28
+ type: string;
29
+ /** Domain the action belongs to */
30
+ domain: string;
31
+ /** Agent's confidence in the action (0-1) */
32
+ confidence: number;
33
+ /** Arbitrary context for the action */
34
+ context: Record<string, unknown>;
35
+ /** Risk classification */
36
+ riskLevel: 'low' | 'medium' | 'high' | 'critical';
37
+ }
38
+ /**
39
+ * Gate decision: PERMIT, DEFER, or DENY.
40
+ */
41
+ export type GateDecision = 'PERMIT' | 'DEFER' | 'DENY';
42
+ /**
43
+ * Full evaluation result from the three-filter pipeline.
44
+ */
45
+ export interface GateEvaluation {
46
+ /** Final decision */
47
+ decision: GateDecision;
48
+ /** Structural filter score (0-1, higher = better fit) */
49
+ structuralScore: number;
50
+ /** Shift filter score (0-1, higher = less shift) */
51
+ shiftScore: number;
52
+ /** Evidence filter score (0-1, higher = more evidence) */
53
+ evidenceScore: number;
54
+ /** Weighted combined score (0-1) */
55
+ combinedScore: number;
56
+ /** Human-readable reasoning for the decision */
57
+ reasoning: string;
58
+ /** Whether this was advisory-only (logged, not enforced) */
59
+ advisory: boolean;
60
+ }
61
+ /**
62
+ * Configurable thresholds for the three filters.
63
+ */
64
+ export interface ThresholdConfig {
65
+ /** Structural filter: minimum score to pass (default: 0.4) */
66
+ structuralPermit?: number;
67
+ /** Structural filter: below this score = DENY (default: 0.2) */
68
+ structuralDeny?: number;
69
+ /** Shift filter: minimum score to pass (default: 0.5) */
70
+ shiftPermit?: number;
71
+ /** Shift filter: below this score = DENY (default: 0.25) */
72
+ shiftDeny?: number;
73
+ /** Evidence filter: minimum score to pass (default: 0.5) */
74
+ evidencePermit?: number;
75
+ /** Evidence filter: below this score = DENY (default: 0.2) */
76
+ evidenceDeny?: number;
77
+ /** Combined score: minimum to PERMIT (default: 0.5) */
78
+ combinedPermit?: number;
79
+ /** Combined score: below this = DENY (default: 0.25) */
80
+ combinedDeny?: number;
81
+ }
82
+ /**
83
+ * Aggregate statistics for observability.
84
+ */
85
+ export interface GateStats {
86
+ /** Total evaluations performed */
87
+ totalEvaluations: number;
88
+ /** Count of PERMIT decisions */
89
+ permitCount: number;
90
+ /** Count of DEFER decisions */
91
+ deferCount: number;
92
+ /** Count of DENY decisions */
93
+ denyCount: number;
94
+ /** Average combined score */
95
+ averageCombinedScore: number;
96
+ /** Average structural filter score */
97
+ averageStructuralScore: number;
98
+ /** Average shift filter score */
99
+ averageShiftScore: number;
100
+ /** Average evidence filter score */
101
+ averageEvidenceScore: number;
102
+ /** Whether advisory mode is active */
103
+ advisoryMode: boolean;
104
+ }
105
+ /**
106
+ * Internal resolved thresholds (all required).
107
+ */
108
+ interface ResolvedThresholds {
109
+ structuralPermit: number;
110
+ structuralDeny: number;
111
+ shiftPermit: number;
112
+ shiftDeny: number;
113
+ evidencePermit: number;
114
+ evidenceDeny: number;
115
+ combinedPermit: number;
116
+ combinedDeny: number;
117
+ }
118
+ /**
119
+ * Three-filter coherence gate for agent action evaluation.
120
+ *
121
+ * Evaluates whether an agent action should proceed by running it through
122
+ * structural, shift, and evidence filters. Advisory mode by default.
123
+ *
124
+ * @example
125
+ * ```typescript
126
+ * const gate = new CoherenceActionGate();
127
+ * const evaluation = gate.evaluate({
128
+ * type: 'generate-test',
129
+ * domain: 'test-generation',
130
+ * confidence: 0.85,
131
+ * context: { filePath: 'src/service.ts' },
132
+ * riskLevel: 'medium',
133
+ * });
134
+ * if (evaluation.decision === 'DENY') {
135
+ * console.warn('Action denied:', evaluation.reasoning);
136
+ * }
137
+ * ```
138
+ */
139
+ export declare class CoherenceActionGate {
140
+ private thresholds;
141
+ private readonly advisoryMode;
142
+ private nativeAvailable;
143
+ private evaluationHistory;
144
+ private permitCount;
145
+ private deferCount;
146
+ private denyCount;
147
+ private totalCombinedScore;
148
+ private totalStructuralScore;
149
+ private totalShiftScore;
150
+ private totalEvidenceScore;
151
+ private cusumHigh;
152
+ private cusumLow;
153
+ private cusumMean;
154
+ private cusumK;
155
+ private cusumH;
156
+ private cusumSampleCount;
157
+ private cusumAlertActive;
158
+ constructor(options?: {
159
+ advisory?: boolean;
160
+ thresholds?: ThresholdConfig;
161
+ });
162
+ /**
163
+ * Evaluate an agent action through the three-filter pipeline.
164
+ *
165
+ * @param action - The agent action to evaluate
166
+ * @returns Full evaluation with decision, scores, and reasoning
167
+ */
168
+ evaluate(action: AgentAction): GateEvaluation;
169
+ /**
170
+ * Get aggregate statistics for observability.
171
+ */
172
+ getStatistics(): GateStats;
173
+ /**
174
+ * Update thresholds at runtime.
175
+ *
176
+ * @param config - Partial threshold overrides
177
+ */
178
+ configureThresholds(config: ThresholdConfig): void;
179
+ /**
180
+ * Get the current threshold configuration.
181
+ */
182
+ getThresholds(): Readonly<ResolvedThresholds>;
183
+ /**
184
+ * Whether advisory mode is active.
185
+ */
186
+ isAdvisory(): boolean;
187
+ /**
188
+ * Get the evaluation history (bounded).
189
+ */
190
+ getEvaluationHistory(): GateEvaluation[];
191
+ /**
192
+ * Clear evaluation history and reset statistics.
193
+ */
194
+ resetStatistics(): void;
195
+ /**
196
+ * Reset CUSUM change detection state.
197
+ */
198
+ resetCusum(): void;
199
+ /**
200
+ * Structural filter: Action type familiarity and context completeness check.
201
+ *
202
+ * Considers:
203
+ * - Action type familiarity (known vs unknown action types)
204
+ * - Domain alignment (is the action appropriate for this domain?)
205
+ * - Context completeness (does the action have sufficient context?)
206
+ *
207
+ * Higher score = better structural fit.
208
+ */
209
+ private computeStructuralScore;
210
+ /**
211
+ * Shift filter: Confidence-risk alignment with CUSUM change detection.
212
+ *
213
+ * Considers:
214
+ * - Confidence level (low confidence suggests distributional shift)
215
+ * - Risk level alignment (high risk with low confidence = shift)
216
+ * - Context consistency (presence of contradictory signals)
217
+ * - CUSUM cumulative sum control chart for persistent drift detection
218
+ *
219
+ * Higher score = less distributional shift detected.
220
+ */
221
+ private computeShiftScore;
222
+ /**
223
+ * Evidence filter: Multiplicative context evidence accumulation score.
224
+ *
225
+ * Uses multiplicative accumulation where each piece of evidence
226
+ * compounds on the previous score. Multiple negative signals compound
227
+ * more aggressively than additive scoring.
228
+ *
229
+ * Considers:
230
+ * - Supporting evidence in context (test results, coverage data, etc.)
231
+ * - Evidence against (errors, failures, warnings)
232
+ * - Risk-level specific evidence requirements
233
+ *
234
+ * Higher score = more evidence supporting the action.
235
+ */
236
+ private computeEvidenceScore;
237
+ /**
238
+ * Determine the final PERMIT/DEFER/DENY decision from filter scores.
239
+ *
240
+ * Logic:
241
+ * - DENY if any individual filter is below its deny threshold
242
+ * - DENY if combined score is below combined deny threshold
243
+ * - PERMIT if all filters are above their permit thresholds AND
244
+ * combined score is above combined permit threshold
245
+ * - DEFER otherwise (marginal - needs human review)
246
+ */
247
+ private computeDecision;
248
+ /**
249
+ * Build a human-readable reasoning string.
250
+ */
251
+ private buildReasoning;
252
+ /**
253
+ * Record an evaluation for statistics tracking.
254
+ */
255
+ private recordEvaluation;
256
+ }
257
+ /**
258
+ * Create a CoherenceActionGate instance.
259
+ *
260
+ * @param options - Optional configuration
261
+ * @returns A new CoherenceActionGate instance
262
+ */
263
+ export declare function createCoherenceActionGate(options?: {
264
+ advisory?: boolean;
265
+ thresholds?: ThresholdConfig;
266
+ }): CoherenceActionGate;
267
+ /**
268
+ * Evaluate a task execution action through the coherence gate.
269
+ *
270
+ * This is the integration point called by the task executor. It checks
271
+ * the feature flag, creates an AgentAction from task metadata, and
272
+ * returns the evaluation result.
273
+ *
274
+ * @param taskType - The type of task being executed
275
+ * @param domain - The domain the task targets
276
+ * @param confidence - Confidence level (0-1)
277
+ * @param riskLevel - Risk classification
278
+ * @param context - Additional context
279
+ * @param gate - Optional pre-existing gate instance (for reuse)
280
+ * @returns The gate evaluation, or null if the feature flag is off
281
+ */
282
+ export declare function evaluateTaskAction(taskType: string, domain: string, confidence: number, riskLevel: 'low' | 'medium' | 'high' | 'critical', context: Record<string, unknown>, gate?: CoherenceActionGate): GateEvaluation | null;
283
+ export {};
284
+ //# sourceMappingURL=coherence-action-gate.d.ts.map