Quickback Docs
Neon

Neon Row Level Security

Worker-scoped RLS on Neon — the set_config claim model, generated policies, the soft-delete lane, delegated principals, relationship arms and helper functions.

On Postgres the compiler emits backstop Row Level Security: it fences tenant scope, soft delete and lane admission in SQL, while roles, status, transitions and masking stay with the API. This page covers how the Worker sets claims, the generated policies, and reads through a user-anchored relationship. Start at Neon for configuration.

How Worker-scoped RLS works

Quickback does not send browser or mobile clients directly to Neon, and it does not use Neon Authorize / a JWKS endpoint. Clients authenticate with the Cloudflare Worker; the Worker verifies the Better Auth session or API key, runs the access checks, and then performs the database call as a trusted proxy.

For every feature-table query, the generated database client opens a claims-scoped transaction (an implicit Neon HTTP batch or a Hyperdrive transaction) whose first statement writes the verified caller context into transaction-local Postgres settings:

-- Injected by the Worker as the batch's first statement (is_local = true):
SELECT
  set_config('quickback.service_role',      '',        true),
  set_config('request.jwt.claim.sub',       'usr_123', true),
  set_config('request.jwt.claim.org_id',    'org_abc', true),
  set_config('request.jwt.claim.team_id',   '',        true),
  set_config('quickback.principal.type',       '',     true),
  set_config('quickback.principal.actor_type', '',     true),
  set_config('quickback.principal.actor_id',   '',     true),
  set_config('quickback.principal.session_id', '',     true),
  set_config('quickback.principal.family_id',  '',     true),
  set_config('quickback.principal.claims',     '{}',   true);

On Hyperdrive the values are not bound parameters: each is hex-encoded and decoded in SQL (convert_from(decode('…', 'hex'), 'UTF8')), so the preamble is a single parameterless statement that shares a message with BEGIN and the SQL text can never contain a claim value verbatim.

RLS policies read those settings through Quickback-defined helper functions — there is no external JWT verification and no persisted session state in the database. auth.user_id() is a compiler-generated shim, not a Neon Authorize function:

-- Generated by Quickback (granted to the quickback runtime role):
CREATE OR REPLACE FUNCTION auth.user_id()
RETURNS TEXT AS $$
  SELECT NULLIF(current_setting('request.jwt.claim.sub', true), '')
$$ LANGUAGE SQL STABLE SET search_path = public;

Because the settings are transaction-local (set_config(..., true)), they apply only to the current batch and never leak between requests. If the Worker never stamps a user id, auth.user_id() returns NULL and the restrictive deny_anon policy blocks the query unless a verified delegated principal is present — fail closed. Account requests explicitly clear all principal fields; delegated requests explicitly clear the account/org/team fields.

An API key's organization metadata is only a candidate scope. Before the middleware stamps it into AppContext, the generated Neon membership lookup opens a request-scoped database handle with the verified API-key owner as userId and the candidate organization as orgId, then requires the member row to match both values. A missing or RLS-denied row clears organization and role authority.

Row Level Security

Generated RLS is a backstop, not a second copy of access. Every database call goes through the API, and the API owns roles, status, transitions and masking. RLS exists so that a bug in a custom route, or a handle that escaped its scope, cannot cross a tenant, resurrect a soft-deleted row, or read another owner's row. It is the floor under the application, not a second application.

Who RLS backstops. The request database handle stamps caller claims only for callers the policies can key on: a signed-in account (ctx.userId) and a delegated principal (whose databaseAccess lane is enforced only here). Every other caller — a PUBLIC door, such as a credential-redeeming action — runs on the service lane, and the generated app firewall scopes each of its queries, exactly as on D1. Without that, those callers would read nothing: no policy recognises an anonymous caller.

Quickback lowers your firewall config — and only your firewall config — into policies that read the transaction-local claims described above through auth.user_id(), get_active_org_id(), get_active_team_id(), get_scope() and the get_principal_*() helpers. Each feature table gets exactly three policies, plus a fourth only where a delegated-principal lane is declared:

PolicyKindWhat it does
<table>_deny_anonRESTRICTIVE FOR ALLBlocks any query carrying neither a stamped user id, nor the service marker — nor, on a table with a delegated lane, a verified delegated/scope principal
<table>_service_rolepermissive FOR ALLAdmits Worker-internal contexts — see Background jobs and cross-tenant actions
<table>_scopepermissive FOR ALLThe firewall scope predicate. On a soft-deletable table USING also requires deleted_at IS NULL OR public.in_soft_delete() — see The soft-delete lane; WITH CHECK is the scope predicate alone, so a row can be soft-deleted but never resurrected. Every other isNull arm ({ field: 'projectId', isNull: true } inside an any:, say) is scope and stays in both clauses
<table>_principal_fenceRESTRICTIVE FOR ALLOnly on tables with a databaseAccess lane or access.principals. Caps every permissive policy, so no policy can broaden a request that carries the wrong principal type

The fence is per-lane, not per-table, because on a table no principal can reach it would read get_principal_type() IS NULL — blocking every principal, which is exactly what leaving them out of deny_anon already does. Two policies for one outcome; the compiler emits neither.

Every helper call inside a policy predicate is emitted as (SELECT …). The claims are transaction-local and stamped before the statement, so PostgreSQL hoists the call into an InitPlan and evaluates it once per statement instead of once per scanned row.

firewall: [
  { field: 'organizationId', equals: 'ctx.activeOrgId' },
]
CREATE POLICY "documents_scope"
ON "app"."documents" FOR ALL
TO quickback
USING (
  organization_id = public.get_active_org_id()
  AND (deleted_at IS NULL OR public.in_soft_delete())
)
WITH CHECK (
  organization_id = public.get_active_org_id()
);

The soft-delete lane

deleted_at IS NULL keeps soft-deleted rows out of every caller's reach. It is in the scope policy of every table that carries deleted_at, exactly where the API firewall adds its own isNull(deletedAt) — including a firewall: [...] array that never mentions deletedAt (declare a predicate on deletedAt yourself to take it over). On its own it also blocks the delete that put them there.

PostgreSQL applies a SELECT-applicable policy's USING expression to the new row of an UPDATE, not only the existing one, whenever the statement reads the relation — which any UPDATE … WHERE does. The new row of a soft delete has deleted_at set, so a bare deleted_at IS NULL refuses the statement with 42501, including the generated DELETE route's own write. Moving the filter to a FOR SELECT policy does not help, and neither does dropping RETURNING: the check follows the filter wherever it goes.

So the filter carries a lane. public.in_soft_delete() reads the transaction-local quickback.soft_delete marker, and the generated write chokepoint sets it for exactly the statement whose payload stamps deletedAt — the same condition that stamps the audit columns. It is a one-shot token: the claims preamble carries it into that statement's transaction and clears it, so the next statement of the same request runs without it.

It is the same trust model as the service marker: Worker-set, never derived from request input. And it is narrower — it exempts the soft-delete filter and nothing else. Tenancy, ownership and scope stay ANDed beside it, so a statement inside the window still cannot cross a tenant; WITH CHECK never carries the lane, so it cannot land a row the firewall rejects; and the emitted statement keeps deleted_at IS NULL in its own WHERE, so it cannot resurrect one.

Exception tables (firewall: [{ exception: true }]) keep their permissive <table>_all policy, and SYSTEM tables — idempotency keys, the webhook store, Better Auth rate-limit counters, subscriptions, file metadata — stay service-role only.

Better Auth's own tables carry the same backstop, in its two- or three-policy form: see Better Auth's tables stay vanilla Better Auth.

What is deliberately not in SQL

Roles, status, transitions, masking and per-operation access are not lowered into policies. That is a decision, not a gap:

  • Roles. access.roles names your application's vocabulary. Mirroring it into SQL made every role rename append a security migration, and left two enforcement points that could disagree — with the SQL copy being the one nobody reads. The API is the single gate.
  • Status and transitions. A policy sees one row and no request context, so it cannot express "an archived invoice may only move to restored, by the route that logs the transition". A half-expressed rule in SQL is worse than no rule in SQL.
  • Masking. Masking shapes a response. RLS decides which rows a caller may touch, never which columns come back redacted.
  • Per-operation access. One FOR ALL scope policy is the same fence for every verb. Four near-identical policies only made the tenant predicate harder to read and easier to get subtly wrong in exactly one of them.

The consequence is intentional: at the SQL layer, a caller whose organization role is member can update a same-org row. The route they would have to call still refuses them, and anything reaching the database outside a generated route holds a caller-scoped handle whose tenant is already fenced.

The compiler enforces the shape at compile time. QB-RLS-SCOPE-POLICY requires the three policies (and the fence wherever a delegated lane exists — and only there), requires a tenant/owner/scope predicate in the scope policy's USING clause, and fails the build if any policy body calls has_any_role. Opt out with compiler.securityContracts.rls.requireScopePolicy: false — requireCrudPolicies is the pre-016 name for the same key and is still honoured.

Upgrading an existing database

An existing project gets one appended quickback_rls security migration on its next compile. It runs DROP POLICY IF EXISTS on the retired names before creating the new ones, so the upgrade is append-only: prior migration files keep their bytes and their journal hashes, and a second unchanged compile appends nothing.

Apply it with the setup-owner credential, not quickback_admin. The security migration reissues the helper functions, and PostgreSQL refuses that to a role that does not own them (42501 must be owner of function ...) — the same requirement that already applies to any changed security or bootstrap SQL.

The same migration also drops the five helper functions the generated policies no longer reference — has_any_role, has_org_role, get_user_role, is_owner and is_org_member — after the policy statements that stop referencing them. Membership is proven by the Worker and stamped as the request org, so nothing re-derives it in SQL.

The retired names include the per-verb auth-table policies (users_select, members_insert, …) that older projects carry. They are dropped, so an upgraded database converges on the narrower set rather than keeping a wider policy nobody emits any more.

Column type changes over policies and triggers. Postgres refuses ALTER COLUMN … SET DATA TYPE while a policy or trigger definition references the column (cannot alter type of a column used in a policy definition). Every soft-delete policy reads deleted_at, and sql: triggers pin it through UPDATE OF and WHEN, so a bare type change — the 0.70 timestamp(3) audit-column migration, for one — could not apply to a provisioned database. Each generated SET DATA TYPE is therefore emitted inside a DO block that reads pg_depend, drops the policies and triggers that reference that column, alters it, and recreates them verbatim. Hand-written policies and triggers are carried the same way. A 0.70.0–0.70.2 schema migration that was generated but never applied keeps its bare statements (applied history is never rewritten); regenerate it by deleting that unapplied file and its journal entry, then quickback build again.

Indexes are rebuilt once. The compiler used to infer idx_<table>_<column> indexes in the security migration, alongside the <table>_<column>_idx indexes Drizzle generates from the schema. Drizzle now owns the whole default set, so the schema migration creates the drizzle-managed index and the security migration that follows it in the journal drops the compiler-owned copy — the two overlap for the length of one db:migrate run and nothing is ever left unindexed. Only idx_* names are dropped; a drizzle-managed index is never touched. See the default index set.

Delegated principal RLS

Delegated principals require Cloudflare + Postgres over Hyperdrive: Neon with connectionMode: "hyperdrive", or PlanetScale Postgres, which emits the same lookup policies and lanes. Their proof hook returns only a digest and receives no database handle. Quickback then runs one lookup under an internal lookup-only principal whose RLS policy admits only the configured table row matching credentialDigest, plus any configured active status condition. The generated unique lookup index is content-addressed: a changed table, digest column, or definition drops the prior logical index and creates the exact replacement. Names are hash-suffixed to avoid collisions and remain inside PostgreSQL's 63-byte identifier limit.

After the lookup, the normal request database handle carries the resolved principal type, actor, optional session/family, and JSON claims in the same transaction-local preamble shown above. RLS reads them with:

FunctionPurpose
get_principal_type()Exact configured type such as event_delegate
get_principal_actor_id()Stable delegated actor id
get_principal_session_id()Optional session id
get_principal_family_id()Optional session-family id
get_principal_claim(name)One configured string claim such as eventId or personId

Generated request types are a closed union of the configured principal names, literal actor types, exact session shape, and configured claim keys. The Neon database context uses the same resolved union plus separate compiler-internal __credential_lookup__:<type> variants. Lookup-only authority therefore cannot appear in an action AppContext, and a delegated action context cannot carry account/org/team/membership fields.

resource.databaseAccess opens a delegated-principal lane at the database: RLS only, no generic routes and no OpenAPI operations. It exists because a delegated principal has no account identity — no userId, no active organization, no membership roles — so the table's ordinary firewall predicate can never match for it. The lane is the row rule that can: the principal's own verified claims, read through get_principal_claim().

// The account lane is the FIREWALL. The delegate lane is databaseAccess.
firewall: [
  { field: "organizationId", equals: "ctx.activeOrgId" },
],
databaseAccess: {
  select: {
    principals: ["event_delegate"],
    record: {
      eventId: { equals: "$ctx.principal.claims.eventId" },
      personId: { equals: "$ctx.principal.claims.personId" },
    },
  },
}

That emits exactly one permissive policy on the table:

CREATE POLICY "attendance_evidence_principal_scope"
ON "app"."attendance_evidence" FOR SELECT TO quickback
USING (public.get_principal_type() = 'event_delegate'
   AND "event_id" = public.get_principal_claim('eventId')
   AND "person_id" = public.get_principal_claim('personId'));

Several principal types on one table are several OR arms of that same policy, never several policies. Postgres ANDs the record comparisons inside each arm.

The policy's command is the lane's declared reach: FOR SELECT with no WITH CHECK when only databaseAccess.select is declared, FOR ALL with the same predicate as WITH CHECK as soon as any of insert / update / delete is. Whether a delegate lane may write is a property of the lane, declared once by the author, so the database enforces it as the policy's command; WHICH verb a caller may reach is still the API's decision.

The lane lowers principals + record and nothing else. Two shapes are compile errors, with the same message: roles anywhere (authored roles are enforced by the API and never reach SQL, so a role arm here promised an authorization the database did not enforce), and a record equality with no principals gate (that is an owner/tenant rule, and those belong in firewall, the one pillar that lowers to SQL). Every authorization path must still carry at least one SQL-lowerable record equality; an unbounded or arm or a principal-only leaf fails the compile.

The policy is permissive, and PostgreSQL ORs permissive policies together, so databaseAccess opens a lane beside <table>_scope rather than narrowing it — that is the point (the delegated caller has no active organization, so the tenant predicate can never match), but it means a databaseAccess arm is never a place to write a restriction. A row that satisfies the arm is reachable even when the table firewall would not have matched it, and even when it is soft-deleted. Write the restriction in firewall; the restrictive <table>_deny_anon and, where a lane is declared, <table>_principal_fence are the only arms that cap every lane. The fence also means a table admits a principal type only where its access (or its lane) names that type — a ctx.principal.claims.* firewall arm on a table whose access names no principal is unreachable.

Upgrading. The four per-operation <table>_database_<op> policies are retired. One appended quickback_rls migration drops them on every table and creates the single <table>_principal_scope where a lane is declared — append-only, like every other security migration, so no applied file changes.

Firewall patterns

Every pattern is the same one FOR ALL scope policy with a different predicate — no per-operation variants, no role arms.

Organization-scoped:

CREATE POLICY "projects_scope" ON "app"."projects" FOR ALL TO quickback
USING (organization_id = public.get_active_org_id())
WITH CHECK (organization_id = public.get_active_org_id());

User-scoped (owner_id, the auto-firewalled ownership column):

CREATE POLICY "preferences_scope" ON "app"."preferences" FOR ALL TO quickback
USING (owner_id = auth.user_id())
WITH CHECK (owner_id = auth.user_id());

Relationship-scoped ({ field: 'projectId', via: 'projectMemberOf' }) — see Relationship arms in SQL:

CREATE POLICY "tasks_scope" ON "app"."tasks" FOR ALL TO quickback
USING (organization_id = public.get_active_org_id()
  AND project_id IN (SELECT r.project_id FROM public.qb_rel_project_member_of() r))
WITH CHECK (organization_id = public.get_active_org_id()
  AND project_id IN (SELECT r.project_id FROM public.qb_rel_project_member_of() r));

Exception tables (firewall: [{ exception: true }]) — no scope predicate, so the restrictive deny-anon policy is the only fence left:

CREATE POLICY "categories_all" ON "app"."categories" FOR ALL TO quickback
USING (true) WITH CHECK (true);

Relationship arms in SQL

Every relationship lookup is enforced by the database, and the generated API reads through the same place. Each declared relationship gets one helper, emitted in the RLS migration ahead of the policies that call it:

CREATE OR REPLACE FUNCTION public.qb_rel_project_member_of()
RETURNS SETOF "app"."project_members"
LANGUAGE sql STABLE SECURITY DEFINER SET search_path = ''
AS $$
  SELECT a.*
  FROM "app"."project_members" a
  WHERE a."user_id" = auth.user_id()
    AND a."deleted_at" IS NULL
$$;
ALTER FUNCTION public.qb_rel_project_member_of() OWNER TO quickback_owner;
REVOKE ALL ON FUNCTION public.qb_rel_project_member_of() FROM PUBLIC;
GRANT EXECUTE ON FUNCTION public.qb_rel_project_member_of() TO quickback;

The scope policy calls it as "project_id" IN (SELECT r."project_id" FROM public.qb_rel_project_member_of() r), and so does the generated API: a firewall via: arm, a relationship-role access check, the action resolver's match row, the namespace gate's relationship probe and the ws-ticket probe all read the caller's relationship rows from the helper, never from the relationship table under its own policy.

  • Same lookup as D1. The body is the relationship subquery the API runs on D1: the subject column against the caller's claim, the where: literals (SQL-quoted), and the related table's soft-delete filter — the API's skipTenantScopes body. Multi-hop (hops) relationships join the same chain and return the first hop's rows.
  • Why SECURITY DEFINER. Under the relationship table's own policy the lookup would recurse for a relationship that reads the table it protects (projectMemberOf on project_members), and the table's tenant scope would zero a caller with no active org — the case the API skips on purpose. The helper runs as quickback_owner, which reads the related table through one <table>_quickback_owner_read policy (FOR SELECT TO quickback_owner USING (true)). Feature tables FORCE ROW LEVEL SECURITY, so the owner needs it; it grants nothing new — an owner can always lift FORCE on its own table — and the runtime role quickback is not a member of quickback_owner.
  • Locked down. search_path = '' and fully-qualified names; EXECUTE is revoked from PUBLIC and granted to quickback only. The caller comes from the transaction's claims, so a lookup on the service handle (no caller) returns nothing.
  • Evaluated once per statement. The helper takes no arguments, so col IN (SELECT … FROM helper() r) is an uncorrelated subquery — one hashed subplan per statement, the same InitPlan discipline as the claim helpers. A per-row helper(row.col) call could never be inlined.
  • Returns the table's own rows. One helper serves every projection a lookup needs (the resource column, the tenant columns the action resolver stamps, scope sub-keys), and CREATE OR REPLACE stays valid as the table's columns change. A helper whose relationship now returns a different table is dropped first — with the generated policies that call it, which the same migration re-creates.
  • Tenant binding. Beside an org arm in an any: group the arm becomes (project_id IN (SELECT …) AND (organization_id = <active org> OR <no active org>)) — exactly where the API applies the same binding.
  • Permissions. A { permission } arm expands as the API expands it; arrow hops become qb_arrow_… helpers (recursive arrows are a maxDepth-bounded closure that re-checks the tenant on every row; a relation-backed arrow keeps the hop's rows whose FK is in the relationship's qb_rel_… set), called by the API too.
  • Still API-only. Literal status filters (a conjunct would refuse status-changing updates, because PostgreSQL checks an UPDATE's new row against the read policy) and claims the Worker never writes into the transaction — ctx.scope.<kind>.<subKey>, area anchors such as ctx.event.id, and relationships whose subject binds one. These lower to true in the policy, and the API keeps the table query for such a relationship.

Helpers no compile references any more are dropped at the end of the migration.

Helper functions

FunctionPurpose
auth.user_id()Reads the verified user id from the transaction-local request.jwt.claim.sub setting
get_active_org_id()Reads the request-scoped org from the transaction-local request.jwt.claim.org_id setting
get_active_team_id()Reads the request-scoped team from request.jwt.claim.team_id (teams mode)
is_admin()Checks the auth.admins table (admin mode). No scope policy calls it.

There is no role-lookup helper and no membership helper. Roles are the API's gate, not SQL's: QB-RLS-SCOPE-POLICY fails the build if any policy body calls has_any_role. Membership is Better Auth's gate: the Worker proves it once and stamps the active organization, and policies compare against that stamp.

is_admin() is no part of that gate either. Enabling the admin plugin does not widen any scope policy: "admin" is a role, and a scope policy is the firewall predicate, full stop. An admin's cross-tenant read goes through the API on the service lane — an unsafe action stamps quickback.service_role, which <table>_service_role admits — not by SQL re-deriving admin from auth.admins. Older databases carry the previous (public.is_admin() OR (…)) form until the new security migration replaces those policies; it does, in the same append-only pass.

All helpers are TEXT-typed to match Better Auth's prefixed ids (org_abc123). The request org/team scope is passed by the Worker per transaction, not read from a persisted mirror. There is no compiler-owned user_sessions table and no session hook that syncs the active organization into the database — switching to "no org" simply means the Worker stamps an empty request.jwt.claim.org_id, and SQL-side access is revoked immediately. Fail closed.

The only compiler-owned support tables the RLS layer reads live in src/db/rls-support.schema.ts: a profiles table (populated by the sync_profile_display_name() trigger and protected by profiles_deny_anon plus a self-scoped, read-only profiles_scope) and, when admin/sysadmin helpers are emitted, an admins table (read by is_admin() / is_sysadmin()). Better Auth's own sessions table may still carry an active_organization_id, but Quickback RLS never reads it.

RLS coverage includes Better Auth's own tables — including those the compiler force-enables (organization, admin, apikeys; plus the OAuth/agent table families when those surfaces are on, which are service-only). Database-backed Better Auth rate-limit counters also receive both ENABLE and FORCE ROW LEVEL SECURITY. Only the internal auth service context can read or change those counters; ordinary caller claims grant no access. See Better Auth's tables stay vanilla Better Auth for the exact policy set per table. Cloudflare uses database counters by default. Explicit memory storage or inactive rate limiting does not generate policies for a missing counter table.

For existing databases, recompile and apply the newly appended security migration using the setup-owner credential, as required for changed security/bootstrap SQL, to protect existing counters. Applied migration files stay unchanged and existing counter rows are preserved.

Reads through a user-anchored relationship

Some resources are readable not because you own them or belong to their org, but because you are reachable from them through a chain of tables anchored on the caller's user id. A conference attendee, for example, can read their own registrations even though they are not an org member — the grant travels person_account_links.user_id = ctx.userId → people → event_people → registrations.

Declare the chain once as an authz.relationships entry using the hops form (each hop names the joined table, the column it is joined on, and the prev column on the previous table that points at it). The terminal hop's table is the anchor — the table carrying the caller's user id:

// quickback.config.ts
authz: {
  relationships: {
    attendeeReachable: {
      from: 'person_account_links',            // the anchor table
      subject: { column: 'userId', equals: 'ctx.userId' },
      resource: { column: 'eventPersonId' },   // the column on the resource this constrains
      hops: [
        { table: 'event_people', on: 'id', prev: 'eventPersonId' },
        { table: 'people',       on: 'id', prev: 'personId' },
        { table: 'person_account_links', on: 'personId', prev: 'id' },
      ],
    },
  },
},

A resource opts into the grant by referencing the relationship from its firewall — typically as one arm of an any: group so org members keep their own path in:

// features/registrations/registrations.ts
firewall: [
  {
    any: [
      { field: 'organizationId', equals: 'ctx.activeOrgId' }, // org-member grant
      { field: 'eventPersonId',  via: 'attendeeReachable' },  // reachable-attendee grant
    ],
  },
],

The anchor must be non-forgeable (fail closed on both targets)

The reachability chain terminates in anchor.user_id = ctx.userId, so whoever can write an anchor row can mint themselves reachability to a victim's data. Quickback therefore refuses to compile a user-anchored multi-hop relationship unless the anchor table is:

  • caller-read-own on the subject column — its firewall scopes reads to ctx.userId (e.g. firewall: [{ field: 'userId', equals: 'ctx.userId' }]), and
  • service-role-write-only — it exposes no caller-reachable create / update / delete endpoint, so the link can only be created by Worker-internal code.

This check is target-independent: it fires identically on Neon and D1, because the reachability join runs in the app layer on both. A forgeable anchor is a compile error everywhere, not a Neon-only concern.

How the read is served

Reads keep the caller-claims handle and the full RLS backstop, on Neon as everywhere else. The reachability WHERE (buildFirewallConditions(...)) and the resource's scope policy both call the relationship's helper, which walks the hop chain without the intermediate tables' tenant policies — so an attendee with no active org gets exactly their reachable rows, from the API and from the database alike.

Earlier releases routed these reads through the service-role handle (createServiceDb) instead, because the multi-hop join read the intermediate tables under their own tenant scopes and came back empty. That bypassed RLS for the whole read; the routing is gone.

The same config compiles identically on D1: the read handlers keep c.get('db'), and the app-layer reachability WHERE runs the join directly.

On this page