Skip to content

Commit 23e7bab

Browse files
committed
wip(spec, lint): defaultRowScope flips to live; its texts say what the reader does
Claude-Session: https://claude.ai/code/session_01Nk17Z26X5DB59iQztDBADH Co-authored-by: Claude <noreply@anthropic.com>
1 parent 6bea692 commit 23e7bab

4 files changed

Lines changed: 86 additions & 71 deletions

File tree

‎packages/lint/src/validate-org-axis-red-lines.test.ts‎

Lines changed: 8 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -73,9 +73,11 @@ function sharingRule(input: SharingRule): Record<string, unknown> {
7373
/**
7474
* Same guard for the permission-set fixtures rule ① reads (#5009).
7575
*
76-
* `permissions[].rowLevelSecurity` is the ONLY authorable RLS surface —
77-
* `ObjectSchema` declares no `rowLevelSecurity` (nor `rls`) and is `.strict()`,
78-
* so the object-level traversal this rule used to carry could not run against a
76+
* `permissions[].rowLevelSecurity` is the ONLY authorable LIST of RLS policies.
77+
* An object declares at most ONE policy, `defaultRowScope` (#24164 ruling E′:
78+
* the policy that applies when no held set carries one for the object), and no
79+
* `rowLevelSecurity` (nor `rls`) list; `ObjectSchema` is `.strict()`, so the
80+
* object-level list traversal this rule used to carry could not run against a
7981
* stack that parses. Building rule ①'s fixtures through the real schema is what
8082
* keeps that from quietly coming back: a fixture for a surface the spec does
8183
* not have now fails HERE.
@@ -349,11 +351,12 @@ const MANIFEST = { id: 'com.example.org-axis-probe', name: 'org_axis_probe', ver
349351
const ORG_WALKING_POLICY = { name: 'rollup', using: 'parent_organization_id = current_user.organization_id' };
350352

351353
describe('validateOrgAxisRedLines — undeclared keys are the schema’s job, not this rule’s (#5009)', () => {
352-
it('object-level RLS is not an authoring surface: `ObjectSchema` declares neither `rowLevelSecurity` nor `rls`', () => {
354+
it('an object-level RLS policy LIST is not an authoring surface: `ObjectSchema` declares neither `rowLevelSecurity` nor `rls` (its one object-level policy is `defaultRowScope`)', () => {
353355
const objectKeys = Object.keys(ObjectSchema.shape);
354356
expect(objectKeys).not.toContain('rowLevelSecurity');
355357
expect(objectKeys).not.toContain('rls');
356-
// The only declared home for RLS policies is the permission set.
358+
// The only declared home for a LIST of RLS policies is the permission set;
359+
// an object's own single policy is `defaultRowScope`.
357360
expect(Object.keys(PermissionSetSchema.shape)).toContain('rowLevelSecurity');
358361

359362
// And `ObjectSchema` is `.strict()`, so this is not a silent strip: a stack

‎packages/spec/liveness/object.json‎

Lines changed: 36 additions & 38 deletions
Original file line numberDiff line numberDiff line change
@@ -159,60 +159,58 @@
159159
"note": "ADR-0055 high-risk class (sharing): the `controlled_by_parent` value derives a detail object's access from its master — the security layer injects `masterFK IN (accessible master ids)` on reads and requires master edit-access on by-id writes. The proof asserts a member who cannot read the master can neither read nor by-id-write the detail, and is not over-blocked on a master they own. 2026-08-28: RE-ANCHORED (commit 93ea19bca) and REPOINTED — `sharing-service.ts:54` had rotted onto a blank line between an interface and a `makeShareId` docblock. Re-closed by hand against c459da6bc."
160160
},
161161
"defaultRowScope": {
162-
"status": "planned",
163-
"verifiedAt": "2026-10-18",
164-
"evidence": "packages/spec/src/data/object.zod.ts#ObjectSchemaBase (declares the key, optional, typed as the default-row-scope shape); packages/spec/src/security/rls.zod.ts#DefaultRowScopeSchema (the shape: RowLevelSecurityPolicySchema's own members without `object`, with the same two rules, refineRowLevelSecurityPolicy)",
165-
"authorWarn": true,
166-
"authorHint": "Not applied yet: no server reads `defaultRowScope` in this release, so it filters no rows. Until the security plugin's row-policy collection applies it, restrict rows with a permission set's `rowLevelSecurity` policy.",
167-
"note": "PLANNED, the reader pending — #24164 ruling E′ item 1 (spec half, #24338). The one reader is to be plugin-security's `collectRLSPolicies` (packages/plugins/plugin-security/src/security-plugin.ts), carried by objectstack-ai/objectstack#24340: measured before the key existed, `git grep defaultRowScope` over the whole tree at origin/main b2e78701f7 returns zero hits (control: `sharingModel` under packages/plugins hits), and objectui at the `.objectui-sha` pin 0707b4ae37 returns zero too (same control hits), so this declaration adds no reader and an object declaring the key is filtered exactly as before. The writers are to be the platform identity objects (packages/platform-objects), carried by objectstack-ai/objectstack#24341, which is blocked on this key alone, so its declarations can land before the reader does; until #24340 lands they too filter nothing. Flip to `live` on the commit that lands #24340, citing `collectRLSPolicies` as the evidence and its explain source as the second read point, and drop `authorWarn` / `authorHint` in that same edit: a warned `live` row reds this gate. Drilled into `children` rather than deferred to `permission/rowLevelSecurity`: every member is RowLevelSecurityPolicySchema's own instance, but the key sets differ (`object`, `priority` and `tags` are left out here), so the gate's equality check would refuse the deferral; each child is `planned` for the same reason as the container, and only the container carries `authorWarn`, so authoring the key warns once. Flip the children with the container.",
162+
"status": "live",
163+
"verifiedAt": "2026-10-19",
164+
"evidence": "packages/plugins/plugin-security/src/security-plugin.ts#collectRLSPolicies (when the held sets' collection for the object and operation is empty, reads the registry schema's `defaultRowScope` and applies it as one policy through the same ADR-0105 D3 admission and `getApplicablePolicies` filter; the read door's Layer 1, the by-id pre-image gate, the bulk write filter, the post-image check, `checkAuthoredRowWrite` and explain all compose from this one collection); packages/plugins/plugin-security/src/object-default-row-scope.ts#objectDefaultRowScopePolicy (builds that policy, `object` implied, marked by identity); packages/plugins/plugin-security/src/explain-engine.ts#objectDefaultRowScopeSource (the second read point: explain names the applied default as the object's declaration, never a permission set)",
165+
"note": "LIVE since #24340 (#24164 ruling E′ item 2), flipped from `planned` with `authorWarn` / `authorHint` dropped in the same edit, as the row's own note asked. The reader is plugin-security's `collectRLSPolicies`: when no held set carries a row policy for the object and operation (the collection's own emptiness, so a held `'*'` policy counts and a policy for another operation does not), the object's default applies; an authored set policy is used as authored; a superuser-bypass principal never reaches the collection; an object with no default collects as before. A `using` that does not lower fails closed exactly as an authored policy's does (the same compiler). Pinned through the real SecurityPlugin + ObjectQL over SqlDriver in packages/plugins/plugin-security/src/object-default-row-scope.test.ts, and ablated there: removing the branch turns every default-dependent pin red and leaves the controls green. The writers are still to be the platform identity objects (#24341); no object in this tree declares the key yet. Drilled into `children` rather than deferred to `permission/rowLevelSecurity` because the key sets differ (`object`, `priority` and `tags` are left out here), so the gate's equality check would refuse the deferral; the children are flipped with the container.",
168166
"children": {
169167
"name": {
170-
"status": "planned",
171-
"verifiedAt": "2026-10-18",
172-
"evidence": "packages/spec/src/security/rls.zod.ts#DefaultRowScopeSchema (declares `name`: RowLevelSecurityPolicySchema's own member instance, the policy name, snake_case; the explain source a reader names)",
173-
"note": "Planned with its container: no server reads `defaultRowScope` until the security plugin's `collectRLSPolicies` does."
168+
"status": "live",
169+
"verifiedAt": "2026-10-19",
170+
"evidence": "packages/plugins/plugin-security/src/rls-compiler.ts#compileFilter (the uncompilable-predicate and fail-closed WARN lines name the policy by `name`); packages/plugins/plugin-security/src/explain-engine.ts#objectDefaultRowScopeSource (explain names the applied default by `name`)",
171+
"note": "Live with its container (#24340): the default is collected as one policy and passes the held policies' own applicability filter and compiler, so this member is read exactly where the permission-set `rowLevelSecurity` member of the same instance is."
174172
},
175173
"label": {
176-
"status": "planned",
177-
"verifiedAt": "2026-10-18",
178-
"evidence": "packages/spec/src/security/rls.zod.ts#DefaultRowScopeSchema (declares `label`: RowLevelSecurityPolicySchema's own member instance, the human-readable policy label)",
179-
"note": "Planned with its container: no server reads `defaultRowScope` until the security plugin's `collectRLSPolicies` does."
174+
"status": "live",
175+
"verifiedAt": "2026-10-19",
176+
"evidence": "packages/plugins/plugin-security/src/explain-engine.ts#objectDefaultRowScopeSource (draws `label` beside the default's name in the rls layer's detail, verbatim; an absent or blank label draws nothing)",
177+
"note": "Live by the display-key rule (README, 'Designer previews count as consumers'): explain shows the label to the administrator reading why a row is visible, which for a display key is the whole claimed effect."
180178
},
181179
"description": {
182-
"status": "planned",
183-
"verifiedAt": "2026-10-18",
184-
"evidence": "packages/spec/src/security/rls.zod.ts#DefaultRowScopeSchema (declares `description`: RowLevelSecurityPolicySchema's own member instance, the policy description)",
185-
"note": "Planned with its container: no server reads `defaultRowScope` until the security plugin's `collectRLSPolicies` does."
180+
"status": "live",
181+
"verifiedAt": "2026-10-19",
182+
"evidence": "packages/plugins/plugin-security/src/explain-engine.ts#objectDefaultRowScopeSource (draws `description` after the label in the rls layer's detail, verbatim; an absent or blank description draws nothing)",
183+
"note": "Live with `label`, on the same reading: explain shows it to the administrator reading the access decision."
186184
},
187185
"operation": {
188-
"status": "planned",
189-
"verifiedAt": "2026-10-18",
190-
"evidence": "packages/spec/src/security/rls.zod.ts#DefaultRowScopeSchema (declares `operation`: RowLevelSecurityPolicySchema's own member instance, which operations the scope applies to)",
191-
"note": "Planned with its container: no server reads `defaultRowScope` until the security plugin's `collectRLSPolicies` does."
186+
"status": "live",
187+
"verifiedAt": "2026-10-19",
188+
"evidence": "packages/plugins/plugin-security/src/rls-compiler.ts#getApplicablePolicies (`policy.operation === 'all'`, else compared against the mapped RLS op; the default passes this filter after the held collection comes back empty)",
189+
"note": "Live with its container (#24340): the default is collected as one policy and passes the held policies' own applicability filter and compiler, so this member is read exactly where the permission-set `rowLevelSecurity` member of the same instance is."
192190
},
193191
"using": {
194-
"status": "planned",
195-
"verifiedAt": "2026-10-18",
196-
"evidence": "packages/spec/src/security/rls.zod.ts#DefaultRowScopeSchema (declares `using`: RowLevelSecurityPolicySchema's own member instance, the row predicate)",
197-
"note": "Planned with its container: no server reads `defaultRowScope` until the security plugin's `collectRLSPolicies` does."
192+
"status": "live",
193+
"verifiedAt": "2026-10-19",
194+
"evidence": "packages/plugins/plugin-security/src/rls-compiler.ts#compileFilter (`policy.using` is the predicate on the read pass, and on a `check` pass for a policy that declares no `check`); packages/plugins/plugin-security/src/security-plugin.ts#writeCheckPolicies (hands USING-only policies to that `check` pass only when no applicable policy for the write declares `check`)",
195+
"note": "Live with its container (#24340): the default is collected as one policy and passes the held policies' own applicability filter and compiler, so this member is read exactly where the permission-set `rowLevelSecurity` member of the same instance is."
198196
},
199197
"check": {
200-
"status": "planned",
201-
"verifiedAt": "2026-10-18",
202-
"evidence": "packages/spec/src/security/rls.zod.ts#DefaultRowScopeSchema (declares `check`: RowLevelSecurityPolicySchema's own member instance, the write-image check, refused on a `select` / `delete` scope)",
203-
"note": "Planned with its container: no server reads `defaultRowScope` until the security plugin's `collectRLSPolicies` does."
198+
"status": "live",
199+
"verifiedAt": "2026-10-19",
200+
"evidence": "packages/plugins/plugin-security/src/security-plugin.ts#writeCheckPolicies (the policies that declare `check` when any applicable policy for the write does, otherwise each applicable policy's `using`); packages/plugins/plugin-security/src/rls-compiler.ts#compileFilter (`policyDeclaresClause(policy, 'check') ? check : policy.using` on the `check` pass)",
201+
"note": "Live with its container (#24340): the default is collected as one policy and passes the held policies' own applicability filter and compiler, so this member is read exactly where the permission-set `rowLevelSecurity` member of the same instance is."
204202
},
205203
"positions": {
206-
"status": "planned",
207-
"verifiedAt": "2026-10-18",
208-
"evidence": "packages/spec/src/security/rls.zod.ts#DefaultRowScopeSchema (declares `positions`: RowLevelSecurityPolicySchema's own member instance, the positions the scope applies to)",
209-
"note": "Planned with its container: no server reads `defaultRowScope` until the security plugin's `collectRLSPolicies` does."
204+
"status": "live",
205+
"verifiedAt": "2026-10-19",
206+
"evidence": "packages/plugins/plugin-security/src/rls-compiler.ts#getApplicablePolicies (`const domain = (policy as { positions?: string[] }).positions` — the applicability domain, matched flat against the caller's held positions)",
207+
"note": "Live with its container (#24340): the default is collected as one policy and passes the held policies' own applicability filter and compiler, so this member is read exactly where the permission-set `rowLevelSecurity` member of the same instance is."
210208
},
211209
"enabled": {
212-
"status": "planned",
213-
"verifiedAt": "2026-10-18",
214-
"evidence": "packages/spec/src/security/rls.zod.ts#DefaultRowScopeSchema (declares `enabled`: RowLevelSecurityPolicySchema's own member instance, whether the scope is active (default true))",
215-
"note": "Planned with its container: no server reads `defaultRowScope` until the security plugin's `collectRLSPolicies` does."
210+
"status": "live",
211+
"verifiedAt": "2026-10-19",
212+
"evidence": "packages/plugins/plugin-security/src/rls-compiler.ts#getApplicablePolicies (`(policy as { enabled?: boolean }).enabled === false` excluded before object / positions / operation matching; absent = active per the schema default)",
213+
"note": "Live with its container (#24340): the default is collected as one policy and passes the held policies' own applicability filter and compiler, so this member is read exactly where the permission-set `rowLevelSecurity` member of the same instance is."
216214
}
217215
}
218216
},

0 commit comments

Comments
 (0)