Documentation

Docs / Related work

Open Policy Agent and Rego

What it is

Open Policy Agent (OPA) is a general policy engine, a graduated CNCF project (2021). Policies are written in Rego, a query language inspired by Datalog and extended to JSON documents. It is used for Kubernetes admission, API gateways, infrastructure checks and application authorization. In August 2025 its core maintainers moved from Styra to Apple; OPA stays a CNCF project.

Model

  • Entities: none fixed. The input is any JSON document; data is any JSON tree. The policy author decides what a person, an asset or an action is.
  • Rule forms: Horn-clause-like rules that define values (allow if { ... }), sets, objects and functions. Negation with not. Comprehensions. Many built-ins, including some that reach outside (http.send).
  • Combining: none built in. The author writes the logic, for example allow if { not deny; ... }. Two complete rules that give different values are a runtime conflict error.
  • Default: a rule with no matching body is "undefined". The idiom default allow := false turns that into deny.
  • Partial evaluation: OPA can evaluate with unknowns and return residual queries (used to push filters into SQL).

Formal semantics and what is proved

  • No official formal semantics. The documentation describes the language informally and relates it to Datalog. We did not find a peer-reviewed formal semantics of Rego; if one exists it is not widely cited.
  • Recursion is rejected at compile time, and negation must be safe, so plain evaluation terminates. Built-ins and external calls break the purely logical reading.
  • Tools: opa test (unit tests), opa eval --explain (traces), the Regal linter. No analyser for equivalence or implication between two policies.

Purpose and use case

None built in. Purpose is whatever field the author puts in the input.

Uncertainty

None.

History and state

Stateless per query. State can be loaded as data. No disclosure history.

What we can reuse

  • Partial evaluation as a way to say "what is still unknown" (for "ask").
  • The decision-log idea: every decision recorded with input, policy version and result.
  • The practice of tests living next to policies.

What it lacks for us

  • Too general: the author builds the combining algebra each time, so no theorem holds for all programs.
  • No formal semantics, no proofs, no rule-set analysis.
  • No forms of output, no purpose, no uncertainty, no history.

Key references

  • OPA policy language documentation. https://www.openpolicyagent.org/docs/latest/policy-language/
  • OPA blog, note from Teemu Koponen, Tim Hinrichs and Torin Sandall (August 2025). https://openpolicyagent.org/blog/note-from-teemu-tim-and-torin-to-the-open-policy-agent-community-2dbbfe494371
  • Oso's account of the move. https://osohq.com/post/opa-maintainers-join-apple-oss-community-to-maintain-styra-products

Last built 2026-11-25