Policy, approval and retention commands
Part of the NovaFabric CLI reference. Both nova and novafabric run the same binary.
Policy and governance (v0.8)
When opa is not installed. OPA is optional in local mode. With no opa on PATH
and no NOVAFABRIC_POLICY_BUNDLE_PATH, the built-in policy gates (promote,
evidence_export, replay_mutating) are disabled with a warning and allow — except
the gates that require an explicit allow (promote direct into production, protected
labels). Two cases now fail closed instead, because a policy was asked for:
NOVAFABRIC_POLICY_BUNDLE_PATHis set: every gated action is refused (a recordedpolicy.denynaming the variable and the missingopa). Install OPA or unset the variable.- A protected label has a
policy_ref: a move that needs it stays pending (… no policy engine is available (opa not found) — fail-closed), just as when the referenced file cannot be read.
nova policy test
Run the Rego unit test suite on the built-in policy bundle (requires opa installed).
nova policy test
nova policy test --bundle /path/to/custom-bundleOptions:
--bundle PATH— override the default policy bundle path (also:NOVAFABRIC_POLICY_BUNDLE_PATHenv var)
Returns exit code 0 if all tests pass, 1 if any test fails or opa is not found.
opa runs sandboxed, as everywhere in NovaFabric: it inherits no environment variable except a fixed PATH, and the Rego cannot call opa.runtime, http.send or net.lookup_ip_addr (they are removed from the capabilities opa runs with, and network access is denied). A test that relies on one of them fails to compile. An opa too old to report its capabilities (opa capabilities --current) is refused with exit code 1.
The built-in bundle ships reference gates including promote_gate.rego,
regression_gate.rego (v0.9), and budget_gate.rego — the cost/energy budget
gate (ADR-0136, experimental).
Budget gate (budget_gate.rego, experimental). Denies promotion when the
capsule's already-recorded cost/energy/token rollup exceeds declared ceilings —
a promotion gate over sealed evidence, never a live spend alert. The rollup is
assembled with novafabric.policy.budget_block_from_capsule(capsule_dir) (reads
nova.cost from model-calls.jsonl, measured_joules from
energy-receipts.jsonl, and gen_ai.usage.* token counts) and passed as
input.resource.budget; ceilings go in input.context.budget_ceilings
(total_cost / cost_per_run / energy_kwh / tokens). Missing evidence is
never treated as zero: absent ceilings or absent data pass with an explicit
"no data" reason (skip_unmeasured, the default), while
input.context.missing_evidence: "require_measured" fail-closes on a declared
ceiling with no recorded evidence. Spec: design/spec/budget-gate-v0.md (private).
The nova policy budget set|list|show authoring commands and the budget-gate
verdict record are future design (ADR-0136 P2/P3) — not yet implemented.
Environment-conditioned gates (experimental, ADR-0126 P3). The evidence-export
gate's input carries the capsule's recorded deployment environment as
input.resource.deployment_environment (the value of nova capture --environment /
NOVAFABRIC_ENVIRONMENT, verbatim; null when none was recorded — never inferred), so a
custom policy can apply production-only requirements:
allow if {
input.resource.deployment_environment == "production"
input.resource.redaction_proof_present == true
input.resource.unsafe_skips == 0
}Asset-scoped gates (promotion, protected labels) carry null. The mutating-replay gate
does not yet populate the field (planned); no built-in gate conditions on it.
nova policy explain <decision-id>
Replay a past policy decision from the audit log, showing the event type, actor, resource, and details.
nova policy explain 3f8a1b2c-...--audit-log PATH— audit log to read (default: the hash-chained audit log —$NOVAFABRIC_AUDIT_LOG_PATH, else$XDG_DATA_HOME/novafabric/audit.jsonl, else~/.local/share/novafabric/audit.jsonl)
The dashboard Policy Explain panel auto-completes decision IDs via
GET /api/policy/recent-decisions?limit=50 (serve REST API), which returns up to 50
recent IDs from ~/.novafabric/dashboard-audit.jsonl in most-recent-first order.
nova policy list
List Rego policy files in the built-in bundle and any signed promotion policies stored in the PolicyStore.
nova policy list
nova policy list --namespace staging
nova policy list --bundle /path/to/custom-bundle
nova policy list --db ~/.local/share/novafabric/merkle.db # a store signed before the default changedOptions:
--bundle PATH— Rego bundle directory to scan (default: built-in bundle; also:NOVAFABRIC_POLICY_BUNDLE_PATH)--db PATH— PolicyStore SQLite DB path (default: the NovaSeal Merkle log —NOVAFABRIC_SEAL_DB_PATH, thenmerkle_dbinnovaseal.yaml, then$NOVAFABRIC_HOME/novaseal-merkle.db, the storenova policy signwrites and the dashboard reads; up to v0.106.0 the default was$NOVAFABRIC_HOME/promote/policy.db, falling back to~/.local/share/novafabric/merkle.db— the command names that old file when it holds a store and the default does not)--namespace / -n TEXT— filter signed policies to this namespace (default: show all namespaces)
Output has two sections:
- Rego Bundle — table of
.regofiles with file name (relative to bundle root) and size. - Signed Promotion Policies — table of stored policy versions with version number, namespace, and creation timestamp. If no DB exists yet, a note is printed and the command exits cleanly.
nova approve <name@version>
Approve an asset that is in the pending_approval lifecycle state, recording the approver and note in the audit log.
nova approve my-model@v2
nova approve my-model@v2 --approver alice --note "Reviewed eval results"Options:
--approver TEXT— name or ID of the approver (default: current OS user)--note TEXT— optional approval note recorded in the audit log
Exits with code 1 if the asset is not found or not in pending_approval state.
nova hold create <registry>
Place a legal hold on a registry, suspending all capsule deletion (ADR-0031).
nova hold create my-registry --reason "SEC examination 2026-Q2"
nova hold create my-registry --reason "SEC examination 2026-Q2" --duration-days 365Options:
--reason TEXT— required; reason for the hold (recorded in audit log)--duration-days N— hold duration in days; omit for indefinite hold
Holds are stored in one store shared with the /api/holds routes:
$NOVAFABRIC_HOME/registries/<registry>/holds.jsonl (append-only; release stamps
released_at). A hold placed here therefore blocks nova retention, nova capsule delete,
nova export-retention and the server/dashboard delete routes alike, and one placed through
the dashboard or API blocks this CLI. Holds written before this store existed — at
./.novafabric/registries/<registry>/holds.jsonl under the working directory, or by
nova serve beside its capsule base (<capsule-dir>/../registries/) — are still read by
every deletion gate and can still be listed and released; nothing is moved. The registry
name must be a single path component (no /, \ or ..; exit 1 otherwise).
nova hold list <registry>
List active (unreleased) legal holds on a registry, from every hold location (CLI- and
API-placed). An unreadable ledger line is listed as an active __corrupt__:<registry> hold.
nova hold list my-registrynova hold release <hold-id>
Release a legal hold by ID, wherever it is stored (including holds placed through the API). Records the release in the audit log.
nova hold release hold-a1b2c3d4Exits with code 1 if the hold ID is not found or already released.
nova capsule delete <capsule-id>
Delete a capsule: removes the capsule directory and its runs-cache index rows through the
same governed core as DELETE /v0/capsules/{run_id} and the dashboard delete route
(ADR-0206), and reports success only once the capsule is actually gone.
nova capsule delete cap-01JXXXXX --registry my-registry
nova capsule delete cap-01JXXXXX --registry my-registry --age-days 1826
nova capsule delete cap-01JXXXXX --registry my-registry --forceOptions:
--registry TEXT— required; the registry whose retention policy applies--age-days N— age of the capsule in days (used for retention window check; default: 0)--force— skip the retention-window check only (holds, WORM, seals,deletion_mode: prohibitedand unreadable WORM or policy files still refuse)--capsule-dir PATH— capsule store (default:NOVAFABRIC_CAPSULE_DIR, else$NOVAFABRIC_HOME/capsules)
Deletion is refused (exit 1, nothing reported or audited as deleted) when:
- any legal hold is active — in any registry,
--forceincluded (holds are registry-global, as on the server delete routes; a damaged ledger counts as a hold) - an unexpired WORM lock or a NovaSeal seal protects the capsule
(
NOVAFABRIC_ALLOW_SEALED_DELETE=1lifts the seal refusal only) - a configured
worm.dbcannot be read (worm_state_unavailable; see below) - a retention policy sets
deletion_mode: prohibited, or a policy file cannot be read (retention_policy_unavailable) - the capsule is within a policy's retention window (unless
--force) - the capsule does not exist
Retention policies are read from $NOVAFABRIC_HOME/registries/<registry>/retention-policy.yaml,
the legacy ./.novafabric/registries/<registry>/retention-policy.yaml and the capsule store's
../registries/<registry>/retention-policy.yaml; every file found applies. A policy entry
that cannot be read — malformed YAML, permission denied, a dangling symbolic link or a
directory — refuses with retention_policy_unavailable (fail closed). A refusal by a hold,
WORM lock, unreadable WORM state or seal is recorded as a run.index_delete_refused audit
event. After the capsule is gone, a capsule.delete entry is appended to the hash-chained
audit log.
WORM state (fail closed). The delete checks every worm.db of every registry in the
same three locations ($NOVAFABRIC_HOME/registries/*/, ./.novafabric/registries/*/ and the
capsule store's ../registries/*/), the same files nova retention reads. What happens:
| On disk | Result |
|---|---|
No worm.db in any location |
No local WORM is configured; WORM does not block the delete |
A readable worm.db with an unexpired lock for the capsule |
Refused, worm_hold |
A worm.db entry that cannot be read: not SQLite, empty, no worm_capsules table, a locked_until that does not parse, a directory, a dangling symbolic link, permission denied, or locked by another writer for 2 s |
Refused, worm_state_unavailable; nothing is deleted. There is no override (--force included) |
A damaged worm.db therefore blocks every delete until it is repaired or restored; see
Backup & Restore — unreadable WORM or retention-policy files.
The check reads worm.db read-only and never repairs it. The local WORM adapter is
dev/test-only (ADR-0031): this guards against a damaged or misplaced file, not against an
administrator who edits it. Before this change an unreadable worm.db was skipped with a
warning, and a truncated one was silently recreated empty, so the delete went ahead.
Before this release the command printed "Deleted capsule", exited 0 and audited
capsule.delete without removing anything, and --force also skipped the hold check.
Retention scheduler (ADR-0134)
Experimental. Applies the ADR-0031 retention
windows over time: a WORM-aware, crypto-shred-integrated, audited sweep.
Bindings live in a new optional bindings: block inside the existing
$NOVAFABRIC_HOME/registries/<registry>/retention-policy.yaml
(schema: schemas/retention-binding.schema.json); a registry with no bindings
is swept for nothing. NovaFabric embeds no daemon — run the sweep manually
or wire nova retention apply --yes into cron/systemd.
Where the per-registry files are read (works today). retention-policy.yaml and
worm.db are resolved like the legal-hold store, independent of the working directory:
- Bindings and sweep switches come from
$NOVAFABRIC_HOME/registries/<registry>/retention-policy.yaml. When only the legacy./.novafabric/registries/<registry>/retention-policy.yamlexists under the working directory, it is still read, and a warning on stderr names it and the path to move it to. When both exist, the$NOVAFABRIC_HOMEcopy wins and the shadowed legacy copy is reported the same way. A new policy belongs under$NOVAFABRIC_HOME/registries/. deletion_mode—prohibitedin any copy found (the two locations above plus the swept capsule base's<capsule-dir>/../registries/<registry>/) holds everypurge(deletion_prohibited), asnova capsule deletedoes.- WORM locks — without
--worm-db, everyworm.dbfound in those locations is read (a legacy copy with a warning), and a lock in any of them holds the item.--worm-db PATHreads only that file, and the file must exist. - Fail closed — a
worm.dbentry that cannot be read (the cases listed undernova capsule delete), a--worm-dbpath that does not exist, or aretention-policy.yamlcopy that cannot be read or validated stopsplan,apply,statusandexplainwith exit 1 before anything is acted on, naming the file and the code (worm_state_unavailableorretention_policy_unavailable). Noworm.dbanywhere means no local WORM is configured, and the sweep runs as before.
Releases before 2026-10-23 read both files relative to the working directory only, so a
cron or container sweep started elsewhere found no bindings and no WORM database.
# retention-policy.yaml (ADR-0031 fields unchanged; bindings are additive)
include_capture_capsules: true # optional, default false — see "Which capsules are swept"
bindings:
- id: mifid-trade-5y
match: {tag: trade-record, deployment_environment: production}
window: P1825D # ISO-8601 duration from capsule created_at, or YYYY-MM-DD
action: purge # expire-metadata | purge | crypto-shred
- id: gdpr-subject-pii
match: {age: P180D}
window: P180D
action: crypto-shred # experimental — see belowWhich capsules are swept. The sweep enumerates both manifest formats under the capsule
directory: <run>/capsule.json (the legacy CapsuleWriter format) and <run>/capsule.yaml
(what nova capture and the framework adapters write; a directory holding both is treated as
capsule.json). plan, apply --dry-run, status and explain always show the
capsule.yaml ("capture") capsules and what would happen to them. apply acts on capture
capsules only when the policy sets include_capture_capsules: true (optional, default
false). Earlier versions never enumerated capsule.yaml, so this opt-in keeps an existing
cron sweep from suddenly deleting capsules it never touched before. Without it, plan and
apply print how many capture capsules are excluded and how to include them, and --json
output carries a capture_capsules block (included, enumerated, excluded — previewed as
they would be swept — and notice). Excluded capsules are not swept, so they leave no audit
entry. Holds, WORM locks and the apply-time re-check apply to capture capsules exactly as to
capsule.json capsules. Any other value than true/false is refused (exit 1).
crypto-shred (experimental). It destroys the data subject's DEK (ADR-0069). The subject
comes from metadata.pii_subject_id when a manifest names it, otherwise from the capsule's
redaction_manifest.json: nova capture --pii-subject <id> records the subject's HMAC
there (never the raw id) for every span it encrypted, and apply resolves that HMAC to a live
DEK in $NOVAFABRIC_HOME/dek.db with NOVA_PII_PEPPER. So for capsules captured with
--pii-subject the action is a real crypto-shred (verified end to end by
tests/retention/test_crypto_shred_current_limits.py): the key is destroyed, an
ErasureReceipt is written to $NOVAFABRIC_HOME/evidence/erasure/<run>.receipt.json, and
readers show [erased]. Know before you enable it:
- The DEK is per subject, not per capsule: destroying it makes the subject's PII
unreadable in every capsule captured with that
--pii-subject. Soapplydestroys it only when every capsule carrying the subject is itself due for crypto-shred in the same sweep. If any sibling is WORM-locked, legal-held, not yet due, or under no crypto-shred binding, the due capsule isskippedwith reasonsubject_in_retained_capsule: <ids>and the key is kept. When all are due, the first recordsappliedand the restalready_shreddedwith its receipt. Releases up to v0.107.0 shredded anyway, erasing a WORM-held capsule's PII the same plan reported as held. applyneedsNOVA_PII_PEPPERin its environment (for example in the cron job). Without it the item is recordedskipped(pii_pepper_unavailable) and no key is touched. If no live DEK matches — a different pepper ordek.db, or a subject already erased withnova pii erase— it isskipped(pii_subject_unresolved); a capsule this sweep already shredded recordsapplied(already_shredded).- A capsule captured without
--pii-subjecthas no subject: it recordsappliedwith reasonno_dekand no key is destroyed. Only PII captured with--pii-subjectis ciphertext (ADR-0314); seenova pii erasefor the subject-driven path.
Matching reads capsule manifests under the capsule directory:
metadata.tags (comma-separated), deployment_environment (metadata.deployment_environment
in capsule.json; the top-level field nova capture writes in capsule.yaml), and alias
(matched by the asset predicate, glob allowed). nova capture writes no tags, so bind
capture capsules by age, deployment_environment or asset.
Safety invariants (fixed, not configurable): a WORM/legal hold always wins
— a WORM-retained capsule is never purged or shredded before its locked_until
(recorded skipped: worm_hold), and an active legal hold on the registry — placed with
nova hold or through POST /api/holds, read from the shared hold store — holds every
item (legal_hold_active); purge is refused under
deletion_mode: prohibited; a crypto-shred inside the Art.17(3)(b) window is
deferred. Every decision — including every skip — appends one hash-chained
retention.action audit entry (schemas/retention-action-record.schema.json):
deletion is itself evidence.
nova retention plan
Dry-run (the default posture): list what WOULD be affected. Touches nothing,
writes no audit records, and uses the identical due-computation code path as
apply. Capture capsules (capsule.yaml) that apply will not act on are listed in a
separate table (and under capture_capsules.excluded with --json).
nova retention plan --registry my-registry
nova retention plan --registry my-registry --jsonnova retention apply
Apply due retention actions. Confirm-gated: prompts unless --yes (or
--dry-run). Idempotent and fail-safe — re-runs are no-ops; a per-item
failure is recorded error and the sweep continues. Acts on capture capsules
(capsule.yaml) only with include_capture_capsules: true in the policy; otherwise it
prints how many it excluded.
Holds are re-read immediately before every action, not only while planning: a legal
hold or WORM lock placed while the confirmation prompt waits, or during the sweep, still wins
(recorded skipped with legal_hold_active: <ids> or worm_hold). The re-check also finds
worm.db files again, so one that was emptied, replaced or became unreadable after planning
skips the item as worm_state_unavailable: <path>: <reason>. If the re-check itself fails
in any other way, the item is skipped (hold_check_failed). A crypto-shred that the DEK store
refuses under a hold is recorded skipped (legal_hold_active), never applied, so a later
nova restore does not replay it.
nova retention apply --registry my-registry --dry-run # preview
nova retention apply --registry my-registry --yes # cron/CI
nova retention apply -r my-registry --action crypto-shred --limit 100 --yesOptions:
--dry-run— preview only (identical planner, no action, no audit entries)--yes / -y— skip the confirmation prompt (for cron/CI)--capsule-dir PATH— capsule directory to sweep (default: wherenova capturewrites —$NOVAFABRIC_CAPSULE_DIR, else$NOVAFABRIC_HOME/capsules; before 2026-10-23 the env var was ignored, so a Docker-layout sweep scanned an empty directory)--worm-db PATH— local WORM adapter DB consulted forlocked_until(default: everyworm.dbfound —$NOVAFABRIC_HOME/registries/<registry>/worm.db, the legacy./.novafabric/registries/<registry>/worm.db(read with a warning) and the swept capsule base's../registries/<registry>/worm.db; a lock in any of them holds, and one that cannot be read refuses the sweep — see where the per-registry files are read). A--worm-dbpath that does not exist refuses withworm_state_unavailable--action NAME— only consider bindings with this action--limit N— bound the number of applied actions per pass (the rest carries over)--principal TEXT— acting identity recorded in evidence entries (default:cli-user)--retention-months N— Art.17(3)(b) minimum window for crypto-shred (default: 6)--json— machine-readable output
nova retention status
Read-only: per binding, how many items are due now, how many are held
(WORM/legal), and the next due date — counting only what apply acts on. Without
include_capture_capsules: true, an excluded column (excluded_capture_capsules in
--json, plus top-level include_capture_capsules and capture_capsules_enumerated) counts
the capture capsules each binding matches that apply will not touch.
nova retention status --registry my-registry --jsonnova retention explain <capsule-id>
Read-only: which bindings match this capsule, its computed due date, and its
current hold state. --json adds manifest (capsule.json or capsule.yaml) and
swept_by_apply (false for a capture capsule without the opt-in).
nova retention explain cap-01JXXXXX --registry my-registry