Tracks per-view fresh-auth grants and enforces the grace window (SR1). Owns no authentication
itself: it drives a LocalAuthGate to mint grants and then gates the sensitive view reads.
What the client sent to the server, checked against the receipt’s server-recomputed facts:
a server that took custody of different bytes cannot answer with a matching receipt.
The verify-before-destroy gate over a StorageVerifier. It never destroys anything itself:
may_release is the pure decision the three destructive paths
(device-owned-original release, Move-import source deletion, streaming-mode release) consult
before any local cleanup, and streaming import drives its per-asset release window
through the same call.
The production GraceClock: a monotonic Instant anchored at construction. Monotonic (not
wall-clock) so a user or NTP nudging the system clock can neither extend nor prematurely expire
a grant.
A short-lived proof that a live grant existed for view at the moment it was minted. Consumed
immediately by a gated read; it carries no capability of its own beyond naming the view.
The gate’s decision. Release is returned only when all three checks pass (durable
verdict, matching per-blob detail + verify_asset, and a verified receipt).
A transport error fetching a verdict or receipt from the server. A gate that cannot reach a
definitive durable/receipt answer never destroys — the caller retains and retries.
A monotonic clock for the grace window, injectable so tests drive time deterministically.
Only differences between readings are meaningful; the absolute value has no meaning.
The per-platform local-authentication seam, implemented by native code (Swift/Kotlin) behind the
capsule_core_ffi namespace’s LocalAuthGate foreign-trait mirror; a plain Rust trait here.
Rust calls into it to perform the fresh-auth challenge; core never sees the biometric or the
credential.
The client’s source of the server-side facts the gate needs: the key-free /storage/verify
verdict and whether a verified custody receipt is held for the write. The capsule-sdk
fills this over HTTP (POST /storage/verify + GET …/receipt verified under the pinned
attestation key); tests fill it with deterministic mocks. Sync by construction — the offline
data plane calls it; async callers resolve the futures before invoking the gate.
Append a verified receipt to the asset’s on-disk log ({uuid}.receipts.cbor), idempotent on
receipt_seq: re-persisting a receipt already present is a no-op, so a retried fetch never
duplicates the log. The log is stored as canonical CBOR of the receipt Vec in chain order.
media/{YYYY}/{YYYY-MM}/{uuid}.attestations.cbor — the client’s signed storage-attestation
log for the asset, kept beside its custody receipts (SSoT: Transfer — Durability: Signed
Storage Attestation). Evidence, not a cache: it is included verbatim in the backup artifact.
Reclaim cached representations until the reclaimable set fits within budget_bytes. Deletes
each evicted representation’s cache file from disk and removes its index row. A cache file that
is already gone is treated as reclaimed (not an error) and its stale row is still dropped.
Pinned and device-owned originals are never evicted by this automatic path; canonical media/
files are never candidates (they are not tracked in cached_representations).
The pure minimum-headroom verdict for a streaming import: streaming bounds peak disk to
the in-flight window, but a single asset must still fully materialize locally (original +
derivatives + metadata) before its upload and release, so the largest single asset in
the plan must fit within available space minus the headroom margin. When even one asset
cannot fit, streaming cannot proceed and the plan surfaces a hard error rather than stall
mid-stream — streaming cannot make a single file smaller than the disk.
Check the history origin just published against the pin, pin or extend it, and return
the pinned history every receipt from that server is verified under.
media/{YYYY}/{YYYY-MM}/{uuid}.receipts.cbor — the client’s custody-receipt log for the
asset, appended beside the provenance chain (SSoT: Storage Verification — Custody Receipts).
Evidentiary, not a cache: it is included verbatim in the backup artifact.
The verify-before-destroy predicate: destructive local cleanup of irreplaceable bytes
may proceed only when the server’s verdict is durable, every declared blob
individually re-checks as safely stored (the client never trusts the server’s
aggregate over the details it can recompute), and verify_asset accepted the asset.
Move-import source deletion. Deleting the external source after a Move-mode import waits
on the server’s durable verdict + a verified receipt — never on the local library copy
alone — so a crash mid-import cannot lose the only copy. Returns the decision; the source is
unlinked only on Release. The gate alone: a caller holding the library uses
Workspace::release_move_source, which
adds the read-back hash check before it reaches here.
Device-owned-original release (the cache-eviction sweep’s counterpart for owned
originals, which cache_sweep never touches
automatically). An original the device itself uploaded is the source of truth until the
server durably holds it; it is released — its local file deleted and its owned-original
representation row dropped, after which it becomes an ordinary server-only, re-fetchable
asset — only on a Release decision. On any Retain the file and row are untouched.
The pure streaming-recommendation predicate: streaming mode is recommended when the
plan’s total size, plus a configurable headroom margin, meets or exceeds the volume’s
available bytes. Attached to the plan at confirmation (never computed inside the pure
planner).
Verify a fetched receipt for a finalized upload: the hybrid signature under one of the
pinned_keys (the published attestation-key history), then that the server’s recomputed
facts match what the client sent, then the gross-drift bound on received_at.