Skip to main content

Module partition

Module partition 

Source
Expand description

The partition metadata record and provisioning API — format v3.

Implements the “partition record and provisioning” sections of the design spec (the format-reservations spec, §3, §4). Deliberately scoped to exactly that: this module does not touch the pack/idx entry layout (§1, §2) and does not add context or key_epoch fields to any packed byte — those stay gated on the open (hash, context) ruling and land in a later change.

Two files, at two different levels, because two different things are recorded and only one of them should ever leave the machine:

<store_root>/
  partitions.local.json          — LOCAL subject bindings, store-level.
                                   NEVER replicated. NEVER inside any
                                   partition directory.
  <partition_id_hex>/
    partition.json               — the PORTABLE partition record.
    active/ packs/ manifests/

The guarantee this schema exists to make structural, not aspirational: retention must reach a person partition identically to a household partition. PartitionStore loads PartitionRecord (portable: retention class, key epoch, timestamps) but never loads or holds a Subject — subject is read only inside crate::store::PartitionStore::create, to verify the derivation, and is then written straight to the store-level local-binding file. No accessor on PartitionStore returns a Subject. Any future code that wants retention (or anything else) to behave differently for a person than a household would have to change a function signature to reach the subject at all — a visible act with an owner, not a quiet conditional.

Structs§

LocalBinding
One entry in the store-level LOCAL_BINDINGS_FILE: the subject a partition was provisioned for, plus a free-text label. Never parsed for semantics beyond subject.
PartitionKey
The reserved key-material slot inside PartitionRecord. kek_ref and kek_scheme are opaque and unresolved today — storage-kit never parses, resolves, or logs either field. Both are null until the key hierarchy lands (the security review, concurrent, out of scope here); a non-null value is rejected on read, fail-closed, the same discipline as the pack/idx reserved fields.
PartitionRecord
partition.json — the portable partition record. Replicated verbatim with the data (spec §3.2): retention class and key state are properties of the bytes, not of the store root they happen to sit in today.
PartitionSpec
Input to crate::store::PartitionStore::create. Deliberately carries no default retention class and no default encryption mode: both fields are required, so a caller must choose. “Retention decided before ingest, not retrofitted” cannot be enforced by a constructor that silently fills one in — the same discipline applies to encryption_mode, which is the field that makes sealed-by-default fail closed rather than depending on every caller remembering.
Subject
A partition’s subject: which principal it was provisioned for. Recorded only in the store-level LOCAL_BINDINGS_FILE, never inside a partition directory.

Enums§

EncryptionMode
The closed encryption-mode vocabulary (spec §3.2, added per §R.2 / the security review’s D-1). Set at creation, never changeable in place — there is no set_encryption_mode, exactly as there is no set_retention_class; no transition is legal in either direction.
RetentionClass
The closed retention-class vocabulary (spec §3.4). Each class changes GC behaviour; a class that only labels is a taxonomy and does not belong here. Deliberately excludes: any retention period (retain_days, expires_at), a legal_hold/hold class, an audit/compliance class, and any access-time or access-count field — each refusal is load-bearing and is spelled out in the spec.
SubjectKind
The subject-kind vocabulary for a local partition binding (spec §3.6, amended by §R.5). Closed, forever, at exactly three values: person, household, and service. Each is a derivation prefix for a principal that gets its own partition — recording a derivation input is not adding a taxonomy, and this enum being closed is what makes that true.

Constants§

LOCAL_BINDINGS_FILE
File name of the store-level, never-replicated local binding record. Lives at the store root, not inside any partition directory — see the module docs and spec §R.4/Q2.
PARTITION_RECORD_FILE
File name of the portable, replicated partition record inside a partition directory.

Functions§

copy_partition_record
Copy partition.json from source_store_root to dest_store_root for partition_id (spec §3.8). Copies the portable record only — never LOCAL_BINDINGS_FILE, which is not inside any partition directory and so is out of reach of a per-partition copy by construction.