Skip to main content

Crate causal_dag

Crate causal_dag 

Source
Expand description

Pillar: I. PACR fields: ι (node identity), Π (predecessor edges).

A lock-free, append-only causal DAG over PacrRecord nodes.

Physical axiom: special relativity mandates that causation propagates at most at the speed of light, imposing a strict partial order on events. This partial order is encoded in the predecessor set Π — there is no total order and no global clock.

§Design

OperationComplexityMechanism
CausalDag::appendO(|Π|)predecessor validation + DashMap CAS
CausalDag::getO(1) expectedDashMap sharded read
CausalDag::successorsO(1)DashMap reverse-index read
CausalDag::predecessorsO(1)DashMap sharded read
CausalDag::ancestryO(V+E)BFS with HashSet visited-set

§CRDT semantics

The DAG is a Grow-Only Set (G-Set): records are immutable once inserted and the only mutation is appending new records. Two replicas converge by exchanging unseen records (union of node sets).

§Concurrency

DashMap uses sharded locks (not a single RwLock) and provides lock-free concurrent reads on already-inserted keys. Append uses entry() for an atomic duplicate-check-and-insert, eliminating the TOCTOU race of a separate contains_key + insert pair.

No Mutex or RwLock is used anywhere in this crate.

Modules§

distance_tax
Pillar: I + II. PACR fields: Π + Λ.
merge
Pillar: I + II. PACR field: Π.

Structs§

CausalDag
A lock-free, append-only directed acyclic graph of PacrRecord nodes.

Enums§

DagError
Error returned by CausalDag::append.