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.
- package/.claude/skills/qe-code-intelligence/SKILL.md +29 -20
- package/.claude/skills/qe-code-intelligence/evals/qe-code-intelligence.yaml +3 -3
- package/.claude/skills/qe-quality-assessment/SKILL.md +1 -1
- package/.claude/skills/qe-test-generation/SKILL.md +1 -1
- package/.claude/skills/skills-manifest.json +1 -1
- package/CHANGELOG.md +45 -0
- package/README.md +9 -0
- package/assets/skills/qe-code-intelligence/SKILL.md +29 -20
- package/assets/skills/qe-code-intelligence/evals/qe-code-intelligence.yaml +3 -3
- package/assets/skills/qe-quality-assessment/SKILL.md +1 -1
- package/assets/skills/qe-test-generation/SKILL.md +1 -1
- package/dist/cli/bundle.js +1162 -1046
- package/dist/cli/commands/code.js +149 -11
- package/dist/cli/commands/init.js +3 -2
- package/dist/cli/commands/ruvector-commands.js +17 -0
- package/dist/cli/handlers/init-handler.d.ts +1 -0
- package/dist/cli/handlers/init-handler.js +15 -10
- package/dist/cli/utils/file-discovery.d.ts +1 -0
- package/dist/cli/utils/file-discovery.js +1 -1
- package/dist/domains/code-intelligence/coordinator-gnn.d.ts +21 -0
- package/dist/domains/code-intelligence/coordinator-gnn.js +102 -0
- package/dist/domains/contract-testing/coordinator.js +13 -0
- package/dist/domains/coverage-analysis/coordinator.js +5 -0
- package/dist/domains/defect-intelligence/coordinator.d.ts +1 -0
- package/dist/domains/defect-intelligence/coordinator.js +43 -0
- package/dist/domains/quality-assessment/coordinator.js +26 -0
- package/dist/domains/test-generation/coordinator.js +14 -0
- package/dist/init/orchestrator.js +1 -0
- package/dist/init/phases/08-mcp.js +4 -4
- package/dist/init/phases/phase-interface.d.ts +3 -1
- package/dist/integrations/agentic-flow/reasoning-bank/experience-replay.d.ts +11 -0
- package/dist/integrations/agentic-flow/reasoning-bank/experience-replay.js +44 -1
- package/dist/integrations/rl-suite/algorithms/eprop.d.ts +79 -0
- package/dist/integrations/rl-suite/algorithms/eprop.js +284 -0
- package/dist/integrations/rl-suite/algorithms/index.d.ts +2 -1
- package/dist/integrations/rl-suite/algorithms/index.js +2 -1
- package/dist/integrations/rl-suite/index.d.ts +2 -2
- package/dist/integrations/rl-suite/index.js +2 -2
- package/dist/integrations/rl-suite/interfaces.d.ts +3 -3
- package/dist/integrations/rl-suite/interfaces.js +1 -1
- package/dist/integrations/rl-suite/orchestrator.d.ts +2 -2
- package/dist/integrations/rl-suite/orchestrator.js +3 -2
- package/dist/integrations/rl-suite/reward-signals.d.ts +1 -1
- package/dist/integrations/rl-suite/reward-signals.js +1 -1
- package/dist/integrations/ruvector/coherence-gate-cohomology.d.ts +41 -0
- package/dist/integrations/ruvector/coherence-gate-cohomology.js +47 -0
- package/dist/integrations/ruvector/coherence-gate-core.d.ts +200 -0
- package/dist/integrations/ruvector/coherence-gate-core.js +294 -0
- package/dist/integrations/ruvector/coherence-gate-energy.d.ts +136 -0
- package/dist/integrations/ruvector/coherence-gate-energy.js +373 -0
- package/dist/integrations/ruvector/coherence-gate-vector.d.ts +38 -0
- package/dist/integrations/ruvector/coherence-gate-vector.js +76 -0
- package/dist/integrations/ruvector/coherence-gate.d.ts +10 -311
- package/dist/integrations/ruvector/coherence-gate.js +10 -652
- package/dist/integrations/ruvector/cold-tier-trainer.d.ts +103 -0
- package/dist/integrations/ruvector/cold-tier-trainer.js +377 -0
- package/dist/integrations/ruvector/cusum-detector.d.ts +70 -0
- package/dist/integrations/ruvector/cusum-detector.js +142 -0
- package/dist/integrations/ruvector/delta-tracker.d.ts +122 -0
- package/dist/integrations/ruvector/delta-tracker.js +311 -0
- package/dist/integrations/ruvector/domain-transfer.d.ts +79 -1
- package/dist/integrations/ruvector/domain-transfer.js +158 -2
- package/dist/integrations/ruvector/eprop-learner.d.ts +135 -0
- package/dist/integrations/ruvector/eprop-learner.js +351 -0
- package/dist/integrations/ruvector/feature-flags.d.ts +177 -0
- package/dist/integrations/ruvector/feature-flags.js +145 -0
- package/dist/integrations/ruvector/graphmae-encoder.d.ts +88 -0
- package/dist/integrations/ruvector/graphmae-encoder.js +360 -0
- package/dist/integrations/ruvector/hdc-fingerprint.d.ts +127 -0
- package/dist/integrations/ruvector/hdc-fingerprint.js +222 -0
- package/dist/integrations/ruvector/hopfield-memory.d.ts +97 -0
- package/dist/integrations/ruvector/hopfield-memory.js +238 -0
- package/dist/integrations/ruvector/index.d.ts +13 -2
- package/dist/integrations/ruvector/index.js +46 -2
- package/dist/integrations/ruvector/mincut-wrapper.d.ts +7 -0
- package/dist/integrations/ruvector/mincut-wrapper.js +54 -2
- package/dist/integrations/ruvector/reservoir-replay.d.ts +172 -0
- package/dist/integrations/ruvector/reservoir-replay.js +335 -0
- package/dist/integrations/ruvector/solver-adapter.d.ts +93 -0
- package/dist/integrations/ruvector/solver-adapter.js +299 -0
- package/dist/integrations/ruvector/sona-persistence.d.ts +33 -0
- package/dist/integrations/ruvector/sona-persistence.js +47 -0
- package/dist/integrations/ruvector/spectral-sparsifier.d.ts +154 -0
- package/dist/integrations/ruvector/spectral-sparsifier.js +389 -0
- package/dist/integrations/ruvector/temporal-causality.d.ts +63 -0
- package/dist/integrations/ruvector/temporal-causality.js +317 -0
- package/dist/learning/pattern-promotion.d.ts +63 -0
- package/dist/learning/pattern-promotion.js +235 -1
- package/dist/learning/pattern-store.d.ts +2 -0
- package/dist/learning/pattern-store.js +187 -1
- package/dist/learning/sqlite-persistence.d.ts +2 -0
- package/dist/learning/sqlite-persistence.js +4 -0
- package/dist/mcp/bundle.js +506 -427
- package/dist/shared/utils/index.d.ts +1 -0
- package/dist/shared/utils/index.js +1 -0
- package/dist/shared/utils/xorshift128.d.ts +24 -0
- package/dist/shared/utils/xorshift128.js +50 -0
- package/package.json +1 -1
|
@@ -10,6 +10,34 @@ import { ok, err } from '../shared/types/index.js';
|
|
|
10
10
|
import { toErrorMessage, toError } from '../shared/error-utils.js';
|
|
11
11
|
import { calculateQualityScore, shouldPromotePattern, validateQEPattern, mapQEDomainToAQE, PROMOTION_THRESHOLD, } from './qe-patterns.js';
|
|
12
12
|
import { applyFilterSync } from '../integrations/ruvector/filter-adapter.js';
|
|
13
|
+
import { isHDCFingerprintingEnabled, isDeltaEventSourcingEnabled, isHopfieldMemoryEnabled, } from '../integrations/ruvector/feature-flags.js';
|
|
14
|
+
import { createHdcFingerprinter, } from '../integrations/ruvector/hdc-fingerprint.js';
|
|
15
|
+
import { DeltaTracker } from '../integrations/ruvector/delta-tracker.js';
|
|
16
|
+
import { createHopfieldMemory } from '../integrations/ruvector/hopfield-memory.js';
|
|
17
|
+
// ============================================================================
|
|
18
|
+
// R1: HDC Fingerprint Singleton (lazy-initialized)
|
|
19
|
+
// ============================================================================
|
|
20
|
+
/** Module-level HDC fingerprinter, created on first use */
|
|
21
|
+
let hdcFingerprinter = null;
|
|
22
|
+
function getHdcFingerprinter() {
|
|
23
|
+
if (!hdcFingerprinter) {
|
|
24
|
+
hdcFingerprinter = createHdcFingerprinter({ dimensions: 10000 });
|
|
25
|
+
}
|
|
26
|
+
return hdcFingerprinter;
|
|
27
|
+
}
|
|
28
|
+
// ============================================================================
|
|
29
|
+
// R5: Hopfield Memory Singleton (lazy-initialized, dimension-aware)
|
|
30
|
+
// ============================================================================
|
|
31
|
+
/** Module-level Hopfield memory for exact pattern recall */
|
|
32
|
+
let hopfieldMemory = null;
|
|
33
|
+
let hopfieldDimension = 0;
|
|
34
|
+
function getHopfieldMemory(dimension) {
|
|
35
|
+
if (!hopfieldMemory || hopfieldDimension !== dimension) {
|
|
36
|
+
hopfieldMemory = createHopfieldMemory({ dimension, maxPatterns: 10000 });
|
|
37
|
+
hopfieldDimension = dimension;
|
|
38
|
+
}
|
|
39
|
+
return hopfieldMemory;
|
|
40
|
+
}
|
|
13
41
|
/**
|
|
14
42
|
* Default pattern store configuration
|
|
15
43
|
*/
|
|
@@ -67,6 +95,10 @@ export class PatternStore {
|
|
|
67
95
|
hnswIndex = null;
|
|
68
96
|
hnswAvailable = false;
|
|
69
97
|
hnswInitPromise = null;
|
|
98
|
+
// R1: HDC fingerprint cache (pattern ID -> fingerprint vector)
|
|
99
|
+
hdcCache = new Map();
|
|
100
|
+
// R3: Delta event sourcing tracker (lazy-initialized with SQLite)
|
|
101
|
+
deltaTracker = null;
|
|
70
102
|
// Statistics
|
|
71
103
|
stats = {
|
|
72
104
|
searchOperations: 0,
|
|
@@ -86,6 +118,18 @@ export class PatternStore {
|
|
|
86
118
|
*/
|
|
87
119
|
setSqliteStore(store) {
|
|
88
120
|
this.sqliteStore = store;
|
|
121
|
+
// R3: Initialize DeltaTracker using the same SQLite DB instance
|
|
122
|
+
if (isDeltaEventSourcingEnabled() && !this.deltaTracker) {
|
|
123
|
+
try {
|
|
124
|
+
const db = store.getDb();
|
|
125
|
+
this.deltaTracker = new DeltaTracker(db);
|
|
126
|
+
this.deltaTracker.initialize();
|
|
127
|
+
console.log('[PatternStore] Delta event sourcing initialized');
|
|
128
|
+
}
|
|
129
|
+
catch (e) {
|
|
130
|
+
console.warn('[PatternStore] Delta tracker init failed:', e instanceof Error ? e.message : e);
|
|
131
|
+
}
|
|
132
|
+
}
|
|
89
133
|
// Load patterns from SQLite if we're already initialized
|
|
90
134
|
// (setSqliteStore is called after initialize() in QEReasoningBank)
|
|
91
135
|
// Store promise so concurrent store/search calls can await it
|
|
@@ -278,6 +322,7 @@ export class PatternStore {
|
|
|
278
322
|
this.domainIndex.get(pattern.qeDomain)?.delete(pattern.id);
|
|
279
323
|
this.typeIndex.get(pattern.patternType)?.delete(pattern.id);
|
|
280
324
|
this.tierIndex.get(pattern.tier)?.delete(pattern.id);
|
|
325
|
+
this.hdcCache.delete(pattern.id); // R1: cleanup HDC fingerprint
|
|
281
326
|
}
|
|
282
327
|
/**
|
|
283
328
|
* Store a new pattern
|
|
@@ -340,6 +385,55 @@ export class PatternStore {
|
|
|
340
385
|
}
|
|
341
386
|
}
|
|
342
387
|
}
|
|
388
|
+
// R1: Compute and cache HDC fingerprint for fast pre-filtering
|
|
389
|
+
if (isHDCFingerprintingEnabled()) {
|
|
390
|
+
try {
|
|
391
|
+
const hdc = getHdcFingerprinter();
|
|
392
|
+
const fp = hdc.fingerprint({
|
|
393
|
+
id: pattern.id,
|
|
394
|
+
domain: pattern.qeDomain,
|
|
395
|
+
type: pattern.patternType,
|
|
396
|
+
content: pattern.description,
|
|
397
|
+
});
|
|
398
|
+
this.hdcCache.set(pattern.id, fp.vector);
|
|
399
|
+
}
|
|
400
|
+
catch (error) {
|
|
401
|
+
console.debug(`[PatternStore] HDC fingerprint failed for ${pattern.id}:`, toErrorMessage(error));
|
|
402
|
+
}
|
|
403
|
+
}
|
|
404
|
+
// R5: Store embedding in Hopfield memory for exact recall
|
|
405
|
+
if (isHopfieldMemoryEnabled() && pattern.embedding) {
|
|
406
|
+
try {
|
|
407
|
+
const hopfield = getHopfieldMemory(pattern.embedding.length);
|
|
408
|
+
hopfield.store(new Float32Array(pattern.embedding), {
|
|
409
|
+
id: pattern.id,
|
|
410
|
+
name: pattern.name,
|
|
411
|
+
domain: pattern.qeDomain,
|
|
412
|
+
});
|
|
413
|
+
}
|
|
414
|
+
catch (error) {
|
|
415
|
+
console.debug(`[PatternStore] Hopfield store failed for ${pattern.id}:`, toErrorMessage(error));
|
|
416
|
+
}
|
|
417
|
+
}
|
|
418
|
+
// R3: Create genesis delta event for new patterns
|
|
419
|
+
if (isDeltaEventSourcingEnabled() && this.deltaTracker) {
|
|
420
|
+
try {
|
|
421
|
+
const snapshot = {
|
|
422
|
+
id: pattern.id,
|
|
423
|
+
name: pattern.name,
|
|
424
|
+
confidence: pattern.confidence,
|
|
425
|
+
qualityScore: pattern.qualityScore,
|
|
426
|
+
usageCount: pattern.usageCount,
|
|
427
|
+
successRate: pattern.successRate,
|
|
428
|
+
tier: pattern.tier,
|
|
429
|
+
};
|
|
430
|
+
this.deltaTracker.createGenesis(pattern.id, snapshot);
|
|
431
|
+
}
|
|
432
|
+
catch (error) {
|
|
433
|
+
// Genesis may already exist if pattern was re-stored; log at debug level
|
|
434
|
+
console.debug(`[PatternStore] Delta genesis for ${pattern.id}:`, toErrorMessage(error));
|
|
435
|
+
}
|
|
436
|
+
}
|
|
343
437
|
return ok(pattern.id);
|
|
344
438
|
}
|
|
345
439
|
/**
|
|
@@ -429,6 +523,34 @@ export class PatternStore {
|
|
|
429
523
|
const limit = options.limit || 10;
|
|
430
524
|
const results = [];
|
|
431
525
|
try {
|
|
526
|
+
// R5: Exact recall via Hopfield — check for high-confidence exact match
|
|
527
|
+
if (Array.isArray(query) && isHopfieldMemoryEnabled()) {
|
|
528
|
+
try {
|
|
529
|
+
const hopfield = getHopfieldMemory(query.length);
|
|
530
|
+
if (hopfield.getPatternCount() > 0) {
|
|
531
|
+
const recallResult = hopfield.recall(new Float32Array(query));
|
|
532
|
+
if (recallResult && recallResult.similarity > 0.98) {
|
|
533
|
+
const patternId = recallResult.metadata.id;
|
|
534
|
+
const pattern = await this.get(patternId);
|
|
535
|
+
if (pattern && this.matchesFilters(pattern, options)) {
|
|
536
|
+
const reuseInfo = this.calculateReuseInfo(pattern, recallResult.similarity);
|
|
537
|
+
results.push({
|
|
538
|
+
pattern,
|
|
539
|
+
score: recallResult.similarity,
|
|
540
|
+
matchType: 'vector',
|
|
541
|
+
similarity: recallResult.similarity,
|
|
542
|
+
canReuse: reuseInfo.canReuse,
|
|
543
|
+
estimatedTokenSavings: reuseInfo.estimatedTokenSavings,
|
|
544
|
+
reuseConfidence: reuseInfo.reuseConfidence,
|
|
545
|
+
});
|
|
546
|
+
}
|
|
547
|
+
}
|
|
548
|
+
}
|
|
549
|
+
}
|
|
550
|
+
catch (error) {
|
|
551
|
+
console.debug('[PatternStore] Hopfield recall failed:', toErrorMessage(error));
|
|
552
|
+
}
|
|
553
|
+
}
|
|
432
554
|
// Vector search if query is embedding and HNSW available (lazy-load)
|
|
433
555
|
if (Array.isArray(query) && options.useVectorSearch !== false) {
|
|
434
556
|
const hnsw = await this.ensureHNSW();
|
|
@@ -552,7 +674,37 @@ export class PatternStore {
|
|
|
552
674
|
else {
|
|
553
675
|
candidates = new Set(this.patternCache.keys());
|
|
554
676
|
}
|
|
555
|
-
|
|
677
|
+
// R1: HDC fast-path pre-filter — sort candidates by Hamming similarity
|
|
678
|
+
// so we process the most likely matches first (reduces wasted iterations)
|
|
679
|
+
let orderedCandidates = [...candidates];
|
|
680
|
+
if (isHDCFingerprintingEnabled() && queryLower && this.hdcCache.size > 0) {
|
|
681
|
+
try {
|
|
682
|
+
const hdc = getHdcFingerprinter();
|
|
683
|
+
const queryFp = hdc.fingerprint({
|
|
684
|
+
id: 'query',
|
|
685
|
+
domain: options.domain ?? 'unknown',
|
|
686
|
+
type: options.patternType ?? 'unknown',
|
|
687
|
+
content: query,
|
|
688
|
+
});
|
|
689
|
+
// Score each candidate by Hamming similarity and sort descending
|
|
690
|
+
const scored = orderedCandidates
|
|
691
|
+
.filter(id => this.hdcCache.has(id))
|
|
692
|
+
.map(id => ({
|
|
693
|
+
id,
|
|
694
|
+
similarity: hdc.similarity(queryFp.vector, this.hdcCache.get(id)),
|
|
695
|
+
}));
|
|
696
|
+
scored.sort((a, b) => b.similarity - a.similarity);
|
|
697
|
+
// Reorder by HDC similarity but never eliminate — text match is authoritative
|
|
698
|
+
const hdcOrdered = scored.map(s => s.id);
|
|
699
|
+
// Add back candidates without fingerprints at the end
|
|
700
|
+
const unfingerprinted = orderedCandidates.filter(id => !this.hdcCache.has(id));
|
|
701
|
+
orderedCandidates = [...hdcOrdered, ...unfingerprinted];
|
|
702
|
+
}
|
|
703
|
+
catch {
|
|
704
|
+
// HDC pre-filter is best-effort; fall through to normal search
|
|
705
|
+
}
|
|
706
|
+
}
|
|
707
|
+
for (const id of orderedCandidates) {
|
|
556
708
|
if (results.length >= limit)
|
|
557
709
|
break;
|
|
558
710
|
const pattern = this.patternCache.get(id);
|
|
@@ -717,6 +869,33 @@ export class PatternStore {
|
|
|
717
869
|
console.warn(`[PatternStore] SQLite recordUsage failed for ${id}:`, toErrorMessage(error));
|
|
718
870
|
}
|
|
719
871
|
}
|
|
872
|
+
// R3: Record delta event for the pattern update
|
|
873
|
+
if (isDeltaEventSourcingEnabled() && this.deltaTracker) {
|
|
874
|
+
try {
|
|
875
|
+
const before = {
|
|
876
|
+
id: pattern.id,
|
|
877
|
+
name: pattern.name,
|
|
878
|
+
confidence: pattern.confidence,
|
|
879
|
+
qualityScore: pattern.qualityScore,
|
|
880
|
+
usageCount: pattern.usageCount,
|
|
881
|
+
successRate: pattern.successRate,
|
|
882
|
+
tier: pattern.tier,
|
|
883
|
+
};
|
|
884
|
+
const after = {
|
|
885
|
+
id: updated.id,
|
|
886
|
+
name: updated.name,
|
|
887
|
+
confidence: updated.confidence,
|
|
888
|
+
qualityScore: updated.qualityScore,
|
|
889
|
+
usageCount: updated.usageCount,
|
|
890
|
+
successRate: updated.successRate,
|
|
891
|
+
tier: updated.tier,
|
|
892
|
+
};
|
|
893
|
+
this.deltaTracker.recordDelta(id, before, after, { success });
|
|
894
|
+
}
|
|
895
|
+
catch (error) {
|
|
896
|
+
console.debug(`[PatternStore] Delta recordDelta for ${id}:`, toErrorMessage(error));
|
|
897
|
+
}
|
|
898
|
+
}
|
|
720
899
|
// Check for promotion (ADR-052: shouldPromotePattern returns PromotionCheck object)
|
|
721
900
|
const promotionCheck = shouldPromotePattern(updated);
|
|
722
901
|
const shouldPromote = promotionCheck.meetsUsageCriteria &&
|
|
@@ -948,6 +1127,13 @@ export class PatternStore {
|
|
|
948
1127
|
this.domainIndex.clear();
|
|
949
1128
|
this.typeIndex.clear();
|
|
950
1129
|
this.tierIndex.clear();
|
|
1130
|
+
this.hdcCache.clear(); // R1: cleanup
|
|
1131
|
+
this.deltaTracker = null; // R3: cleanup
|
|
1132
|
+
if (hopfieldMemory) {
|
|
1133
|
+
hopfieldMemory.clear();
|
|
1134
|
+
hopfieldMemory = null;
|
|
1135
|
+
hopfieldDimension = 0;
|
|
1136
|
+
} // R5: cleanup
|
|
951
1137
|
this.initialized = false;
|
|
952
1138
|
}
|
|
953
1139
|
}
|
|
@@ -53,6 +53,8 @@ export declare class SQLitePatternStore {
|
|
|
53
53
|
private initialized;
|
|
54
54
|
private unifiedMemory;
|
|
55
55
|
constructor(config?: Partial<SQLitePersistenceConfig>);
|
|
56
|
+
/** Expose the underlying database for cross-module schema extensions (R8 citations, R3 deltas) */
|
|
57
|
+
getDatabase(): DatabaseType | null;
|
|
56
58
|
/**
|
|
57
59
|
* Initialize the database
|
|
58
60
|
*/
|
|
@@ -64,6 +64,10 @@ export class SQLitePatternStore {
|
|
|
64
64
|
constructor(config = {}) {
|
|
65
65
|
this.config = { ...DEFAULT_SQLITE_CONFIG, ...config };
|
|
66
66
|
}
|
|
67
|
+
/** Expose the underlying database for cross-module schema extensions (R8 citations, R3 deltas) */
|
|
68
|
+
getDatabase() {
|
|
69
|
+
return this.db;
|
|
70
|
+
}
|
|
67
71
|
/**
|
|
68
72
|
* Initialize the database
|
|
69
73
|
*/
|