Index of the modules

The BOM

Core

Builtins

Bundles

Signing

OPA

Testing

Server

Command line

Modules

Each module of rego4k is a Maven artifact in the group dev.rego4k, and the BOM rego4k-bom gives each module the same version.

The BOM

rego4k-bom

rego4k-bom is a Maven BOM (a bill of materials). It names the same version for each module in modules. Import it, and then declare the rego4k modules without a version.

Core

rego4k-core

rego4k-core is the Rego engine. It parses, compiles and evaluates Rego (v1 syntax) in the JVM. It has no builtins of its own.

rego4k-http4k-json

rego4k-http4k-json converts between the nodes of an http4k Json and the Values of rego4k-core. It works with each JSON library that http4k supports, for example Moshi, Kondor, Gson and Jackson.

rego4k-formatter

rego4k-formatter formats Rego v1 modules. Its output is the output of opa fmt of OPA 1.23.0, byte for byte. It is a port of OPA's v1/format/format.go.

Builtins

rego4k-builtins-stdlib

rego4k-builtins-stdlib holds all the builtins of OPA's library that rego4k has, in one value: Builtins.stdlib(regex). It is the sum of the pure, provided, impure and yaml.* builtins. The builtins that compile a regex use the regex engine regex.

rego4k-builtins-stdlib-pure

rego4k-builtins-stdlib-pure holds the pure builtins of OPA's standard library: Builtins.Pure.stdlib(regex). A pure builtin depends only on its arguments. Rego.standard(regex) gives an engine with these builtins.

rego4k-builtins-stdlib-provided

rego4k-builtins-stdlib-provided holds the provided builtins of OPA's standard library: Builtins.Provided.stdlib. A provided builtin reads a value that the runtime provides, for example the time of the query. The query records each value that it reads.

rego4k-builtins-stdlib-impure

rego4k-builtins-stdlib-impure holds the impure builtins of OPA's standard library: Builtins.Impure.stdlib. An impure builtin depends on the network or on randomness, for example http.send and rand.intn.

rego4k-builtins-yaml

rego4k-builtins-yaml holds OPA's yaml.* builtins: yaml.unmarshal, yaml.marshal and yaml.is_valid. The parser uses yaml.unmarshal to read # METADATA blocks.

rego4k-builtins-re2

rego4k-builtins-re2 holds Re2Engine, the RE2 regex engine, for Builtins.Pure.stdlib(Re2Engine). With it, the builtins that compile a regex have the regex syntax, the regex semantics and the linear running time of OPA.

rego4k-builtins-http4k-send

rego4k-builtins-http4k-send has an http.send builtin that sends each request to an http4k HttpHandler: Builtins.httpSend(handler). In a test, an in-memory handler lets a policy call http.send with no network.

Bundles

rego4k-bundles-core

rego4k-bundles-core reads and writes OPA bundles. A bundle holds the policy and the data of one deployment. The module also does tree shaking (Bundle.shake) and its dry run (Bundle.shakeDryRun).

rego4k-bundles-signing

rego4k-bundles-signing verifies and signs OPA bundles, with the same format and the same options as OPA. OPA can verify a bundle that it signs.

Signing

rego4k-signing-utils

rego4k-signing-utils holds the cryptography that bundle signing and decision signing share: the signature algorithms, the JWS, the PEM keys and the canonical JSON form. Thus both can use the same keys.

rego4k-signing-verifier

rego4k-signing-verifier is for a system that receives signed decisions. It verifies the signature of a signed decision and gives the Decision. It does not evaluate Rego.

rego4k-signing-signer

rego4k-signing-signer signs the output of a query. A reader can then prove which policy gave which output for which input, and when. Decision.reproduce evaluates the query again and compares the output.

OPA

rego4k-opa-core

rego4k-opa-core declares the capabilities of OPA as interfaces, for example Evaluation and Checking, and the sets of capabilities Toolchain and Opa. It has no engine.

rego4k-opa-embedded

rego4k-opa-embedded gives the Toolchain with rego4k in the process: Toolchain.embedded(rego). It has the capabilities that rego4k shares with OPA, and it needs no OPA.

rego4k-opa-command-line

rego4k-opa-command-line gives the Opa that runs the opa binary: Opa.cli(). It has all the capabilities of rego4k-opa-core. Each call runs one opa command in a temporary directory.

rego4k-opa-server

rego4k-opa-server gives OpaServer: the capabilities of OPA's REST API, through an http4k HttpHandler. It works with opa run --server, and with the OPA-compatible API of the decision server of rego4k.

Testing

rego4k-testing-core

rego4k-testing-core runs the Rego tests of policies, as opa test does. It gives the outcome of each test, and the text of opa test.

rego4k-testing-junit

rego4k-testing-junit gives the Rego tests of policies to JUnit 5 as dynamic tests. Gradle, Maven and an IDE then show each Rego test with the tests of the application.

Server

rego4k-server-core

rego4k-server-core is the base of the decision server. DecisionServer is an http4k HttpHandler that puts the routes of its modules in one contract. The module also holds the hosted bundles and the plumbing of OPA's REST API.

rego4k-server-policies

rego4k-server-policies holds the module OpaApi: OPA's REST API for the bundles that a decision server hosts.

rego4k-server-signing

rego4k-server-signing adds signed decisions to the decision server. Another system then verifies a signed decision with only the certificate of an authority that it trusts.

rego4k-server-debugger

rego4k-server-debugger is a debugger for Rego policies in the browser. It steps through the evaluation, and shows the bindings of the vars and the part of the input that each step reads. It is a library, and also an application.

rego4k-server-shaking

rego4k-server-shaking shows what tree shaking does to a bundle of the decision server, before anybody deploys the shaken bundle. It gives the dry run as JSON, and as a page in the browser.

rego4k-server-docs

rego4k-server-docs serves an HTML page with the OpenAPI descriptions of the decision server. It is a separate module because it renders HTML with kotlinx.html.

rego4k-server-lsp

rego4k-server-lsp is a language server for Rego v1 files. Each editor with a client for the Language Server Protocol (LSP) can use it. The editor shows the errors of OPA and the format of opa fmt without an opa binary.

Command line

rego4k-cli-core

rego4k-cli-core is the base of the command line. Each module in modules/cli gives its commands as Commands, and Cli runs the command that a command line names. Its flags read a command line as OPA's library pflag does.

rego4k-cli-opa

rego4k-cli-opa is the command line of opa, with rego4k in place of OPA. Its commands are eval, check, fmt, parse, test and build, with OPA's flags, output and exit codes.

rego4k-cli-decision-signing

rego4k-cli-decision-signing is the command line of signed decisions. Its commands are sign-decision, verify-decision, reproduce-decision and sign-input.

rego4k-cli-shaking

rego4k-cli-shaking is the command line of tree shaking: the command shake. With --wasm, it gives the shaken bundle to opa build -t wasm.

rego4k-cli-server

rego4k-cli-server is the command line of the decision server: the command run --server. A script that starts opa run --server can start rego4k run --server with the same flags and the same paths.

rego4k-cli-full

rego4k-cli-full is the command rego4k: the commands of each module in modules/cli, with OPA's builtins. The build writes it as one runnable jar, rego4k.jar, and a start script.