Skip to content

Commit c614b03

Browse files
committed
test(plugin-security): the rig-users testkit lives under __tests__, and the delegate-read pins type their options
The system-context page's reference-check row names referencesCheckedBeforeRules, and its site register is regenerated. Claude-Session: https://claude.ai/code/session_01Utp6CYQjMkN514R78sCrTT Co-authored-by: Claude <noreply@anthropic.com>
1 parent d2b3757 commit c614b03

9 files changed

Lines changed: 12 additions & 11 deletions

‎content/docs/permissions/system-context.mdx‎

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -134,7 +134,7 @@ bugs — it is the protection or the side effect that silently does not happen.
134134
| 21 | **`readonly` strip bypassed — INSERT** | objectql | Same, on create — one gate over BOTH create-side passes since the 2026-09-03 ruling moved the static-`readonly` strip in beside the runtime-owned one and deleted the DataProtocol ingress copy. `isSystem` is the **only** exemption on this path: `preserveAudit` is deliberately not read on create, so a non-system historical import is still stripped. A second read in the same symbol gates the pass that withholds those caller values from `beforeInsert` before the strip, the same exemption, so a system caller's hook still sees what it sent | `insert` |
135135
| 21b | **`readonly` strip bypassed — the write PREVIEW (`ObjectQL.validate`)** | objectql | Same as 19–21, in the preview: it runs the write's caller-write strips under the write's own gate, so a system preview reports no `readonly` drop and judges the value a system write would store. The `computed` strip of a `formula` value is NOT gated here or on either write verb — no driver has a column for it, so it runs for every caller | `validate` |
136136
| 22 | Strict-drop refusal never fires | objectql | Lose: a caller that opted into loud refusal gets **silence** — strict refuses exactly what the strip would have taken, and the strip took nothing. Two exceptions, both judged in every context: a `formula` value, which the `computed` strip takes from every caller, and a value for a stored field that declares `expression` when it differs from the value the engine computes in its place (`stored_expression`), so strict still refuses both | `insert`, `packages/objectql/src/readonly-strict-errors.ts#READONLY_CLASS_REASONS` |
137-
| 23 | **Referential-integrity check skipped** — except a `runAs: 'system'` flow's record writes, which keep it | objectql | Get: writes proceed against unreachable/unresolvable targets — a seed replay, an import, a restore or a cascade may store a reference to a row that does not exist yet. Lose: an `isSystem` caller can write a **dangling reference**. A flow run's elevated context (`resolveRunDataContext`) carries an internal mark that keeps the check, so a flow's `create_record` / `update_record` naming a row that does not exist is refused `400 VALIDATION_FAILED` / `reference_not_found`, as on the user path; its authorization elevation is unchanged. A write the flow's write sets off (a hook's `ctx.api`, its `sudo()`, a cascade leg of a flow's delete) spreads the run's context and is checked as the flow's own, as on the user path. The mark is a symbol no flow definition or request can spell, and `ExecutionContextSchema.parse` drops it | `assertReferencesResolve` |
137+
| 23 | **Referential-integrity check skipped** — except a `runAs: 'system'` flow's record writes, which keep it | objectql | Get: writes proceed against unreachable/unresolvable targets — a seed replay, an import, a restore or a cascade may store a reference to a row that does not exist yet. Lose: an `isSystem` caller can write a **dangling reference**. A flow run's elevated context (`resolveRunDataContext`) carries an internal mark that keeps the check, so a flow's `create_record` / `update_record` naming a row that does not exist is refused `400 VALIDATION_FAILED` / `reference_not_found`, as on the user path; its authorization elevation is unchanged. A write the flow's write sets off (a hook's `ctx.api`, its `sudo()`, a cascade leg of a flow's delete) spreads the run's context and is checked as the flow's own, as on the user path. The mark is a symbol no flow definition or request can spell, and `ExecutionContextSchema.parse` drops it. Where a system write runs the check (a flow run's), it runs after the record's validation rules, as before; every other write runs it before them | `assertReferencesResolve`, `referencesCheckedBeforeRules` |
138138
| 23b | **Position-catalog check skipped** — a `sys_user_position` write whose `position` names no position in the security catalog is not refused | plugin-security | Get: a system writer can store an assignment naming no position — the seed loader writes `stack.data` from `AppPlugin.start()` under a system context, as invitation acceptance and the platform's own bootstraps do. Lose: such a row grants nothing and nothing says so. A non-system insert, or a non-system update that changes `position`, is refused `400 VALIDATION_FAILED` / `reference_not_found` instead when the security catalog holds no position of that name: the environment registry (ADR-0131 D3), one per deployment, which takes no organization, so a name only a `sys_position` row carries — any organization's — is refused like one nobody carries. It is the same stand-down as the engine's referential-integrity check for a lookup column | `assertPositionNamesCatalogRow` |
139139
| 23c | **Grant-name catalog check skipped** — a `sys_user_permission_set` write whose `permission_set` names no permission set in the security catalog is not refused | plugin-security | Get: a system writer can store a grant naming a set not yet registered — seed replay and boot provisioning may write the grant before the definition it names is registered. Lose: such a row grants nothing and nothing says so. A non-system insert, or a non-system update that changes `permission_set`, is refused `400 VALIDATION_FAILED` / `reference_not_found` instead when the security catalog holds no set by that name; a grant that names no set at all is refused `required` for every caller. The grant names its set by name alone, and nothing derives the name from `permission_set_id` (ADR-0131 D4, D10) | `packages/plugins/plugin-security/src/grant-permission-set-name.ts#onInsert`, `packages/plugins/plugin-security/src/grant-permission-set-name.ts#onUpdate` |
140140
| 23d | **Grant-holder membership check skipped** — a `sys_user_position` or `sys_user_permission_set` write naming a user with no `sys_member` row in the row's organization is not refused | plugin-security | Get: a system writer can store such a grant — invitation acceptance writes the membership and its placement together, and seed replay, the organization-admin reconcile and the platform bootstraps write grants as the system. Lose: such a row takes effect once its user is admitted to the organization. A non-system insert, or a non-system update that moves `user_id` or `organization_id`, is refused `400 VALIDATION_FAILED` / `reference_not_found` at `user_id` instead, for every caller, a platform administrator included; the membership is read as `{ isSystem: true, tenantId }` with `tenantId` the row's own organization, never another one. A row stored with no organization is not judged. Under `single`, 18.0 stamps a new grant with the Default Organization, so such a row is one an earlier release wrote | `packages/plugins/plugin-security/src/grant-holder-membership-refusal.ts#onInsert`, `packages/plugins/plugin-security/src/grant-holder-membership-refusal.ts#onUpdate` |
@@ -539,6 +539,7 @@ and CI refuses one that differs from what the tree produces.
539539
| `packages/objectql/src/engine-master-detail-related.ts#resolveOneHopRelated` | 1 | 29b |
540540
| `packages/objectql/src/engine-referential-integrity.ts#assertReferencesResolve` | 1 | 23 |
541541
| `packages/objectql/src/engine-referential-integrity.ts#masterDetailHeadersCallerReads` | 1 | 29c |
542+
| `packages/objectql/src/engine-referential-integrity.ts#referencesCheckedBeforeRules` | 1 | 23 |
542543
| `packages/objectql/src/engine-secret-internal-fields.ts#encryptSecretFields` | 1 | 23e |
543544
| `packages/objectql/src/engine-secret-internal-fields.ts#stripSearchCompanionFromRead` | 1 | 27 |
544545
| `packages/objectql/src/engine-validate.ts#validate` | 1 | 21b |

packages/plugins/plugin-security/src/rig-users.testkit.ts renamed to packages/plugins/plugin-security/src/__tests__/rig-users.testkit.ts

File renamed without changes.

‎packages/plugins/plugin-security/src/delegable-scope-no-identity-positions.posture.test.ts‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,7 @@ import { SysUserPermissionSet } from './objects/sys-user-permission-set.object.j
3737
import { RESERVED_IDENTITY_NAMES } from './objects/reserved-identity-names.js';
3838
import { defaultPermissionSets } from './objects/index.js';
3939
import { BUILTIN_IDENTITY_ORG_EXTERNAL } from '@objectstack/spec';
40-
import { provisionRigUsers } from './rig-users.testkit.js';
40+
import { provisionRigUsers } from './__tests__/rig-users.testkit.js';
4141

4242
const SYS = { isSystem: true } as const;
4343
const ORG_A = 'org_a';

‎packages/plugins/plugin-security/src/delegated-admin-own-name-set.posture.test.ts‎

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -258,9 +258,9 @@ describe('[ADR-0090 D12, amended 2026-10-17; #24757] a delegate is judged on exa
258258
});
259259

260260
/** [#29029] Every unit id `context` reads, sorted, or the refusal's status and code. */
261-
async function unitsRead(h: Awaited<ReturnType<typeof boot>>, context: any): Promise<string[] | { status: number; code?: string }> {
261+
async function unitsRead(h: Awaited<ReturnType<typeof boot>>, context: ReturnType<typeof delegateCtx>): Promise<string[] | { status: number; code?: string }> {
262262
try {
263-
const rows = await h.engine.find('sys_business_unit', { context } as any);
263+
const rows = await h.engine.find('sys_business_unit', { context });
264264
return (Array.isArray(rows) ? rows : []).map((r: any) => String(r.id)).sort();
265265
} catch (e) {
266266
const r = resolveThrownHttpError(e);
@@ -294,9 +294,9 @@ describe('[ADR-0090 D12, ruling of record 6663849489; #29029] a delegate reads t
294294
it('the delegate reads exactly the units its scope covers: the scope root and its subtree, not the unit above it', async () => {
295295
const h = await boot(posture);
296296
expect(await unitsRead(h, NARROW)).toEqual(['bu_east', 'bu_east_field']);
297-
const above = await h.engine.findOne('sys_business_unit', { where: { id: 'bu_hq' }, context: NARROW } as any);
297+
const above = await h.engine.findOne('sys_business_unit', { where: { id: 'bu_hq' }, context: NARROW });
298298
expect(above ?? null).toBeNull();
299-
expect(await h.engine.count('sys_business_unit', { context: NARROW } as any)).toBe(2);
299+
expect(await h.engine.count('sys_business_unit', { context: NARROW })).toBe(2);
300300
});
301301

302302
it('the delegate assigns a position in a unit its scope covers, and the assignment is stored', async () => {

‎packages/plugins/plugin-security/src/grant-holder-membership-refusal.test.ts‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,7 @@ import {
4040
registerGrantHolderMembershipRefusal,
4141
} from './grant-holder-membership-refusal.js';
4242
import { relaxTenantColumns } from './pre-18-tenant-column.testkit.js';
43-
import { provisionRigUsers } from './rig-users.testkit.js';
43+
import { provisionRigUsers } from './__tests__/rig-users.testkit.js';
4444

4545
// ---------------------------------------------------------------------------
4646
// Fixture

‎packages/plugins/plugin-security/src/grant-permission-set-name.test.ts‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -44,7 +44,7 @@ import {
4444
registerGrantPermissionSetNameHooks,
4545
} from './grant-permission-set-name.js';
4646
import { relaxTenantColumns } from './pre-18-tenant-column.testkit.js';
47-
import { provisionRigUsers } from './rig-users.testkit.js';
47+
import { provisionRigUsers } from './__tests__/rig-users.testkit.js';
4848

4949
// ---------------------------------------------------------------------------
5050
// Fixture

‎packages/plugins/plugin-security/src/org-admin-assignment-boundary.posture.test.ts‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -44,7 +44,7 @@ import { SysUserPosition } from './objects/sys-user-position.object.js';
4444
import { SysUserPermissionSet } from './objects/sys-user-permission-set.object.js';
4545
import { defaultPermissionSets } from './objects/index.js';
4646
import { maskFieldValue } from './field-masker.js';
47-
import { provisionRigUsers } from './rig-users.testkit.js';
47+
import { provisionRigUsers } from './__tests__/rig-users.testkit.js';
4848

4949
const SYS = { isSystem: true } as const;
5050
const ORG_A = 'org_a';

‎packages/plugins/plugin-security/src/position-catalog-refusal.test.ts‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,7 @@ import { SysUserPosition } from './objects/sys-user-position.object.js';
3737
import { SysUserPermissionSet } from './objects/sys-user-permission-set.object.js';
3838
import { namesWithoutCatalogRow, positionNotInCatalogMessage } from './position-catalog-refusal.js';
3939
import { relaxTenantColumns } from './pre-18-tenant-column.testkit.js';
40-
import { provisionRigUsers } from './rig-users.testkit.js';
40+
import { provisionRigUsers } from './__tests__/rig-users.testkit.js';
4141

4242
// ---------------------------------------------------------------------------
4343
// Fixture

‎packages/plugins/plugin-security/src/sys-user-permission-set-window-order.test.ts‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -44,7 +44,7 @@ import { SysPermissionSet } from './__tests__/legacy-catalog-objects.testkit.js'
4444
import { SysPositionPermissionSet } from './__tests__/legacy-catalog-objects.testkit.js';
4545
import { SysUserPermissionSet } from './objects/sys-user-permission-set.object.js';
4646
import { relaxTenantColumns } from './pre-18-tenant-column.testkit.js';
47-
import { provisionRigUsers } from './rig-users.testkit.js';
47+
import { provisionRigUsers } from './__tests__/rig-users.testkit.js';
4848

4949
const MEMBER_DEFAULT = { name: 'member_default', label: 'Member', objects: {} } as unknown as PermissionSet;
5050
const QA_ADMIN = {

0 commit comments

Comments
 (0)