bft-consensus-patternslisted
Install: claude install-skill phamlongh230-lgtm/yamtam-engine
# Byzantine Fault Tolerant Consensus
A swarm of 87 agents can tolerate up to 28 simultaneous compromised agents (f = ⌊(N-1)/3⌋) if decisions require 2f+1 votes.
## When to Use
- Critical operations that no single agent should decide unilaterally (rule changes, deploys, key rotation)
- Detecting when a minority of agents have been compromised or are producing incorrect output
- Dual-verification of important task results (two agents must agree before result is accepted)
- Enforcing quorum requirements before high-privilege Swarm Bus commands
## Do NOT use for
- Routine read-only operations (overhead not worth it for non-critical tasks)
- Single-agent systems or development environments
## BFT Voting via SwarmRouter
```js
import { SwarmRouter } from 'core/bus/swarm-router.js';
const router = new SwarmRouter();
// Register voters
['auditor-1', 'auditor-2', 'auditor-3', 'orch-1', 'orch-2'].forEach(id =>
router.register(id, { role: 'auditor', trustScore: 90 })
);
// Propose a critical change
async function proposeChange(proposerId, change) {
const QUORUM = 3;
const votes = await Promise.allSettled(
[...router.agents.keys()]
.filter(id => id !== proposerId)
.slice(0, 5)
.map(id => router.route({
from: proposerId, to: id,
command: 'VOTE_REQUEST',
payload: { change, fingerprint: router._fingerprint(change) }
}))
);
const yesVotes = votes.filter(v => v.status === 'fulfilled' && v.value.delivered).length;
if (ye