/v1/guard/sqlDecide whether an agent-authored PostgreSQL statement complies with an execution policy, using PostgreSQL's own parser rather than pattern matching. Detects statement stacking, data-modifying CTEs, COPY PROGRAM, privilege changes, and dangerous functions that read as ordinary SELECTs. Returns reason codes and an optional short-lived signed permit bound to the exact normalized statement. Never connects to your database.
{
"additionalProperties": false,
"properties": {
"audience": {
"description": "Identity of the ONE executor the permit is for. Required when issue_permit is true. Wildcards are rejected.",
"type": "string"
},
"dialect": {
"enum": [
"postgresql"
],
"type": "string"
},
"issue_permit": {
"type": "boolean"
},
"policy": {
"additionalProperties": false,
"properties": {
"allow_multi_statement": {
"description": "Permit more than one statement in the input. Defaults to false.",
"type": "boolean"
},
"allow_returning": {
"description": "Accept RETURNING on a permitted write without a warning.",
"type": "boolean"
},
"allow_row_locks": {
"description": "Accept SELECT ... FOR UPDATE without a warning.",
"type": "boolean"
},
"allowed_functions": {
"description": "Added to the built-in allowlist. Bare name, or schema.function to admit one of your own.",
"items": {
"type": "string"
},
"type": "array"
},
"allowed_languages": {
"description": "Permitted CREATE FUNCTION languages. Defaults to none.",
"items": {
"type": "string"
},
"type": "array"
},
"allowed_schemas": {
"description": "Schemas the statement may reference.",
"items": {
"type": "string"
},
"type": "array"
},
"allowed_tables": {
"description": "Permitted relations as schema.table, or a bare name to match an unqualified reference.",
"items": {
"type": "string"
},
"type": "array"
},
"max_rows": {
"description": "Row ceiling. Becomes a permit obligation the executor enforces.",
"minimum": 1,
"type": "integer"
},
"read_only": {
"description": "Reject anything that can change data or schema, including writes reached through a CTE.",
"type": "boolean"
},
"statement_timeout_ms": {
"description": "Timeout written into the permit obligations. Defaults to 30000.",
"minimum": 1,
"type": "integer"
}
},
"type": "object"
},
"sql": {
"maxLength": 100000,
"minLength": 1,
"type": "string"
},
"subject": {
"description": "Opaque caller label recorded as the permit subject.",
"type": "string"
},
"target_pg_major": {
"description": "Required. The PostgreSQL major the statement will run on. Only 18 is supported in v1: a permit issued under one grammar and verified against another is a parser differential.",
"enum": [
18
],
"type": "integer"
}
},
"required": [
"dialect",
"target_pg_major",
"sql"
],
"type": "object"
}{
"confidence": 1,
"data_versions": {
"grammar": "pg18/libpg-query@18.1.4",
"parser": "libpg-query@18.1.4",
"pg_parse_version": "180004"
},
"evidence": [],
"ok": true,
"policy_version": "sqlpermit-policy-1.0.0",
"request_hash": "sha256:1c2d0f4c1d8e2b7a9c5d3e6f8a1b2c4d5e6f7a8b9c0d1e2f3a4b5c6d7e8f9a0b",
"result": {
"classification": "read_only",
"findings": [],
"grammar": "pg18/libpg-query@18.1.4",
"normalized_sql": "SELECT id, total FROM analytics.orders ORDER BY created_at DESC LIMIT 100",
"obligations": {
"max_rows": 1000,
"require_read_only_tx": true,
"statement_timeout_ms": 30000
},
"permit": "eyJhbGciOiJFZDI1NTE5Iiwia2lkIjoi…",
"permit_expires_at": "2026-08-03T12:00:45.000Z",
"permit_kid": "uGzLTTwi4LTsOiBLgwf2wMU7ILTecj18Y_71Y37bVD8",
"policy_hash": "sha256:2b7a9c5d3e6f8a1b2c4d5e6f7a8b9c0d1e2f3a4b5c6d7e8f9a0b1c2d0f4c1d8e",
"referenced_functions": [],
"referenced_schemas": [
"analytics"
],
"referenced_tables": [
"analytics.orders"
],
"statement_count": 1,
"statement_types": [
"SelectStmt"
],
"stmt_fingerprint": "a1b2c3d4e5f60718",
"stmt_hash": "sha256:0f4c1d8e2b7a9c5d3e6f8a1b2c4d5e6f7a8b9c0d1e2f3a4b5c6d7e8f9a0b1c2d",
"target_pg_major": 18
},
"risk_codes": [],
"verdict": "pass",
"warnings": [
"stmt_fingerprint is ADVISORY and must not be used for authorization: libpg-query fingerprints discard literal constants, so two statements differing only in a value share one fingerprint. stmt_hash is the binding value."
]
}