spacedrive/.tasks/LSYNC-001-design-library-sync-protocol.md
Jamie Pine c478b40c1a feat: Revise library sync architecture to leaderless hybrid model
- Updated the library sync system to utilize a leaderless hybrid model, enhancing real-time synchronization of shared resources.
- Implemented state-based sync for device-owned data and log-based sync with Hybrid Logical Clocks (HLC) for shared resources.
- Revised documentation to reflect architectural changes, including the removal of leader election and the introduction of per-device sync logs.
- Enhanced conflict resolution strategies using HLC for shared metadata, ensuring deterministic merging and consistency across devices.
- Updated implementation tasks and acceptance criteria for various components to align with the new architecture.
2025-10-08 11:15:52 -07:00

1.9 KiB

id, title, status, assignee, parent, priority, tags, whitepaper, design_doc
id title status assignee parent priority tags whitepaper design_doc
LSYNC-001 Design Library Sync Protocol (Leaderless) Done james LSYNC-000 High
sync
networking
protocol
design
leaderless
Section 4.5.1 core/src/infra/sync/NEW_SYNC.md

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

Aspect Old Design New Design
Architecture Leader/follower Peer-to-peer
Ordering Central sequences HLC timestamps
Sync log One central log Per-device for shared changes only
Device-owned data Goes through leader Direct state broadcast
Complexity High (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