Skip to content

fix(plugin-security)!: a predicate write composes the platform ownership floor per row, as the by-id write does - #35914

Merged
os-zhuang merged 13 commits into
mainfrom
claude/issue-35802-predicate-write-floor-deferral
Nov 21, 2026
Merged

os-zhuang merged 13 commits into
mainfrom
claude/issue-35802-predicate-write-floor-deferral

Conversation

@objectstack-fleet

@objectstack-fleet objectstack-fleet Bot commented Nov 20, 2026 •

Copy link
Copy Markdown
Contributor

repo:objectstack#7 · os-tesla · session_01L9qibvVRcFWKrfWeG5jzPb

Part of #35802 (the controlled_by_parent half of the card's repro is left for a decision, see Acceptance notes)

Clause-②: no (narrowing)
Metadata-protocol: none
Skills-docs: none — skills/objectstack-data/rules/security.md (lines 69–70) already teaches that a check is judged on every row a multi: true update writes and one failing row refuses the write; no skill teaches that a predicate write skips rows the caller did not create.

维护者速读

  • 业务用户用条件批量修改或删除(流程、脚本、服务端批量更新)时,拥有「修改全部」的经理、不是创建人的记录负责人、以及被授予「编辑」共享的人(仅修改),现在能改到他们逐条修改也能改的那些记录;以前只改到自己创建的记录,结果照样报成功。
  • 属于记录级权限,替在 18.6.0 上搭审批对象的外部开发者解决「批量改悄悄少改」的问题,延续之前逐条修改那次修复;两页权限文档同步改正。
  • 这是一次需申报的收紧:新纳入的某一行若不满足检查规则、或在删除前被拦截规则拒绝,整次批量修改或删除会被拒、一行都不动,以前会只处理创建人的那几行并报成功;普通成员批量改大量别人的记录会变慢(一万行约五秒)。出问题可以直接撤回本 PR,不涉及数据迁移。
  • 要你定一件事:新纳入的行被检查规则或删除拦截拒绝时整次拒绝(本 PR 现状,已按收紧申报),还是改为跳过该行只处理其余的。

What changes

packages/plugins/plugin-security only. The #5492 floor composition (the sharing service's allow replaces the platform's own owner_only_writes / owner_only_deletes; abstain and deny keep it) now runs per matched row on the PREDICATE write path, which never reached it because it sits under extractSingleId(opCtx) != null in step 2.7.

  • Step 3, RLS injection (security-plugin-authz-middleware.ts). For an addressed predicate update or delete (addressedPredicateWrite) by a non-delegated caller, after the existing read question (readableRowsScopeForPredicateWrite, the readable ids the caller's predicate matches, capped at 10,000 with a refusal above), when the platform floor is in play for the caller (predicateWriteFloorRelief):
    1. replaced: computeLayeredRlsFilter with dropPlatformOwnershipFloor, the Layer 1 the by-id write of a row composes once its floor is replaced. Where it is not null, an authored using policy remains, and the relief answers null with no read and no verdict. Policies compose by OR only, so a row floored refuses fails every authored policy too, and its by-id write is refused as well: replacing the floor can add no row there (L2 S2);
    2. one read, under the caller's context, of which matched ids the floored Layer 1 already admits; nothing is asked about them;
    3. for every other matched id, the by-id gate's own floor decision, resolvePreImageFloorDrop (predicateWriteFloorDropIds, new in security-plugin-sharing-verdicts.ts, asked in batches of 25);
    4. Layer 1 becomes floored OR id IN dropIds. Layer 0 is recomposed exactly as it stood.
  • Step 3.6, the per-row check. A predicate update's row whose floor step 3 replaced is held to the check computeWriteCheckFilter composes with dropPlatformOwnershipFloor (what step 2.7 passes for a by-id allow); every other row keeps checkParts. Without this the floor's using, defaulted as the check, refused on the new row the write it had just admitted (ablation leg 2 below).
  • Docs. content/docs/permissions/permissions-matrix.mdx and content/docs/permissions/sharing-rules.mdx said that modifyAllRecords does not lift member_default's owner-scoped write policies on an ordinary business object, and that members stay owner-scoped on writes even under public_read_write. The first has been false by id since Row-level write gate consults neither modifyAllRecords nor sys_record_share.access_level — both declared write-widening mechanisms are inert #5492, and this PR makes it false by predicate too. The second has been false for update since A public_read_write object is only writable by the row's creator — showcase_contributor gets 403 editing a showcase_project it can read, where the access matrix declares edit:true #8023. Both pages now say: the floor is creator-only (created_by == current_user.id). Under public_read_write the update floor does not apply and the delete floor does; with no owner_id both apply. Where record sharing enforces writes (an owner_id and a private or public_read OWD), the sharing service's allow for a row replaces the floor for that row: ownership at write depth or modifyAllRecords, and, for an update, an edit share. On an update, a row in a queue the caller belongs to gets the same allow under any OWD. A by-id write takes the replacement, and so does a predicate write unless an authored using policy for the write applies to the caller. An on-behalf-of write keeps the floor. A controlled_by_parent detail's by-id write is judged by its master gate. An app-authored policy is never replaced.
  • Changeset. It declares Clause-②: no (narrowing) with a BREAKING banner covering a predicate update and a predicate delete (the FROM and TO, and the fix for a caller), one ADR-0087 disposition (not-required, category no-migration-prescription), and the measured verdict cost.
  • Untouched: Layer 0, every app-authored policy (where one remains, no row is added), the verb boundary (delete asks checkDelete, and the sharing middleware's bulk delete scope stays owner-only), ADR-0066 ① (Modify All does not skip business RLS on an ordinary object), the delegated path (both floors kept, as on the by-id path), nested predicate writes (no readable-id list, floor kept), and masterGateCoversThisWrite (never set on the predicate path).

Why

#35802, measured on 18.6.0 by an outside builder: a predicate update by a Modify All manager or a non-creator owner changed only the rows the caller created and answered success. Measured on this branch with the fix ablated (= origin/main f44758b), rows changed by a predicate write over the 4-row owner x creator matrix vs the by-id path:

caller verb predicate, before by id predicate, after
(a) ALICE, owns r1 r2, created r1 r3 update r1 r1 r2 r1 r2
(a) ALICE delete r1 r1 r2 r1 r2
(b) BOB, owns r3 r4, created none update none r3 r4 r3 r4
(b) BOB delete none r3 r4 r3 r4
(c) CAROL, created r2 r4, owns none update none none none
(c) CAROL delete none none none
(d) Modify All manager update none r1 r2 r3 r4 r1 r2 r3 r4
(d) Modify All manager delete none r1 r2 r3 r4 r1 r2 r3 r4
edit-share target, shares on r2 r3 update none r2 r3 r2 r3
edit-share target delete none none none

Tests

New src/predicate-write-floor-deferral.test.ts, 29 cases, on the isolated tenancy posture so Layer 0 is composed on every write: the real SecurityPlugin over a real ObjectQL + SqlDriver (better-sqlite3), the real SharingService and its middleware, and the shipped member_default floor (the rig of controlled-by-parent-owner-may-edit.test.ts). Each case runs the predicate write on one copy of the matrix and a by-id write of each id on a second copy, asserts the two sets are equal row for row, and names the expected set. Cases: the four callers and the edit-share target, each x predicate update and predicate delete (the edit-share delete stays floored: ADR-0111 D3); a Modify All holder under an authored update policy (stage == 'open'), which still binds the rows whose floor is replaced; the CONTROL, an owner-less object where sharing abstains, both verbs, where a member still changes only the rows they created; and a row outside the predicate is never touched. Round 2 adds: the verdicts each predicate write asked, recorded on the real sharing service (the floor-admitted rows are never asked about; a delete asks checkDelete and never checkEdit; no verdict under an authored using policy); five on-behalf-of cases (BOB for CAROL, a member with Modify All, both verbs; ALICE for CAROL; ALICE for ERIN, an admin with Modify All, both verbs), each equal to the by-id set; the owner-creator under an authored widener writing the closed row she created, as before; the S1 case below; 60 candidates across three verdict batches; the composed predicate still naming the organization (Layer 0); idsOfReadableScope keeping bigint ids; and three direct pins on predicateWriteFloorDropIds (the verb it is handed, delegation, at most 25 in flight). The objects are ordinary tenant business objects on purpose: on a tenancy-disabled object a Modify All holder skips business RLS entirely and the floor would never be composed (measured: the first draft of the file used tenancy.enabled: false and its manager cases passed for that reason).

A new file rather than a describe in row-write-widener-composition.test.ts (the #5492 file): that file's engine double cannot run a predicate write's composed AST, the nested read questions, or the sharing middleware's bulk scope, and each of them decides a row here.

Acceptance notes

  • The admit set is a union; the outcome is not (L2 S1, ruled option (b), declared as a narrowing). Layer 1 is floored OR id IN dropIds: every row it adds is one the by-id path admits for the same caller, and no row today's predicate write matches is removed. But a predicate update applies to all of its matched rows or to none. Measured: ALICE under a check-only policy (region == 'emea'), r1 hers and EMEA, r2 hers, created by CAROL, in APAC. Before this PR the predicate update answered success with r1 written. On this head it is refused whole, PERMISSION_DENIED 403, nothing written. By id, r1 is written and r2 is refused 403. The same follows from a validation rule, a hook or a readonlyWhen lock on a newly matched row. Option (b) keeps the update all-or-nothing and declares it: the changeset carries the BREAKING banner (FROM: success with r1 written; TO: 403 PERMISSION_DENIED, nothing written) and the fix for a caller (write those rows by id to get an outcome per row, or narrow the predicate to the rows that pass the check). The maintainer confirms the arm on a decision card, and the PR stays a draft until then. The case is pinned as the declared answer, and ablation A8 below shows the pin goes red when the newly admitted rows skip the step 3.6 check.
  • The delete half of the narrowing (L2 S5), measured. A predicate delete also applies to all of its matched rows or to none. ALICE's predicate delete over the matrix now matches r1 and r2. With a beforeDelete hook refusing r2, it is refused whole with the hook's 409 and deletes nothing. By id, r1 is deleted and r2 is refused 409. A Modify All holder's predicate delete now matches all four rows, and is refused whole the same way. With the relief ablated (A9 below, origin/main's predicate path), both deletes answer success, so both pins go red. A restrict relation on a newly matched row refuses the whole delete the same way; that is pinned at the engine in engine-cascade-delete-atomic.test.ts and was not re-measured here. The changeset banner now covers delete, and it no longer says a validation refusal comes back the same way as the check's 403 (N7).
  • Measured corner where the two paths still differ, as before this PR: an owner-creator holding an authored update widener (stage == 'open') on a CLOSED row they created and own. By id: 403, because dropping the floor from an OR of permissive policies leaves the widener alone. By predicate: written, as before. Pinned. Reported as a by-id finding, not copied.
  • Not fixed here: the card's own repro object. On a controlled_by_parent detail, record sharing abstains (except on an update of a row that sits in a queue the caller belongs to) and the by-id write drops the floor through masterGateCoversThisWrite (the master gate), which RlsFilterOptions documents the bulk path must not set ("a separate decision"). Measured on this branch with the same rig: the master's owner, predicate update over 4 detail rows changes r1 r3 (created by them), by id all 4; a Modify All manager, predicate 0, by id 4. Hence Part of. Measured in round 4 with a scratch rig (not committed): a member who sits in queue q_ops and may edit the master predicate-updates two detail rows, neither created by them, both with no owner. The one in q_ops is written (the sharing service answers allow, so the floor is replaced) and the one in q_other is not. By id, the master gate admits the row. A member who may not edit the master is refused 403 by the master gate on the predicate write too (requires edit access to its master record). So the queue basis never takes a predicate write past the master gate, and the changeset's controlled_by_parent line now names this exception.
  • Cost, measured (SQLite in memory, shared box, one run each; origin/main, then this head). A member updating 1,000 readable rows owned by others: 44 ms with 3 driver reads, then 1,085 ms with 1,000 checkEdit and 2,004 reads, writing 0 rows either way. The same at 10,000: 47 ms, then 5,298 ms with 10,000 verdicts and 20,004 reads. A Modify All holder at 10,000: 47 ms writing 0 rows, then 1,796 ms with 10,000 verdicts and 10,003 reads, writing all 10,000. A Modify All holder under an authored using policy, 10,000 closed rows: 1,629 ms with 10,000 verdicts at the round-1 head, then 45 ms with none on this head (S2). Bounded by the existing 10,000 readable-row cap, which refuses above it before anything runs. The changeset names all four numbers. The follow-up bulk write scope and verdict contract on the sharing service is its own card.
  • Nested predicate writes (a hook's or cascade's own write under the caller's context) are not addressed predicate writes, carry no readable-id list, and keep the floor as before.
  • Response shape unchanged: no "rows dropped by the floor" report was added.
  • Not taken from L2: N3 (a !preImageFloorOpts guard on the relief). Measured on the compare-and-set shape, BOB updating where: { id: r4, stage: 'open' }, multi: true: origin/main writes nothing (1 verdict), this head writes r4 (2 verdicts), and this head with the guard writes nothing again (1 verdict). Step 3 does not read step 2.7's decision, so the guard would bring the reported under-write back on that shape. The cost is one extra verdict for one row. N6 (image.id) is also not taken: a predicate update never carries a truthy payload id (resolveEngineUpdateDispatch routes it by id, or refuses), and a falsy one is never in dropIds.

Verification

Read first, by risk:

  1. security-plugin-authz-middleware.ts, predicateWriteFloorRelief (end of file): the union and the floor-admitted read.
  2. security-plugin-authz-middleware.ts, step 3.6 hunk (floorDropJudge): which rows get the floor-replaced check.
  3. security-plugin-sharing-verdicts.ts, predicateWriteFloorDropIds: the per-row by-id decision.

Two-minute check: pnpm --filter @objectstack/plugin-security exec vitest run src/predicate-write-floor-deferral.test.ts shows 29 passed. Flip if (rlsFilter && layered.layer1 && !delegatorSets) to if (false && ...) and the matrix cases go red.

Round 4 readings are at head c5208e4597, and the final head is 35ef59a3ff. Since round 3 the branch adds two delete pins to the test file and prose in the changeset and the two docs pages. 35ef59a3ff changes only the banner's first sentence, and the 17 derived families that read a changeset all re-ran at it with exit 0, check:adr-0087-registration and check-changeset-no-major among them. No package source changed, so the round 3 dogfood battery at 6ff08df403 still reads the same plugin code; it was not re-run. origin/main was not merged again, because 4 new main commits would have moved the code the battery read. The round 2 ablations ran on 7b89b3ceb4, with the same plugin code.

plugin-security typecheck and suite: all green at c5208e4
  • pnpm typecheck then the full suite, in the package, under the lock: VERDICT command-exit 0. check:test-typecheck: OK ... 0 file(s) / 0 error(s); Test Files 285 passed (285), Tests 7097 passed | 45 skipped (7142) (round 3: 7095; the two new delete pins).
  • New file alone at a98bd1ee57: Tests 29 passed (29), lock VERDICT command-exit 0.
  • Round 3, at 6ff08df403: pnpm typecheck then pnpm build, lock VERDICT command-exit 0, check-dts-emitted: @objectstack/plugin-security - 2/2 declared declaration file(s) present.
Round 4 ablation A9: without the relief, both delete pins answer success and go red

This ran through scripts/ablation-replace.mjs in wrap mode at a98bd1ee57, and ran only the S5 cases (-t S5, 27 skipped). The relief guard became if (rlsFilter && layered.layer1 && !delegatorSets && false) {, which is origin/main's predicate path. The anchor went from 1 hit to 0, the marker counted 1 on disk, and the blob moved 869cbad82cdf -> 7a00ce83b134. Result: RED, 2 of 2: AssertionError: the predicate delete is refused: expected null not to be null for ALICE and for the Modify All holder. Without the relief, both predicate deletes answer success: the FROM of the banner. Restore: blob after restore == HEAD (869cbad82cdf), and git diff HEAD is empty.

Dogfood battery (owed by the narrowing): green at 6ff08df

The closure was built first: pnpm --workspace-concurrency=2 --filter '@objectstack/dogfood^...' build, lock VERDICT command-exit 0. Then, under the lock, with no shard and no path: pnpm --filter @objectstack/dogfood test. Result: lock VERDICT command-exit 0 (held 40m40s), Test Files 482 passed | 3 skipped (485), Tests 4098 passed | 68 skipped (4166). No test failed.

Round 3 ablation A8: the S1 pin goes red when the newly admitted rows skip the step 3.6 check

This ran through scripts/ablation-replace.mjs in wrap mode, at 6ff08df403. The step 3.6 line became if (!(floorReplaced ? true : satisfiesCheck(row))) denyCheck();, so a row whose floor step 3 replaced passes the check unconditionally. The anchor went from 1 hit to 0, the marker counted 1 on disk, and the blob moved 869cbad82cdf -> 2e088580e5c0. Result: RED, 1 of 27, the S1 pin alone: AssertionError: the predicate update is refused: expected null not to be null. With the check skipped, the update answered success. Restore: blob after restore == HEAD (869cbad82cdf), and git diff HEAD is empty.

Round 2 ablations: 7 legs red, 1 equivalent mutant, every restore clean

Each leg ran through scripts/ablation-replace.mjs in wrap mode: the anchor hit once and then zero times, the blob moved, the file ran, and the restore proved blob == HEAD with git diff HEAD empty.

  • Verb ('update' in place of rlsOperation in the relief), blob 869cbad82cdf -> 3f018c0744b9. The round-1 pins (14, run beside it) stay GREEN, as the L2 predicted: the sharing middleware's bulk delete scope is the owner set, so no row moves. The new verdict pins go RED, 2 of 27: ALICE's and DAVE's predicate deletes asked edit: verdicts.
  • !delegatorSets at the relief, blob -> 9eab6beaab22: RED, 5 of 27. The delegated updates were refused whole, and the delegated deletes wrote extra rows (BOB for CAROL wrote r4; ALICE for ERIN wrote r1 r2 r3).
  • !delegatorSets at the step 3.6 check, blob -> ad03a10d8fe7: GREEN, 27 of 27. This is an equivalent mutant. On a delegated write the relief never runs, so no row is in predicateFloorDropIds, and the floor-dropped judge is computed and never read.
  • Floor-admitted set-aside, blob -> d7f80d96aaab: RED, 2 of 27. ALICE's update asked edit:r1..r4, not edit:r2 r4, and her delete did the same.
  • Batch loop ran once, blob 5569e873e4a4 -> 628fcd57a9e3: RED, 2 of 27. Only 25 of the 60 rows were asked about, and the direct helper pin failed too.
  • Batch slice one short, blob -> 819033e6e42f: RED, 2 of 27.
  • Layer 0 recompose dropped, blob -> 5d9ad8cb55d5: RED, 1 of 27. The composed predicate no longer names the organization.
  • S2 early return removed, blob -> e54f5695cc91: RED, 1 of 27. Without it the added arm has no authored policy, so NARROW's closed r1 r4 were matched and the write was refused whole (PERMISSION_DENIED). The early return is what keeps an authored using policy binding on this shape.
Derived gates at c5208e4: 103 derived, 102 exit 0, 1 NOT MEASURED

dispatch-gates --commands --repo objectstack-ai/objectstack at c5208e4597 derived the same 103 families as round 3. Each ran once in a fresh worktree, and its exit code was recorded before any pipe. Three families were re-run after a first non-zero exit, and none of the three read this diff's content. check:skill-examples (exit 3) lacked the @objectstack/client-react build; after that closure was built it reads 346 prose examples type-check across 3 surface(s). check:i18n (exit 3) lacked the built CLI; after the @objectstack/cli closure was built it reads check-i18n-bundles: OK. check:query-options-erasure (exit 1) hit ENOENT on packages/client-react/.examples-build/client-react__context__1.tsx, a temp file that my concurrent check:skill-examples run wrote and removed while ESLint was listing it; re-run alone it reads ratchet holds ... none new. Reconciliation: 103 derived famil(ies) accounted for — 102 run, 1 NOT-MEASURED (1 DERIVED from a recorded exit 3). The one NOT MEASURED family is pnpm check:dual-build-cjs-loads, exit 3: it reads the dist/ of packages this change does not touch, and CI runs it.

The declaration gates, on the committed changeset at c5208e4597: check:adr-0087-registration --base origin/main exits 0, with [BREAKING+bang+clause-②-narrowing] not-required (no-migration-prescription). check-changeset-no-major.mjs exits 0, with This diff introduces no major bump. check-governed-merges --pr 35914 reads NOT governed: 1,081 changed lines.

CI check-runs at c5208e4597: 55 runs, all completed, 40 success and 15 skipped, none failed.

Human Minimum

  • 1. Schemas start as Zod; packages/spec holds no runtime logic.
  • 2. Every name I added uses the casing for its kind.
  • 3. No formatter ran; pnpm lint passes. (CI runs it.)
  • 4. One issue, one branch off an up-to-date main, one pull request.
  • 5. A change that publishes carries a changeset, and both declaration lines are filled in here and in the changeset.
  • 6. packages/spec touched: not touched.
  • 7. No hand edits to content/docs/references/, packages/*/CHANGELOG.md or content/docs/releases/.
  • 8. Title, body and comments are in English (the maintainer summary is the fleet's Chinese section).
  • The Before Submitting list in CONTRIBUTING.md is done.

Generated by Claude Code


Body refreshed 2026-11-20T22:10Z for round 4 (contract review 7050850078 S4, S5, N7; prose plus two delete pins), head 35ef59a.

@github-actions github-actions Bot added size/l documentation Improvements or additions to documentation tests tooling Fix lands in tooling, not a product package — enters pm:queue only with Unblocks: or a named surface labels Nov 20, 2026
@github-actions

github-actions Bot commented Nov 20, 2026 •

Copy link
Copy Markdown
Contributor

📓 Docs Drift Check

This PR changes 1 package(s): @objectstack/plugin-security, touching 8 documentable anchor(s).

3 hand-written doc(s) NAME something this change touched and may need an implementation-accuracy re-verification:

  • content/docs/permissions/permissions-matrix.mdx (via computeLayeredRlsFilter (literal, a string literal in predicateWriteFloorRelief))
  • content/docs/permissions/sharing-rules.mdx (via computeLayeredRlsFilter (literal, a string literal in predicateWriteFloorRelief))
  • content/docs/permissions/system-context.mdx (via registerAuthzMiddleware (symbol, a top-level function))
What this run could not see
  • the SDK route bridge reached 65 of 247 client-bound route-ledger rows — the other 182 have no registrar path: tail to select them, so pages documenting THEIR client methods cannot appear above, on this or any run. Of those 182: 0 are remediable by widening that discovery convention (an in-repo file declares the path; the convention did not scan it); 59 are structural — on a ledger where NOT ONE row is declared in-repo, so no discovery change reaches them at any price; 123 are undecided (no in-repo declaration, on a ledger that has other in-repo registrars — absence and an unreadable spelling are not distinguishable here). The rows themselves: node scripts/docs-audit/affected-docs.mjs --bridge-coverage
  • a page that states a rule by its inputs shares no identifier with the emitter that implements the rule, so an emitter-only diff cannot list it — not on this run and not on any run. Measured on fix(driver-sql): emit varchar(maxLength) for a text field a declared index keys on #11430: content/docs/protocol/objectql/types.mdx documents the text-family column mapping by the ObjectQL type names it maps FROM (text / textarea / html) while the diff changed createColumn; it went unlisted, and it was the page that diff falsified, in four places. No shared token exists to detect this on, so a rule your change carries has to be re-read by hand in the pages that restate it.
  • a key NAME is not a key, so the hand re-read the line above prescribes can land on the wrong schema. The same spelling is authorable on one governed type and a [REMOVED] tombstone on another for each of active, aria, joins, objects, template, tools and version (censused on [finding] tools is a key on BOTH AgentSchema (tombstoned, dead) and SkillSchema (live, cloud-attested), so a name-based search attributes skill examples to the agent key — it produced a false stop-the-line alarm on PR #19059 #19093 over the liveness ledger's governed types, top-level keys); nothing in a search result distinguishes the two, so a grep hit on a LIVE example reads as evidence about the DEAD key. Measured on fix(spec): the agent.tools liveness row says dead — it claimed live on a key the schema tombstoned #19059: content/docs/ai/agents.mdx was reported as contradicting the agent.tools tombstone over its tools: example at :161, which is inside the defineSkill({ block opened at :155 — the page was already correct. Settle ownership by PARSING the value against both schemas, never by the name: that literal PASSES SkillSchema, and as an AgentSchema it FAILS at tools with the tombstone prescription. ⛔ These names are not the whole class — a key retired through a .strict() guidance map leaves no tombstone in the walked shape and none of them here (tool.category, live as AIToolDefinition.category).

Coarse fallback — 18 page(s) merely mention a changed package (the pre-#9192 predicate, kept for the deliberately-wide backstop): node scripts/docs-audit/affected-docs.mjs --json 170ca481f0aeec14ca06d74ec3d57c654997e698 → packageMentionDocs.

Which tree this was computed on

This run read content/docs from 466e1def44bde871630b72b59eb6663697bca8bb — the merge of head 35ef59a3ffc6334e0518078fb9b8c42da8c0c401 into base 170ca481f0aeec14ca06d74ec3d57c654997e698, which is what actions/checkout gives a pull_request run. Not the PR head.

A worktree cut from an older main holds a different content/docs, so re-deriving there can legitimately return a different list — that is a different tree, not a wrong row. To answer on the same tree:

# while this PR is open — GitHub drops the merge commit once it closes
git fetch origin 466e1def44bde871630b72b59eb6663697bca8bb && git checkout 466e1def44bde871630b72b59eb6663697bca8bb
# afterwards, rebuild it from the two parents, which stay fetchable
git fetch origin 170ca481f0aeec14ca06d74ec3d57c654997e698 35ef59a3ffc6334e0518078fb9b8c42da8c0c401 && git checkout -B drift-repro 170ca481f0aeec14ca06d74ec3d57c654997e698 && git merge --no-ff 35ef59a3ffc6334e0518078fb9b8c42da8c0c401

node scripts/docs-audit/affected-docs.mjs --json 170ca481f0aeec14ca06d74ec3d57c654997e698

⚠️ That checkout carried uncommitted changes, so the commit above does not fully identify what was read.

Advisory only, and a precision-first one (#9192): a page is listed because it names a
symbol, wire route or SDK method this diff touched — not because it mentions a changed
package. Each row says which anchor put it there, so a wrong row is reportable rather than
merely annoying. To re-verify, run the docs-accuracy-audit workflow scoped to these files:
node scripts/docs-audit/affected-docs.mjs 170ca481f0aeec14ca06d74ec3d57c654997e698 → pass the list as
args.docs, on the commit named under Which tree this was computed on.

@objectstack-fleet

Copy link
Copy Markdown
Contributor Author

repo:objectstack#7 · os-tesla · session_01L9qibyQBB3KuDoNobNq9LH

L1: REWORK at 99d771ef0b79e4f3239379f190e2ae09e5c47f1a (2026-11-20T18:54Z). The cost of the verdict leg, one unpinned changeset sentence, and one ablation

Scope. I reviewed the 4 files against merge base f44758b21e (+671 / −9). All four are inside the claim's file surface (7046489990). The dev report is 7047889135.

The design is sound. The relief is a union, each row it adds is one the by-id gate admits, Layer 0 and the readable scope are untouched, and the matrix test holds the predicate write to a by-id oracle row for row. Three things are owed before ACCEPT. Two of them are records.

What I checked

  • The relief (predicateWriteFloorRelief).
    • It runs only for an addressed predicate write, a non-delegated caller, a Layer 1 that exists, and a floor in play for the write class.
    • The rows the floored Layer 1 already admits are read once under the caller's context and set aside. A refused read keeps the floor.
    • Every other readable matched id (falsy ids excluded) goes to predicateWriteFloorDropIds, which is resolvePreImageFloorDrop per row with delegated: false, in batches of 25.
    • The answer is floored OR (id IN dropIds AND layer1-with-dropPlatformOwnershipFloor), written back into extra[rlsFilterAt] with layer0 recomposed as it stood. It can only add rows, and an authored policy stays in both arms. ✔
  • The verb boundary. rlsOperationForVerb sends a delete to checkDelete, so an edit share never drops a delete's floor (ADR-0111 D3). DAVE's delete case shows it. ✔
  • Step 3.6. A predicate update's post-image whose id is in dropIds is judged by the check composed with dropPlatformOwnershipFloor, and every other image keeps checkParts. It is skipped where 2.7 already decided (preImageFloorOpts) and on a delegated write. A refusal is attributed to the parts that judged it. ✔
  • The sharing middleware still ANDs buildWriteFilter on a predicate write (sharing-plugin.ts, the id == null arm), so nothing here can reach a row outside the sharing write scope. ✔
  • The test (predicate-write-floor-deferral.test.ts). It uses a real plugin, engine, SQLite driver, sharing service and the shipped member_default. There are 14 cases over the owner × creator matrix, the Modify All manager, the edit-share target, an authored stage == 'open' policy, and the owner-less CONTROL, plus one row outside the predicate. Each case asserts the predicate set equals the by-id set, and the by-id set equals the expected one. ✔
  • Ablations 1 and 2. Leg 1 (relief off) gave 8 red and 6 green, and the greens are exactly the cases where the answer should not move. Leg 2 (check relief off) gave 5 red, each a whole-write record_change_not_allowed. Both restores were clean. ✔
  • Changeset. owner_only_writes / owner_only_deletes are created_by == current_user.id (default-permission-sets.ts). The 10,000 cap is PREDICATE_WRITE_READABLE_ID_CAP. Clause-②: yes (widening) and patch are right. ✔ Two sentences fail; they are items 1 and 2 below.
  • Part of #35802. I agree. The card's own repro is a controlled_by_parent detail, and this PR does not change it.
  • CI at 99d771ef0b: 18 success, 16 skipped, 16 in progress, 0 failed at my read. It is not yet green.

Required

  1. The verdict leg's cost: measure it, and say it.
    • Before this PR, a predicate write asked no sharing verdicts. Now every matched readable row that the floor does not already admit costs one checkEdit / checkDelete call. Each call is several store reads: the queue check, the owner scope, the edit shares, and the Modify All bypass.
    • Open question 3 says "a member over their own rows asks no verdict at all". That is true, but it is not the common case. A member whose predicate matches rows other people own on an org-readable object asks one verdict per such row, and almost every one answers deny. Those rows are also outside the sharing middleware's buildWriteFilter, so they were never going to be written. A rep's bulk update matching 3,000 readable rows, 20 of them their own, now makes about 2,980 verdict calls to change those same 20 rows.
    • Fix (record + changeset):
      • Time it on the existing rig, before and after: (i) an ordinary member's predicate update matching 1,000 and 10,000 readable rows owned by others (the all-deny path), and (ii) a Modify All holder at 10,000. Post the numbers as a report amendment.
      • Restate open question 3 with the member case.
      • If the cost is material, add one changeset sentence naming it. The "What does not change" list now implies nothing else moves.
    • Whether to narrow the candidates before asking is a design question, not mine to rule. buildWriteFilter is not on the ISharingService contract, so it is option B territory. I am naming it for the L2.
  2. An unpinned changeset sentence. The changeset says "a write made on another user's behalf … keeps the floor for both principals as its by-id write does". The code does this (!delegatorSets in both places), but no case in the new file runs an on-behalf-of predicate write, and the report cites no existing pin. Fix: add a case (DAVE or BOB writing on behalf of CAROL: the floor kept, and the predicate set equals the by-id set), or cite an existing pin that runs the predicate path delegated. Otherwise drop the sentence.
  3. One ablation: a record, no new head. The D3 boundary relies on the verb reaching resolvePreImageFloorDrop, and leg 1 cannot show that, because DAVE's delete stays green with the relief off. Fix: pass 'update' in place of rlsOperation to predicateWriteFloorDropIds (predicateWriteFloorRelief). DAVE's predicate delete should go red, writing r2 and r3. Post the red and the clean restore. If item 2 adds a delegated case, also ablate !delegatorSets in the relief and post that leg too.

For the seat (not L1's to rule)

Before landing

  • A delta L1 after items 1–3.
  • CI green on that head.
  • The CONTRACT_REVIEW_TIER L2 PASS (Clause-②: yes), same head. The cost question in item 1 belongs on its desk too.

Generated by Claude Code

@objectstack-fleet

Copy link
Copy Markdown
Contributor Author

repo:objectstack#7 · os-tesla · session_01L9qibvVRcFWKrfWeG5jzPb

Contract review

Served-tier: CONTRACT_REVIEW_TIER
Head-sha: 99d771ef0b79e4f3239379f190e2ae09e5c47f1a
Local-runs: none
Scope: packages/plugins/plugin-security/src/security-plugin-authz-middleware.ts, packages/plugins/plugin-security/src/security-plugin-sharing-verdicts.ts, packages/plugins/plugin-security/src/predicate-write-floor-deferral.test.ts, .changeset/35802-predicate-write-floor-deferral.md + packages/plugins/plugin-security/src/security-plugin-rls-filter.ts, packages/plugins/plugin-security/src/security-plugin-addressed-writes.ts, packages/plugins/plugin-security/src/security-plugin.ts, packages/plugins/plugin-security/src/rls-compiler.ts, packages/plugins/plugin-security/src/objects/default-permission-sets.ts, packages/plugins/plugin-sharing/src/sharing-service.ts, packages/plugins/plugin-sharing/src/sharing-plugin.ts, packages/objectql/src/engine-update.ts
Security-touching: yes

Read: card #35802 (body; triage 7034749465; claim 7046489990; os-dev-report 7047889135); PR #35914 (body, the 4-file list, the net diff against merge-base f44758b21e, +671/-9; origin/main was cd55df8f3c); the PR thread (docs-drift 7047860335; L1 REWORK 7047985230, read after my own derivation was done); AGENTS.md (Prime Directive #14, Post-Task Checklist step 3) and .claude/skills/pm-dispatch/references/contract-review.md. Code outside the diff was read on the head. Nothing was built or run: every scenario below is derived by reading and none is measured. Check-runs on the head when read: 24 success, 16 skipped, 11 in progress, none red. The PR is a draft; its user.login is objectstack-fleet[bot].

Result: PASS. No must-fix: I found no row a predicate write can now reach that a by-id write of the same row by the same caller refuses. Open on this head: S1 to S3 (should-fix), N1 to N6 (nits). S1 needs a word from the seat on whether the corner it names is a narrowing arm; if it is ruled one, this PASS does not cover the four pieces that arm owes.

① Derived judgments

  1. The added arm is a subset of the by-id admit set, row for row. A row enters the new arm only if it is in dropIds, which is resolvePreImageFloorDrop asked with the same write class, sets and context step 2.7 passes (security-plugin-sharing-verdicts.ts:350). The arm is id IN dropIds AND replaced, where replaced is computeLayeredRlsFilter(..., { dropPlatformOwnershipFloor: true }).layer1, the Layer 1 step 2.7's re-read enforces for an allow (security-plugin-authz-middleware.ts:3071-3078). Layer 0 is the same object recomposed (:2861), and the readable-id scope, the caller's where and the sharing middleware's buildWriteFilter (sharing-plugin.ts:1674) are still ANDed. So arm 2 ⊆ {rows whose by-id write passes 2.7 and the sharing by-id gate}.
  2. Tenant wall / Layer 0. Untouched: layered.layer0 is reused, never recomputed, and andComposeLayers(layer0, relief.layer1) keeps it outside the $or. The candidates come from the read door, which walls them first.
  3. App-authored policies. compileFilter composes policies with $or only (rls-compiler.ts:1162); there is no restrictive class. floored compiles floor ∪ A, replaced compiles A (the authored write-class policies). Consequence: when A has any using policy, replaced ⊆ floored and arm 2 adds no row at all; the relief changes the matched set only when replaced is null. The by-id path has the same shape (floor dropped leaves A alone). No authored policy is bypassed. This is also the ground of S2.
  4. Delegated callers. Both sites are guarded by !delegatorSets (:2490, :2852), and predicateWriteFloorDropIds returns [] for delegated (:344). The delegator's own floored Layer 1 is ANDed as before (:2807-2810). Correct, and unpinned (S3).
  5. Verb boundary (ADR-0111 D3). rlsOperationForVerb picks checkDelete for delete and purge; checkDelete has no share branch and no queue branch (sharing-service.ts:1315-1339). Independently, buildWriteFilter(..., 'delete') returns the owner match alone (sharing-service.ts:938). An edit share cannot widen a predicate delete through either.
  6. ADR-0066 ①. On a posture-permitting object the superuser short-circuit leaves layer1 null, so the layered.layer1 guard skips the relief; on an ordinary object replaced keeps every authored policy. Modify All gains nothing it lacks by id.
  7. Field-level write checks. Step 2.5 runs before and is not moved; a when entry is still applied as a lock on a predicate update. The ownership step still fails closed on a predicate change-set that writes owner_id or queue without the transfer grant (preImage() is null with no single id). An edit-share target cannot take ownership by predicate.
  8. Lifecycle verbs. addressedPredicateWrite is true only for update and the delete class; transfer and restore never reach the relief. purge maps to delete and is dispatched with no ast, so step 3 does not run for it.
  9. TOCTOU. dropIds is decided before next(); replaced, Layer 0 and the sharing owner match are predicates the statement evaluates. A row whose owner changes after the verdict is still held by the sharing middleware's pushed-down owner match. An edit share revoked after the verdict leaves a window, but buildWriteFilter already materialises granted ids the same way today, and the by-id path has the same order (verdict at 2.7, write later). The window is longer here (up to 400 batches of verdicts). No new class; not a finding.
  10. The 10,000 cap. readableRowsScopeForPredicateWrite throws above the cap before the relief is called (security-plugin-addressed-writes.ts:172). The relief reads at most the ids that scope returned, with limit: readableIds.length + 1; nothing is cut off.
  11. id IN composition and empty sets. Empty readable ids, no floor in play, a refused or empty probe, no candidates and no allow each return null and leave extra as composed. extra[rlsFilterAt] is the caller's scope exactly when rlsFilter is truthy, which the guard requires. floored may be RLS_DENY_FILTER; inside the $or it loses its identity but still matches no row, and the by-id path puts it in an $and the same way.
  12. Step 3.6. A row in dropIds is judged by computeWriteCheckFilter(..., { dropPlatformOwnershipFloor: true }), the check a by-id allow gets; every other row keeps checkParts. writeCheckPolicies returns only the check-declaring policies when any exist, so the two checks differ only where every policy is using-only. The block sits inside checkParts.length > 0, which is safe: the floor-dropped policy set is a subset of the floored one.
  13. Drivers. The composed tree is $or / $and / $in on id, all in the common filter vocabulary; the check runs in process. Pinned on better-sqlite3 only (N5).
  14. The union claim holds for the admit set and fails for the outcome. Layer 1 only gains rows, and a row the floor admits is never asked a verdict, so its check does not move. But a predicate update is all-or-nothing downstream of the match (engine-update.ts:2161-2171 for the check seam; validation rules, per-row before* hooks and the readonlyWhen strip follow the same rule). A newly matched row that one of them refuses now refuses, or alters, the write for the rows that were written before. See S1.

② Semver level

  • Level. '@objectstack/plugin-security': patch is right: Metadata-protocol: none (no key, accepted value or metadata type moves) takes patch, and a widening ships patch.
  • Declarations. Clause-②: yes (widening) and Metadata-protocol: none are line-initial on the claim, the PR body and the changeset (:7-8). The arm is right for the authorization admit set, which is what the clause is about here. It is not the whole truth about what a caller observes: S1.
  • Changeset, sentence by sentence.
Sentence Verdict
Summary (:5) True for the three callers on an owner-bearing, non-controlled_by_parent object; the body carries the "update only" limit for the share.
"used to match only the rows that user had created" (:10) Over-general: N1.
"applied … as an unconditional condition, while a write by id lets … allow replace it" (:10) True (:1425, :2784).
"makes the by-id decision for each matched row … (ownership at the caller's write depth, an edit share for an update, or Modify All)" (:12) True. The list leaves out the queue basis: N1.
"abstains … or denies keeps the floor" (:12) True.
"The row-level check on each updated row follows the same decision" (:12) True (:2396-2398).
Reach and the 10,000 refusal (:16) True, code unchanged.
Authored policy still binds; Modify All does not bypass (:17) True (① 3 and 6).
Edit share never delete (:18) True (① 5).
Tenant wall; on-behalf-of keeps both floors (:19) True by reading; no pin (S3).
controlled_by_parent keeps the floor (:20) True: checkEdit abstains on the public-mapped model, so dropIds is empty. One exception, the queue basis, answers allow before that abstain (sharing-service.ts:1240); there the by-id write drops the floor too and the master gate (step 2.8) still judges every master the predicate reaches.
"No action is needed. … now writes those rows too" (:22) Incomplete: S1.

③ Boundary flags

  • Part of #35802 is honest. The card's repro object is a controlled_by_parent detail; checkEdit abstains there and this PR leaves it creator-only on the predicate path, as the changeset says. Closing the card here would be wrong.
  • Q1 (information). Option A is coherent: with no single id, assertControlledByParentWrite refuses on the first master the caller may not edit, so a write that passes it has only editable masters. It reverses a recorded "must not" (security-plugin.ts:683-690) and widens, so it is the maintainer's word and its own L2.
  • Q2 (information). Part of, as opened.
  • Q3 (information). "A" understates the cost. An ordinary member whose predicate matches rows other people own asks one verdict per such row and gets deny for nearly all of them (the L1 says the same). checkEdit asks the Modify All bypass last, so the card's main persona pays the queue, owner and share reads on every row first. S2 removes one whole population for free; the rest needs numbers.
  • SQL push-down: new id materialisation, with a reason, and with one avoidable part. The relief adds one id read (up to 10,000 ids in), up to 10,000 service calls, and a second id IN list in the write. The reason holds for the verdict: the allow / abstain split is not on a pushable contract (buildWriteFilter answers null for both "abstains" and "org scope", and is not on ISharingService). The avoidable part is S2.
  • Out-of-scope finding (authored widener narrows by id): real, and it should be filed. compileFilter ORs policies, so dropping the floor from floor OR widener leaves widener alone: an owner-creator is refused by id on a row the floor admitted. The same happens to a using-defaulted check. It is the by-id composition of Row-level write gate consults neither modifyAllRecords nor sys_record_share.access_level — both declared write-widening mechanisms are inert #5492, not this PR. The dev was right not to copy it onto the predicate path. Reach beyond the engine door is unmeasured, as the report says.
  • Docs. content/docs/permissions/rls.mdx:101-114 and permissions-matrix.mdx:374 describe the predicate write's bound by the write scope; neither says the predicate path keeps the creator floor, so neither is falsified.
  • File surface. All four paths are inside claim 7046489990. No exported symbol is removed or renamed; predicateWriteFloorDropIds is added and is not reachable from the package entry.

④ Design judgment

Are the pins real?

Pin Result
ALICE, BOB, manager × update and delete Real. Each compares the predicate set with a by-id oracle on a second copy and names the set. Red under leg 1.
CAROL × both verbs Real as a control: creating is not owning; green under both legs by design.
DAVE update Real. Red under legs 1 and 2.
DAVE delete True, but it cannot discriminate the relief's verb leg: buildWriteFilter(..., 'delete') is owner-only, so r2 and r3 stay even if the relief asked checkEdit. The ablation the L1 asks for (pass 'update') will stay green on this rig. See S3.
Authored stage == 'open' policy under Modify All Real against one mutant only: dropping replaced from arm 2 would write r1 and r4. Green under leg 1, because the widener is ORed into floored and admits r2 and r3 before this PR too.
Owner-less CONTROL × both verbs Real as a control (sharing abstains).
Row outside the predicate Real.

Ablations. Two legs, each with landing and restore blob ids and a red list that matches what the code predicts (leg 2 reds are whole-write refusals, as engine-update.ts:2161-2171 implies). Credible. Not ablated, and no pin would go red: the floor-admitted set-aside, !delegatorSets, the Layer 0 recompose, the batch boundary, the verb argument. See S3.

Design. Asking the by-id gate's own function per row is the right way to get by-id equality without a second implementation, and setting aside the floor-admitted rows is what keeps an owner-creator's check from tightening. What gives way: an outcome the prose denies (S1), a verdict loop that is provably idle in one population (S2), and five load-bearing legs with no pin (S3).

S1 (should-fix; the seat rules the arm) — "a union, never a narrowing" and "No action is needed" are false for the outcome of a write that today succeeds small. .changeset/35802-predicate-write-floor-deferral.md:22, :14-20; PR body, Acceptance notes, first bullet; security-plugin-authz-middleware.ts:2396-2398, :3078.

Scenario, by reading: an object with owner_id and an authored check-only policy { operation: 'update', check: "region == 'emea'" }. ALICE owns r1 (created by her, emea) and r2 (created by CAROL, apac). update(obj, { name: 'x' }, { where: { owner_id: ALICE }, multi: true }).

  • Before: Layer 1 is the floor alone (a check-only policy has no using), so r1 matches; its image passes the check; the write answers success, 1 row.
  • After: r2 is a candidate, the owner verdict is allow, replaced is null, so r2 matches. Its image fails the check (the floor-dropped check is the same policy), denyCheck() throws, and the engine refuses the whole write: 403 record_change_not_allowed, r1 not written.
  • By id: r1 is still written, r2 is refused.

The same follows without any RLS policy from the other all-or-nothing steps on the predicate path: an error-severity validation rule on r2, a throwing beforeUpdate / beforeDelete hook, and the readonlyWhen strip, which drops a field for every row when one matched row locks it (a silent change to r1). The card's reporter builds approval-gated objects, which is this shape. The new behaviour is defensible (the predicate now targets rows the caller may write, and one of them refuses loudly), but it is a change an existing caller gets, and the changeset tells them there is none.

Fix: state it in the changeset ("a write that used to succeed on the rows the caller created can now be refused whole, or have a field stripped, when a newly matched row fails a row-level check, a validation rule, a hook or a readonlyWhen lock"), correct the Acceptance note, and pin the check-only case so the answer is chosen. The seat or the maintainer says whether this corner makes the declaration a narrowing arm with its banner; I read yes (widening) as the right arm for the admit set and this as an owed disclosure.

S2 (should-fix) — the verdict loop runs where it cannot change anything. security-plugin-authz-middleware.ts:3059-3076. When replaced is non-null, every candidate already failed floored, which contains every disjunct of replaced (① 3), so id IN dropIds AND replaced matches no candidate at decision time, and a candidate that later satisfies replaced is admitted by floored anyway. On any object with an authored write-class using policy, and on sys_attachment with the storage alternate, a Modify All holder's predicate over 10,000 rows still makes 10,000 checkEdit calls for nothing. Fix: compute replaced before predicateWriteFloorDropIds and return null when it is non-null; the result is then always floored OR id IN dropIds. The cost that remains (members matching other people's rows, Modify All on a policy-free object) needs the measurement the L1 asked for and one changeset sentence.

S3 (should-fix) — five legs the claims rest on have no pin; each mutant below leaves the 14 cases green.

  • The floor-admitted set-aside (:3041-3059). Treating every readable id as a candidate turns the dev's measured corner (owner-creator, authored stage == 'open', a closed row they created) from "written" into a whole-write 403, because the row would get the floor-dropped check. This is the leg that makes the design a union. Pin that corner on the predicate path.
  • !delegatorSets (:2852, :2490). Removing the first drops the agent's floor while the delegator's stays: a half-state the by-id path excludes. The changeset asserts the delegated behaviour (:19). Pin an on-behalf-of predicate write, or drop the sentence.
  • The verb argument (:3063). Not pinnable through DAVE's delete (see the table). Pin predicateWriteFloorDropIds directly with a sharing double: a delete asks checkDelete and never checkEdit.
  • The batch boundary (security-plugin-sharing-verdicts.ts:346-355). No case has more than 4 candidates. One case with more than 25.
  • The Layer 0 recompose (:2861). Every seeded row is in one organization and the readable scope masks a dropped wall. One cross-organization row, or an assertion on the composed tree.

N1 (nit) — .changeset/35802-predicate-write-floor-deferral.md:10, :12. "used to match only the rows that user had created" is not true where an authored update widener applies (its rows matched already) or on a public_read_write object (no floor on update). The allow bases omit queue membership (ADR-0142 D3, update only).

N2 (nit) — .changeset/35802-predicate-write-floor-deferral.md:5. "now writes the rows … can write by id" still has known exceptions the note could name in one clause: edit shares beyond buildWriteFilter's 5,000-row read (sharing-service.ts:948), a row held through a read share plus an authored widener (rls.mdx:101-112), and the controlled_by_parent half. Each is a silent smaller success, the card's own symptom.

N3 (nit) — security-plugin-authz-middleware.ts:2852 lacks the !preImageFloorOpts guard its twin has at :2489. A multi: true write whose where carries a scalar id runs step 2.7 and then the relief; the result is the same, the verdicts are asked twice.

N4 (nit) — security-plugin-authz-middleware.ts:2986. idsOfReadableScope keeps strings and numbers; extractSingleId also accepts bigint. On a bigint key the relief never applies. Fail-safe, and the under-write the card reports stays there.

N5 (nit) — the write can now bind the readable ids and dropIds (up to 20,000 values, plus up to 5,000 shared ids), and the admitted read binds 10,000 more. Inside SQLite's 32,766 and Postgres's 65,535; not exercised near the cap, and only on better-sqlite3.

N6 (nit) — security-plugin-authz-middleware.ts:2396-2397. The row is told by image.id after the payload merge. A payload id equal to another matched row's id would be judged by the floor-dropped check; it cannot be stored (primary key), so nothing follows.

Implemented-by: claude/issue-35802-predicate-write-floor-deferral
Reviewed-by: session_01L9qibvVRcFWKrfWeG5jzPb

VERDICT: PASS

…ass policy remains; pin each leg of the predicate floor relief

Claude-Session: https://claude.ai/code/session_01L9qibvVRcFWKrfWeG5jzPb
Co-authored-by: Claude <noreply@anthropic.com>
…erb it is handed, delegation, the batch ceiling

Claude-Session: https://claude.ai/code/session_01L9qibvVRcFWKrfWeG5jzPb
Co-authored-by: Claude <noreply@anthropic.com>
…outcome, the verdict cost, and the bounds that stay

Claude-Session: https://claude.ai/code/session_01L9qibvVRcFWKrfWeG5jzPb
Co-authored-by: Claude <noreply@anthropic.com>
…st and its docs

The changeset now declares Clause-② no (narrowing) with a BREAKING banner (FROM, TO and the fix for a caller), one ADR-0087 disposition, and the measured verdict cost. The permissions matrix and the sharing page now say that the sharing allow replaces the creator-only floor per row, by id and by predicate alike.

Claude-Session: https://claude.ai/code/session_01L9qibvVRcFWKrfWeG5jzPb
Co-authored-by: Claude <noreply@anthropic.com>
@objectstack-fleet objectstack-fleet Bot changed the title fix(plugin-security): a predicate write composes the platform ownership floor per row, as the by-id write does fix(plugin-security)!: a predicate write composes the platform ownership floor per row, as the by-id write does Nov 20, 2026
@objectstack-fleet

Copy link
Copy Markdown
Contributor Author

repo:objectstack#7 · os-tesla · session_01L9qibyQBB3KuDoNobNq9LH

L1 delta: ACCEPT at 6ff08df403121d0fb9bdce9bc1422d9d3ebd836f (2026-11-20T21:16Z), with one body line owed and the maintainer's S1 word pending

This follows my REWORK 7047985230 at 99d771ef0b. Rounds 2 and 3 are in reports 7049211796 and 7050721656. Seat ruling 19:58Z and claim amendment 7049287805 cover them. The PR's own diff against merge base 138faaabac is 6 files (+984 / −14); the other files in the range are main merged in.

What I checked

  • Item 1, the cost: met.
    • The member all-deny case is measured at 1k (1.1 s, 2,004 reads) and 10k (5.3 s, 20,004 reads). Modify All at 10k is 1.8 s.
    • The changeset now names the cost with its before numbers, and open question 3 is restated with the member case.
    • Moving the bulk verdict contract to a filed follow-up (option B) is the seat's call.
    • ✔
  • The S2 early return (predicateWriteFloorRelief step 2). It computes replaced first and answers null when an authored write-class policy remains.
    • I checked the argument. Layer 1 policies compose by $or (rls-compiler.ts, return { $or: filters }), so floored is the authored set OR the floor. A row floored refuses fails every authored policy, and its by-id write (authored set alone) is refused too. Replacing the floor admits no row there.
    • The relief is now floored OR id IN dropIds. Each added row is one whose by-id Layer 1 was the floor alone, and the verdict replaced it.
    • The authored stage == 'open' case still equals by-id (r2, r3). A7 (early return removed) goes red.
    • ✔
  • Item 2, on-behalf-of: met. Five delegated cases are added, each equal to by-id. A2 (!delegatorSets at the relief) goes red 5/27: the delegated deletes wrote rows the by-id path refuses. A3 (!delegatorSets at the 3.6 judge) stays green. I accept it as an equivalent mutant: on a delegated write the relief never runs, so predicateFloorDropIds stays null and the judge is never read. ✔
  • Item 3, the verb ablation: met, and my prediction was wrong.
    • I said DAVE's predicate delete would write r2 and r3 under A1. It cannot. The sharing middleware's delete buildWriteFilter is owner-only, so no row moves, and the round-1 pins stay green.
    • The new verdict-recorder pins see the mutant (ALICE's and DAVE's deletes ask edit: instead of delete:): 2/27 red.
    • The direct predicateWriteFloorDropIds pin covers verb pass-through, delegation and the batch ceiling. A5 and A5b (batching) go red.
    • ✔
  • The other legs.
    • A4 (set-aside dropped) goes red on the recorder. It is now a cost leg, and its round-1 role passes to the S2 return.
    • A6 (Layer 0 recompose dropped) goes red 1/27, now that the rig runs in isolated posture. That move is right: on the single-posture rig the leg could not go red.
    • A8 (the 3.6 relief forced on) turns the S1 pin red.
    • All restores were blob-equal.
    • ✔
  • The S1 narrowing record.
    • The title carries !. Clause-②: no (narrowing) and Metadata-protocol: none are declared, as a patch. AGENTS.md (Post-Task Checklist step 3) gives a non-protocol breaking change patch.
    • The ADR-0087 marker not-required (no-migration-prescription) gives a reason, which fits: no key, stored value or export moves.
    • The BREAKING banner has a FROM/TO and a fix line ("write by id, or narrow the predicate").
    • The dogfood battery at this head is 482 files and 4,098 tests, with 0 failed.
    • The whole-write consequences the banner names for a validation rule, a hook and a readonlyWhen lock are the engine's existing predicate-update contract (stripReadonlyWhenFieldsMulti, 安全:readonlyWhen 服务端剥离仅覆盖单条 update 路径,多行 updateMany 不强制(条件只读可被批量绕过) #3042). They are not new behaviour, so they need no pin here.
    • ✔
  • The docs (permissions-matrix.mdx, sharing-rules.mdx). Both now state the per-row replacement where sharing enforces writes (owner_id with a private or public_read OWD). They say the floor stays under public_read_write or with no owner_id, which is checkEdit's abstain. They also say an authored policy is never replaced. ✔
  • The changeset, sentence by sentence.
    • The "What does not change" list now includes the edit-share ceiling (5,000) and the queue.
    • The delegated sentence is now pinned.
    • The cost section matches the report.
    • ✔
  • CI at 6ff08df403: 42 success, 19 skipped and 0 failed. One Check Changeset run was cancelled, and a fresh run is in progress.

Owed (a record, no new head)

  • A Skills-docs: line in the PR body. A narrowing needs one, and the body has none. I checked skills/. objectstack-data/rules/security.md (lines 69–70) already teaches that a check is "judged on every row an insert/update writes (array inserts and multi: true included; one failing row refuses the write)". No skill teaches that a predicate write skips non-created rows. So the line can read Skills-docs: none — security.md already teaches the all-or-nothing multi write, unless you find a passage I missed.

Before landing

  • The maintainer confirms option (b) for S1 on the seat's decision card. The PR stays a draft until then.
  • The CONTRACT_REVIEW_TIER L2 PASS on this head, because of the narrowing.
  • Check Changeset green, plus the body line above.

Generated by Claude Code

@objectstack-fleet

Copy link
Copy Markdown
Contributor Author

repo:objectstack#7 · os-tesla · session_01L9qibvVRcFWKrfWeG5jzPb

Contract review

Served-tier: CONTRACT_REVIEW_TIER
Head-sha: 6ff08df403121d0fb9bdce9bc1422d9d3ebd836f
Local-runs: none
Scope: packages/plugins/plugin-security/src/security-plugin-authz-middleware.ts, packages/plugins/plugin-security/src/security-plugin-sharing-verdicts.ts, packages/plugins/plugin-security/src/predicate-write-floor-deferral.test.ts, .changeset/35802-predicate-write-floor-deferral.md, content/docs/permissions/permissions-matrix.mdx, content/docs/permissions/sharing-rules.mdx + packages/plugins/plugin-security/src/security-plugin-rls-filter.ts, packages/plugins/plugin-security/src/security-plugin.ts, packages/plugins/plugin-security/src/platform-ownership-policies.ts, packages/plugins/plugin-security/src/rls-compiler.ts, packages/plugins/plugin-sharing/src/sharing-service.ts, packages/objectql/src/engine-update.ts, packages/objectql/src/engine-cascade-delete-atomic.test.ts
Security-touching: yes

Delta record on my PASS 7048114223 (head 99d771ef0b). Read: git diff 99d771ef0b..6ff08df403 on the six PR paths (the two merges of origin/main, 25c3807b54 and 5bd87728b4, touch none of them); dev reports 7049211796 (round 2) and 7050721656 (round 3); claim amendment 7049287805; the PR title and body as they stand. Code outside the diff was read on the head. Nothing was built or run: every judgment is derived by reading, and the ablation and cost figures are the dev's, read and checked against the code for what they predict. Check-runs on the head when read: 42 success, 19 skipped, 1 in progress, 1 cancelled, none failed. The PR is a draft.

Result: PASS. No must-fix. S1, S2 and S3 of the first record are resolved. Two new should-fix, both prose (S4, S5), and one nit (N7). N3 of the first record was wrong and is withdrawn.

Does this PASS cover the narrowing arm? Yes, for the contract judgment. It covers the arm chosen, the level, the banner's FROM / TO and fix, the ADR-0087 marker, and the pin and ablation that hold the new refusal (④ ran on every non-prose path of the diff). It does not stand in for the maintainer's word on option (b) against (a), which is still open on the decision card, and I read the dogfood battery only as the report states it.

① Derived judgments

  1. The S2 shape is still a subset of the by-id admit set, row for row. The relief now returns null when replaced (Layer 1 with dropPlatformOwnershipFloor) is non-null, and otherwise answers floored OR id IN dropIds (security-plugin-authz-middleware.ts:3048-3053, :3088-3091). With replaced null, the by-id write of a dropIds row composes layer0 alone at step 2.7, so the by-id gate admits exactly: verdict allow, inside Layer 0, readable. The predicate arm asks the same verdict and ANDs Layer 0 (:2862), the readable ids, the caller's where and the sharing bulk scope. Subset holds. replaced depends on the policy set and the context only, never on a row, so computing it first opens no window.
  2. The early return changes no row. compileFilter ORs policies, so replaced ⊆ floored; where it is non-null the old arm id IN dropIds AND replaced matched no candidate. The deny sentinel is non-null and returns null too, where the by-id write is refused. On public_read_write update the floor has already yielded and both sides are the select-derived scope or null; null is stopped by the layered.layer1 guard.
  3. The check. With replaced null there is no authored using policy, so the floor-dropped check is either the check-declaring policies (the same set checkParts uses) or nothing. A dropIds row is held to what its by-id write is held to. The set-aside is now a cost leg only, as A4 says; the widener corner is protected by the early return (A7).
  4. N4 (bigint). idsOfReadableScope and predicateWriteFloorDropIds carry bigint; !!0n is false like the other falsy ids; the verdict is asked with String(id), as step 2.7 does. Unit-pinned.
  5. A3 is an equivalent mutant. predicateFloorDropIds is declared per operation and assigned only inside the !delegatorSets relief (:2852-2864). On a delegated write it stays null, predicateFloorDropIds?.has(...) === true is false, and floorDropJudge is never called whether or not :2490 builds it. Removing :2490 costs one unused computeWriteCheckFilter. No pin can separate it from the head without A2, which is red 5/27.
  6. The N3 rebuttal is right and my N3 was wrong. For where: { id: r4, stage: 'open' } under multi: true, step 2.7 judges r4 by id and drops the floor for its pre-image re-read, but step 3 composes its own floored Layer 1 into the statement and never reads that decision. A !preImageFloorOpts guard on the relief would leave the floor ANDed and BOB's owned row unwritten: the reported under-write, on the compare-and-set shape. The second verdict is the price of the right answer. Step 3.6 is consistent there: :2489 skips the judge and checkParts already carry step 2.7's floor decision for the one row the where can match.
  7. N6 withdrawn. A truthy payload id is routed by id by resolveEngineUpdateDispatch, never to the predicate path, so an image id cannot name another matched row.
  8. No new defect found in the round-2 and round-3 code. The source delta is the early return, the bigint widening, one export (idsOfReadableScope, for its test) and comments.

② Semver level

  • Arm. Clause-②: no (narrowing) is the right arm of the closed pair: the admit set widens and one outcome narrows, and the declaration takes the breaking one. Line-initial on the claim amendment, the PR body and the changeset (:7). Metadata-protocol: none holds.
  • Level. patch is right: a non-protocol breaking change ships patch with its banner and disposition. The ! is on the PR title and the changeset summary.
  • ADR-0087 marker. Present, one, not-required (no-migration-prescription) (:10). Right category: nothing stored or authored moves, so there is nothing for a migration to rewrite.
  • FROM / TO and the fix, against the code.
Line Verdict
Banner scope (:12) True for an update. Incomplete: it names update only. See S5.
FROM (:14) True where no authored write using policy admits the row, which :19 states.
TO, the check (:15) True: denyCheck throws 403 PERMISSION_DENIED from the predicate seam before the statement (engine-update.ts:2161-2171); pinned, and A8 turns that pin red.
TO, validation rule and hook (:15) True that the whole update is refused. "The same way" over-reads: N7.
TO, readonlyWhen (:15) True: a field locked in any matched row is dropped for all (engine-update.ts:1887-1893).
"A write of that row by id is refused the same way, alone" (:15) True for the check.
The fix (:17) True: by id gives an outcome per row; a predicate that leaves the failing rows out matches what was written before.
  • Cost text (:23-28). The four lines repeat the report's measurements exactly. Their shape agrees with the code: checkEdit for a member's deny reads the owner scope and the share row, a Modify All allow is asked last after the owner read, and the early return asks nothing under an authored using policy. The figures themselves are the dev's, on SQLite in memory, as the text says.
  • The rest. :19 and :21 now carry the creator-only wording, the queue basis and the authored-policy exception (N1 resolved). :33 names the 5,000-share read and the read-share-plus-widener row (N2 resolved). :37 is now pinned by five on-behalf-of cases.

③ Boundary flags

  • Docs correction 1, content/docs/permissions/permissions-matrix.mdx:53-61.
    • Before: "authored and baseline RLS still applies (e.g. member_default's owner-scoped write policies keep org_member holders owner-scoped on update/delete even when another set grants modifyAllRecords), and the Layer 0 tenant wall always ANDs on top."
    • After: "authored RLS still applies, and so does member_default's creator-only write floor (created_by == current_user.id) for org_member holders, except where record sharing enforces writes (an object with an owner_id whose OWD is private or public_read): there the sharing service's allow for a row (ownership at the caller's write depth, modifyAllRecords, or, for an update, an edit share or the row's queue) replaces the floor for that row, on a by-id write and on a predicate write alike. Under public_read_write, or on an object with no owner_id, the floor stays, and an app-authored policy is never replaced. The Layer 0 tenant wall always ANDs on top."
    • Verdict: true, except one clause. See S4.
  • Docs correction 2, content/docs/permissions/sharing-rules.mdx:66-74.
    • Before: "modifyAllRecords does not lift those policies".
    • After: "modifyAllRecords does not short-circuit those policies … Where record sharing enforces writes (an owner_id and a private or public_read OWD), the sharing service's allow for a row (…) replaces the baseline floor for that row, by id and by predicate alike. Under public_read_write, or on an object with no owner_id, the sharing service abstains and the floor stays. An app-authored policy is never replaced."
    • Verdict: true, except the same clause. See S4.
  • S1's ruling. Option (b) is the consistent one: the predicate path already refuses whole when a floor-admitted row fails its check, and (a) would bring back a silent skip. The maintainer's word is still owed and the PR is rightly a draft.
  • Cost. Staying in this PR under the existing cap, named in the changeset, with the bulk contract as a follow-up card: accepted as the seat ruled. The member all-deny case (5.3 s, 20,004 reads, no row written) is the one to carry on that card.
  • SQL push-down. Unchanged from the first record, less the population S2 removed.
  • Out of scope. The by-id widener corner is carried by plugin-security: on a by-id write, a sharing allow drops owner_only_writes out of the OR of permissive policies, so an owner-creator holding an authored widener is refused on their own row #35917 and now pinned on the predicate side.

④ Design judgment

First-record findings.

Finding State
S1 Resolved: declared as the narrowing arm with banner, marker and fix; pinned (code, status, no row changed, by-id oracle ['r1']); A8 red 1/27. Open only as the maintainer's (b) or (a).
S2 Resolved: replaced first, null when non-null; pinned by verdict count 0 in the NARROW and widener cases; A7 red. Measured 1,629 ms to 45 ms.
S3 Resolved: set-aside (A4 red 2/27), !delegatorSets at the relief (A2 red 5/27), verb (A1 red 2/27 through the verdict recorder; the round-1 pins stayed green, as derived), batch (A5, A5b red), Layer 0 (A6 red 1/27 on the isolated rig). The direct pins on predicateWriteFloorDropIds are in.
N1, N2, N4 Resolved.
N3 Withdrawn; the dev's measurement is right (① 6).
N5 Stands as a note; not actionable inside the surface.
N6 Withdrawn (① 7).

Pins. 27 cases. The 14 round-1 cases are unchanged in substance (the removed lines are signature changes for the wider seed helper). The new ones each have a named ablation except the bigint unit pin, which is direct. The Layer 0 pin asserts on the composed predicate text, which is weaker than a cross-organization row but does go red under A6.

S4 (should-fix, docs prose) — both corrected pages say the floor stays under public_read_write; for an update it does not exist there. content/docs/permissions/permissions-matrix.mdx:59-61, content/docs/permissions/sharing-rules.mdx:71-73. platformFloorYieldsToObjectWriteModel removes owner_only_writes on an object whose OWD opens row writes, for update only (security-plugin.ts:4522, platform-ownership-policies.ts:280); owner_only_deletes stays. So on a public_read_write object a member updates a row they did not create (the #8023 fix), and the new sentence tells an author the opposite. The pre-existing line above it in sharing-rules.mdx:59-62 ("stay owner-scoped on writes even under public_read_write") has the same fault and was left; the table at :31 ("All users can read and edit") is the true one. Fix: "Under public_read_write the update floor does not apply and the delete floor stays; on an object with no owner_id both stay", and correct :59-62 to match. A smaller imprecision in the same sentences: "by id and by predicate alike" is not so where an authored write policy remains (the predicate keeps the floor, by id replaces it, #35917), and the queue basis answers allow on a public OWD too.

S5 (should-fix, changeset prose) — the BREAKING banner names a predicate update only; a predicate delete has the same outcome. .changeset/35802-predicate-write-floor-deferral.md:12-15. A predicate delete by an owner or a Modify All holder now matches rows they did not create. A delete is rolled back whole when a beforeDelete hook or a restrict relation refuses one row (engine-cascade-delete-atomic.test.ts, #7413), so a delete that used to remove the caller's created rows and answer success can now be refused whole by a newly matched row. By reading; not measured, and the dev's S1 measurement covers the update only. Fix: one clause in the banner and the TO line for delete (hook or restrict on a newly matched row), or a measurement showing a multi-row predicate delete is not all-or-nothing.

N7 (nit) — .changeset/35802-predicate-write-floor-deferral.md:15: "A validation rule or hook that refuses that row refuses the whole update the same way" reads as 403 PERMISSION_DENIED; a validation refusal carries its own code and status. Say "refuses the whole update too".

Implemented-by: claude/issue-35802-predicate-write-floor-deferral
Reviewed-by: session_01L9qibvVRcFWKrfWeG5jzPb

VERDICT: PASS

…foreDelete hook on a newly matched row

Claude-Session: https://claude.ai/code/session_01L9qibvVRcFWKrfWeG5jzPb
Co-authored-by: Claude <noreply@anthropic.com>
…declare the delete half of the narrowing

The two permissions pages said the floor stays under public_read_write; only the delete floor does, because that OWD opens row updates. They now also say where a predicate write keeps the floor beside an authored using policy, that the queue basis answers allow under any OWD, and that an on-behalf-of write keeps the floor. The changeset banner now covers a predicate delete refused whole by a beforeDelete hook or a restrict relation, and no longer implies a validation refusal answers 403.

Claude-Session: https://claude.ai/code/session_01L9qibvVRcFWKrfWeG5jzPb
Co-authored-by: Claude <noreply@anthropic.com>
@github-actions github-actions Bot added size/xl and removed size/l labels Nov 20, 2026
…ing allow newly matches

Claude-Session: https://claude.ai/code/session_01L9qibvVRcFWKrfWeG5jzPb
Co-authored-by: Claude <noreply@anthropic.com>
@objectstack-fleet

Copy link
Copy Markdown
Contributor Author

repo:objectstack#7 · os-tesla · session_01L9qibyQBB3KuDoNobNq9LH

L1 delta-2: ACCEPT at 35ef59a3ffc6334e0518078fb9b8c42da8c0c401 (2026-11-20T22:11Z), with CI still owed

This follows my delta ACCEPT 7050824260 at 6ff08df403. This round folds in L2 PASS 7050850078's S4, S5 and N7. The dev report is 7051799391.

What I checked

  • The range 6ff08df403..35ef59a3ff is three commits touching four files: the changeset, the two docs pages, and the test file (+63). No package source changed, so the code findings in 7050824260 carry over.
  • S4: each claim in the per-OWD, per-verb floor text matches the code.
    • Under public_read_write, the update floor yields and the delete floor stays. platformFloorYieldsToObjectWriteModel returns true only when owdOpensRowWrites and owdOpenWritesCoversOperation(operation) both hold, and that second function answers operation === 'update'. On a delete under that OWD, checkEdit / checkDelete see owdForPrincipal answer public, so they abstain and the floor stays. ✔
    • With no owner_id, both floors stay, because the service answers abstain from !hasOwnerField. ✔
    • A queue row is allowed under any OWD, so a controlled_by_parent detail's queue row is the one exception. In checkEdit, sitsInCallersQueue answers allow before owdForPrincipal is read, and controlled_by_parent maps to public there (sharing-service.ts, the m === 'controlled_by_parent' branch).
      • I confirmed this by reading the code. The dev measured it on a scratch rig that was not committed. Carry a pin at the next head if there is one; I do not hold the verdict on it.
    • The predicate path keeps the floor beside an authored using policy, which is the S2 early return. A delegated write keeps the floor. Both pages now say so. ✔
  • S5, the delete half of the narrowing: met.
    • The banner now covers predicate delete: a beforeDelete hook or a restrict relation on a newly matched row refuses the whole delete. FROM/TO, the fix line and the ADR-0087 reason all now say "write", not "update".
    • Two new pins cover it:
      • ALICE: by id, r1 is deleted and r2 gets 409. By predicate, the whole delete gets 409 and nothing is deleted.
      • The Modify All holder: the predicate delete matches all four rows and is refused whole by the hook on r2.
    • A9 (relief off) turns both red. ✔
    • A nit, not held: the new delete pins assert only the status (409), not the refusal's code. The L1 checklist asks for both. The 409 is the test hook's own refusal, so add its code at the next head if one comes.
  • N7. A validation rule or hook refusal refuses the whole update "with its own code". That is the engine's existing predicate-update contract. ✔
  • The Skills-docs: line is present and names security.md lines 69–70. ✔
  • The dogfood battery carries over from 6ff08df403. No package code changed and main was not merged in, so I accept the carry.
  • CI at 35ef59a3ff: 24 success, 17 skipped, 15 in progress, 0 failed at my read. It is not yet green.

Before landing

  • CI green on 35ef59a3ff.
  • The maintainer confirms S1 option (b) on the seat's decision card.
  • The CONTRACT_REVIEW_TIER L2 PASS on this head.

Generated by Claude Code

@objectstack-fleet

Copy link
Copy Markdown
Contributor Author

repo:objectstack#7 · os-tesla · session_01L9qibvVRcFWKrfWeG5jzPb

Contract review

Served-tier: CONTRACT_REVIEW_TIER
Head-sha: 35ef59a3ffc6334e0518078fb9b8c42da8c0c401
Local-runs: none
Scope: packages/plugins/plugin-security/src/predicate-write-floor-deferral.test.ts, .changeset/35802-predicate-write-floor-deferral.md, content/docs/permissions/permissions-matrix.mdx, content/docs/permissions/sharing-rules.mdx, packages/plugins/plugin-security/src/security-plugin-authz-middleware.ts, packages/plugins/plugin-security/src/security-plugin-sharing-verdicts.ts + packages/plugins/plugin-security/src/security-plugin.ts, packages/plugins/plugin-security/src/platform-ownership-policies.ts, packages/plugins/plugin-security/src/security-plugin-rls-filter.ts, packages/plugins/plugin-sharing/src/sharing-service.ts, packages/objectql/src/engine-delete-and-aggregate.ts, packages/objectql/src/engine-delete-cascade.ts, packages/objectql/src/engine-cascade-planning.ts
Security-touching: yes

Delta record on my PASS 7050850078 (head 6ff08df403). Read: git diff 6ff08df403..35ef59a3ff (three commits, four files, +101/-24: one test file, the changeset, two docs pages; no package source and no merge of origin/main); dev report 7051799391 with its before and after for each sentence. The two source files are byte-identical to the head I reviewed, so ① to ④ of record 7050850078 stand for them. Code outside the diff was read on the head. Nothing was built or run: every judgment is derived by reading, and A9 and the controlled_by_parent queue measurement are the dev's. Check-runs on the head when read: 23 success, 17 skipped, 16 in progress, none failed. The PR is a draft.

Result: PASS. No must-fix and no should-fix. S4, S5 and N7 are resolved. Two nits open (N8, N9).

The narrowing-arm coverage of record 7050850078 still holds, and now includes the delete half. No source moved; the banner's wider scope is true of the code and its hook leg is pinned and ablated. As before, this does not stand in for the maintainer's word on option (b) against (a), and the dogfood battery is read as reported at 6ff08df403, where the package code is the same.

① Derived judgments

  1. S4, every new docs sentence against the code.
Sentence (both pages unless noted) Verdict
"Under public_read_write the update floor does not apply (that OWD opens row updates) and the delete floor does" True: platformFloorYieldsToObjectWriteModel yields on owdOpensRowWrites for update only (security-plugin.ts:4522, platform-ownership-policies.ts:280).
"on an object with no owner_id both apply" / "it abstains on both, so both floors stay" True: checkEdit and checkDelete abstain with no owner field, and the queue column rides with it.
"Where record sharing enforces writes (an owner_id and a private or public_read OWD), the sharing service's allow for a row replaces the floor for that row: ownership at the caller's write depth or modifyAllRecords, and, for an update, an edit share" True (sharing-service.ts:1247-1267, :1332-1335).
"On an update, a row sitting in a queue the caller belongs to gets the same allow under any OWD" True: sitsInCallersQueue is asked before the public abstain in checkEdit (:1240) and never in checkDelete. It holds only while the row has no owner: N9.
"A by-id write takes that replacement, and so does a predicate write unless an app-authored using policy for the write applies to the caller (then it keeps the floor beside that policy)" True: the relief returns null when replaced is non-null (security-plugin-authz-middleware.ts:3048-3053), and Layer 1 stays floor OR policy.
"A write made on another user's behalf keeps the floor" True by id (resolvePreImageFloorDrop answers false for delegated; the delegator's floored filter is ANDed) and by predicate (!delegatorSets); pinned by the five on-behalf-of cases.
"A controlled_by_parent detail's by-id write is judged by its master gate instead of the floor" True for a direct write (masterGateCoversThisWrite, step 2.8). An on-behalf-of by-id write keeps the floor there too: N9.
sharing-rules.mdx:59-65: "ships creator-only update/delete policies … under every other OWD both apply, and record sharing can replace them row by row, as below" True, read with the next sentence, which carves out the controlled_by_parent by-id write. The false "stay owner-scoped on writes even under public_read_write" is gone.
"Under public_read_write the sharing service abstains on a delete, so the delete floor stays" (sharing-rules.mdx) True (checkDelete, the public abstain).
"An app-authored policy is never replaced" True.
  1. S5, the delete half. The predicate delete arm reads the matched rows, dispatches beforeDelete per row before any statement, and honours deleteBehavior as the by-id branch does (engine-delete-and-aggregate.ts, the objectql: a predicate delete (multi: true with a filter) skips the referential walk, so a flow's bulk delete_record bypasses restrict, master_detail cascade and set_null #26871 note: "a restrict refuses"). refuseRestrictsInsideOwnCascade runs over every root before the cascade writes anything (engine-cascade-planning.ts:576). So a newly matched row that a hook or a restrict relation refuses refuses the whole delete, and FROM / TO are true for delete: before, the row was not matched and the delete answered success on the rows the caller created (or on none, for a Modify All holder who created none).
  2. The controlled_by_parent queue line is true and widens nothing the "Part of" scoping keeps out. On a detail, checkEdit answers allow for an unowned row in the caller's queue before it abstains on the public-mapped model, so that row enters dropIds on an update. Its by-id write already has no floor (the master gate vouches), and the master gate still judges the predicate write and refuses it whole on a master the caller may not edit, so the row is one the by-id path admits. The half the card leaves open, masterGateCoversThisWrite on the predicate path, is still unset: the master's owner and a Modify All holder still write only rows they created there. This behaviour was already in the code at 99d771ef0b (first record, ② table); this round only declares it.
  3. N7. Resolved: "refuses the whole update too, with its own code".

② Semver level

  • Arm, level, marker. Unchanged and still right: Clause-②: no (narrowing), Metadata-protocol: none, patch, one not-required (no-migration-prescription) marker whose reason now says "such a write" for both verbs.
  • Banner (:12). Now scoped by the cause, "because the record-sharing service answers allow for a write of that row by id", in place of "on an object where record sharing enforces writes". That is the exact population of dropIds, and it takes in the queue basis on any OWD. The verb split of the bases (ownership or Modify All for both; edit share and queue for update) is right.
  • FROM / TO (:14-15) and the fix (:17). True for update (as judged before) and for delete (① 2). "A write of that row by id is refused too, alone" holds for each named cause. One unpinned leg and one edge: N8.
  • :21. The three abstain cases are each true: no owner_id; a delete under public_read_write (an update there has no floor); a controlled_by_parent detail except the queue row on update.
  • :38, :40. True (① 3); the closing sentence now names delete.

③ Boundary flags

  • Part of #35802 stays honest (① 3).
  • Skills-docs. skills/objectstack-data/references/data-hooks.md already teaches the per-row before* dispatch of a multi: true write; nothing there teaches the creator-only skip. none holds with delete in scope.
  • Deviation accepted. The round was called prose-only and added two pins in the test file. They are the pins S5 asked for, and no source moved.
  • SQL push-down. No change this round.

④ Design judgment

The two new pins are real.

Pin Result
ALICE, predicate delete, hook refuses r2 Real: asserts a refusal, status 409, no row deleted; then the by-id oracle on a second copy (r1 deleted, r2 refused 409, ['r1']). The hook is inert outside these cases (an empty id set, cleared in finally).
Modify All holder, predicate delete, hook refuses r2 Real: refusal, 409, no row deleted. No by-id leg, which the first case carries.

A9. The relief guard forced false turns both red because the deletes answer success, which is the FROM the banner states. Credible: with the relief off ALICE's Layer 1 is the floor, r2 is not matched, and the hook never sees it.

First- and second-record findings.

Finding State
S4 Resolved (① 1), including the pre-existing sentence at sharing-rules.mdx:59-62.
S5 Resolved for the hook leg by measurement and pins; the restrict leg is true by reading and unpinned (N8).
N7 Resolved.
N5 Stands as a note.

N8 (nit) — .changeset/35802-predicate-write-floor-deferral.md:12, :15: the restrict leg of the delete banner rests on reading (engine-delete-and-aggregate.ts, #26871; engine-cascade-planning.ts:576), not on a pin or a measurement in this PR. One case with a restrict child on a newly matched row would close it. Edge of "deletes nothing": where the delete's cascade spans datasources (planCascadeAtomicity answers 'split') the engine opens no transaction and warns, so a refusal raised after the cascade has started can leave earlier cascade writes; a beforeDelete hook or a restrict on a matched root is judged before any write and is not affected.

N9 (nit) — two readings a careful author could take wrong, both pages. "A row sitting in a queue the caller belongs to" is an allow only while the row has no owner (sitsInCallersQueue answers false once owner_id is set). "A controlled_by_parent detail's by-id write is judged by its master gate instead of the floor" is true for a direct write; an on-behalf-of by-id write of a detail keeps the floor, which the preceding sentence implies but does not tie to this one.

Implemented-by: claude/issue-35802-predicate-write-floor-deferral
Reviewed-by: session_01L9qibvVRcFWKrfWeG5jzPb

VERDICT: PASS

@objectstack-fleet

Copy link
Copy Markdown
Contributor Author

repo:objectstack#7 · os-tesla · session_01L9qibvvVzM5KhCWkT5f45c

维护者速读

  • 用户能看到什么变化:业务用户按条件批量改动或删除(流程、脚本、批量操作)时,命中的行和逐条按 id 改删一致。拥有者、改全部权限(Modify All)、编辑共享和队列都算数,不再只命中自己创建的那几行。
  • 收窄的地方:新命中的行里只要有一行被拒(没过检查、校验、钩子,或者被限制删除的关联挡住),整批就拒绝。以前同样的请求会"成功",但只改了一部分。这就是你决定卡上的 B 项。
  • 代价:一个普通成员的条件命中 1 万条别人拥有的行时,耗时从 47 毫秒升到约 5.3 秒,受 1 万行上限约束。后续卡 sharing: a predicate write asks one write verdict per candidate row, so a member bulk update over 10,000 rows owned by others costs ~5 s for no extra row; give ISharingService a bulk write-scope and verdict contract #35934 会把这部分开销降掉。
  • 不在这次范围:跟随主表权限的明细表那一半,等你的另一张决定卡。
  • 要你做什么:这是收窄,请在 GitHub 上点一次 Approve。你如果在 S1 决定卡上选了 A 或 C,这个 PR 会先改出新版本,不会照现在的版本合并。
  • 席位意见:通过,没有必改项。

席位核对

Seat 7: hand-off for the maintainer's approval · head 35ef59a3ffc6334e0518078fb9b8c42da8c0c401 · Part of #35802 (p1) · not governed · declared narrowing (Clause-②: no (narrowing), Metadata-protocol: none, patch) · 2026-11-20T22:29Z

@objectstack-fleet

Copy link
Copy Markdown
Contributor Author

repo:objectstack#7 · os-tesla · session_01L9qibvvVzM5KhCWkT5f45c

Narrowing hand-off: pm:awaiting-merge on, after the seat record on this head (2026-11-20T22:30Z). Waiting for an authorized APPROVED review (os-zhuang) and the maintainer S1 answer.

@objectstack-fleet objectstack-fleet Bot added the pm:awaiting-merge PR only: landing waits on the maintainer's own review and merge (SKILL.md 复核 ②); never on an issue label Nov 20, 2026
@objectstack-fleet
objectstack-fleet Bot marked this pull request as ready for review November 20, 2026 22:31
@os-zhuang
os-zhuang added this pull request to the merge queue Nov 21, 2026
@objectstack-fleet objectstack-fleet Bot removed the pm:awaiting-merge PR only: landing waits on the maintainer's own review and merge (SKILL.md 复核 ②); never on an issue label Nov 21, 2026
Merged via the queue into main with commit 1c4db09 Nov 21, 2026
68 checks passed
@os-zhuang
os-zhuang deleted the claude/issue-35802-predicate-write-floor-deferral branch November 21, 2026 03:34
247257110 pushed a commit to 247257110/objectstack that referenced this pull request Nov 22, 2026
…e an authored write policy, so a creator writes their own row by id (objectstack-ai#36117)

Fixes objectstack-ai#35917

Clause-②: yes (widening)
Metadata-protocol: none

## 维护者速读

- 用户能看到什么变化:业务对象上配了「满足条件可改/删」规则时,创建人按单条记录改或删自己建的记录不再被误拒,和批量改的结果一致。
- 为什么做:修复「按单条改」与「批量改」对同一条记录给出相反答案的问题,按你已拍板的「放行」方案落地。
- 出错会怎样:最坏情况是创建人能改删一条本该被规则拦住的自己的记录;改动只在服务端权限判断里,撤回这个合并即可恢复。
- 要你做什么:无。

## What changes

The maintainer ruled option A on objectstack-ai#35917 (ruling comment 7063130499; the
analysis is comment 7062795693): under a record sharing `allow`, the
platform ownership floor (`created_by == current_user.id`) stays an OR
term beside an app-authored update or delete `using` policy. It is
dropped only where it is the OR's last term.

- **Pre-image row gate** (`computeLayeredRlsFilter`,
`security-plugin-rls-filter.ts`). With `dropPlatformOwnershipFloor`, the
floor leaves Layer 1 only when the policies left after it carry no
`using` term (asked through the same field-existence pass the compile
uses). Beside an authored `using` it stays.
- **Post-image check** (`computeWriteCheckFilter`, same file). The
defaulted check keeps the floor term on the same condition, so the
stored row is judged by the same OR. A `check` an author wrote still
refuses.
- **Authored probe** (`checkAuthoredRowWrite`,
`security-plugin-authored-row-write.ts`). It now takes the floor out of
the permission SETS by provenance instead of through the knob, so it
still judges the authored policies alone and still answers `abstain`
where no authored policy matches.
- Every caller of `dropPlatformOwnershipFloor` gets the one meaning: the
step 2.7 by-id gate, the predicate path's relief
(`predicateWriteFloorRelief`, comments only: its `floored OR id IN
dropIds` now agrees with the by-id answer), the `controlled_by_parent`
master check, the delegator's own composition
(`delegatorOwnWriteFloorOptions`) and `security/explain`. The authored
probe is the one caller that no longer uses the knob, for the reason
above.
- The claim's surface was amended to cover `security-plugin.ts`, so
these edits are no longer a breach:
  - the `RlsFilterOptions.dropPlatformOwnershipFloor` jsdoc line;
- N1: the `checkAuthoredRowWrite` docblock no longer says the probe is
driven by the knob;
- the L1-a item: `writeCheckPolicies` point 3 now says the floor stays
in the check beside an authored `using` under an `allow`, and names the
pass-1 corner where the check keeps a floor the pre-image dropped.
- **Docs and changeset (S2, S3, N2):**
- `permissions-matrix.mdx` now agrees with `sharing-rules.mdx`: both
paths keep the floor beside an authored `using`.
- `rls.mdx` says a write policy is one more OR term that adds rows,
names the cbp exception, and says where a cap goes.
  - The changeset and `sharing-rules.mdx` now:
- drop "a creator who does not own the row is still refused": write
depth, Modify All, an `edit` share or a queue earn `allow`;
- scope "by id and by predicate agree" to the rows the floor admits and
name the divergence;
- say a `check` bounds only the stored image, and name a `beforeUpdate`
hook reading `ctx.previous` for the prior state, `beforeDelete` for a
delete, and a hook on the detail object for a master's details;
    - state the master-gate consequence;
- name the lifecycle verbs (`transfer` with update, `purge` with delete;
`restore` addresses no single row id and does not meet the gate) and the
fail-closed outcome that moves.
  - N3 and N5 are left, as directed.

**Removed capability.** A `using` write policy no longer stops a row's
own creator once record sharing says `allow`, and the same holds for a
`controlled_by_parent` master's creator writing its details beside the
master's authored update policy. A `check` bounds only the stored image
of an update; a limit on the prior state goes in a `beforeUpdate` hook
reading `ctx.previous`, a delete's limit in a `beforeDelete` hook, and a
limit on a master's details in a hook on the detail object.

**Fixture changes (the ruling turns 22 pinned refusals into
admissions).** The objectstack-ai#24746 / ADR-0090 D10 fixtures pinned the old refusal
on rows the delegator created. Each test keeps its invariant and every
assertion exactly as written; only the rows moved:

- `delegated-write-never-exceeds-delegator.test.ts` (12 tests: five
held-row cells and the post-image store test, under both tenancy
postures). `held_1`, `held_del_direct`, `held_del_agent`,
`store_direct`, `store_agent` and the master `m_held` are now created by
OTHER (owner still BOUNDED); `held_2` is owned and created by OTHER. New
rows `held_created`, `held_created_del_direct`, `held_created_del_agent`
(owned and created by BOUNDED) back two new cells, update and delete: a
held row the delegator created is admitted for the delegator and on its
behalf.
- `explain-enforce-parity.test.ts` (10 tests: five objectstack-ai#24746 rows under
both postures). `p_bounded_held`, `p_del_bounded_held` and
`m_bounded_held` are now created by D_OTHER. New row
`p_bounded_held_created` backs two new 'objectstack-ai#35917' table rows, agent and
direct update, both admitted, with explain equal to enforce.

## Why

On an object where an authored update or delete policy applied (for
example "any open deal"), a sharing `allow` deleted the floor term from
the OR, so the creator-owner's own closed row was refused by id with 403
while a predicate write over the same row wrote it. By id and by
predicate now give one answer on the rows the floor admits (the open-row
divergence on rows it does not admit is tracked on objectstack-ai#35934).

## Tests

New describe in `predicate-write-floor-deferral.test.ts`, `[objectstack-ai#35917]
beside an authored widener ...`, extending the objectstack-ai#35914 matrix with the
widener:

| Caller (all rows closed unless named) | By id | Predicate |
| --- | --- | --- |
| ALICE, owner-creator, her closed r1, update and delete | admitted (was
403, the defect) | admitted (agrees) |
| ALICE with r2 open | r1 by the floor, r2 by the widener | the same
rows |
| BOB, owner who created none | nothing, as before | nothing |
| CAROL, creator who owns none | nothing: the floor admits, record
sharing does not | nothing |
| Modify All holder, rows it did not create | nothing, unchanged
(ADR-0066 ①) | nothing |
| Modify All holder, open r2 and r3 | r2, r3, unchanged | r2, r3 |
| Modify All holder, a closed row it created | admitted by the floor |
admitted |
| DAVE, edit-share target on closed rows | nothing | nothing |
| DAVE, closed shared r2 he created (N4) | update admitted by the floor;
delete refused (ADR-0111 D3) | the same |
| DAVE, update with r2 open, shared to him | r2, not the closed r3 | the
same |

CONTROLS: an authored EMEA `check` still refuses ALICE's closed r1 moved
out of EMEA (403 PERMISSION_DENIED); the tenant wall still refuses her
own row in another organization; on an owner-less object (sharing
abstains) the floor still applies (r1, r3 only). `security/explain`
answers the verdict the write gets.

Also pinned (N4):

- The edit-share target DAVE who created the closed shared r2, under the
wideners. The update is admitted by the floor, by id and by predicate.
The delete is still refused (ADR-0111 D3). A1 turns the update red.

Ablations (each through `scripts/ablation-replace.mjs` on the committed
fix, restore proven by an empty `git diff HEAD`):

- A1, pre-image keeps deleting the floor term: pin file 8 failed / 49;
rewritten D10 + parity files 8 failed / 192 (all four new `held_created`
cells and all four new parity rows).
- A2, post-image check keeps deleting the floor term: pin file 4 failed
/ 49.
- A3, authored probe composes with the floor in its sets: pin file 7
failed / 49; `authored-row-write-verdict.test.ts` 1 failed (the abstain
pin for a creator whose authored policy does not match).

Full plugin-security suite and typecheck at the head: see Verification.

## Acceptance notes

- **The objectstack-ai#24792 delegator-own guard is pinned where it still narrows.**
On an ordinary object, ruling A makes the delegator's own composition a
superset of the floor-kept delegator filter the delegated path already
ANDs, so the guard narrows nothing there. It still narrows on a
`controlled_by_parent` object. There the delegator's direct write
carries the master-gate vouch, so the floor yields and the delegator's
authored detail policy decides alone, while every floor-standing filter
on the delegated path admits a row the delegator created. The body's
earlier "an OWD that opens row writes" was wrong:
`platformFloorYieldsToObjectWriteModel` answers for `public_read_write`
from the object alone, so both delegator filters drop the floor there
and the guard narrows nothing. The D10 rig gets the authored update
policy `note != 'held'` on its cbp DETAIL, a grand detail whose master
is DETAIL (DETAIL becomes a middle master), and three pins, each under
both postures:
  - by-id update of `d_note_held` (the step 2.7 site);
  - the store test on `d_store_*` (the post-image check site);
- update of `g_under_mid_held` under the held middle master (the
master-gate site).

Each pin refuses both the delegator's own write and the write on its
behalf, and explain agrees for the two cells. Ablation on the D10,
parity and pin files (253 tests), each through `ablation-replace.mjs`,
restore proven by `git diff HEAD` = 0 lines:
- G1 (`delOwnWriteFilter` removed): 2 red, the step 2.7 cell under both
postures;
- G2 (`delOwnCheckFilter` removed): 2 red, the detail store test under
both postures;
- G3 (`delegatorOwnMasterWriteFilter` removed): 2 red, the middle-master
cell under both postures.
- **Open-row by-id vs predicate divergence (held finding, not fixed
here).** Under an authored write widener, an OPEN row the caller neither
owns nor holds a share on is admitted by id (the authored probe lifts
the sharing refusal) but left out of a predicate write (the sharing bulk
scope stays owner and shares). The relief test in
`predicate-write-floor-deferral.test.ts` records it: by id r1, r2, r3,
r4; by predicate r1, r2. Tracked on objectstack-ai#35934 (comment 7065565832): it is
that card's predicate bulk write scope, in the same files, so it was
folded there rather than filed apart. `Fixes objectstack-ai#35917` still holds: ruling
A (7063130499) asks for one answer on the rows the platform floor
admits, and this divergence is on rows the floor does not admit.
- The objectstack-ai#35802 relief test in `predicate-write-floor-deferral.test.ts` now
pins the by-id answer r1, r2, r3, r4 against the predicate's r1, r2.
That locks the held out-of-scope finding (a), the open-row by-id vs
predicate divergence, in place until that finding is worked.
- objectstack-ai#35934 proceeds on its own premise and is out of scope here.
- The `controlled_by_parent` half of objectstack-ai#35802 is out of scope here.
- **S4, the master check's widening is pinned.** The D10 rig gets the
master `m_held_created`: held, owned and created by the delegator. Under
it are the details `d_under_held_created` and
`d_under_held_created_del_direct` / `_agent`. A detail update and a
detail delete are both admitted for the delegator and on its behalf,
with explain agreeing, under both postures. A1 turns all 4 red.

## Verification

- Head `a82a0b1be0` for every run below. Head `1b90fa5f2a` (seat 4,
contract record 7065591342 NEW-1/NEW-2/NEW-4) changes only `rls.mdx`
prose and one changeset sentence.
- Full plugin-security suite: VERDICT command-exit 0. Test Files 286
passed (286); Tests 7151 passed, 45 skipped (7196).
- `pnpm --filter @objectstack/plugin-security typecheck`: VERDICT
command-exit 0.
- dispatch-gates at `a82a0b1be0` derived 104 families: 101 exit 0.
`--ran` reconciliation: 104 accounted, 101 run, 3 NOT MEASURED, 0 unrun.
- The three NOT MEASURED exited 3 with PREREQUISITE NOT MET. CI runs
them:
  - `pnpm --filter @objectstack/spec run check:skill-examples`
  - `pnpm check:dual-build-cjs-loads`
  - `pnpm check:i18n`
- `check-governed-merges.mjs --pr 36117`: NOT governed. 0 of 11 paths
hit the register; 594 changed lines.

Two-minute check: `pnpm --filter @objectstack/plugin-security exec
vitest run --maxWorkers=2 src/predicate-write-floor-deferral.test.ts`
prints every test passed, including the `[objectstack-ai#35917] beside an authored
widener` describe.

Read first: (1) `security-plugin-rls-filter.ts`, the `withoutFloor` hunk
in `computeLayeredRlsFilter`, the decision itself; (2) the
`floorReplaced` hunk in `computeWriteCheckFilter`, which must agree with
(1); (3) `security-plugin-authored-row-write.ts`, the probe that must
not start answering `admit`.

## Human Minimum

- [x] 1. Schemas start as Zod; `packages/spec` holds no runtime logic.
(not touched)
- [x] 2. Every name I added uses the casing for its kind.
- [x] 3. No formatter ran; `pnpm lint` passes. (CI runs the repo lint)
- [x] 4. One issue, one branch off an up-to-date `main`, one pull
request.
- [x] 5. A change that publishes carries a changeset, and both
declaration lines are filled in here and in the changeset.
- [x] 6. `packages/spec` touched: not touched.
- [x] 7. No hand edits to `content/docs/references/`,
`packages/*/CHANGELOG.md` or `content/docs/releases/`.
- [x] 8. Title, body and comments are in English.
- [x] The *Before Submitting* list in CONTRIBUTING.md is done.

---

_Generated by [Claude
Code](https://claude.ai/code/session_01L9qibvVRcFWKrfWeG5jzPb)_

<!-- signed: repo:objectstack#4 · os-project-manager ·
session_01FEkQ5krBqrrgxCYgjXmfbv -->

---------

Co-authored-by: Claude <noreply@anthropic.com>
Nenzyz pushed a commit to Nenzyz/objectstack that referenced this pull request Dec 1, 2026
…te write's candidates as one set (objectstack-ai#37558)

<!-- claude-projects-attribution: {"github_login":"os-bill"} -->
_Requested by **Bill** · [project
thread](https://claude.ai/code/project/chan_016iMXWSZDzqWRWvWzdNo8wg?thread=cmsg_016iMXWSZDzqWRWvWzdNo8wg8ZBQe4UHadd2fGHGeWRW9V)_

repo:objectstack#5 · os-bill · session_01Utp6CbdHk3orAeensH6EzS

Fixes objectstack-ai#35934
Ruling-ref: 7190344023
Clause-②: yes (widening)
Metadata-protocol: none

## 维护者速读

- 用户看到什么变化:成员或「修改全部」管理员按条件批量改、删上万条记录时,速度从几秒降到零点几秒;改哪些行、删哪些行与之前完全一样。
- 为什么做:属于「记录共享与权限性能」这一组工作,解决批量写入时权限检查逐行读库、读数随行数增长的问题。
- 出错会怎样:最坏情况是批量写入里本该放行的行被拒(查询失败一律按拒绝处理,不会多放行);新能力是可选的,撤回本次改动即恢复逐行检查。
- 要你做什么:新增的两个接口名称在你的否决窗口内,请确认或否决命名。

## What changes

`ISharingService` (`packages/spec/src/contracts/sharing-service.ts`)
gains two OPTIONAL members, as ruled (option C):

- `checkEditMany(object, recordIds, context)` and
`checkDeleteMany(object, recordIds, context)`.
- Each answers `SharingWriteVerdict[]`: answer i is the verdict
`checkEdit` / `checkDelete` answers for `recordIds[i]` (same length,
same order, repeats kept).
- Same bases, same order of decision, same verb boundary: an `edit`
share is `allow` to `checkEditMany` and `deny` to `checkDeleteMany`.
- A chunk whose lookup fails answers `deny` for each of its records,
never `abstain`.
- Name and precedent: `checkEdit` / `checkDelete` on this same contract,
plus the data protocol's `…Many` suffix (`IDataDriver.updateMany?` /
`deleteMany?`, both optional). Two members rather than one with a verb
argument, because this contract already splits the write verdict by
verb.

`SharingService` (`plugin-sharing`) implements both. `checkEdit` /
`checkDelete` are now the one-record case of the same private
`writeVerdicts`:

- Object-level decisions (bypass list, schema, OWD, owner field,
principal) are made once per call.
- Ids are read in chunks of 1,000 (`WRITE_VERDICT_CHUNK`; the docblock
gives the dialect bounds: Oracle's 1,000-item IN list, SQL Server's
2,100 parameters).
- Per chunk: one read of the rows (owner, and queue plus organization
when the object has an ownership queue column), and for an update one
read of the caller's write-level shares.
- The owner set, each queue membership and the Modify All probe are
resolved at most once per call.
- A single record costs the reads it always did. One exception: an
update on an object with an ownership queue column now reads the row
once instead of twice (queue and owner in one read).

`SecurityPlugin` (`plugin-security`) feature-detects the set form on the
kernel's `sharing` service on the predicate write floor relief (objectstack-ai#35802 /
objectstack-ai#35914):

- If the set form is there: one set-form call for the candidates the
platform floor does not admit, with one context built once
(`__writeScope`, the external grant patch). An answer that is not
`allow` or `deny` normalises to `abstain`. A probe that throws, or a
list of the wrong length, gives `deny` for all, with one error logged.
- If it is not there: per row, 25 at a time, exactly as before.
- Delegated callers are still not asked.
- Which rows are written is unchanged either way.

Not in this PR (as ordered): the 2a authored-scope change. Untouched:
ADR-0155, `buildWriteFilter` and every find.

Changeset: patch for `@objectstack/spec`, `@objectstack/plugin-sharing`
and `@objectstack/plugin-security`. Rule read: AGENTS.md Post-Task
Checklist 3. Kind `none` gives patch, and an optional, non-protocol
contract widening ships patch.

## Tests

Measured on SQLite, N = 10,000 rows owned by another user. The bench is
the kept one from report 7187608580, extended with set-form counting and
a per-row mode. It is uncommitted, as ordered. Set form is this branch;
per-row is the same branch without the set members; main is the report's
readings.

| case | main | per-row on this branch | set form |
|---|---|---|---|
| member predicate update | 20,004 reads · 6,013 ms | 20,004 · 6,603 ms
| **24 reads · 270 ms** |
| member predicate delete | 10,003 reads · 2,178 ms | 10,003 · 1,957 ms
| **13 reads · 111 ms** |
| Modify All predicate update (10,000 written) | 10,004 reads · 1,880 ms
| 10,004 · 1,765 ms | **14 reads · 242 ms** |

- Set mode made one set call per write, with at most one bypass probe
(per row: 10,000).
- The per-row reads equal main's, so the by-id path gained no read.

New pins:

- `plugin-sharing/src/sharing-service.test.ts`, **equivalence**:
`checkEditMany` / `checkDeleteMany` equal `checkEdit` / `checkDelete` on
every row.
- Objects × callers × verbs: private with a queue column, public
read/write, no owner field, phantom owner anchor, shares inert, unknown
object.
- Callers: member, unit depth, Modify All at own and org depth,
delegated, principal-less, guest, system.
- Rows: own, owner-not-creator, created-not-owned, edit-shared,
read-shared, queue mine / not mine / other org, ownerless, missing.
  - Also: the empty list, and order with repeats.
- Same file, **counted reads**: 10,000 records give 10 row reads, 10
share reads, 1 bypass probe and 1 owner set; a delete makes 0 share
reads. A per-row control of 300 rows gives 300 / 200 / 100. A queue
membership is asked once over 2,500 rows.
- Same file, **fail-closed**: 1,500 ids with a failing second chunk give
500 `deny` and one log line. A share read that throws denies its whole
chunk, owned rows included.
- `plugin-security/src/predicate-write-floor-deferral.test.ts`,
**feature-detect**:
  - The objectstack-ai#35914 rig's 60 candidates go in one set call.
- Without the set form: the same rows and the same per-row asked list
for ALICE, BOB, CAROL, the manager, DAVE and two delegated callers, for
update and delete.
- Host doubles: stringified ids, normalisation, a throwing or
wrong-length answer gives all `deny`, and delegated or no-floor callers
are not asked.

Ablations: each one was committed first, mutated through
`scripts/ablation-replace.mjs`, and restored (blob equals HEAD, `git
status` clean).

1. Share membership emptied: 7 equivalence cases red.
2. The chunk catch answers `abstain`: 2 fail-closed cases red.
3. `WRITE_VERDICT_CHUNK = 1`: 2 counted-reads cases red.
4. Feature-detect `return null` changed to `return []`: 10
plugin-security cases red.

## Acceptance notes

- Docs: `content/docs/**/sharing-service.mdx` lists only the boolean
methods, and says nothing about bulk write cost. It is outside this
card's file surface, so it is left to the docs-drift follow-up.
- The pending changeset from objectstack-ai#35802 describes the per-row cost that this
PR supersedes in the same release; this changeset states the new cost.
- By id, an update of a queue-column object now reads queue and owner in
one row read instead of two. The verdicts are pinned equal.
- The bench file is not committed (dispatch order).

## Verification

- Two minutes: `pnpm --filter @objectstack/plugin-sharing exec vitest
run --maxWorkers=2 src/sharing-service.test.ts -t "35934"`. Expect every
`[objectstack-ai#35934]` case green, including `10,000 records: two reads per chunk of
1,000`.
- Read first, by risk:
1. `plugin-sharing/src/sharing-service.ts`, `writeVerdicts`: the per-row
order inside the chunk loop, and the try per chunk.
2. `plugin-security/src/security-plugin-sharing-verdicts.ts`,
`resolveSharingWriteVerdicts`: normalisation and the length check.
3. `packages/spec/src/contracts/sharing-service.ts`: the member
docblocks.

Local runs at the final head `14bf9f91`, through
`scripts/pm/os-verify-lock.sh`:

- `plugin-sharing`: `pnpm test` gives 78 files, 1,748 passed / 11
skipped. Typecheck passed. `sharing-service.test.ts` was re-run after
the last commit: 289 passed.
- `plugin-security`: `pnpm test` gives 290 files, 7,330 passed / 45
skipped. Typecheck passed. Run at `c6f613be`; the last commit touched
only a `plugin-sharing` test file.
- `spec`: `src/contracts/sharing-service.test.ts` gives 15 passed, and
`check:generated` reports all 14 artefacts up to date.
- Dogfood: the dependency closure was built, then the nine files that
judge the sharing write paths were run. 9 files, 110 tests passed. The
files: authored-row-write-scope, bulk-widener-probe,
owd-public-read-write-write-floor, showcase-scope-depth-write,
federated-phantom-share-grant, direct-share-grant-is-manual,
cbp-parent-attachment-comment-gates,
predicate-write-unreadable-not-matched, armed.

<details><summary>Derived gate families: 95 derived, 95 run</summary>

- `node scripts/pm/dispatch-gates.mjs --commands` gives 95 commands. The
list is the same at `c6f613be` and at `14bf9f91`. The `--ran`
reconciliation reports 95 run, 0 NOT-MEASURED, 0 UNRUN.
- The full run was at `c6f613be`: 92 exited 0 and 3 exited 1.
- `check:dts-closure` and `check:dual-build-cjs-loads` went red while a
concurrent closure build of mine had
`packages/plugins/organizations/dist` half-written. Re-run after the
build: both exit 0 (267/267 declaration files; 127 require entry points
load).
- `check:where-matcher` was a real finding: the new engine double read a
where combinator as a field name. Fixed in `14bf9f91` (the double now
refuses a combinator), and the gate exits 0.
- 20 families that read test files were re-run at `14bf9f91`, and all 20
exited 0: where-matcher, objectql-double-limit, engine-double-contract,
nul-bytes, test-source-alias, type-check-debt,
cross-package-test-inputs, query-options-erasure, refd-timer-probe and
eleven more.
- Local-only `check:dev-prereqs` scan: NOT MEASURED (`--self-test`
passed). This box has 35 unrelated `@object-ui` packages unbuilt, and
the scan judges the whole workspace.
- `node scripts/pm/overlap-check.mjs --branch=HEAD` at `14bf9f91` gives
VERDICT clean: it merges cleanly with origin/main `1af67b26`, and no
open pull request head shares a file.

</details>

🤖 Generated with [Claude Code](https://claude.com/claude-code)

<!-- signed: repo:objectstack#5 · os-bill ·
session_01Utp6CbdHk3orAeensH6EzS -->

---------

Co-authored-by: Claude <noreply@anthropic.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

documentation Improvements or additions to documentation size/xl tests tooling Fix lands in tooling, not a product package — enters pm:queue only with Unblocks: or a named surface

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants