Causal
@Serializable
A full delta-state CRDT built from a DotStore and the DotContext that adjudicates its dots. piece is the causal join: merge the stores using both contexts, then union the contexts. This is the glue that turns any DotStore shape (DotSet now; DotFun/DotMap later) into a Quilted.
Invariant: every dot in store is witnessed by context. The factory paths that build CRDTs on top of Causal maintain it; merges preserve it.
Samples
val a = ReplicaId("A")
val b = ReplicaId("B")
// Alice removed the only dot she saw; her context still remembers (A,1).
val alice = Causal(DotSet(emptySet()), DotContext.of(Dot(a, 1L)))
// Bob concurrently added a fresh dot; he still holds both.
val bob = Causal(
DotSet(setOf(Dot(a, 1L), Dot(b, 1L))),
DotContext.of(Dot(a, 1L), Dot(b, 1L)),
)
val merged = alice.piece(bob)
// (A,1): Alice saw & dropped -> gone. (B,1): Alice never saw -> kept.
check(merged.store.dots == setOf(Dot(b, 1L)))
check(!merged.store.isBottom) // present — add winsContent copied to clipboard