mirror of
https://github.com/proffesor-for-testing/agentic-qe.git
synced 2026-09-19 08:45:47 +08:00
fd2f37eaa0
Changes: - Fix README.md agent counts (48 QE agents = 41 main + 7 subagents) - Fix README.md skill counts (15 QE-specific skills) - Fix v3/README.md agent counts (47 → 48) - Fix init-wizard.ts hooks from 'npx @agentic-qe/v3' to 'npx agentic-qe' - Complete v2 → v2/ folder reorganization (54 items moved) - Update root package.json to point to v3 as main version Verified claims: - 48 QE agents (41 main + 7 TDD subagents) - 15 QE-specific skills - 12 DDD bounded contexts - ~5,600+ tests - HNSW, ReasoningBank, Queen Coordinator features exist Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
226 lines
7.2 KiB
TypeScript
Executable File
226 lines
7.2 KiB
TypeScript
Executable File
#!/usr/bin/env ts-node
|
||
/**
|
||
* End-to-End AgentDB Validation Script
|
||
*
|
||
* Tests that QE agents actually use AgentDB features:
|
||
* 1. Patterns stored in AgentDB (not just JSON flags)
|
||
* 2. Vector embeddings generated
|
||
* 3. Databases populated with real data
|
||
* 4. QUIC sync occurs (if configured)
|
||
*/
|
||
|
||
import { TestGeneratorAgent } from '../src/agents/TestGeneratorAgent';
|
||
import { EventBus } from '../src/core/EventBus';
|
||
import { MemoryManager } from '../src/core/MemoryManager';
|
||
import { AgentId, AgentStatus, TaskAssignment } from '../src/types';
|
||
import { LearningEngine } from '../src/learning/LearningEngine';
|
||
import { AgentDBManager } from '../src/core/memory/AgentDBManager';
|
||
import Database from 'better-sqlite3';
|
||
import * as fs from 'fs';
|
||
import * as path from 'path';
|
||
|
||
async function runE2EValidation() {
|
||
console.log('🧪 AgentDB End-to-End Validation\n');
|
||
console.log('=' .repeat(60));
|
||
|
||
const testDir = path.join(process.cwd(), '.test-agentdb-e2e');
|
||
const dbPath = path.join(testDir, 'test.db');
|
||
|
||
// Cleanup previous test
|
||
if (fs.existsSync(testDir)) {
|
||
fs.rmSync(testDir, { recursive: true });
|
||
}
|
||
fs.mkdirSync(testDir, { recursive: true });
|
||
|
||
try {
|
||
// Step 1: Initialize components
|
||
console.log('\n📦 Step 1: Initializing components...');
|
||
const eventBus = new EventBus();
|
||
const memoryStore = new MemoryManager({
|
||
path: path.join(testDir, 'memory.db'),
|
||
partition: 'test'
|
||
});
|
||
|
||
const learningEngine = new LearningEngine({
|
||
alpha: 0.1,
|
||
gamma: 0.95,
|
||
epsilon: 0.1
|
||
});
|
||
|
||
const agentDB = new AgentDBManager({
|
||
dbPath: path.join(testDir, 'agentdb.db'),
|
||
enableQUICSync: false, // Disable for E2E test
|
||
syncPort: 4433,
|
||
syncPeers: [],
|
||
enableLearning: true,
|
||
enableReasoning: true,
|
||
cacheSize: 1000,
|
||
quantizationType: 'scalar',
|
||
syncInterval: 1000,
|
||
syncBatchSize: 100,
|
||
maxRetries: 3,
|
||
compression: true
|
||
});
|
||
|
||
await agentDB.initialize();
|
||
console.log('✅ Components initialized');
|
||
|
||
// Step 2: Create test agent
|
||
console.log('\n🤖 Step 2: Creating TestGeneratorAgent...');
|
||
const agentId: AgentId = {
|
||
id: 'test-gen-001',
|
||
type: 'qe-test-generator',
|
||
created: new Date()
|
||
};
|
||
|
||
const agent = new TestGeneratorAgent({
|
||
id: agentId,
|
||
capabilities: [
|
||
{ name: 'test-generation', version: '1.0.0', description: 'Generate tests' }
|
||
],
|
||
context: {
|
||
id: agentId.id,
|
||
type: agentId.type,
|
||
status: AgentStatus.IDLE
|
||
},
|
||
memoryStore,
|
||
eventBus,
|
||
enableLearning: true,
|
||
learningConfig: { engine: learningEngine },
|
||
agentDBConfig: {
|
||
dbPath: path.join(testDir, 'agentdb.db'),
|
||
enableQUICSync: false,
|
||
syncPort: 4433,
|
||
syncPeers: [],
|
||
enableLearning: true
|
||
}
|
||
});
|
||
|
||
await agent.initialize();
|
||
console.log('✅ Agent created and initialized');
|
||
|
||
// Step 3: Execute task
|
||
console.log('\n⚙️ Step 3: Executing test generation task...');
|
||
const assignment: TaskAssignment = {
|
||
id: 'task-001',
|
||
agent: agentId,
|
||
type: 'test-generation',
|
||
priority: 1,
|
||
payload: {
|
||
framework: 'jest',
|
||
codeToTest: `
|
||
export class Calculator {
|
||
add(a: number, b: number): number {
|
||
return a + b;
|
||
}
|
||
subtract(a: number, b: number): number {
|
||
return a - b;
|
||
}
|
||
}
|
||
`,
|
||
testType: 'unit'
|
||
},
|
||
dependencies: [],
|
||
createdAt: Date.now()
|
||
};
|
||
|
||
const result = await agent.executeTask(assignment);
|
||
console.log('✅ Task executed successfully');
|
||
console.log(' Generated tests:', result.generatedTests ? 'Yes' : 'No');
|
||
|
||
// Step 4: Verify AgentDB operations
|
||
console.log('\n🔍 Step 4: Verifying AgentDB operations...');
|
||
|
||
// Check if patterns were stored
|
||
const agentdbPath = path.join(testDir, 'agentdb.db');
|
||
if (fs.existsSync(agentdbPath)) {
|
||
const db = new Database(agentdbPath, { readonly: true });
|
||
|
||
try {
|
||
// Check for patterns table
|
||
const tables = db.prepare("SELECT name FROM sqlite_master WHERE type='table'").all();
|
||
console.log(` Tables in AgentDB: ${tables.map((t: any) => t.name).join(', ')}`);
|
||
|
||
// Try to count patterns (table might not exist in mock)
|
||
try {
|
||
const patternCount = db.prepare('SELECT COUNT(*) as count FROM patterns').get() as any;
|
||
console.log(` Patterns stored: ${patternCount.count}`);
|
||
|
||
if (patternCount.count > 0) {
|
||
const sample = db.prepare('SELECT id, confidence FROM patterns LIMIT 3').all() as any[];
|
||
console.log(' Sample patterns:');
|
||
sample.forEach(p => console.log(` - ${p.id}: confidence=${p.confidence}`));
|
||
}
|
||
} catch (e) {
|
||
console.log(' ⚠️ Patterns table not found (expected with mock adapter)');
|
||
}
|
||
|
||
db.close();
|
||
} catch (error) {
|
||
console.log(' ⚠️ Database inspection error:', error);
|
||
}
|
||
} else {
|
||
console.log(' ⚠️ AgentDB database file not found');
|
||
}
|
||
|
||
// Step 5: Check memory store
|
||
console.log('\n💾 Step 5: Checking memory store...');
|
||
const memoryDbPath = path.join(testDir, 'memory.db');
|
||
if (fs.existsSync(memoryDbPath)) {
|
||
const memDb = new Database(memoryDbPath, { readonly: true });
|
||
try {
|
||
const entries = memDb.prepare('SELECT COUNT(*) as count FROM memory_entries').get() as any;
|
||
console.log(` Memory entries: ${entries.count}`);
|
||
|
||
if (entries.count > 0) {
|
||
const samples = memDb.prepare('SELECT key FROM memory_entries LIMIT 5').all() as any[];
|
||
console.log(' Sample keys:');
|
||
samples.forEach(s => console.log(` - ${s.key}`));
|
||
}
|
||
memDb.close();
|
||
} catch (error) {
|
||
console.log(' ⚠️ Memory store inspection error:', error);
|
||
}
|
||
}
|
||
|
||
// Step 6: Verify learning occurred
|
||
console.log('\n🧠 Step 6: Verifying learning system...');
|
||
const qValues = learningEngine.getQValues();
|
||
console.log(` Q-Values learned: ${Object.keys(qValues).length} strategies`);
|
||
if (Object.keys(qValues).length > 0) {
|
||
console.log(' Sample Q-values:');
|
||
Object.entries(qValues).slice(0, 3).forEach(([strategy, value]) => {
|
||
console.log(` - ${strategy}: ${value.toFixed(3)}`));
|
||
});
|
||
}
|
||
|
||
// Cleanup
|
||
await agent.stop();
|
||
await agentDB.shutdown();
|
||
|
||
console.log('\n' + '='.repeat(60));
|
||
console.log('✅ E2E Validation Complete\n');
|
||
|
||
// Summary
|
||
console.log('📊 Summary:');
|
||
console.log(' ✅ Agent initialization: PASS');
|
||
console.log(' ✅ Task execution: PASS');
|
||
console.log(' ✅ Learning system: PASS');
|
||
console.log(' ⚠️ AgentDB population: PARTIAL (mock adapter used)');
|
||
console.log('\n💡 Note: Full AgentDB features require agentic-flow package');
|
||
console.log(' Current test uses mock adapter for validation\n');
|
||
|
||
} catch (error) {
|
||
console.error('\n❌ E2E Validation Failed:', error);
|
||
process.exit(1);
|
||
} finally {
|
||
// Cleanup test directory
|
||
if (fs.existsSync(testDir)) {
|
||
fs.rmSync(testDir, { recursive: true });
|
||
}
|
||
}
|
||
}
|
||
|
||
// Run validation
|
||
runE2EValidation().catch(console.error);
|