AssetSyncEngine
serviceBreakdex::SyncInfrastructure::AssetSyncEngine
Content-addressed multi-provider cloud sync with manifest reconciliation
The backup layer — SHA-256 hashes every video, deduplicates, and distributes copies across iCloud, Google Drive, and Supabase. Two-phase: manifest (metadata) syncs first, then binary assets. Two-copy safety: won't delete local until 2+ verified remote copies exist.
Relationships
Depends On 4
cloud_provider_interfaceasset_hash_servicemanifest_serializersupabase_client
Reads From 5
moves_tablecombos_tablereviews_tablesync_log_tableasset_manifest_table
Writes To 6
moves_tablecombos_tablereviews_tablesync_operations_tableasset_manifest_tableasset_copies_table
Configured By 3
network_policybackground_sync_managersync_connectivity_trigger_provider
Breaks If 4
manifest_format_changescloud_provider_api_changescontent_hash_algorithm_changessupabase_migration_fails
Validated By 6
asset_hash_service_testintegrity_verifier_testmanifest_serializer_testnetwork_policy_testsafety_guard_testtombstone_cleaner_test
Data Access
Owns 6
moves_tablecombos_tablereviews_tablesync_operations_tableasset_manifest_tableasset_copies_table
Reads 5
moves_tablecombos_tablereviews_tablesync_log_tableasset_manifest_table
Writes 6
moves_tablecombos_tablereviews_tablesync_operations_tableasset_manifest_tableasset_copies_table
Answers
States
| State | Behavior |
|---|---|
| no Providers | message: No cloud providers configured — enable iCloud or Google Drive in Settings shows: sync_onboarding |
| offline | message: Changes queued locally — sync resumes when connectivity returns shows: queued_operations |
Invariants
Two-copy safety: local delete only permitted when copyCount >= 2
Enforced by: safety_guard
Content-addressed: same video = same hash = one manifest entry
Enforced by: sha256_content_hash
Failure Modes
- Manifest corruption → requires full re-sync from cloud
- Supabase migration failure → sync writes silently fail
Safe Change Notes
- Add new fields to manifest — backward compatible if old fields preserved