Systems / 2026 / Runs natively
Local-First Sync
A last-writer-wins CRDT with vector clocks and causal delivery, written from scratch, so three replicas can go offline, edit the same keys and reconverge without a server deciding anything.
01
The problem
Offline sync built on updated_at loses data quietly. Clock skew breaks convergence, out-of-order delivery breaks causality, and most-recent-wins picks a different winner on each device.
02
How I approached it
Vector clocks classify every pair of edits as before, after, equal or concurrent, and only concurrent is a real conflict. Operations whose causes have not arrived are buffered rather than applied, and receiving the missing cause drains the buffer. Concurrent edits break the tie on node id so every replica independently reaches the same answer. Deletes are tombstones, because dropping a key lets a stale write resurrect it.
03
The outcome
Nine tests including a property check across 40 randomised edit-and-gossip orders, asserting three replicas converge to identical state every time.