mirror of
https://github.com/ruvnet/ruflo.git
synced 2026-11-23 21:59:14 +09:00
## 🔧 Critical Swarm System Fixes ### Fixed Task File Naming Bug - Tasks were being saved as '[object Object].json' due to TaskId object structure - Now properly extracts task ID string for file naming - Files save correctly as 'task_<id>.json' ### Added Task Timeout Protection - Implemented automatic timeout detection in task execution loop - Tasks that exceed timeout (default 5 minutes) are marked as failed - Prevents swarms from hanging indefinitely on stuck tasks - Agent state properly cleaned up on timeout ### Fixed Target Directory Propagation - Testing tasks were receiving null targetDir, preventing file access - Target directory now extracted from objective description - All tasks inherit targetDir through context - Enhanced extractTargetDirectory to check multiple sources ### Improved Task Dependencies - Fixed taskDependenciesMet to handle both string and TaskId objects - Added convertDependenciesToTaskDependencies for Map structure - Dependencies now properly resolve for sequential task execution ### Auto Strategy Integration - Added missing autoStrategy property and initialization - Proper AutoStrategy instantiation in coordinator constructor - Enables intelligent task decomposition for 'auto' strategy ## 📊 Added Comprehensive Benchmarks ### Benchmark Suite Integration - Added complete Python-based benchmarking tool - Tests 7 strategies across 5 coordination modes - 100% success rate across all test scenarios - Performance metrics: 0.10s - 0.20s execution times ### Real-World Performance Data - Calculator example: 4m 20s total (3 tasks) - Task breakdown: Analysis 29%, Implementation 22%, Testing 48% - Successfully created 6 files with proper directory structure ## 📝 Documentation Updates ### Updated README.md - Added v1.0.50 changelog with critical fixes - Integrated benchmark performance results table - Added real-world timing example - Removed old update notes for clarity - Added dedicated Benchmarks & Performance section ## 🧪 Test Results - Swarm now completes successfully with proper task coordination - All fixes validated in production environment - Task files save with correct names - Testing tasks find implementation files - Swarms exit cleanly after completion 🤖 Generated with [Claude Code](https://claude.ai/code) Co-Authored-By: Claude <noreply@anthropic.com>
191 lines
5.4 KiB
TypeScript
191 lines
5.4 KiB
TypeScript
#!/usr/bin/env ts-node
|
|
|
|
/**
|
|
* Tester Agent Test - Designed for parallel execution
|
|
* This agent tests and validates functionality
|
|
*/
|
|
|
|
export class TesterAgent {
|
|
private agentId: string;
|
|
private startTime: number;
|
|
|
|
constructor(id: string = 'tester-001') {
|
|
this.agentId = id;
|
|
this.startTime = Date.now();
|
|
}
|
|
|
|
async writeUnitTests(component: string): Promise<any> {
|
|
console.log(`[${this.agentId}] Writing unit tests for: ${component}`);
|
|
|
|
await this.simulateWork(1000);
|
|
|
|
const unitTests = {
|
|
framework: 'Jest',
|
|
testCases: Math.floor(Math.random() * 20) + 15,
|
|
coverage: Math.floor(Math.random() * 15) + 85,
|
|
testSuites: [
|
|
`${component}.controller.test.ts`,
|
|
`${component}.service.test.ts`,
|
|
`${component}.validator.test.ts`,
|
|
`${component}.utils.test.ts`
|
|
],
|
|
mockingStrategy: 'Full mocking of external dependencies',
|
|
assertions: Math.floor(Math.random() * 50) + 50,
|
|
edgeCasesCovered: [
|
|
'Null inputs',
|
|
'Empty arrays',
|
|
'Invalid data types',
|
|
'Boundary values',
|
|
'Concurrent access'
|
|
]
|
|
};
|
|
|
|
console.log(`[${this.agentId}] Unit tests created`);
|
|
return {
|
|
agentId: this.agentId,
|
|
duration: Date.now() - this.startTime,
|
|
component,
|
|
unitTests
|
|
};
|
|
}
|
|
|
|
async runIntegrationTests(system: string): Promise<any> {
|
|
console.log(`[${this.agentId}] Running integration tests for: ${system}`);
|
|
|
|
await this.simulateWork(2000);
|
|
|
|
const totalTests = Math.floor(Math.random() * 30) + 20;
|
|
const passedTests = Math.floor(totalTests * 0.9);
|
|
|
|
const integrationResults = {
|
|
totalTests,
|
|
passed: passedTests,
|
|
failed: totalTests - passedTests,
|
|
duration: '3m 45s',
|
|
testScenarios: [
|
|
{ name: 'User login flow', status: 'passed', time: '245ms' },
|
|
{ name: 'Token refresh', status: 'passed', time: '189ms' },
|
|
{ name: 'Concurrent authentication', status: 'passed', time: '567ms' },
|
|
{ name: 'Database failover', status: 'failed', time: '3021ms' },
|
|
{ name: 'API rate limiting', status: 'passed', time: '432ms' }
|
|
],
|
|
coverage: {
|
|
endpoints: '92%',
|
|
scenarios: '87%',
|
|
errorCases: '78%'
|
|
},
|
|
recommendations: [
|
|
'Fix database failover handling',
|
|
'Add more edge case scenarios',
|
|
'Improve error message validation'
|
|
]
|
|
};
|
|
|
|
console.log(`[${this.agentId}] Integration tests completed`);
|
|
return {
|
|
agentId: this.agentId,
|
|
duration: Date.now() - this.startTime,
|
|
system,
|
|
results: integrationResults
|
|
};
|
|
}
|
|
|
|
async runPerformanceTests(endpoint: string): Promise<any> {
|
|
console.log(`[${this.agentId}] Running performance tests for: ${endpoint}`);
|
|
|
|
await this.simulateWork(3000);
|
|
|
|
const performanceResults = {
|
|
endpoint,
|
|
virtualUsers: 1000,
|
|
duration: '5 minutes',
|
|
metrics: {
|
|
avgResponseTime: '145ms',
|
|
p50ResponseTime: '120ms',
|
|
p95ResponseTime: '280ms',
|
|
p99ResponseTime: '450ms',
|
|
maxResponseTime: '1230ms',
|
|
requestsPerSecond: 850,
|
|
errorRate: '0.2%',
|
|
throughput: '12.5 MB/s'
|
|
},
|
|
bottlenecks: [
|
|
'Database connection pooling',
|
|
'JSON serialization overhead'
|
|
],
|
|
recommendations: [
|
|
'Increase connection pool size',
|
|
'Implement response caching',
|
|
'Optimize database queries'
|
|
],
|
|
passedSLA: true
|
|
};
|
|
|
|
console.log(`[${this.agentId}] Performance tests completed`);
|
|
return {
|
|
agentId: this.agentId,
|
|
duration: Date.now() - this.startTime,
|
|
endpoint,
|
|
results: performanceResults
|
|
};
|
|
}
|
|
|
|
async runSecurityTests(component: string): Promise<any> {
|
|
console.log(`[${this.agentId}] Running security tests for: ${component}`);
|
|
|
|
await this.simulateWork(2500);
|
|
|
|
const securityResults = {
|
|
vulnerabilitiesFound: 3,
|
|
criticalIssues: 0,
|
|
highIssues: 1,
|
|
mediumIssues: 2,
|
|
lowIssues: 0,
|
|
testsConducted: [
|
|
'SQL Injection',
|
|
'XSS Attacks',
|
|
'CSRF Protection',
|
|
'Authentication Bypass',
|
|
'Authorization Flaws',
|
|
'Session Management',
|
|
'Input Validation'
|
|
],
|
|
findings: [
|
|
{ type: 'High', issue: 'Weak password policy', recommendation: 'Enforce minimum 12 characters' },
|
|
{ type: 'Medium', issue: 'Missing rate limiting', recommendation: 'Implement API rate limiting' },
|
|
{ type: 'Medium', issue: 'Verbose error messages', recommendation: 'Sanitize error responses' }
|
|
],
|
|
complianceStatus: {
|
|
OWASP: '85%',
|
|
PCI_DSS: 'N/A',
|
|
GDPR: '90%'
|
|
}
|
|
};
|
|
|
|
console.log(`[${this.agentId}] Security tests completed`);
|
|
return {
|
|
agentId: this.agentId,
|
|
duration: Date.now() - this.startTime,
|
|
component,
|
|
results: securityResults
|
|
};
|
|
}
|
|
|
|
private async simulateWork(ms: number): Promise<void> {
|
|
await new Promise(resolve => setTimeout(resolve, ms));
|
|
}
|
|
}
|
|
|
|
// Allow direct execution
|
|
if (require.main === module) {
|
|
const tester = new TesterAgent();
|
|
|
|
Promise.all([
|
|
tester.writeUnitTests('UserAuthentication'),
|
|
tester.runIntegrationTests('Authentication System'),
|
|
tester.runPerformanceTests('/api/v1/authenticate'),
|
|
tester.runSecurityTests('AuthenticationModule')
|
|
]).then(results => {
|
|
console.log('\nTester Agent Results:', JSON.stringify(results, null, 2));
|
|
});
|
|
} |