Skip to content

The sefra CLI

One binary is the server and the CLI. sefra <command> without arguments prints its usage. Every command exits 0 on success, 1 on a failure or a refusal (the reason is printed), and 2 on a usage error.

Most commands call the operator API. They read:

Variable Default Used by
SEFRA_OPERATOR_URL http://127.0.0.1:18101 approvals, control, executions, drain, license
SEFRA_OPERATOR_TOKEN none the same: an access token of the person or automation acting
SEFRA_URL, SEFRA_TOKEN the same default; none bundle apply, bundle upload: the operator API and a sefra_admin token
SEFRA_DATABASE_URL none migrate (as the owner of the tables), audit, policy replay, usage (any role that may read the audit tables)

audit, policy replay and usage read PostgreSQL directly, so that checking the record does not depend on the service that writes it.

Role May
sefra_viewer Read executions, workflows, audit events, the active bundle and approvals (status and requirements); no approval summaries, rationales or step inputs
sefra_auditor Everything a viewer may, and approval summaries and rationales
sefra_operator Everything an auditor may, and an approval’s step inputs in redacted form; suspend, disable, pause and their inverses; settle a step, retry compensation, resolve; cancel a pending execution
sefra_admin Everything an operator may, and upload and activate bundles
A role named in an approval requirement List and decide the approvals that name it

All are held by principals of type human. The console uses the same roles.

Command Does
sefra serve [--config sefra.yaml] [--role api,worker] Runs the service. api is the agent listener; worker runs the Temporal worker, the sweeper and the retention purge. The operator listener runs with either. --role worker closes admission for an upgrade (upgrade)
sefra migrate [--runtime-password-env NAME] [--wait 60s] Applies the schema migrations as the owner of the tables, and with --runtime-password-env sets the password of sefra_app, the runtime role, and enables its login. Run it before every start of a new version
sefra probe <url> Exit 0 if the URL answers 2xx; for container health checks (sefra probe http://127.0.0.1:8081/readyz)

GET /healthz says the process is up; GET /readyz says PostgreSQL, Temporal, the identity provider’s keys and every connector secret are reachable and a bundle is active, and names the failing check otherwise. Neither needs a token.

Command Does
sefra bundle test <dir> Validates and tests a bundle locally; prints the digest, problems, test results and effective intents. Needs nothing running (testing and activation)
sefra bundle apply <dir> Uploads the bundle, which the server validates again, and activates it
sefra bundle upload <dir> Uploads the bundle, which the server validates again, and stores it without activating it. Prints stored <digest> for a new bundle or already stored <digest> for one the server holds, then any warnings; an invalid bundle is refused with every problem, as for apply, and exits 1. The active bundle is unchanged

bundle upload is the step a CI job runs on a reviewed change: the candidate is then compared and replayed in the console, and an admin activates its digest there, with a note, or with sefra bundle apply. Activating an earlier digest is the roll-back. The console never uploads a bundle.

digest=$(sefra bundle upload ./bundle | awk '/stored sha256:/ {print $NF}')
Command Does
sefra approvals list [--status pending|approved|denied|expired|cancelled|all] The approvals you may decide, with their summaries, nearest expiry first (pending, the default). Any other status lists the history, newest first: every approval for sefra_viewer and above, those naming your roles otherwise
sefra approvals show <id> One approval in full: summary, step inputs, requirements, requester, the agent’s rationale, expiry, execution hash. Step inputs are in clear, sensitive fields included, only for a person who could decide the approval. sefra_operator and sefra_admin otherwise get them with sensitive fields redacted. Other roles do not get them
sefra approvals approve <id> [--comment <text>] Shows the approval, then approves exactly what it showed, by sending back the hash it printed
sefra approvals deny <id> [--comment <text>] Shows it, then denies it

Decisions through the CLI are recorded at evidence level token. A requirement with min_evidence: oidc is decided on the approval page, <oauth.resource.operator>/approvals/<id>.

Command Does
sefra executions get <id> Status, error, approval, principal, bundle, steps with their attempts; never step bodies
sefra executions audit <id> Every audit event of the execution, in order
sefra executions list [--status s,…] [--limit n] [--after id] Executions, newest first; --status in_flight for everything not final
sefra executions cancel <id> Cancels an execution pending approval; the agent sees CANCELLED
sefra executions settle-step <id> --step <step> --outcome succeeded|failed [--output <json>] [--note <text>] Settles a step whose outcome is unknown, after you looked at the system of record
sefra executions retry-compensation <id> [--note <text>] Runs the failed compensations again
sefra executions resolve <id> --note <text> Ends a needs_intervention execution as resolved_manually, after you fixed the system of record by hand

An execution in needs_intervention also raises the operator.alert webhook.

Command Does
sefra control suspend <principal> / unsuspend <principal> Refuse every submission of one principal / lift it, also a suspension by the denial breaker
sefra control disable <intent> / enable <intent> Refuse one intent type / allow it again
sefra control pause / resume Refuse every submission and every forward step / lift it. A pause fails the next forward step of every running plan, which is then compensated; do not use it for an upgrade

Each takes --note <text>, recorded with the operator.action event. They act at once, without a bundle change.

Command Does
sefra drain Exit 0 only when no execution is in flight and no execution workflow runs; lists them otherwise. The procedure is in upgrade
Command Does
sefra audit verify [--from N] Recomputes the hash chain; OK: … and exit 0, or BROKEN at seq <n>: <reason> and exit 1. A break is a security incident
sefra audit head The current sequence number and head hash, to record elsewhere as a checkpoint
sefra audit export [--from N] [--to N] [--out FILE] Events as JSON Lines, for an archive or a security monitoring system
sefra audit verify --file FILE Recomputes the chain over an exported file alone
sefra policy replay --bundle <dir> [--from N] [--json] Decisions whose effect would change under a candidate bundle
sefra policy replay [--from N] [--json] Every decision under its recorded bundle, compared with the record; exit 1 on any difference
sefra policy replay --event <seq> [--json] One decision, both outputs
Command Does
sefra license status [--json] The deployment’s licence: type, days left, limits, and what happens when it expires. Any console or operator role
sefra license request The deployment id, version and first audit hash to send us for a subscription licence
sefra usage report [--from YYYY-MM] [--out FILE] Governed executions per month and day, with the newest audit event’s hash. Counts and hashes only
sefra usage verify --report FILE [--report FILE ...] [--file EXPORT] Verifies the audit chain and recomputes each report from it, or from an exported file; exit 1 on any difference

See Licence.