ADR-0026: RLS Runtime Safety — Connection-Pool Scope Isolation¶
- Status: accepted
- Date: 2026-06-18
- Deciders: Nicolas Burri
- Extends: ADR-0009; relates to ADR-0011, ADR-0012; review findings RV-09, RV-15
- Refined by: ADR-0027 (the RLS backstop moved onto content tables)
Context¶
Separation (the top quality goal) relies on each request setting
lqms.authorized_scope_ids on a connection drawn from a shared lqms_app pool (ADR-0009).
A session variable persists on the physical connection; if not reset, a pooled
connection can carry a previous request's authorized scopes into the next request — a
classic, severe footgun on the separation critical path (RV-09). Separately, ADR-0009's
"planned hardening" (in-DB scope derivation via a SECURITY DEFINER function) was left
orphaned once ADR-0011/0012 adopted application-side scope resolution (RV-15).
Decision¶
- Scope context is request-bounded.
lqms.authorized_scope_idsis set with transaction scope (SET LOCAL, inside the request's transaction) — or, where a transaction does not wrap the work, explicitly reset when the connection returns to the pool. No connection may carry a prior request's scope set. - The separation test suite (REQ-SEP-007, RISK-001) must include a pooled-connection- reuse case that proves request A's scopes cannot leak into request B over a reused connection.
- Accepted scope-resolution model: application-side resolution (ADR-0011/0012) is the committed approach. ADR-0009's SECURITY DEFINER in-DB derivation is explicitly deferred (not abandoned) as a future hardening — recorded here so the residual-trust posture is a conscious decision rather than a dangling promise.
Consequences¶
- Binding implementation rule for the persistence/data-access layer and the runtime datasource wiring (the RISK-002 work).
- The separation test suite gains a connection-reuse scenario — a strong, automated guard on the highest quality goal.
- ADR-0009's hardening path is now status-clarified (deferred), closing RV-15.
Requirements¶
Adds REQ-SEP-011 (pending requirements baseline v1.3).