v3/docs/adr/ADR-334-hierarchical-consensus-topology.md
Status: Proposed Date: 2026-05-29 Authors: claude (dream-cycle agent, 2026-05-29) Issue: ruvnet/ruflo#TBD Related: ADR-103 (witness temporal history), ADR-104 (federation wire transport)
Ruflo's hive-mind currently uses flat Raft consensus: one leader, N workers, O(N²) message complexity in the worst case. The configured maximum is 8 agents (CLAUDE.md anti-drift default). This ceiling is a product of the protocol, not the hardware.
The 2026 research literature has converged on two complementary improvements:
SWARM+ (arXiv:2603.19431, March 2026, Grade A): Adapts PBFT for distributed workload management via a two-tier hierarchy — a small coordinator group (3-5 nodes) runs Byzantine-tolerant consensus among themselves, then delegates shards of the task space to worker clusters that use lightweight crash-fault Raft internally. Benchmarked at 1,000 agents with 97-98% scheduling latency improvement over flat baseline and ≤7.5% degradation under 50% agent failure.
SwarmHarness (arXiv May 2026, Grade A): Introduces Shapley-value credit attribution so individual skill nodes are weighted by marginal contribution to recent task outcomes. Without this, flat consensus treats all agents as equivalent — a low-quality agent can veto or slow progress on the same footing as a high-quality one.
Ruflo has no mechanism for either. Adding more than 8 agents today will not improve throughput; it may degrade it due to Raft leader bottleneck.
Adopt a two-tier hierarchical consensus topology for hive-mind swarms with agentCount > 20:
queen-coordinator logic.The existing 8-agent flat Raft path remains unchanged for agentCount ≤ 20 (no regression).
Positive:
Negative:
@claude-flow/cli hive-mind module (~400 LOC addition)Neutral:
maxAgents: 8 CLAUDE.md default remains correct for anti-drift coding swarmsTarget file: v3/@claude-flow/cli/src/hive-mind/consensus/hierarchical-topology.ts
Coordinator tier: reuse RaftManager (existing). Shard tier: new ShardCluster class with ShardLeader role. Credit vector: CreditTracker using banzhee/sampling approximation to avoid O(2^N) Shapley computation.
Threshold config key: hiveMind.hierarchicalThreshold (default: 20). Expose as --hierarchical-threshold N CLI flag on swarm init.
v3/docs/research/dream-cycle-2026-05-29-swarm.md