Skip to main content

Module policy_guard

Module policy_guard 

Source
Expand description

Context-policy-pack enforcement for the MCP server pipeline (GL #673).

Consults the resolved active policy (crate::core::policy::runtime) to allow/deny tool calls, in addition to the super::role_guard. This is the runtime half of Context Policy Packs v1 (GL #489), whose engine module ships the format/validation/CLI and defers enforcement to here.

  • Opt-in: with no active pack, every tool is allowed (current behavior).
  • Local-Free: only the agent pipeline is constrained, never a human’s own local reads.
  • No self-lockout: the EXEMPT_TOOLS meta tools can never be policy-denied, so an operator can always switch roles/policies back out.

Structs§

PolicyCheckResult

Functions§

audit_egress
Audit a blocked egress (write/action) DLP decision (GL #676). Privacy-preserving: records the rule/class label (forbidden-pattern:…, secret, pii:…, rate-limit) — never the matched content.
audit_filter
Audit a content-filter decision (GL #675). Privacy-preserving: records only the detector classes and counts (e.g. pii:iban×2) — never the matched values. A blocked decision additionally surfaces a policy-violation event; redactions are recorded as SecretDetected for the compliance ledger.
check_tool_access
Check whether tool_name is allowed by the active policy pack, recording an audit entry on denial (same APIs as super::role_guard).
into_call_tool_result
redact_result
Apply the active policy’s redaction patterns to outbound tool result text. Returns the (possibly redacted) text and the number of redactions applied. No-op (hits == 0, original text) when no pack is active or it has no [redaction] block.