agentic-qe 3.6.19 → 3.7.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.
- package/.claude/skills/skills-manifest.json +1 -1
- package/README.md +29 -1
- package/package.json +2 -1
- package/scripts/rvf-baseline-benchmark.ts +843 -0
- package/v3/CHANGELOG.md +30 -0
- package/v3/dist/audit/witness-chain.d.ts +148 -0
- package/v3/dist/audit/witness-chain.d.ts.map +1 -0
- package/v3/dist/audit/witness-chain.js +269 -0
- package/v3/dist/audit/witness-chain.js.map +1 -0
- package/v3/dist/cli/brain-commands.d.ts +39 -0
- package/v3/dist/cli/brain-commands.d.ts.map +1 -0
- package/v3/dist/cli/brain-commands.js +60 -0
- package/v3/dist/cli/brain-commands.js.map +1 -0
- package/v3/dist/cli/bundle.js +4509 -2452
- package/v3/dist/cli/command-registry.d.ts.map +1 -1
- package/v3/dist/cli/command-registry.js +3 -1
- package/v3/dist/cli/command-registry.js.map +1 -1
- package/v3/dist/cli/handlers/brain-handler.d.ts +22 -0
- package/v3/dist/cli/handlers/brain-handler.d.ts.map +1 -0
- package/v3/dist/cli/handlers/brain-handler.js +148 -0
- package/v3/dist/cli/handlers/brain-handler.js.map +1 -0
- package/v3/dist/cli/handlers/index.d.ts +1 -0
- package/v3/dist/cli/handlers/index.d.ts.map +1 -1
- package/v3/dist/cli/handlers/index.js +1 -0
- package/v3/dist/cli/handlers/index.js.map +1 -1
- package/v3/dist/domains/coverage-analysis/services/hnsw-index.d.ts +31 -44
- package/v3/dist/domains/coverage-analysis/services/hnsw-index.d.ts.map +1 -1
- package/v3/dist/domains/coverage-analysis/services/hnsw-index.js +73 -178
- package/v3/dist/domains/coverage-analysis/services/hnsw-index.js.map +1 -1
- package/v3/dist/domains/quality-assessment/coordinator.d.ts.map +1 -1
- package/v3/dist/domains/quality-assessment/coordinator.js +8 -0
- package/v3/dist/domains/quality-assessment/coordinator.js.map +1 -1
- package/v3/dist/domains/test-execution/coordinator.d.ts +14 -0
- package/v3/dist/domains/test-execution/coordinator.d.ts.map +1 -1
- package/v3/dist/domains/test-execution/coordinator.js +18 -0
- package/v3/dist/domains/test-execution/coordinator.js.map +1 -1
- package/v3/dist/domains/test-execution/services/index.d.ts +1 -0
- package/v3/dist/domains/test-execution/services/index.d.ts.map +1 -1
- package/v3/dist/domains/test-execution/services/index.js +1 -0
- package/v3/dist/domains/test-execution/services/index.js.map +1 -1
- package/v3/dist/domains/test-execution/services/mincut-test-optimizer.d.ts +118 -0
- package/v3/dist/domains/test-execution/services/mincut-test-optimizer.d.ts.map +1 -0
- package/v3/dist/domains/test-execution/services/mincut-test-optimizer.js +358 -0
- package/v3/dist/domains/test-execution/services/mincut-test-optimizer.js.map +1 -0
- package/v3/dist/integrations/ruvector/brain-exporter.d.ts +66 -0
- package/v3/dist/integrations/ruvector/brain-exporter.d.ts.map +1 -0
- package/v3/dist/integrations/ruvector/brain-exporter.js +537 -0
- package/v3/dist/integrations/ruvector/brain-exporter.js.map +1 -0
- package/v3/dist/integrations/ruvector/index.d.ts +4 -0
- package/v3/dist/integrations/ruvector/index.d.ts.map +1 -1
- package/v3/dist/integrations/ruvector/index.js +5 -0
- package/v3/dist/integrations/ruvector/index.js.map +1 -1
- package/v3/dist/integrations/ruvector/mincut-wrapper.d.ts +204 -0
- package/v3/dist/integrations/ruvector/mincut-wrapper.d.ts.map +1 -0
- package/v3/dist/integrations/ruvector/mincut-wrapper.js +310 -0
- package/v3/dist/integrations/ruvector/mincut-wrapper.js.map +1 -0
- package/v3/dist/integrations/ruvector/rvf-dual-writer.d.ts +141 -0
- package/v3/dist/integrations/ruvector/rvf-dual-writer.d.ts.map +1 -0
- package/v3/dist/integrations/ruvector/rvf-dual-writer.js +367 -0
- package/v3/dist/integrations/ruvector/rvf-dual-writer.js.map +1 -0
- package/v3/dist/integrations/ruvector/rvf-native-adapter.d.ts +60 -0
- package/v3/dist/integrations/ruvector/rvf-native-adapter.d.ts.map +1 -0
- package/v3/dist/integrations/ruvector/rvf-native-adapter.js +240 -0
- package/v3/dist/integrations/ruvector/rvf-native-adapter.js.map +1 -0
- package/v3/dist/kernel/hnsw-adapter.d.ts +99 -0
- package/v3/dist/kernel/hnsw-adapter.d.ts.map +1 -0
- package/v3/dist/kernel/hnsw-adapter.js +218 -0
- package/v3/dist/kernel/hnsw-adapter.js.map +1 -0
- package/v3/dist/kernel/hnsw-index-provider.d.ts +90 -0
- package/v3/dist/kernel/hnsw-index-provider.d.ts.map +1 -0
- package/v3/dist/kernel/hnsw-index-provider.js +23 -0
- package/v3/dist/kernel/hnsw-index-provider.js.map +1 -0
- package/v3/dist/kernel/progressive-hnsw-backend.d.ts +67 -0
- package/v3/dist/kernel/progressive-hnsw-backend.d.ts.map +1 -0
- package/v3/dist/kernel/progressive-hnsw-backend.js +266 -0
- package/v3/dist/kernel/progressive-hnsw-backend.js.map +1 -0
- package/v3/dist/kernel/unified-memory-hnsw.d.ts +71 -0
- package/v3/dist/kernel/unified-memory-hnsw.d.ts.map +1 -1
- package/v3/dist/kernel/unified-memory-hnsw.js +87 -0
- package/v3/dist/kernel/unified-memory-hnsw.js.map +1 -1
- package/v3/dist/kernel/unified-memory-schemas.d.ts +1 -0
- package/v3/dist/kernel/unified-memory-schemas.d.ts.map +1 -1
- package/v3/dist/kernel/unified-memory-schemas.js +16 -0
- package/v3/dist/kernel/unified-memory-schemas.js.map +1 -1
- package/v3/dist/learning/dream/dream-engine.d.ts +16 -0
- package/v3/dist/learning/dream/dream-engine.d.ts.map +1 -1
- package/v3/dist/learning/dream/dream-engine.js +70 -0
- package/v3/dist/learning/dream/dream-engine.js.map +1 -1
- package/v3/dist/learning/dream/index.d.ts +2 -0
- package/v3/dist/learning/dream/index.d.ts.map +1 -1
- package/v3/dist/learning/dream/index.js +8 -0
- package/v3/dist/learning/dream/index.js.map +1 -1
- package/v3/dist/learning/dream/rvcow-branch-manager.d.ts +170 -0
- package/v3/dist/learning/dream/rvcow-branch-manager.d.ts.map +1 -0
- package/v3/dist/learning/dream/rvcow-branch-manager.js +263 -0
- package/v3/dist/learning/dream/rvcow-branch-manager.js.map +1 -0
- package/v3/dist/learning/dream/speculative-dreamer.d.ts +129 -0
- package/v3/dist/learning/dream/speculative-dreamer.d.ts.map +1 -0
- package/v3/dist/learning/dream/speculative-dreamer.js +214 -0
- package/v3/dist/learning/dream/speculative-dreamer.js.map +1 -0
- package/v3/dist/learning/qe-reasoning-bank.d.ts +9 -0
- package/v3/dist/learning/qe-reasoning-bank.d.ts.map +1 -1
- package/v3/dist/learning/qe-reasoning-bank.js +50 -1
- package/v3/dist/learning/qe-reasoning-bank.js.map +1 -1
- package/v3/dist/mcp/bundle.js +8900 -7163
- package/v3/dist/mcp/services/mincut-routing-service.d.ts +148 -0
- package/v3/dist/mcp/services/mincut-routing-service.d.ts.map +1 -0
- package/v3/dist/mcp/services/mincut-routing-service.js +198 -0
- package/v3/dist/mcp/services/mincut-routing-service.js.map +1 -0
- package/v3/dist/mcp/services/task-router.d.ts +4 -0
- package/v3/dist/mcp/services/task-router.d.ts.map +1 -1
- package/v3/dist/mcp/services/task-router.js +57 -15
- package/v3/dist/mcp/services/task-router.js.map +1 -1
- package/v3/dist/monitoring/structural-health.d.ts +142 -0
- package/v3/dist/monitoring/structural-health.d.ts.map +1 -0
- package/v3/dist/monitoring/structural-health.js +201 -0
- package/v3/dist/monitoring/structural-health.js.map +1 -0
- package/v3/package.json +1 -1
|
@@ -0,0 +1,358 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* MinCut-Based Test Suite Optimization
|
|
3
|
+
* Task 2.3: RVF Integration Plan
|
|
4
|
+
*
|
|
5
|
+
* Uses mincut analysis to identify the minimum set of tests that provide
|
|
6
|
+
* maximum coverage assurance. Models the test suite as a bipartite graph
|
|
7
|
+
* (tests and source files as vertices, coverage as edges) and computes
|
|
8
|
+
* the minimum cut to find the critical test boundary.
|
|
9
|
+
*
|
|
10
|
+
* Algorithm:
|
|
11
|
+
* 1. Build bipartite graph: test nodes <-> source file nodes
|
|
12
|
+
* 2. Edge capacity = 1 / (number of tests covering that file) — rarer coverage is more valuable
|
|
13
|
+
* 3. Compute mincut via MinCutCalculator (weighted-degree heuristic)
|
|
14
|
+
* 4. Tests on the source side of the cut are critical
|
|
15
|
+
* 5. Remaining tests are skippable (their coverage is redundant)
|
|
16
|
+
* 6. Execution order: critical tests first, sorted by coverage breadth
|
|
17
|
+
*
|
|
18
|
+
* @module domains/test-execution/services/mincut-test-optimizer
|
|
19
|
+
*/
|
|
20
|
+
import { MinCutCalculator } from '../../../coordination/mincut/mincut-calculator.js';
|
|
21
|
+
import { SwarmGraph } from '../../../coordination/mincut/swarm-graph.js';
|
|
22
|
+
// ============================================================================
|
|
23
|
+
// Implementation
|
|
24
|
+
// ============================================================================
|
|
25
|
+
/**
|
|
26
|
+
* Default implementation of MinCutTestOptimizer.
|
|
27
|
+
*
|
|
28
|
+
* Builds a bipartite graph from test nodes and their covered source files,
|
|
29
|
+
* then uses mincut analysis to partition tests into critical vs skippable.
|
|
30
|
+
*/
|
|
31
|
+
export class MinCutTestOptimizerImpl {
|
|
32
|
+
calculator;
|
|
33
|
+
constructor(calculator) {
|
|
34
|
+
this.calculator = calculator ?? new MinCutCalculator();
|
|
35
|
+
}
|
|
36
|
+
/**
|
|
37
|
+
* Optimize a test suite using mincut analysis.
|
|
38
|
+
*
|
|
39
|
+
* @param tests - The test nodes to analyze
|
|
40
|
+
* @param coverageThreshold - Minimum fraction of files that must remain covered (0-1, default 1.0)
|
|
41
|
+
* @returns Optimization result with critical/skippable partitioning
|
|
42
|
+
*/
|
|
43
|
+
optimize(tests, coverageThreshold = 1.0) {
|
|
44
|
+
// Edge case: empty test suite
|
|
45
|
+
if (tests.length === 0) {
|
|
46
|
+
return this.emptyResult();
|
|
47
|
+
}
|
|
48
|
+
// Edge case: single test is always critical
|
|
49
|
+
if (tests.length === 1) {
|
|
50
|
+
return this.singleTestResult(tests[0]);
|
|
51
|
+
}
|
|
52
|
+
// Build the bipartite coverage graph
|
|
53
|
+
const { graph, testIds, fileIds, edgeCount } = this.buildCoverageGraph(tests);
|
|
54
|
+
// Compute mincut
|
|
55
|
+
const mincutResult = this.calculator.approxMinCut(graph);
|
|
56
|
+
const stats = graph.getStats();
|
|
57
|
+
// Classify tests based on mincut partitioning
|
|
58
|
+
const sourceSideSet = new Set(mincutResult.sourceSide);
|
|
59
|
+
// Identify which tests are on the source side (critical boundary)
|
|
60
|
+
// and which are on the target side (potentially skippable)
|
|
61
|
+
const criticalFromCut = new Set();
|
|
62
|
+
const skippableFromCut = new Set();
|
|
63
|
+
for (const testId of testIds) {
|
|
64
|
+
if (sourceSideSet.has(testId)) {
|
|
65
|
+
criticalFromCut.add(testId);
|
|
66
|
+
}
|
|
67
|
+
else {
|
|
68
|
+
skippableFromCut.add(testId);
|
|
69
|
+
}
|
|
70
|
+
}
|
|
71
|
+
// Build file-to-tests coverage map for redundancy analysis
|
|
72
|
+
const fileCoverage = this.buildFileCoverageMap(tests);
|
|
73
|
+
const allCoveredFiles = new Set(fileCoverage.keys());
|
|
74
|
+
// Ensure tests with unique coverage are always critical
|
|
75
|
+
// A test is uniquely critical if it covers a file no other test covers
|
|
76
|
+
const uniquelyCritical = this.findUniquelyCriticalTests(tests, fileCoverage);
|
|
77
|
+
for (const testId of uniquelyCritical) {
|
|
78
|
+
criticalFromCut.add(testId);
|
|
79
|
+
skippableFromCut.delete(testId);
|
|
80
|
+
}
|
|
81
|
+
// Verify coverage threshold: ensure skipping tests doesn't drop coverage below threshold
|
|
82
|
+
const criticalTests = new Set(criticalFromCut);
|
|
83
|
+
const skippableTests = new Set(skippableFromCut);
|
|
84
|
+
if (coverageThreshold < 1.0) {
|
|
85
|
+
// Allow dropping some coverage
|
|
86
|
+
const requiredFileCount = Math.ceil(allCoveredFiles.size * coverageThreshold);
|
|
87
|
+
const criticalCoveredFiles = this.computeCoveredFiles(tests, criticalTests);
|
|
88
|
+
if (criticalCoveredFiles.size < requiredFileCount) {
|
|
89
|
+
// Promote skippable tests to critical until threshold is met
|
|
90
|
+
this.promoteToCritical(tests, criticalTests, skippableTests, requiredFileCount);
|
|
91
|
+
}
|
|
92
|
+
}
|
|
93
|
+
else {
|
|
94
|
+
// Full coverage required: promote any test whose removal would lose a file
|
|
95
|
+
this.ensureFullCoverage(tests, criticalTests, skippableTests, fileCoverage);
|
|
96
|
+
}
|
|
97
|
+
// Build execution order: critical first (sorted by coverage breadth desc), then skippable
|
|
98
|
+
const executionOrder = this.buildExecutionOrder(tests, criticalTests, skippableTests);
|
|
99
|
+
// Calculate time savings
|
|
100
|
+
const testMap = new Map(tests.map(t => [t.testId, t]));
|
|
101
|
+
const estimatedTimeSavingsMs = Array.from(skippableTests)
|
|
102
|
+
.reduce((sum, id) => sum + (testMap.get(id)?.estimatedDurationMs ?? 0), 0);
|
|
103
|
+
return {
|
|
104
|
+
criticalTests: Array.from(criticalTests),
|
|
105
|
+
skippableTests: Array.from(skippableTests),
|
|
106
|
+
executionOrder,
|
|
107
|
+
estimatedTimeSavingsMs,
|
|
108
|
+
graphStats: {
|
|
109
|
+
testCount: tests.length,
|
|
110
|
+
coverageEdges: edgeCount,
|
|
111
|
+
mincutValue: mincutResult.value,
|
|
112
|
+
connectedComponents: stats.componentCount,
|
|
113
|
+
},
|
|
114
|
+
};
|
|
115
|
+
}
|
|
116
|
+
// ==========================================================================
|
|
117
|
+
// Graph Construction
|
|
118
|
+
// ==========================================================================
|
|
119
|
+
/**
|
|
120
|
+
* Build a bipartite graph from test nodes and their covered files.
|
|
121
|
+
*
|
|
122
|
+
* Test nodes and file nodes are vertices. Edges connect tests to the
|
|
123
|
+
* files they cover, weighted inversely by the number of tests covering
|
|
124
|
+
* that file (rarer coverage = higher weight = more valuable).
|
|
125
|
+
*/
|
|
126
|
+
buildCoverageGraph(tests) {
|
|
127
|
+
const graph = new SwarmGraph();
|
|
128
|
+
const testIds = [];
|
|
129
|
+
const fileIdSet = new Set();
|
|
130
|
+
// Count how many tests cover each file (for weight calculation)
|
|
131
|
+
const fileCoverCount = new Map();
|
|
132
|
+
for (const test of tests) {
|
|
133
|
+
for (const file of test.coveredFiles) {
|
|
134
|
+
fileCoverCount.set(file, (fileCoverCount.get(file) ?? 0) + 1);
|
|
135
|
+
}
|
|
136
|
+
}
|
|
137
|
+
// Add test vertices
|
|
138
|
+
for (const test of tests) {
|
|
139
|
+
const vertex = {
|
|
140
|
+
id: test.testId,
|
|
141
|
+
type: 'agent',
|
|
142
|
+
weight: test.coveredFiles.length,
|
|
143
|
+
createdAt: new Date(),
|
|
144
|
+
metadata: { nodeType: 'test', testFile: test.testFile },
|
|
145
|
+
};
|
|
146
|
+
graph.addVertex(vertex);
|
|
147
|
+
testIds.push(test.testId);
|
|
148
|
+
}
|
|
149
|
+
// Add file vertices
|
|
150
|
+
for (const [file] of fileCoverCount) {
|
|
151
|
+
const fileId = `file:${file}`;
|
|
152
|
+
const vertex = {
|
|
153
|
+
id: fileId,
|
|
154
|
+
type: 'domain',
|
|
155
|
+
weight: 1.0,
|
|
156
|
+
createdAt: new Date(),
|
|
157
|
+
metadata: { nodeType: 'file', filePath: file },
|
|
158
|
+
};
|
|
159
|
+
graph.addVertex(vertex);
|
|
160
|
+
fileIdSet.add(fileId);
|
|
161
|
+
}
|
|
162
|
+
// Add edges from tests to files
|
|
163
|
+
let edgeCount = 0;
|
|
164
|
+
for (const test of tests) {
|
|
165
|
+
for (const file of test.coveredFiles) {
|
|
166
|
+
const fileId = `file:${file}`;
|
|
167
|
+
const coverCount = fileCoverCount.get(file) ?? 1;
|
|
168
|
+
// Weight: rarer coverage is more valuable
|
|
169
|
+
const weight = 1.0 / coverCount;
|
|
170
|
+
const edge = {
|
|
171
|
+
source: test.testId,
|
|
172
|
+
target: fileId,
|
|
173
|
+
weight,
|
|
174
|
+
type: 'coordination',
|
|
175
|
+
bidirectional: true,
|
|
176
|
+
};
|
|
177
|
+
graph.addEdge(edge);
|
|
178
|
+
edgeCount++;
|
|
179
|
+
}
|
|
180
|
+
}
|
|
181
|
+
return {
|
|
182
|
+
graph,
|
|
183
|
+
testIds,
|
|
184
|
+
fileIds: Array.from(fileIdSet),
|
|
185
|
+
edgeCount,
|
|
186
|
+
};
|
|
187
|
+
}
|
|
188
|
+
// ==========================================================================
|
|
189
|
+
// Coverage Analysis
|
|
190
|
+
// ==========================================================================
|
|
191
|
+
/**
|
|
192
|
+
* Build a map from source file -> set of test IDs that cover it.
|
|
193
|
+
*/
|
|
194
|
+
buildFileCoverageMap(tests) {
|
|
195
|
+
const map = new Map();
|
|
196
|
+
for (const test of tests) {
|
|
197
|
+
for (const file of test.coveredFiles) {
|
|
198
|
+
let testSet = map.get(file);
|
|
199
|
+
if (!testSet) {
|
|
200
|
+
testSet = new Set();
|
|
201
|
+
map.set(file, testSet);
|
|
202
|
+
}
|
|
203
|
+
testSet.add(test.testId);
|
|
204
|
+
}
|
|
205
|
+
}
|
|
206
|
+
return map;
|
|
207
|
+
}
|
|
208
|
+
/**
|
|
209
|
+
* Find tests that are the sole provider of coverage for at least one file.
|
|
210
|
+
* These tests are always critical regardless of mincut partitioning.
|
|
211
|
+
*/
|
|
212
|
+
findUniquelyCriticalTests(tests, fileCoverage) {
|
|
213
|
+
const uniquelyCritical = new Set();
|
|
214
|
+
for (const [, testSet] of fileCoverage) {
|
|
215
|
+
if (testSet.size === 1) {
|
|
216
|
+
// Only one test covers this file; it is uniquely critical
|
|
217
|
+
const [testId] = testSet;
|
|
218
|
+
uniquelyCritical.add(testId);
|
|
219
|
+
}
|
|
220
|
+
}
|
|
221
|
+
return uniquelyCritical;
|
|
222
|
+
}
|
|
223
|
+
/**
|
|
224
|
+
* Compute the set of files covered by a given set of test IDs.
|
|
225
|
+
*/
|
|
226
|
+
computeCoveredFiles(tests, testIds) {
|
|
227
|
+
const covered = new Set();
|
|
228
|
+
for (const test of tests) {
|
|
229
|
+
if (testIds.has(test.testId)) {
|
|
230
|
+
for (const file of test.coveredFiles) {
|
|
231
|
+
covered.add(file);
|
|
232
|
+
}
|
|
233
|
+
}
|
|
234
|
+
}
|
|
235
|
+
return covered;
|
|
236
|
+
}
|
|
237
|
+
/**
|
|
238
|
+
* Promote skippable tests to critical until the required file count is met.
|
|
239
|
+
* Greedy: pick the skippable test that adds the most new coverage each step.
|
|
240
|
+
*/
|
|
241
|
+
promoteToCritical(tests, criticalTests, skippableTests, requiredFileCount) {
|
|
242
|
+
const covered = this.computeCoveredFiles(tests, criticalTests);
|
|
243
|
+
const testMap = new Map(tests.map(t => [t.testId, t]));
|
|
244
|
+
const remaining = Array.from(skippableTests);
|
|
245
|
+
while (covered.size < requiredFileCount && remaining.length > 0) {
|
|
246
|
+
// Find the skippable test that adds the most new files
|
|
247
|
+
let bestIdx = -1;
|
|
248
|
+
let bestNewCount = 0;
|
|
249
|
+
for (let i = 0; i < remaining.length; i++) {
|
|
250
|
+
const test = testMap.get(remaining[i]);
|
|
251
|
+
if (!test)
|
|
252
|
+
continue;
|
|
253
|
+
const newCount = test.coveredFiles.filter(f => !covered.has(f)).length;
|
|
254
|
+
if (newCount > bestNewCount) {
|
|
255
|
+
bestNewCount = newCount;
|
|
256
|
+
bestIdx = i;
|
|
257
|
+
}
|
|
258
|
+
}
|
|
259
|
+
if (bestIdx === -1 || bestNewCount === 0)
|
|
260
|
+
break;
|
|
261
|
+
const promotedId = remaining[bestIdx];
|
|
262
|
+
remaining.splice(bestIdx, 1);
|
|
263
|
+
criticalTests.add(promotedId);
|
|
264
|
+
skippableTests.delete(promotedId);
|
|
265
|
+
const promotedTest = testMap.get(promotedId);
|
|
266
|
+
for (const file of promotedTest.coveredFiles) {
|
|
267
|
+
covered.add(file);
|
|
268
|
+
}
|
|
269
|
+
}
|
|
270
|
+
}
|
|
271
|
+
/**
|
|
272
|
+
* Ensure that skipping the skippable tests does not lose any file coverage.
|
|
273
|
+
* Promote tests from skippable to critical as needed.
|
|
274
|
+
*/
|
|
275
|
+
ensureFullCoverage(tests, criticalTests, skippableTests, fileCoverage) {
|
|
276
|
+
// For each file, check that at least one critical test covers it
|
|
277
|
+
const criticalCovered = this.computeCoveredFiles(tests, criticalTests);
|
|
278
|
+
for (const [file, testSet] of fileCoverage) {
|
|
279
|
+
if (!criticalCovered.has(file)) {
|
|
280
|
+
// No critical test covers this file; promote one
|
|
281
|
+
for (const testId of testSet) {
|
|
282
|
+
if (skippableTests.has(testId)) {
|
|
283
|
+
criticalTests.add(testId);
|
|
284
|
+
skippableTests.delete(testId);
|
|
285
|
+
// Update covered files
|
|
286
|
+
const test = tests.find(t => t.testId === testId);
|
|
287
|
+
if (test) {
|
|
288
|
+
for (const f of test.coveredFiles) {
|
|
289
|
+
criticalCovered.add(f);
|
|
290
|
+
}
|
|
291
|
+
}
|
|
292
|
+
break;
|
|
293
|
+
}
|
|
294
|
+
}
|
|
295
|
+
}
|
|
296
|
+
}
|
|
297
|
+
}
|
|
298
|
+
// ==========================================================================
|
|
299
|
+
// Execution Order
|
|
300
|
+
// ==========================================================================
|
|
301
|
+
/**
|
|
302
|
+
* Build optimal execution order:
|
|
303
|
+
* 1. Critical tests first, sorted by coverage breadth (most files first)
|
|
304
|
+
* 2. Skippable tests after, sorted by coverage breadth
|
|
305
|
+
*/
|
|
306
|
+
buildExecutionOrder(tests, criticalTests, skippableTests) {
|
|
307
|
+
const testMap = new Map(tests.map(t => [t.testId, t]));
|
|
308
|
+
const byCoverage = (a, b) => {
|
|
309
|
+
const aCount = testMap.get(a)?.coveredFiles.length ?? 0;
|
|
310
|
+
const bCount = testMap.get(b)?.coveredFiles.length ?? 0;
|
|
311
|
+
return bCount - aCount; // descending
|
|
312
|
+
};
|
|
313
|
+
const critical = Array.from(criticalTests).sort(byCoverage);
|
|
314
|
+
const skippable = Array.from(skippableTests).sort(byCoverage);
|
|
315
|
+
return [...critical, ...skippable];
|
|
316
|
+
}
|
|
317
|
+
// ==========================================================================
|
|
318
|
+
// Edge Case Results
|
|
319
|
+
// ==========================================================================
|
|
320
|
+
emptyResult() {
|
|
321
|
+
return {
|
|
322
|
+
criticalTests: [],
|
|
323
|
+
skippableTests: [],
|
|
324
|
+
executionOrder: [],
|
|
325
|
+
estimatedTimeSavingsMs: 0,
|
|
326
|
+
graphStats: {
|
|
327
|
+
testCount: 0,
|
|
328
|
+
coverageEdges: 0,
|
|
329
|
+
mincutValue: 0,
|
|
330
|
+
connectedComponents: 0,
|
|
331
|
+
},
|
|
332
|
+
};
|
|
333
|
+
}
|
|
334
|
+
singleTestResult(test) {
|
|
335
|
+
return {
|
|
336
|
+
criticalTests: [test.testId],
|
|
337
|
+
skippableTests: [],
|
|
338
|
+
executionOrder: [test.testId],
|
|
339
|
+
estimatedTimeSavingsMs: 0,
|
|
340
|
+
graphStats: {
|
|
341
|
+
testCount: 1,
|
|
342
|
+
coverageEdges: test.coveredFiles.length,
|
|
343
|
+
mincutValue: 0,
|
|
344
|
+
connectedComponents: test.coveredFiles.length > 0 ? 1 : 1,
|
|
345
|
+
},
|
|
346
|
+
};
|
|
347
|
+
}
|
|
348
|
+
}
|
|
349
|
+
// ============================================================================
|
|
350
|
+
// Factory
|
|
351
|
+
// ============================================================================
|
|
352
|
+
/**
|
|
353
|
+
* Create a new MinCutTestOptimizer instance.
|
|
354
|
+
*/
|
|
355
|
+
export function createMinCutTestOptimizer(calculator) {
|
|
356
|
+
return new MinCutTestOptimizerImpl(calculator);
|
|
357
|
+
}
|
|
358
|
+
//# sourceMappingURL=mincut-test-optimizer.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"mincut-test-optimizer.js","sourceRoot":"","sources":["../../../../src/domains/test-execution/services/mincut-test-optimizer.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;GAkBG;AAEH,OAAO,EAAE,gBAAgB,EAAE,MAAM,mDAAmD,CAAC;AACrF,OAAO,EAAE,UAAU,EAAE,MAAM,6CAA6C,CAAC;AA8CzE,+EAA+E;AAC/E,iBAAiB;AACjB,+EAA+E;AAE/E;;;;;GAKG;AACH,MAAM,OAAO,uBAAuB;IACjB,UAAU,C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@
|
|
|
1
|
+
/**
|
|
2
|
+
* QE Brain Export/Import System
|
|
3
|
+
*
|
|
4
|
+
* Exports learning state (patterns, Q-values, dream insights, witness chain)
|
|
5
|
+
* into a portable directory format that can be imported by another AQE instance.
|
|
6
|
+
*
|
|
7
|
+
* Export format (.aqe-brain directory):
|
|
8
|
+
* manifest.json — BrainExportManifest with checksum
|
|
9
|
+
* patterns.jsonl — One QE pattern per line
|
|
10
|
+
* q-values.jsonl — Q-learning state-action values
|
|
11
|
+
* dream-insights.jsonl — Dream cycle discoveries
|
|
12
|
+
* witness-chain.jsonl — Witness chain entries
|
|
13
|
+
*
|
|
14
|
+
* Safety: Export uses a READ-ONLY connection (WAL mode, no write lock).
|
|
15
|
+
* Import validates manifest checksum before merging.
|
|
16
|
+
*/
|
|
17
|
+
import Database from 'better-sqlite3';
|
|
18
|
+
export interface BrainExportManifest {
|
|
19
|
+
readonly version: '1.0';
|
|
20
|
+
readonly exportedAt: string;
|
|
21
|
+
readonly sourceDb: string;
|
|
22
|
+
readonly stats: {
|
|
23
|
+
readonly patternCount: number;
|
|
24
|
+
readonly vectorCount: number;
|
|
25
|
+
readonly qValueCount: number;
|
|
26
|
+
readonly dreamInsightCount: number;
|
|
27
|
+
readonly witnessChainLength: number;
|
|
28
|
+
};
|
|
29
|
+
readonly domains: readonly string[];
|
|
30
|
+
readonly checksum: string;
|
|
31
|
+
}
|
|
32
|
+
export interface BrainExportOptions {
|
|
33
|
+
readonly domains?: readonly string[];
|
|
34
|
+
readonly includeVectors?: boolean;
|
|
35
|
+
readonly includeQValues?: boolean;
|
|
36
|
+
readonly includeDreamInsights?: boolean;
|
|
37
|
+
readonly includeWitnessChain?: boolean;
|
|
38
|
+
readonly outputPath: string;
|
|
39
|
+
}
|
|
40
|
+
export interface BrainImportOptions {
|
|
41
|
+
readonly mergeStrategy: 'latest-wins' | 'highest-confidence' | 'union' | 'skip-conflicts';
|
|
42
|
+
readonly dryRun?: boolean;
|
|
43
|
+
}
|
|
44
|
+
export interface BrainImportResult {
|
|
45
|
+
readonly imported: number;
|
|
46
|
+
readonly skipped: number;
|
|
47
|
+
readonly conflicts: number;
|
|
48
|
+
}
|
|
49
|
+
/**
|
|
50
|
+
* Export the QE brain state from a SQLite database into a portable directory.
|
|
51
|
+
*
|
|
52
|
+
* Uses a read-only connection to avoid acquiring write locks.
|
|
53
|
+
*/
|
|
54
|
+
export declare function exportBrain(db: Database.Database, options: BrainExportOptions, sourceDbLabel?: string): BrainExportManifest;
|
|
55
|
+
/**
|
|
56
|
+
* Import a brain export directory into a target SQLite database.
|
|
57
|
+
*
|
|
58
|
+
* Validates the manifest checksum before proceeding. Applies the chosen
|
|
59
|
+
* merge strategy to resolve conflicts on existing IDs.
|
|
60
|
+
*/
|
|
61
|
+
export declare function importBrain(db: Database.Database, containerPath: string, options: BrainImportOptions): BrainImportResult;
|
|
62
|
+
/**
|
|
63
|
+
* Read and return the manifest from a brain export directory.
|
|
64
|
+
*/
|
|
65
|
+
export declare function brainInfo(containerPath: string): BrainExportManifest;
|
|
66
|
+
//# sourceMappingURL=brain-exporter.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"brain-exporter.d.ts","sourceRoot":"","sources":["../../../src/integrations/ruvector/brain-exporter.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;GAeG;AAKH,OAAO,QAAQ,MAAM,gBAAgB,CAAC;AAMtC,MAAM,WAAW,mBAAmB;IAClC,QAAQ,CAAC,OAAO,EAAE,KAAK,CAAC;IACxB,QAAQ,CAAC,UAAU,EAAE,MAAM,CAAC;IAC5B,QAAQ,CAAC,QAAQ,EAAE,MAAM,CAAC;IAC1B,QAAQ,CAAC,KAAK,EAAE;QACd,QAAQ,CAAC,YAAY,EAAE,MAAM,CAAC;QAC9B,QAAQ,CAAC,WAAW,EAAE,MAAM,CAAC;QAC7B,QAAQ,CAAC,WAAW,EAAE,MAAM,CAAC;QAC7B,QAAQ,CAAC,iBAAiB,EAAE,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