Expand description
A Vault record as it leaves the machine: sealed with the Vault’s collection key, so a LAN peer’s log, the relay and the cloud store see only the clear header (docs/specs/SPEC_VAULT_SHARED_ACROSS_MACHINES_LAN_AND_CLOUD_2026_11_01.md section 6.1) and never a label, a kind, a site or a value.
The seal is ChaCha20-Poly1305 with a random nonce and the associated data
agentmux-vault-sync-v1:<vault>:<record>:<version>:<epoch>:<base>, so a record replayed under another Vault, record, version
key epoch or base does not open, and an old version can’t be put back under the same id. This is a different seal from
seal.rs, which keeps a value on one machine under that machine’s own key: the record is opened with the collection
key on arrival and sealed again with the machine key.
Every function here is pure: bytes in, bytes out. Nothing reads a store, a clock or the network, so the layer that carries the records (and the cloud service that stores them) needs none of this to be built first.
Re-exports§
pub use crate::backend::user_sync::hlc::Version;
Structs§
- Place
- Where a sealed record belongs: the Vault, the record, the version and the key epoch it was sealed at. All four are in the associated data, so a record only opens at the place it was sealed for.
Constants§
- AAD_
PREFIX - The associated data’s first part: what the seal is for and its format.
- MAX_
CHUNK - A sealed record travels in pieces of at most this size. A record in AWS Secrets Manager is limited to 64 KB, and the pieces leave room for the framing around them.
- MAX_
SEALED - The most a sealed record may weigh: a Vault part is at most 1 MiB, and a file entry goes as content-addressed chunks of its own, so this bounds the record and not the file.
Functions§
- join
- The sealed record back from its pieces. A piece over
MAX_CHUNK, a short piece before the last, and a total overMAX_SEALEDare refused: a peer that sends them is not sending whatsplitmakes. - open_
raw - Opens what
seal_rawsealed forat. Fails, with one sentence for every cause, on any change to the record, on a record sealed for another Vault, record, version or epoch, and on another key. What it returns is wiped when dropped. - open_
raw_ with open_rawunder another associated-data prefix.- open_
record open_rawfor a body. The body’s ownDropwipes what it holds.- open_
tombstone - Opens a tombstone sealed by
seal_tombstone. A record that holds anything is not a tombstone and is refused. - reseal
- Seals again a record under a new key and epoch, for the background pass that follows a member’s removal: the new key is sealed to the members who remain, and every record is opened with the old key at the old place and sealed with the new at the new one. The version is the record’s own and does not change.
- seal_
raw - Seals
plainfor the placeat. The plaintext is copied into a buffer that is wiped when this returns. - seal_
raw_ with seal_rawunder another associated-data prefix (another kind of collection;user_sync::seal).- seal_
record seal_rawfor a body: its JSON, sealed.- seal_
tombstone - A tombstone sealed for
at: it holds nothing, so no value and no label can live on in it, but the seal still vouches for its place, its version and its base, so a relay can neither forge a delete nor change what it follows. - split
- A sealed record in pieces of at most
MAX_CHUNK, in order.