ZerwOnePlatform
Private preview

Docs

API reference

Version 1. Two endpoints. JSON in, JSON out. Bearer token auth.

Base URL: https://api.zerwone.com

POST /v1/verify

Rebuilds the schema in a sandbox, tests access, writes a fix and tests again. Runs take seconds to a few minutes; set a client timeout of 10 minutes.

Request body

FieldTypeMeaning
formatstringAlways zerwone.verify-request.v1.
request_idstringYour id for this run. Returned unchanged.
schemaobjectThe schema export (zerwone.schema-export.v1): tables, policies, views, functions. At most 30 tables per request.
app_descriptionstring, optionalOne sentence on what the app should allow. Strongly recommended: it decides what is a leak.
confirmed_guardsstring[], optionalCheck ids the owner confirmed as intended access, from a previous result.
rule_checksboolean, optionalDefault true. Adds fixed checks that do not depend on a model.
request (shortened)
{
  "format": "zerwone.verify-request.v1",
  "request_id": "chat-app-0001",
  "app_description": "Recipients should be able to see messages sent to them; only the sender should be able to edit a message's text.",
  "confirmed_guards": [],
  "schema": {
    "format": "zerwone.schema-export.v1",
    "tables": [ /* 1 table */ ],
    "policies": [ /* 3 policies */ ],
    "views": [],
    "functions": []
  }
}

Response body

FieldTypeMeaning
formatstringzerwone.verify-result.v1
request_idstringYour request_id.
modelstringThe model that wrote the checks and the fix.
findingsobject[]One per leak: title, severity (critical for anonymous access, otherwise high), location, check_ids.
checksobject[]Every check: id, role, sql, expect, category before the fix, passes_after, intent_dependent, rule.
migration.sqlstring | nullThe fix. Only access changes: row level security, policies, grants, view and function security settings.
migration.ran_cleanbooleanEvery statement ran without error on the copy.
migration.roundsnumberHow many tries the fix took (at most 3).
migration.errorsstring[]Statements that failed or were out of scope, and places where the copy differs from your database.
response (real run, shortened)
{
  "format": "zerwone.verify-result.v1",
  "request_id": "chat-app-0001",
  "findings": [
    {
      "title": "recipient bob cannot edit alice's message",
      "severity": "high",
      "location": "public.messages",
      "check_ids": [
        "c_1e1c855edcf3"
      ]
    }
  ],
  "checks": [
    {
      "id": "c_1e1c855edcf3",
      "role": "user_b",
      "expect": "denied",
      "category": "leak",
      "description": "recipient bob cannot edit alice's message",
      "passes_after": true
    },
    {
      "id": "c_47f5a21275cc",
      "role": "user_b",
      "expect": "denied",
      "category": "leak",
      "description": "bob cannot reassign alice's message to himself",
      "passes_after": true
    },
    {
      "id": "c_e5f98d289d27",
      "role": "user_b",
      "expect": "denied",
      "category": "leak",
      "description": "[rule] bob as recipient_id cannot rewrite body of alice's messages row",
      "passes_after": true
    },
    {
      "id": "c_066f5ee46e2b",
      "role": "user_a",
      "expect": "allowed",
      "category": "guard",
      "description": "alice reads messages she sent or received",
      "passes_after": true
    },
    "... 14 more checks"
  ],
  "migration": {
    "sql": "-- 1. anon has no business touching this table.\nrevoke all on table \"public\".\"messages\" from anon;\n\n-- 2. Only the sender may update a message. Replace the participants-update\n--    policy with a sender-only one, and pin sender_id in WITH CHECK so a\n--    sender cannot hand the row to someone else.\ndrop policy \"participants update\" on \"public\".\"messages\";\n\ncreate policy \"sender updates\" on \"public\".\"messages\"\n  as permissive for update to \"authenticated\"\n  using  (((select auth.uid()) = sender_id))\n  with check (((select auth.uid()) = sender_id));",
    "ran_clean": true,
    "rounds": 1,
    "errors": []
  }
}

Check categories

FieldTypeMeaning
leakexpect denied, but allowed before the fixA hole. passes_after true means it closed.
guardexpect allowed, and allowed before the fixAccess the app needs. passes_after true means the fix kept it.
blockedexpect allowed, but denied before the fixA feature that does not work today. Reported, not fixed.
okexpect denied, and denied before the fixAlready safe. Must stay safe after the fix.

Roles

user_a and user_b are two signed-in users (Alice and Bob), anon is a visitor with the public key, service_role bypasses row level security and is only used to observe.

GET /healthz

No auth. Returns {"ok": true} when the service is up.