@claude-flow/plugin-test-intelligence 3.0.0-alpha.1
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/README.md +409 -0
- package/dist/bridges/index.d.ts +8 -0
- package/dist/bridges/index.d.ts.map +1 -0
- package/dist/bridges/index.js +8 -0
- package/dist/bridges/index.js.map +1 -0
- package/dist/bridges/learning-bridge.d.ts +65 -0
- package/dist/bridges/learning-bridge.d.ts.map +1 -0
- package/dist/bridges/learning-bridge.js +368 -0
- package/dist/bridges/learning-bridge.js.map +1 -0
- package/dist/bridges/sona-bridge.d.ts +95 -0
- package/dist/bridges/sona-bridge.d.ts.map +1 -0
- package/dist/bridges/sona-bridge.js +432 -0
- package/dist/bridges/sona-bridge.js.map +1 -0
- package/dist/index.d.ts +113 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +88 -0
- package/dist/index.js.map +1 -0
- package/dist/mcp-tools.d.ts +18 -0
- package/dist/mcp-tools.d.ts.map +1 -0
- package/dist/mcp-tools.js +681 -0
- package/dist/mcp-tools.js.map +1 -0
- package/dist/types.d.ts +429 -0
- package/dist/types.d.ts.map +1 -0
- package/dist/types.js +131 -0
- package/dist/types.js.map +1 -0
- package/package.json +82 -0
package/README.md
ADDED
|
@@ -0,0 +1,409 @@
|
|
|
1
|
+
# @claude-flow/plugin-test-intelligence
|
|
2
|
+
|
|
3
|
+
[](https://www.npmjs.com/package/@claude-flow/plugin-test-intelligence)
|
|
4
|
+
[](https://www.npmjs.com/package/@claude-flow/plugin-test-intelligence)
|
|
5
|
+
[](https://opensource.org/licenses/MIT)
|
|
6
|
+
|
|
7
|
+
A comprehensive test intelligence plugin combining reinforcement learning for optimal test selection with graph neural networks for code-to-test mapping. The plugin enables predictive test selection (run only tests likely to fail), flaky test detection, mutation testing optimization, and test coverage gap identification while integrating seamlessly with popular testing frameworks.
|
|
8
|
+
|
|
9
|
+
## Features
|
|
10
|
+
|
|
11
|
+
- **Predictive Test Selection**: Select tests most likely to fail based on code changes using RL
|
|
12
|
+
- **Flaky Test Detection**: Identify and analyze flaky tests with root cause classification
|
|
13
|
+
- **Coverage Gap Analysis**: Identify test coverage gaps using code-test graph analysis
|
|
14
|
+
- **Mutation Testing Optimization**: Optimize mutation testing for efficiency within time budgets
|
|
15
|
+
- **Test Generation Suggestions**: Suggest test cases for uncovered code paths
|
|
16
|
+
|
|
17
|
+
## Installation
|
|
18
|
+
|
|
19
|
+
### npm
|
|
20
|
+
|
|
21
|
+
```bash
|
|
22
|
+
npm install @claude-flow/plugin-test-intelligence
|
|
23
|
+
```
|
|
24
|
+
|
|
25
|
+
### CLI
|
|
26
|
+
|
|
27
|
+
```bash
|
|
28
|
+
npx claude-flow plugins install --name @claude-flow/plugin-test-intelligence
|
|
29
|
+
```
|
|
30
|
+
|
|
31
|
+
## Quick Start
|
|
32
|
+
|
|
33
|
+
```typescript
|
|
34
|
+
import { TestIntelligencePlugin } from '@claude-flow/plugin-test-intelligence';
|
|
35
|
+
|
|
36
|
+
// Initialize the plugin
|
|
37
|
+
const testIntel = new TestIntelligencePlugin({
|
|
38
|
+
historyPath: './data/test-history',
|
|
39
|
+
framework: 'vitest',
|
|
40
|
+
projectPath: './'
|
|
41
|
+
});
|
|
42
|
+
|
|
43
|
+
// Predictive test selection
|
|
44
|
+
const selectedTests = await testIntel.selectPredictive({
|
|
45
|
+
changes: {
|
|
46
|
+
files: ['src/auth/login.ts', 'src/utils/validation.ts'],
|
|
47
|
+
gitRef: 'HEAD'
|
|
48
|
+
},
|
|
49
|
+
strategy: 'balanced',
|
|
50
|
+
budget: { maxTests: 50, confidence: 0.95 }
|
|
51
|
+
});
|
|
52
|
+
|
|
53
|
+
// Detect flaky tests
|
|
54
|
+
const flakyTests = await testIntel.flakyDetect({
|
|
55
|
+
scope: { historyDepth: 100 },
|
|
56
|
+
analysis: ['intermittent_failures', 'timing_sensitive'],
|
|
57
|
+
threshold: 0.1
|
|
58
|
+
});
|
|
59
|
+
|
|
60
|
+
// Identify coverage gaps
|
|
61
|
+
const gaps = await testIntel.coverageGaps({
|
|
62
|
+
targetPaths: ['src/'],
|
|
63
|
+
coverageType: 'semantic',
|
|
64
|
+
prioritization: 'risk'
|
|
65
|
+
});
|
|
66
|
+
```
|
|
67
|
+
|
|
68
|
+
## MCP Tools
|
|
69
|
+
|
|
70
|
+
### 1. `test/select-predictive`
|
|
71
|
+
|
|
72
|
+
Select tests most likely to fail based on code changes.
|
|
73
|
+
|
|
74
|
+
```typescript
|
|
75
|
+
const result = await mcp.invoke('test/select-predictive', {
|
|
76
|
+
changes: {
|
|
77
|
+
files: ['src/services/UserService.ts', 'src/models/User.ts'],
|
|
78
|
+
gitDiff: '...diff content...',
|
|
79
|
+
gitRef: 'feature-branch'
|
|
80
|
+
},
|
|
81
|
+
strategy: 'fast_feedback',
|
|
82
|
+
budget: {
|
|
83
|
+
maxTests: 30,
|
|
84
|
+
maxDuration: 300, // 5 minutes
|
|
85
|
+
confidence: 0.95
|
|
86
|
+
}
|
|
87
|
+
});
|
|
88
|
+
|
|
89
|
+
// Returns:
|
|
90
|
+
// {
|
|
91
|
+
// selectedTests: [
|
|
92
|
+
// { name: 'UserService.createUser', file: 'tests/UserService.test.ts', priority: 1, failureProbability: 0.82 },
|
|
93
|
+
// { name: 'User.validate', file: 'tests/User.test.ts', priority: 2, failureProbability: 0.75 },
|
|
94
|
+
// ...
|
|
95
|
+
// ],
|
|
96
|
+
// estimatedDuration: 45,
|
|
97
|
+
// coverageEstimate: 0.89,
|
|
98
|
+
// skippedTests: 120,
|
|
99
|
+
// timeSaved: '4m 30s'
|
|
100
|
+
// }
|
|
101
|
+
```
|
|
102
|
+
|
|
103
|
+
### 2. `test/flaky-detect`
|
|
104
|
+
|
|
105
|
+
Identify and analyze flaky tests.
|
|
106
|
+
|
|
107
|
+
```typescript
|
|
108
|
+
const result = await mcp.invoke('test/flaky-detect', {
|
|
109
|
+
scope: {
|
|
110
|
+
testSuite: 'integration',
|
|
111
|
+
historyDepth: 200
|
|
112
|
+
},
|
|
113
|
+
analysis: [
|
|
114
|
+
'intermittent_failures',
|
|
115
|
+
'timing_sensitive',
|
|
116
|
+
'order_dependent',
|
|
117
|
+
'resource_contention'
|
|
118
|
+
],
|
|
119
|
+
threshold: 0.1
|
|
120
|
+
});
|
|
121
|
+
|
|
122
|
+
// Returns:
|
|
123
|
+
// {
|
|
124
|
+
// flakyTests: [
|
|
125
|
+
// {
|
|
126
|
+
// name: 'API.rateLimit.test',
|
|
127
|
+
// flakinessScore: 0.23,
|
|
128
|
+
// failureRate: 0.15,
|
|
129
|
+
// rootCause: 'timing_sensitive',
|
|
130
|
+
// details: 'Relies on 100ms timeout that occasionally exceeds',
|
|
131
|
+
// recommendation: 'Use fake timers or increase timeout margin',
|
|
132
|
+
// lastFailed: '2024-01-14T10:30:00Z'
|
|
133
|
+
// },
|
|
134
|
+
// {
|
|
135
|
+
// name: 'Database.concurrent.test',
|
|
136
|
+
// flakinessScore: 0.18,
|
|
137
|
+
// failureRate: 0.08,
|
|
138
|
+
// rootCause: 'resource_contention',
|
|
139
|
+
// details: 'Competes for database connections with other tests',
|
|
140
|
+
// recommendation: 'Isolate test database or use connection pooling'
|
|
141
|
+
// }
|
|
142
|
+
// ],
|
|
143
|
+
// summary: {
|
|
144
|
+
// totalFlakyTests: 8,
|
|
145
|
+
// quarantineSuggested: 3,
|
|
146
|
+
// estimatedCITimeSaved: '12 minutes per run'
|
|
147
|
+
// }
|
|
148
|
+
// }
|
|
149
|
+
```
|
|
150
|
+
|
|
151
|
+
### 3. `test/coverage-gaps`
|
|
152
|
+
|
|
153
|
+
Identify test coverage gaps.
|
|
154
|
+
|
|
155
|
+
```typescript
|
|
156
|
+
const result = await mcp.invoke('test/coverage-gaps', {
|
|
157
|
+
targetPaths: ['src/services/', 'src/controllers/'],
|
|
158
|
+
coverageType: 'semantic',
|
|
159
|
+
prioritization: 'risk',
|
|
160
|
+
minCoverage: 80
|
|
161
|
+
});
|
|
162
|
+
|
|
163
|
+
// Returns:
|
|
164
|
+
// {
|
|
165
|
+
// gaps: [
|
|
166
|
+
// {
|
|
167
|
+
// file: 'src/services/PaymentService.ts',
|
|
168
|
+
// function: 'processRefund',
|
|
169
|
+
// currentCoverage: 45,
|
|
170
|
+
// riskScore: 0.85,
|
|
171
|
+
// complexity: 'high',
|
|
172
|
+
// recommendation: 'Add tests for error handling paths',
|
|
173
|
+
// suggestedTestCases: [
|
|
174
|
+
// 'should handle partial refund',
|
|
175
|
+
// 'should reject refund exceeding original amount',
|
|
176
|
+
// 'should handle payment provider timeout'
|
|
177
|
+
// ]
|
|
178
|
+
// },
|
|
179
|
+
// ...
|
|
180
|
+
// ],
|
|
181
|
+
// summary: {
|
|
182
|
+
// averageCoverage: 72,
|
|
183
|
+
// highRiskUncovered: 5,
|
|
184
|
+
// estimatedTestsNeeded: 15
|
|
185
|
+
// }
|
|
186
|
+
// }
|
|
187
|
+
```
|
|
188
|
+
|
|
189
|
+
### 4. `test/mutation-optimize`
|
|
190
|
+
|
|
191
|
+
Optimize mutation testing for efficiency.
|
|
192
|
+
|
|
193
|
+
```typescript
|
|
194
|
+
const result = await mcp.invoke('test/mutation-optimize', {
|
|
195
|
+
targetPath: 'src/utils/validation.ts',
|
|
196
|
+
budget: 100, // Max mutations to run
|
|
197
|
+
strategy: 'ml_guided',
|
|
198
|
+
mutationTypes: ['arithmetic', 'logical', 'boundary', 'null_check']
|
|
199
|
+
});
|
|
200
|
+
|
|
201
|
+
// Returns:
|
|
202
|
+
// {
|
|
203
|
+
// selectedMutations: [
|
|
204
|
+
// {
|
|
205
|
+
// location: { line: 45, column: 12 },
|
|
206
|
+
// type: 'boundary',
|
|
207
|
+
// original: 'age >= 18',
|
|
208
|
+
// mutated: 'age > 18',
|
|
209
|
+
// killedBy: ['validateAge.boundary.test'],
|
|
210
|
+
// priority: 1
|
|
211
|
+
// },
|
|
212
|
+
// ...
|
|
213
|
+
// ],
|
|
214
|
+
// mutationScore: 0.82,
|
|
215
|
+
// survivingMutants: 18,
|
|
216
|
+
// testGaps: [
|
|
217
|
+
// { mutation: 'null_check at line 67', reason: 'No test covers null input' }
|
|
218
|
+
// ],
|
|
219
|
+
// timeSpent: '45s',
|
|
220
|
+
// timeVsFullRun: '12x faster'
|
|
221
|
+
// }
|
|
222
|
+
```
|
|
223
|
+
|
|
224
|
+
### 5. `test/generate-suggest`
|
|
225
|
+
|
|
226
|
+
Suggest test cases for uncovered code.
|
|
227
|
+
|
|
228
|
+
```typescript
|
|
229
|
+
const result = await mcp.invoke('test/generate-suggest', {
|
|
230
|
+
targetFunction: 'src/auth/validateToken.ts:validateJWT',
|
|
231
|
+
testStyle: 'unit',
|
|
232
|
+
framework: 'vitest',
|
|
233
|
+
edgeCases: true,
|
|
234
|
+
mockStrategy: 'minimal'
|
|
235
|
+
});
|
|
236
|
+
|
|
237
|
+
// Returns:
|
|
238
|
+
// {
|
|
239
|
+
// suggestedTests: [
|
|
240
|
+
// {
|
|
241
|
+
// name: 'should validate a valid JWT token',
|
|
242
|
+
// type: 'happy_path',
|
|
243
|
+
// code: `
|
|
244
|
+
// test('should validate a valid JWT token', () => {
|
|
245
|
+
// const token = createTestToken({ userId: '123', exp: Date.now() + 3600000 });
|
|
246
|
+
// const result = validateJWT(token);
|
|
247
|
+
// expect(result.valid).toBe(true);
|
|
248
|
+
// expect(result.payload.userId).toBe('123');
|
|
249
|
+
// });`
|
|
250
|
+
// },
|
|
251
|
+
// {
|
|
252
|
+
// name: 'should reject expired token',
|
|
253
|
+
// type: 'edge_case',
|
|
254
|
+
// code: `
|
|
255
|
+
// test('should reject expired token', () => {
|
|
256
|
+
// const token = createTestToken({ userId: '123', exp: Date.now() - 1000 });
|
|
257
|
+
// const result = validateJWT(token);
|
|
258
|
+
// expect(result.valid).toBe(false);
|
|
259
|
+
// expect(result.error).toBe('TOKEN_EXPIRED');
|
|
260
|
+
// });`
|
|
261
|
+
// },
|
|
262
|
+
// ...
|
|
263
|
+
// ],
|
|
264
|
+
// requiredMocks: ['jsonwebtoken.verify'],
|
|
265
|
+
// setupCode: '...'
|
|
266
|
+
// }
|
|
267
|
+
```
|
|
268
|
+
|
|
269
|
+
## Configuration Options
|
|
270
|
+
|
|
271
|
+
```typescript
|
|
272
|
+
interface TestIntelligenceConfig {
|
|
273
|
+
// Data paths
|
|
274
|
+
historyPath: string; // Path to test history storage
|
|
275
|
+
projectPath: string; // Project root path
|
|
276
|
+
|
|
277
|
+
// Framework
|
|
278
|
+
framework: 'jest' | 'vitest' | 'pytest' | 'junit' | 'mocha';
|
|
279
|
+
testPattern: string; // Glob pattern for test files
|
|
280
|
+
|
|
281
|
+
// Performance
|
|
282
|
+
maxMemoryMB: number; // WASM memory limit (default: 512)
|
|
283
|
+
maxCpuTimeSeconds: number; // Operation timeout (default: 60)
|
|
284
|
+
|
|
285
|
+
// Learning
|
|
286
|
+
learningEnabled: boolean; // Enable continuous learning (default: true)
|
|
287
|
+
minHistoryDepth: number; // Minimum runs before predictions (default: 50)
|
|
288
|
+
}
|
|
289
|
+
```
|
|
290
|
+
|
|
291
|
+
## Framework Support
|
|
292
|
+
|
|
293
|
+
| Framework | Language | Support Level |
|
|
294
|
+
|-----------|----------|---------------|
|
|
295
|
+
| Jest | JavaScript/TypeScript | Full |
|
|
296
|
+
| Vitest | JavaScript/TypeScript | Full |
|
|
297
|
+
| pytest | Python | Full |
|
|
298
|
+
| JUnit | Java | Partial |
|
|
299
|
+
| Mocha | JavaScript | Partial |
|
|
300
|
+
| RSpec | Ruby | Basic |
|
|
301
|
+
|
|
302
|
+
## Security Considerations
|
|
303
|
+
|
|
304
|
+
### Test Execution Safety
|
|
305
|
+
|
|
306
|
+
This plugin analyzes tests but does NOT execute them directly:
|
|
307
|
+
- Returns test selection lists only
|
|
308
|
+
- User runs tests via their own CI/CD pipeline
|
|
309
|
+
- No arbitrary code execution in WASM
|
|
310
|
+
|
|
311
|
+
### WASM Security Constraints
|
|
312
|
+
|
|
313
|
+
| Constraint | Value | Rationale |
|
|
314
|
+
|------------|-------|-----------|
|
|
315
|
+
| Memory Limit | 512MB max | Sufficient for test analysis |
|
|
316
|
+
| CPU Time Limit | 60 seconds | Prevent runaway analysis |
|
|
317
|
+
| No Test Execution | Analysis only | Prevent arbitrary code execution |
|
|
318
|
+
| No Network Access | Enforced | Prevent data exfiltration |
|
|
319
|
+
| Sandboxed History | Per-project | Prevent cross-project leakage |
|
|
320
|
+
|
|
321
|
+
### Input Validation
|
|
322
|
+
|
|
323
|
+
All inputs are validated using Zod schemas:
|
|
324
|
+
```typescript
|
|
325
|
+
// All inputs validated:
|
|
326
|
+
- Git diffs: Maximum 1MB
|
|
327
|
+
- File lists: Maximum 1000 files
|
|
328
|
+
- History depth: 10-10000 runs
|
|
329
|
+
- Max duration: 1-86400 seconds (24 hours)
|
|
330
|
+
- Confidence level: 0.5-1.0
|
|
331
|
+
- Test names: Alphanumeric with standard punctuation, max 500 characters
|
|
332
|
+
- Framework: Enum validated against supported frameworks
|
|
333
|
+
```
|
|
334
|
+
|
|
335
|
+
### Rate Limiting
|
|
336
|
+
|
|
337
|
+
```typescript
|
|
338
|
+
const rateLimits = {
|
|
339
|
+
'test/select-predictive': { requestsPerMinute: 60, maxConcurrent: 5 },
|
|
340
|
+
'test/flaky-detect': { requestsPerMinute: 10, maxConcurrent: 2 },
|
|
341
|
+
'test/coverage-gaps': { requestsPerMinute: 30, maxConcurrent: 3 },
|
|
342
|
+
'test/mutation-optimize': { requestsPerMinute: 5, maxConcurrent: 1 },
|
|
343
|
+
'test/generate-suggest': { requestsPerMinute: 30, maxConcurrent: 3 }
|
|
344
|
+
};
|
|
345
|
+
```
|
|
346
|
+
|
|
347
|
+
## Performance
|
|
348
|
+
|
|
349
|
+
| Metric | Target |
|
|
350
|
+
|--------|--------|
|
|
351
|
+
| Test selection | <1s for 10K tests |
|
|
352
|
+
| Flaky detection | <5s for 1000 test runs |
|
|
353
|
+
| Coverage gap analysis | <10s for 100K LOC |
|
|
354
|
+
| Mutation optimization | 80% mutation score in 20% time |
|
|
355
|
+
| CI time reduction | 60-80% |
|
|
356
|
+
|
|
357
|
+
## Learning Pipeline
|
|
358
|
+
|
|
359
|
+
The plugin continuously learns from test execution history:
|
|
360
|
+
|
|
361
|
+
```
|
|
362
|
+
Execution History --> SONA Learning --> RL Policy
|
|
363
|
+
| | |
|
|
364
|
+
v v v
|
|
365
|
+
[fail rates] [pattern bank] [selection model]
|
|
366
|
+
[timings] [failure modes] [prioritization]
|
|
367
|
+
[coverage] [correlations] [budget allocation]
|
|
368
|
+
```
|
|
369
|
+
|
|
370
|
+
## Dependencies
|
|
371
|
+
|
|
372
|
+
- `micro-hnsw-wasm`: Fast code-to-test similarity matching
|
|
373
|
+
- `ruvector-learning-wasm`: RL-based test selection and prioritization
|
|
374
|
+
- `ruvector-gnn-wasm`: Code-test dependency graphs for impact analysis
|
|
375
|
+
- `ruvector-sparse-inference-wasm`: Efficient flaky test pattern detection
|
|
376
|
+
- `sona`: Continuous learning from test execution history
|
|
377
|
+
- `istanbul-lib-coverage`: Coverage report parsing
|
|
378
|
+
|
|
379
|
+
## Related Plugins
|
|
380
|
+
|
|
381
|
+
| Plugin | Description | Use Case |
|
|
382
|
+
|--------|-------------|----------|
|
|
383
|
+
| [@claude-flow/plugin-code-intelligence](../code-intelligence) | Code analysis | Impact analysis for test prioritization |
|
|
384
|
+
| [@claude-flow/plugin-perf-optimizer](../perf-optimizer) | Performance optimization | Test performance profiling |
|
|
385
|
+
| [@claude-flow/plugin-financial-risk](../financial-risk) | Risk analysis | Test risk scoring for critical paths |
|
|
386
|
+
|
|
387
|
+
## License
|
|
388
|
+
|
|
389
|
+
MIT License
|
|
390
|
+
|
|
391
|
+
Copyright (c) 2026 Claude Flow
|
|
392
|
+
|
|
393
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
394
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
395
|
+
in the Software without restriction, including without limitation the rights
|
|
396
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
397
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
398
|
+
furnished to do so, subject to the following conditions:
|
|
399
|
+
|
|
400
|
+
The above copyright notice and this permission notice shall be included in all
|
|
401
|
+
copies or substantial portions of the Software.
|
|
402
|
+
|
|
403
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
404
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
405
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
406
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
407
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
408
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
409
|
+
SOFTWARE.
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Test Intelligence Plugin - Bridges Barrel Export
|
|
3
|
+
*
|
|
4
|
+
* @module @claude-flow/plugin-test-intelligence/bridges
|
|
5
|
+
*/
|
|
6
|
+
export { TestLearningBridge, createTestLearningBridge, } from './learning-bridge.js';
|
|
7
|
+
export { TestSonaBridge, createTestSonaBridge, } from './sona-bridge.js';
|
|
8
|
+
//# sourceMappingURL=index.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/bridges/index.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAEH,OAAO,EACL,kBAAkB,EAClB,wBAAwB,GACzB,MAAM,sBAAsB,CAAC;AAE9B,OAAO,EACL,cAAc,EACd,oBAAoB,GACrB,MAAM,kBAAkB,CAAC"}
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Test Intelligence Plugin - Bridges Barrel Export
|
|
3
|
+
*
|
|
4
|
+
* @module @claude-flow/plugin-test-intelligence/bridges
|
|
5
|
+
*/
|
|
6
|
+
export { TestLearningBridge, createTestLearningBridge, } from './learning-bridge.js';
|
|
7
|
+
export { TestSonaBridge, createTestSonaBridge, } from './sona-bridge.js';
|
|
8
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/bridges/index.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAEH,OAAO,EACL,kBAAkB,EAClB,wBAAwB,GACzB,MAAM,sBAAsB,CAAC;AAE9B,OAAO,EACL,cAAc,EACd,oBAAoB,GACrB,MAAM,kBAAkB,CAAC"}
|
|
@@ -0,0 +1,65 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Learning Bridge for Test Intelligence
|
|
3
|
+
*
|
|
4
|
+
* Provides RL-based test selection and prioritization using
|
|
5
|
+
* ruvector-learning-wasm for Q-Learning, PPO, and Decision Transformer.
|
|
6
|
+
*/
|
|
7
|
+
import type { LearningBridgeInterface, LearningConfig, TestHistoryEntry, CodeChange, PredictedTest, TestFeedback } from '../types.js';
|
|
8
|
+
/**
|
|
9
|
+
* Learning Bridge Implementation for Test Intelligence
|
|
10
|
+
*
|
|
11
|
+
* Uses reinforcement learning to optimize test selection based on:
|
|
12
|
+
* - Historical test execution patterns
|
|
13
|
+
* - Code change characteristics
|
|
14
|
+
* - Test failure correlations
|
|
15
|
+
*/
|
|
16
|
+
export declare class TestLearningBridge implements LearningBridgeInterface {
|
|
17
|
+
readonly name = "test-intelligence-learning";
|
|
18
|
+
readonly version = "0.1.0";
|
|
19
|
+
private status;
|
|
20
|
+
private config;
|
|
21
|
+
private replayBuffer;
|
|
22
|
+
private policyWeights;
|
|
23
|
+
private testEmbeddings;
|
|
24
|
+
private fileTestMapping;
|
|
25
|
+
constructor(config?: Partial<LearningConfig>);
|
|
26
|
+
init(): Promise<void>;
|
|
27
|
+
destroy(): Promise<void>;
|
|
28
|
+
isReady(): boolean;
|
|
29
|
+
/**
|
|
30
|
+
* Train on test execution history
|
|
31
|
+
*
|
|
32
|
+
* Uses temporal difference learning to update the test selection policy
|
|
33
|
+
* based on historical outcomes.
|
|
34
|
+
*/
|
|
35
|
+
trainOnHistory(history: TestHistoryEntry[], config?: LearningConfig): Promise<number>;
|
|
36
|
+
/**
|
|
37
|
+
* Predict which tests are likely to fail given code changes
|
|
38
|
+
*
|
|
39
|
+
* Uses the learned policy to rank tests by failure probability.
|
|
40
|
+
*/
|
|
41
|
+
predictFailingTests(changes: CodeChange[], topK: number): Promise<PredictedTest[]>;
|
|
42
|
+
/**
|
|
43
|
+
* Update policy with feedback from actual test results
|
|
44
|
+
*/
|
|
45
|
+
updatePolicyWithFeedback(feedback: TestFeedback): Promise<void>;
|
|
46
|
+
private initializeMockWeights;
|
|
47
|
+
private computeTestEmbedding;
|
|
48
|
+
private computeChangeEmbedding;
|
|
49
|
+
private combineEmbeddings;
|
|
50
|
+
private computeQValues;
|
|
51
|
+
private createExperiencesFromHistory;
|
|
52
|
+
private computeTDError;
|
|
53
|
+
private updatePolicyWeights;
|
|
54
|
+
private batchUpdate;
|
|
55
|
+
private computeReward;
|
|
56
|
+
private computeHistoricalReward;
|
|
57
|
+
private generateReason;
|
|
58
|
+
private sigmoid;
|
|
59
|
+
private hashString;
|
|
60
|
+
}
|
|
61
|
+
/**
|
|
62
|
+
* Create a new learning bridge instance
|
|
63
|
+
*/
|
|
64
|
+
export declare function createTestLearningBridge(config?: Partial<LearningConfig>): TestLearningBridge;
|
|
65
|
+
//# sourceMappingURL=learning-bridge.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"learning-bridge.d.ts","sourceRoot":"","sources":["../../src/bridges/learning-bridge.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAEH,OAAO,KAAK,EACV,uBAAuB,EACvB,cAAc,EACd,gBAAgB,EAChB,UAAU,EACV,aAAa,EACb,YAAY,EACb,MAAM,aAAa,CAAC;AA4BrB;;;;;;;GAOG;AACH,qBAAa,kBAAmB,YAAW,uBAAuB;IAChE,QAAQ,CAAC,IAAI,gCAAgC;IAC7C,QAAQ,CAAC,OAAO,WAAW;IAE3B,OAAO,CAAC,MAAM,CAAgC;IAC9C,OAAO,CAAC,MAAM,CAAiB;IAC/B,OAAO,CAAC,YAAY,CAAoB;IACxC,OAAO,CAAC,aAAa,CAAe;IACpC,OAAO,CAAC,cAAc,CAAwC;IAC9D,OAAO,CAAC,eAAe,CAAuC;gBAElD,MAAM,CAAC,EAAE,OAAO,CAAC,cAAc,CAAC;IAKtC,IAAI,IAAI,OAAO,CAAC,IAAI,CAAC;IA0BrB,OAAO,IAAI,OAAO,CAAC,IAAI,CAAC;IAO9B,OAAO,IAAI,OAAO;IAIlB;;;;;OAKG;IACG,cAAc,CAClB,OAAO,EAAE,gBAAgB,EAAE,EAC3B,MAAM,CAAC,EAAE,cAAc,GACtB,OAAO,CAAC,MAAM,CAAC;IAiClB;;;;OAIG;IACG,mBAAmB,CACvB,OAAO,EAAE,UAAU,EAAE,EACrB,IAAI,EAAE,MAAM,GACX,OAAO,CAAC,aAAa,EAAE,CAAC;IA0C3B;;OAEG;IACG,wBAAwB,CAAC,QAAQ,EAAE,YAAY,GAAG,OAAO,CAAC,IAAI,CAAC;IA0CrE,OAAO,CAAC,qBAAqB;IAQ7B,OAAO,CAAC,oBAAoB;IAyB5B,OAAO,CAAC,sBAAsB;IA4C9B,OAAO,CAAC,iBAAiB;IAOzB,OAAO,CAAC,cAAc;IAetB,OAAO,CAAC,4BAA4B;IAoCpC,OAAO,CAAC,cAAc;IAMtB,OAAO,CAAC,mBAAmB;YAOb,WAAW;IAiBzB,OAAO,CAAC,aAAa;IAUrB,OAAO,CAAC,uBAAuB;IAU/B,OAAO,CAAC,cAAc;IAUtB,OAAO,CAAC,OAAO;IAIf,OAAO,CAAC,UAAU;CASnB;AAED;;GAEG;AACH,wBAAgB,wBAAwB,CAAC,MAAM,CAAC,EAAE,OAAO,CAAC,cAAc,CAAC,GAAG,kBAAkB,CAE7F"}
|