Skip to content

Commit e21172f

Browse files
committed
docs(runtime): retire present-tense prose that the driver still reads organization-less rows
ADR-0131 D8 retired the driver's OR organization_id IS NULL arm, but the comments of fifteen runtime files (and one runtime warning) still described it as the live tenant predicate. Restate each: the tenant term is the equality (or IN under group) alone, an organization-less row on a tenant table is reached by no tenant-scoped read, and where code was written against the old arm the text now says so. Claude-Session: https://claude.ai/code/session_017ae4eMXWeERGrG6heTbwBX Co-authored-by: Claude <noreply@anthropic.com>
1 parent 584b202 commit e21172f

15 files changed

Lines changed: 115 additions & 87 deletions

File tree

‎packages/objectql/src/tenancy/platform-object-tenancy.ts‎

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -239,9 +239,9 @@ export const PLATFORM_OBJECT_TENANCY: Readonly<Record<string, PlatformObjectTena
239239
"carries the granting rule's organization, a direct grant the shared record's. The maintainer ordered " +
240240
'the rows written before it backfilled from the record they reference on 2026-09-02 ' +
241241
'(`backfill-sys-record-share-organizations.ts`). A grant table that cannot say which organization ' +
242-
'a grant belongs to is a defect, not a design: under a wall, a tenant-scoped read would AND ' +
243-
"plugin-security's strict `organization_id = :tenant` over the driver's NULL-tolerant arm and every " +
244-
'organization-less grant would silently disappear.',
242+
'a grant belongs to is a defect, not a design: under a wall, a tenant-scoped read compiles ' +
243+
'`organization_id = :tenant` at both layers, and every organization-less grant would silently ' +
244+
'disappear.',
245245
},
246246
};
247247

‎packages/plugins/plugin-security/src/delegated-admin-gate.ts‎

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1296,9 +1296,9 @@ export class DelegatedAdminGate {
12961296
* `{ isSystem: true }`;
12971297
* 2. the candidates that come back are reduced to the caller's OWN row by
12981298
* {@link resolveOwnOrganizationRow}. That arm is load-bearing on its own:
1299-
* the driver's compatibility arm deliberately also returns
1300-
* organization-less rows, and a driver with no tenant scoping at all
1301-
* returns every organization's. Under a walled posture an
1299+
* a driver with no native tenant scoping returns every organization's
1300+
* rows, organization-less ones included. (The SQL driver's NULL arm,
1301+
* which also returned organization-less rows, is retired — ADR-0131 D8.) Under a walled posture an
13021302
* organization-less business unit is invalid state
13031303
* (`organization-scope.ts`), so neither class may answer a
13041304
* delegation boundary.

‎packages/plugins/plugin-security/src/organization-scope.ts‎

Lines changed: 22 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -17,9 +17,9 @@
1717
*
1818
* Under a walled posture that row is invalid state. It was measured to be
1919
* unreadable by anyone: plugin-security's Layer 0 composes a STRICT
20-
* `organization_id = :tenant` and the middleware ANDs it over the driver's
21-
* `(organization_id = :tenant OR organization_id IS NULL)`, and the conjunction
22-
* of the two is the strict equality alone — so on a walled deployment every
20+
* `organization_id = :tenant` and the middleware ANDed it over the driver's
21+
* v17 predicate `(organization_id = :tenant OR organization_id IS NULL)`, and
22+
* the conjunction of the two is the strict equality alone — so on a walled deployment every
2323
* principal, at every rung, listed ZERO positions, permission sets and sharing
2424
* rules while the tables held rows.
2525
*
@@ -32,11 +32,14 @@
3232
*
3333
* An organization-less row is INVALID STATE under a walled posture — refuse or
3434
* warn loudly, never treat it as a platform-wide default. The older reading, in
35-
* which a NULL organization marked a platform row visible to every tenant,
36-
* survives only as DRIVER-LEVEL COMPATIBILITY BEHAVIOUR: `applyTenantScope`
37-
* still emits the `OR organization_id IS NULL` arm, and this module depends on
38-
* that arm being there — it is precisely how a per-organization pass can still
39-
* SEE a pre-fix organization-less row and therefore say something about it.
35+
* which a NULL organization marked a platform row visible to every tenant, is
36+
* retired at every layer: ADR-0131 D8 removed the driver's
37+
* `OR organization_id IS NULL` arm from `applyTenantScope`, and
38+
* `check-tenant-chokepoint` refuses it. A per-organization pass therefore no
39+
* longer SEES an organization-less row at all — the tenant predicate is
40+
* `organization_id = :tenant` and nothing else — and the 18.x upgrade ceremony
41+
* (ADR-0131 D10) attributes or retires such rows before a walled deployment
42+
* boots.
4043
*
4144
* ## What replaces a reap
4245
*
@@ -69,10 +72,11 @@
6972
* So the pass said so instead. Its guard (retired with the seeder) named the
7073
* rows and named the remedy, and — this is the load-bearing half — the pass
7174
* still CREATES the organization's own copy. The failure shape it exists to
72-
* prevent is the silent no-op: a tenant-threaded pass sees the pre-fix
73-
* organization-less row through the driver's compatibility arm, reads the name
74-
* as already represented, takes the update branch and creates nothing, leaving
75-
* the deployment exactly as broken as before while reporting success.
75+
* prevent is the silent no-op: a tenant-threaded pass that saw the pre-fix
76+
* organization-less row through the driver's v17 NULL arm (retired by ADR-0131
77+
* D8) read the name as already represented, took the update branch and created
78+
* nothing, leaving the deployment exactly as broken as before while reporting
79+
* success.
7680
* {@link resolveOwnOrganizationRow} is the one read that distinguishes "this
7781
* organization has its row" from "somebody's organization-less row is visible
7882
* here", and every seeder in this catalog routes through it.
@@ -111,13 +115,15 @@ export function rowOrganizationId(row: any): string | null {
111115
* Resolve THIS organization's own row for a name, out of what a tenant-scoped
112116
* read returned.
113117
*
114-
* A scoped read passes through `applyTenantScope`, whose compatibility arm
115-
* returns the caller's rows AND any organization-less ones. Those two are not
116-
* interchangeable and the seeders must never treat them as such:
118+
* A scoped read passes through `applyTenantScope`, which since ADR-0131 D8
119+
* returns the caller's rows only — the driver's NULL arm is retired. A row
120+
* set can still mix the two classes when it comes from a driver with no
121+
* native tenant scoping or from an unscoped read, and they are not
122+
* interchangeable; the seeders must never treat them as such:
117123
*
118124
* - a row stamped with `organizationId` is this organization's — update it;
119125
* - an organization-less row is a PRE-FIX residue that merely happens to be
120-
* visible here. Reading it as "already seeded" is the silent no-op this
126+
* in the row set. Reading it as "already seeded" is the silent no-op this
121127
* catalog exists to prevent, so it is reported separately and never returned
122128
* as the organization's own row.
123129
*

‎packages/plugins/plugin-sharing/src/backfill-sys-record-share-organizations.ts‎

Lines changed: 11 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -13,13 +13,17 @@
1313
* grant the shared record's. It wrote nothing to existing rows, and on a WALLED
1414
* deployment that asymmetry is the cliff that commit pins:
1515
*
16-
* - the SQL driver's own tenant predicate is NULL-TOLERANT —
16+
* - the SQL driver's own tenant predicate was then NULL-TOLERANT —
1717
* `(organization_id = :tenantId OR organization_id IS NULL)` — so an
1818
* unstamped grant stayed readable by every bare-context reader;
1919
* - but Layer 0 (`plugin-security`'s `computeTenantLayer0Filter`) AND-composes
2020
* a STRICT `organization_id = <active org>` above it, and the conjunction is
2121
* the strict equality alone.
2222
*
23+
* (ADR-0131 D8 has since retired the driver's NULL arm: both layers now
24+
* compile the equality alone, so an unstamped grant is unreachable by every
25+
* tenant-scoped read.)
26+
*
2327
* ⇒ the day anything reads this table under a tenant context, every
2428
* organization-less grant becomes invisible — not refused, simply "this person
2529
* was never granted access". Forward-only stamping would split the table in
@@ -591,9 +595,12 @@ function finish(
591595
*
592596
* The derived organization is threaded as `tenantId` on the write context too,
593597
* beside the elevation: the shape #8844 prescribes for a system write and the
594-
* one the repaired writer uses. On this verb the driver's scope keeps the NULL
595-
* row in reach (`organization_id = ? OR IS NULL`, #2734), so the write lands
596-
* exactly on the row the plan named.
598+
* one the repaired writer uses. ⚠️ That shape predates ADR-0131 D8: it relied
599+
* on the driver's v17 scope `organization_id = ? OR IS NULL` keeping the NULL
600+
* row in reach. D8 retired that arm, so under the SQL driver a write threaded
601+
* with `tenantId` no longer reaches an organization-less row. No runtime path
602+
* calls this pass; the 18.x upgrade ceremony's attribution fate (ADR-0131
603+
* D10) is what stamps these rows now.
597604
*
598605
* A row whose write throws is RECORDED and the sweep continues: a driver
599606
* rejecting one row must not cost the other N-1 their repair, and a half-done

‎packages/plugins/plugin-webhooks/src/auto-enqueuer.ts‎

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -136,7 +136,8 @@ interface CachedSubscription {
136136
* (`EnqueueHttpInput.organizationId`), which is what makes the
137137
* cross-organization wall on `redeliver()` (#10740) actually exclude other
138138
* tenants' rows: a row enqueued without it lands `organization_id = NULL`,
139-
* the driver's global-row arm, visible to every organization. There is no
139+
* a row of no organization that no tenant-scoped read reaches (ADR-0131
140+
* D8 retired the driver's NULL arm). There is no
140141
* request context to read here — the enqueuer runs fire-and-forget off the
141142
* write path — so the subscription row is the one honest source. Absent
142143
* when the row itself carries no organization (a `single`-posture install):
@@ -1175,7 +1176,7 @@ export class AutoEnqueuer {
11751176
// organization — the one honest tenant in scope on this
11761177
// fire-and-forget path (no request context exists here).
11771178
// Absent for an org-less subscription; the row then lands
1178-
// NULL, the global-row shape. A deployment-wide declared
1179+
// NULL, a row of no organization. A deployment-wide declared
11791180
// webhook takes the event's organization instead.
11801181
organizationId: sub.deploymentWide ? organization.organizationId : sub.organizationId,
11811182
// [#3946] Envelope keys are written LAST so the event payload

‎packages/runtime/src/domains/packages.ts‎

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2690,8 +2690,9 @@ _context: HttpProtocolContext,
26902690
// Read the just-published seed body. The protocol decides the scope,
26912691
// not this call site: [ADR-0131 D6] every metadata read is
26922692
// environment → code, so this read is env-wide by construction:
2693-
// `organization_id IS NULL`, the partition a workspace seed is stored
2694-
// in and the only one cold boot hydrates.
2693+
// `sys_metadata` carries no organization column (ADR-0131 D6/D7), so
2694+
// the environment's rows are the only partition there is — the one a
2695+
// workspace seed is stored in and cold boot hydrates.
26952696
//
26962697
// [commit 8744de9e9] This used to be a two-attempt org-then-env ladder, written
26972698
// when resolving the wrong scope here is what silently produced "0

‎packages/services/service-automation/src/builtin/http-nodes.ts‎

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -260,9 +260,9 @@ export function registerHttpNodes(engine: AutomationEngine, ctx: PluginContext):
260260
// organization, and a wrong value is worse than a null (a
261261
// null is visibly missing; a wrong one is silently
262262
// authoritative). Without it the sys_http_delivery row
263-
// lands `organization_id = NULL` — the driver's global-row
264-
// arm — visible to and replayable by EVERY organization
265-
// through the redeliver() door (#10740).
263+
// lands `organization_id = NULL` — a row of no
264+
// organization, which no tenant-scoped read or redeliver()
265+
// reaches (ADR-0131 D8 retired the driver's NULL arm).
266266
const organizationId =
267267
typeof context.tenantId === 'string' && context.tenantId !== ''
268268
? context.tenantId
@@ -277,8 +277,8 @@ export function registerHttpNodes(engine: AutomationEngine, ctx: PluginContext):
277277
// id; see check:doc-authoring.)
278278
ctx.logger.warn(
279279
`[http] node '${node.id}': no organization in scope for this durable callout — its ` +
280-
`sys_http_delivery row will carry organization_id = NULL, which is a global row ` +
281-
`every organization's redeliver door can reach on a walled deployment. ` +
280+
`sys_http_delivery row will carry organization_id = NULL, a row of no organization ` +
281+
`that no organization's redeliver door can reach on a walled deployment. ` +
282282
`On a multi-organization install the triggering context lost its tenant: give the ` +
283283
`flow's trigger an acting organization (AutomationContext.tenantId). On a ` +
284284
`single-organization install this is expected and can be ignored.`,

‎packages/services/service-automation/src/runtime-identity.ts‎

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -293,11 +293,11 @@ export function resolveRunDataContext(context: AutomationContext | undefined): R
293293
// sequences org-scoped. Without it, every row a user-triggered system
294294
// sweep created was born org-NULL — outside the org partition, where
295295
// unique indexes don't bite and org-scoped queries don't look. Reads /
296-
// updates / deletes org-scope to `(org = trigger-org OR org IS NULL)` at
297-
// the driver — the same posture the action-body seam ships for its
298-
// `{ ...caller, isSystem: true }` envelope (the hotcrm#548-family fix):
299-
// the tenant wall survives elevation for an org-triggered run, while
300-
// org-NULL (pre-fix / global) rows stay reachable via the OR-NULL arm.
296+
// updates / deletes org-scope to `org = trigger-org` at the driver
297+
// (ADR-0131 D8 — no NULL arm) — the same posture the action-body seam
298+
// ships for its `{ ...caller, isSystem: true }` envelope (the
299+
// hotcrm#548-family fix): the tenant wall survives elevation for an
300+
// org-triggered run.
301301
// A run that must genuinely cross orgs is a user-less one (a schedule
302302
// carries no org, nothing narrows) or sets explicit fields.
303303
...(context.tenantId ? { tenantId: context.tenantId } : {}),

‎packages/services/service-messaging/src/http-outbox.ts‎

Lines changed: 9 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -109,7 +109,8 @@ export interface HttpDelivery {
109109
* [#13546] Organization this delivery row belongs to — the read-back of
110110
* the row's kernel-provisioned `organization_id` tenant column, which is
111111
* the column the cross-organization wall on {@link IHttpOutbox.redeliver}
112-
* scopes by (#10740). Absent for a global row (`organization_id = NULL`).
112+
* scopes by (#10740). Absent for a row of no organization
113+
* (`organization_id = NULL`).
113114
* Mirrors `NotificationDeliveryRecord.organizationId` on the sibling
114115
* notification outbox.
115116
*/
@@ -173,18 +174,20 @@ export interface EnqueueHttpInput {
173174
* [#13546] Organization this delivery belongs to. Lands on the row's
174175
* kernel-provisioned `organization_id` tenant column — the column the
175176
* cross-organization wall on {@link IHttpOutbox.redeliver} scopes by
176-
* (#10740). The driver's tenant term is
177-
* `(organization_id = :tenantId OR organization_id IS NULL)`, so a row
178-
* enqueued WITHOUT one lands in the deliberate global-row arm: visible
179-
* to — and replayable by — every organization on a walled deployment.
177+
* (#10740). The driver's tenant term is `organization_id = :tenantId`
178+
* (ADR-0131 D8 — no NULL arm), so a row enqueued WITHOUT one is reached
179+
* by no tenant-scoped read or redeliver on a walled deployment: an
180+
* organization-less row on a tenant table is invalid state there
181+
* (ADR-0131 D1).
180182
* Producers MUST thread the organization they are acting for whenever
181183
* they have one: the flow `http` node passes its run's acting tenant
182184
* (`AutomationContext.tenantId`, the same source as the `notify` node's
183185
* #11303 repair), the webhook auto-enqueuer its subscription's own
184186
* organization (`sys_webhook.organization_id`). Threaded, never
185187
* fabricated: a producer with genuinely no organization — a
186188
* `single`-posture deployment, a stack before its first organization —
187-
* leaves it absent, and the row lands NULL, the honest global-row shape.
189+
* leaves it absent, and the row lands NULL — honest under `single`, where
190+
* there is no wall and no organization for it to belong to.
188191
*
189192
* Deliberately OPTIONAL, mirroring `EnqueueDeliveryInput.organizationId`
190193
* — the sibling notification outbox's identical repair — so the two

‎packages/services/service-messaging/src/memory-http-outbox.ts‎

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -203,14 +203,16 @@ export class MemoryHttpOutbox implements IHttpOutbox {
203203
* owes the predicate here") — and `insert()` now stamps
204204
* {@link HttpDelivery.organizationId}, so the debt is due.
205205
*
206-
* The predicate mirrors the SQL driver's tenant term
206+
* The predicate was written to mirror the SQL driver's v17 tenant term
207207
* `(organization_id = :tenantId OR organization_id IS NULL)`, all three
208208
* arms deliberately:
209209
* - a row in ANOTHER organization is INVISIBLE (`RESOURCE_NOT_FOUND`),
210210
* never forbidden — the same non-oracle refusal the contract rules;
211-
* - a row with NO organization is a global row every tenant may reach
212-
* (the driver's deliberate fail-open arm — hiding platform rows from
213-
* every tenant is a different defect);
211+
* - a row with NO organization is reachable by every tenant here. ⚠️ The
212+
* SQL driver no longer does this: ADR-0131 D8 retired its NULL arm, so
213+
* there the term is `organization_id = :tenantId` alone and an
214+
* organization-less row is reached by no tenant. This in-memory store
215+
* still admits it;
214216
* - a caller with NO tenant (`tenantId: undefined`) stays unscoped,
215217
* which is the honest degraded shape {@link RedeliverOptions} rules
216218
* for genuinely tenant-less deployments.

0 commit comments

Comments
 (0)