core practice · implementation task

Make three replicas converge

Implement mergeGCounter(left, right) and valueGCounter(state). A grow-only counter stores one non-negative count per replica; merge takes the maximum count for every replica, and value sums the merged counts. Your merge must converge when updates arrive in different orders and remain unchanged when the same state is delivered twice.

The mechanism

Collaborative state needs an explicit notion of causality and a deterministic reconciliation rule. OT transforms concurrent operations against an agreed history; CRDTs design state or operations around algebraic merge laws so replicas converge despite reordering and duplication. Neither is universally simpler: choose from offline requirements, metadata and tombstone cost, server coordination, undo semantics, and the data structures the product needs.

Study Collaboration Systems

Expected evidence

Three independently updated replicas converge to the same {a:2,b:3,c:4} state and value 9 regardless of merge order.

Try this drill in the practice workspace →

Hints when you need them
  • Treat a missing replica entry as zero.
  • Per-key maximum makes merge commutative, associative, and idempotent.

Watch for these mistakes

  • Treating replica convergence as proof that concurrent edits preserve user intent
  • Calling CRDTs coordination-free while ignoring causal delivery, metadata compaction, tombstone garbage collection, or membership changes
  • Assuming every OT design requires one central server, or that every CRDT design has the same wire and storage costs
  • Replicating ephemeral cursor and presence state through the durable document history

Check the sources

Practice the same mechanism

Browse all practice briefs