Skip to main content
This document is the normative schema for @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 is 1.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.
The 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.
scope is a vestige of the pre-card-composition design: today, every Policy extracted from a card is hardcoded scope: "agent", because org-level policy is no longer a standalone concept — it lives in org/team card templates instead (see Card Composition), and that composition happens before the evaluator ever sees a Policy (see Merge semantics).

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:
Each tool call is matched against patterns in declaration order — the first matching capability wins. If a tool matches multiple capabilities, only the first match is used for policy evaluation. Order your capability mappings from most specific to least specific.
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.
If 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

The condition field currently supports one expression type:
The glob pattern inside 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.
Setting fail_open: true means that if the policy engine encounters an internal error, all tool calls will be permitted. This maximizes availability but reduces safety guarantees. For high-risk agents, set fail_open: false to ensure errors fail safely.

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.schema_version must be present, a string, and a recognized version (currently "1.0")
  • meta.name must be present and non-empty
  • meta.scope must be exactly "org" or "agent"
  • meta.description, if present, must be a string
  • 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 tools array with at least one element
  • Each element in tools must be a non-empty string (valid glob pattern)
  • Each entry must have a card_actions array with at least one element
  • Each element in card_actions must be a non-empty string
  • description, if present, must be a string
  • Duplicate capability names are rejected
  • Must be an array (can be empty)
  • Each element must have pattern (non-empty string), reason (non-empty string), and severity
  • severity must be one of: "critical", "high", "medium", "low"
  • Overlapping patterns are permitted (all matching rules fire)
  • If present, must be an array
  • Each element must have condition (non-empty string), action, and reason (non-empty string)
  • action must be one of: "escalate", "warn", "deny"
  • condition must be a valid expression (currently only tool_matches('...') is supported)
  • Invalid condition expressions produce a validation error
  • unmapped_tool_action must be present and one of: "allow", "deny", "warn"
  • unmapped_severity must be present and one of: "critical", "high", "medium", "low"
  • fail_open must be present and a boolean
  • enforcement_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

  1. 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.
  2. capability_mappings — Four capabilities are defined. web_browsing uses a catch-all glob (mcp__browser__*) as its last pattern, ensuring any browser tool not explicitly listed still maps to this capability. knowledge_base_read and knowledge_base_write separate read and write filesystem operations.
  3. forbidden — Six rules block destructive operations. The critical and high severity rules will be hard-blocked in enforce mode. The medium severity rule for mcp__browser__execute_script produces a warning even in enforce mode, since it is discouraged but not categorically dangerous.
  4. escalation_triggers — Ticket updates require human approval during ramp-up. File writes and external navigation are permitted but logged.
  5. defaults — Unmapped tools produce a medium warning (not blocked). fail_open: false ensures 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 if enforcement_mode is later changed to enforce.

Merge semantics

policy-engine’s own mergePolicies(org, agent) function has been removed. Org+agent merging of everything this DSL describes now happens upstream, in the Mnemom API’s canonical-card composer, over the card’s capabilities and enforcement sections — before extractPolicyFromCard() ever produces a Policy object. See Alignment Card Schema §capabilities and §enforcement for the real, current per-field composition rules (union within a capability’s tools/required_actions, platform→agent intersection for allowed_domains, strictest-wins for enforcement.*, deny-overrides union for forbidden_tools, min-across-scopes for grace_period_hours). By the time the evaluator sees a Policy, it is already a single, pre-merged, agent-scoped view — there is no separate org-vs-agent merge step left to reason about at this layer.
The one merge function that remains in policy-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:
  1. 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).
  2. Escalation triggers — All matching triggers fire. Actions (escalate, warn, deny) are collected.
  3. 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).
  4. Defaults — If no capability mapping matched and no forbidden rule matched, the unmapped_tool_action is applied.
  5. Decision — The engine aggregates all violations, warnings, and escalations to produce a final decision: allow, warn, deny, or escalate.

See also

  • Policy Engine — Architecture and runtime behavior of the policy evaluation engine
  • CLI Reference — CLI commands including card validate, card evaluate, and card publish
  • Policy Management Guide — End-to-end guide for writing and managing policies