Skip to main content

Module crdt

Module crdt 

Source
Expand description

CRDT runtime values for the tree-walker interpreter.

The compiled (AOT) tier lowers a Shared struct’s collection fields to the real logicaffeine_data::crdt types — ORSet, RGA, MVRegister — and runs their full convergent semantics. For the interpreter to MEAN THE SAME THING as the compiler (the futamura invariant the cross-tier differential tests lock), it holds those very same types, not a lookalike Set/List. Merge is then concurrent-correct by construction: both tiers call into one Merge implementation, so there is no second copy of the convergence logic that could drift.

The language’s shared collections are homogeneous over a concrete element type (SharedSet of Text, … of Int) exactly as the compiled tier’s ORSet<String> is. CrdtScalar is the dynamically-typed element that covers every element type the surface syntax can name; it is Hash + Eq + Ord + Clone, so it satisfies the data-crate CRDT bounds.

Enums§

CrdtScalar
A scalar CRDT element. CRDT collections are homogeneous, so a collection only ever holds one of these variants in practice; the enum exists because the interpreter is dynamically typed and the element type is not threaded through struct_defs.
CrdtValue
A live CRDT held by the interpreter. Wraps the actual logicaffeine_data type, so its convergence behaviour is identical to the compiled tier’s by construction.

Functions§

crdt_values_equal
Structural equality used by the interpreter’s values_equal for CRDT values: two CRDTs are equal when they observe the same elements (sequences also compare order).
next_replica_id
Allocate the next distinct replica id.