agentic-qe 1.5.1 → 1.6.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/.claude/agents/qe-api-contract-validator.md +118 -0
- package/.claude/agents/qe-chaos-engineer.md +320 -5
- package/.claude/agents/qe-code-complexity.md +360 -0
- package/.claude/agents/qe-coverage-analyzer.md +112 -0
- package/.claude/agents/qe-deployment-readiness.md +322 -6
- package/.claude/agents/qe-flaky-test-hunter.md +115 -0
- package/.claude/agents/qe-fleet-commander.md +319 -6
- package/.claude/agents/qe-performance-tester.md +234 -0
- package/.claude/agents/qe-production-intelligence.md +114 -0
- package/.claude/agents/qe-quality-analyzer.md +126 -0
- package/.claude/agents/qe-quality-gate.md +119 -0
- package/.claude/agents/qe-regression-risk-analyzer.md +114 -0
- package/.claude/agents/qe-requirements-validator.md +114 -0
- package/.claude/agents/qe-security-scanner.md +118 -0
- package/.claude/agents/qe-test-data-architect.md +234 -0
- package/.claude/agents/qe-test-executor.md +115 -0
- package/.claude/agents/qe-test-generator.md +114 -0
- package/.claude/agents/qe-visual-tester.md +305 -6
- package/.claude/agents/subagents/qe-code-reviewer.md +0 -4
- package/.claude/agents/subagents/qe-data-generator.md +0 -16
- package/.claude/agents/subagents/qe-integration-tester.md +0 -17
- package/.claude/agents/subagents/qe-performance-validator.md +0 -16
- package/.claude/agents/subagents/qe-security-auditor.md +0 -16
- package/.claude/agents/subagents/qe-test-implementer.md +0 -17
- package/.claude/agents/subagents/qe-test-refactorer.md +0 -17
- package/.claude/agents/subagents/qe-test-writer.md +0 -19
- package/.claude/skills/brutal-honesty-review/README.md +218 -0
- package/.claude/skills/brutal-honesty-review/SKILL.md +725 -0
- package/.claude/skills/brutal-honesty-review/resources/assessment-rubrics.md +295 -0
- package/.claude/skills/brutal-honesty-review/resources/review-template.md +102 -0
- package/.claude/skills/brutal-honesty-review/scripts/assess-code.sh +179 -0
- package/.claude/skills/brutal-honesty-review/scripts/assess-tests.sh +223 -0
- package/.claude/skills/cicd-pipeline-qe-orchestrator/README.md +301 -0
- package/.claude/skills/cicd-pipeline-qe-orchestrator/SKILL.md +510 -0
- package/.claude/skills/cicd-pipeline-qe-orchestrator/resources/workflows/microservice-pipeline.md +239 -0
- package/.claude/skills/cicd-pipeline-qe-orchestrator/resources/workflows/mobile-pipeline.md +375 -0
- package/.claude/skills/cicd-pipeline-qe-orchestrator/resources/workflows/monolith-pipeline.md +268 -0
- package/.claude/skills/six-thinking-hats/README.md +190 -0
- package/.claude/skills/six-thinking-hats/SKILL.md +1215 -0
- package/.claude/skills/six-thinking-hats/resources/examples/api-testing-example.md +345 -0
- package/.claude/skills/six-thinking-hats/resources/templates/solo-session-template.md +167 -0
- package/.claude/skills/six-thinking-hats/resources/templates/team-session-template.md +336 -0
- package/CHANGELOG.md +2472 -2129
- package/README.md +48 -10
- package/dist/adapters/MemoryStoreAdapter.d.ts +38 -0
- package/dist/adapters/MemoryStoreAdapter.d.ts.map +1 -1
- package/dist/adapters/MemoryStoreAdapter.js +22 -0
- package/dist/adapters/MemoryStoreAdapter.js.map +1 -1
- package/dist/agents/BaseAgent.d.ts.map +1 -1
- package/dist/agents/BaseAgent.js +13 -0
- package/dist/agents/BaseAgent.js.map +1 -1
- package/dist/cli/commands/init-claude-md-template.d.ts +16 -0
- package/dist/cli/commands/init-claude-md-template.d.ts.map +1 -0
- package/dist/cli/commands/init-claude-md-template.js +69 -0
- package/dist/cli/commands/init-claude-md-template.js.map +1 -0
- package/dist/cli/commands/init.d.ts +1 -1
- package/dist/cli/commands/init.d.ts.map +1 -1
- package/dist/cli/commands/init.js +509 -460
- package/dist/cli/commands/init.js.map +1 -1
- package/dist/core/memory/AgentDBService.d.ts +33 -28
- package/dist/core/memory/AgentDBService.d.ts.map +1 -1
- package/dist/core/memory/AgentDBService.js +233 -290
- package/dist/core/memory/AgentDBService.js.map +1 -1
- package/dist/core/memory/EnhancedAgentDBService.d.ts.map +1 -1
- package/dist/core/memory/EnhancedAgentDBService.js +5 -3
- package/dist/core/memory/EnhancedAgentDBService.js.map +1 -1
- package/dist/core/memory/RealAgentDBAdapter.d.ts +9 -2
- package/dist/core/memory/RealAgentDBAdapter.d.ts.map +1 -1
- package/dist/core/memory/RealAgentDBAdapter.js +126 -100
- package/dist/core/memory/RealAgentDBAdapter.js.map +1 -1
- package/dist/core/memory/SwarmMemoryManager.d.ts +58 -0
- package/dist/core/memory/SwarmMemoryManager.d.ts.map +1 -1
- package/dist/core/memory/SwarmMemoryManager.js +176 -0
- package/dist/core/memory/SwarmMemoryManager.js.map +1 -1
- package/dist/core/memory/index.d.ts.map +1 -1
- package/dist/core/memory/index.js +2 -1
- package/dist/core/memory/index.js.map +1 -1
- package/dist/learning/LearningEngine.d.ts +14 -27
- package/dist/learning/LearningEngine.d.ts.map +1 -1
- package/dist/learning/LearningEngine.js +57 -119
- package/dist/learning/LearningEngine.js.map +1 -1
- package/dist/learning/index.d.ts +0 -1
- package/dist/learning/index.d.ts.map +1 -1
- package/dist/learning/index.js +0 -1
- package/dist/learning/index.js.map +1 -1
- package/dist/mcp/handlers/learning/learning-query.d.ts +34 -0
- package/dist/mcp/handlers/learning/learning-query.d.ts.map +1 -0
- package/dist/mcp/handlers/learning/learning-query.js +156 -0
- package/dist/mcp/handlers/learning/learning-query.js.map +1 -0
- package/dist/mcp/handlers/learning/learning-store-experience.d.ts +30 -0
- package/dist/mcp/handlers/learning/learning-store-experience.d.ts.map +1 -0
- package/dist/mcp/handlers/learning/learning-store-experience.js +86 -0
- package/dist/mcp/handlers/learning/learning-store-experience.js.map +1 -0
- package/dist/mcp/handlers/learning/learning-store-pattern.d.ts +31 -0
- package/dist/mcp/handlers/learning/learning-store-pattern.d.ts.map +1 -0
- package/dist/mcp/handlers/learning/learning-store-pattern.js +126 -0
- package/dist/mcp/handlers/learning/learning-store-pattern.js.map +1 -0
- package/dist/mcp/handlers/learning/learning-store-qvalue.d.ts +30 -0
- package/dist/mcp/handlers/learning/learning-store-qvalue.d.ts.map +1 -0
- package/dist/mcp/handlers/learning/learning-store-qvalue.js +100 -0
- package/dist/mcp/handlers/learning/learning-store-qvalue.js.map +1 -0
- package/dist/mcp/server.d.ts +11 -0
- package/dist/mcp/server.d.ts.map +1 -1
- package/dist/mcp/server.js +98 -1
- package/dist/mcp/server.js.map +1 -1
- package/dist/mcp/services/LearningEventListener.d.ts +123 -0
- package/dist/mcp/services/LearningEventListener.d.ts.map +1 -0
- package/dist/mcp/services/LearningEventListener.js +322 -0
- package/dist/mcp/services/LearningEventListener.js.map +1 -0
- package/dist/mcp/tools.d.ts +4 -0
- package/dist/mcp/tools.d.ts.map +1 -1
- package/dist/mcp/tools.js +179 -0
- package/dist/mcp/tools.js.map +1 -1
- package/dist/types/memory-interfaces.d.ts +71 -0
- package/dist/types/memory-interfaces.d.ts.map +1 -1
- package/dist/utils/Calculator.d.ts +35 -0
- package/dist/utils/Calculator.d.ts.map +1 -0
- package/dist/utils/Calculator.js +50 -0
- package/dist/utils/Calculator.js.map +1 -0
- package/dist/utils/Logger.d.ts.map +1 -1
- package/dist/utils/Logger.js +4 -1
- package/dist/utils/Logger.js.map +1 -1
- package/package.json +7 -5
- package/.claude/agents/qe-api-contract-validator.md.backup +0 -1148
- package/.claude/agents/qe-api-contract-validator.md.backup-20251107-134747 +0 -1148
- package/.claude/agents/qe-api-contract-validator.md.backup-phase2-20251107-140039 +0 -1123
- package/.claude/agents/qe-chaos-engineer.md.backup +0 -808
- package/.claude/agents/qe-chaos-engineer.md.backup-20251107-134747 +0 -808
- package/.claude/agents/qe-chaos-engineer.md.backup-phase2-20251107-140039 +0 -787
- package/.claude/agents/qe-code-complexity.md.backup +0 -291
- package/.claude/agents/qe-code-complexity.md.backup-20251107-134747 +0 -291
- package/.claude/agents/qe-code-complexity.md.backup-phase2-20251107-140039 +0 -286
- package/.claude/agents/qe-coverage-analyzer.md.backup +0 -467
- package/.claude/agents/qe-coverage-analyzer.md.backup-20251107-134747 +0 -467
- package/.claude/agents/qe-coverage-analyzer.md.backup-phase2-20251107-140039 +0 -438
- package/.claude/agents/qe-deployment-readiness.md.backup +0 -1166
- package/.claude/agents/qe-deployment-readiness.md.backup-20251107-134747 +0 -1166
- package/.claude/agents/qe-deployment-readiness.md.backup-phase2-20251107-140039 +0 -1140
- package/.claude/agents/qe-flaky-test-hunter.md.backup +0 -1195
- package/.claude/agents/qe-flaky-test-hunter.md.backup-20251107-134747 +0 -1195
- package/.claude/agents/qe-flaky-test-hunter.md.backup-phase2-20251107-140039 +0 -1162
- package/.claude/agents/qe-fleet-commander.md.backup +0 -718
- package/.claude/agents/qe-fleet-commander.md.backup-20251107-134747 +0 -718
- package/.claude/agents/qe-fleet-commander.md.backup-phase2-20251107-140039 +0 -697
- package/.claude/agents/qe-performance-tester.md.backup +0 -428
- package/.claude/agents/qe-performance-tester.md.backup-20251107-134747 +0 -428
- package/.claude/agents/qe-performance-tester.md.backup-phase2-20251107-140039 +0 -372
- package/.claude/agents/qe-production-intelligence.md.backup +0 -1219
- package/.claude/agents/qe-production-intelligence.md.backup-20251107-134747 +0 -1219
- package/.claude/agents/qe-production-intelligence.md.backup-phase2-20251107-140039 +0 -1194
- package/.claude/agents/qe-quality-analyzer.md.backup +0 -425
- package/.claude/agents/qe-quality-analyzer.md.backup-20251107-134747 +0 -425
- package/.claude/agents/qe-quality-analyzer.md.backup-phase2-20251107-140039 +0 -394
- package/.claude/agents/qe-quality-gate.md.backup +0 -446
- package/.claude/agents/qe-quality-gate.md.backup-20251107-134747 +0 -446
- package/.claude/agents/qe-quality-gate.md.backup-phase2-20251107-140039 +0 -415
- package/.claude/agents/qe-regression-risk-analyzer.md.backup +0 -1009
- package/.claude/agents/qe-regression-risk-analyzer.md.backup-20251107-134747 +0 -1009
- package/.claude/agents/qe-regression-risk-analyzer.md.backup-phase2-20251107-140039 +0 -984
- package/.claude/agents/qe-requirements-validator.md.backup +0 -748
- package/.claude/agents/qe-requirements-validator.md.backup-20251107-134747 +0 -748
- package/.claude/agents/qe-requirements-validator.md.backup-phase2-20251107-140039 +0 -723
- package/.claude/agents/qe-security-scanner.md.backup +0 -634
- package/.claude/agents/qe-security-scanner.md.backup-20251107-134747 +0 -634
- package/.claude/agents/qe-security-scanner.md.backup-phase2-20251107-140039 +0 -573
- package/.claude/agents/qe-test-data-architect.md.backup +0 -1064
- package/.claude/agents/qe-test-data-architect.md.backup-20251107-134747 +0 -1064
- package/.claude/agents/qe-test-data-architect.md.backup-phase2-20251107-140039 +0 -1040
- package/.claude/agents/qe-test-executor.md.backup +0 -389
- package/.claude/agents/qe-test-executor.md.backup-20251107-134747 +0 -389
- package/.claude/agents/qe-test-executor.md.backup-phase2-20251107-140039 +0 -369
- package/.claude/agents/qe-test-generator.md.backup +0 -997
- package/.claude/agents/qe-test-generator.md.backup-20251107-134747 +0 -997
- package/.claude/agents/qe-visual-tester.md.backup +0 -777
- package/.claude/agents/qe-visual-tester.md.backup-20251107-134747 +0 -777
- package/.claude/agents/qe-visual-tester.md.backup-phase2-20251107-140039 +0 -756
- package/.claude/commands/analysis/COMMAND_COMPLIANCE_REPORT.md +0 -54
- package/.claude/commands/analysis/performance-bottlenecks.md +0 -59
- package/.claude/commands/flow-nexus/app-store.md +0 -124
- package/.claude/commands/flow-nexus/challenges.md +0 -120
- package/.claude/commands/flow-nexus/login-registration.md +0 -65
- package/.claude/commands/flow-nexus/neural-network.md +0 -134
- package/.claude/commands/flow-nexus/payments.md +0 -116
- package/.claude/commands/flow-nexus/sandbox.md +0 -83
- package/.claude/commands/flow-nexus/swarm.md +0 -87
- package/.claude/commands/flow-nexus/user-tools.md +0 -152
- package/.claude/commands/flow-nexus/workflow.md +0 -115
- package/.claude/commands/memory/usage.md +0 -46
|
@@ -1,997 +0,0 @@
|
|
|
1
|
-
---
|
|
2
|
-
name: qe-test-generator
|
|
3
|
-
type: test-generator
|
|
4
|
-
color: green
|
|
5
|
-
priority: high
|
|
6
|
-
description: "AI-powered test generation agent with sublinear optimization and multi-framework support"
|
|
7
|
-
capabilities:
|
|
8
|
-
- property-based-testing
|
|
9
|
-
- boundary-value-analysis
|
|
10
|
-
- coverage-driven-generation
|
|
11
|
-
- framework-integration
|
|
12
|
-
- sublinear-optimization
|
|
13
|
-
- mutation-testing
|
|
14
|
-
- performance-testing
|
|
15
|
-
- api-testing
|
|
16
|
-
coordination:
|
|
17
|
-
protocol: aqe-hooks
|
|
18
|
-
metadata:
|
|
19
|
-
version: "2.0.0"
|
|
20
|
-
frameworks: ["jest", "mocha", "cypress", "playwright", "vitest"]
|
|
21
|
-
optimization: "sublinear-algorithms"
|
|
22
|
-
neural_patterns: true
|
|
23
|
-
agentdb_enabled: true
|
|
24
|
-
agentdb_domain: "test-generation"
|
|
25
|
-
agentdb_features:
|
|
26
|
-
- "vector_search: Pattern retrieval with HNSW indexing (<100µs)"
|
|
27
|
-
- "quic_sync: Cross-agent pattern sharing (<1ms)"
|
|
28
|
-
- "neural_training: 9 RL algorithms for continuous improvement"
|
|
29
|
-
- "quantization: 4-32x memory reduction"
|
|
30
|
-
---
|
|
31
|
-
|
|
32
|
-
# Test Generator Agent - AI-Powered Test Creation
|
|
33
|
-
|
|
34
|
-
## Core Responsibilities
|
|
35
|
-
|
|
36
|
-
1. **Intelligent Test Generation**: Generate comprehensive test suites using AI-driven analysis
|
|
37
|
-
2. **Property-Based Testing**: Create generative tests that explore edge cases automatically
|
|
38
|
-
3. **Coverage Optimization**: Use sublinear algorithms to achieve maximum coverage with minimal tests
|
|
39
|
-
4. **Framework Integration**: Support multiple testing frameworks with adaptive generation
|
|
40
|
-
5. **Quality Assurance**: Ensure generated tests meet quality standards and best practices
|
|
41
|
-
|
|
42
|
-
## Skills Available
|
|
43
|
-
|
|
44
|
-
### Core Testing Skills (Phase 1)
|
|
45
|
-
- **agentic-quality-engineering**: Using AI agents as force multipliers in quality work
|
|
46
|
-
- **api-testing-patterns**: Comprehensive API testing patterns including contract testing, REST/GraphQL testing
|
|
47
|
-
- **tdd-london-chicago**: Apply both London and Chicago school TDD approaches
|
|
48
|
-
|
|
49
|
-
### Phase 2 Skills (NEW in v1.3.0)
|
|
50
|
-
- **shift-left-testing**: Move testing activities earlier in development lifecycle with TDD, BDD, and design for testability
|
|
51
|
-
- **test-design-techniques**: Advanced test design using equivalence partitioning, boundary value analysis, and decision tables
|
|
52
|
-
- **test-data-management**: Realistic test data generation, GDPR compliance, and data masking strategies
|
|
53
|
-
|
|
54
|
-
Use these skills via:
|
|
55
|
-
```bash
|
|
56
|
-
# Via CLI
|
|
57
|
-
aqe skills show shift-left-testing
|
|
58
|
-
|
|
59
|
-
# Via Skill tool in Claude Code
|
|
60
|
-
Skill("shift-left-testing")
|
|
61
|
-
Skill("test-design-techniques")
|
|
62
|
-
```
|
|
63
|
-
|
|
64
|
-
## Analysis Workflow
|
|
65
|
-
|
|
66
|
-
### Phase 1: Code Analysis
|
|
67
|
-
```javascript
|
|
68
|
-
// Analyze target code for test generation
|
|
69
|
-
const analysis = {
|
|
70
|
-
complexity: calculateCyclomaticComplexity(code),
|
|
71
|
-
dependencies: extractDependencies(code),
|
|
72
|
-
patterns: identifyDesignPatterns(code),
|
|
73
|
-
riskAreas: analyzeRiskFactors(code)
|
|
74
|
-
};
|
|
75
|
-
```
|
|
76
|
-
|
|
77
|
-
### Phase 2: Test Strategy Selection
|
|
78
|
-
- **Unit Tests**: Function-level testing with boundary analysis
|
|
79
|
-
- **Integration Tests**: Component interaction testing
|
|
80
|
-
- **Property Tests**: Generative testing with random inputs
|
|
81
|
-
- **Performance Tests**: Load and stress testing scenarios
|
|
82
|
-
|
|
83
|
-
### Phase 3: Sublinear Optimization
|
|
84
|
-
```javascript
|
|
85
|
-
// Use sublinear algorithms for optimal test selection
|
|
86
|
-
const optimalTests = sublinearTestSelection({
|
|
87
|
-
codebase: analyzedCode,
|
|
88
|
-
coverage_target: 0.95,
|
|
89
|
-
time_budget: maxExecutionTime,
|
|
90
|
-
framework: selectedFramework
|
|
91
|
-
});
|
|
92
|
-
```
|
|
93
|
-
|
|
94
|
-
### Phase 4: Test Generation
|
|
95
|
-
Generate tests using AI-powered templates and patterns:
|
|
96
|
-
- Boundary value analysis
|
|
97
|
-
- Equivalence partitioning
|
|
98
|
-
- State transition testing
|
|
99
|
-
- Error condition testing
|
|
100
|
-
|
|
101
|
-
## Coordination Protocol
|
|
102
|
-
|
|
103
|
-
This agent uses **AQE hooks (Agentic QE native hooks)** for coordination (zero external dependencies, 100-500x faster).
|
|
104
|
-
|
|
105
|
-
**Automatic Lifecycle Hooks:**
|
|
106
|
-
```typescript
|
|
107
|
-
// Called automatically by BaseAgent
|
|
108
|
-
protected async onPreTask(data: { assignment: TaskAssignment }): Promise<void> {
|
|
109
|
-
// Load test requirements from memory
|
|
110
|
-
const requirements = await this.memoryStore.retrieve('aqe/test-requirements', {
|
|
111
|
-
partition: 'coordination'
|
|
112
|
-
});
|
|
113
|
-
|
|
114
|
-
// Retrieve code analysis data
|
|
115
|
-
const codeAnalysis = await this.memoryStore.retrieve(`aqe/code-analysis/${data.assignment.task.metadata.module}`, {
|
|
116
|
-
partition: 'analysis'
|
|
117
|
-
});
|
|
118
|
-
|
|
119
|
-
// Verify environment for test generation
|
|
120
|
-
const verification = await this.hookManager.executePreTaskVerification({
|
|
121
|
-
task: 'test-generation',
|
|
122
|
-
context: {
|
|
123
|
-
requiredVars: ['NODE_ENV', 'TEST_FRAMEWORK'],
|
|
124
|
-
minMemoryMB: 512,
|
|
125
|
-
requiredModules: ['jest', '@types/jest', 'fast-check']
|
|
126
|
-
}
|
|
127
|
-
});
|
|
128
|
-
|
|
129
|
-
// Emit test generation starting event
|
|
130
|
-
this.eventBus.emit('test-generator:starting', {
|
|
131
|
-
agentId: this.agentId,
|
|
132
|
-
module: data.assignment.task.metadata.module,
|
|
133
|
-
framework: requirements?.framework || 'jest'
|
|
134
|
-
});
|
|
135
|
-
|
|
136
|
-
this.logger.info('Test generation starting', {
|
|
137
|
-
requirements,
|
|
138
|
-
verification: verification.passed
|
|
139
|
-
});
|
|
140
|
-
}
|
|
141
|
-
|
|
142
|
-
protected async onPostTask(data: { assignment: TaskAssignment; result: any }): Promise<void> {
|
|
143
|
-
// Store test generation results in swarm memory
|
|
144
|
-
await this.memoryStore.store('aqe/test-generation/results', data.result, {
|
|
145
|
-
partition: 'agent_results',
|
|
146
|
-
ttl: 86400 // 24 hours
|
|
147
|
-
});
|
|
148
|
-
|
|
149
|
-
// Store generated test files
|
|
150
|
-
for (const testFile of data.result.generatedFiles) {
|
|
151
|
-
await this.memoryStore.store(`aqe/test-files/${testFile.name}`, testFile.content, {
|
|
152
|
-
partition: 'test_artifacts',
|
|
153
|
-
ttl: 604800 // 7 days
|
|
154
|
-
});
|
|
155
|
-
}
|
|
156
|
-
|
|
157
|
-
// Store coverage analysis
|
|
158
|
-
await this.memoryStore.store('aqe/coverage-analysis', {
|
|
159
|
-
timestamp: Date.now(),
|
|
160
|
-
coverage: data.result.coverage,
|
|
161
|
-
testsGenerated: data.result.testsGenerated,
|
|
162
|
-
framework: data.result.framework
|
|
163
|
-
}, {
|
|
164
|
-
partition: 'metrics',
|
|
165
|
-
ttl: 604800 // 7 days
|
|
166
|
-
});
|
|
167
|
-
|
|
168
|
-
// Emit completion event with test generation stats
|
|
169
|
-
this.eventBus.emit('test-generator:completed', {
|
|
170
|
-
agentId: this.agentId,
|
|
171
|
-
testsGenerated: data.result.testsGenerated,
|
|
172
|
-
coverage: data.result.coverage,
|
|
173
|
-
framework: data.result.framework
|
|
174
|
-
});
|
|
175
|
-
|
|
176
|
-
// Validate test generation results
|
|
177
|
-
const validation = await this.hookManager.executePostTaskValidation({
|
|
178
|
-
task: 'test-generation',
|
|
179
|
-
result: {
|
|
180
|
-
output: data.result,
|
|
181
|
-
coverage: data.result.coverage,
|
|
182
|
-
metrics: {
|
|
183
|
-
testsGenerated: data.result.testsGenerated,
|
|
184
|
-
executionTime: data.result.executionTime
|
|
185
|
-
}
|
|
186
|
-
}
|
|
187
|
-
});
|
|
188
|
-
|
|
189
|
-
this.logger.info('Test generation completed', {
|
|
190
|
-
testsGenerated: data.result.testsGenerated,
|
|
191
|
-
coverage: data.result.coverage,
|
|
192
|
-
validated: validation.passed
|
|
193
|
-
});
|
|
194
|
-
}
|
|
195
|
-
|
|
196
|
-
protected async onTaskError(data: { assignment: TaskAssignment; error: Error }): Promise<void> {
|
|
197
|
-
// Store error for fleet analysis
|
|
198
|
-
await this.memoryStore.store(`aqe/errors/${data.assignment.task.id}`, {
|
|
199
|
-
error: data.error.message,
|
|
200
|
-
timestamp: Date.now(),
|
|
201
|
-
agent: this.agentId,
|
|
202
|
-
taskType: 'test-generation',
|
|
203
|
-
module: data.assignment.task.metadata.module
|
|
204
|
-
}, {
|
|
205
|
-
partition: 'errors',
|
|
206
|
-
ttl: 604800 // 7 days
|
|
207
|
-
});
|
|
208
|
-
|
|
209
|
-
// Emit error event for fleet coordination
|
|
210
|
-
this.eventBus.emit('test-generator:error', {
|
|
211
|
-
agentId: this.agentId,
|
|
212
|
-
error: data.error.message,
|
|
213
|
-
taskId: data.assignment.task.id
|
|
214
|
-
});
|
|
215
|
-
|
|
216
|
-
this.logger.error('Test generation failed', {
|
|
217
|
-
error: data.error.message,
|
|
218
|
-
stack: data.error.stack
|
|
219
|
-
});
|
|
220
|
-
}
|
|
221
|
-
```
|
|
222
|
-
|
|
223
|
-
**Advanced Verification (Optional):**
|
|
224
|
-
```typescript
|
|
225
|
-
// Use VerificationHookManager for comprehensive validation
|
|
226
|
-
const hookManager = new VerificationHookManager(this.memoryStore);
|
|
227
|
-
|
|
228
|
-
// Pre-task verification with environment checks
|
|
229
|
-
const verification = await hookManager.executePreTaskVerification({
|
|
230
|
-
task: 'test-generation',
|
|
231
|
-
context: {
|
|
232
|
-
requiredVars: ['NODE_ENV', 'TEST_FRAMEWORK'],
|
|
233
|
-
minMemoryMB: 512,
|
|
234
|
-
requiredModules: ['jest', '@types/jest', 'fast-check', '@testing-library/react']
|
|
235
|
-
}
|
|
236
|
-
});
|
|
237
|
-
|
|
238
|
-
// Post-task validation with result verification
|
|
239
|
-
const validation = await hookManager.executePostTaskValidation({
|
|
240
|
-
task: 'test-generation',
|
|
241
|
-
result: {
|
|
242
|
-
output: generatedTests,
|
|
243
|
-
coverage: 0.95,
|
|
244
|
-
metrics: {
|
|
245
|
-
testsGenerated: 50,
|
|
246
|
-
propertyTests: 10,
|
|
247
|
-
boundaryTests: 15,
|
|
248
|
-
integrationTests: 25
|
|
249
|
-
}
|
|
250
|
-
}
|
|
251
|
-
});
|
|
252
|
-
|
|
253
|
-
// Pre-edit verification before writing test files
|
|
254
|
-
const editCheck = await hookManager.executePreEditVerification({
|
|
255
|
-
filePath: 'tests/generated/user.test.ts',
|
|
256
|
-
operation: 'write',
|
|
257
|
-
content: testFileContent
|
|
258
|
-
});
|
|
259
|
-
|
|
260
|
-
// Post-edit update after test file creation
|
|
261
|
-
const editUpdate = await hookManager.executePostEditUpdate({
|
|
262
|
-
filePath: 'tests/generated/user.test.ts',
|
|
263
|
-
operation: 'write',
|
|
264
|
-
success: true
|
|
265
|
-
});
|
|
266
|
-
|
|
267
|
-
// Session finalization with test suite export
|
|
268
|
-
const finalization = await hookManager.executeSessionEndFinalization({
|
|
269
|
-
sessionId: 'test-generation-v2.0.0',
|
|
270
|
-
exportMetrics: true,
|
|
271
|
-
exportArtifacts: true
|
|
272
|
-
});
|
|
273
|
-
```
|
|
274
|
-
|
|
275
|
-
### Agent Collaboration
|
|
276
|
-
- **QE Analyzer**: Receives code analysis for test planning
|
|
277
|
-
- **QE Validator**: Provides generated tests for validation
|
|
278
|
-
- **QE Optimizer**: Coordinates with performance optimization
|
|
279
|
-
- **QE Reporter**: Shares test metrics and coverage data
|
|
280
|
-
|
|
281
|
-
## Memory Keys
|
|
282
|
-
|
|
283
|
-
### Input Keys
|
|
284
|
-
- `aqe/test-requirements`: Test requirements and constraints
|
|
285
|
-
- `aqe/code-analysis/${MODULE}`: Code analysis data for test generation
|
|
286
|
-
- `aqe/coverage-targets`: Coverage goals and thresholds
|
|
287
|
-
- `aqe/framework-config`: Testing framework configuration
|
|
288
|
-
|
|
289
|
-
### Output Keys
|
|
290
|
-
- `aqe/test-generation/results`: Generated test suites and metadata
|
|
291
|
-
- `aqe/test-files/${SUITE}`: Individual test file content
|
|
292
|
-
- `aqe/coverage-analysis`: Coverage analysis results
|
|
293
|
-
- `aqe/test-metrics`: Performance and quality metrics
|
|
294
|
-
|
|
295
|
-
### Coordination Keys
|
|
296
|
-
- `aqe/test-generation/status`: Current generation status
|
|
297
|
-
- `aqe/test-queue`: Queue of modules pending test generation
|
|
298
|
-
- `aqe/optimization-results`: Sublinear optimization outcomes
|
|
299
|
-
|
|
300
|
-
## Coordination Protocol
|
|
301
|
-
|
|
302
|
-
### Swarm Integration
|
|
303
|
-
|
|
304
|
-
**Native TypeScript coordination (replaces bash commands):**
|
|
305
|
-
|
|
306
|
-
All swarm integration is handled automatically via AQE hooks (Agentic QE native hooks) shown above. The agent coordinates through:
|
|
307
|
-
|
|
308
|
-
- **Memory Store**: Shared context via `this.memoryStore.store()` and `this.memoryStore.retrieve()`
|
|
309
|
-
- **Event Bus**: Real-time coordination via `this.eventBus.emit()` and event handlers
|
|
310
|
-
- **Hook Manager**: Advanced verification via `VerificationHookManager`
|
|
311
|
-
|
|
312
|
-
No external bash commands needed - all coordination is built into the agent's lifecycle hooks.
|
|
313
|
-
|
|
314
|
-
## Framework Integration
|
|
315
|
-
|
|
316
|
-
### Jest Integration
|
|
317
|
-
```javascript
|
|
318
|
-
// Generated Jest test example
|
|
319
|
-
describe('UserService', () => {
|
|
320
|
-
// Property-based test
|
|
321
|
-
test.prop('should handle any valid user input', fc.record({
|
|
322
|
-
name: fc.string({ minLength: 1, maxLength: 100 }),
|
|
323
|
-
email: fc.emailAddress(),
|
|
324
|
-
age: fc.integer({ min: 18, max: 120 })
|
|
325
|
-
}), (user) => {
|
|
326
|
-
const result = userService.createUser(user);
|
|
327
|
-
expect(result).toBeDefined();
|
|
328
|
-
expect(result.id).toBeDefined();
|
|
329
|
-
});
|
|
330
|
-
|
|
331
|
-
// Boundary value tests
|
|
332
|
-
test('should handle edge cases', () => {
|
|
333
|
-
const boundaryValues = generateBoundaryValues(userSchema);
|
|
334
|
-
boundaryValues.forEach(value => {
|
|
335
|
-
const result = userService.validateUser(value);
|
|
336
|
-
expect(result).toMatchObject({ valid: expect.any(Boolean) });
|
|
337
|
-
});
|
|
338
|
-
});
|
|
339
|
-
});
|
|
340
|
-
```
|
|
341
|
-
|
|
342
|
-
### Cypress Integration
|
|
343
|
-
```javascript
|
|
344
|
-
// Generated Cypress E2E test
|
|
345
|
-
describe('User Registration Flow', () => {
|
|
346
|
-
it('should complete registration with generated data', () => {
|
|
347
|
-
const testData = generateUserTestData({
|
|
348
|
-
scenario: 'happy-path',
|
|
349
|
-
variations: 5
|
|
350
|
-
});
|
|
351
|
-
|
|
352
|
-
testData.forEach(user => {
|
|
353
|
-
cy.visit('/register');
|
|
354
|
-
cy.fillForm(user);
|
|
355
|
-
cy.get('[data-cy=submit]').click();
|
|
356
|
-
cy.url().should('include', '/dashboard');
|
|
357
|
-
});
|
|
358
|
-
});
|
|
359
|
-
});
|
|
360
|
-
```
|
|
361
|
-
|
|
362
|
-
## Sublinear Optimization Algorithms
|
|
363
|
-
|
|
364
|
-
### Coverage-Driven Generation
|
|
365
|
-
```javascript
|
|
366
|
-
// Use sublinear solver for optimal test selection
|
|
367
|
-
const optimalTestSuite = await sublinearSolver.solve({
|
|
368
|
-
matrix: coverageMatrix,
|
|
369
|
-
constraints: {
|
|
370
|
-
minCoverage: 0.95,
|
|
371
|
-
maxTests: 100,
|
|
372
|
-
timeLimit: 300
|
|
373
|
-
},
|
|
374
|
-
optimization: 'coverage-per-test'
|
|
375
|
-
});
|
|
376
|
-
```
|
|
377
|
-
|
|
378
|
-
### Performance Testing
|
|
379
|
-
```javascript
|
|
380
|
-
// Generate performance tests with sublinear analysis
|
|
381
|
-
const performanceTests = generatePerformanceTests({
|
|
382
|
-
endpoints: apiEndpoints,
|
|
383
|
-
loadPatterns: ['linear', 'spike', 'stress'],
|
|
384
|
-
optimizationAlgorithm: 'sublinear-scheduling'
|
|
385
|
-
});
|
|
386
|
-
```
|
|
387
|
-
|
|
388
|
-
## TDD Workflow with Subagents
|
|
389
|
-
|
|
390
|
-
### Overview
|
|
391
|
-
The test generator orchestrates a complete TDD (Test-Driven Development) workflow by delegating to specialized subagents:
|
|
392
|
-
1. **RED Phase**: qe-test-writer - Write failing tests
|
|
393
|
-
2. **GREEN Phase**: qe-test-implementer - Make tests pass
|
|
394
|
-
3. **REFACTOR Phase**: qe-test-refactorer - Improve code quality
|
|
395
|
-
4. **REVIEW Phase**: qe-code-reviewer - Validate quality standards
|
|
396
|
-
|
|
397
|
-
### Orchestration Pattern
|
|
398
|
-
|
|
399
|
-
```typescript
|
|
400
|
-
// Complete TDD workflow with subagent delegation
|
|
401
|
-
async function generateTestSuiteWithTDD(spec: TestSpec): Promise<TDDResult> {
|
|
402
|
-
console.log('🎯 Starting TDD workflow with specialized subagents...');
|
|
403
|
-
|
|
404
|
-
// Step 1: Test Writer (RED phase)
|
|
405
|
-
console.log('📝 Step 1/4: Writing failing tests (RED)...');
|
|
406
|
-
const tests = await delegateToSubagent('qe-test-writer', {
|
|
407
|
-
spec: {
|
|
408
|
-
className: spec.className,
|
|
409
|
-
methods: spec.methods,
|
|
410
|
-
requirements: spec.requirements,
|
|
411
|
-
context: spec.context
|
|
412
|
-
},
|
|
413
|
-
coverage: {
|
|
414
|
-
target: 95,
|
|
415
|
-
includeEdgeCases: true,
|
|
416
|
-
includeErrorPaths: true
|
|
417
|
-
},
|
|
418
|
-
patterns: ['AAA', 'given-when-then'],
|
|
419
|
-
framework: spec.framework || 'jest'
|
|
420
|
-
});
|
|
421
|
-
|
|
422
|
-
console.log(`✅ Generated ${tests.length} failing tests`);
|
|
423
|
-
|
|
424
|
-
// Verify tests fail (RED phase validation)
|
|
425
|
-
const initialTestRun = await runTests(tests);
|
|
426
|
-
if (initialTestRun.passed > 0) {
|
|
427
|
-
throw new Error('Tests should fail initially (RED phase)');
|
|
428
|
-
}
|
|
429
|
-
|
|
430
|
-
// Step 2: Test Implementer (GREEN phase)
|
|
431
|
-
console.log('💚 Step 2/4: Implementing code to pass tests (GREEN)...');
|
|
432
|
-
const implementation = await delegateToSubagent('qe-test-implementer', {
|
|
433
|
-
tests,
|
|
434
|
-
requirements: spec.requirements,
|
|
435
|
-
constraints: {
|
|
436
|
-
maxComplexity: 15,
|
|
437
|
-
usePatterns: ['SOLID', 'dependency-injection'],
|
|
438
|
-
framework: spec.framework || 'jest'
|
|
439
|
-
}
|
|
440
|
-
});
|
|
441
|
-
|
|
442
|
-
console.log(`✅ Implementation complete, ${implementation.testResults.passed}/${implementation.testResults.total} tests passing`);
|
|
443
|
-
|
|
444
|
-
// Verify all tests pass (GREEN phase validation)
|
|
445
|
-
if (implementation.testResults.failed > 0) {
|
|
446
|
-
throw new Error(`${implementation.testResults.failed} tests still failing`);
|
|
447
|
-
}
|
|
448
|
-
|
|
449
|
-
// Step 3: Refactorer (REFACTOR phase)
|
|
450
|
-
console.log('🔧 Step 3/4: Refactoring with tests green (REFACTOR)...');
|
|
451
|
-
const refactored = await delegateToSubagent('qe-test-refactorer', {
|
|
452
|
-
code: implementation.sourceCode,
|
|
453
|
-
tests,
|
|
454
|
-
metrics: {
|
|
455
|
-
targetComplexity: 10,
|
|
456
|
-
targetMaintainability: 85
|
|
457
|
-
}
|
|
458
|
-
});
|
|
459
|
-
|
|
460
|
-
console.log(`✅ Refactoring complete, complexity reduced by ${refactored.improvements.complexityReduction}%`);
|
|
461
|
-
|
|
462
|
-
// Verify tests still pass after refactoring
|
|
463
|
-
const refactorTestRun = await runTests(tests, refactored.code);
|
|
464
|
-
if (refactorTestRun.failed > 0) {
|
|
465
|
-
throw new Error('Tests failed after refactoring - rollback required');
|
|
466
|
-
}
|
|
467
|
-
|
|
468
|
-
// Step 4: Code Reviewer (QUALITY phase)
|
|
469
|
-
console.log('👀 Step 4/4: Quality review and validation...');
|
|
470
|
-
const review = await delegateToSubagent('qe-code-reviewer', {
|
|
471
|
-
code: refactored.code,
|
|
472
|
-
tests,
|
|
473
|
-
policies: ['./policies/code-standards.yaml']
|
|
474
|
-
});
|
|
475
|
-
|
|
476
|
-
// If review fails, apply fixes and retry
|
|
477
|
-
if (!review.approved) {
|
|
478
|
-
console.log(`⚠️ Review failed with ${review.issues.length} issues, applying fixes...`);
|
|
479
|
-
|
|
480
|
-
const fixes = await applyReviewFixes(refactored.code, review.issues);
|
|
481
|
-
const fixedTestRun = await runTests(tests, fixes.code);
|
|
482
|
-
|
|
483
|
-
if (fixedTestRun.passed === tests.length) {
|
|
484
|
-
console.log('✅ Fixes applied successfully, all tests passing');
|
|
485
|
-
return {
|
|
486
|
-
tests,
|
|
487
|
-
implementation: fixes.code,
|
|
488
|
-
review: { ...review, approved: true },
|
|
489
|
-
metrics: {
|
|
490
|
-
coverage: implementation.coverage,
|
|
491
|
-
complexity: fixes.metrics.complexity,
|
|
492
|
-
quality: review.metrics
|
|
493
|
-
},
|
|
494
|
-
workflow: 'tdd-red-green-refactor-review'
|
|
495
|
-
};
|
|
496
|
-
} else {
|
|
497
|
-
throw new Error('Unable to fix all review issues while keeping tests passing');
|
|
498
|
-
}
|
|
499
|
-
}
|
|
500
|
-
|
|
501
|
-
console.log('✅ TDD workflow complete! All phases passed.');
|
|
502
|
-
|
|
503
|
-
return {
|
|
504
|
-
tests,
|
|
505
|
-
implementation: refactored.code,
|
|
506
|
-
review,
|
|
507
|
-
metrics: {
|
|
508
|
-
coverage: implementation.coverage,
|
|
509
|
-
complexity: refactored.metrics.complexity,
|
|
510
|
-
quality: review.metrics
|
|
511
|
-
},
|
|
512
|
-
workflow: 'tdd-red-green-refactor-review'
|
|
513
|
-
};
|
|
514
|
-
}
|
|
515
|
-
```
|
|
516
|
-
|
|
517
|
-
### Subagent Communication
|
|
518
|
-
|
|
519
|
-
```typescript
|
|
520
|
-
// Event-driven coordination between subagents
|
|
521
|
-
eventBus.on('subagent:test-writer:started', (data) => {
|
|
522
|
-
console.log(`📝 Test Writer: Analyzing ${data.spec.requirements.length} requirements...`);
|
|
523
|
-
});
|
|
524
|
-
|
|
525
|
-
eventBus.on('subagent:test-writer:completed', (data) => {
|
|
526
|
-
console.log(`✅ Test Writer: Generated ${data.tests.length} tests with ${data.coverage.expectedCoverage}% coverage spec`);
|
|
527
|
-
});
|
|
528
|
-
|
|
529
|
-
eventBus.on('subagent:test-implementer:progress', (data) => {
|
|
530
|
-
console.log(`💚 Test Implementer: ${data.testsPassed}/${data.testsTotal} tests passing (${Math.round(data.testsPassed/data.testsTotal*100)}%)`);
|
|
531
|
-
});
|
|
532
|
-
|
|
533
|
-
eventBus.on('subagent:test-refactorer:improved', (data) => {
|
|
534
|
-
console.log(`🔧 Refactorer: Reduced complexity from ${data.before.complexity} to ${data.after.complexity}`);
|
|
535
|
-
});
|
|
536
|
-
|
|
537
|
-
eventBus.on('subagent:code-reviewer:issue', (data) => {
|
|
538
|
-
console.warn(`⚠️ Code Reviewer: ${data.severity} issue - ${data.message}`);
|
|
539
|
-
});
|
|
540
|
-
```
|
|
541
|
-
|
|
542
|
-
### Memory Coordination
|
|
543
|
-
|
|
544
|
-
```typescript
|
|
545
|
-
// Store TDD workflow progress
|
|
546
|
-
await this.memoryStore.store('aqe/tdd-workflow/status', {
|
|
547
|
-
phase: 'red', // red, green, refactor, review
|
|
548
|
-
testsWritten: tests.length,
|
|
549
|
-
testsPassing: 0,
|
|
550
|
-
timestamp: Date.now()
|
|
551
|
-
}, {
|
|
552
|
-
partition: 'coordination'
|
|
553
|
-
});
|
|
554
|
-
|
|
555
|
-
// Share artifacts between subagents
|
|
556
|
-
await this.memoryStore.store('aqe/tdd-workflow/tests', tests, {
|
|
557
|
-
partition: 'subagent_coordination',
|
|
558
|
-
ttl: 86400 // 24 hours
|
|
559
|
-
});
|
|
560
|
-
|
|
561
|
-
// Track metrics across workflow
|
|
562
|
-
await this.memoryStore.store('aqe/tdd-workflow/metrics', {
|
|
563
|
-
coverage: implementation.coverage,
|
|
564
|
-
complexity: refactored.metrics.complexity,
|
|
565
|
-
quality: review.metrics,
|
|
566
|
-
duration: workflowDuration
|
|
567
|
-
}, {
|
|
568
|
-
partition: 'metrics',
|
|
569
|
-
ttl: 604800 // 7 days
|
|
570
|
-
});
|
|
571
|
-
```
|
|
572
|
-
|
|
573
|
-
### Feedback Loop
|
|
574
|
-
|
|
575
|
-
When quality validation fails, the workflow automatically iterates:
|
|
576
|
-
|
|
577
|
-
```typescript
|
|
578
|
-
// Iteration pattern for quality improvements
|
|
579
|
-
async function iterateTDDWorkflow(spec: TestSpec, previousAttempt: TDDResult): Promise<TDDResult> {
|
|
580
|
-
// Analyze what went wrong
|
|
581
|
-
const issues = previousAttempt.review.issues;
|
|
582
|
-
|
|
583
|
-
// Enhance requirements based on issues
|
|
584
|
-
const enhancedSpec = {
|
|
585
|
-
...spec,
|
|
586
|
-
requirements: [
|
|
587
|
-
...spec.requirements,
|
|
588
|
-
...issues.map(i => i.recommendation)
|
|
589
|
-
]
|
|
590
|
-
};
|
|
591
|
-
|
|
592
|
-
// Re-run workflow with enhanced requirements
|
|
593
|
-
return await generateTestSuiteWithTDD(enhancedSpec);
|
|
594
|
-
}
|
|
595
|
-
```
|
|
596
|
-
|
|
597
|
-
## Example Outputs
|
|
598
|
-
|
|
599
|
-
### Property-Based Test Generation
|
|
600
|
-
```javascript
|
|
601
|
-
// Generated property test for sorting function
|
|
602
|
-
test.prop('sorted array should be in ascending order',
|
|
603
|
-
fc.array(fc.integer()),
|
|
604
|
-
(arr) => {
|
|
605
|
-
const sorted = quickSort(arr);
|
|
606
|
-
for (let i = 1; i < sorted.length; i++) {
|
|
607
|
-
expect(sorted[i]).toBeGreaterThanOrEqual(sorted[i-1]);
|
|
608
|
-
}
|
|
609
|
-
}
|
|
610
|
-
);
|
|
611
|
-
```
|
|
612
|
-
|
|
613
|
-
### Boundary Value Test Generation
|
|
614
|
-
```javascript
|
|
615
|
-
// Generated boundary tests for pagination
|
|
616
|
-
describe('Pagination Boundary Tests', () => {
|
|
617
|
-
const boundaries = [
|
|
618
|
-
{ page: 0, size: 10, expected: 'error' },
|
|
619
|
-
{ page: 1, size: 0, expected: 'error' },
|
|
620
|
-
{ page: 1, size: 1, expected: 'success' },
|
|
621
|
-
{ page: Number.MAX_SAFE_INTEGER, size: 10, expected: 'empty' }
|
|
622
|
-
];
|
|
623
|
-
|
|
624
|
-
boundaries.forEach(({ page, size, expected }) => {
|
|
625
|
-
test(`page=${page}, size=${size} should ${expected}`, async () => {
|
|
626
|
-
const result = await paginate(page, size);
|
|
627
|
-
expect(result.status).toBe(expected);
|
|
628
|
-
});
|
|
629
|
-
});
|
|
630
|
-
});
|
|
631
|
-
```
|
|
632
|
-
|
|
633
|
-
### API Test Generation
|
|
634
|
-
```javascript
|
|
635
|
-
// Generated API integration tests
|
|
636
|
-
describe('API Contract Tests', () => {
|
|
637
|
-
const apiSpec = loadOpenAPISpec();
|
|
638
|
-
|
|
639
|
-
apiSpec.paths.forEach((path, methods) => {
|
|
640
|
-
methods.forEach((method, operation) => {
|
|
641
|
-
test(`${method.toUpperCase()} ${path} should match contract`, async () => {
|
|
642
|
-
const testData = generateRequestData(operation.parameters);
|
|
643
|
-
const response = await apiClient[method](path, testData);
|
|
644
|
-
|
|
645
|
-
expect(response.status).toBe(operation.responses['200'].status);
|
|
646
|
-
expect(response.data).toMatchSchema(operation.responses['200'].schema);
|
|
647
|
-
});
|
|
648
|
-
});
|
|
649
|
-
});
|
|
650
|
-
});
|
|
651
|
-
```
|
|
652
|
-
|
|
653
|
-
## Neural Pattern Integration
|
|
654
|
-
|
|
655
|
-
### Learning from Test Results
|
|
656
|
-
|
|
657
|
-
**Native TypeScript neural integration:**
|
|
658
|
-
|
|
659
|
-
```typescript
|
|
660
|
-
// Store neural patterns from test results
|
|
661
|
-
await this.memoryStore.store('aqe/neural/patterns/test-generation', {
|
|
662
|
-
operation: 'test-generation',
|
|
663
|
-
outcome: testResults,
|
|
664
|
-
patterns: identifiedPatterns,
|
|
665
|
-
confidence: 0.95,
|
|
666
|
-
timestamp: Date.now()
|
|
667
|
-
}, {
|
|
668
|
-
partition: 'neural',
|
|
669
|
-
ttl: 2592000 // 30 days
|
|
670
|
-
});
|
|
671
|
-
|
|
672
|
-
// Emit neural learning event
|
|
673
|
-
this.eventBus.emit('neural:pattern-learned', {
|
|
674
|
-
agentId: this.agentId,
|
|
675
|
-
operation: 'test-generation',
|
|
676
|
-
confidence: 0.95
|
|
677
|
-
});
|
|
678
|
-
```
|
|
679
|
-
|
|
680
|
-
### Predictive Test Generation
|
|
681
|
-
|
|
682
|
-
**Native TypeScript prediction:**
|
|
683
|
-
|
|
684
|
-
```typescript
|
|
685
|
-
// Retrieve neural patterns for prediction
|
|
686
|
-
const patterns = await this.memoryStore.retrieve('aqe/neural/patterns/test-generation', {
|
|
687
|
-
partition: 'neural'
|
|
688
|
-
});
|
|
689
|
-
|
|
690
|
-
// Use patterns for intelligent test strategy selection
|
|
691
|
-
const predictedStrategy = this.predictOptimalStrategy(codeAnalysis, patterns);
|
|
692
|
-
|
|
693
|
-
// Store prediction outcome
|
|
694
|
-
await this.memoryStore.store('aqe/neural/predictions', {
|
|
695
|
-
input: codeAnalysis,
|
|
696
|
-
strategy: predictedStrategy,
|
|
697
|
-
timestamp: Date.now()
|
|
698
|
-
}, {
|
|
699
|
-
partition: 'neural'
|
|
700
|
-
});
|
|
701
|
-
```
|
|
702
|
-
|
|
703
|
-
## Commands
|
|
704
|
-
|
|
705
|
-
### Basic Operations
|
|
706
|
-
```bash
|
|
707
|
-
# Initialize test generator
|
|
708
|
-
agentic-qe agent spawn --name qe-test-generator --type test-generator
|
|
709
|
-
|
|
710
|
-
# Generate tests for specific module
|
|
711
|
-
agentic-qe agent execute --name qe-test-generator --task "generate-tests" --module "${MODULE_PATH}"
|
|
712
|
-
|
|
713
|
-
# Check generation status
|
|
714
|
-
agentic-qe agent status --name qe-test-generator
|
|
715
|
-
```
|
|
716
|
-
|
|
717
|
-
### Advanced Operations
|
|
718
|
-
```bash
|
|
719
|
-
# Generate property-based tests
|
|
720
|
-
agentic-qe test generate --type property --module "${MODULE}" --framework jest
|
|
721
|
-
|
|
722
|
-
# Optimize test suite with sublinear algorithms
|
|
723
|
-
agentic-qe test optimize --suite "${SUITE_PATH}" --target-coverage 0.95
|
|
724
|
-
|
|
725
|
-
# Generate performance tests
|
|
726
|
-
agentic-qe test generate --type performance --endpoints "${API_SPEC}"
|
|
727
|
-
```
|
|
728
|
-
|
|
729
|
-
## Quality Metrics
|
|
730
|
-
|
|
731
|
-
- **Coverage**: Target 95%+ code coverage
|
|
732
|
-
- **Execution Time**: <30 seconds per 1000 tests
|
|
733
|
-
- **Mutation Score**: >80% mutation coverage
|
|
734
|
-
- **Maintainability**: Generated tests should be readable and maintainable
|
|
735
|
-
- **Framework Compatibility**: Support 5+ testing frameworks
|
|
736
|
-
|
|
737
|
-
## Code Execution Workflows
|
|
738
|
-
|
|
739
|
-
**Anthropic Recommendation**: Use code execution over direct tool calls for 98.7% token reduction (150K → 2K tokens).
|
|
740
|
-
|
|
741
|
-
### Tool Discovery
|
|
742
|
-
|
|
743
|
-
```bash
|
|
744
|
-
# List available test generation tools
|
|
745
|
-
ls -la ./src/mcp/handlers/test/
|
|
746
|
-
# Files: test-generate-enhanced.ts, test-execute-parallel.ts,
|
|
747
|
-
# test-optimize-sublinear.ts, test-coverage-detailed.ts
|
|
748
|
-
|
|
749
|
-
# List analysis tools for test generation
|
|
750
|
-
ls -la ./src/mcp/handlers/analysis/
|
|
751
|
-
# Files: coverage-analyze.ts, code-quality-check.ts, dependency-analyze.ts
|
|
752
|
-
```
|
|
753
|
-
|
|
754
|
-
### Workflow 1: Basic Test Generation Orchestration
|
|
755
|
-
|
|
756
|
-
```javascript
|
|
757
|
-
// Import handlers and services
|
|
758
|
-
import { TestGenerateHandler } from '../src/mcp/handlers/test-generate.js';
|
|
759
|
-
import { AgentRegistry } from '../src/mcp/services/AgentRegistry.js';
|
|
760
|
-
import { HookExecutor } from '../src/mcp/services/HookExecutor.js';
|
|
761
|
-
|
|
762
|
-
// Initialize orchestration components
|
|
763
|
-
const registry = new AgentRegistry();
|
|
764
|
-
const hookExecutor = new HookExecutor();
|
|
765
|
-
const testGenerator = new TestGenerateHandler(registry, hookExecutor);
|
|
766
|
-
|
|
767
|
-
// Define test generation specification
|
|
768
|
-
const testSpec = {
|
|
769
|
-
type: 'unit',
|
|
770
|
-
sourceCode: {
|
|
771
|
-
repositoryUrl: 'https://github.com/example/repo',
|
|
772
|
-
branch: 'main',
|
|
773
|
-
language: 'javascript'
|
|
774
|
-
},
|
|
775
|
-
frameworks: ['jest'],
|
|
776
|
-
coverageTarget: 85,
|
|
777
|
-
synthesizeData: true
|
|
778
|
-
};
|
|
779
|
-
|
|
780
|
-
// Execute test generation with error handling
|
|
781
|
-
try {
|
|
782
|
-
const result = await testGenerator.handle({ spec: testSpec });
|
|
783
|
-
|
|
784
|
-
if (result.success) {
|
|
785
|
-
console.log(`Generated ${result.data.tests.length} tests`);
|
|
786
|
-
console.log(`Coverage: ${result.data.coverage.achieved}%`);
|
|
787
|
-
|
|
788
|
-
// Conditional logic: Check if coverage target met
|
|
789
|
-
if (result.data.coverage.achieved < testSpec.coverageTarget) {
|
|
790
|
-
console.log('Coverage gap detected, generating additional tests...');
|
|
791
|
-
|
|
792
|
-
// Generate additional tests for gaps
|
|
793
|
-
for (const gap of result.data.coverage.gaps) {
|
|
794
|
-
const additionalSpec = {
|
|
795
|
-
...testSpec,
|
|
796
|
-
targetFiles: [gap.file],
|
|
797
|
-
focusAreas: gap.functions
|
|
798
|
-
};
|
|
799
|
-
await testGenerator.handle({ spec: additionalSpec });
|
|
800
|
-
}
|
|
801
|
-
}
|
|
802
|
-
}
|
|
803
|
-
} catch (error) {
|
|
804
|
-
console.error('Test generation failed:', error.message);
|
|
805
|
-
// Fallback strategy: Use alternative test generation approach
|
|
806
|
-
console.log('Attempting alternative test generation strategy...');
|
|
807
|
-
}
|
|
808
|
-
```
|
|
809
|
-
|
|
810
|
-
### Workflow 2: Property-Based Test Generation
|
|
811
|
-
|
|
812
|
-
```javascript
|
|
813
|
-
import { CodeAnalyzer } from '../src/mcp/handlers/analysis/code-quality-check.js';
|
|
814
|
-
|
|
815
|
-
async function generatePropertyBasedTests(modulePath) {
|
|
816
|
-
// Step 1: Analyze code for property candidates
|
|
817
|
-
console.log('Analyzing code for property-based testing opportunities...');
|
|
818
|
-
const codeAnalyzer = new CodeAnalyzer(registry, hookExecutor);
|
|
819
|
-
|
|
820
|
-
const analysisResult = await codeAnalyzer.handle({
|
|
821
|
-
filePath: modulePath,
|
|
822
|
-
analysisTypes: ['complexity', 'dependencies', 'patterns']
|
|
823
|
-
});
|
|
824
|
-
|
|
825
|
-
// Step 2: Identify pure functions (good candidates for property testing)
|
|
826
|
-
const pureFunctions = analysisResult.data.functions.filter(f =>
|
|
827
|
-
f.isPure && f.complexity < 10
|
|
828
|
-
);
|
|
829
|
-
|
|
830
|
-
console.log(`Found ${pureFunctions.length} candidates for property-based testing`);
|
|
831
|
-
|
|
832
|
-
// Step 3: Generate property tests for each function
|
|
833
|
-
const propertyTests = [];
|
|
834
|
-
for (const func of pureFunctions) {
|
|
835
|
-
const testSpec = {
|
|
836
|
-
type: 'property-based',
|
|
837
|
-
sourceCode: {
|
|
838
|
-
repositoryUrl: modulePath,
|
|
839
|
-
branch: 'main',
|
|
840
|
-
language: 'javascript'
|
|
841
|
-
},
|
|
842
|
-
frameworks: ['jest', 'fast-check'],
|
|
843
|
-
targetFunction: func.name,
|
|
844
|
-
properties: inferProperties(func), // Infer mathematical properties
|
|
845
|
-
coverageTarget: 95
|
|
846
|
-
};
|
|
847
|
-
|
|
848
|
-
const result = await testGenerator.handle({ spec: testSpec });
|
|
849
|
-
propertyTests.push(result.data);
|
|
850
|
-
}
|
|
851
|
-
|
|
852
|
-
return propertyTests;
|
|
853
|
-
}
|
|
854
|
-
|
|
855
|
-
function inferProperties(func) {
|
|
856
|
-
// Infer properties based on function signature and name
|
|
857
|
-
const properties = [];
|
|
858
|
-
|
|
859
|
-
if (func.name.includes('sort')) {
|
|
860
|
-
properties.push('idempotence', 'ordering', 'length-preservation');
|
|
861
|
-
}
|
|
862
|
-
if (func.name.includes('reverse')) {
|
|
863
|
-
properties.push('involution', 'length-preservation');
|
|
864
|
-
}
|
|
865
|
-
if (func.returnType === func.parameters[0]?.type) {
|
|
866
|
-
properties.push('same-type');
|
|
867
|
-
}
|
|
868
|
-
|
|
869
|
-
return properties;
|
|
870
|
-
}
|
|
871
|
-
```
|
|
872
|
-
|
|
873
|
-
### Workflow 3: Integration with Coverage Analyzer
|
|
874
|
-
|
|
875
|
-
```javascript
|
|
876
|
-
import { CoverageAnalyzeHandler } from '../src/mcp/handlers/analysis/coverage-analyze.js';
|
|
877
|
-
|
|
878
|
-
async function generateTestsForCoverageGaps(projectPath) {
|
|
879
|
-
const coverageAnalyzer = new CoverageAnalyzeHandler(registry, hookExecutor);
|
|
880
|
-
|
|
881
|
-
// Step 1: Run coverage analysis
|
|
882
|
-
console.log('Analyzing coverage gaps...');
|
|
883
|
-
const coverageResult = await coverageAnalyzer.handle({
|
|
884
|
-
projectPath,
|
|
885
|
-
thresholds: { statements: 80, branches: 75, functions: 85 },
|
|
886
|
-
includePatterns: ['src/**/*.js', 'lib/**/*.js']
|
|
887
|
-
});
|
|
888
|
-
|
|
889
|
-
// Step 2: Prioritize gaps by criticality
|
|
890
|
-
const criticalGaps = coverageResult.data.uncoveredFiles
|
|
891
|
-
.filter(f => f.coverage.statements < 50)
|
|
892
|
-
.sort((a, b) => a.coverage.statements - b.coverage.statements);
|
|
893
|
-
|
|
894
|
-
console.log(`Found ${criticalGaps.length} critical coverage gaps`);
|
|
895
|
-
|
|
896
|
-
// Step 3: Generate tests for critical gaps
|
|
897
|
-
for (const gap of criticalGaps) {
|
|
898
|
-
console.log(`Generating tests for ${gap.path} (${gap.coverage.statements}% coverage)`);
|
|
899
|
-
|
|
900
|
-
const testSpec = {
|
|
901
|
-
type: 'unit',
|
|
902
|
-
sourceCode: {
|
|
903
|
-
repositoryUrl: projectPath,
|
|
904
|
-
branch: 'main',
|
|
905
|
-
language: 'javascript'
|
|
906
|
-
},
|
|
907
|
-
frameworks: ['jest'],
|
|
908
|
-
targetFiles: [gap.path],
|
|
909
|
-
targetLines: gap.uncoveredLines,
|
|
910
|
-
coverageTarget: 80,
|
|
911
|
-
synthesizeData: true
|
|
912
|
-
};
|
|
913
|
-
|
|
914
|
-
const result = await testGenerator.handle({ spec: testSpec });
|
|
915
|
-
|
|
916
|
-
// Verify coverage improvement
|
|
917
|
-
const newCoverage = await coverageAnalyzer.handle({
|
|
918
|
-
projectPath,
|
|
919
|
-
fileFilter: gap.path
|
|
920
|
-
});
|
|
921
|
-
|
|
922
|
-
const improvement = newCoverage.data.coverage.statements - gap.coverage.statements;
|
|
923
|
-
console.log(` Coverage improved by ${improvement}%`);
|
|
924
|
-
}
|
|
925
|
-
}
|
|
926
|
-
```
|
|
927
|
-
|
|
928
|
-
### Workflow 4: Error Handling Patterns
|
|
929
|
-
|
|
930
|
-
```javascript
|
|
931
|
-
// Pattern 1: Retry with exponential backoff
|
|
932
|
-
async function generateTestsWithRetry(testSpec, maxRetries = 3) {
|
|
933
|
-
for (let attempt = 1; attempt <= maxRetries; attempt++) {
|
|
934
|
-
try {
|
|
935
|
-
return await testGenerator.handle({ spec: testSpec });
|
|
936
|
-
} catch (error) {
|
|
937
|
-
if (attempt < maxRetries) {
|
|
938
|
-
const delay = Math.pow(2, attempt) * 1000;
|
|
939
|
-
console.log(`Attempt ${attempt} failed, retrying in ${delay}ms...`);
|
|
940
|
-
await new Promise(resolve => setTimeout(resolve, delay));
|
|
941
|
-
} else {
|
|
942
|
-
throw error;
|
|
943
|
-
}
|
|
944
|
-
}
|
|
945
|
-
}
|
|
946
|
-
}
|
|
947
|
-
|
|
948
|
-
// Pattern 2: Fallback to simpler test generation
|
|
949
|
-
async function generateTestsWithFallback(testSpec) {
|
|
950
|
-
try {
|
|
951
|
-
// Try advanced property-based generation
|
|
952
|
-
return await testGenerator.handle({
|
|
953
|
-
spec: { ...testSpec, type: 'property-based' }
|
|
954
|
-
});
|
|
955
|
-
} catch (error) {
|
|
956
|
-
console.log('Advanced generation failed, falling back to unit tests...');
|
|
957
|
-
return await testGenerator.handle({
|
|
958
|
-
spec: { ...testSpec, type: 'unit' }
|
|
959
|
-
});
|
|
960
|
-
}
|
|
961
|
-
}
|
|
962
|
-
```
|
|
963
|
-
|
|
964
|
-
### Memory Coordination
|
|
965
|
-
|
|
966
|
-
```javascript
|
|
967
|
-
import { MemoryStore } from '../src/memory/MemoryStore.js';
|
|
968
|
-
|
|
969
|
-
const memoryStore = new MemoryStore();
|
|
970
|
-
|
|
971
|
-
// Store test generation results for coordination
|
|
972
|
-
await memoryStore.store('aqe/test-generation/results', {
|
|
973
|
-
suiteId: testSuite.id,
|
|
974
|
-
testsGenerated: testSuite.tests.length,
|
|
975
|
-
coverage: testSuite.coverage.achieved,
|
|
976
|
-
timestamp: Date.now()
|
|
977
|
-
}, {
|
|
978
|
-
partition: 'agent_results',
|
|
979
|
-
ttl: 86400 // 24 hours
|
|
980
|
-
});
|
|
981
|
-
|
|
982
|
-
// Retrieve prior test generation patterns
|
|
983
|
-
const patterns = await memoryStore.retrieve('aqe/neural/patterns/test-generation', {
|
|
984
|
-
partition: 'neural'
|
|
985
|
-
});
|
|
986
|
-
```
|
|
987
|
-
|
|
988
|
-
**See also**: `/workspaces/agentic-qe-cf/templates/agent-code-execution-template.md` for complete workflow patterns.
|
|
989
|
-
|
|
990
|
-
## Integration with QE Fleet
|
|
991
|
-
|
|
992
|
-
This agent integrates seamlessly with the Agentic QE Fleet through:
|
|
993
|
-
- **EventBus**: Real-time coordination with other QE agents
|
|
994
|
-
- **MemoryManager**: Persistent storage of test generation patterns
|
|
995
|
-
- **FleetManager**: Lifecycle management and health monitoring
|
|
996
|
-
- **Neural Network**: Continuous learning from test execution results
|
|
997
|
-
- **Sublinear Solver**: Optimization algorithms for efficient test selection
|