Skip to content

Testing and activation

sefra bundle test ./my-bundle

It loads the directory, validates every manifest, connectors.yaml, grants.yaml and limits.yaml, compiles the policies with the restricted capabilities, runs the Rego tests, and prints the digest, every error and warning, the test results with coverage, and the intents each grant subject sees. It needs nothing running: no database, no system of record, no Sefra. Run it in CI on every change.

Exit Meaning
0 Valid, and every test passed. Warnings may still be printed
1 An error, or a failed test. The bundle cannot be applied
2 Wrong arguments

Warnings are worth reading. The ones you will see:

  • fact <name> has no response_schema …: the fact’s answer, and its sensitive fields, are not declared (manifests).
  • mode none and no probe …: an ambiguous outcome of this write always ends in needs_intervention.
  • <pattern> matches no intent of this bundle: a grant or a limit names nothing.

A policy change that passes its tests can still change decisions nobody thought of. Replay re-evaluates every recorded decision from the audit trail under the candidate bundle, from the stored input document at its recorded time, and lists each decision whose effect would change:

export SEFRA_DATABASE_URL=postgres://…   # a role that may read the audit tables
sefra policy replay --bundle ./my-bundle            # every decision
sefra policy replay --bundle ./my-bundle --from 5000 --json

Read the list: each line is a past request that would now be allowed, denied or sent for approval where it was not. Facts are the recorded ones; nothing is fetched, so a rule that reads a fact the recorded bundle did not declare sees it absent. Replay exits 0 whenever it could replay every decision, whatever changed; it is evidence for the review, not a gate.

sefra policy replay --event <seq> re-evaluates one recorded decision under its original bundle and prints both outputs, to answer “why was this denied”.

export SEFRA_URL=https://sefra-ops.example.com     # the operator listener
export SEFRA_TOKEN=…                                # an access token of a sefra_admin
sefra bundle apply ./my-bundle

It uploads a gzip tar of the directory; Sefra validates it as bundle test does (and refuses it on any error or failed test), stores it under its digest, and activates it atomically, recorded as an audit event. Applying the active bundle again changes nothing. A connector secret the bundle names must be configured in sefra.yaml, or the upload is refused.

  • Executions already accepted finish under the bundle they were accepted under, including their compensations.
  • Going back is applying the previous directory again: every bundle ever applied is kept, and the same files give the same digest.
  • Review before activation: sefra bundle upload ./my-bundle stores the bundle without activating it and prints its digest. In the console (Policy) the candidate can be read, compared file by file with the active bundle and activated by an admin with a note; activating an earlier digest there is also the way back.
  • Who can read a bundle: every console viewer can read all its files. Keep credentials out of them, in URLs too; a connector names its secret.
  • Urgent stops do not wait for a bundle: sefra control disable <intent>, suspend <principal> and pause act at once (CLI).