If one edit causally happened after the other, it wins. If they really were simultaneous, every device picks the same winner with no coordination and no server. That's the whole trick.
kt
// Two devices edited the same record while offline. Who wins? class VectorClockResolver : ConflictResolver { override fun resolve(local: Event, remote: Event): Event = when { local.vectorClock.isBefore(remote.vectorClock) -> remote remote.vectorClock.isBefore(local.vectorClock) -> local else -> if (remote.id > local.id) remote else local // deterministic tiebreak } }
commit 5d55950