1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
//! # mdcs-core
//!
//! Core CRDT types and traits for the **Carnelia** Merkle-Delta CRDT Store.
//!
//! This crate provides the foundational building blocks for conflict-free
//! replicated data types (CRDTs). Every type implements the [`Lattice`] trait,
//! which models a join-semilattice and guarantees **Strong Eventual Consistency**:
//! all replicas converge to the same state regardless of message order.
//!
//! ## Mathematical Foundation
//!
//! A join-semilattice $(S, \sqcup)$ satisfies three properties:
//!
//! | Property | Definition |
//! |---|---|
//! | **Commutativity** | $a \sqcup b = b \sqcup a$ |
//! | **Associativity** | $(a \sqcup b) \sqcup c = a \sqcup (b \sqcup c)$ |
//! | **Idempotence** | $a \sqcup a = a$ |
//!
//! These guarantees mean that updates can be applied in **any order**, **any
//! number of times**, and the result is always deterministic.
//!
//! ## CRDT Types
//!
//! | Type | Module | Description |
//! |---|---|---|
//! | [`GSet`] | [`gset`] | Grow-only set — elements can only be added |
//! | [`ORSet`] | [`orset`] | Observed-Remove set — add-wins semantics |
//! | [`PNCounter`] | [`pncounter`] | Increment/decrement counter |
//! | [`LWWRegister`] | [`lwwreg`] | Last-Writer-Wins register |
//! | [`MVRegister`] | [`mvreg`] | Multi-Value register — preserves concurrent writes |
//! | [`CRDTMap`] | [`map`] | Composable map with shared causal context |
//!
//! ## Quick Start
//!
//! ```rust
//! use mdcs_core::prelude::*;
//!
//! // Create two replicas of a grow-only set
//! let mut a = GSet::new();
//! let mut b = GSet::new();
//!
//! a.insert(1);
//! b.insert(2);
//!
//! // Merge — order doesn't matter
//! let merged = a.join(&b);
//! assert!(merged.contains(&1));
//! assert!(merged.contains(&2));
//! ```
//!
//! ## Feature: Delta-State Support
//!
//! Types that implement [`DeltaCRDT`] support efficient delta-state
//! replication. Instead of shipping full state, only incremental changes
//! (deltas) are transmitted. See the [`mdcs-delta`](https://docs.rs/mdcs-delta)
//! crate for the anti-entropy protocol that drives synchronization.
// Re-exports for convenience
pub use GSet;
pub use ;
pub use LWWRegister;
pub use ;
pub use MVRegister;
pub use ORSet;
pub use PNCounter;
/// Prelude module — import everything you need with `use mdcs_core::prelude::*`.