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.
121 lines (120 loc) • 4.05 kB
JavaScript
/**
* Enterprise Planning Consensus (Loop 0.5)
* Architect consensus before Loop 1 execution
*/ import { ByzantineConsensusAdapter } from '../byzantine-consensus-adapter.js';
import { Logger } from '../../core/logger.js';
/**
* Enterprise planning consensus: 3 architects, threshold 0.85
* Validates architecture, security, and system integration before implementation
*/ export class EnterprisePlanningConsensus {
adapter;
logger;
config;
constructor(memoryManager){
this.config = {
threshold: 0.85,
validatorCount: 3,
algorithm: 'byzantine',
faultTolerance: 1
};
this.adapter = new ByzantineConsensusAdapter({
consensusThreshold: this.config.threshold,
validatorCount: this.config.validatorCount,
faultTolerance: this.config.faultTolerance
}, memoryManager);
const loggerConfig = process.env.CLAUDE_FLOW_ENV === 'test' ? {
level: 'error',
format: 'json',
destination: 'console'
} : {
level: 'info',
format: 'json',
destination: 'console'
};
this.logger = new Logger(loggerConfig, {
component: 'EnterprisePlanningConsensus'
});
}
/**
* Execute planning consensus with architects
*/ async executeConsensus(votes) {
this.logger.info('Executing Enterprise planning consensus', {
totalVotes: votes.length,
expectedArchitects: this.config.validatorCount
});
// Validate architect votes
const architectVotes = votes.filter((v)=>this.isArchitectVote(v));
if (architectVotes.length < this.config.validatorCount) {
this.logger.warn('Insufficient architect votes', {
received: architectVotes.length,
required: this.config.validatorCount
});
}
// Execute Byzantine consensus
const baseResult = await this.adapter.executeConsensus(architectVotes);
// Extract recommendations and blockers
const recommendations = [];
const blockers = [];
architectVotes.forEach((vote)=>{
const architectVote = vote;
if (architectVote.recommendations) {
recommendations.push(...architectVote.recommendations);
}
if (architectVote.concerns) {
blockers.push(...architectVote.concerns);
}
});
const result = {
...baseResult,
planningPhase: 'architecture',
architectVotes: architectVotes,
recommendations: [
...new Set(recommendations)
],
blockers: [
...new Set(blockers)
]
};
this.logger.info('Enterprise planning consensus complete', {
consensusReached: result.consensusReached,
consensusScore: result.consensusScore,
recommendations: result.recommendations.length,
blockers: result.blockers.length
});
return result;
}
/**
* Validate vote structure
*/ validateVote(vote) {
return this.adapter.validateVote(vote) && this.isArchitectVote(vote);
}
/**
* Check if vote is from an architect
*/ isArchitectVote(vote) {
const architectVote = vote;
return !!architectVote.architectType && [
'architect',
'system-architect',
'security-specialist'
].includes(architectVote.architectType);
}
/**
* Get consensus threshold
*/ getThreshold() {
return this.config.threshold;
}
/**
* Get validator count
*/ getValidatorCount() {
return this.config.validatorCount;
}
/**
* Get configuration
*/ getConfig() {
return {
...this.config
};
}
}
export default EnterprisePlanningConsensus;
//# sourceMappingURL=enterprise-planning-consensus.js.map