cliffy-protocols
Distributed consensus protocols using geometric algebra.
Overview
cliffy-protocols provides distributed systems primitives where conflicts are resolved geometrically. State transformations become geometric operations with closed-form solutions and guaranteed convergence.
Modules
Vector Clock
Causal ordering for distributed events:
use VectorClock;
let mut clock = new;
clock.tick;
clock.tick;
let mut other = new;
other.tick;
// Causal ordering
assert!;
// Merge clocks
let merged = clock.merge;
Geometric CRDT
Conflict-free replicated data types with geometric merge:
use ;
let mut crdt = new;
// Apply operations
crdt.apply_operation;
crdt.apply_operation;
// Merge with another replica
let merged = crdt.merge;
// Conflicts resolved via geometric mean - always converges!
Lattice Operations
Join-semilattice for monotonic state:
use ;
// Component-wise maximum (join)
let joined = lattice_join;
// Component-wise minimum (meet)
let met = lattice_meet;
// Lattice laws hold:
// - Commutative: join(a, b) = join(b, a)
// - Associative: join(join(a, b), c) = join(a, join(b, c))
// - Idempotent: join(a, a) = a
Delta Synchronization
Efficient state sync with minimal bandwidth:
use ;
// Compute difference between states
let delta = compute_delta;
// Apply delta to reconstruct state
let reconstructed = apply_delta;
// Batch multiple deltas
let mut batch = new;
batch.push;
batch.push;
let combined = batch.combine_additive;
Storage
Snapshot + operation log persistence:
use MemoryStore;
let store = new;
// Save snapshots
store.save_snapshot.await;
// Load latest
let snapshot = store.load_latest_snapshot.await;
// Recovery from operation log
let recovered = store.recover.await;
Sync Protocol
P2P synchronization messages:
use SyncState;
let mut sync = new;
// Peer discovery
sync.register_peer;
// Message handling
let hello = sync.create_hello;
let response = sync.handle_message;
// Delta requests
let request = sync.create_delta_request;
Geometric Consensus
Distributed agreement via geometric mean:
use GeometricConsensus;
let mut consensus = new;
// Propose value
let round = consensus.propose;
// Receive proposals from others
consensus.receive_proposal;
// Vote
consensus.vote;
// Commit when majority reached
if let Some = consensus.try_commit
The Geometric Insight
All conflict resolution uses geometric algebra:
- State changes = rotors/versors (geometric transformations)
- Conflicts = geometric distance from expected manifold
- Resolution = geometric mean (closed-form, always converges)
- Composition = geometric product (associative)
This means no ad-hoc conflict resolution logic - just geometry.
Integration with Leptos
Build collaborative apps with Leptos and geometric CRDTs:
use *;
use ;
Integration with Yew
Real-time sync in Yew applications:
use *;
use ;
use Interval;
License
MIT