Skip to content

feat(permissions): allow opting out of implicit READ via READ: false#470

Closed
nicola-smartive wants to merge 1 commit into
mainfrom
feat/ZWEI-3796-permission-block-read-false
Closed

feat(permissions): allow opting out of implicit READ via READ: false#470
nicola-smartive wants to merge 1 commit into
mainfrom
feat/ZWEI-3796-permission-block-read-false

Conversation

@nicola-smartive
Copy link
Copy Markdown
Collaborator

Every PermissionsBlock previously emitted an implicit READ chain — the short-circuit action === 'READ' || action in block in both generatePermissions and addPermissions always pushed READ regardless of whether the block declared one. That made it impossible to declare a mutation-only sub-block (e.g. user: { UPDATE: true }) without also contributing a READ chain to the OR'd EXISTS subtree on the linked type.

This adds an explicit opt-out: set READ: false on any block to suppress the implicit READ-chain emission while keeping the other action grants intact. Default behavior is unchanged (omit READ ⇒ READ emitted as before; READ: true ⇒ same).

  • PermissionsBlock type widens READ?: boolean (other actions stay true-only).
  • Generated per-model ${Model}Permissions type widens READ?: boolean to match.
  • Both READ short-circuits switch to block.READ !== false.

Unblocks consumer-side cleanup of redundant implicit READ chains where the same path is already covered by a flatter grant on the same role — shrinks the OR'd EXISTS subtree on heavily-joined types like User.

Every `PermissionsBlock` previously emitted an implicit READ chain — the
short-circuit `action === 'READ' || action in block` in both
`generatePermissions` and `addPermissions` always pushed READ regardless
of whether the block declared one. That made it impossible to declare a
mutation-only sub-block (e.g. `user: { UPDATE: true }`) without also
contributing a READ chain to the OR'd EXISTS subtree on the linked type.

This adds an explicit opt-out: set `READ: false` on any block to suppress
the implicit READ-chain emission while keeping the other action grants
intact. Default behavior is unchanged (omit READ ⇒ READ emitted as
before; `READ: true` ⇒ same).

- `PermissionsBlock` type widens `READ?: boolean` (other actions stay
  `true`-only).
- Generated per-model `${Model}Permissions` type widens `READ?: boolean`
  to match.
- Both READ short-circuits switch to `block.READ !== false`.

Unblocks consumer-side cleanup of redundant implicit READ chains where
the same path is already covered by a flatter grant on the same role —
shrinks the OR'd EXISTS subtree on heavily-joined types like User.

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant