Sync
UnauditedCe contenu n’est pas encore disponible dans votre langue.
The sync feed tells a client what changed; the Transfer Protocol moves the bytes. A client never polls assets individually: it holds one opaque cursor and reads everything after it. Server: capsule-server::sync; client: capsule-sdk::sync, applied by capsule-library::lifecycle::sync_apply.
Discovering What Changed
Section titled “Discovering What Changed”GET /v1/sync returns a page of asset changes (create, update, delete) after a cursor, with the next cursor (Sync and blob fetch). With album_id, it returns one shared album’s page to its owner, a current roster member, or a federated peer holding a capability for that album. Anyone else is refused 403 error.sync.album_access_denied, and a peer naming another album 403 error.federation.audience_mismatch. A member’s album page starts at the album’s first entry whatever epoch they joined at: what they can decrypt is the MLS Welcome’s decision, not the feed’s.
Each entry carries:
- the signed manifest, the exact bytes uploaded as the provenance blob, never re-encoded;
- the small encrypted metadata blob;
- the blob manifest (content hashes of the original and derivatives);
- each derivative tier’s signed
DerivativeManifest, verbatim; original_held, the derived awaiting-original fact (Download — Awaiting-Original).
It never carries original or derivative bytes. The client decrypts metadata, then decides what to fetch (Download).
A delete carries its signed manifest, the delete record whose retention_until closes the asset’s retention window (Asset Organization — Retention Window). Applying a deletion needs nothing more; restoring one does:
- Owner’s feed. The entry also names what a restore needs: the asset’s live metadata blob and its original, with
original_heldas for a live asset. It names no derivative and no derivative manifest, because the restore’s own entry names them again. - First seen at its delete. A device that first sees the asset at its delete fetches the asset’s earlier records, that metadata blob and that original, adopts the asset from its create, and can sign the
trash-restore. The server serves them to the asset’s readers until the window closes, then answers410(Download — Trash). - Window closed. A device that does not hold the asset, and finds the window closed at the entry’s
changed_ator is answered410or404on the way, passes the delete rather than retrying it: nothing is left to adopt, and passing it loses nothing. - Already held. A device that holds the asset applies the delete against the chain and original it holds, fetching nothing.
- Album pages. Every album page, an account’s or a federation peer’s, serves the delete with no metadata blob, no blob and
original_held: false. An album page has one shape whoever reads it, and a peer’s puller binds adeleteto no metadata blob, so a peer on an older server never stalls on the page. A writer member’s device that first sees the asset at its delete on an album page restores it from the records alone: the asset’s live metadata blob is the one named by the newest record that binds a metadata blob, and the delete commits to the original and its size. The device fetches its earlier records, then both blobs, and adopts the asset as from the owner’s feed. A puller served a delete naming a metadata blob anyway accepts the entry and fetches nothing for it. - Purged. A purge drops the record with the rest of the asset’s references, so a purged asset’s delete entry carries no manifest, names no blob, and carries
purged: trueinstead. The purge mints no new position: the flag rides the tombstone’s existing entry, so a client that read the entry before the purge judges the window from the record it already holds.
purged is the only evidence of a purge a client acts on. A client records a peering tombstone for a delete whose window it has seen close, or whose entry is purged; a delete entry with neither stays in trash. An absent manifest is never read as a purge: the server also omits it when the store cannot produce the blob, a server that predates the record or the flag omits them on every tombstone, and a tombstone recorded on that reading would be permanent for an asset only moved to trash. The flag is additive and optional, and its absence reads as false.
Cursor Authenticity and Anti-Rewind
Section titled “Cursor Authenticity and Anti-Rewind”- The cursor is MAC’d by the server under a server-only key (
capsule-server::sync::cursor). The tag covers the cursor’s own bytes, then the length-prefixed reader (the account, or the peer server for a federation pull), then the scope: the caller’s own feed, or one album’s page as read by an account, or that page as pulled by a peer, with the album id for both album scopes. A cursor minted for another reader, another album or another scope therefore fails verification, even though neither the reader nor the album is a cursor field. A forged, mutated or foreign cursor is refused, and the client re-syncs from zero. - The cursor carries the owner’s sync epoch. After an index rebuild moves the epoch, an older cursor is refused with
409 error.sync.cursor_stale. The client drops its cursor and its high-water marks, resyncs from zero, and keeps everything it holds. What it holds that the resynced feed no longer lists it then re-announces: manifests only, which restore the rows whose blobs the server still holds (Server Filesystem — Sync Epoch and Client Re-Announce). - Every entry carries the album’s
protocol_versionand a per-album, strictly increasingsync_seq. The client MUST refuse an entry above its maximum known version, and MUST surface, never apply, a page whosesync_seqregresses against its high-water mark. - The two layers are independent: the MAC stops forgery, but only the client’s high-water mark stops a server replaying its own older, valid cursor (the sync-cursor rewind class in Damage Scenarios and Quarantine — Damage Scenario → Invariant Map).
- An album page discloses index facts, not content. A member’s page starts at the album’s first entry whatever their history policy (MLS Group Membership). So a member who cannot decrypt older epochs still receives every entry’s server-visible facts: the count of entries, ciphertext sizes,
content_type,changed_at, the author device and the action history. This is accepted: those facts are the feed’s routing data, the server cannot read which epochs a member holds, and one page shape for every reader is what keeps a peer’s puller from stalling. The history policy bounds what a member can decrypt, never what the feed lists. - A feed manifest is verified with
verify_asset(Key Management — Write Authorization) over the bytes as received. Bytes that do not decode as a provenance record are quarantined as malformed.
Stale-Revival Detection
Section titled “Stale-Revival Detection”An old but validly signed manifest could resurrect an asset tombstoned later. The per-asset prior_provenance_hash chain (Signed Manifests and Provenance — Provenance of Library Modifications) prevents it at two layers:
- Client. Each device stores
latest_provenance_hashper asset. A manifest from sync, federation, peering or backup restore whose chain is behind it is quarantined as stale state (Damage Scenarios and Quarantine — Quarantine Surfaces). - Server. The server stores the same value and rejects any non-
createmanifest whoseprior_provenance_hashdoes not match (Validation Invariants — Server-Side Validation Invariants).
Synchronization Scope
Section titled “Synchronization Scope”- New local content is uploaded with its metadata and derivatives, in the order the upload policy sets (Upload — Upload Tiering (Staged Uploads)).
- Modified or deleted content updates metadata or tombstones.
- New remote content is fetched per the library setting: metadata only, + thumbnails, or + thumbnails + original. The original is otherwise on demand.
Auto Syncing
Section titled “Auto Syncing”On mobile, auto sync uploads new assets and pulls others’ assets. When a check fires, the client reconciles all pending uploads and downloads while the criteria hold, and re-evaluates if conditions change mid-transfer.
Synchronization Criteria
Section titled “Synchronization Criteria”- Small reconciliation (feed pages, metadata-only deltas, index-tier records): any usable connection class, metered and constrained included. A user on cellular still sees what changed.
- Large reconciliation (bulk uploads, original-tier downloads, streaming import):
unmeteredonly, unless the user consents.
These are the defaults of the per-class admission policy, which owns the rule and the user’s overrides (Network Resilience — Admission and Priority).
Platform Limitations
Section titled “Platform Limitations”Auto sync is offered only on platforms that expose what it needs, such as metered-connection detection, and is not implemented elsewhere.
Background Execution
Section titled “Background Execution”Background and OS-scheduled transfer are post-v1 (Clients — Platform Limitations); v1 transfers run while the app is in the foreground. Any background transfer is held to:
- Requests are self-contained. Every chunk
PATCHandRangeGETis complete in its URL, headers and a body the core has written to a file before queuing it. An OS transfer daemon can run it while the Rust core is suspended, and the core reconciles from server truth when it wakes. - Queued requests outlive the access token. A request the OS queues may run after the access token has expired, so no queued request may depend on one. The credential that replaces it is specified with background transfer in Authentication.
- Rust builds, the OS ships. Where the OS daemon, not the app, runs the transfer, the core seals the chunks to files and builds each request with the generated client (Network Resilience — One HTTP Stack): URL, method, headers and body file. Native code only hands that spec to the daemon. No native code builds a request, holds a key or sees plaintext.
Per platform:
- iOS. Small work rides
BGAppRefreshTask. Automatic large work requestsBGProcessingTaskwith network (and power for very large batches). A large job the user started (an import, a force sync) continues underBGContinuedProcessingTask, which shows its progress and lets the user cancel it (Platform Integrations). In all three the core runs in process. Uploads that must continue while the app is suspended ride a backgroundURLSession, which runs the request specs the core wrote and reports each one’s completion when the app next wakes. The core then reads server truth (HEAD, the committed set) instead of trusting the daemon’s report. - Android. Automatic work runs under
WorkManagerwith explicit constraints (UNMETEREDfor large,CONNECTEDfor small, battery-not-low). A transfer the user started (a backup, a large force sync) runs as a user-initiated data transfer job on Android 14 and later, which the OS does not cap the way it caps a data-sync foreground service (Platform Integrations). Earlier versions use a foreground service. Both run the Rust core in process, so their requests leave through the generated client like any other. - Desktop. Self-throttled with the maintenance gating rules (Library Maintenance and Atomic Writes — Content Validation (Expensive, Scheduled)).
- All platforms. Every window is preemptible: an OS kill loses at most the chunks in flight, uploads resume from the server’s committed set and downloads via
Range, and there is no “must finish” state. Retries follow the bulk-transfer policy class (Network Resilience — Retry Policy Classes).
Notifications
Section titled “Notifications”After two weeks without a completed sync while changes remain un-synced (including originals pending under a staged policy), the client offers a one-tap force sync now that ignores the connection criteria with consent, routing through re-authentication if the session has lapsed (Authentication — Sliding Inactivity Expiry). This is the sync_stale alert class (Notifications — Alert Classes), pre-armed so it fires on a device the OS never schedules (Notifications — The Pre-Arm Rule). Notifications owns delivery and snoozing.