Skip to main content

Module lattice

Module lattice 

Source
Expand description

Lattice surface for the PDP — re-export of S1’s canonical types (#567).

S4 (#570) originally developed the TE evaluator + AVC against a stub lattice (StubLinearLattice + a local SecurityLabel(u32) + a Lattice dominance trait) so the two streams could proceed in parallel. S1 has landed (feature/security-mac-ucan @ 406ff9fdc) with the real, canonical types in hyprstream_rpc::auth::mac, and this file is now a thin re-export so the rest of the PDP (te.rs, avc.rs, compiled.rs) consumes S1 directly. The stub is deleted.

§What changed at reconciliation (the S1 contract, as landed)

  • SecurityLabel is no longer an opaque u32 interned id. It is S1’s structured value — a point in the product lattice Level × Assurance × CompartmentSet — and is Copy + Ord + Hash (compartments are a packed u64 bitset), so it still keys the AVC directly with no interning indirection. Crucially it has no Default: an unlabeled subject/object is Option::None ⇒ deny, never a permissive default.
  • Dominance (⊒) and join (⊔) are intrinsic to the value (SecurityLabel::can_access, SecurityLabel::join / SecurityLabel::join_all), and re-exposed on SecurityContext::can_access for a verified subject. They are NOT methods on a Lattice trait — content truth, no policy argument. The old Lattice::can_access/join trait is gone; the PDP floor now calls the intrinsic order (see te.rs).
  • Lattice is now S1’s policy object (the closed, versioned compartment name↔bit vocabulary). The PDP holds it to (a) align its TE matrix columns to the exact bits a label carries via Lattice::compartment_names, (b) validate labels at enrollment/seal, and (c) embed it, via Lattice::to_bytes, inside the signed CompiledPolicy so every process reconstructs the identical bit map (compiled). LatticeVersion is bound to CompiledPolicy.generation.

The MAC floor (per-op subject.ctx ⊒ object.label + IFC join) is computed against the intrinsic order and is independent of any grant/token/UCAN (design §3, §10).

Structs§

Compartment
A need-to-know compartment name (the categories axis vocabulary).
CompartmentSet
A fixed bitset of compartment bits — the powerset-lattice axis, packed so SecurityLabel stays Copy + Ord + Hash.
Lattice
The active lattice policy: the closed compartment vocabulary (name↔bit) and the version. Levels and assurances are fixed by their enums (TCB), so only the open dimension — compartments — needs a registry.
LatticeCodecError
Failure decoding a Lattice from its canonical byte form: either the CBOR itself was malformed or the decoded vocabulary was rejected (see LatticeDecodeError). Carries a rendered message; the distinction is not load-bearing for callers, which fail closed either way.
LatticeVersion
Monotonic lattice policy version. Crypto-agility / policy-agility rule (design §14): the suite/lattice is pinned and versioned; migration is a deliberate version bump, never an in-band negotiation. Labels and the (UCAN, bundle_hash) approval (S5) bind this version so a label minted under v1 can’t be silently reinterpreted under v2.
SecurityContext
A verified subject’s security context = the clearance label the monitor compares against object labels.
SecurityLabel
A complete security label: a point in the product lattice Level × Assurance × CompartmentSet.

Enums§

Assurance
Crypto-assurance axis (#548) — a total order derived from verified key material, never claimed.
LabelError
Reasons a label fails the well-formedness policy. All are fail-closed.
LatticeDecodeError
Reasons a serialized Lattice is rejected on decode. All fail-closed: a malformed wire vocabulary never silently becomes a smaller/different lattice.
Level
Multi-Level-Security sensitivity level — a total order (the MLS axis).
VerifiedKeyMaterial
How a principal’s key material was verified, used to derive (never trust) an Assurance. Produced by the envelope/claims verification layer — this type is the seam between “what crypto verified” and “what the lattice sees”.

Constants§

MAX_COMPARTMENTS
Number of distinct compartments representable in a label.

Traits§

SubjectContextClaims
Seam for carrying a subject clearance on the verified claims/envelope.

Functions§

ifc_join
IFC convenience: join a slice of input labels into the derived label (design §3 — sealed at rollup). Thin forwarder over S1’s intrinsic SecurityLabel::join_all. Non-empty joins use the per-axis algebraic identity (Public, PqHybrid, {}); empty input instead yields the fail-closed (Public, Unverified, {}), which the seal/rollup policy (S2) must treat as suspicious. This is the function S6/seal-time labeling calls; it lives here so PDP callers have a single entry-point without reaching across crates.