Download
UnauditedEsta página aún no está disponible en tu idioma.
The server-to-client half of the Transfer Protocol, bound by its invariants (Transfer Protocol — Invariants). Upload optimises for correctness under interruption; download optimises for bandwidth and storage frugality, fetching the smallest representation that serves the user’s current intent. A client learns what to fetch from the sync feed (Sync). Server: capsule-server::serve behind GET /v1/blob/{hash} (Sync and blob fetch); client: capsule-sdk::fetch.
Tiered, On-Demand Fetch
Section titled “Tiered, On-Demand Fetch”Each asset has a ladder of representations, cheapest first:
- LQIP — inside the metadata blob; present the moment metadata syncs.
- Thumbnail — fetched when the asset scrolls into or near view.
- Preview — fetched when the asset is opened.
- Original — fetched only on explicit demand (full-fidelity view, export, share).
The per-library synchronization scope (Sync — Synchronization Scope) sets which tiers are fetched eagerly; anything above it is fetched lazily, and the original never speculatively. The client looks up its cache by content hash before any request, so a representation shared between assets is fetched once.
Render Ladder
Section titled “Render Ladder”What a client shows follows the same ladder, extended with what is already on the device. The order is computed once, in Rust, and reaches every native app through the FFI; apps render the representation it names and keep no ladder of their own. The keyless web client shows what the sync feed and its share paths serve. From least to most faithful:
- LQIP from the metadata blob, or its dominant colour when the LQIP cannot be decoded (Thumbnails and Previews — LQIP).
- Thumbnail: the encoded tier, or, until it exists, an embedded preview (Thumbnails and Previews — Embedded Previews) whose long edge reaches the Thumbnail tier’s.
- Preview: the encoded tier, or, on the device holding the original until it holds an encoded Preview, an embedded preview that covers the surface showing it when the view opens. A view that later grows keeps the embedded preview rather than dropping a rung.
- Original, decoded.
A surface asks for the rung its intent needs (Thumbnail for the grid, Preview for the single-asset view) and at once shows the best rung held at or below it. The view then upgrades in place as a better rung arrives, generated on the device or fetched, and never shows a blank while it waits. It never downgrades a rung it has shown, except through the Fallback Ladder.
Blob Access
Section titled “Blob Access”GET /v1/blob/{hash} is membership-scoped (capsule-server::serve::authority):
- An account may fetch blobs of assets filed under it and of every album whose current signed roster names it (Authorization).
- A former member gets
403; every other caller gets404, byte-identical to an unknown address.403is reserved for a caller the server knows once had access, because it confirms the address is referenced. - Backup blobs are owner-only; everyone else gets
404, decided on the role before the roster is consulted. - The roster is a transport control over who is handed bytes, never a confidentiality control; removal is paired with an AMK epoch bump.
- Share-link and drop paths serve from their own capabilities and answer
404once withdrawn; they do not use membership.
A delete moves an asset to trash, restorable by a trash-restore until the retention_until its signed record fixed (Asset Organization — Retention Window). Until then the asset’s blobs serve as the live asset’s did: its provenance records (including those the delete moved past), its live metadata blob, its original and its derivatives. A device that first sees the asset at its delete fetches them to adopt the asset from its create and restore it.
- The window that serves the blobs is the window that admits the restore, judged on the server’s clock, so no instant serves a blob of an asset whose restore it would refuse. A delete that signed no
retention_untilnever closes its window, as it never makes the asset purgeable. - Past the window the asset’s blobs are
410; after the purge drops their references they are404, as an address nothing references. - The authority is decided first in every state. A stranger gets
404and a former member403whether the asset is live, in trash or past its window, and a serving hold is410inside the window too. - Trash is not a confidentiality boundary. Until the window closes, every current member of the album can fetch a trashed asset’s original and history, including a member who joined after the delete, because any member’s device may need them to restore it. Deleting hides an asset; it does not withdraw it from the people the album is shared with. To withdraw it from someone, remove them from the album, which bumps the album’s epoch (Authorization). The user-facing description of delete says so.
Awaiting-Original
Section titled “Awaiting-Original”An asset whose T0 tier has finalized but whose original has not (Upload — Upload Tiering (Staged Uploads)) carries original_held = false on its feed entry. The state is derived from held blob roles, never stored.
- Other devices list it immediately (LQIP, then T1 as it lands) with an “original still on device” badge.
- Fetching its original returns the transient
409 error.blob.pending_upload, distinct from410, only when the fetching account itself has an active upload session declaring those bytes. The open session is the promise, so it expires with the session. A sharee or federated peer gets404and waits fororiginal_heldto flip. - GC and the index rebuild treat the missing original as expected state, not a dangling reference.
Fallback Ladder
Section titled “Fallback Ladder”- Transient failure (network drop,
5xx, content-hash mismatch): retry with backoff, resuming viaRange. 403: an authorization change, not data loss. Re-sync membership for the album, then degrade.- Permanent failure (
410, purged origin, unreachable federated home server, Federation — Robustness Against Connectivity Loss): degrade to the best representation already held — preview → thumbnail → LQIP — and show a non-destructive “full resolution unavailable” state. 409 error.blob.pending_upload: show the awaiting-original badge, never a failure; re-fetch when the feed flips.
A missing representation MUST NOT remove the asset’s metadata or index entry, and MUST NOT thrash the fetch. The asset re-fetches automatically once the representation is reachable.
Resumption and Verification
Section titled “Resumption and Verification”- Every fetch streams. A blob is fetched as a sequence of bounded
Rangewindows (at most 16 MiB each, smaller on an adverse link), with offsets counted from the first byte of the blob’s header (Asset and Metadata Encryption — Content Address), and each response body is streamed into its destination (a partial file, or the decoder for a representation that is only displayed) through a fixed I/O buffer as it arrives. No response is ever buffered whole, so a fetch’s memory is the I/O buffer whatever the window or blob size, and a dropped connection costs at most the unwritten part of one window. There is no fetch path that requests an open-ended range into memory. - An interrupted download resumes from the last persisted byte. The resume position is the partial file’s length after an fsync, never a separate counter that could run ahead of it, so a download also resumes across a process restart. Before extending a partial, the client re-checks the held prefix: a client holding the key verifies it chunk by chunk against the STREAM tags and truncates at the first chunk that fails, treating that chunk as corrupt at rest, as any ranged tag failure is until the whole blob is checked (Asset and Metadata Encryption — Reading a Blob). A write torn by a crash is therefore fetched again rather than carried to the end. A keyless holder relies on the final address check (Transfer Protocol — Failure Model).
- A download is written to a temporary file and appears under its final name only by an atomic rename after its content address verifies, so a partial or unverified file is never read as the blob. A blob’s address is its content and its
ETag, so two ranges of one address can never splice two different objects. - The client recomputes the ciphertext content hash against the requested address. A mismatch discards the bytes and is retried as transient.
- The client then checks the header and decrypts, relying on STREAM’s authentication tags to detect truncation, reordering or deletion. A blob that will not open is classified into exactly one state (corrupt, unsupported, key not held, wrong key, or sealed bad at source), each with its own action (Asset and Metadata Encryption — Reading a Blob); a fetch never reports one undifferentiated failure. A derivative sealed bad at source is discarded and not re-fetched, since the manifest commits to that address; the client regenerates it from the original (Thumbnails and Previews).
- Decryption is one pass. Where the client wants plaintext (opening an original, export, restore), it hashes the ciphertext and decrypts it in the same streaming read, writing plaintext to a temporary file that is renamed into place only after the final STREAM tag and the content address both verify. The ciphertext is not staged on disk and read a second time. A restore interrupted mid-blob resumes by re-sealing the held plaintext prefix, which reproduces the ciphertext prefix exactly and so restores the hash state, or else starts the blob again.
- A write that fails for lack of space keeps the partial and pauses the fetch’s class rather than retrying it (Transfer Protocol — Failure Model).
- Discarding the only local copy of a local-origin asset is gated by Durability — Verify Before Destroy. Re-fetchable server-origin blobs are always safe to drop.
Prefetch and Frugality
Section titled “Prefetch and Frugality”- Prefetch is bounded and predictive (thumbnails just beyond the viewport, the likely-next preview) and is cancelled when focus moves (Transfer Scheduler).
- Prefetch and above-tier fetches obey the synchronization criteria (Sync — Synchronization Criteria): on a metered connection the client fetches only what the user explicitly opens.
- Fetched-but-unpinned blobs are cache, evicted per Client Filesystem — Automatic cache management and re-fetched on demand.
Transfer Scheduler
Section titled “Transfer Scheduler”What a user is looking at decides what moves first. One TransferScheduler per client process, in Rust core and shared by every app through the FFI, admits every blob transfer in both directions: fetches, upload sessions from every lane (Upload — Queueing Across Servers) and delegated hand-offs. It decides order, deduplication and cancellation, and stamps each request with its class. Whether a class may send at all on the current path (allow, ask or deny; metering, power, heat) is decided per request by the admission layer at Spargen’s transport seam (Network Resilience — Admission and Priority), so a backend swap keeps both and no scheduling or metering ever lives in the HTTP backend (Network Resilience — One HTTP Stack).
Priority classes, highest first:
| Class | What | Typical source |
|---|---|---|
visible |
A representation a surface is showing now | Grid cells and the open asset, from viewport hints |
near_view |
A representation just outside the viewport, in scroll direction | Viewport hints’ lookahead |
requested_original |
An original the user explicitly asked for | Full-fidelity view, export, share |
prefetch |
A predicted need | The likely-next preview |
sync |
Keeping devices converged | Feed metadata, eager-scope fetches (Sync — Synchronization Scope), index- and preview-tier uploads |
backup |
Moving custody to the server | Original uploads, backup artifacts, delegated hand-offs |
- Strict order for admission. When a slot frees, the highest class with waiting work takes it. To keep custody moving, the lowest class the plan permits keeps one slot whenever it has work, so
backupis slowed, never starved. - One request per address. A representation wanted by two classes is one transfer at the higher class; a lower-class request for it joins the transfer already admitted.
- Held content is skipped. The scheduler checks the local cache by content hash when work is enqueued and again when it is dispatched, so nothing already on disk is fetched (the eager-scope planner does the same,
capsule-sdk::fetch). - Viewport hints. Native code pushes a hint whenever a scrolling surface settles or a surface gains or loses focus: the surface, the assets visible in display order, the lookahead in scroll direction, and a hint generation. A newer hint replaces the older for its surface. Assets that leave the visible set drop to
near_vieworprefetch, and assets that leave the lookahead are dequeued. - Cancel on focus change. When a surface loses focus, its
visibleandnear_viewwork that has not started is dropped, and work in flight is cancelled at its next window boundary. Because fetches resume byRangefrom the persisted partial, a cancel costs at most one window, and a later hint for the same asset resumes it. - Path changes win. A new path generation cancels what the new plan forbids, whatever its class (Network Resilience — Path Snapshot). A class the plan holds back stays queued in order and is not re-ranked.
- Disk floor. The client keeps a free-space floor on the library’s volume. Below it only
visibleruns, a cache sweep runs first, and every other class waits for space (Transfer Protocol — Failure Model). - Observable. Queue depth per class, admissions, cancellations and the time from enqueue to first byte are emitted as typed progress events, so a live-metrics view can show why a thumbnail was late.
The scheduler is policy and holds no durable state: dropping it loses no work, because every queue it orders is rebuilt from the local index and server truth.
Validation
Section titled “Validation”- Scheduler order (unit). With every class waiting, admissions follow the class order; the lowest permitted class still gets its one slot; one address wanted by two classes is one transfer.
- Viewport and focus (unit). A newer hint re-ranks and dequeues; a focus loss drops unstarted work and cancels in-flight work at its window boundary; a later hint resumes from the partial.
- Bounded memory (unit). A multi-gigabyte fetch through a mock source never holds more than the I/O buffer.
- Torn partial (unit). A partial with a corrupted tail chunk is truncated at that chunk on resume with the key, and discarded at the address check without it.
- Disk full (unit). A sink that fails with no space keeps the partial, pauses the class and evicts only reclaimable cache.
- Single-pass open (unit). Plaintext lands only after the last tag and the address verify; a mismatch leaves nothing under the final name.