agentic-qe 3.8.11 → 3.8.13

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