Expand description
Fjall-backed storage for in-flight backup bundles.
See docs/05-design-notes/backup-descriptor-pattern.md for the
full state machine. Brief recap: every initiate-export /
initiate-import mints a BundleRecord, the bytes live
separately on disk under ${data_dir}/backups/{bundle_id}.vtabak,
and a background sweeper transitions expired records to
Expired (terminal) and deletes the on-disk bytes.
Tokens are stored as SHA-256(token_b64) so a leaked database
does not yield usable bearer credentials. Validation in the blob
endpoint uses constant-time comparison via subtle::ConstantTimeEq.
Structs§
- Bundle
Record - Persistent record for an in-flight backup bundle. The
token_hashisSHA-256(token_b64_url)— the plaintext token is returned to the client exactly once at mint time and never stored. - Bundle
Token - Plaintext token returned to the client at descriptor mint time. Zeroized on drop so it doesn’t linger in memory after the descriptor is built.
Enums§
- Bundle
Kind - Bundle kind — export bytes flow VTA → operator, import bytes flow operator → VTA. Encoded on the record so the same keyspace can hold both directions without separate prefixes.
- Bundle
State - Per-bundle state machine. Transitions are recorded in
docs/05-design-notes/backup-descriptor-pattern.md§“State machine”.
Functions§
- delete_
bundle - Remove a bundle record. Called by the sweeper after a terminal state ages out of the 24h audit retention window.
- get_
bundle - Fetch a bundle record by id.
- hash_
token - Hash a bearer token to the form persisted in
BundleRecord::token_hash. PlainSHA-256over the UTF-8 bytes of the base64url-encoded token. Used both at mint time and at validation time so the two values are guaranteed to be derived the same way. - list_
bundles - Enumerate every persisted bundle. The sweeper iterates this to find candidates for TTL expiry and post-terminal cleanup. Operator audit tooling can also consult it to inspect open transfers.
- mint_
token - Mint a fresh bearer token for a new bundle.
- store_
bundle - Insert or replace a bundle record. Called at every state transition (mint, blob-endpoint hit, finalize, sweeper expiry).
- verify_
token - Constant-time check that the caller-supplied
X-Backup-Tokenmatches a stored hash. Returnstrueon match. Returnsfalsewithout revealing where the mismatch is (no early return on a per-byte loop).