Local-First Sync & Conflict Simulator
Lamport logical clocks, field-level auto-merge, and non-destructive conflict preservation across offline household devices in Rust & WebAssembly.
Why Local-First Sync Cannot Rely on Wall Clocks
In a real household, two devices rarely agree on wall-clock time to the millisecond—and one of them is frequently offline in a basement, grocery aisle, or airplane seat. Relying on naive server timestamps risks silently overwriting a spouse's grocery update or losing a note written offline.
Instead, every operation in this simulator carries a monotonic Lamport logical clock and a replica identifier . Whenever a replica generates a local operation, it increments its clock:
Whenever a replica receives a remote operation with timestamp , it advances its clock past both histories:
Three Outcomes When Devices Reconnect
- Disjoint block edits & additions: Changes to separate blocks or newly added items merge automatically and sort deterministically by .
- Orthogonal field edits on the same block: Text content and completion state carry independent field clocks. Checking off an item on Pocket iPhone while refining its wording on Kitchen Mac merges cleanly with zero conflict.
- Concurrent edits to the same text revision: When both replicas rewrite the same block from the same base revision, a total order over selects the canonical text identically on both devices—while the losing revision is preserved inline as a Conflict Copy so nothing written by a family member is ever silently erased.
After reconciliation, both devices compute an FNV-1a 64-bit fingerprint over their canonical block state. Matching fingerprints confirm exact byte-for-byte convergence without a central coordinator.