Repository navigation
Commit ed33f8a
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
File tree
- .changeset
- content/docs/permissions
- docs/adr
- packages/plugins/plugin-security/src
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
| 1 | + | |
| 2 | + | |
| 3 | + | |
| 4 | + | |
| 5 | + | |
| 6 | + | |
| 7 | + | |
| 8 | + | |
| 9 | + | |
| 10 | + | |
| 11 | + | |
| 12 | + | |
| 13 | + | |
| 14 | + | |
| 15 | + | |
| 16 | + | |
| 17 | + | |
| 18 | + | |
| 19 | + | |
| 20 | + | |
| 21 | + | |
| 22 | + | |
| 23 | + | |
| 24 | + | |
| 25 | + | |
| 26 | + | |
| 27 | + | |
| 28 | + | |
| 29 | + | |
| 30 | + | |
| 31 | + | |
| 32 | + | |
| 33 | + | |
| 34 | + | |
| 35 | + | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
18 | 18 | | |
19 | 19 | | |
20 | 20 | | |
21 | | - | |
| 21 | + | |
22 | 22 | | |
23 | 23 | | |
24 | 24 | | |
| |||
35 | 35 | | |
36 | 36 | | |
37 | 37 | | |
38 | | - | |
| 38 | + | |
39 | 39 | | |
40 | 40 | | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
63 | 63 | | |
64 | 64 | | |
65 | 65 | | |
66 | | - | |
67 | | - | |
| 66 | + | |
| 67 | + | |
| 68 | + | |
| 69 | + | |
| 70 | + | |
| 71 | + | |
68 | 72 | | |
69 | 73 | | |
70 | 74 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
84 | 84 | | |
85 | 85 | | |
86 | 86 | | |
87 | | - | |
| 87 | + | |
88 | 88 | | |
89 | | - | |
| 89 | + | |
| 90 | + | |
90 | 91 | | |
91 | 92 | | |
92 | 93 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
61 | 61 | | |
62 | 62 | | |
63 | 63 | | |
64 | | - | |
65 | | - | |
| 64 | + | |
| 65 | + | |
| 66 | + | |
| 67 | + | |
| 68 | + | |
| 69 | + | |
| 70 | + | |
66 | 71 | | |
67 | 72 | | |
68 | 73 | | |
| |||
0 commit comments