UNPKG

task-master-neo-sdlc

Version:

Enhanced task management system with Neo SDLC agents and MCP tools for comprehensive, AI-driven software development lifecycle management.

221 lines (185 loc) 6.5 kB
import { KnowledgeGraph } from '../knowledge-graph.js'; import { AgentWorkflowSystem } from '../agent-workflow.js'; import { MonitoringSystem } from '../monitoring.js'; describe('Neo Integration Tests', () => { let graph; let workflow; let monitoring; beforeEach(() => { graph = new KnowledgeGraph(); workflow = new AgentWorkflowSystem(graph); monitoring = new MonitoringSystem(graph); }); describe('Workflow Execution with Monitoring', () => { beforeEach(async () => { await monitoring.initialize({ thresholds: { workflow_quality: 0.8 } }); workflow.registerAgent({ id: 'agent-1', capabilities: ['testing'], knowledgeDomains: ['jest'] }); }); it('should track workflow execution metrics', async () => { // Create and execute workflow await workflow.createWorkflow({ id: 'workflow-1', steps: [{ id: 'test', type: 'testing', requiredCapabilities: ['testing'] }] }); await workflow.assignStep('workflow-1', 0, 'agent-1'); await workflow.completeStep('workflow-1', 0, { data: 'test passed', quality: 0.9 }); // Verify metrics are tracked const snapshot = await monitoring.takeSnapshot(); expect(snapshot.metrics.workflow_quality).toBeGreaterThan(0.8); // Check knowledge graph updates const context = await graph.getContext('workflow-1'); expect(context.status).toBe('completed'); expect(context.connected.completed_by[0].id).toBe('agent-1'); }); it('should generate alerts for quality issues', async () => { await workflow.createWorkflow({ id: 'workflow-2', steps: [{ id: 'test', type: 'testing', requiredCapabilities: ['testing'] }] }); await workflow.assignStep('workflow-2', 0, 'agent-1'); await workflow.completeStep('workflow-2', 0, { data: 'test failed', quality: 0.7 }); const snapshot = await monitoring.takeSnapshot(); const violations = await monitoring.checkThresholds(snapshot.metrics); expect(violations).toHaveLength(1); expect(violations[0].metric).toBe('workflow_quality'); const alerts = await monitoring.getActiveAlerts(); expect(alerts).toHaveLength(1); expect(alerts[0].type).toBe('workflow'); expect(alerts[0].severity).toBe('warning'); }); }); describe('Agent Performance Analysis', () => { beforeEach(async () => { await monitoring.initialize(); workflow.registerAgent({ id: 'agent-1', capabilities: ['testing', 'documentation'] }); workflow.registerAgent({ id: 'agent-2', capabilities: ['testing'] }); }); it('should track agent metrics across workflows', async () => { // Execute multiple workflows for (let i = 1; i <= 3; i++) { await workflow.createWorkflow({ id: `workflow-${i}`, steps: [{ id: 'test', type: 'testing', requiredCapabilities: ['testing'] }] }); const agent = i % 2 === 0 ? 'agent-2' : 'agent-1'; await workflow.assignStep(`workflow-${i}`, 0, agent); await workflow.completeStep(`workflow-${i}`, 0, { data: 'completed', quality: 0.9 }); } // Verify agent metrics const agent1Status = await workflow.getAgentStatus('agent-1'); const agent2Status = await workflow.getAgentStatus('agent-2'); expect(agent1Status.metrics.tasksCompleted).toBe(2); expect(agent2Status.metrics.tasksCompleted).toBe(1); // Check knowledge graph relationships const agent1Context = await graph.getContext('agent-1'); expect(agent1Context.connected.completed_by).toHaveLength(2); }); it('should analyze agent performance trends', async () => { // Create workflow history for (let i = 1; i <= 2; i++) { await workflow.createWorkflow({ id: `workflow-${i}`, steps: [{ id: 'test', type: 'testing', requiredCapabilities: ['testing'] }] }); await workflow.assignStep(`workflow-${i}`, 0, 'agent-1'); await workflow.completeStep(`workflow-${i}`, 0, { data: 'completed', quality: i === 1 ? 0.8 : 0.9 }); await monitoring.takeSnapshot(); } const report = await monitoring.getMetricsReport(); expect(report.trends.quality.direction).toBe('improving'); const analysis = await graph.analyzeContext('agent-1'); expect(analysis.metrics.successRate).toBe(1); expect(analysis.recommendations).toBeDefined(); }); }); describe('Error Handling and Recovery', () => { beforeEach(async () => { await monitoring.initialize(); workflow.registerAgent({ id: 'agent-1', capabilities: ['testing'] }); workflow.registerAgent({ id: 'agent-2', capabilities: ['testing'] }); }); it('should handle and recover from step failures', async () => { await workflow.createWorkflow({ id: 'workflow-1', steps: [{ id: 'test', type: 'testing', requiredCapabilities: ['testing'] }] }); // Initial failure await workflow.assignStep('workflow-1', 0, 'agent-1'); await workflow.handleStepFailure('workflow-1', 0, new Error('Test failed'), { retry: true } ); // Verify alert created let alerts = await monitoring.getActiveAlerts(); expect(alerts).toHaveLength(1); expect(alerts[0].type).toBe('workflow'); expect(alerts[0].severity).toBe('error'); // Successful retry await workflow.assignStep('workflow-1', 0, 'agent-2'); await workflow.completeStep('workflow-1', 0, { data: 'retry succeeded', quality: 0.85 }); // Verify alert resolved alerts = await monitoring.getActiveAlerts(); expect(alerts).toHaveLength(0); const alertHistory = await monitoring.getAlertHistory(); expect(alertHistory[0].status).toBe('resolved'); // Check final state const context = await graph.getContext('workflow-1'); expect(context.status).toBe('completed'); expect(context.data.retries).toBe(1); }); }); });