Skip to content

Record confirmed full syncs with Iroh peers - #2564

Open
michielbdejong wants to merge 1 commit into
codex/vault-first-backup-statusfrom
codex/peer-full-sync-confirmation
Open

michielbdejong wants to merge 1 commit into
codex/vault-first-backup-statusfrom
codex/peer-full-sync-confirmation

Conversation

@michielbdejong

Copy link
Copy Markdown
Contributor

Follow-up to #2559. Previous peer activity could reflect a transfer that stopped after the file metadata arrived.

  • Pairing nodes with full sync support confirm the selected drive’s stored resource versions and verify uploaded file bytes before replying. The originating node saves the date for that drive and peer after receiving the matching reply.
  • Sync settings shows Last full sync for the selected drive when a peer has confirmed it. Peers without a recorded confirmation can still show Last sync activity.
  • Current uploads use the existing blob transfer. Legacy file records and chunked manifests require all referenced contents to be present before the peer can confirm them.

The two-node Iroh regression transfers a file and records a date, then disconnects during a second file write after its metadata has arrived. It checks that the second file’s bytes are absent and the previous date is unchanged.

Locally verified with the focused Rust full-sync tests, the existing Iroh probe-hit test, the Chromium Sync settings test, and the drive protection and server helper unit tests.

joepio commented Nov 17, 2026

Copy link
Copy Markdown
Member

Complexity review of this PR together with #2559, which it stacks on. Combined they are +3,317 / −223.

The main point: "this copy holds everything I have" is built twice, in two layers and two ways.

  • Server path (driveProtection.ts:208-270, Show verified server sync and Cloud Vault backup status #2559):
    • The browser fetches driveInventory and compares the server's version vectors against computeDriveSyncState by itself.
    • It keeps the result in a module-level WeakMap<Store, Map>, with its own fullSyncListeners set.
    • It is in memory only, so a reload drops it and the warning comes back until the next check passes.
  • Iroh path (lib/src/sync/peer_full_sync.rs, this PR):
    • A new CAP_PEER_FULL_SYNC frame with a drive hash and a nonce.
    • A receipt stored in Tree::PluginMeta and exposed through a peerFullSyncsOnly mode on /drive-usage (managedServer.ts fetchDriveUsageData).

Both paths answer the same question that the reconcile in lib/src/sync/engine.rs already answers: after SYNC_DIFF, is there nothing left to push? I'd record one receipt there, for WS and Iroh alike: "reconcile with peer X ended with an empty push list at time T". Persist it once, and let the UI read one value. That would remove:

  • the client-side version-vector comparison (verifyFullSync and its 15-condition isCurrent);
  • the WeakMap and the listener set;
  • the new frame type and its hash and nonce;
  • the query-flag mode on /drive-usage.

Smaller points:

  • httpUrl, effectivePort and isExternalServer (driveProtection.ts:120-147) are a second answer to "is this the embedded or local node", next to isOriginWithoutNode / getLocalServerOrigin. They belong in originNode.ts, as one function.
  • peerFullSyncsOnly=true makes one endpoint return two different response shapes. A separate field in the normal usage response is simpler, and older servers simply leave it out.
  • vault-first-backup-status.spec.ts is 457 lines for one status line. Most of the cases are already covered by driveProtection.test.ts (537 lines). Keep one e2e happy path and leave the rest to vitest.

Generated by Claude Code

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants