Files
proffesor-for-testing__agen…/tests/phase3/generate-test-data.js
Profa b91627f282 fix(quality): implement GOAP Issue #149 code quality remediation
Phase 1: Test Determinism
- Create SeededRandom utility with Mulberry32 PRNG (src/utils/SeededRandom.ts)
- Migrate 258+ Math.random() calls to SeededRandom across 65+ test files
- Add timer test utilities (tests/helpers/timerTestUtils.ts)
- Add jest.useFakeTimers() pattern to 13 test files

Phase 2: Type Safety (63.5% reduction)
- Reduce `any` types from ~1,800 to 656
- Add 50+ new interfaces across agents, core, mcp, cli modules
- Fix all TypeScript errors (0 errors, build passes)
- Replace Record<string, any> with Record<string, unknown>
- Add proper type guards for hook methods (PostTaskData, TaskErrorData)

Key improvements:
- agents/: 105 → 0 any types (100% reduction)
- mcp/: 226 → 102 any types (55% reduction)
- cli/: 277 → 168 any types (39% reduction)
- core/: 199 → 175 any types (12% reduction)

Closes #149

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
2025-12-27 17:08:12 +00:00

73 lines
2.7 KiB
JavaScript
Raw Permalink Blame History

This file contains invisible Unicode characters
This file contains invisible Unicode characters that are indistinguishable to humans but may be processed differently by a computer. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
#!/usr/bin/env node
/**
* Generate test data for Phase 3 visualization testing
*/
const { EventStore } = require('../../dist/persistence/event-store.js');
const { ReasoningStore } = require('../../dist/persistence/reasoning-store.js');
const { createSeededRandom } = require('../../src/utils/SeededRandom');
const rng = createSeededRandom(26000);
async function generateTestData() {
console.log('📊 Generating test data for Phase 3 visualization...\n');
// Initialize stores
const eventStore = new EventStore({ dbPath: './data/agentic-qe.db' });
const reasoningStore = new ReasoningStore({ dbPath: './data/agentic-qe.db' });
const sessionId = 'test-session-' + Date.now();
const agents = ['qe-test-generator', 'qe-coverage-analyzer', 'qe-api-tester', 'qe-perf-tester'];
const eventTypes = ['test_generated', 'coverage_analyzed', 'test_executed', 'performance_tested'];
console.log(`Session ID: ${sessionId}`);
console.log(`Generating events for ${agents.length} agents...\n`);
// Generate events for each agent
for (let i = 0; i < 20; i++) {
const agent = agents[i % agents.length];
const eventType = eventTypes[i % eventTypes.length];
const event = eventStore.recordEvent({
session_id: sessionId,
agent_id: agent,
event_type: eventType,
payload: {
test_count: Math.floor(rng.random() * 100),
coverage: Math.floor(rng.random() * 100),
duration_ms: Math.floor(rng.random() * 5000),
status: i % 5 === 0 ? 'error' : 'completed',
metadata: {
iteration: i + 1,
total_iterations: 20
}
}
});
console.log(`✅ Event ${i + 1}/20: ${agent} - ${eventType}`);
}
// Skip reasoning chains for now - focusing on event data
console.log('\n⏭️ Skipping reasoning chains (not required for visualization test)\n');
// Get statistics
const eventStats = eventStore.getStatistics();
const reasoningStats = reasoningStore.getStatistics();
console.log('\n📈 Statistics:');
console.log(` Total Events: ${eventStats.totalEvents}`);
console.log(` Unique Agents: ${eventStats.uniqueAgents}`);
console.log(` Unique Sessions: ${eventStats.uniqueSessions}`);
console.log(` Total Chains: ${reasoningStats.totalChains}`);
console.log(` Total Steps: ${reasoningStats.totalSteps}`);
console.log(` Avg Steps/Chain: ${reasoningStats.avgStepsPerChain}`);
console.log('\n✅ Test data generated successfully!');
console.log(`\nTest the APIs:`);
console.log(` curl http://localhost:3001/api/visualization/events`);
console.log(` curl http://localhost:3001/api/visualization/metrics`);
console.log(` curl http://localhost:3001/api/visualization/sessions/${sessionId}`);
}
generateTestData().catch(console.error);