$ fssg build --deterministic --validate |

FACET vs OPA and Cedar: Which Policy Boundary Do You Need?

FACET

FACET, OPA, and Cedar can all contain rules. That does not make them interchangeable.

I see the same architecture mistake whenever a team adopts policy as code: one policy engine gradually becomes responsible for every decision in the system. Authorization, request construction, tool visibility, context layout, provider quirks, and runtime effects collapse into one rule surface. The result looks centralized, but the boundaries become harder to reason about.

The useful question is not “Which policy language is best?” It is: what object is being decided, and at which phase?

FACET compiles an AI request contract. Open Policy Agent evaluates general policy over structured input. Cedar decides whether a principal may perform an action on a resource under stated conditions. These jobs can cooperate. They should not impersonate one another.

The three decision objects

System Primary decision object Typical answer Natural boundary
FACET AI request and execution contract What tools, messages, layout, policy, and metadata form the canonical request? Before provider adaptation and model inference
OPA/Rego Arbitrary structured input What policy decision follows from this data? Beside an application, gateway, CI system, or control plane
Cedar Principal-action-resource request Is this action authorized in this context? Application authorization boundary

OPA describes itself as a general-purpose policy engine. Rego reasons over structured data and can return booleans, sets, objects, or richer decisions. That flexibility is its strength.

Cedar is deliberately narrower. Its core authorization question binds a principal, action, resource, and context to a policy set, producing an allow or deny decision. Its schema and validator help keep authorization data and policies aligned.

FACET operates on another axis. A .facet document is parsed, resolved, validated, evaluated, laid out through the Token Box model, checked against policy, and rendered as Canonical JSON. The output is not merely “allow” or “deny.” It is the request artifact that a passive provider adapter must translate without repairing semantics.

That difference determines where each system belongs.

Where OPA fits around an AI agent

OPA is a strong choice when the policy input already exists as structured application state.

Examples:

  • may this tenant use this model class?
  • may this deployment call an external network destination?
  • does this tool request satisfy organization policy?
  • may this CI job release an artifact to production?
  • which limits apply to this account, environment, or region?

The application packages relevant facts, asks OPA for a decision, and enforces the result. OPA does not need to understand how an AI prompt was assembled. It can remain outside that mechanism.

I would use OPA for organization-wide rules that span AI and non-AI systems. A network egress rule should not be hidden inside a prompt language. A deployment policy should not depend on a model request compiler. OPA gives those concerns an independent decision service and policy lifecycle.

But an OPA decision does not automatically construct a reproducible model request. It does not define FACET import merge semantics, dependency evaluation, Token Box allocation, canonical message order, or provider-neutral request identity. You can encode approximations of those rules in Rego, but then you are rebuilding a compiler inside a general policy engine.

Where Cedar fits around an AI agent

Cedar is the cleaner choice when the question is application authorization.

Suppose an agent wants to invoke refund_order for order 1234. Cedar can express whether principal Agent::"support-bot" may perform action Action::"refund" on resource Order::"1234", using attributes and context such as tenant, amount, ownership, role, or risk level.

That is a precise authority decision. It remains useful even if the agent is replaced by a human interface, a workflow worker, or another model.

FACET can compile tool visibility and contract-local policy before inference, so the model never sees capabilities excluded by the effective contract. Cedar can still authorize the concrete application action at the resource boundary. These are not duplicate checks:

FACET: should this capability exist in the model's effective request?
Cedar: may this principal perform this action on this resource now?

The first reduces the model's available action surface. The second protects the application even if a caller bypasses, corrupts, or misunderstands the model-facing layer.

This is the same separation I use when I say that an effect class is not a permission. Classification describes what an operation can do. Authorization decides whether this operation is allowed here.

What FACET owns that policy engines should not

FACET should own semantics that determine the identity of the model request:

  1. typed runtime inputs;
  2. deterministic imports and variable evaluation;
  3. conditional inclusion before inference;
  4. context priorities and budget behavior;
  5. effective tool and interface projection;
  6. contract-local policy and guard metadata;
  7. Canonical JSON and its document/policy identity.

These are compiler concerns because ordering and transformation change the artifact itself.

A separate policy engine may supply an input to compilation. For example, OPA may return an environment policy profile, or Cedar may confirm that a principal can enter a privileged workflow. FACET can then compile the request under that already-resolved fact. The important rule is to preserve provenance: record which external decision, policy version, and input identity affected the compiled request.

Do not let the provider adapter call OPA or Cedar opportunistically and mutate the payload. FACET adapters are supposed to be behaviorally passive. If policy evaluation changes request semantics, it belongs before the canonical boundary, where the change can be validated and hashed.

A practical composition

A minimal stack can look like this:

identity + application state
        |
        +--> Cedar: principal/action/resource authorization
        |
        +--> OPA: organization/environment policy decision
        |
        v
resolved policy facts + runtime inputs
        |
        v
FACET compiler
  - validate contract
  - project tools
  - evaluate conditions
  - allocate context
  - emit Canonical JSON
        |
        v
passive provider adapter
        |
        v
model call
        |
        v
host runtime re-authorizes concrete effects

Not every system needs all three. A small single-tenant assistant may need only FACET plus host-side checks. A multi-tenant platform may use Cedar for application permissions. A larger organization may already use OPA for infrastructure and governance policy.

The architecture should grow by boundary, not by logo count.

The failure test

When choosing the layer, I ask what failure I am trying to prevent.

Failure Best primary boundary
Unauthorized user accesses a resource Cedar or equivalent application authorization
Deployment violates organization policy OPA or equivalent general policy engine
Forbidden tool appears in the model request FACET capability projection and contract policy
Context priority changes after a refactor FACET compilation and Token Box tests
Provider adapter silently rewrites semantics FACET adapter conformance and fail-closed behavior
Tool executes an irreversible effect without current authority Host runtime authorization, possibly backed by Cedar/OPA

A policy engine is not a substitute for the boundary that owns the failure.

I would not ask FACET to become an enterprise authorization database. I would not ask Cedar to assemble model context. I would not ask Rego to become a second implementation of the FACET compiler. Each move is technically possible. Each one erases a useful separation.

The stronger design is compositional: authorization decides authority, general policy decides organizational constraints, and FACET compiles the exact AI request those decisions permit.

Policy as code becomes safer when “policy” stops meaning one giant thing.

Sources

FACET AI CLI Terminal
facet@ai:~$