Expand description
Refuse-by-default validation invariants — the operational core of the threat model (SSoT: Threat Model — Validation Invariants).
These are pure, key-less structural checks: the protocol/capability handshake
(protocol) and the server-side manifest envelope (structural). They mirror the
client-side checks in verify_asset, and the server
write paths consume them today — the envelope gate, the ops surface, the feed,
federation pull, and the drop routes all validate through here. This module used to describe those consumers as
deferred; they are six live call sites, and the checks are the only thing standing
between a key-free server and a malformed write.
Upload-transport-specific invariants (chunk offset/4 KiB alignment, cumulative size) live with the deferred upload protocol.
Structs§
- Envelope
Context - Context a key-less server holds when validating a non-upload lifecycle manifest.
Enums§
- Envelope
Reject - A keyless envelope decision over a manifest core plus the server-known context.
- Handshake
Reject - A handshake rejection. Each maps to a fail-closed rule and an HTTP status.
Functions§
- album_
pin_ matches - Part of invariant 6: the album’s pinned
protocol_versionequals the request’s. - amk_
version_ monotonic - Invariant 18:
amk_versionnever regresses for an album (server’s structural backstop; MLS is the authority on the ceiling — seeverify_asset). - check_
manifest_ envelope - Run the keyless envelope checks (2, 6, 7, 8, 17, 18) over a lifecycle manifest core.
Returns the first invariant violated, or
Ok(()). - check_
metadata_ blob_ envelope - Invariant 25 as a refuse-by-default decision: run on any write whose bundle carries a
metadata blob (a
createbundle, at finalization, or a non-uploadmetadata-update). The blob’s content hash must equal the manifest’s committedmetadata_blob_hash. Key-free — the server never decrypts (SSoT: Threat Model — invariant 25, Metadata — Local and Server Metadata Equivalence). - check_
sidecar_ schema - Reject a
sidecar_schemaabove the receiver’s max known (Postel cross-version closure). - check_
suite - Reject a
crypto_suite_idthe receiver does not implement (invariant 2). - content_
type_ allowed - Invariant 5:
content_typeis in the closed allow-list for this protocol version. - device_
added_ before - Invariant 7 (time half): the device’s directory
added_atprecedes the manifesttimestamp.Noneon an unparseable timestamp (the caller rejects with400). - hash_
length_ ok - Invariant 3: the declared content hash length matches the digest size for the suite.
(Type-level true for
Hash32, but checked explicitly for wire-decoded lengths.) - metadata_
blob_ hash_ matches - Invariant 25 (key-free): the metadata blob in the bundle has a content hash equal to the
manifest’s committed
metadata_blob_hash. The server holds no key, but it hashes the ciphertext object it stores and compares it against the signed manifest field, so a client cannot present a metadata blob different from the one its manifest is signed over.falsewhen the manifest commits to no hash — a bundle carrying a blob must be committed to. - prior_
hash_ matches - Invariant 17:
prior_provenance_hashequals the last accepted manifest’s hash for this asset.stored_headisNonefor a never-seen asset (only acreateis valid then). - protocol_
gate - Gate a request’s
protocol_versionagainst the server-advertised[min, max]window. Reads succeed for any past version (callers skip this on read paths); this is the write gate. - size_
in_ bounds - Invariant 4: declared size is in
(0, max_file_size]. - timestamp_
within_ drift - Invariant 8: the self-asserted
timestampis within±drift_daysof the server clock. A non-security gross-drift guard.Noneon an unparseable timestamp.