@mnemom/policy-engine’s internal Policy shape — capability mappings, forbidden rules, escalation triggers, and defaults. The policy engine evaluates every tool call against this shape before execution.
You do not author a standalone Policy YAML file. A
Policy object is derived at evaluation time from an agent’s canonical alignment card via extractPolicyFromCard() — capability_mappings comes from the card’s capabilities section, forbidden from enforcement.forbidden_tools, escalation_triggers from autonomy.escalation_triggers, and defaults from enforcement.{allow_unmapped_tools,fail_open,mode,grace_period_hours}. To author policy, edit the card — see Alignment Card Schema — and validate/publish it with mnemom card validate / mnemom card publish. The mnemom policy init/validate/publish commands this page’s examples once referenced were removed; use the card equivalents. This page remains the source of truth for anyone implementing a policy-engine client, writing CI checks against the evaluator’s shape directly, or reading evaluatePolicy()’s output.Schema version
The current schema version is1.0.
Schema versions follow semantic versioning for backward compatibility. All
1.x schemas are backward-compatible with 1.0 — new optional fields may be added, but no existing field will change meaning or become required. A major version bump (e.g., 2.0) indicates a breaking change and will be accompanied by a migration guide.schema_version field is required in every policy file. The policy engine rejects files with an unrecognized schema version.
Complete schema definition
A valid policy YAML file contains five top-level keys:meta, capability_mappings, forbidden, escalation_triggers, and defaults.
meta (required)
Identifies the policy and controls merge behavior.
capability_mappings (required)
A map of capability names to their definitions. Each capability groups related tools under a semantic name that corresponds to bounded actions in the agent’s alignment card.
Tool pattern syntax
Tool patterns use glob syntax for matching:
The
card_actions array must reference entries defined in the agent’s alignment card under autonomy.bounded_actions (unified) / autonomy_envelope.bounded_actions (AAP protocol) — on the card itself this binding is authored as capabilities.<name>.required_actions (see Alignment Card Schema §capabilities); the extractor renames it to card_actions for the evaluator’s internal shape.
forbidden (required, can be empty array)
An array of rules that unconditionally block specific tools. Forbidden rules are evaluated before capability mappings.
Severity enforcement behavior
Severity determines how the policy engine handles a match:Even in
enforce mode, medium and low severity forbidden rules produce warnings rather than hard blocks. This allows you to track usage of discouraged tools without disrupting agent operation. Use critical or high for tools that must never be called.forbidden has no rules, pass an empty array:
escalation_triggers (optional, defaults to empty)
An array of conditional rules that flag tool calls for human review, add warnings, or deny access based on pattern expressions.
Action behavior
Condition expressions
Thecondition field currently supports one expression type:
tool_matches() uses the same syntax as tool patterns in capability_mappings and forbidden. Future schema versions may add additional expression types (e.g., session_count_exceeds(n), time_since_last_escalation()).
If escalation_triggers is omitted, it defaults to an empty array.
defaults (required)
Controls fallback behavior for tools that do not match any capability mapping or forbidden rule.
Validation rules
The policy engine validates every policy file on load. A policy that fails validation is rejected entirely — partial policies are never applied.meta validation
meta validation
meta.schema_versionmust be present, a string, and a recognized version (currently"1.0")meta.namemust be present and non-emptymeta.scopemust be exactly"org"or"agent"meta.description, if present, must be a string
capability_mappings validation
capability_mappings validation
- Must be a mapping (YAML object), not an array or scalar
- Each entry key (capability name) must be a non-empty string
- Each entry must have a
toolsarray with at least one element - Each element in
toolsmust be a non-empty string (valid glob pattern) - Each entry must have a
card_actionsarray with at least one element - Each element in
card_actionsmust be a non-empty string description, if present, must be a string- Duplicate capability names are rejected
forbidden validation
forbidden validation
- Must be an array (can be empty)
- Each element must have
pattern(non-empty string),reason(non-empty string), andseverity severitymust be one of:"critical","high","medium","low"- Overlapping patterns are permitted (all matching rules fire)
escalation_triggers validation
escalation_triggers validation
- If present, must be an array
- Each element must have
condition(non-empty string),action, andreason(non-empty string) actionmust be one of:"escalate","warn","deny"conditionmust be a valid expression (currently onlytool_matches('...')is supported)- Invalid condition expressions produce a validation error
defaults validation
defaults validation
unmapped_tool_actionmust be present and one of:"allow","deny","warn"unmapped_severitymust be present and one of:"critical","high","medium","low"fail_openmust be present and a booleanenforcement_mode, if present, must be one of:"warn","enforce","off"grace_period_hours, if present, must be a non-negative number
Full annotated example
The following is a complete, realistic policy for a customer support agent. It maps browser and filesystem tools to alignment card actions, forbids dangerous operations, sets up escalation triggers for sensitive patterns, and uses warn mode with a 24-hour grace period.Walkthrough
-
meta— The policy is scoped to a single agent (scope: "agent"), meaning it layers on top of an org-level baseline via the merge rules described below. -
capability_mappings— Four capabilities are defined.web_browsinguses a catch-all glob (mcp__browser__*) as its last pattern, ensuring any browser tool not explicitly listed still maps to this capability.knowledge_base_readandknowledge_base_writeseparate read and write filesystem operations. -
forbidden— Six rules block destructive operations. Thecriticalandhighseverity rules will be hard-blocked in enforce mode. Themediumseverity rule formcp__browser__execute_scriptproduces a warning even in enforce mode, since it is discouraged but not categorically dangerous. -
escalation_triggers— Ticket updates require human approval during ramp-up. File writes and external navigation are permitted but logged. -
defaults— Unmapped tools produce amediumwarning (not blocked).fail_open: falseensures that policy engine errors are treated as denials. The 24-hour grace period means a newly deployed policy runs in warn mode for the first day, even ifenforcement_modeis later changed toenforce.
Merge semantics
The one merge function that remains inpolicy-engine is mergeTransactionGuardrails(basePolicy, txnPolicy) — an ephemeral, per-request restriction layered on top of the (already-merged) card-derived policy for a single transaction. It is not org/agent composition, and it is not multi-agent/counterparty coordination.
A transaction guardrail can only restrict the base policy it’s layered on — never expand it. Use this when a single transaction (e.g. a high-value action) needs a tighter, request-scoped policy than the agent’s standing card-derived one.
Evaluation order
When a tool call is evaluated against the effective policy, the engine follows this order:- Forbidden rules — If any forbidden rule matches, the tool call is flagged as a violation with the corresponding severity. Evaluation continues (all matching forbidden rules are collected).
- Escalation triggers — All matching triggers fire. Actions (
escalate,warn,deny) are collected. - Capability mappings — The tool is matched against capability patterns in declaration order. The first matching capability is used. If matched, the tool call is permitted (subject to any forbidden or escalation results from steps 1-2).
- Defaults — If no capability mapping matched and no forbidden rule matched, the
unmapped_tool_actionis applied. - Decision — The engine aggregates all violations, warnings, and escalations to produce a final decision:
allow,warn,deny, orescalate.
See also
- Policy Engine — Architecture and runtime behavior of the policy evaluation engine
- CLI Reference — CLI commands including
card validate,card evaluate, andcard publish - Policy Management Guide — End-to-end guide for writing and managing policies