Expand description
Runtime view of the active context policy pack (GL #673 / #489 enforcement).
active refreshes bounded policy and organization trust bytes on every
admission. Identical snapshots reuse prepared rules; changed or unreadable
inputs never reuse a stale authorization. One bounded worker serializes file
resolution and compilation without accumulating timed-out reader threads.
Opt-in & backward-compatible: with no project pack present, active
returns None and nothing is gated — existing behavior is preserved
exactly. An invalid local pack activates a deny-all policy so enforcement
never fails open.
Local-Free Invariant: enforcement derived from this view only ever constrains the agent pipeline; it never gates a human’s own local reads.
Structs§
- Active
Policy - A resolved policy plus its precompiled redaction regexes — the cached, hot-path-ready form.
- Publication
Authority - Revalidate buffered CLI data at its output and persistence boundaries. This does not lock policy files against a concurrent administrator write.
- Source
View - Stored
Lifetime - The stored lifetime of a view: its signed horizon,
Nonefor a view bound to a lifted requirement, which has none. - Stored
Publication Authority - The stored form of a
PublicationAuthority: project root, policy and role fingerprints and the lifetime of the view it was captured from. Content-free.
Constants§
- REQUIRED_
POLICY_ DIGEST_ ENV - REQUIRED_
POLICY_ ROOT_ ENV - Process-scoped pin set by explicit protected launchers; absent in Community.
Statics§
- REQUEST_
PROJECT - Per-request project authority; never mutate process CWD for MCP roots.
Functions§
- active
- The active resolved policy, or
Nonewhen no project or org pack exists. Fresh source bytes are mandatory even when compiled rules are cached. - bind_
request_ project - detached_
project_ root - Resolve the project root for a detached worker without retaining request- lifetime policy or capture state. The worker must reopen a fresh source view from this root when it stores output.
- for_
project - Resolve the explicit runtime project without using the process-global cache. Configured local/org errors remain errors rather than granting admission.
- in_
project - Run
operationas part of a request forproject. - inherited_
source_ view - Capture the pinned view when propagating a synchronous worker scope.
- is_
active - Current “is a policy active?” probe; refresh failure requires protection.
- protected_
authority_ paths - The launcher’s kernel write boundary covers the same file authorities as the bounded admission snapshot, including absent optional inputs.
- protected_
policy_ digest - The launcher and admission worker use exactly the same bounded snapshot. A deliberate authority update requires a new protected launch; changing files within the old session never silently grants the new authority.
- reload
- Re-read the project pack (e.g. after a
policyedit). Idempotent. - spawn_
for_ project - Start
operationon its own thread as part of a request forproject. A spawned thread inherits no task-local: without this it reads the configuration and admission state of the process’s own project (AP04-G3). - with_
explicit_ project_ source_ view - Run an egress preparation for one explicitly selected project. Unlike the source-view fallback helper, this rejects a conflicting trusted request root and revalidates authority after the operation before its result is published.
- with_
governed_ source_ view with_source_view, entered only when the verification the view is pinned to established something to act under: a policy, or an observed organization decision (a signed unpin leaves no policy and is one all the same).Ok(None): it established neither, no view was opened andoperationdid not run.- with_
project_ source_ view - Run a source operation with an explicit fallback project root. An existing request project remains authoritative; the fallback only fills an unbound request scope.
- with_
source_ view - Run a synchronous source operation against one freshly verified policy snapshot. Publish the returned value only if the same authority still holds. Nested calls reuse the parent snapshot; they never refresh into a weaker view.