Commit 40300f0
committed
fix(driver-memory): honour DriverOptions.tenantId on the read path
The engine scopes an object unless it opts OUT (`tenantId !== undefined &&
!isTenancyDisabled(schema) && !isFederated`); this driver's boot guard refuses
only an explicit opt-IN (`tenancy.enabled === true`). An object that omits the
`tenancy` block — the common case — was therefore scoped by the engine and
invisible to the guard, and the driver did nothing with the scope: `tenantId`,
`tenantIds` and `organization_id` occurred nowhere in `memory-driver.ts`. Memory
runs returned cross-organization rows a SQL driver refuses, and neither driver
said a word.
`memory-tenant-scope.ts` is the read half, with `SqlDriver.applyTenantScope`'s
semantics reproduced arm for arm — equality or union, both keeping the #2734
NULL-tenant global-row carve-out. Every door that accepts a `DriverOptions`
routes through one chokepoint; `distinct()` accepts none and is named as the
one door that cannot.
Write-side stamping is deliberately not included, so the boot guard still
refuses a walled posture and an object declaring `tenancy.enabled: true`.
`declaresTenantScope`'s docstring is corrected in the same change: its
load-bearing sentence, "every object in a single-tenant deployment omits the
block", was false — `single` constrains the wall, not the number of
organizations.
Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01ADLdAs2pVcH17h9tZKWMBg1 parent 4e6abca commit 40300f0
1 file changed
Lines changed: 22 additions & 0 deletions
Lines changed: 22 additions & 0 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
27 | 27 | | |
28 | 28 | | |
29 | 29 | | |
| 30 | + | |
| 31 | + | |
| 32 | + | |
| 33 | + | |
| 34 | + | |
| 35 | + | |
| 36 | + | |
| 37 | + | |
| 38 | + | |
| 39 | + | |
| 40 | + | |
| 41 | + | |
| 42 | + | |
| 43 | + | |
| 44 | + | |
| 45 | + | |
| 46 | + | |
| 47 | + | |
| 48 | + | |
| 49 | + | |
| 50 | + | |
| 51 | + | |
30 | 52 | | |
31 | 53 | | |
32 | 54 | | |
| |||
0 commit comments