Back to Spacedrive

Design Library Sync Protocol (Leaderless)

.tasks/core/LSYNC-001-design-library-sync-protocol.md

0.4.31.7 KB
Original Source

Description

Design the detailed protocol for Library Sync using a leaderless hybrid model.

Architecture Update (Oct 2025): Moved from leader-based to peer-to-peer model based on data ownership analysis.

Design Documents

  • core/src/infra/sync/NEW_SYNC.md - Current leaderless design
  • docs/core/sync.md - Outdated leader-based model
  • docs/core/sync-setup.md - Library sync setup flow (still valid)
  • docs/core/events.md - Unified event system
  • docs/core/devices.md - Device system

Architecture Decisions (Revised)

  • Leaderless peer-to-peer: No leader election, all devices equal
  • Hybrid sync strategy:
    • State-based for device-owned data (locations, entries)
    • Log-based with HLC for shared resources (tags, albums)
  • Bulk optimization: Batched state transfers for efficiency
  • Conflict resolution: HLC ordering + union merge
  • No central coordinator: Each device broadcasts to peers

Key Changes from Original Design

AspectOld DesignNew Design
ArchitectureLeader/followerPeer-to-peer
OrderingCentral sequencesHLC timestamps
Sync logOne central logPer-device for shared changes only
Device-owned dataGoes through leaderDirect state broadcast
ComplexityHigh (election, heartbeats)Low (simpler)

Acceptance Criteria

  • Detailed protocol design document created
  • Hybrid strategy (state + log) defined
  • HLC ordering mechanism specified
  • Peer broadcast protocol designed
  • Implementation tasks updated

References

  • core/src/infra/sync/NEW_SYNC.md - Complete new specification
  • HLC implementation: LSYNC-009
  • Peer sync service: LSYNC-010