Skip to main content

Module runtime

Module runtime 

Source
Expand description

Runtime view of the active context policy pack (GL #673 / #489 enforcement).

active loads and resolves the project policy pack (.lean-ctx/policy.toml) once, folds in a trusted central org policy as a floor when one is installed (GL #674), then caches the ResolvedPolicy together with its precompiled redaction regexes so the MCP hot path (crate::server::policy_guard and the call_tool redaction step) can consult it cheaply.

Opt-in & backward-compatible: with no project pack present, active returns None and nothing is gated — existing behavior is preserved exactly. An invalid pack is ignored (logged), never bricking the agent.

Local-Free Invariant: enforcement derived from this view only ever constrains the agent pipeline; it never gates a human’s own local reads.

Structs§

ActivePolicy
A resolved policy plus its precompiled redaction regexes — the cached, hot-path-ready form.

Functions§

active
The active resolved policy, or None when no (valid) project pack exists. Loaded once and cached; call reload after the pack changes.
is_active
Cheap “is a policy active?” probe for the hot path.
reload
Re-read the project pack (e.g. after a policy edit). Idempotent.