Skip to content

[FEATURE]: OPA/Rego PDP builtin (regorus) #137

Closed

Description

@araujof

Summary

Add an OPA PDP builtin that evaluates Rego policies in-process, alongside the existing cedar-direct and cel PDPs. Back it with
regorus, a pure-Rust Rego interpreter (Apache-2.0), so we get embedded evaluation with no sidecar and no network hop.

PdpDialect::Opa already exists in apl-core; this issue fills it with a resolver.

Motivation

Operators standardized on OPA/Rego have no in-process option today. Their choices are Cedar, CEL, or an external OPA over HTTP. An embedded Rego backend lets them reuse existing policy without a sidecar, matching the deployment model of the other builtin PDPs.

Scope

New crate builtins/pdps/opa (cpex-pdp-opa), mirroring the shape of builtins/pdps/cel:

  • OpaResolver implementing PdpResolver, dialect() -> PdpDialect::Opa.
  • OpaPdpFactory implementing PdpFactory, kind() = "opa", built from the
    global.pdp config block.
  • AttributeBag → Rego input document (reuse the bag→namespace mapping the
    CEL resolver already does; the flat dotted keys become nested input
    fields).
  • Compile-once / eval-many: parse policy modules at factory build time, hold
    the prepared engine, evaluate per request.
  • Decision contract: the configured query must resolve to a boolean
    allow/deny. on_error: deny | allow (default deny), matching CEL/Cedar.
  • Route step form opa: { ... } carrying the module(s) + query path; keep it
    consistent with how cel: { expr } and cedar: { ... } read.

Wire an optional opa feature into cpex-builtins (one feature → one crate, like the others) and add it to default.

Acceptance Criteria

Scenario: allow decision from an embedded Rego policy
  Given a route with an `opa:` step and a Rego module that allows the request
  When the PDP step evaluates
  Then the resolver returns allow and the pipeline continues

Scenario: deny on evaluation error honors on_error
  Given an `opa` PDP configured with on_error: deny
  When policy evaluation errors
  Then the request is denied

Notes

  • regorus is Apache-2.0 and pure Rust — no new entries needed in the deny.toml license allow list, no C/sidecar dependency.
  • Keep the crate apl-core-only at compile time (apl-cpex/cpex-core as dev-deps for e2e tests), same as cel and cedar-direct.

Activity

  1. added
    enhancement
    on Jul 29, 2026
  2. self-assigned this
    on Jul 29, 2026
  3. moved this from Backlog to In progress in CPEXon Jul 29, 2026
  4. moved this from In progress to Done in CPEXon Aug 3, 2026
  5. closed this as completedby moving to Done in CPEXon Aug 3, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Labels

Rustenhancementframework

Type

No type

Projects

  • Status
    Done

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions