crdt-merge-is-idempotent

Status: IN

All four CRDT `merge` methods (`GCounter`, `PNCounter`, `LWWRegister`, `ORSet`) are idempotent: merging the same state twice produces the same result as merging once

Source: entries/2026/05/29/conflict-free-replicated-data-types-crdts.md

Example

def merge(self, other):  # GCounter
    for rid, count in other.counts.items():
        self.counts[rid] = max(self.counts.get(rid, 0), count)
    return self  # max is idempotent

JSON