symfonic.memory.backends.postgres_runtime_roles¶
postgres_runtime_roles ¶
Opt-in schema-migrator / DML-only runtime login split (CORE-127 candidate).
Import explicitly. Nothing here creates roles, sets passwords, terminates
sessions, resolves prepared transactions or swaps indexes; those are operator
acts. grant_runtime and revoke_runtime run as the schema owner;
require_split_runtime runs read-only as the runtime; require_login_retired
runs as an administrative observer. A passing probe is point-in-time evidence
for the named login only, never a fleet barrier.
RuntimeRoleNotReady ¶
Bases: RuntimeError
A login violates the migrator/runtime split contract.
grant_runtime
async
¶
grant_runtime(connection: Any, runtime_login: str, *, schema: str = 'public', ledger: str = MIGRATION_LEDGER) -> tuple[str, ...]
Owner side: reset the runtime to exact DML on every owned table, atomically.
Every table in schema gets SELECT/INSERT/UPDATE/DELETE and nothing else,
column grants included; the CORE-199 erase job table gets SELECT only,
its receipts nothing, its memory erase generations SELECT/INSERT/UPDATE and its
erase log SELECT/INSERT; the
migration ledger, views, materialized views and foreign tables get nothing;
sequences get USAGE only. No default privileges are installed, so each
migration must be followed by this call. Returns the tables granted DML.
Source code in src/symfonic/memory/backends/postgres_runtime_roles.py
require_login_retired
async
¶
Administrative observer: is old_login disabled, unreachable and drained?
Point-in-time and named-login only. It cannot see a session that already ran SET ROLE from a former member, privileged operators who may re-enable the login, credentials copied into another login, or other databases' prepared transactions beyond this cluster's view. It changes nothing.
Source code in src/symfonic/memory/backends/postgres_runtime_roles.py
require_split_runtime
async
¶
require_split_runtime(connection: Any, *, owner_login: str, tables: tuple[str, ...], schema: str = 'public', ledger: str = MIGRATION_LEDGER) -> None
Runtime side, read-only: refuse startup unless this login is DML-only.
The connected login must be a direct, unprivileged, membership-free LOGIN
owning nothing (large objects included), able to create nothing, holding no
large object grant and unable to EXECUTE any SECURITY DEFINER function
outside pg_catalog and information_schema. schema and every
relation in it must belong to owner_login; each table carries exactly
the table-level DML grant and no column grant beyond it (the ledger none,
the erase job table SELECT only, its receipts none, the memory erase
generations SELECT/INSERT/UPDATE, the erase log SELECT/INSERT), every tables entry
and memory_nodes resolve on this login's search_path to schema,
views, materialized views and foreign tables carry none, every tables
entry exists, and sequences are USAGE without UPDATE.
Source code in src/symfonic/memory/backends/postgres_runtime_roles.py
revoke_runtime
async
¶
Owner side rollback: withdraw every runtime privilege in schema at once.
It does not re-enable any old login; reopening one is a separate,
explicitly authorised operator act that require_login_retired reports.