Skip to main content

Module compiler

Module compiler 

Source
Expand description

UCAN → Type Enforcement policy compiler (S5 / #571).

Compiles a validated UCAN grant into a TE CompiledPolicy, then verifies the compiled policy grants no permission the grant does not authorize (no privilege escalation) before it is signed. Deny-by-default, fail-closed.

Three steps: compile (grant → TE allow-rules), check_no_escalation (compiled policy ⊆ grant), and compile_policy (compile, check, sign — signs only if the check passes).

The capability → rule mapping is the PermissionMap seam; the concrete S3 action vocabulary (#582) plugs in here.

Structs§

AccessRequest
A concrete access request: the (resource, ability, caveats) a subject presents.
PrivilegeEscalation
A rule the compiled policy grants that the UCAN grant does not authorize — a privilege escalation. A policy with one of these must never be signed.

Enums§

CompileError
Errors from compile_policy.

Traits§

PermissionMap
Maps a UCAN capability to the TE rules it grants. The injection point for the concrete action vocabulary — the production impl is crate::mac::permission_map::ScopePermissionMap (#676).

Functions§

authorize
Decide a request against a UCAN grant directly, independent of any compiled policy: permit iff some capability in the grant authorizes it, else deny. This is the reference used to check the compiled policy.
authorize_at
As authorize, but also deny if now is outside the grant’s validity window [not_before, expiration] (inclusive) — matching the chain validator’s temporal gate.
check_no_escalation
Verify the compiled policy grants no permission beyond the UCAN grant.
compile
Compile a validated UCAN grant into a TE policy: the union of every capability’s rules over the given lattice generation. Deterministic (order-independent), and emits no rule not granted by some capability.
compile_policy
Compile a policy from a validated UCAN grant, verify it does not escalate, and sign the approval — signing ONLY if the check passes (fail-closed). The caller must have already validated the UCAN chain. Returns the compiled policy (for distribution) and the signed approval (for the loader).
missing_permission
The first rule the grant’s capabilities map to that the compiled policy omits, if any — a completeness gap. Non-security (a narrower policy never over-grants) and NOT part of the signing gate; for diagnostics only.