OPA and rego4k
rego4k evaluates Rego (v1 syntax) with the results of OPA 1.23.0.
The same results as OPA
rego4k passes all 2538 cases of OPA's v1 conformance suite. About 2400 more cases have results from the OPA binary.
Before each commit, the fuzz gate compares rego4k with the OPA binary on 4500 generated programs, and fails for a new difference. Testing and verification describes each layer and when it runs.
The capabilities of OPA as interfaces
rego4k-opa-core has the capabilities of OPA as interfaces, for example Evaluation, Checking, Formatting and
WasmBuilding. Code that is written against an interface can use OPA or rego4k as the engine:
| Engine | Module | What it is |
|---|---|---|
Opa.cli() |
rego4k-opa-command-line |
The opa binary, with the JDK's ProcessBuilder. All the capabilities. |
OpaServer(handler) |
rego4k-opa-server |
OPA's REST API, through an http4k HttpHandler: an OPA server, or the decision server of rego4k. |
Toolchain.embedded(rego) |
rego4k-opa-embedded |
rego4k in the process: the capabilities that rego4k shares with OPA. |
/**
* True if the entrypoint `authz/allow` of [bundle] allows [input],
* with any engine of OPA's capabilities.
*/
fun allowed(engine: Evaluation, bundle: Bundle, input: Value): Boolean =
engine.data(bundle, "authz/allow", input).result == Bool.TRUE
// the opa binary:
// allowed(Opa.cli(), bundle, input)
// rego4k in the process:
// allowed(Toolchain.embedded(Rego.standard(Re2Engine)), bundle, input)Toolchains.kt, lines 15 to 25, on GitHubThe contract tests of verification/capabilities run one suite of cases for each capability against each engine.
The README of opa has the table of the capabilities of each engine.
The differences
Divergences from OPA lists each case where rego4k gives a different result from OPA on purpose, and the faults of OPA that rego4k does or does not copy. The known differences of the fuzz gate have their reasons there.
Gaps lists the features of OPA that rego4k does not have, for example v0 Rego and delta bundles.
The builtins that compile a regex use the engine that you give to Builtins.Pure.stdlib(regex). For the regex
semantics of OPA (RE2), give Re2Engine. See Builtins.