Use this file to discover all available pages before exploring further.
This specification defines the behavioral contract for the Agent OS policy engine: the single enforcement point through which all governed agent actions flow. All SDK implementations — Python, TypeScript, Rust, .NET, and Go — MUST conform to this specification. The key words “MUST”, “MUST NOT”, “REQUIRED”, “SHALL”, “SHOULD”, “RECOMMENDED”, and “MAY” are interpreted as described in RFC 2119 and RFC 8174.
Conforming implementations MUST support all nine operators:
Operator
Semantics
Example
eq
Context value equals target value.
tool_name eq "execute_code"
ne
Context value does not equal target value.
agent_id ne "admin"
gt
Context value is greater than target.
token_count gt 4096
lt
Context value is less than target.
priority lt 5
gte
Context value is greater than or equal to target.
confidence gte 0.8
lte
Context value is less than or equal to target.
retries lte 3
in
Context value is a member of target collection.
tool_name in ["read", "write"]
contains
Target value is contained within context value.
arguments contains "password"
matches
Context value matches target regex pattern.
tool_name matches "^exec_.*"
Missing field behavior: If the condition references a context field that does not exist, the condition MUST evaluate to false. A missing field MUST NOT cause an error or exception.
For the matches operator, both values MUST be coerced to strings before regex evaluation. For all other operators, no implicit type coercion is performed.
When evaluating a set of rules against an execution context:
Rules MUST be sorted by priority in descending order (highest priority first).
Rules MUST be evaluated in sorted order.
The first rule whose condition matches determines the decision. Subsequent rules are NOT evaluated.
If no rule matches and external backends are registered, backends MUST be consulted in registration order. The first backend returning a non-error result determines the decision.
If no rule matches and no backend produces a result, the default action from the policy’s defaults object is applied.
When a root_dir is configured and the execution context contains a path field, the evaluator MUST use folder-scoped evaluation (governance files discovered from the action path up to the root, loaded, filtered by scope, and merged before evaluation).When no root_dir is configured or the context lacks a path field, the evaluator MUST use flat evaluation against the loaded policy list.
Security boundary: Fail-closed behavior is a deliberate security design. Systems that default to allow on error create exploitable failure modes. Never change the default to fail-open.
If any unhandled exception occurs during policy evaluation, the implementation MUST:
Return a deny decision (allowed: false, action: "deny").
Include reason: "Policy evaluation error — access denied (fail closed)".
Include error: true in the audit entry.
Log the exception at ERROR level.
The deny decision MUST be produced even if the exception occurs in an external backend, a condition evaluator, or the conflict resolver.
When multiple policy candidates conflict, the PolicyConflictResolver determines which rule wins using one of four strategies:
Strategy
Enum Value
Behaviour
Deny Overrides
deny_overrides
Any deny rule wins over any allow, regardless of priority.
Allow Overrides
allow_overrides
Any allow rule wins over any deny, regardless of priority.
Priority First Match
priority_first_match
Highest priority value wins regardless of action. Default.
Most Specific Wins
most_specific_wins
Agent scope > Tenant scope > Global scope; ties broken by priority.
Scope specificity order: Agent > Tenant > Global.Conforming implementations MUST support all four strategies. The strategy MUST be configurable at engine construction time.
During folder-level policy merge, a child policy MUST NOT override a parent deny rule with an allow rule, even if override: true is set. A child that attempts to override a parent deny MUST have its override dropped silently.
where BackendDecision is one of "allow", "deny", or "review".Backends MUST be consulted only after local rules fail to match. If a backend returns an error, the engine MUST treat it as a deny (fail closed). Multiple backends are consulted in registration order; the first non-error result wins.
When root_dir is configured, the engine discovers governance.yaml files from the action path up to the root directory. Policies are merged with the following rules:
Root policies apply to all paths (lowest specificity).
Subfolder policies apply only to their subtree (higher specificity).
Child policies MAY override parent rules with override: true, except parent deny rules (immutability invariant).
The inherit: false field stops the merge at that level.
Policy discovery MUST validate that action paths are within the configured root to prevent loading policies from arbitrary filesystem locations. Any path containing .. components MUST be rejected.
Implement folder-level policy discovery and merge.
Enforce the deny immutability invariant.
Implement path traversal protection.
Support all four conflict resolution strategies.
Support the ExternalPolicyBackend protocol.
Enforce fail-closed semantics on all evaluation errors.
Produce structured audit entries for every decision.
Support YAML serialization for PolicyDocument.
Framework adapters using GovernancePolicyMUST additionally:
Validate policies at construction time.
Support exact, glob, and regex pattern types.
Enforce the tool call interception order.
Enforce concurrency limits.
The reference conformance test suite contains 68 tests covering all MUST requirements. Cross-language SDK compatibility is verified by running the same YAML policy files against each SDK’s evaluator.
version: "1.0"name: "no-code-execution"rules: - name: block-execute condition: field: tool_name operator: eq value: execute_code action: deny priority: 100 message: "Code execution is not permitted in this environment"defaults: action: allow
Context: {"tool_name": "execute_code", "agent_id": "assistant-1"}Expected: allowed: false, matched_rule: "block-execute", reason: "Code execution is not permitted in this environment"