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.
93 lines (92 loc) • 2.88 kB
JavaScript
/**
* MVP Consensus Implementation
* Simple majority voting with 2 validators
*/ import { ByzantineConsensusAdapter } from '../byzantine-consensus-adapter.js';
import { Logger } from '../../core/logger.js';
/**
* MVP consensus: Simple 2-validator majority voting
* Threshold: 0.85 (85% agreement)
*/ export class MVPConsensus {
adapter;
logger;
config;
constructor(memoryManager){
this.config = {
threshold: 0.85,
validatorCount: 2,
algorithm: 'simple-majority',
faultTolerance: 0
};
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: 'MVPConsensus'
});
}
/**
* Execute MVP consensus validation
*/ async executeConsensus(votes) {
this.logger.info('Executing MVP consensus', {
totalVotes: votes.length,
expectedValidators: this.config.validatorCount
});
// Validate minimum votes
if (votes.length < this.config.validatorCount) {
this.logger.warn('Insufficient votes for MVP consensus', {
received: votes.length,
required: this.config.validatorCount
});
}
// Validate all votes
const validVotes = votes.filter((v)=>this.validateVote(v));
if (validVotes.length < votes.length) {
this.logger.warn('Invalid votes detected', {
total: votes.length,
valid: validVotes.length
});
}
// Execute Byzantine consensus
const result = await this.adapter.executeConsensus(validVotes);
this.logger.info('MVP consensus complete', {
consensusReached: result.consensusReached,
consensusScore: result.consensusScore
});
return result;
}
/**
* Validate vote structure
*/ validateVote(vote) {
return this.adapter.validateVote(vote);
}
/**
* Get consensus threshold
*/ getThreshold() {
return this.config.threshold;
}
/**
* Get validator count
*/ getValidatorCount() {
return this.config.validatorCount;
}
/**
* Get configuration
*/ getConfig() {
return {
...this.config
};
}
}
export default MVPConsensus;
//# sourceMappingURL=mvp-consensus.js.map