Expand description
Type-Enforcement evaluator — the Policy Decision Point hot-path core (S4 / #570).
A TOTAL, default-deny function (subject_ctx, object_label, action) → Decision over the
compiled TE matrix AND the independent MAC lattice floor. This is intentionally tiny and
verifiable — it is the data-plane evaluator that runs per op. It is NOT Casbin’s
general string matcher (that stays control-plane; see crate::mac module docs).
§Two independent checks, conjoined (design §3, §10)
PERMIT(subject, object, action) ⟺
te_matrix.permits(subject.type, object.type, action) ← compiled TE (authority gate)
∧ subject.clearance ⊒ object.label ← MAC floor (content-truth, IFC)The lattice floor is the intrinsic dominance on S1’s SecurityLabel
(SecurityLabel::can_access) — it takes no policy argument and no Lattice lookup, so it
is uncircumventable: no TE entry, grant, or token can relax it (design §1 invariant 3).
Default is DENY: an unknown subject type, object type, action, or a non-dominating /
unlabeled clearance → DENY. There is no permissive mode.
§S1 reconciliation (#567 landed)
- The floor is S1’s intrinsic
SecurityLabel::can_access, not aLattice::can_accesstrait method. The evaluator still holds the S1Latticepolicy object, but only for well-formedness concerns (column alignment / validation / version binding), never for the per-op order. - The subject’s
clearancecarried inSubjectCtxis the clearance label the PEP already produced from a verified [SecurityContext] (assurance clamped to the verified key material — #548). The PEP, not this evaluator, applies that clamp. - “Unlabeled ⇒ deny” lives at the PEP boundary: a subject/object with no S1 label is
Option::Noneand never reachesevaluate. There is deliberately noDefaultSecurityLabel.
§Relationship to the AVC and to Casbin
- The AVC (
crate::mac::avc) caches the output of this function so the PEP (S2) never re-runs it per op once warm. This evaluator is what fills the cache on a miss, and is itself cheap enough to be the miss path. - Casbin authors the policy; S5’s compiler lowers it into the
TeMatrixentries this evaluator reads. Casbin’sEnforcer::enforceis NEVER on this path.
Structs§
- Action
- Interned id of an action / op. One per distinct op in the compiled policy. Maps from
S3’s action vocabulary at compile time — see
Action::from_scope_actionfor the canonicalScopeAction→id assignment so a compiled matrix and a PEP agree on ids. - Lattice
TeEvaluator - Concrete PDP: a compiled
TeMatrix+ the S1Latticepolicy object. Small, total, allocation-free on the hot path. This is the verifiable TCB core. - Object
Ctx - The object’s security context: a TE object type plus its content-bound label. The label
comes ONLY from the content-addressed manifest (design §3, §14 “labels ONLY from
manifests”), never from a token. The PEP resolves it (S1
LabeledObject::security_label,None⇒ deny before this point) before calling the evaluator. - Object
Type - Interned id of a TE object type. One per object class in the compiled policy.
- Subject
Ctx - The subject’s security context as the evaluator sees it: a TE type (domain) plus the
lattice clearance. Built by the PEP from the Ed25519-verified token/claims (design §2
“subject ctx from Ed25519 claims”) via S1’s [
SecurityContext] — the clearance carried here isSecurityContext::clearance(), with assurance already clamped to the verified key material (#548). The TE type is an interned id; the clearance is S1’sCopystructured label — both cheap to pass per op. - Subject
Type - Interned id of a TE subject type (SELinux “domain”). One per subject security context class in the compiled policy. Stable within a policy generation.
- TeMatrix
- The compiled type-enforcement matrix: a flat allow-set of
TeRules. Default-deny — any triple not present is denied. This is the data-plane artifact loaded from signed compiled policy (seecrate::mac::compiled). Kept as aHashSetso the hot-path lookup is O(1); it is also the unit S5 produces andcompiledsigns. - TeRule
- A single permitted TE triple
(subject_type, object_type, action). The compiled matrix is the allow-set of these triples (default-deny: absence = deny). Produced by S5’s UCAN→TE compiler.
Enums§
- Decision
- The decision a PDP returns. Three-valued per design §8 —
Escalateis a deny-on-the-data-plane that the control plane may turn into a ceiling-amendment flow, but for the per-op monitor it is NOT a permit. - Scope
Action
Constants§
- ACTION_
UNRECOGNIZED - GRANT_
PATH_ OBJECT - GRANT_
PATH_ SUBJECT - Sentinel ids (B2, #674) for auditing a decision that is NOT a per-op TE
evaluation — today, the S6 grant path (
mac::exchange::evaluate_grant), which decides against a UCAN grant’s capabilities, not a compiled TE matrix.AuditRecordhas one shape (it predates the grant path); rather than fork the schema, a grant record uses these reserved ids so it is self-describing and can never collide with a real interned TE id (which starts from 0 and is bounded by the compiled registry).subject_type/object_typereuseu32::MAX;actionusesScopeAction’s id space directly when the requested ability parses, orACTION_UNRECOGNIZEDotherwise (still recorded — an audit record for an unparseable ability is exactly the diagnosable case, not a reason to drop the record).
Traits§
- TeEvaluator
- The Policy Decision Point evaluator interface — what S2 (the PEP) calls per op.