pg_risk
pg_risk · Deterministic risk policies with auditable decisions
Overview
PostgreSQL · 14, 15, 16, 17, 18
Usage
Sources:
pg_risk evaluates deterministic policies and records auditable decisions on PostgreSQL 14–18. It evaluates permissions or limits around an operation; the application still owns execution of that operation.
Core Workflow
The following psql example creates a subject, policy, and rolling-volume rule, then evaluates a request. Amount limits use the asset’s smallest units.
Decision Semantics
risk_check records a decision and applies idempotency semantics, while risk_evaluate provides evaluation without the same persisted-decision workflow. Policy configuration and event history determine the result; success does not execute a payment or reserve external funds. For strict concurrent limits, use the documented subject locking and keep the check and application operation in one transaction.
Core use has no mandatory companion extension. Optional adapters connect to the matching RustedBytes financial extensions; enabling them requires those exact APIs and appropriate grants. The ledger adapter must not be pointed at an unrelated extension with the same name.
Operation
The extension needs no preload and is non-relocatable. Treat policy administration, event ingestion, and decision execution as separate privileges. Its immutable decision records do not make incorrect input data or an incorrectly configured policy trustworthy.