MVRegister
A multi-value register holding the value(s) last written. A single write yields one value; concurrent writes from different replicas are all retained until a later write observes and supersedes them — surfacing the conflict rather than silently picking a winner.
Thin wrapper over Causal<DotFun<V>>: each write mints a fresh dot → value and drops every dot it has already observed; the causal merge keeps exactly the writes that are mutually concurrent.
Samples
val a = ReplicaId("A")
val b = ReplicaId("B")
// Two replicas set independently — neither has seen the other.
val fromA = MVRegister.empty<String>().set(a, "vA")
val fromB = MVRegister.empty<String>().set(b, "vB")
val merged = fromA.piece(fromB)
check(merged.values == setOf("vA", "vB")) // concurrent writes retained
// A later write on one replica that observes the merged state resolves it.
val resolved = merged.set(a, "resolved")
check(resolved.values == setOf("resolved"))Content copied to clipboard