Expand description
Pushing a locally-imported asset to a server — the glue between
capsule_core’s UploadBundle and the hand-written upload client.
capsule-core builds the bundle (ciphertext, sealed metadata blob, derivatives, and the
manifest-envelope projection); this module turns it into the protocol’s POST /upload
bodies and drives them in tier ladder order. Nothing here re-implements a
network flow — every byte goes through UploadClient, and the ordering/gating goes
through StagedScheduler::plan_sessions.
Resume derives from server truth. There is no push-side state file: pull the sync feed,
fold it with held_from_feed into the set of blob content
addresses the server durably holds, and remaining_tiers
rebuilds exactly the outstanding work. Within a blob, POST /upload’s idempotent re-create
returns the authoritative offset; across an asset’s blobs, a duplicate_blob answer is a
merge, not an error. Re-running a push against an unchanged library is therefore a no-op.
§The index tier is two blobs, not one
T0 is provenance and metadata, in that order. The server publishes an asset to other
devices only once it holds both index-tier roles
(capsule_server::upload::visibility::INDEX_TIER_ROLES), and the head of the server-side
provenance chain — what a later lifecycle op’s prior_provenance_hash must equal — is the
SHA-256 of the provenance blob’s bytes. A ladder that shipped only the metadata blob
therefore uploaded an asset that no device could ever see and no op could ever chain onto:
the bytes were on the server and the asset was not in anybody’s library.
The provenance blob is the canonical CBOR of the chain’s head ProvenanceRecord
(UploadBundle::provenance_blob), which capsule-core encodes once so the SDK and the
FFI cannot disagree about it. It goes first within T0: it is the blob the server reads
prior_provenance_hash, action and retention_until out of, so sending it first is the
order in which the asset’s own claims arrive before the bytes they describe.
Every blob this module ships is ciphertext. The original is re-derived from its
manifest’s nonce prefix one upload chunk at a time (BlobBytes::Original), so a push holds
one chunk window of an original and never the whole file; the metadata blob is carried sealed, and derivative blobs are
encrypted too — capsule-core re-derives each one from the plaintext it holds locally
using the prefix that derivative’s signed manifest recorded. Nothing here decrypts, encrypts,
or inspects a blob; it moves opaque bytes.
One deviation from “the envelope mirrors the signed manifest”, and it is the server’s
rule: invariant 15 requires manifest_envelope.ciphertext_hash == hash (the top-level
declared content address of this blob). A bundle’s metadata and derivative blobs are not
the original, so their envelope carries their own content address; every other field is the
head manifest’s, verbatim. See envelope_for.
§A transfer is not custody
Every byte reaching the server is not the same as the server holding the asset. A finalize
that lost its claim race answers the chunk 204 and is still running; an index failure after
the commit leaves bytes nobody references. So a push does not end at the last chunk:
verify_custody asks POST /storage/verify whether every blob the asset now relies on is
stored, indexed and retrievable, then fetches the asset’s custody-receipt log and requires a
receipt per blob that verifies under the server’s attestation-key history and names the
exact bytes, size and role the client sent. That history is the one the caller pinned for the
server (capsule_library::library::pin_attestation_keys), never a fetch trusted on its own. Only then is the asset reported as pushed, and
the verified receipts are what the caller persists beside the provenance chain.
Structs§
- Asset
Push Report - What pushing one asset did.
- Bundle
Blob - One transferable blob of an
UploadBundle: its ladder tier, protocol blob role, declared content type, and the bytes themselves (borrowed from the bundle). Paired with its content address bybundle_blobs. - Lane
Bundle - One bundle queued on a lane, with the server truth its plan prunes against (see
push_bundle’sheld). - Lane
Push - One server’s share of a
push_lanesrun: the client that reaches it, and the bundles queued for it. - Push
Plan - What a push would do for one bundle: the blobs it plans to open sessions for, in ladder
order, plus what it skipped and why. Computed without touching the network — the dry-run
primitive, and the first half of
push_bundle. - Pushed
Blob - How one blob of a bundle resolved.
- Redaction
- What
redact_assetdid to one asset’s open upload sessions. - Verified
Custody - What
verify_custodyestablished for one asset.
Enums§
- Blob
Bytes - Where a
BundleBlob’s bytes come from. Everything but the original is small and already in the bundle; the original is aOriginalCiphertextsource the upload client reads one chunk window at a time, so a push never holds an original whole. - Push
Error - Errors a push can fail with.
Constants§
- PUSH_
BATCH_ BUNDLES - The most bundles a caller pushing a long list of assets should hold at once: it pushes them
in batches of this many, each batch through one
push_lanesrun. Four times the widest sessions window keeps that window full for most of a batch, while a list of any length holds at most this many bundles’ derivatives in memory. - PUSH_
BYTE_ BUDGET - The device-wide byte budget a push run’s ranges reserve against when the caller has no narrower one: four of the protocol’s largest chunks in flight at once, however many sessions and servers the run drives.
Functions§
- bundle_
blobs - Every transferable blob of
bundle, in ladder order: the index tier (T0) — the provenance blob then the sealed metadata blob — the preview tier (T1) — each derivative tier’s signed manifest, then each derivative — then the original (T2). - create_
request - The
POST /uploadbody for one blob ofbundle. - ensure_
album - Register
album_idwith the server before any blob session opens for it. - envelope_
for - The
ManifestEnvelopefor one blob ofbundle: every field of the head manifest, verbatim, withciphertext_hashnaming this blob (the server’s invariant-15 consistency rule —manifest_envelope.ciphertext_hashmust equal the top-levelhash). - plan
- Plan a push for one bundle: prune to what server truth says is outstanding, then let the scheduler decide which of those tiers open now.
- push_
bundle - Push one
UploadBundlethroughclient, in the orderschedulerpermits. - push_
lanes - Push every lane’s bundles through one device-wide
UploadQueue, up to W at once per lane. - redact_
asset - Abort every open upload session this account holds for
asset_id: the network half of redacting an asset deleted before its upload finished (Organization — Deletion State Machine). - staged_
asset - The bundle as a
StagedAssetthe scheduler can order and gate. - verify_
custody - Confirm the server holds what
push_bundlesent, and collect the evidence that it does. - verify_
custody_ with_ events verify_custody, publishing the verdict (TransferEvent::Verify) and each verified receipt (TransferEvent::Receipt) toevents.