Skip to content

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 valuesum(values) = 2 + 3
5

Merge compares each replica component independently. The user-facing read sums the components only after that merge.

Choose the shape of your state.

Start from the data you need to replicate, then install the smallest package that carries that merge rule.

Prototype safely.

Verify the merge behavior your application depends on, then pin the package versions you validated. Recheck behavior and release notes before upgrading.