The Policy Engine is Phase 1 of CLPI (Card Lifecycle & Policy Intelligence) — the governance layer that transforms alignment cards into lifecycle-managed artifacts with policy enforcement, trust recovery, risk intelligence, and on-chain anchoring.
The policy engine translates Alignment Card declarations into enforceable rules over concrete tools. An Alignment Card says an agent may perform web_fetch. The policy says that web_fetch means the agent can call mcp__browser__navigate and mcp__browser__click, but not mcp__filesystem__delete. The card declares intent. The policy enforces it.Policies are defined in a YAML-based DSL with five top-level sections: capability_mappings, forbidden, defaults, and optionally escalation_triggers and meta. They are evaluated in three contexts — CI/CD pipelines, live gateway requests, and post-action observation — giving operators governance coverage across the full agent lifecycle.
The policy engine is a parallel enforcement layer to alignment enforcement (observe/nudge/enforce). Alignment enforcement checks agent behavior against card values. Policy enforcement checks tool usage against policy rules. Both run independently and produce separate verdicts.
A policy file is a YAML document that declares how abstract card capabilities map to concrete tools, which tools are always forbidden, and what happens when a tool falls outside any mapping.
Copy
Ask AI
meta: name: "research-agent-policy" version: "1.2.0" description: "Policy for research agents with web and filesystem access"capability_mappings: web_browsing: tools: - "mcp__browser__*" card_actions: - "web_fetch" - "web_search" file_reading: tools: - "mcp__filesystem__read*" - "mcp__filesystem__list*" card_actions: - "read_file"forbidden: - pattern: "mcp__filesystem__delete*" reason: "File deletion not permitted" severity: "critical" - pattern: "mcp__shell__*" reason: "Shell execution not permitted" severity: "high"defaults: unmapped_tool_action: "warn" unmapped_severity: "medium" grace_period_hours: 24escalation_triggers: - condition: "tool_count > 50" action: "escalate" reason: "Excessive tool usage in single session"
The three required sections serve distinct purposes:
Section
Purpose
capability_mappings
Bridge card-level categories to concrete tool patterns
forbidden
Tools that are always blocked, regardless of mappings
defaults
Fallback behavior for tools that match no mapping
The two optional sections extend the policy:
Section
Purpose
escalation_triggers
Conditions that trigger escalation regardless of individual tool verdicts
Capability mappings reference card actions that exist in the agent’s alignment card
Historical traces would pass/fail under the proposed policy
Coverage report identifies unmapped card actions
Use case: Pre-deploy gates. A CI job runs smoltbot policy validate and smoltbot policy evaluate before merging policy changes. If evaluation shows violations in recent traces, the merge is blocked.
Live evaluation runs in real-time as requests pass through the smoltbot gateway. The policy engine extracts tool names from the request body, checks each tool against the policy, and returns a verdict.How it works:
Request arrives at the gateway
Policy engine extracts tool names from the request body
Each tool is checked against forbidden rules first
Remaining tools are matched against capability_mappings
Unmatched tools fall through to defaults.unmapped_tool_action
A verdict is returned via the X-Policy-Verdict response header
Verdict headers:
Header Value
Meaning
X-Policy-Verdict: pass
All tools passed policy checks
X-Policy-Verdict: warn
One or more tools triggered warnings (logged, not blocked)
X-Policy-Verdict: fail
One or more tools violated policy (blocked in enforce mode)
Enforcement interaction: The policy verdict determines the gateway response based on the policy enforcement mode (separate from the alignment enforcement mode):
Post-action evaluation runs after an action completes. It analyzes what actually happened against what the policy expected.What it detects:
card_gap violations: Tools that the agent used successfully but that are not represented in any capability mapping. These are tools that should be in the card but are not.
Frequency anomalies: Tools used at rates that exceed expected patterns
New tool discovery: Tools appearing for the first time, subject to grace period handling
Feeds into reclassification: Observer findings feed into the AIP reclassification pipeline. A card_gap detection triggers a proposed card amendment — suggesting that the alignment card should be updated to include the newly observed capability.
Capability mappings are the core of the policy DSL. They bridge the gap between what an alignment card declares (abstract semantic actions like web_fetch) and what agents actually invoke (concrete tool names like mcp__browser__navigate).
Tool patterns support standard glob syntax for flexible matching:
Pattern
Matches
mcp__browser__*
All browser tools (navigate, click, screenshot, etc.)
mcp__filesystem__read*
read_file, read_directory, read_metadata
mcp__*__list*
Any MCP server’s list operations
custom_tool_v?
custom_tool_v1, custom_tool_v2, etc.
Start with broad globs during initial policy development, then tighten them as you understand which specific tools your agent uses. A mapping like mcp__browser__* is fine for week one. By month two, you should enumerate the specific tools.
The policy engine has its own enforcement mode, independent of the alignment enforcement mode (observe/nudge/enforce).
Warn
Log violations but do not block. X-Policy-Verdict: warn header returned. This is the default mode.
Enforce
Block requests with policy violations. X-Policy-Verdict: fail header returned. HTTP 403 for non-streaming requests.
Off
Skip policy evaluation entirely. No X-Policy-Verdict header. No performance overhead.
Policy enforcement and alignment enforcement are parallel systems. Setting alignment enforcement to enforce does not affect policy enforcement, and vice versa. An agent can be in alignment observe mode and policy enforce mode simultaneously — meaning alignment violations are logged but policy violations are blocked.
Policy forbidden rules complement alignment card forbidden_actions. Card forbidden actions declare intent (“this agent must never delete files”). Policy forbidden rules enforce that intent at the tool level (“block all tools matching mcp__filesystem__delete*”). Both are checked — card-level by alignment enforcement, tool-level by policy enforcement.
New tools appear when agents gain new MCP server connections or when tool providers add capabilities. The grace period prevents these newly discovered tools from immediately becoming violations.
Copy
Ask AI
defaults: grace_period_hours: 24
How it works:
The policy engine tracks when each tool is first seen via tool_first_seen records.
When an unmapped tool is encountered, the engine checks how long ago it was first seen.
If the tool was first seen within the grace period window, it is treated as allow regardless of unmapped_tool_action.
After the grace period expires, the tool falls back to the configured unmapped_tool_action.
This gives operators time to update their policy after adding new tools or MCP servers, without immediately triggering violations in enforce mode.
The default grace period is 24 hours. Set it to 0 to disable grace periods entirely (strict mode). Set it higher (48-72 hours) for teams that deploy on weekly cycles and need more time to update policies.
In organizations with multiple agents, policies exist at two levels: org-level and agent-level. These are merged at evaluation time using rules that prevent agents from weakening organizational policy.
Transaction-scoped policies can further restrict the merged policy via intersection semantics. A transaction guardrail can only narrow what is permitted — never expand it.
Copy
Ask AI
# Transaction-level override: restrict to read-only tools for this operationtransaction_guardrails: allowed_capabilities: - "file_reading" - "database_read" # All other capabilities are denied for this transaction
Every policy evaluation produces a coverage report that quantifies how well the policy maps to the alignment card. This helps identify gaps between what the card declares and what the policy actually covers.
A coverage percentage below 100% means some card actions have no policy enforcement. Tools implementing those actions will fall through to the unmapped_tool_action default. Aim for 100% coverage in production policies.
Policy evaluation adds latency to gateway requests (typically under 5ms for policies with fewer than 100 rules).
Glob patterns match tool names only, not tool arguments. A tool can be permitted by policy but still violate alignment constraints based on how it is called.
Grace periods are tracked per-agent, not per-policy-version. Updating a policy does not reset grace period timers for previously seen tools.
Coverage reports require a valid alignment card. Agents without a published card receive a coverage report with 0% coverage.