sheaf-gossip
Bridging sheaf cohomology to room gossip protocols.
When H¹ ≠ 0, rooms know they disagree and need reconciliation messages. Sheaf obstructions drive the gossip schedule.
Core Idea
In a distributed system of rooms (nodes) connected by edges (shared agents/passages), each room maintains a local sheaf section — a vector of data. The question: do these local views glue into a consistent global state?
The answer lives in sheaf cohomology. When the first cohomology group H¹ is non-trivial, local sections conflict on overlaps — the system is inconsistent. The magnitude of the obstruction quantifies how badly they disagree.
This library computes that obstruction and uses it to drive a gossip reconciliation protocol:
- Detect — Compute H¹ obstruction from local sections and the room graph.
- Schedule — Higher obstruction → more aggressive gossip (t-minus campaign topology).
- Reconcile — Averaging, weighted merge, or majority vote to reduce H¹ each round.
- Converge — H¹ → 0 under sufficient connectivity, at a rate governed by the spectral gap of the room graph's Laplacian.
Modules
| Module | Purpose |
|---|---|
sheaf_state |
Local sheaf sections per room: data vectors and restriction maps. |
obstruction |
Compute H¹ obstruction: quantify mismatches at overlaps. |
gossip_schedule |
Schedule reconciliation messages from obstruction magnitude. |
reconcile |
Reconciliation protocols: averaging, weighted merge, majority vote. |
convergence |
Track convergence; spectral gap predicts speed. |
room_graph |
Room connectivity graph; Laplacian eigenvalues. |
Core Types
Quick Start
use *;
// Define rooms and their data
let sections = new;
// Define connectivity
let graph = new;
// Compute obstruction (H¹)
let obs = compute_direct_obstruction;
println!;
// Schedule gossip
let schedule = schedule_from_obstruction;
println!;
// Reconcile
let mut sections = sections;
let result = reconcile;
println!;
Mathematical Background
Sheaf Cohomology
A sheaf assigns data to each open set (room) with restriction maps between them. Given a covering of rooms connected by overlaps (edges), local sections s_i ∈ F(U_i) are consistent when they agree on overlaps:
s_i|_{U_i ∩ U_j} = s_j|_{U_i ∩ U_j} for all i, j
When this fails, the obstruction lives in H¹ — the first Čech cohomology group.
Gossip Convergence
The reconciliation protocol is a consensus iteration on the room graph. Each round, rooms blend their data with neighbors. The convergence rate is governed by the spectral gap (λ₂ of the graph Laplacian):
- Connected graph: λ₂ > 0 → consensus reached, H¹ → 0
- Disconnected graph: λ₂ = 0 → global consensus impossible
- Higher spectral gap → faster convergence
For averaging with weight w, the convergence rate is approximately:
rate ≈ 1 - (1 - w · λ₂/N)^rounds
Reconciliation Strategies
| Strategy | Best For | Mechanism |
|---|---|---|
| Averaging | Continuous data | Blend with neighbors: x_new = (1-w)·x + w·x̄_neighbors |
| WeightedMerge | Heterogeneous bandwidth | Weight by edge weights |
| MajorityVote | Discrete/categorical | Snap to most common value within tolerance |
Testing
38 tests covering:
- Trivial H¹ = 0 (single room, consistent rooms)
- H¹ > 0 detection (conflicting data)
- Gossip round reduces H¹
- Convergence in bounded rounds for connected graphs
- Spectral gap predicts convergence speed
- Disconnected graphs: no global reconciliation
- Full pipeline: sections → obstruction → schedule → reconcile → converge
License
MIT