claude-flow-novice
Version:
Claude Flow Novice - Advanced orchestration platform for multi-agent AI workflows with CFN Loop architecture Includes Local RuVector Accelerator and all CFN skills for complete functionality.
211 lines (172 loc) ⢠7.22 kB
text/typescript
/**
* Standalone North Star E2E Test Runner
* Shows full console output of the 5-iteration CFN Loop simulation
*/
import {
Orchestrator,
type OrchestrationConfig,
} from './src/orchestrate';
async function runNorthStarTest() {
const taskId = `north-star-e2e-${Date.now()}`;
const config: OrchestrationConfig = {
taskId,
mode: 'standard',
maxIterations: 5,
loop3Agents: ['typescript-specialist', 'tester'],
loop2Agents: ['code-reviewer', 'security-specialist'],
productOwner: 'product-owner',
successCriteriaEnabled: true,
};
console.log('š North Star E2E Test Starting');
console.log('Task ID:', taskId);
console.log('Mode:', config.mode);
console.log('Max Iterations:', config.maxIterations);
console.log('āāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāā\n');
const orchestrator = new Orchestrator(config);
// Track all iterations
const iterationResults: Array<{
iteration: number;
gatePass: boolean;
passRate: number;
consensus?: number;
decision?: string;
}> = [];
// Simulate 5 iterations
for (let iteration = 1; iteration <= 5; iteration++) {
console.log(`\nš Iteration ${iteration}/5`);
console.log('āāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāā');
// Phase 1: Context Injection
console.log(' ā
Context injected');
// Phase 2: Loop 3 Agent Spawning
const loop3Agents = config.loop3Agents || [];
console.log(` ā
Loop 3 spawned (${loop3Agents.length} agents: ${loop3Agents.join(', ')})`);
// Phase 3: Test Execution
// Simulate progressive improvement: iterations get better over time
const basePassRate = 0.70 + (iteration * 0.06); // 0.76, 0.82, 0.88, 0.94, 1.00
const passRate = Math.min(basePassRate, 1.0);
// Test execution simulation
const testsPassed = Math.floor(passRate * 20);
const testsFailed = Math.ceil((1 - passRate) * 20);
console.log(` ā
Tests executed (${testsPassed}/${testsPassed + testsFailed} passed, pass rate: ${passRate.toFixed(2)})`);
// Phase 4: Gate Check
const gateThreshold = 0.95; // Standard mode
const gatePass = passRate >= gateThreshold;
if (!gatePass) {
console.log(` ā Gate check failed (${passRate.toFixed(2)} < ${gateThreshold})`);
console.log(' ā» Retrying iteration...');
iterationResults.push({
iteration,
gatePass: false,
passRate,
});
continue;
}
console.log(` ā
Gate check passed (${passRate.toFixed(2)} >= ${gateThreshold})`);
// Phase 5: Loop 2 Validator Spawning
const loop2Agents = config.loop2Agents || [];
console.log(` ā
Loop 2 spawned (${loop2Agents.length} validators: ${loop2Agents.join(', ')})`);
// Phase 6: Consensus Calculation
// Simulate validator scores with progressive improvement
const baseConsensus = 0.85 + (iteration * 0.03); // 0.88, 0.91, 0.94, 0.97, 1.00
const validatorScores = loop2Agents.map((agent) => ({
agent,
score: Math.min(baseConsensus + (Math.random() * 0.02 - 0.01), 1.0), // Small variance around base
}));
const consensus = validatorScores.reduce((sum, v) => sum + v.score, 0) / validatorScores.length;
console.log(` ā
Consensus: ${consensus.toFixed(2)}`);
validatorScores.forEach(v => {
console.log(` - ${v.agent}: ${v.score.toFixed(2)}`);
});
// Phase 7: Consensus Check
const consensusThreshold = 0.90; // Standard mode
const consensusPass = consensus >= consensusThreshold;
if (!consensusPass) {
console.log(` ā Consensus failed (${consensus.toFixed(2)} < ${consensusThreshold})`);
console.log(' ā» Retrying iteration...');
iterationResults.push({
iteration,
gatePass: true,
passRate,
consensus,
decision: 'ITERATE',
});
continue;
}
console.log(` ā
Consensus passed (${consensus.toFixed(2)} >= ${consensusThreshold})`);
// Phase 8: Product Owner Decision
// PROCEED if both gate and consensus are strong (>= 0.95 for standard mode)
const decision = (passRate >= 0.95 && consensus >= 0.95) ? 'PROCEED' : 'ITERATE';
console.log(` ā
Product Owner: ${decision}`);
// Phase 9: Deliverable Verification
if (decision === 'PROCEED') {
console.log(' ā
Deliverables verified');
iterationResults.push({
iteration,
gatePass: true,
passRate,
consensus,
decision,
});
// Success - exit loop
console.log('\nā
CFN Loop Complete: PROCEED');
break;
} else {
iterationResults.push({
iteration,
gatePass: true,
passRate,
consensus,
decision,
});
console.log(' ā» Iterating for improvements...');
}
}
// Final Summary
console.log('\nāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāā');
console.log('š Iteration Summary');
console.log('āāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāā\n');
iterationResults.forEach(result => {
console.log(`Iteration ${result.iteration}:`);
console.log(` Pass Rate: ${result.passRate.toFixed(2)}`);
console.log(` Gate: ${result.gatePass ? 'PASS' : 'FAIL'}`);
if (result.consensus) {
console.log(` Consensus: ${result.consensus.toFixed(2)}`);
}
if (result.decision) {
console.log(` Decision: ${result.decision}`);
}
console.log('');
});
// Validation
const gatePassCount = iterationResults.filter(r => r.gatePass).length;
const finalIteration = iterationResults[iterationResults.length - 1];
console.log('ā
North Star E2E Test Complete');
console.log(` Total Iterations: ${iterationResults.length}`);
console.log(` Gate Passes: ${gatePassCount}`);
console.log(` Final Decision: ${finalIteration?.decision || 'ITERATE'}`);
console.log('');
// Verify orchestrator was properly initialized
console.log('š Orchestrator Validation:');
console.log(` Task ID: ${orchestrator.getTaskId()}`);
console.log(` Mode: ${orchestrator.getMode()}`);
console.log(` Max Iterations: ${orchestrator.getMaxIterations()}`);
return {
success: true,
iterations: iterationResults.length,
gatePasses: gatePassCount,
finalDecision: finalIteration?.decision,
};
}
// Run the test
runNorthStarTest()
.then(result => {
console.log('\nāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāā');
console.log('ā
Test Execution Complete');
console.log('āāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāā');
process.exit(0);
})
.catch(error => {
console.error('\nā Test Failed:', error);
process.exit(1);
});