feat(sync): device-to-device inventory sync, end to end
Wires the encrypted sync transport into a working replication between one identity's own devices, reusing the CRDT-ready model (HLC + tombstones + LWW) the data model was built for. - SocialSession gains a 5th interface, sync, over the shared connection, built with a per-install deviceId + the app's inventory namespace. - DeviceIdStore: a stable random per-install id in the keystore — distinct from the seed-derived CRDT node id, which is IDENTICAL across a user's devices (so it couldn't tell them apart / they'd clobber each other's replaceable record). - InventorySnapshotIO (implemented by ExportImportService): build/apply the inventory as the SAME interchange JSON as backups but UNSEALED — the sync transport does the encryption, so it must not double-seal. Apply = the existing idempotent LWW importInventory. - SyncService: on (re)connect publishes this device's snapshot + subscribes to the others'; a local edit (debounced, off tableUpdates) republishes; incoming snapshots merge idempotently; skips its own echo; a byte check skips re-publishing an unchanged snapshot so the ping-pong converges. Foreground only, like the inbox. - DI/Bootstrap/switchSocialAccount wire and lifecycle it per identity. Tests: DeviceIdStore, ExportImportService snapshot round-trip (unsealed + idempotent), SyncService.handleRemote (applies others', skips own). Follow-ups: deltas vs full-snapshot pushes; background sync; conflict UI.
This commit is contained in:
parent
182c334883
commit
225880fc64
10 changed files with 363 additions and 12 deletions
|
|
@ -22,6 +22,7 @@ import 'services/social_account_store.dart';
|
|||
import 'services/social_connection.dart';
|
||||
import 'services/social_service.dart';
|
||||
import 'services/social_settings.dart';
|
||||
import 'services/sync_service.dart';
|
||||
import 'services/trust_referents.dart';
|
||||
import 'services/wot_settings.dart';
|
||||
import 'ui/theme.dart';
|
||||
|
|
@ -65,9 +66,12 @@ class _BootstrapState extends State<Bootstrap> {
|
|||
// Ask for notification permission and set up the OS channel (no-op on
|
||||
// unsupported platforms). Done before the inbox starts listening.
|
||||
if (notifications != null) await notifications.initialize();
|
||||
// Subscribe the inbox listener BEFORE the shared connection starts
|
||||
final sync =
|
||||
getIt.isRegistered<SyncService>() ? getIt<SyncService>() : null;
|
||||
// Subscribe the inbox + sync listeners BEFORE the shared connection starts
|
||||
// connecting, so the first session is caught; then bring the connection up.
|
||||
inbox?.start();
|
||||
sync?.start();
|
||||
connection?.start();
|
||||
|
||||
return TaneApp(
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue