Deckard, Scan for Rogue AI Agents
Arthur

Policy as Code for AI Agents: Translating a Written Rule Into One a Machine Can Check

October 20, 20268 min read

Most agent policies live in a document. Someone writes "agents may only access customer data when necessary," it gets approved, and it sits in a wiki. The agent never reads it. Nothing in the runtime enforces it. When an auditor or an incident asks whether the rule held, there is no record either way.

A written policy becomes enforceable only when each clause is rewritten as a decision with typed inputs that a policy engine evaluates at a defined point in the agent's execution. That is the authoring half of the work. The other half is proving every agent actually routes through the rule, which is where discovery and monitoring come in. This post covers both.

Why prose policies do not execute

Take a clause that sounds reasonable: "Agents may only access customer data when necessary."

A policy engine cannot evaluate that sentence. Who decides what counts as necessary? Which agents does it apply to? What is "customer data," exactly, and how does the engine know a given request touches it? The clause encodes intent, not a decision. It assumes a human reader who will interpret it in context.

An engine needs the opposite: typed inputs and a deterministic effect. It needs to know the agent making the request, the action, the resource, the condition under which the action is allowed, and what to do when the condition fails. Until you supply those, the policy is advisory text, not a control.

The translation layer in five steps

Turning a clause into an enforceable rule is a repeatable process. Run every clause through the same five steps.

  1. Normalize the clause into five parts: subject, action, resource, condition, effect. "Agents may only access customer data when necessary" becomes, roughly, subject = agent, action = read, resource = customer-data, condition = request is within the agent's declared purpose, effect = permit (else deny).
  2. Define the inputs as typed attributes. The engine needs real fields to evaluate against: agent id, owner, risk tier, the tool being invoked, the data class of the resource, the agent's autonomy level. Each becomes a typed attribute the decision can reference. Vague conditions like "when necessary" force you to pick a concrete proxy, for example, the data class must match the agent's declared scope.
  3. Pick the policy decision point and the enforcement point. The decision point is where the rule is evaluated. The enforcement point is where the effect is applied. They are often different places, and naming both is what makes the rule real rather than theoretical.
  4. Write tests. At least one allow case and one deny case per clause. Tests are how you know the rule does what the prose intended, and how you catch regressions when the policy changes later.
  5. Version and review the rule like any other code artifact. It gets a version, a change history, and a review date. A policy you cannot diff is a policy you cannot trust.

Worked example: AUP Clause 4, in illustrative pseudo-code

Say Clause 4 of your acceptable use policy reads: "Tier 3 agents may not call tools that write to production systems."

Here is the shape of that rule in illustrative pseudo-Rego (not runnable, structure only):

# illustrative pseudo-Rego
deny if {
   input.agent.tier == 3
   input.tool.effect == "write"
   input.resource.environment == "production"
}

And the same intent in illustrative pseudo-Cedar:

// illustrative pseudo-Cedar
forbid(principal, action, resource)
when {
   principal.tier == 3 &&
   action.effect == "write" &&
   resource.environment == "production"
};

Both encode the same decision. The difference is in how each engine evaluates it, which is the next section.

OPA versus Cedar

The two most common policy engines for this work are Open Policy Agent (OPA, using the Rego language) and Cedar. They make different tradeoffs.

__wf_reserved_inherit

OPA's reach is its strength. The ARPaCCino research paper calls it "the de facto standard implementation," and its integrations across infrastructure make it a safe default for most policy work. Harness's 2026 analysis argues Cedar is "not ready to displace OPA for most of the work."

Cedar's strength is that it is analyzable. As TianPan describes, Cedar is default-deny with forbid-wins-over-permit and order-independent evaluation, which means you can reason about what a policy set permits without executing every path. Its strict, upfront schema enforcement (per Harness) catches malformed policies before they run. Amazon's Bedrock AgentCore Policy builds on Cedar: per AWS, Policy in Amazon Bedrock AgentCore went generally available on March 3, 2026, policies automatically convert to Cedar, and it is available in thirteen AWS Regions.

For agent policy, the framework guidance points the same way regardless of engine. OWASP's Agentic Top 10 flags excessive agency and privilege compromise (ASI02, ASI03), and the Five Eyes agentic guidance pushes least privilege. Both are easier to enforce with a default-deny posture.

The translation worksheet

Use this template to carry each clause from prose to an enforced, tested, verifiable rule. One row per clause.

__wf_reserved_inherit

The last two fields are the ones teams skip, and they are the ones that matter most when the rule is challenged.

Proving the rule held

Authoring an enforceable rule is half the job. The other half is evidence that every agent actually routes through it. A rule that a policy engine evaluates perfectly is worthless if half your agents never reach the decision point.

Three failure modes break coverage:

  • Agents not routed through any decision point. The rule exists, the engine works, but the agent calls its tools on a path that never consults the policy. The policy is live and irrelevant at the same time.
  • Agents emitting no telemetry. If an agent produces no traces, you cannot confirm whether it hit the decision point or not. Absence of evidence becomes absence of control.
  • Drift. A policy that ran last quarter quietly stops running after a refactor, a redeploy, or a config change, and nobody notices until it is tested.

Closing these gaps needs an independent view of what is actually running, not just what the policy says should happen. Read-only discovery finds agents across telemetry, MCP, network, and cloud-platform signals, including agents that never route through any decision point. Comparing that observed inventory against the set of agents the policy is supposed to cover is how you turn "the rule is written" into "the rule is covering every agent."

Where Arthur fits: Arthur is not a policy decision point, a gateway, or an OPA or Cedar host. Arthur translates a written governance framework into machine-checkable evaluation-type policies, scoped per application, model, and environment. Those are guardrails, evals, and alert rules that return a verdict the application enforces. For the proof loop, read-only discovery finds agents not routed through any decision point, and compliance jobs re-check policy status every 24 hours with webhooks, flagging agents where policy is no longer running.

OPA and Cedar handle the admission decision at the enforcement point. Arthur handles the evaluation-type policies and the independent evidence that the rules are covering what they should. The two layers are complementary.

FAQ

Policy as code for AI agents, in one sentence. Rewriting each clause of a written agent policy as a decision with typed inputs that a policy engine evaluates at a defined enforcement point, then proving every agent routes through it.

When should I pick OPA for AI agents? When you want the de facto standard with broad infrastructure integrations and flexibility in how you structure rules. Pick Cedar when you want default-deny, order-independent evaluation, and the ability to analyze what a policy set permits without running it. If you are on Bedrock AgentCore, you are already using Cedar under the hood.

How do I know every agent routes through the rule? You cannot know it from the policy engine alone, because the engine only sees agents that reach it. You need an independent inventory from discovery, compared against the agents the policy is meant to cover, with recurring re-checks to catch drift.

Agents don't read your policy documents. Write the rule so a machine can check it, then verify that every agent is actually routing through it. Book a demo to see how Arthur translates a written framework into machine-checkable policies and proves coverage across your agent fleet.

‍

SHARE