pub struct PolicyEngine { /* private fields */ }Expand description
The policy engine evaluates actions against configured rules
Implementations§
Source§impl PolicyEngine
impl PolicyEngine
pub fn new(tool_allowlist: ToolAllowlist, default_budget: Budget) -> Self
Sourcepub fn evaluate_tool_call(&self, tool_name: &str) -> PolicyDecision
pub fn evaluate_tool_call(&self, tool_name: &str) -> PolicyDecision
Evaluate whether a tool call is allowed.
Now gathers every matching verdict from the allowlist and runs
them through crate::precedence::resolve_conflicts, so two
disagreeing policies produce a deterministic winner plus a full
explanation trace surfaced on PolicyDecision::trace. Behaviour
matches the legacy short-circuit (Deny > RequiresApproval > Allow > default-deny) — back-compat is covered by existing tests.
Sourcepub fn evaluate_tool_call_with(
&self,
allowlist: &ToolAllowlist,
tool_name: &str,
) -> PolicyDecision
pub fn evaluate_tool_call_with( &self, allowlist: &ToolAllowlist, tool_name: &str, ) -> PolicyDecision
Evaluate a tool call against a caller-supplied allowlist instead of the engine’s process-global default.
The gateway uses this to hold each run to its own agent’s configured
tools (deny / approval-required / allowed tiers), so deny-by-default is
keyed on the agent — not on a single empty default shared across every
run. Self::evaluate_tool_call is the special case where the allowlist
is the engine’s own default.
Sourcepub fn check_budget(
&self,
usage: &BudgetUsage,
budget: Option<&Budget>,
) -> PolicyDecision
pub fn check_budget( &self, usage: &BudgetUsage, budget: Option<&Budget>, ) -> PolicyDecision
Check if budget allows continuing. The returned decision carries a trace whose single matched verdict (if any) is the offending budget axis.
Sourcepub fn default_budget(&self) -> &Budget
pub fn default_budget(&self) -> &Budget
Get the default budget
Sourcepub fn evaluate_bench_gated_decision(
&self,
policy: &BenchAuditPolicy,
claim: &BenchGatedClaim,
summary: &BenchTrustSummary,
) -> PolicyDecision
pub fn evaluate_bench_gated_decision( &self, policy: &BenchAuditPolicy, claim: &BenchGatedClaim, summary: &BenchTrustSummary, ) -> PolicyDecision
Evaluate a routing / model-swap decision that cites an external
benchmark delta. Reuses resolve_conflicts so the bench-audit gate
shares precedence semantics with the allowlist + budget tiers — this
is a new rule source, not a parallel engine. Deny-by-default still
applies: if the BenchAuditPolicy emits no verdicts (no signal
from the eval plane), the decision is denied with an empty trace.