Python: Simulation
Run access simulations as every user type, preview policy or SQL changes, and compare runs with the Python SDK.
Checks who can do what in your project without writing anything. Use a team member's token — simulations act on the project's configuration. Background: Simulate access before you ship.
run = await sovaria.simulate_run(resource="public.orders")
if run["cases_fail"]:
raise SystemExit(f"{run['cases_fail']} access checks failed")#Methods
sovaria.sim_compare_runs
Sim compare runs.
await sovaria.sim_compare_runs(
target_run_id: str,
baseline_run_id: str,
) -> dict[str, Any]Parameters
target_run_idstrrequiredbaseline_run_idstrrequired
Returns
dict[str, Any]
{
"baseline_run_id": "run_41a…",
"target_run_id": "run_7c2e…",
"summary": {
"regressions": 1,
"improvements": 3,
"unchanged": 210,
"new_cases": 4,
"removed_cases": 0,
"new_failures": 1,
"resolved_failures": 3
},
"regressions": [
{
"case_key": "__guest__|sql:select|orders|",
"role": "__guest__",
"action": "sql:select",
"resource": "orders",
"endpoint": "",
"baseline": {
"outcome": "DENY",
"is_deviation": false,
"deviation_type": "NONE",
"severity": 0
},
"target": {
"outcome": "ALLOW",
"is_deviation": true,
"deviation_type": "UNEXPECTED_ALLOW",
"severity": 3
}
}
],
"improvements": []
}sovaria.sim_discover
Sim discover.
await sovaria.sim_discover() -> dict[str, Any]Returns
dict[str, Any]
{
"manifest_id": "man_3b…",
"project_id": "f0c3e9a2-1b4d-4e7f-8a6c-2d9b5e3f1a07",
"org_id": "b2f4a1c8-7d3e-4f0a-9c6b-5e8d2a1f3c90",
"env_id": null,
"discovered_at": "2026-10-17T13:30:58Z",
"roles": [
"OWNER",
"ADMIN",
"MEMBER",
"VIEWER"
],
"app_personas": [
{
"persona": "app:staff",
"users": 3,
"roles": [
"staff"
],
"has_public_key": true
}
],
"user_count_by_role": {
"MEMBER": 2
},
"role_subjects": {},
"functions": [
{
"name": "send-receipt",
"method": "POST",
"invoke_permission": "authenticated",
"runtime": "python3",
"description": ""
}
],
"policies": [
{
"policy_id": "pol_orders_read",
"name": "Signed-in users read orders",
"is_active": true,
"spl_source": "ALLOW IF ctx.resource.name == \"orders\" AND ctx.action IN [\"SELECT\", \"sql:select\"] AND ctx.actor.is_anonymous == False",
"conditions": []
}
],
"collections": [
"carts"
],
"tables": [
{
"name": "orders",
"schema": "public",
"table": "orders",
"kind": "table",
"rls_enabled": true,
"rls_forced": false,
"columns": [
{
"name": "id",
"type": "bigint"
}
],
"rls_policies": [],
"security_invoker": false
}
],
"buckets": [
"avatars"
],
"bucket_details": [
{
"name": "avatars",
"public": false
}
],
"settings": {
"allowPublicSignup": true
},
"channels": [
"room-42"
],
"discovery_ms": 812.4
}sovaria.sim_get_run
Sim get run.
await sovaria.sim_get_run(run_id: str) -> dict[str, Any]Parameters
run_idstrrequired
Returns
dict[str, Any]
{
"run_id": "run_7c2e…",
"project_id": "f0c3e9a2-1b4d-4e7f-8a6c-2d9b5e3f1a07",
"org_id": "b2f4a1c8-7d3e-4f0a-9c6b-5e8d2a1f3c90",
"status": "complete",
"started_at": "2026-10-17T13:31:02Z",
"completed_at": "2026-10-17T13:31:40Z",
"cases_total": 214,
"cases_pass": 209,
"cases_fail": 2,
"cases_warn": 3,
"cases_deviation": 2,
"top_findings": [
{
"severity": "critical",
"category": "access_control",
"title": "2 request(s) get through that your rules deny",
"detail": "…",
"fix": "…"
}
],
"results": [
{
"case": {
"role": "__guest__",
"action": "sql:select",
"resource": "orders",
"expected": "DENY"
},
"outcome": "ALLOW",
"is_deviation": true,
"deviation_type": "UNEXPECTED_ALLOW",
"guard_decision": "DENY",
"duration_ms": 38.5
}
],
"runner_ms": 38210.0
}sovaria.sim_list_runs
Sim list runs.
await sovaria.sim_list_runs(
*, limit: int = 20,
offset: int = 0,
) -> dict[str, Any]Parameters
limitintoptionaldefault20offsetintoptionaldefault0
Returns
dict[str, Any]
{
"runs": [
{
"run_id": "run_7c2e…",
"status": "complete",
"started_at": "2026-10-17T13:31:02Z",
"cases_total": 214,
"cases_fail": 2
}
],
"total": 1,
"limit": 50,
"offset": 0
}sovaria.simulate_change
Try a change before making it; nothing is written.
policy (SPL, optionally replaces a live policy id) or disable_policy_ids: who gains and who loses access.
await sovaria.simulate_change(
*, policy: str | None = None,
policy_name: str = 'draft',
replaces: str | None = None,
disable_policy_ids: list[str] | None = None,
sql: str | None = None,
) -> dict[str, Any]sql: the script runs with every check and is rolled back; the answer lists objects added/dropped/changed, rows changed and tables that would be rewritten under a full lock. violations lists what should block the change.
Parameters
policystr | NoneoptionaldefaultNonepolicy_namestroptionaldefault'draft'replacesstr | NoneoptionaldefaultNonedisable_policy_idslist[str] | NoneoptionaldefaultNonesqlstr | NoneoptionaldefaultNone
Returns
dict[str, Any]
{
"kind": "policy",
"nothing_written": true,
"cases_checked": 48,
"changes": [
{
"persona": "__guest__",
"who": "Visitors who aren't signed in",
"action": "sql:insert",
"resource": "orders",
"before": "DENY",
"after": "ALLOW",
"before_policy": null,
"after_policy": "pol_orders_read",
"row_policies_still_apply": true
}
],
"violations": [
{
"persona": "__guest__",
"who": "Visitors who aren't signed in",
"action": "sql:insert",
"resource": "orders",
"before": "DENY",
"after": "ALLOW",
"before_policy": null,
"after_policy": "pol_orders_read",
"row_policies_still_apply": true,
"severity": "critical",
"reason": "Visitors who aren't signed in could change data"
}
],
"summary": {
"gains": 1,
"losses": 0,
"violations": 1
},
"impact": [
"1 request type(s) newly allowed",
"0 request type(s) newly denied",
"Visitors who aren't signed in could change data: sql:insert on orders"
]
}sovaria.simulate_checks
What is wrong or at risk, worst first: {"checks": [{id, area, severity, title, detail, evidence, fix, fix_link, node_ids}], "summary": {"critical": n, "warning": n, "info": n}}.
await sovaria.simulate_checks(
*, severity: str | None = None,
area: str | None = None,
fresh: bool = False,
) -> dict[str, Any]severity keeps that level and worse (critical | warning | info).
Parameters
severitystr | NoneoptionaldefaultNoneareastr | NoneoptionaldefaultNonefreshbooloptionaldefaultFalse
Returns
dict[str, Any]
sovaria.simulate_drills_run
The 14 security drills judged from the project's configuration, with an optional what-if draft (never saved).
await sovaria.simulate_drills_run(
*, drill_ids: list[str] | None = None,
overrides: dict[str, Any] | None = None,
) -> dict[str, Any]Parameters
drill_idslist[str] | NoneoptionaldefaultNoneoverridesdict[str, Any] | NoneoptionaldefaultNone
Returns
dict[str, Any]
{
"results": [
{
"id": "stuff",
"group": "Accounts",
"name": "Credential stuffing from a botnet",
"verdict": "exposed",
"stopped_at": null,
"why": "A botnet trying leaked passwords stays under the per-IP limits; nothing else stops it.",
"fix": {
"setting_path": "authConfig.attack.leakedPasswordCheck",
"label": "Turn on the leaked-password check or CAPTCHA",
"console_link": "auth/attack-protection"
}
}
],
"score": 71,
"real_score": 71,
"shield": false,
"overrides_applied": {},
"mode": "modelled"
}sovaria.simulate_graph
The architecture map: {"nodes": [{id, kind, layer, group, label, status, badges, metrics, check_ids, drill}], "edges": [{id, from, to, kind, evidence, status}], "summary": {...}}.
await sovaria.simulate_graph(*, fresh: bool = False) -> dict[str, Any]Parameters
freshbooloptionaldefaultFalse
Returns
dict[str, Any]
sovaria.simulate_integration_run
One integration flow under a programmed outcome.
await sovaria.simulate_integration_run(
*, connector_id: str,
flow_id: str,
outcome: str = 'ok',
mode: str = 'modelled',
) -> dict[str, Any]modelled is free and sends nothing; sealed runs the real code path to the send point and returns the recording (one single-request check).
Parameters
connector_idstrrequiredflow_idstrrequiredoutcomestroptionaldefault'ok'modestroptionaldefault'modelled'
Returns
dict[str, Any]
{
"connector_id": "smtp",
"flow_id": "password_reset",
"outcome": "creds",
"mode": "modelled",
"steps": [
{
"lane": "app",
"text": "A user signs up / asks for a link",
"tone": "on"
},
{
"lane": "sovaria",
"text": "Sovaria renders your email template and hands it to the sender",
"tone": "on"
},
{
"lane": "dummy",
"text": "Email sender (dummy): Refuses the username or password",
"tone": "bad"
},
{
"lane": "sovaria",
"text": "Reports 'check your SMTP settings'",
"tone": "bad"
}
],
"user_sees": "No email at all until the SMTP password is fixed.",
"verdict": "bad",
"lesson_key": "sim.integrations.smtp.creds",
"artifact": {
"id": "",
"kind": "smtp",
"target_host": "Email",
"outcome": "creds",
"created_at": "",
"preview": {
"note": "Modelled from your settings: nothing was built or sent."
}
}
}sovaria.simulate_inventory
Everything the project has, read from every engine (tables in every schema it created, collections, buckets, secret names, functions with schedules, queues, workflows and triggers, sign-in, webhooks, channels, edge limits, backups, environments, domains, policies, plan headroom).
await sovaria.simulate_inventory(
*, include: str | None = None,
fresh: bool = False,
) -> dict[str, Any]include names sections, comma-separated.
Parameters
includestr | NoneoptionaldefaultNonefreshbooloptionaldefaultFalse
Returns
dict[str, Any]
sovaria.simulate_limits
Every limit the project lives under: {"limits": [{label, setting, value, unit, keyed_by, method, kind}]}.
await sovaria.simulate_limits() -> dict[str, Any]Returns
dict[str, Any]
{
"limits": [
{
"label": "Sign-ins per 5 minutes",
"setting": "signInsPer5Min",
"value": 30,
"unit": "per 5 min",
"keyed_by": "ip",
"method": "fixed window",
"kind": "rate"
}
]
}sovaria.simulate_list_intended
Outcomes the team marked as intended for this project: {"intended": [{mark_id, role, action, resource, outcome, note, marked_by, marked_at}]}.
await sovaria.simulate_list_intended() -> dict[str, Any]Returns
dict[str, Any]
{
"intended": [
{
"mark_id": "6f1c2a9d0b7e4c5a8e3f2d1c0b9a8e7f",
"role": "__guest__",
"action": "sql:select",
"resource": "public.products",
"outcome": "ALLOW",
"note": "The product catalogue is public",
"marked_by": "2c1f6b8a-4d3e-4f5a-9b8c-7d6e5f4a3b2c",
"marked_at": 1792531200.0
}
]
}sovaria.simulate_mark_intended
Mark an outcome as intended (outcome ALLOW or DENY): matching cases show green on every run and leave the findings.
await sovaria.simulate_mark_intended(
*, role: str,
action: str,
resource: str,
outcome: str,
note: str | None = None,
) -> dict[str, Any]Needs policies.write; marking the same role/action/resource again replaces it.
Parameters
rolestrrequiredactionstrrequiredresourcestrrequiredoutcomestrrequirednotestr | NoneoptionaldefaultNone
Returns
dict[str, Any]
{
"mark_id": "6f1c2a9d0b7e4c5a8e3f2d1c0b9a8e7f",
"role": "__guest__",
"action": "sql:select",
"resource": "public.products",
"outcome": "ALLOW",
"note": "The product catalogue is public",
"marked_by": "2c1f6b8a-4d3e-4f5a-9b8c-7d6e5f4a3b2c",
"marked_at": 1792531200.0
}sovaria.simulate_plan
Preview simulation traversal without execution side effects.
await sovaria.simulate_plan(
simulation_name: str,
operations: list[dict[str, Any]],
*, actor_ctx: dict[str, Any] | None = None,
context: dict[str, Any] | None = None,
) -> dict[str, Any]actor_ctx is who the operations run as (context is the old name for it).
Parameters
simulation_namestrrequiredoperationslist[dict[str, Any]]requiredactor_ctxdict[str, Any] | NoneoptionaldefaultNonecontextdict[str, Any] | NoneoptionaldefaultNone
Returns
dict[str, Any]
sovaria.simulate_quota
Real simulation runs used and allowed today (UTC) and this month.
{"day": {"used", "limit", "resets_at"}, "month": {...}}; a real run uses one of each, a failed run gives both back, and single-request checks use one from the day per 5 checks.
await sovaria.simulate_quota() -> dict[str, Any]Returns
dict[str, Any]
{
"day": {
"used": 1,
"limit": 2,
"resets_at": "2026-10-22T00:00:00+00:00"
},
"month": {
"used": 3,
"limit": 5,
"resets_at": "2026-11-03T10:00:00+00:00"
},
"partial_units_per_run": 5
}sovaria.simulate_run
Who can do what in the live project, as visitors, the app's users and the team. Every persona's requests go through the real gateway; SQL writes run with every check and are rolled back, other writes stop after their access checks, so nothing is written.
await sovaria.simulate_run(
simulation_name: str | None = None,
operations: list[dict[str, Any]] | None = None,
*, resource: str | None = None,
action: str | None = None,
role: str | None = None,
include_execution_tree: bool = False,
context: dict[str, Any] | None = None,
manifest_id: str | None = None,
) -> dict[str, Any]resource/action/role narrow the run (role: __guest__, __app_user__, app:<role> or a team role): up to 25 request types is a single-request check that doesn't use the allowance; a wider filter is charged as a full run. manifest_id (from simulate_discover) skips discovery. One full run at a time per organization (409 SIMULATION_RUN_IN_PROGRESS). simulation_name/operations are accepted for older callers and ignored: the run covers the whole project.
Parameters
simulation_namestr | NoneoptionaldefaultNoneoperationslist[dict[str, Any]] | NoneoptionaldefaultNoneresourcestr | NoneoptionaldefaultNone- Only this table/collection/bucket/channel/function.
actionstr | NoneoptionaldefaultNone- Only this action, e.g.
sql:delete. rolestr | NoneoptionaldefaultNone__guest__,__app_user__,app:<role>or a team role.include_execution_treebooloptionaldefaultFalsecontextdict[str, Any] | NoneoptionaldefaultNonemanifest_idstr | NoneoptionaldefaultNone
Returns
dict[str, Any]
sovaria.simulate_run_artifacts
What a run's sealed send points would have sent (secrets masked).
await sovaria.simulate_run_artifacts(run_id: str) -> dict[str, Any]Parameters
run_idstrrequired
Returns
dict[str, Any]
{
"run_id": "7c1d…",
"artifacts": [
{
"id": "9f2e1c0a…",
"run_id": "7c1d…",
"kind": "smtp",
"target_host": "email.amazonaws.com",
"outcome": "ok",
"persona": "__guest__",
"preview": {
"to": "a***@example.com",
"subject": "Confirm your email",
"body": "(hidden: needs Project settings)"
},
"created_at": 1792531200.0
}
]
}sovaria.simulate_topology
Callers, gateway checks, sign-in, resources and connectors (platform defences as "Platform protection").
await sovaria.simulate_topology() -> dict[str, Any]Returns
dict[str, Any]
{
"project": {
"id": "8cab1cf9-…",
"name": "Storefront",
"plan": "pro"
},
"callers": [
{
"id": "__guest__",
"label": "Visitor (not signed in)",
"kind": "guest"
}
],
"gateway": {
"checks": [
{
"id": "project_rate",
"label": "Project rate limit",
"detail": "120 requests/min per IP"
},
{
"id": "platform",
"label": "Platform protection"
}
]
},
"identity": {
"providers": [
"Email and password",
"Google"
],
"mfa": true,
"passkeys": false,
"captcha": false,
"sessions": {
"timeoutMin": 0,
"inactivityMin": 0,
"singleSession": false
}
},
"resources": {
"tables": [
"orders"
],
"collections": [],
"functions": [
"stripe-webhook"
],
"buckets": [
"invoices"
],
"channels": []
},
"integrations": [
{
"id": "smtp",
"kind": "smtp",
"name": "Sovaria email",
"vendor": "Email",
"configured": true,
"lastError": null,
"flows": [
{
"id": "password_reset",
"label": "Password reset"
}
],
"outcomes": [
"ok",
"slow",
"down",
"limit",
"creds",
"ours"
]
}
],
"settingsReview": []
}sovaria.simulate_unmark_intended
Remove an intended-outcome mark; matching cases show as measured again.
await sovaria.simulate_unmark_intended(mark_id: str) -> dict[str, Any]Parameters
mark_idstrrequired
Returns
dict[str, Any]
{
"removed": true,
"mark_id": "6f1c2a9d0b7e4c5a8e3f2d1c0b9a8e7f"
}