Skip to content

Commit 917f024

Browse files
fix(plugin-security)!: an external object that states no organization scope reads as empty for every caller, the platform owner included (#30146)
Clause-②: no (narrowing) — under the `isolated` and `group` postures, an external object registered after the boot that states no organization scope reads as empty for every caller, the declared platform owner included; nothing is widened, and the `single` posture is unchanged. Metadata-protocol: none Skills-docs: none — the published texts already state this rule for every caller, and this diff changes none of them: the ADR-0087 D3 entry `external-object-organization-scope-declared` ("every read is denied at Layer 0"), and the once-warning in `external-organization-scope.ts`. The ADR-0015 §10 amendment that states it is in #29866 (Tier H, still open). ## 维护者速读 - **改了什么**:`isolated` / `group` 姿态下,启动后才注册、且未声明组织范围的外部对象,对每个调用者读取都为空,平台所有者也不例外;平台所有者在其它对象上跨组织墙读取的行为不变,成员与 `single` 姿态不变。 - **为什么改**:安全频道裁决(2026-11-04,选项 A):未声明组织范围的外部对象是配置缺陷,这一拒绝对已验证的平台所有者同样成立;`main` 上已有的文案(D3 条目、一次性告警)本就这样写;ADR-0015 §10 的修订在 #29866(Tier H,未合并)。 - **风险与回滚**:风险低,只在一种启动时已按名拒绝的配置上收窄一个主体的读取,不放宽任何东西;回滚即撤销本 PR(一处条件)。 - **先看**:① `packages/plugins/plugin-security/src/security-plugin-rls-filter.ts` 跨墙分支前新增的条件 `deniedForUndeclaredExternalScope`;② `packages/plugins/plugin-security/src/platform-owner-wall-bypass.test.ts` 新增的顶层 describe;③ `packages/runtime/src/plugin-driver-external-object.spike.test.ts` 的 (h5c)。 - **两分钟验证**:`pnpm --filter @objectstack/plugin-security exec vitest run src/platform-owner-wall-bypass.test.ts`,预期 26 个用例全部通过。 - **需要你做的**:无,席位落地。 ## What changes - **The rule (ADR-0015 §10 as amended).** Under a walled posture, the Layer 0 `deny` an external object earns by stating no organization scope judges the object's configuration, not the reader's organization, so it stands for every caller, the verified platform owner included. In `computeLayeredRlsFilter` the verified platform owner's read crossing (the `OS_PLATFORM_OWNER_EMAIL` read door) now stands down on exactly that verdict, and the owner probe is not consulted there. The recorded verdict stays `deny`. - **Unchanged.** The owner's reads still cross the `isolated` equality, the `group` union and the org-less deny, on local objects and on an external object that declares its own `organization_id`. Writes stay walled for everyone. Members and the `single` posture are unchanged. No type, verdict ladder or published export moves. - **Docs in code.** The owner-crossing module's header names the one verdict the read crossing does not lift. - **Changeset.** One `patch` changeset on `@objectstack/plugin-security`, titled `fix(plugin-security)!:`, with a BREAKING section (the rule, what is unchanged, who moves and the fix) and the ADR-0087 disposition `not-required (already-registered external-object-organization-scope-declared)`: the existing entry already prescribes the operator's remedy. ## Why Security-channel ruling of 2026-11-04 (option A): the configuration-defect deny on an external object that states no organization scope stands for the verified platform owner too. The texts already on `main` say so: the D3 entry's "every read is denied at Layer 0", and the once-warning naming "denies every read and write". The ADR-0015 §10 amendment lands separately in #29866. ### The declarations, justified - `Clause-②: no (narrowing)` and the `!`. Measured against the published release, `@objectstack/plugin-security@18.3.0` (npm `latest`): its `dist/index.js` carries no undeclared-external-scope verdict (0 hits for `externalOrganizationScopeUndeclared`, against 1 hit for the owner crossing's audit event name as the positive control in the same file). So this diff narrows one principal's reads relative to the published release, on a configuration the boot already refuses by name when the stack declares it. Nothing is widened. It is a runtime security narrowing, not an accept-set widening, so `no`. - `Metadata-protocol: none`. Nothing an author can write changes; the three declarations are the ones `main` already accepts. The level follows the kind: `patch`. ## Tests - **The owner crossing's shared unit harness**, a new top-level describe beside the crossing's existing pins (the shared harness's `boot` gains an optional `schema`): `[ADR-0015 §10] an external object that states no organization scope reads as empty for every caller, the platform owner included`, 7 cases. - `isolated`: the verified owner reads the deny sentinel (by identity), the recorded verdict is `deny`, no crossing is logged, and no `sys_user` row is read. - `group`: the same. - An org-less verified owner reads the deny sentinel on it as well. - CONTROL: the owner still crosses the wall on an external object that declares its own `organization_id`, and a member there keeps the equality. - CONTROL: the owner still crosses the wall, and the org-less deny, on a local object. - CONTROL: a member is unchanged under `isolated` and `group`. - CONTROL: `single` is unchanged for the owner and a member. - **`plugin-driver-external-object.spike.test.ts` (h5c)**, beside (h5)/(h5b), on the real `isolated` boot: the owner's `GET /data/spike_late` answers 200 with no row, and no read without the deny sentinel reaches the remote. CONTROL in the same case: the owner's `GET /data/spike_walled` still crosses the wall and reads every organization's rows. - **One-shot ablation** (not committed): with the new condition replaced by `true` and plugin-security rebuilt, the 3 owner cases above and (h5c) went red and every other case stayed green; restored and rebuilt, all green. Readings below. ## Acceptance notes - No out-of-scope finding to note. - Pre-fix readings are with the seat. ## Verification All readings are at or source-equal to head `471f235499`: `packages/` is byte-identical from `111074d2f6` (the fix commit) to `471f235499`, and the later commits touch only the changeset and merge one skills-only `main` commit. Heavy runs went through `scripts/pm/os-verify-lock.sh`, and each reading is that wrapper's `VERDICT` line. <details><summary>Unit: the crossing's pins and the federated Layer 0 pins (34/34)</summary> ```text pnpm --filter @objectstack/plugin-security exec vitest run --maxWorkers=2 src/platform-owner-wall-bypass.test.ts src/federated-tenant-layer0.test.ts Test Files 2 passed (2) Tests 34 passed (34) os-verify-lock: VERDICT command-exit 0 ``` </details> <details><summary>Full plugin-security suite and typechecks</summary> ```text pnpm --filter @objectstack/plugin-security test Test Files 242 passed (242) Tests 5273 passed | 45 skipped (5318) plugin-security test exit=0 pnpm --filter @objectstack/plugin-security typecheck exit=0 pnpm --filter @objectstack/runtime typecheck exit=0 ``` The first runtime typecheck exited 1 at `check:test-typecheck` on `organization-ownership-boot-guard.turso-remote.kernel.test.ts`, a file this diff does not touch. Its import `@objectstack/driver-turso` is an optional peer that the runtime closure build does not build, so it had no `dist/` here. After `turbo run build --filter=@objectstack/driver-turso`, the same typecheck passed (one `&&` chain, `VERDICT command-exit 0`). </details> <details><summary>Spike harness: the real isolated boot (20/20)</summary> ```text pnpm --filter @objectstack/plugin-security build && pnpm --filter @objectstack/runtime exec vitest run --project local --maxWorkers=2 src/plugin-driver-external-object.spike.test.ts Test Files 1 passed (1) Tests 20 passed (20) os-verify-lock: VERDICT command-exit 0 ``` The spike resolves `@objectstack/plugin-security` through its `dist/`, so plugin-security was rebuilt first. The new condition's text is in `dist/index.js` and `dist/index.mjs`. </details> <details><summary>One-shot ablation (not committed)</summary> - Tool: `scripts/ablation-replace.mjs` in WRAP mode, under the lock. The anchor is the new condition in `security-plugin-rls-filter.ts` (1 hit, replaced by `true`). Blob `f1bb2ff4e4` became `099c25dc90`. - Mutate leg: plugin-security was rebuilt, and `ablation-dist-preflight.mjs --absent` passed (marker absent from all 6 built files; the source marker was lost). - The owner crossing's unit pins: `3 failed | 23 passed (26)`. The `isolated`, `group` and org-less owner cases went red. - Spike: `1 failed | 19 passed (20)`. (h5c) went red. - Every control case stayed green. - Restore leg: the blob after restore equals HEAD (`f1bb2ff4e4`), `git diff HEAD` is empty, and the whole-tree `git status --porcelain` is clean. After the rebuild, the present-mode preflight passed (marker in 2 built files) and the suites read 26/26 and 20/20. - The direction matched the prediction: red. </details> <details><summary>Derived gate families: 60 derived, 57 run, 3 NOT MEASURED, 0 unrun</summary> `node scripts/pm/dispatch-gates.mjs --commands --repo objectstack-ai/objectstack` derived 60 commands off merge base `987ff33b8`. Each command ran with its exit captured before any pipe, and `--ran` reconciled the records: ```text Run reconciliation — 60 derived, 57 run, 3 NOT-MEASURED, 0 UNRUN. ✓ dispatch-gates --ran: 60 derived famil(ies) accounted for — 57 run, 3 NOT-MEASURED (3 DERIVED from a recorded exit 3). ``` - 56 of the 57 were re-run at `471f235499`, all exit 0. Among them, `check-adr-0087-registration` reads: `[BREAKING+bang+clause-②-narrowing] not-required (already-registered)`. - `check-comment-mask-corpus` (exit 0) is the repo-wide comment-mask sweep. It was taken at `0135956739`, whose sources equal `471f235499`'s. - NOT MEASURED, left to CI's `Lint & Repo Gates`: - `check:dual-build-cjs-loads`: PREREQUISITE NOT MET, because it needs every package's `dist/`. - `check:i18n`: PREREQUISITE NOT MET, because it needs the workspace CLI build. - `check:type-check-debt`: its closure build never got the shared lock (queue-timeout). The two touched packages' own typechecks, both exit 0, give the narrower reading. </details> <details><summary>Full dogfood battery (the title carries a bang)</summary> ```text pnpm exec turbo run build --filter='@objectstack/dogfood^...' --concurrency=2 && pnpm --filter @objectstack/dogfood test Tasks: 69 successful, 69 total Test Files 417 passed | 3 skipped (420) Tests 3462 passed | 28 skipped (3490) os-verify-lock: VERDICT command-exit 0 · held the lock 2613s (43m33s) ``` </details> - Not run locally: the `test:repo` vitest project (`Test Core` runs it on the PR and in the merge group). Neither changed test file is in a `repo` project list. <!-- signed: security#1 · os-justin · session_01QSeKYn5CmmdShCJifm6WYj --> --------- Co-authored-by: Claude <noreply@anthropic.com>
1 parent 6cc0b81 commit 917f024

5 files changed

Lines changed: 173 additions & 5 deletions

File tree

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
---
2+
'@objectstack/plugin-security': patch
3+
---
4+
5+
fix(plugin-security)!: an external object that states no organization scope reads as empty for every caller, the platform owner included
6+
7+
Clause-②: no (narrowing) — under the `isolated` and `group` postures, an external object registered after the boot that states no organization scope reads as empty for every caller, the declared platform owner included; nothing is widened, and the `single` posture is unchanged.
8+
Metadata-protocol: none
9+
10+
<!-- adr-0087: not-required (already-registered external-object-organization-scope-declared) the operator's remedy is the existing entry's: declare one of the three scopes on the external object; nothing an author writes changes here -->
11+
12+
**BREAKING** for a deployment running the `isolated` or `group` tenancy posture (`OS_TENANCY_POSTURE`) that registers an external object after the boot without stating its organization scope.
13+
14+
- **The rule (ADR-0015 §10 as amended).** Whose rows an external object serves is a fact only its author can state. Under a walled posture an external object that states none is refused by name when the boot completes, and one registered after the boot — a Studio import, a runtime datasource — reads as empty for every caller, the platform owner included, and accepts no write, until it states its scope. That deny judges the object's configuration, not the reader's organization.
15+
- **What is unchanged.** The declared platform owner's reads still cross the organization wall everywhere else: on local objects, on an external object that declares its own `organization_id`, and in a session with no active organization. Writes stay walled for everyone. A member's reads are unchanged.
16+
- **Who moves, and the fix.** Declare one of the three on the external object, as the ADR-0087 entry `external-object-organization-scope-declared` prescribes: an `organization_id` field of its own (the rows are then walled by organization), `tenancy: { enabled: false }` (shared by every organization), or `systemFields: { tenant: false }` (the same opt-out on the system fields).

‎packages/plugins/plugin-security/src/platform-owner-wall-bypass.test.ts‎

Lines changed: 106 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -41,6 +41,7 @@
4141
import { describe, it, expect, vi, beforeEach, afterEach } from 'vitest';
4242
import type { PermissionSet } from '@objectstack/spec/security';
4343
import { parsePlatformAdminEmails } from '@objectstack/core';
44+
import { TENANT_SCOPE_FIELD_DEF } from '@objectstack/metadata-core';
4445
import { SecurityPlugin } from './security-plugin.js';
4546
import { RLS_DENY_FILTER } from './rls-compiler.js';
4647
import {
@@ -91,16 +92,19 @@ async function boot(opts: {
9192
users?: Record<string, any>;
9293
tenancy?: { posture: string };
9394
permissionSets?: PermissionSet[];
95+
/** The one object schema served; {@link TENANT_SCHEMA} unless a case names another. */
96+
schema?: Record<string, unknown>;
9497
} = {}) {
9598
const users = opts.users ?? {};
99+
const schema = opts.schema ?? TENANT_SCHEMA;
96100
const findOne = vi.fn(async (object: string, o: any) =>
97101
object === 'sys_user' ? (users[o?.where?.id] ?? null) : null,
98102
);
99103
const warn = vi.fn();
100104
const services: Record<string, unknown> = {
101105
manifest: { register: vi.fn() },
102-
objectql: { registerMiddleware: vi.fn(), getSchema: () => TENANT_SCHEMA, findOne },
103-
metadata: { get: async () => TENANT_SCHEMA, list: async () => opts.permissionSets ?? [PLAIN_MEMBER] },
106+
objectql: { registerMiddleware: vi.fn(), getSchema: () => schema, findOne },
107+
metadata: { get: async () => schema, list: async () => opts.permissionSets ?? [PLAIN_MEMBER] },
104108
'org-scoping': { name: 'com.objectstack.org-scoping' },
105109
};
106110
if (opts.tenancy) services['tenancy'] = opts.tenancy;
@@ -310,6 +314,106 @@ describe('[#12974] audit — the ruled floor', () => {
310314
});
311315
});
312316

317+
describe('[ADR-0015 §10] an external object that states no organization scope reads as empty for every caller, the platform owner included', () => {
318+
/**
319+
* What the registry hands the plugin for an external object registered after
320+
* the boot that states nothing: its remote columns plus the platform's
321+
* injected `organization_id` anchor (the spread `applySystemFields` makes),
322+
* which is no declaration — `federated-tenant-layer0.test.ts` pins the
323+
* member's half of the same verdict.
324+
*/
325+
const UNDECLARED_EXTERNAL = {
326+
name: 'ext_ledger',
327+
external: { remoteName: 'ledger' },
328+
fields: {
329+
organization_id: { ...TENANT_SCOPE_FIELD_DEF },
330+
name: { type: 'text', label: 'Name' },
331+
},
332+
};
333+
/** The same remote, declaring its own `organization_id`: walled by organization. */
334+
const DECLARED_WALLED_EXTERNAL = {
335+
name: 'ext_ledger',
336+
external: { remoteName: 'ledger' },
337+
fields: {
338+
organization_id: { type: 'text', label: 'Organization (remote column)' },
339+
name: { type: 'text', label: 'Name' },
340+
},
341+
};
342+
const OWNER_ROW = { u_owner: { id: 'u_owner', email: OWNER_EMAIL, email_verified: true } };
343+
const MEMBER = { userId: 'u_m', email: 'member@corp.example' };
344+
const layered = (plugin: unknown, ctx: unknown) =>
345+
(plugin as any).computeLayeredRlsFilter([PLAIN_MEMBER], 'ext_ledger', 'find', ctx);
346+
const bypassEvents = (warn: ReturnType<typeof vi.fn>) =>
347+
warn.mock.calls.filter(([, meta]) => meta?.event === PLATFORM_OWNER_WALL_BYPASS_EVENT);
348+
349+
it('`isolated`: the verified owner reads the deny sentinel, the recorded verdict is `deny`, no crossing is logged and the owner probe is never asked', async () => {
350+
process.env.OS_PLATFORM_OWNER_EMAIL = OWNER_EMAIL;
351+
const { plugin, warn, findOne } = await boot({ users: OWNER_ROW, schema: UNDECLARED_EXTERNAL });
352+
// The spec's frozen deny sentinel, by identity (ADR-0139 D2 step 2).
353+
expect(await (plugin as any).getReadFilter('ext_ledger', sessionCtx())).toBe(RLS_DENY_FILTER);
354+
const split = await layered(plugin, sessionCtx());
355+
expect(split.layer0).toBe(RLS_DENY_FILTER);
356+
// The verdict as RECORDED for the engine: the wall still stands, so `deny`, never `none`.
357+
expect(split.tenantLayer0Verdict).toEqual({ kind: 'deny' });
358+
expect(split.crossedByPlatformAdmin).toBe(false);
359+
expect(bypassEvents(warn)).toHaveLength(0);
360+
// The verdict judges the object, not the reader: no `sys_user` row is read to reach it.
361+
expect(findOne.mock.calls.filter(([object]) => object === 'sys_user')).toHaveLength(0);
362+
});
363+
364+
it('`group`: the verified owner reads the deny sentinel there too', async () => {
365+
process.env.OS_PLATFORM_OWNER_EMAIL = OWNER_EMAIL;
366+
const { plugin, warn } = await boot({ users: OWNER_ROW, schema: UNDECLARED_EXTERNAL, tenancy: { posture: 'group' } });
367+
const ctx = sessionCtx({ accessible_org_ids: ['org-1', 'org-2'] });
368+
expect(await (plugin as any).getReadFilter('ext_ledger', ctx)).toBe(RLS_DENY_FILTER);
369+
expect((await layered(plugin, ctx)).tenantLayer0Verdict).toEqual({ kind: 'deny' });
370+
expect(bypassEvents(warn)).toHaveLength(0);
371+
});
372+
373+
it('an org-less verified owner reads the deny sentinel on it as well: the crossing of the org-less deny does not reach this one', async () => {
374+
process.env.OS_PLATFORM_OWNER_EMAIL = OWNER_EMAIL;
375+
const { plugin } = await boot({ users: OWNER_ROW, schema: UNDECLARED_EXTERNAL });
376+
expect(await (plugin as any).getReadFilter('ext_ledger', sessionCtx({ tenantId: undefined }))).toBe(RLS_DENY_FILTER);
377+
});
378+
379+
it('CONTROL: the verified owner still crosses the wall on an external object that declares its own `organization_id`', async () => {
380+
process.env.OS_PLATFORM_OWNER_EMAIL = OWNER_EMAIL;
381+
const { plugin, warn } = await boot({ users: OWNER_ROW, schema: DECLARED_WALLED_EXTERNAL });
382+
expect(await (plugin as any).getReadFilter('ext_ledger', sessionCtx())).toBeUndefined();
383+
const split = await layered(plugin, sessionCtx());
384+
expect(split.layer0).toBeNull();
385+
expect(split.tenantLayer0Verdict).toEqual({ kind: 'none' });
386+
expect(bypassEvents(warn).length).toBeGreaterThan(0);
387+
// …and a member of that object keeps the organization equality.
388+
expect(await (plugin as any).getReadFilter('ext_ledger', sessionCtx(MEMBER))).toEqual({ organization_id: 'org-1' });
389+
});
390+
391+
it('CONTROL: the verified owner still crosses the wall, and the org-less deny, on a local object', async () => {
392+
process.env.OS_PLATFORM_OWNER_EMAIL = OWNER_EMAIL;
393+
const { plugin } = await boot({ users: OWNER_ROW });
394+
expect(await readFilter(plugin, sessionCtx())).toBeUndefined();
395+
expect(await readFilter(plugin, sessionCtx({ tenantId: undefined }))).toBeUndefined();
396+
});
397+
398+
it('CONTROL: a member is unchanged — the deny sentinel, under `isolated` and `group`', async () => {
399+
process.env.OS_PLATFORM_OWNER_EMAIL = OWNER_EMAIL;
400+
const { plugin } = await boot({ users: OWNER_ROW, schema: UNDECLARED_EXTERNAL });
401+
expect(await (plugin as any).getReadFilter('ext_ledger', sessionCtx(MEMBER))).toBe(RLS_DENY_FILTER);
402+
const group = await boot({ users: OWNER_ROW, schema: UNDECLARED_EXTERNAL, tenancy: { posture: 'group' } });
403+
expect(
404+
await (group.plugin as any).getReadFilter('ext_ledger', sessionCtx({ ...MEMBER, accessible_org_ids: ['org-1'] })),
405+
).toBe(RLS_DENY_FILTER);
406+
});
407+
408+
it('CONTROL: `single` is unchanged — no wall, so the owner and a member both read it unwalled', async () => {
409+
process.env.OS_PLATFORM_OWNER_EMAIL = OWNER_EMAIL;
410+
const { plugin } = await boot({ users: OWNER_ROW, schema: UNDECLARED_EXTERNAL, tenancy: { posture: 'single' } });
411+
expect(await (plugin as any).getReadFilter('ext_ledger', sessionCtx())).toBeUndefined();
412+
expect(await (plugin as any).getReadFilter('ext_ledger', sessionCtx(MEMBER))).toBeUndefined();
413+
expect((await layered(plugin, sessionCtx())).tenantLayer0Verdict).toEqual({ kind: 'none' });
414+
});
415+
});
416+
313417
describe('[#12974] the shared row predicate (the per-request derivation’s twin)', () => {
314418
it('matchesDeclaredOwnerEmail — canonical comparison: trimmed, case-insensitive', () => {
315419
expect(matchesDeclaredOwnerEmail({ email: 'Operator@Corp.Example' }, SOLO)).toBe(true);

‎packages/plugins/plugin-security/src/platform-owner-wall-bypass.ts‎

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,11 @@
2121
* wall is byte-identical to before the ruling, and WRITES keep today's
2222
* behaviour for the owner too — the ADR-0123 D2 org-less write refusal
2323
* stands (director's correction on the same card: lifting the write twin
24-
* would mint the NULL-organization rows the platform is eliminating).
24+
* would mint the NULL-organization rows the platform is eliminating). Nor
25+
* does a READ cross the one `deny` that judges the object rather than the
26+
* reader: an external object that states no organization scope reads as
27+
* empty for every caller, the platform owner included (ADR-0015 §10; the
28+
* stand-down is at the crossing in `security-plugin-rls-filter.ts`).
2529
*
2630
* [#13147] The comparison is no longer spelled here at all. `OS_PLATFORM_OWNER_EMAIL`
2731
* takes ONE address **or a comma-separated list** of them (#11663 Choice 2B),

‎packages/plugins/plugin-security/src/security-plugin-rls-filter.ts‎

Lines changed: 23 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -510,7 +510,29 @@ export async function computeLayeredRlsFilter(
510510
// ONLY the read-side Layer 0 is lifted. Layer 1 (business RLS, object/field
511511
// permissions, the write `check` path) is untouched by construction — this
512512
// branch rewrites the `layer0` half of the split and nothing else.
513-
if (!isWrite && layer0 !== null && (await this.isVerifiedPlatformOwnerSession(context))) {
513+
//
514+
// [ADR-0015 §10] ONE Layer 0 answer is not the wall's to lift: the `deny` an
515+
// EXTERNAL object earns by stating no organization scope (security-channel
516+
// ruling 2026-11-04, option A). That deny is not a filter on the reader's
517+
// organization — it is the verdict on a configuration defect: whose rows the
518+
// object serves is a fact only its author can state, and an unstated scope
519+
// reads as empty for every caller, the verified platform owner included,
520+
// until the object declares one of the three (`external-organization-scope.ts`).
521+
// So the owner's read crossing stands down on exactly that verdict, and the
522+
// probe is not even consulted there. Every other answer is crossed as
523+
// before: the `isolated` equality, the `group` union, and the deny sentinel
524+
// an org-less session hits — on a local object and on an external object
525+
// that declares its own `organization_id` alike. The recorded verdict stays
526+
// `deny` (the return below): a reader must not learn `none` from a wall
527+
// that still stands.
528+
const deniedForUndeclaredExternalScope =
529+
tenantLayer0Verdict.kind === 'deny' && tenantLayer0Input.externalOrganizationScopeUndeclared === true;
530+
if (
531+
!isWrite &&
532+
layer0 !== null &&
533+
!deniedForUndeclaredExternalScope &&
534+
(await this.isVerifiedPlatformOwnerSession(context))
535+
) {
514536
// The audit floor (hard piece 3 of the ruling): a structured warn-level
515537
// log with the stable event name, per wall-bypassing READ computation —
516538
// the only bypass kind left. plugin-audit is not wired into

‎packages/runtime/src/plugin-driver-external-object.spike.test.ts‎

Lines changed: 23 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
// Copyright (c) 2026 ObjectStack. Licensed under the Apache-2.0 license.
2-
// test-budget: 30 — spawns the real producer once per single-cause fixture: two real-kernel boots, one per posture (ObjectQL, the sqlite-wasm default datasource, Hono on port 0, auth, datasource admin, security, sharing, REST, the dispatcher and the spike's plugin driver) with real sign-ups, the `single` boot shared by the 12 cases (a) to (g) and itself the subject of (a) and (b), the `isolated` boot shared by the 6 cases of (h), plus the refused boot that is case (h6)'s subject; 4.6 s of cases in a local run against 2.9 s before the third boot; the single-boot file's slowest CI reading was 12.4 s (scheduled full-battery run 41255489006, Test Core shard log), scaled by the local ratio and x 1.25, rounded up — re-measure on the first scheduled run that carries (h)
2+
// test-budget: 30 — spawns the real producer once per single-cause fixture: two real-kernel boots, one per posture (ObjectQL, the sqlite-wasm default datasource, Hono on port 0, auth, datasource admin, security, sharing, REST, the dispatcher and the spike's plugin driver) with real sign-ups, the `single` boot shared by the 12 cases (a) to (g) and itself the subject of (a) and (b), the `isolated` boot shared by the 7 cases of (h), plus the refused boot that is case (h6)'s subject; 4.6 s of cases in a local run against 2.9 s before the third boot; the single-boot file's slowest CI reading was 12.4 s (scheduled full-battery run 41255489006, Test Core shard log), scaled by the local ratio and x 1.25, rounded up — re-measure on the first scheduled run that carries (h)
33

44
/**
55
* Spike: a virtual object on a plugin driver, end to end in a booted kernel
@@ -991,6 +991,28 @@ describe('(h) under the `isolated` posture every external object states its orga
991991
expect(walledCalls.slice(mark).some((c) => c.object === SHARED && c.method === 'create')).toBe(true);
992992
});
993993

994+
it('(h5c) …and reads as empty for every caller, the platform owner included: the owner\'s GET answers no row and no unwalled read reaches the remote, while the owner still crosses the wall on a declared-walled object', async () => {
995+
// The declared platform owner seated in A — the one caller whose reads
996+
// cross the organization wall elsewhere. The object (h5) registered states
997+
// no organization scope, so its deny judges the object, not the reader.
998+
const mark = walledCalls.length;
999+
const res = await wAs(adminTokenW, 'GET', `/data/${LATE}`);
1000+
const body = await readJson(res);
1001+
expect(res.status, JSON.stringify(body)).toBe(200);
1002+
expect(idsOf(body)).toEqual([]);
1003+
// Every read that reached the remote carried the deny sentinel.
1004+
const unwalled = walledCalls
1005+
.slice(mark)
1006+
.filter((c) => c.object === LATE && c.method === 'find' && !/__rls_deny__|__deny_all__/.test(JSON.stringify(c.query)));
1007+
expect(unwalled).toEqual([]);
1008+
// CONTROL: the same owner on the declared-walled object crosses the wall —
1009+
// every row the remote holds, every organization's.
1010+
const walled = await wAs(adminTokenW, 'GET', `/data/${WALLED}`);
1011+
const walledBody = await readJson(walled);
1012+
expect(walled.status, JSON.stringify(walledBody)).toBe(200);
1013+
expect(idsOf(walledBody)).toEqual((walledTables[WALLED] ?? []).map((r) => String(r.id)).sort());
1014+
});
1015+
9941016
it('(h6) an external object that states no scope at boot is refused BY NAME, with the three ways out; so is a `tenancy.tenantField` the wall cannot read', async () => {
9951017
const refused = await composeWalled(REFUSED_STACK, createSpikeTreeDriver({}, []));
9961018
let thrown: unknown;

0 commit comments

Comments
 (0)