Expand description
Causal Consistency Mode for δ-CRDTs (Algorithm 2)
This module implements the delta-interval anti-entropy algorithm that provides causal consistency guarantees, extending Algorithm 1’s convergence mode.
§Algorithm 2: δ-CRDT Anti-Entropy with Causal Delivery
Unlike Algorithm 1 which only guarantees eventual convergence, Algorithm 2 ensures that deltas are applied in causal order. This prevents seeing effects before their causes.
§State Components
Each replica i maintains:
-
Durable state
(Xᵢ, cᵢ):Xᵢ: The current CRDT statecᵢ: A durable counter (sequence number) that survives crashes
-
Volatile state
(Dᵢ, Aᵢ):Dᵢ[j]: Delta-interval buffer for each peer j (deltas to send)Aᵢ[j]: Acknowledgment map - last seq acked by peer j
§Protocol
-
On local mutation m:
cᵢ := cᵢ + 1 d := mδ(Xᵢ) Xᵢ := Xᵢ ⊔ d ∀j: Dᵢ[j] := Dᵢ[j] ⊔ d // add delta to all peer buffers -
On send to peer j (periodic or on-demand):
if Dᵢ[j] ≠ ⊥ then send ⟨Dᵢ[j], Aᵢ[j]+1, cᵢ⟩ to j // delta-interval with seq range -
On receive
⟨d, n, m⟩from peer j:if n = Aᵢ[j] + 1 then // causally ready Xᵢ := Xᵢ ⊔ d Aᵢ[j] := m send ack(m) to j else discard (or buffer for later) -
On receive ack(m) from peer j:
Dᵢ[j] := ⊥ // clear delta buffer for j
§Garbage Collection
Deltas can be safely garbage collected when ALL tracked peers have acknowledged them. This ensures no peer will ever need those deltas again.
§Crash Recovery
On restart:
Xᵢandcᵢare restored from durable storageDᵢandAᵢstart fresh (volatile state lost)- Peers will detect the gap and request retransmission
Structs§
- Causal
Cluster - Cluster coordinator for causal anti-entropy
- Causal
Network Simulator - Network simulator for causal anti-entropy
- Causal
Replica - A causal δ-CRDT replica implementing Algorithm 2
- Delta
Interval - A delta-interval message for causal delivery
- Durable
State - Durable state that survives crashes
- Interval
Ack - Acknowledgment for a delta-interval
- Memory
Storage - In-memory storage for testing (simulates durable storage)
- Peer
Delta Buffer - Per-peer delta buffer for causal mode
- Volatile
State - Volatile state for causal anti-entropy (lost on crash)
Enums§
- Causal
Message - Messages for the causal anti-entropy protocol
- Storage
Error - Storage errors
Traits§
- Durable
Storage - Trait for durable storage backends