# CLI: Policies, rules tests, simulation, audit and compliance
Source: https://sovaria.in/docs/cli-security

Manage access policies, test who can do what with rules tests, run access simulations and change previews (with CI exit codes), read the audit trail, and download your organization's compliance evidence pack with sov.

`sov sim run --fail-on critical` exits with status 1 when a run finds critical problems, so it can stop a CI pipeline. `sov rules test` checks a file of expectations (who may do what) and exits 1 when one fails; both run in the Sovaria GitHub Action ([Tutorial: prove your table is private before you ship](https://sovaria.in/docs/tutorial-secure-a-table)). Background: [Simulate access before you ship](https://sovaria.in/docs/simulation).

Before every deploy:
```bash
sov sim run --fail-on critical
sov sim change --sql-file migrations/20261016_add_note.sql
```

## sov policy

Access policy commands

### sov policy templates
`sov policy templates [OPTIONS]`
List built-in SPL policy templates.

### sov policy list
`sov policy list [OPTIONS]`
List active policies in scope.

### sov policy get
`sov policy get [OPTIONS] POLICY_ID`
Fetch a policy by ID.

### sov policy upsert
`sov policy upsert [OPTIONS] POLICY_ID`
Create or update a policy (tries create then update).
Policies apply to the project in scope (`--project` or `sov scope set`).

### sov policy delete
`sov policy delete [OPTIONS] POLICY_ID`
Delete (deactivate) a policy.

### sov policy history
`sov policy history [OPTIONS] POLICY_ID`
List policy version history.

### sov policy rollback
`sov policy rollback [OPTIONS] POLICY_ID`
Rollback policy to a historical version.

### sov policy evaluate
`sov policy evaluate [OPTIONS] POLICY_ID`
Evaluate policy against an explicit context.

### sov policy check
`sov policy check [OPTIONS]`
Preflight an action/resource against the active access policies.

### sov policy simulate
`sov policy simulate [OPTIONS]`
Dry-run operations against the project's active access rules (nothing is changed).
Example: sov policy simulate --action PUBLISH --resource book:42       --context '{"actor": {"roles": ["librarian"]}, "realtime": {"prefix": "book"}}'

Try a rule before saving it: --draft 'DENY IF ctx.action == "DELETE"' [--replaces pol_123] --explain

The actor is one of your app's users unless you pass --as team: team members and app users are judged by different rules, exactly as their real requests are.

## sov rules

Test access rules: who can do what (CI-ready)

### sov rules init
`sov rules init [PATH]`
Write a starter rules test file to edit.

### sov rules test
`sov rules test [OPTIONS] [PATH]`
Check every case against the project's rules; exit 1 if any case fails.

## sov sim

Scenario discovery, runs, and comparisons

### sov sim discover
`sov sim discover [OPTIONS]`
What a run would cover: personas, tables, collections, buckets, channels, functions, settings.

### sov sim quota
`sov sim quota [OPTIONS]`
Real simulation runs left today (UTC) and this month.
A full run uses one of each; narrow runs use one from the day per 5 checks; a failed run gives them back.

### sov sim limits
`sov sim limits [OPTIONS]`
Every limit the project lives under: value, unit, what it is counted per and how.
Free.

### sov sim integrations
`sov sim integrations [OPTIONS]`
What happens in one integration flow when the outside service answers a certain way.
Modelled by default (free, nothing sent); --sealed shows the exact message that would have gone out.

### sov sim drills
`sov sim drills [OPTIONS]`
Security drills judged from the project's configuration, with a readiness score.
With --fail-on it is a CI gate: exposed fails on exposed drills, partial fails on partial or exposed ones.

### sov sim runs
`sov sim runs [OPTIONS]`
List simulation runs for the current project.

### sov sim get
`sov sim get [OPTIONS] RUN_ID`
Fetch one simulation run by ID.

### sov sim compare
`sov sim compare [OPTIONS] TARGET_RUN_ID BASELINE_RUN_ID`
Compare two simulation runs.

### sov sim checks
`sov sim checks [OPTIONS]`
What is wrong or at risk in the project, worst first, each with a fix.
Free: reads configuration, runs nothing.

### sov sim inventory
`sov sim inventory [OPTIONS]`
Everything the project has, read from every engine: every schema it created, collections, buckets, secret names, functions with schedules, queues, workflows and triggers, sign-in, webhooks, channels, limits, backups and more.

### sov sim map
`sov sim map [OPTIONS]`
The architecture map as text: each layer's parts with their status (the console draws it).
--json for the graph.

### sov sim run
`sov sim run [OPTIONS]`
Check who can do what in the live project — as visitors, your app's users and your team — with nothing written.
A full run uses one simulation from your plan's allowance and runs one at a time per organization. A narrow run (--resource/--action/--role matching at most 25 request types) doesn't use the allowance; a wider one is charged as a full run.

### sov sim change
`sov sim change [OPTIONS]`
Try a policy or SQL change before making it: who gains or loses access, what the script changes.
Nothing is written.

### sov sim intended list
`sov sim intended list [OPTIONS]`
Outcomes marked as intended in this project.

### sov sim intended mark
`sov sim intended mark [OPTIONS]`
Mark an outcome as intended (needs permission to change policies).

### sov sim intended unmark
`sov sim intended unmark [OPTIONS] MARK_ID`
Remove a mark; matching cases show as measured again.

## sov simulate

Offline simulation from a project snapshot

### sov simulate snapshot
`sov simulate snapshot [OPTIONS]`
Record the project's access surface for offline runs: tables, row policies, SQL functions and every case of the simulation matrix with the project's rules' verdict.
Counts against sim.snapshot_exports_month.

### sov simulate offline
`sov simulate offline [OPTIONS]`
Run the SQL part of the simulation matrix on a throwaway Postgres built from a snapshot — no live project, nothing sent anywhere.
With --migration, runs before and after and lists every access change.

## sov audit

Audit trail and simulations

### sov audit append
`sov audit append [OPTIONS]`
Append an immutable audit entry.

### sov audit list
`sov audit list [OPTIONS]`
Query audit log entries.

### sov audit verify
`sov audit verify [OPTIONS]`
Verify audit hash-chain integrity.

### sov audit count
`sov audit count [OPTIONS]`
Return audit log entry count.

### sov audit sim-run
`sov audit sim-run [OPTIONS] SIMULATION_NAME OPERATIONS`
Run a phantom simulation.

### sov audit sim-plan
`sov audit sim-plan [OPTIONS] SIMULATION_NAME OPERATIONS`
Preview a simulation plan.

## sov compliance

Compliance center: your organization's evidence pack for audits

### sov compliance status
`sov compliance status [OPTIONS]`
What the evidence pack shows now: audit log, own key, regions, backups, PITR, Security Advisor, access.

### sov compliance export
`sov compliance export [OPTIONS]`
Download the evidence pack (ZIP) and check every file against its MANIFEST.json SHA-256.

### sov compliance hipaa
`sov compliance hipaa [OPTIONS]`
HIPAA status (Enterprise): HIPAA mode (BAA signed), session limits, retention and PHI projects.
With --report, download the safeguards report: each HIPAA Security Rule technical safeguard judged from live data (counts toward the plan's packs per day; audited). Evidence for your own risk analysis, not a certification. Plans without HIPAA get PLAN_FEATURE_REQUIRED: HIPAA comes with Enterprise and a signed BAA.

### sov compliance audit-log
`sov compliance audit-log [OPTIONS]`
Export the organization's tamper-evident audit log (within the plan's retention).
Each export is itself written to the log. Check the chain with `sov audit verify`.
