The YAML policy schema is the interface between humans and the policy engine. Its design determines how easy policies are to write, review, and maintain. This article explains the design principles behind Authensor's policy schema.
Readable by non-engineers: Security teams, compliance officers, and managers should be able to read and understand policies without programming knowledge.
Machine-evaluatable: The schema must be unambiguous. Every valid policy must produce a deterministic evaluation result.
Composable: Multiple policies can be merged. Base policies and override policies combine predictably.
Safe by default: A minimal or empty policy should deny everything, not allow everything.
version: "1"
metadata:
name: "Production policy"
description: "Safety rules for the production agent"
owner: "security-team"
updated: "2026-02-15"
rules:
- tool: "search.web"
action: allow
- tool: "file.write"
action: escalate
when:
args.path:
not:
startsWith: "/tmp/"
reason: "Writes outside /tmp/ need approval"
- tool: "*"
action: block
reason: "Deny by default"
Each rule has:
tool: A tool name or pattern (supports * wildcards)action: What to do (allow, block, escalate)when: Optional conditions on arguments and contextreason: Human-readable explanation (required for block and escalate)metadata: Optional data for approval routing, SLA, etc.The when block uses nested matchers that read like natural language:
when:
args.amount:
gt: 100 # Amount greater than 100
args.to:
not:
endsWith: "@company.com" # Not an internal email
context.role:
equals: "engineer" # User role is engineer
Available matchers: equals, not, startsWith, endsWith, contains, matches (regex), gt, lt, gte, lte.
YAML was chosen over JSON, TOML, or a custom DSL for several reasons:
The policy schema is defined as a JSON Schema. This enables:
The version field enables schema evolution. When the schema changes (new matchers, new fields), the version increments. The policy engine can evaluate policies of any supported version, maintaining backward compatibility.
Allowlist: List allowed tools explicitly, block everything else with a catch-all * rule at the bottom.
Blocklist: Allow everything by default, block specific patterns. Less safe but simpler for low-risk environments.
Escalation ladder: Multiple rules for the same tool with different conditions, escalating from allow to escalate to block based on argument values.
Explore more guides on AI agent safety, prompt injection, and building secure systems.
View All Guides