Skip to main content

cliffy_protocols/
lib.rs

1//! Distributed consensus protocols using geometric algebra
2//!
3//! This crate provides CRDT, consensus, and synchronization implementations
4//! using Clifford algebra for coordination-free distributed systems.
5//!
6//! # Key Components
7//!
8//! ## State Management
9//! - [`GeometricCRDT`]: Operation-based CRDT with geometric transforms
10//! - [`GeometricLattice`](lattice::GeometricLattice): Trait for lattice-based conflict resolution
11//! - [`VectorClock`]: Causal ordering for distributed operations
12//!
13//! ## Consensus
14//! - [`GeometricConsensus`]: Consensus protocol using geometric mean
15//!
16//! ## Synchronization (Phase 3)
17//! - [`delta`]: State delta computation for efficient sync
18//! - [`sync`]: P2P synchronization protocol
19//! - [`storage`]: Persistence layer with snapshots and operation logs
20//!
21//! # Example
22//!
23//! ```rust
24//! use cliffy_protocols::{GeometricCRDT, OperationType};
25//! use cliffy_core::GA3;
26//! use uuid::Uuid;
27//!
28//! let node_id = Uuid::new_v4();
29//! let mut crdt = GeometricCRDT::new(node_id, GA3::scalar(0.0));
30//!
31//! // Apply a geometric transformation
32//! let op = crdt.create_operation(GA3::scalar(5.0), OperationType::Addition);
33//! crdt.apply_operation(op);
34//! ```
35
36use cliffy_core::GA3;
37
38// Phase 2: Core CRDT and consensus
39pub mod consensus;
40pub mod crdt;
41pub mod lattice;
42pub mod serde_ga3;
43pub mod vector_clock;
44
45// Phase 3: Synchronization layer
46pub mod delta;
47pub mod storage;
48pub mod sync;
49
50// Re-exports
51pub use consensus::*;
52pub use crdt::*;
53pub use delta::{
54    apply_additive_delta, apply_delta, compute_delta, DeltaBatch, DeltaEncoding, StateDelta,
55};
56pub use lattice::{ComponentLattice, GA3Lattice, GeometricLattice};
57pub use storage::{GeometricStore, MemoryStore, Snapshot, StorageStats};
58pub use sync::{
59    PeerCapabilities, PeerConnectionState, PeerInfo, PeerState, SyncConfig, SyncMessage,
60    SyncPayload, SyncState,
61};
62pub use vector_clock::*;
63
64/// Type alias for the default multivector type used in protocols
65pub type ProtocolMultivector = GA3;