Expand description
Upload delegation: a device hands sealed, signed upload bundles to another device of the same account, which uploads them later as an opaque courier (SSoT: Peering § Delegation).
origin: seal + sign bundle ──hand-off──▶ delegate: verify, fsync, ack, upload ──▶ server
▲ │
└──────── origin verifies custody of the hashes it computed itself ◀────────────┘§What moves
A HandOff is one asset’s upload bundle exactly as the origin would upload it: every
blob’s POST /v1/upload body (CreateUploadRequest, built by crate::push) and the
blob’s bytes, which are ciphertext or signed CBOR. The delegate never holds an album key or
plaintext for it, never re-signs, re-encrypts or re-derives anything, and uploads the requests
byte for byte under its own session. The server admits the manifest on the origin’s
signature, never on who uploads it (capsule-server::upload::signer).
A hand-off is per asset and all or nothing: the delegate verifies every member against the signed manifest before it persists any of it, so it never uploads an incomplete bundle.
§The origin (OriginLedger)
seal builds the hand-off and records the hashes the origin computed itself. The
OriginLedger holds each Delegation with a monotonic deadline: on expiry, when the
delegate is revoked, or when the clock the deadline was set on is gone (a reboot), the asset
is re-queued for the origin to upload itself or delegate again (OriginLedger::due). It is
released only through the verify-before-destroy gate over custody facts the origin fetched
with its own session for its own hashes, plus a read-back of its own copy
(OriginLedger::release); an acknowledgement is never custody, and nothing the delegate
relays is consulted. A signed delete of a handed-off asset is held until the create’s custody
is confirmed (OriginLedger::hold_delete), so the server never sees a delete for an asset
it has not indexed.
§The delegate
accept_hand_off verifies a hand-off (verify_hand_off), persists it durably through a
DelegateInbox and only then returns the HandOffAck. upload_hand_off drives the
requests in ladder order under the delegate’s own StagedScheduler (its own battery and
metering policy), and settle deletes the delegate’s copy once custody of every blob it
sent is confirmed. A delegate copy is never a library asset. A held hand-off that can never
succeed — its origin revoked after acceptance, its bytes no longer verifying, or a server
refusal the delegate cannot act on — is quarantined by dispose_failure, never deleted:
a revoked origin is often a lost device, and the delegate’s copy may be the only one left. A
quarantined copy keeps its bytes, is no longer retried, and is deleted only when the user
asks (DelegateInbox::discard). A transient failure keeps the copy for the next run
(DelegationError::is_permanent).
§Transport
The hand-off is a self-verifying byte string with a content address (HandOff::address),
so it rides any channel: the peering channel (offer_hand_offs on the origin,
take_hand_offs on the delegate, a resumable ranged pull and the acknowledgement over the
same verified TLS session), or a file a CLI writes and another reads. Integrity never depends
on the channel: the delegate re-verifies every hash and the manifest’s signature, the server
verifies the signature again, and the origin trusts only custody it fetched itself. What the
channel adds is identity: a peer serves only hand-offs it sealed itself, and an
acknowledgement counts only from the device the hand-off was sealed for.
Structs§
- Delegated
Upload - What
upload_hand_offdid. - Delegation
- One delegated asset, as the origin records it.
- HandOff
- One asset’s sealed upload bundle, as it moves from the origin to the delegate.
- Hand
OffAck - A delegate’s acknowledgement: it verified the hand-off and persisted it durably. Not custody.
- Hand
OffHeader - The hand-off’s header: who handed what to whom, and each member’s upload request.
- Memory
Inbox - An in-memory
DelegateInbox: durable for the life of the process. - Origin
Ledger - The origin’s record of every asset it handed off: pinned until its own custody check passes, re-queued on a deadline or a revocation.
- OwnBlob
- One blob the origin handed off, as the origin itself computed it.
- Quarantine
- Why a held hand-off was quarantined, recorded beside its copy when it was.
- Sealed
Hand Off - A sealed hand-off: the container to send and what the origin records about it.
- Taken
Hand Off - What became of one hand-off a peer offered.
- Taken
Hand Offs - What one session of
take_hand_offsdid. - Verified
Hand Off - A hand-off the delegate verified: every member hashes to what its request declares, the signed manifest verifies under the origin’s published key, and every member is the one the manifest commits to.
Enums§
- Delegation
Error - Why a hand-off could not be sealed, accepted, uploaded or settled.
- Delegation
State - Where a delegation stands on the origin.
- Delete
Disposition - What
OriginLedger::hold_deletedid with a signed delete. - Held
Failure - What
dispose_failuredid with a held hand-off a run could not deliver. - Release
Outcome - What
OriginLedger::releasedecided. - Requeue
Reason - Why a delegation was re-queued.
- Settled
- What
settledid with the delegate’s copy.
Constants§
- DEFAULT_
HAND_ OFF_ DEADLINE_ MS - How long an origin waits, by default, for a delegated asset’s custody before it re-queues the upload itself.
- HAND_
OFF_ FORMAT - The hand-off container format this build writes, and the newest it reads.
- MAX_
HAND_ OFF_ HEADER - The largest header a hand-off may declare. The header is a few kilobytes of JSON (one upload request per blob); the ceiling bounds a malicious length prefix.
- PERMANENT_
UPLOAD_ REFUSALS - The server’s
error.*codes that refuse a hand-off’s requests for good. The delegate sends the origin’s signed requests verbatim and can change none of them, so no later run of the same hand-off can succeed:
Traits§
- Delegate
Inbox - Where a delegate keeps the hand-offs it accepted until custody is confirmed. Never a library: a delegate copy is not an asset of the delegate’s.
Functions§
- accept_
hand_ off - Take a hand-off: verify it (
verify_hand_off), persist it durably ininbox, and only then acknowledge it. - accept_
hand_ off_ from accept_hand_offfor a hand-off pulled over a peering channel frompeer, the device the channel’s handshake verified: the hand-off must also have been sealed by that peer, so a peer can hand over only its own uploads.- dispose_
failure - Decide the fate of the hand-off of
asset_idheld underaddressaftererror: a permanent refusal quarantines the delegate’s copy under aQuarantinenote namingkind, so it neither fails every later run nor is lost; a transient one keeps it held. - offer_
hand_ offs - The origin’s side of a hand-off over a verified peering channel: offer each sealed
hand-off to the channel’s peer, serve its ranged pulls, and take its acknowledgements,
authorizing every request against
trust(serve). - seal
- Seal
bundlefordelegate: the full upload bundle exactly as the origin would upload it, and the hashes the origin computed itself. - settle
- Delete the delegate’s copy of
hand_offonce the server holds every member it can receipt, by custody facts the delegate fetched with its own session throughcoordinator. Deferred members (deferrednon-empty) keep the copy. - take_
hand_ offs - The delegate’s side of a hand-off over a verified peering channel: pull each hand-off the
peer offers, verify it (
accept_hand_off_from, so it must be the verified peer’s own), persist it durably, and only then acknowledge it over the same channel. - tier_of
- The ladder tier a blob role belongs to (transfer upload doc, §Upload Tiering).
- upload_
hand_ off - Upload a verified hand-off under the delegate’s own session, in the order the delegate’s own
schedulerpermits — its battery and metering policy, not the origin’s. Each member’s request is sent exactly as the origin built it. - verify_
hand_ off - Verify a hand-off addressed to
delegate_device, all or nothing.