lattice
Conflict-free replicated data types (CRDTs) for Gleam, with property-tested merge semantics.
Convergence notebook
Local updates, deterministic merges, one shared value.
lattice gives each replica a CRDT state it can update independently. When replicas meet, merge uses the CRDT's lattice rule so every node converges without locks, consensus, or a conflict-resolution callback.
GCounter merge
Merge components first. Sum only when reading.
- node-a local state
{a: 2, b: 0}- node-b local state
{a: 0, b: 3}- Component-wise merged state
{a: max(2, 0), b: max(0, 3)} = {a: 2, b: 3}
Derived read value
5sum(values) = 2 + 3Merge compares each replica component independently. The user-facing read sums the components only after that merge.
Evaluating lattice?
Take the route that answers your next question.
Choose the shape of your state.
Start from the data you need to replicate, then install the smallest package that carries that merge rule.
TotalCounters
lattice_counters for values that only grow, or grow and shrink.Single valueRegisterslattice_registers for last-writer-wins or multi-value conflicts.MembershipSets + presencelattice_sets and lattice_presence for collections and live membership.Nested stateMaps + textlattice_maps, lattice_sequence, and lattice_text for keyed or ordered data.Prototype safely.
Verify the merge behavior your application depends on, then pin the package versions you validated. Recheck behavior and release notes before upgrading.
