Objective: Upgrade the sync system from "last-write-wins" to a distributed consensus model. This uses Vector Clocks to track changes across multiple devices and a field-level "Merge Engine" to handle conflicts without data loss.
Files involved (9):
services/consensusService.js (New: Distributed logic)
utils/vectorClockMath.js (New: Mathematical clock logic)
models/SyncConflict.js (New: Detailed conflict storage)
middleware/consistencyGuard.js (New: Out-of-order protection)
routes/syncManager.js (New: Advanced sync API)
models/Transaction.js
(Update: Schema changes for vector clocks)
jobs/conflictCleaner.js (New: Background maintenance)
tests/consensus.test.js (New: Multi-user race condition tests)
SYNC_CONSENSUS_SPEC.md (Technical spec)
Objective: Upgrade the sync system from "last-write-wins" to a distributed consensus model. This uses Vector Clocks to track changes across multiple devices and a field-level "Merge Engine" to handle conflicts without data loss.
Files involved (9):
services/consensusService.js (New: Distributed logic)
utils/vectorClockMath.js (New: Mathematical clock logic)
models/SyncConflict.js (New: Detailed conflict storage)
middleware/consistencyGuard.js (New: Out-of-order protection)
routes/syncManager.js (New: Advanced sync API)
models/Transaction.js
(Update: Schema changes for vector clocks)
jobs/conflictCleaner.js (New: Background maintenance)
tests/consensus.test.js (New: Multi-user race condition tests)
SYNC_CONSENSUS_SPEC.md (Technical spec)