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
use *;
// Create two replicas of a grow-only set
let mut a = new;
let mut b = new;
a.insert;
b.insert;
// Merge — order doesn't matter
let merged = a.join;
assert!;
assert!;
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
crate for the anti-entropy protocol that drives synchronization.