mirror of
https://github.com/spacedriveapp/spacedrive.git
synced 2025-12-11 20:15:30 +01:00
2.8 KiB
2.8 KiB
id, title, status, assignee, parent, priority, tags, depends_on, design_doc, last_updated
| id | title | status | assignee | parent | priority | tags | depends_on | design_doc | last_updated | |||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
| LSYNC-002 | Shared Metadata Sync (Albums, Tags) with HLC | Done | james | LSYNC-000 | High |
|
|
core/src/infra/sync/NEW_SYNC.md | 2025-10-15 |
Description
Implement synchronization for truly shared resources (Albums, Tags) using the HLC-based log model. These resources can be modified by any device and need conflict resolution.
Architecture: Log-based sync with Hybrid Logical Clocks for ordering.
Data Classification
Shared Resources (this task):
- Tags: Global tag definitions (no device owner)
- Albums: Collections referencing entries from multiple devices
- UserMetadata: When scoped to ContentIdentity (content-universal)
Device-Owned (separate - state-based):
- Locations: Owned by specific device
- Entries: Owned via location's device
- (Handled by state-based sync, not this task)
Implementation Steps
- Mark tags/albums as shared in
Syncabletrait - Implement
commit_shared()in TransactionManager:- Generate HLC
- Write to database
- Write to
sync.db - Broadcast to all peers
- Implement conflict resolution:
- Tags: Deterministic UUID from name (merge duplicates)
- Albums: Union merge for entry lists
- UserMetadata: HLC ordering for LWW
- Implement ACK mechanism for log pruning
- Test concurrent tag creation across devices
- Test album modification conflicts
Technical Details
- Changes written to
sync.db(per-device log) - Broadcast via
SharedChangemessage with HLC - Peers apply in HLC order
- ACKs enable aggressive pruning (log stays <1000 entries)
Conflict Examples
Tag Name Collision
Device A: Creates tag "Vacation" → HLC(1000,A)
Device B: Creates tag "Vacation" → HLC(1001,B)
Resolution: Deterministic UUID from name
Both generate: Uuid::v5(NAMESPACE, "Vacation")
Same UUID → automatically merge
Album Concurrent Edits
Device A: Adds entry-1 to "Summer" → HLC(1000,A)
Device B: Adds entry-2 to "Summer" → HLC(1001,B)
Resolution: Union merge
Album contains: [entry-1, entry-2]
Acceptance Criteria
- Tags sync between all peers (tag::Model implements Syncable)
- Collections (albums) sync between all peers (collection::Model implements Syncable)
- UserMetadata sync (both entry-scoped and content-scoped)
- HLC ordering works (applied in peer.rs)
sync.dbper-device log implementation with PeerLog- ACK mechanism prunes old entries (prune_acked method)
- Integration tests validate tag sync and conflicts (10 tests passing)
- ContentIdentity sync with deterministic UUIDs
References
core/src/infra/sync/NEW_SYNC.md- Shared resource sync- HLC: LSYNC-009
- Sync service: LSYNC-010