mdcs-core 0.1.1

Core CRDT types and traits for the Carnelia Merkle-Delta CRDT Store
Documentation

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 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 crate for the anti-entropy protocol that drives synchronization.