Skip to content

Commit ed33f8a

Browse files
fix(plugin-security)!: a predicate update or delete of a controlled_by_parent detail writes the rows its by-id writes do (#36282)
<!-- claude-projects-attribution: {"github_login":"os-project-manager"} --> _Requested by **Leehom** · [project thread](https://claude.ai/code/project/chan_01TenzsRopZj4jMbvjX8uz1X?thread=cmsg_01TenzsRopZj4jMbvjX8uz1X1qGnTYLQs3EtmtCmjrcfCe)_ Fixes #35802 Ruling-ref: 7073030861 — maintainer Leehom, 「A 批量与逐条一致」, answered by tap at 2026-11-22T02:37Z, recorded in comment 7073030861 on the card Clause-②: no (narrowing) Metadata-protocol: none Skills-docs: follow-up #36285 ## 维护者速读 - 用户能看到什么变化:有权编辑主记录的人,用流程的批量节点或服务端脚本按条件修改、删除它下面的明细时,现在会改到、删到全部明细,包括别人录入的;以前只动到本人录入的那几行,还报成功。 - 为什么做:外部搭建者在已发布版本上搭审批类应用时撞到的问题;这是你裁定的「批量与逐条一致」的落地,属于权限与共享这条线。 - 出错会怎样:升级后,现有流程会多改、多删到别人录入的明细;其中任何一行被规则拦下,整次拒绝、一行不动。合并后发现不对,可以整单撤回。另有一处反方向的变化:明细上如果应用自己写了行级的修改或删除规则,批量改删现在只动规则允许的行,本人录入但规则不允许的行不再被改。 - 要你做什么:这是收紧批量改删明细的改动,需要你本人审阅、批准并亲手合并。契约 PASS 7075099454,遗留问题由座位 7 复核 7076369115 关闭(head 4fe236d),三个小问题另立 #36365、#36367、#36285 跟进。请留意:明细上应用自己写的行级改删规则现在会限制批量改删,方向与 #35917 的裁定 7063130499 相反,复核记录认为它在你「批量与逐条一致」裁定第 1 项之内。 ## What changes The ruling's line, quoted: 「A 批量与逐条一致」 — 「有权编辑主记录的人批量改删明细时,改到逐条能改的全部行;其中一行被规则拦下就整次拒绝。升级后现有流程会多改到别人创建的行。一个PR。」 On a `controlled_by_parent` detail, an addressed predicate update or delete (`multi: true`) by a caller who is not acting on another user's behalf no longer keeps the platform ownership floor (`owner_only_writes` / `owner_only_deletes`) once the master gate has passed every master the write reaches. The rows it writes are the rows a by-id write of each would write for the same caller. - **The vouch** (`security-plugin-authz-middleware.ts`, step 2.8). Straight after the caller's own pass of the master gate returns, the middleware takes the gate's record of the rows it judged. That record is the coverage vouch for the predicate path, as step 2.7's position above the gate is for a by-id write. A delegated write, a nested or referential write, and a shape the gate does not judge take none and keep the floor. - **The row scope** (step 3). The write composes its Layer 1 with `masterGateCoversThisWrite`, and it is scoped to the gate's own row list instead of asking the read question a second time. This answers premise P3 of the ruling by reusing one id list: no row is written under the handed-over floor without its master having been judged. - **The per-row check** (step 3.6). A predicate update's stored-image check is composed on the same decision. - **The gate** (`security-plugin-cbp-write-gate.ts`). `judgeControlledByParentWrite` records, at the end of a predicate pass that refused nothing, the ids of the rows whose master reference it read. No verdict of the gate moves. - **Text.** ADR-0055 gains one dated amendment (a status line, one pointer under the superseded sentence of the 2026-11-14 amendment, and the section at the end); the older amendments are not rewritten. The `RlsFilterOptions.masterGateCoversThisWrite` docblock's "must not … a separate decision" bullet is replaced. `content/docs/permissions/permissions-matrix.mdx`, `sharing-rules.mdx` and `rls.mdx` say the new rule. One new changeset on the narrowing arm, and one release-note correction of the earlier sharing-half changeset (see DELIBERATE CORRECTION). No spec change, no new key, switch or response member: `Metadata-protocol: none`. The arm is narrowing by the ruling's item 5: a predicate write applies to all of its matched rows or to none, so a newly matched row that a row-level check, a validation rule, a hook or a `restrict` relation refuses now refuses a write that used to answer success. **An app-authored row-level write policy on the detail now bounds a predicate write alone.** Where an app authors an `update` or `delete` policy with a `using` on a `controlled_by_parent` detail, a predicate write used to compose the platform floor beside that policy as one more OR term, so it also wrote the rows the caller created that the policy does not admit. With the floor handed to the master gate (`security-plugin-rls-filter.ts`, the floor filter), the authored policy alone bounds the write and those rows are left unwritten. A by-id write of such a row was already refused, so this is by-id parity (ruling item 1). A write made on another user's behalf keeps the floor. The changeset states this case; `rls.mdx` already says it. ### Premises, checked before any code - **P1 holds**, measured on `origin/main` `a5a5312ff4` with the new pins against the unchanged source (real `SecurityPlugin`, `ObjectQL`, SQL driver, `SharingService`): 16 of the new cases red. The master's owner changed r1 and r3 by predicate (the two rows they created) against all 4 by id; the Modify All manager and the member with an edit share on the master changed none against all 4; a master reader on a `writeRequiresMasterRead` detail changed 2 against 4; the owner of null-master rows changed 1 against 2. - **P2 holds**, read at `a5a5312ff4`: the vouch was set by step 2.7, by the chain walk's master-edit leg and by `security/explain` only, and the gate judges every master of the rows a predicate write selects before step 3 composes Layer 1. - **P3 did not hold as it stood, and is closed in this PR**: the gate's row read and the write's readable-row scope were two reads of one question, so a row inserted between them, under a master the caller reads and may not edit, would have been written with no master judged once the floor is gone. The write now uses the gate's list. Pinned, and ablated red. ## Tests Head `2ba103da71`. <details><summary>plugin-security suite, typecheck and build</summary> `pnpm --filter @objectstack/plugin-security typecheck && pnpm --filter @objectstack/plugin-security build && pnpm --filter @objectstack/plugin-security exec vitest run --maxWorkers=2` under the verify lock: `Test Files 287 passed (287)`, `Tests 7238 passed | 45 skipped (7283)`, `VERDICT command-exit 0`. </details> <details><summary>The new pins</summary> `predicate-write-floor-deferral.test.ts`, a new top-level describe on the file's own rig. Each case runs the predicate write on one seeded copy and by-id writes on a second, and asserts equal sets row for row and the named set. Each of these, for predicate update and for predicate delete: - the master's owner: all 4 rows; - a member holding an edit share on the master who created none of the rows: all 4; - the Modify All manager: all 4; - a member who may not edit one of the masters: refused whole with `PERMISSION_DENIED` / 403, nothing written (by id: the 3 rows under the editable master); - a member who only reads the master: refused whole; - a detail declaring `writeRequiresMasterRead`, a master reader: all 4; - a detail declaring `ownerMayEdit`: the master's owner writes all 4; the row owner who only reads the master is refused whole (unchanged; by id they update their 2 rows and delete none); - null-master rows: their owner writes the 2 they own, the Modify All manager all 4; - a delegated write: only the rows the agent created (both floors kept). Plus: a newly matched row a `beforeDelete` hook refuses refuses the whole delete; and a row inserted after the gate's read is not written. `controlled-by-parent-detail-write-authority.test.ts`: the `§3 RESIDUAL` pin is flipped and its stale comment corrected. The composed predicate carries no floor where the gate admitted an addressed predicate write, the write is refused whole when it reaches a master the caller may not edit, and the floor stays on a write the gate does not judge. `controlled-by-parent-every-master-edit.test.ts` and `controlled-by-parent-write-shape-master-edit.test.ts` pinned the superseded outcome for a member's selecting write (the rows it created); they now expect every selected row, and keep the delegated case on the floor. </details> <details><summary>Ablations, each committed first, each restored and proved by blob hash</summary> Through `scripts/ablation-replace.mjs` (anchor 1 to 0, blob changed, restore blob equal to HEAD and `git diff HEAD` empty on every leg), over the four test files above. The tests import source, so there is no dist hop. 1. The vouch set to `null`: 22 failed, 107 passed. Every equality pin, the hook case, the late-row case, the flipped pin and the two write-shape suites. 2. The delegated exclusion removed: 2 failed, 127 passed. The delegated update and delete wrote all 4 rows. 3. The gate's row list replaced by a second read: 1 failed, 128 passed. The late row was written. 4. The per-row check left on the floor: 13 failed, 116 passed. The predicate updates were refused whole; the deletes stayed green, as expected. </details> <details><summary>Dogfood battery</summary> Run once, on the final head `2ba103da71`, with CI's command: the closure built first (`pnpm --filter '@objectstack/dogfood^...' build`, `VERDICT command-exit 0`), then `pnpm --filter @objectstack/dogfood test` under the verify lock, no shard and no path. `Test Files 484 passed | 3 skipped (487)`, `Tests 4107 passed | 68 skipped (4175)`, `VERDICT command-exit 0`. No failure. </details> ## Acceptance notes - **Files outside the dispatched surface, edited under the bounded in-place rule and named here.** `packages/plugins/plugin-security/src/security-plugin-rls-filter.ts`: one comment that said the bulk path "does not and must not" vouch, which this change makes false (comment only). `content/docs/permissions/rls.mdx`: one sentence that said a predicate write on a detail keeps the floor, a published statement this change makes false. The two write-shape test files above pinned the superseded outcome. `scripts/pm/overlap-check.mjs` at this head: `VERDICT clean`, no open PR shares any of the 14 files at `2ba103da71`. At the current head the PR has 15 files, +576/−59: the two later rounds changed only the two changeset files. - **Not updated here:** `skills/objectstack-data/rules/relationships.md` still says the ownership floor binds a predicate update or delete on a `writeRequiresMasterRead` detail. It is a published skill and belongs to a skills PR; see the `Skills-docs:` line. - **The earlier changeset for the sharing half** (`.changeset/35802-predicate-write-floor-deferral.md`) said a `controlled_by_parent` detail keeps the floor on a predicate write. It is corrected in this PR, release text only: see DELIBERATE CORRECTION below. The two notes now cross-reference each other. - **The sharing relief is skipped on a vouched write.** With the floor handed to the gate there is no floor left to replace, so no sharing verdict is asked for such a write. The skip is not pinned by a case of its own: on these fixtures the relief would answer nothing either way. - **One read fewer.** A predicate write of such a detail asked the read door for its rows twice (the gate, then the readable scope) and now asks once. - **`ownerMayEdit` and the whole-write refusal are the two places a predicate write and the by-id writes still differ**, both in the refusing direction and both stated in the ruling (items 2 and 4). ## Follow-ups from the contract review Nits of record 7076369115 (PASS at `4fe236dbd1`). Each is carried by a queued card, not fixed here, so the head stays on that record: - **N1 and N5:** the ADR-0055 amendment and the `sharing-rules.mdx` / `permissions-matrix.mdx` wording about the authored-policy outcome and the `ownerMayEdit` leg. Carried by #36365. - **N3:** pins for the authored-policy outcome and the skipped sharing relief on the vouched path. Carried by #36367. - **N4:** the skills eval `skills/objectstack-data/evals/objects-fields-relationships.json` (eval 17) is named on #36285 in comment 7075133273. Carried by #36285. ## DELIBERATE CORRECTION One pending release note is corrected, release text only: `.changeset/35802-predicate-write-floor-deferral.md` (the sharing half, unreleased). It ships in the same `@objectstack/plugin-security` CHANGELOG entry as this PR's note and said the opposite of it in two sentences. `check-empty-changeset` is red on it, as it should be; no `skip-changeset`. 1. Paragraph 4. - Before: "A row the service abstains on keeps the floor: on an object with no `owner_id`, on a delete under `public_read_write` (an update there has no floor to keep, because that OWD opens row updates), and on a `controlled_by_parent` detail unless an update's row sits in a queue the caller belongs to. A row it denies keeps the floor too." - After: "A row the service abstains on keeps the floor: on an object with no `owner_id`, and on a delete under `public_read_write` (an update there has no floor to keep, because that OWD opens row updates). A row it denies keeps the floor too." 2. The last "What does not change" bullet. - Before: "A `controlled_by_parent` detail keeps the floor on a predicate write, except on an update of a row that sits in a queue the caller belongs to, which the sharing service answers `allow` for under any OWD. The master gate still judges the predicate write. Its by-id write is decided by the master gate instead of the floor, and that half is not changed here." - After: "A `controlled_by_parent` detail is not decided by this composition. Its predicate write, like its by-id write, is decided by its master gate instead of the floor: see the note "a predicate update or delete of a `controlled_by_parent` detail now writes every row its caller may write by id"." This PR's own note (`.changeset/35802-cbp-predicate-write-master-gate.md`) drops "whose bullet … no longer holds" for a plain cross-reference: "This is the `controlled_by_parent` half of the predicate-write change shipped beside it: see the note "a predicate update or delete now writes the rows a Modify All holder, a non-creator owner or an edit-share target can write by id" for every other object." ## Verification Read first, by risk: 1. `packages/plugins/plugin-security/src/security-plugin-authz-middleware.ts`: the hunk in step 2.8 that takes the vouch, and the step 3 hunk that passes it and scopes the write to the gate's rows. This is where a widening would live. 2. `packages/plugins/plugin-security/src/security-plugin-cbp-write-gate.ts`: where the record is written, after every refusal of the predicate leg. 3. `docs/adr/0055-master-detail-controlled-by-parent.md`: the 2026-11-22 amendment. Two-minute check: `pnpm --filter @objectstack/plugin-security exec vitest run --maxWorkers=2 src/predicate-write-floor-deferral.test.ts`. Expect `Tests 75 passed (75)`, 24 of them under "a predicate write of a controlled_by_parent detail writes the rows its by-id writes do". <details><summary>Gates</summary> Derived with `node scripts/pm/dispatch-gates.mjs --commands --repo objectstack-ai/objectstack` at `2ba103da71` (14 paths against merge base `a5a5312ff4`): 107 families, each run once after the last commit with its exit code captured before any pipe. `dispatch-gates --ran`: "107 derived famil(ies) accounted for — 104 run, 3 NOT-MEASURED (3 DERIVED from a recorded exit 3)", exit 0. - 104 exit 0. Two of them on a second run: `pnpm check:dts-closure` first exited 1 naming packages this worktree had not built yet, and `pnpm check:i18n` first exited 3; both exit 0 once the dogfood closure was built. - NOT MEASURED, PREREQUISITE NOT MET (exit 3), left to CI: `pnpm --filter @objectstack/spec run check:skill-examples` and `pnpm check:dual-build-cjs-loads` read the dist of packages outside the closures built here; `pnpm check:type-check-debt` did not get its turn on the shared verify lock for its own closure build (queue-timeout, twice). - `node scripts/check-platform-checklist.mjs --changed-from origin/main`: "OK — 2 anchored file(s) in the change set, 6 anchor(s) judged, 0 lost", exit 0. `node scripts/check-nul-bytes.mjs`: exit 0. - Not run locally, by rule: the repo-wide lint and `test:repo` (CI-owned; the diff touches none of its tests). </details> 🤖 Generated with [Claude Code](https://claude.com/claude-code) <!-- signed: repo:objectstack#4 · os-project-manager · session_01FEkQ5krBqrrgxCYgjXmfbv --> --------- Co-authored-by: Claude <noreply@anthropic.com>
1 parent fd471d3 commit ed33f8a

15 files changed

Lines changed: 576 additions & 59 deletions
Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,35 @@
1+
---
2+
'@objectstack/plugin-security': patch
3+
---
4+
5+
fix(plugin-security)!: a predicate update or delete of a `controlled_by_parent` detail now writes every row its caller may write by id, the rows other users created included, instead of stopping at the platform's creator-only floor
6+
7+
Clause-②: no (narrowing)
8+
Metadata-protocol: none
9+
10+
<!-- adr-0087: not-required (no-migration-prescription) No key of any schema is added, removed, renamed or re-shaped, and no export changes shape. What moves is which rows one predicate update or delete of a controlled_by_parent detail writes, and whether such a write is refused whole: no stored row, registry key or authored value changes, so there is nothing for a migration to rewrite and no tombstone. -->
11+
12+
**BREAKING: an existing flow now changes or deletes detail rows its caller did not create.** A flow's bulk update or bulk delete node, a server-side script or a hook that runs a predicate write (`update(object, data, { where, multi: true })`, `delete(object, { where, multi: true })`) on a `controlled_by_parent` detail, as an organization member who may edit the master record (or read it, where the detail declares `sharing.controlledByParent.writeRequiresMasterRead`), used to change or delete only the detail rows that member had created and answer success. It now changes or deletes every row its predicate matches that the member can read, within any row-level `update` or `delete` policy the app authored on the detail. Review any such flow that deletes by predicate before upgrading: it will delete more rows than it did.
13+
14+
It ships `patch` because it is a non-protocol breaking change (AGENTS.md Post-Task Checklist step 3): no schema, key or stored value moves, so `Metadata-protocol` is `none`.
15+
16+
- FROM: on a `controlled_by_parent` detail the predicate write kept the platform ownership floor (`owner_only_writes` / `owner_only_deletes` in `member_default`, `created_by == current_user.id`) after its master check had passed. It matched only the rows the caller created, answered success, and never judged the other rows. Measured on a 4-row detail under one master: the master's owner changed 2 rows by predicate and all 4 by id; a member holding an `edit` share on the master, and a manager holding `modifyAllRecords`, changed 0 by predicate and all 4 by id.
17+
- TO: once the master check has passed for every master the write reaches, the write is no longer held to that floor. It changes the rows a write of each row by id would change for the same caller, and it applies to all of its matched rows or to none: a newly matched row refused by a row-level `check`, a validation rule, a hook or a `restrict` relation refuses the whole write with that refusal, and nothing is written.
18+
19+
**A detail that carries its own row-level write policy now writes fewer of the caller's own rows by predicate.** Where an app authors an `update` or `delete` policy with a `using` on a `controlled_by_parent` detail, a predicate write used to compose the platform floor beside that policy as one more OR term, so it also wrote the rows the caller created that the policy does not admit. The floor is no longer a term of that write, so the authored policy alone bounds it: those rows are left unwritten and the write answers success for the rows the policy admits. A by-id write of such a row was already refused, so the two now agree. A write made on another user's behalf keeps the floor and is not changed.
20+
21+
The fix for a caller that must keep the old outcome: narrow the predicate to the rows it means to write (add `created_by` to the `where` to keep writing only the caller's own rows), or write the rows by id to get an outcome per row. To forbid a caller from writing rows other users created on a detail, author a row-level policy on the detail; it binds every row, by id and by predicate.
22+
23+
This is the `controlled_by_parent` half of the predicate-write change shipped beside it: see the note "a predicate update or delete now writes the rows a Modify All holder, a non-creator owner or an edit-share target can write by id" for every other object. It follows the maintainer's ruling that a predicate write and a by-id write of such a detail agree (ADR-0055 §3 as amended 2026-11-22).
24+
25+
What does not change:
26+
27+
- A predicate write reaches only the rows its predicate matches that the caller can read, and a predicate matching more than 10,000 of them is refused before anything is written.
28+
- It is refused whole, with `PERMISSION_DENIED` / 403 and nothing written, when it reaches a detail row under a master the caller may not edit (or may not read, where the detail declares `writeRequiresMasterRead`).
29+
- A detail row that names no master (an optional master) is written by its owner or a Modify All holder; a predicate write that reaches such a row the caller can read and may not write is refused whole.
30+
- A write made on another user's behalf keeps the floor for both principals, as its by-id write does.
31+
- `sharing.controlledByParent.ownerMayEdit` widens a by-id update only: a predicate update still needs edit on the master.
32+
- A by-id write is unchanged, and so is every predicate write on an object that is not a `controlled_by_parent` detail.
33+
- No key, option or response member is added.
34+
35+
A predicate write on such a detail also asks the read door for its rows once where it asked twice: the write is scoped to the rows its master check judged, so a row that starts matching the predicate while the write is being authorized is not written.

‎.changeset/35802-predicate-write-floor-deferral.md‎

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ The fix for a caller: write those rows by id to get an outcome per row, or narro
1818

1919
A predicate write (`update(object, data, { where, multi: true })`, `delete(object, { where, multi: true })`) by an organization member held the platform's own ownership floor (`owner_only_writes` / `owner_only_deletes` in `member_default`, `created_by == current_user.id`) as an unconditional condition, where record sharing enforces writes. Unless an app-authored write policy admitted a row, the write matched only the rows that member had created, even when the same user could update or delete the other matching rows one at a time by id. This affected a manager holding `modifyAllRecords` on the object, a row's owner who did not create it, and, for an update, the target of an `edit`-level record share or a member of the queue a row sits in. The write answered success and changed fewer rows than its predicate matched. A write by id lets the record-sharing service's `allow` verdict replace the floor.
2020

21-
The predicate write now makes the by-id decision for each matched row the floor would refuse. Such a row is written when a write of that row by id would be, because the sharing service answers `allow` for it: ownership at the caller's write depth, Modify All, or, for an update only, an `edit` share or the row's queue. A row the service abstains on keeps the floor: on an object with no `owner_id`, on a delete under `public_read_write` (an update there has no floor to keep, because that OWD opens row updates), and on a `controlled_by_parent` detail unless an update's row sits in a queue the caller belongs to. A row it denies keeps the floor too. The row-level `check` on each updated row follows the same decision.
21+
The predicate write now makes the by-id decision for each matched row the floor would refuse. Such a row is written when a write of that row by id would be, because the sharing service answers `allow` for it: ownership at the caller's write depth, Modify All, or, for an update only, an `edit` share or the row's queue. A row the service abstains on keeps the floor: on an object with no `owner_id`, and on a delete under `public_read_write` (an update there has no floor to keep, because that OWD opens row updates). A row it denies keeps the floor too. The row-level `check` on each updated row follows the same decision.
2222

2323
The by-id decision costs one sharing verdict, a few store reads, for each matched row the floor does not already admit. Measured on SQLite in memory:
2424

@@ -35,6 +35,6 @@ What does not change:
3535
- An `edit` share still widens update and never delete.
3636
- The tenant wall is unchanged.
3737
- A write made on another user's behalf keeps the floor for both principals, as its by-id write does.
38-
- A `controlled_by_parent` detail keeps the floor on a predicate write, except on an update of a row that sits in a queue the caller belongs to, which the sharing service answers `allow` for under any OWD. The master gate still judges the predicate write. Its by-id write is decided by the master gate instead of the floor, and that half is not changed here.
38+
- A `controlled_by_parent` detail is not decided by this composition. Its predicate write, like its by-id write, is decided by its master gate instead of the floor: see the note "a predicate update or delete of a `controlled_by_parent` detail now writes every row its caller may write by id".
3939

4040
A flow, script or server-side bulk update or delete that relied on a predicate write skipping the rows its caller did not create now changes those rows too, when the caller may write them by id, and is refused whole when one of them is refused. The fix is the one above.

‎content/docs/permissions/permissions-matrix.mdx‎

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -63,8 +63,12 @@ by-id write and a predicate write both take that replacement unless an
6363
app-authored `using` policy for the write applies to the caller; then the write
6464
keeps the floor beside that policy, so a row the caller created stays writable
6565
and the policy bounds every other row. A write made on another user's behalf
66-
keeps the floor. A `controlled_by_parent` detail's by-id write is
67-
judged by its master gate instead of the floor. An app-authored policy is never
66+
keeps the floor. A `controlled_by_parent` detail's write, by id or by
67+
predicate, is judged by its master gate instead of the floor: a caller who may
68+
edit the master (or read it, where the detail declares
69+
`writeRequiresMasterRead`) writes the detail rows under it whoever created
70+
them, and a predicate write that reaches a master the caller may not write
71+
under is refused whole. An app-authored policy is never
6872
replaced. The Layer 0 tenant wall always ANDs on top. See
6973
[Sharing & OWD](/docs/permissions/sharing-rules#how-viewallrecords--modifyallrecords-interact-with-the-owd)
7074
and `plugin-security/src/security-plugin.ts` (`computeLayeredRlsFilter`).

‎content/docs/permissions/rls.mdx‎

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -84,9 +84,10 @@ does not take away a row the floor admits (one the caller created), whether
8484
or not record sharing replaces the floor for that row. Two exceptions: on an
8585
object whose org-wide default is `public_read_write`, an `update` has no floor,
8686
so an authored `update` policy is the whole scope and does refuse the caller's
87-
own non-matching row; and on a `controlled_by_parent` detail, a by-id write is
87+
own non-matching row; and on a `controlled_by_parent` detail, a write is
8888
judged by its master gate instead of the floor, so a detail policy bounds every
89-
detail row written by id (a predicate write on a detail keeps the floor). To cap what a caller
89+
detail row written, by id or by predicate (a write made on another user's
90+
behalf keeps the floor). To cap what a caller
9091
may do to rows they created, use a `check` (it judges the stored image) or a
9192
`beforeUpdate` / `beforeDelete` lifecycle hook (it sees the prior row as
9293
`ctx.previous`). Nothing is derived for `insert`

‎content/docs/permissions/sharing-rules.mdx‎

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -61,8 +61,13 @@ Two things the bits do **not** override, regardless of the OWD:
6161
`org_member`). Under `public_read_write` the update policy does not apply
6262
(that OWD opens row updates) and the delete policy does; under every other
6363
OWD both apply, and record sharing can replace them row by row, as below.
64-
A `controlled_by_parent` detail's by-id write is judged by its master gate
65-
instead. The super-user bits short-circuit RLS **only
64+
A `controlled_by_parent` detail's write is judged by its master gate
65+
instead, by id and by predicate alike: a caller who may edit the master (or
66+
read it, where the detail declares `writeRequiresMasterRead`) updates and
67+
deletes the detail rows under it whoever created them. A predicate
68+
(`multi: true`) update or delete writes the rows a by-id write of each
69+
would, and is refused whole, with nothing written, when it reaches a master
70+
the caller may not write under. The super-user bits short-circuit RLS **only
6671
where the object's access posture permits it** — `access: { default:
6772
'private' }`, `tenancy.enabled: false` (deployment-level: no organization column), or better-auth
6873
managed objects (ADR-0066 D2 ①). On an ordinary tenant business object,

0 commit comments

Comments
 (0)