Skip to content

AI Glossary · Governance & compliance

What is Policy as Code?

Policy as Code

Policy as code is writing governance, security, and compliance rules as machine-readable, version-controlled code so systems enforce them automatically instead of waiting on a human review. For agentic AI it's how you encode the guardrails: what an agent can access, what it can do, and what makes it stop.

Also known as: policy-as-code, PaC

· Updated · Chain of Thought

Enterprise AIAI Agents

  • 1 episode
  • 1 source

The idea came out of cloud, and the original pitch was ambitious: encode your security and configuration rules as executable policy instead of static documents, build it right, and you’d never have another security problem. That didn’t survive contact with production. Teams still needed cloud compliance tooling and a second layer of controls on top, and policy as code settled into being one important element rather than the whole answer. Applied to agentic AI, it means writing down what an agent can access, which actions it can take, and what triggers a halt, so those limits run automatically instead of depending on someone catching a violation afterward.

In episode 62, Kris Lovejoy says she has a fraught relationship with policy as code because she sees teams trying to “apply deterministic rules to inherently autonomous systems.” Part of the problem, she says, is that “we think in a linear way” about business processes, while “AI works in parallel.” Push determinism far enough and you’re arguably rebuilding RPA rather than deploying an autonomous agent. Her answer is a supporting stack around policy as code: inventory every agent, evaluate it in a simulated environment before it touches production, generate and monitor the policies, keep audit and compliance reporting good enough to reconstruct what happened, and put humans in supervisory roles — what she calls “human on top” rather than human in the loop, because she sees a checkpoint inside the loop as a human construct imposed on a system meant to be autonomous.

One rule, three tests

An illustrative rule: a support agent may read cases for the project it is authorized on, and any customer-facing send needs approval for that exact message and recipient. The policy engine needs trusted inputs (who is calling, for what task, on which resource, with what approval), not a flag the model produced. Before relying on it, test an allowed read, a read from a different project that must be denied, and a send whose recipient changed after approval that must be denied. Also decide what happens when the policy service is down: privileged actions should stop, not proceed.

Sources

  • Open Policy Agent documentation — Describes OPA, a graduated CNCF project, which decouples policy decisions from enforcement: software queries it with structured input and it evaluates policies written in Rego, for example which roles may access a resource; checked October 26, 2026.

From the conversation