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>
121 lines
3.7 KiB
TypeScript
121 lines
3.7 KiB
TypeScript
#!/usr/bin/env ts-node
|
|
|
|
/**
|
|
* Analyzer Agent Test - Designed for parallel execution
|
|
* This agent analyzes data and generates insights independently
|
|
*/
|
|
|
|
export class AnalyzerAgent {
|
|
private agentId: string;
|
|
private startTime: number;
|
|
|
|
constructor(id: string = 'analyzer-001') {
|
|
this.agentId = id;
|
|
this.startTime = Date.now();
|
|
}
|
|
|
|
async analyzePerformanceMetrics(metrics: any): Promise<any> {
|
|
console.log(`[${this.agentId}] Starting performance analysis...`);
|
|
|
|
// Simulate analysis work
|
|
await this.simulateWork(800);
|
|
|
|
const analysis = {
|
|
avgResponseTime: this.calculateAverage(metrics.response_times || []),
|
|
errorRate: this.calculateErrorRate(metrics.error_counts || {}),
|
|
cpuUsage: this.calculateAverage(metrics.cpu_usage || []),
|
|
memoryUsage: this.calculateAverage(metrics.memory_usage || []),
|
|
recommendations: [
|
|
'Optimize database queries',
|
|
'Implement caching strategy',
|
|
'Scale horizontally during peak hours'
|
|
]
|
|
};
|
|
|
|
console.log(`[${this.agentId}] Performance analysis completed`);
|
|
return {
|
|
agentId: this.agentId,
|
|
duration: Date.now() - this.startTime,
|
|
analysis
|
|
};
|
|
}
|
|
|
|
async analyzeCodeQuality(path: string): Promise<any> {
|
|
console.log(`[${this.agentId}] Analyzing code quality for: ${path}`);
|
|
|
|
await this.simulateWork(600);
|
|
|
|
const qualityMetrics = {
|
|
complexity: Math.floor(Math.random() * 10) + 5,
|
|
maintainability: Math.floor(Math.random() * 30) + 70,
|
|
testCoverage: Math.floor(Math.random() * 40) + 60,
|
|
duplications: Math.floor(Math.random() * 5),
|
|
issues: {
|
|
critical: Math.floor(Math.random() * 3),
|
|
major: Math.floor(Math.random() * 10),
|
|
minor: Math.floor(Math.random() * 20)
|
|
}
|
|
};
|
|
|
|
console.log(`[${this.agentId}] Code quality analysis completed`);
|
|
return {
|
|
agentId: this.agentId,
|
|
duration: Date.now() - this.startTime,
|
|
path,
|
|
metrics: qualityMetrics
|
|
};
|
|
}
|
|
|
|
async analyzeSecurityVulnerabilities(): Promise<any> {
|
|
console.log(`[${this.agentId}] Scanning for security vulnerabilities...`);
|
|
|
|
await this.simulateWork(1000);
|
|
|
|
const vulnerabilities = [
|
|
{ severity: 'high', type: 'SQL Injection', location: 'UserController.ts:45' },
|
|
{ severity: 'medium', type: 'Weak Password Policy', location: 'auth/config.ts:12' },
|
|
{ severity: 'low', type: 'Missing HTTPS redirect', location: 'server.ts:8' }
|
|
];
|
|
|
|
console.log(`[${this.agentId}] Security analysis completed`);
|
|
return {
|
|
agentId: this.agentId,
|
|
duration: Date.now() - this.startTime,
|
|
vulnerabilities,
|
|
riskScore: 6.5
|
|
};
|
|
}
|
|
|
|
private calculateAverage(numbers: number[]): number {
|
|
if (numbers.length === 0) return 0;
|
|
return numbers.reduce((a, b) => a + b, 0) / numbers.length;
|
|
}
|
|
|
|
private calculateErrorRate(errorCounts: Record<string, number>): number {
|
|
const total = Object.values(errorCounts).reduce((a, b) => a + b, 0);
|
|
return total > 0 ? (errorCounts['5xx'] || 0) / total : 0;
|
|
}
|
|
|
|
private async simulateWork(ms: number): Promise<void> {
|
|
await new Promise(resolve => setTimeout(resolve, ms));
|
|
}
|
|
}
|
|
|
|
// Allow direct execution
|
|
if (require.main === module) {
|
|
const analyzer = new AnalyzerAgent();
|
|
const testMetrics = {
|
|
response_times: [245, 312, 198, 580, 225],
|
|
error_counts: { '4xx': 12, '5xx': 3 },
|
|
cpu_usage: [45.2, 52.1, 48.7, 61.3],
|
|
memory_usage: [1024, 1156, 1298, 1402]
|
|
};
|
|
|
|
Promise.all([
|
|
analyzer.analyzePerformanceMetrics(testMetrics),
|
|
analyzer.analyzeCodeQuality('/src/modules/authentication'),
|
|
analyzer.analyzeSecurityVulnerabilities()
|
|
]).then(results => {
|
|
console.log('\nAnalyzer Agent Results:', JSON.stringify(results, null, 2));
|
|
});
|
|
} |