Mediate on Cerbos

How do I bind this adapter, and what mechanism answers each rule shape? For an adopter whose rules are policy files a sidecar reads.

Mediate.Cerbos decides through a sidecar that reads policy files with an owner of their own. The sidecar runs beside the application on the same host, and flake.nix pins its version. Revocation of a fact is one commit, and a rule change waits on the sidecar's reload.

How to bind

The configuration entry carries the sidecar's address and nothing else: adapter: {Mediate.Cerbos, address: "127.0.0.1:3592"}. After the configuration boots, bind the repo, the attribute declarations, the policy directory, and the commit, then publish. Mediate.Cerbos.Binding has the options and the call.

The declarations

use Mediate.Cerbos.Attributes is the declaration module, and its moduledoc has the full form.

Every column behind a declaration must be a declared fact of the application, and Mediate.Cerbos.Coverage checks that. What reaches the sidecar is the declared attributes and a role per subject kind, and nothing else about the subject travels.

Mechanism per rule shape

Rule shape Mechanism
A test on the subject a principal attribute, a column of the subject's schema or a subquery of the subject and the environment. The adapter reads it at the call and sends it with the request
A test on the row a resource attribute, sent the same way. A policy cannot depend on a value no declaration names
A test on the moment or a request-time fact the environment principal attribute: request.principal.attr.environment.now and one field per declared fact, from the port's clock and not the sidecar's. The adapter cuts every moment to the second. A policy compares text, and a plan compares a database column of the same moment
A rule over a whole type the sidecar's query plan, compiled over declared attributes alone. The adapter refuses an operator the compiler does not carry, and never narrows the plan
A write gate the seam refuses a write with no decision for the operation, before anyone asks the policy

What this adapter decided

Revocation latency has two components: commit for a fact, and policy propagation for a rule, which Mediate.Cerbos.Propagation measures.