Repository navigation
fix(plugin-security)!: a predicate write composes the platform ownership floor per row, as the by-id write does - #35914
Conversation
… writes Claude-Session: https://claude.ai/code/session_01L9qibvVRcFWKrfWeG5jzPb Co-authored-by: Claude <noreply@anthropic.com>
…nst the by-id oracle Claude-Session: https://claude.ai/code/session_01L9qibvVRcFWKrfWeG5jzPb Co-authored-by: Claude <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01L9qibvVRcFWKrfWeG5jzPb Co-authored-by: Claude <noreply@anthropic.com>
📓 Docs Drift CheckThis PR changes 1 package(s): 3 hand-written doc(s) NAME something this change touched and may need an implementation-accuracy re-verification:
What this run could not see
Coarse fallback — 18 page(s) merely mention a changed package (the pre-#9192 predicate, kept for the deliberately-wide backstop): Which tree this was computed onThis run read A worktree cut from an older # 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
|
|
repo:objectstack#7 · os-tesla · session_01L9qibyQBB3KuDoNobNq9LH L1: REWORK at
|
Claude-Session: https://claude.ai/code/session_01L9qibvVRcFWKrfWeG5jzPb Co-authored-by: Claude <noreply@anthropic.com>
|
repo:objectstack#7 · os-tesla · session_01L9qibvVRcFWKrfWeG5jzPb Contract reviewServed-tier: 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 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
② Semver level
③ Boundary flags
④ Design judgmentAre the pins 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 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. Scenario, by reading: an object with
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 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 S2 (should-fix) — the verdict loop runs where it cannot change anything. S3 (should-fix) — five legs the claims rest on have no pin; each mutant below leaves the 14 cases green.
N1 (nit) — N2 (nit) — N3 (nit) — N4 (nit) — N5 (nit) — the write can now bind the readable ids and N6 (nit) — Implemented-by: 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>
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>
Claude-Session: https://claude.ai/code/session_01L9qibvVRcFWKrfWeG5jzPb Co-authored-by: Claude <noreply@anthropic.com>
|
repo:objectstack#7 · os-tesla · session_01L9qibyQBB3KuDoNobNq9LH L1 delta: ACCEPT at
|
|
repo:objectstack#7 · os-tesla · session_01L9qibvVRcFWKrfWeG5jzPb Contract reviewServed-tier: Delta record on my PASS 7048114223 (head 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
② Semver level
③ Boundary flags
④ Design judgmentFirst-record findings.
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 S4 (should-fix, docs prose) — both corrected pages say the floor stays under S5 (should-fix, changeset prose) — the BREAKING banner names a predicate update only; a predicate delete has the same outcome. N7 (nit) — Implemented-by: 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>
…ing allow newly matches Claude-Session: https://claude.ai/code/session_01L9qibvVRcFWKrfWeG5jzPb Co-authored-by: Claude <noreply@anthropic.com>
|
repo:objectstack#7 · os-tesla · session_01L9qibyQBB3KuDoNobNq9LH L1 delta-2: ACCEPT at
|
|
repo:objectstack#7 · os-tesla · session_01L9qibvVRcFWKrfWeG5jzPb Contract reviewServed-tier: Delta record on my PASS 7050850078 (head 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 ① Derived judgments
② Semver level
③ Boundary flags
④ Design judgmentThe two new pins are real.
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.
N8 (nit) — N9 (nit) — two readings a careful author could take wrong, both pages. "A row sitting in a queue the caller belongs to" is an Implemented-by: VERDICT: PASS |
|
repo:objectstack#7 · os-tesla · session_01L9qibvvVzM5KhCWkT5f45c 维护者速读
席位核对Seat 7: hand-off for the maintainer's approval · head
|
|
repo:objectstack#7 · os-tesla · session_01L9qibvvVzM5KhCWkT5f45c Narrowing hand-off: |
…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>
…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>
repo:objectstack#7 · os-tesla · session_01L9qibvVRcFWKrfWeG5jzPb
Part of #35802 (the
controlled_by_parenthalf 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 acheckis judged on every row amulti: trueupdate writes and one failing row refuses the write; no skill teaches that a predicate write skips rows the caller did not create.维护者速读
What changes
packages/plugins/plugin-securityonly. The #5492 floor composition (the sharing service'sallowreplaces the platform's ownowner_only_writes/owner_only_deletes;abstainanddenykeep it) now runs per matched row on the PREDICATE write path, which never reached it because it sits underextractSingleId(opCtx) != nullin step 2.7.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):replaced:computeLayeredRlsFilterwithdropPlatformOwnershipFloor, the Layer 1 the by-id write of a row composes once its floor is replaced. Where it is not null, an authoredusingpolicy remains, and the relief answers null with no read and no verdict. Policies compose by OR only, so a rowflooredrefuses fails every authored policy too, and its by-id write is refused as well: replacing the floor can add no row there (L2 S2);resolvePreImageFloorDrop(predicateWriteFloorDropIds, new insecurity-plugin-sharing-verdicts.ts, asked in batches of 25);floored OR id IN dropIds. Layer 0 is recomposed exactly as it stood.check. A predicate update's row whose floor step 3 replaced is held to the checkcomputeWriteCheckFiltercomposes withdropPlatformOwnershipFloor(what step 2.7 passes for a by-idallow); every other row keepscheckParts. Without this the floor'susing, defaulted as the check, refused on the new row the write it had just admitted (ablation leg 2 below).content/docs/permissions/permissions-matrix.mdxandcontent/docs/permissions/sharing-rules.mdxsaid thatmodifyAllRecordsdoes not liftmember_default's owner-scoped write policies on an ordinary business object, and that members stay owner-scoped on writes even underpublic_read_write. The first has been false by id since Row-level write gate consults neithermodifyAllRecordsnorsys_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 Apublic_read_writeobject is only writable by the row's creator —showcase_contributorgets 403 editing ashowcase_projectit can read, where the access matrix declaresedit:true#8023. Both pages now say: the floor is creator-only (created_by == current_user.id). Underpublic_read_writethe update floor does not apply and the delete floor does; with noowner_idboth apply. Where record sharing enforces writes (anowner_idand aprivateorpublic_readOWD), the sharing service'sallowfor a row replaces the floor for that row: ownership at write depth ormodifyAllRecords, and, for an update, aneditshare. On an update, a row in a queue the caller belongs to gets the sameallowunder any OWD. A by-id write takes the replacement, and so does a predicate write unless an authoredusingpolicy for the write applies to the caller. An on-behalf-of write keeps the floor. Acontrolled_by_parentdetail's by-id write is judged by its master gate. An app-authored policy is never replaced.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, categoryno-migration-prescription), and the measured verdict cost.deleteaskscheckDelete, 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), andmasterGateCoversThisWrite(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/mainf44758b), rows changed by a predicate write over the 4-row owner x creator matrix vs the by-id path:Tests
New
src/predicate-write-floor-deferral.test.ts, 29 cases, on theisolatedtenancy posture so Layer 0 is composed on every write: the realSecurityPluginover a realObjectQL+SqlDriver(better-sqlite3), the realSharingServiceand its middleware, and the shippedmember_defaultfloor (the rig ofcontrolled-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 askscheckDeleteand nevercheckEdit; no verdict under an authoredusingpolicy); 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);idsOfReadableScopekeeping bigint ids; and three direct pins onpredicateWriteFloorDropIds(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 usedtenancy.enabled: falseand its manager cases passed for that reason).A new file rather than a
describeinrow-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
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_DENIED403, nothing written. By id, r1 is written and r2 is refused 403. The same follows from a validation rule, a hook or areadonlyWhenlock 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: 403PERMISSION_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.beforeDeletehook 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. Arestrictrelation on a newly matched row refuses the whole delete the same way; that is pinned at the engine inengine-cascade-delete-atomic.test.tsand 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).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.controlled_by_parentdetail, 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 throughmasterGateCoversThisWrite(the master gate), whichRlsFilterOptionsdocuments 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. HencePart of. Measured in round 4 with a scratch rig (not committed): a member who sits in queueq_opsand may edit the master predicate-updates two detail rows, neither created by them, both with no owner. The one inq_opsis written (the sharing service answersallow, so the floor is replaced) and the one inq_otheris 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'scontrolled_by_parentline now names this exception.checkEditand 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 authoredusingpolicy, 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.!preImageFloorOptsguard on the relief). Measured on the compare-and-set shape, BOB updatingwhere: { 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 payloadid(resolveEngineUpdateDispatchroutes it by id, or refuses), and a falsy one is never indropIds.Verification
Read first, by risk:
security-plugin-authz-middleware.ts,predicateWriteFloorRelief(end of file): the union and the floor-admitted read.security-plugin-authz-middleware.ts, step 3.6 hunk (floorDropJudge): which rows get the floor-replaced check.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.tsshows 29 passed. Flipif (rlsFilter && layered.layer1 && !delegatorSets)toif (false && ...)and the matrix cases go red.Round 4 readings are at head
c5208e4597, and the final head is35ef59a3ff. Since round 3 the branch adds two delete pins to the test file and prose in the changeset and the two docs pages.35ef59a3ffchanges 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-registrationandcheck-changeset-no-majoramong them. No package source changed, so the round 3 dogfood battery at6ff08df403still reads the same plugin code; it was not re-run.origin/mainwas not merged again, because 4 new main commits would have moved the code the battery read. The round 2 ablations ran on7b89b3ceb4, with the same plugin code.plugin-security typecheck and suite: all green at c5208e4
pnpm typecheckthen 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).a98bd1ee57:Tests 29 passed (29), lockVERDICT command-exit 0.6ff08df403:pnpm typecheckthenpnpm build, lockVERDICT 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.mjsin wrap mode ata98bd1ee57, and ran only the S5 cases (-t S5, 27 skipped). The relief guard becameif (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 moved869cbad82cdf -> 7a00ce83b134. Result: RED, 2 of 2:AssertionError: the predicate delete is refused: expected null not to be nullfor 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), andgit diff HEADis empty.Dogfood battery (owed by the narrowing): green at 6ff08df
The closure was built first:
pnpm --workspace-concurrency=2 --filter '@objectstack/dogfood^...' build, lockVERDICT command-exit 0. Then, under the lock, with no shard and no path:pnpm --filter @objectstack/dogfood test. Result: lockVERDICT 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.mjsin wrap mode, at6ff08df403. The step 3.6 line becameif (!(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 moved869cbad82cdf -> 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), andgit diff HEADis empty.Round 2 ablations: 7 legs red, 1 equivalent mutant, every restore clean
Each leg ran through
scripts/ablation-replace.mjsin wrap mode: the anchor hit once and then zero times, the blob moved, the file ran, and the restore proved blob == HEAD withgit diff HEADempty.'update'in place ofrlsOperationin the relief), blob869cbad82cdf -> 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 askededit:verdicts.!delegatorSetsat the relief, blob-> 9eab6beaab22: RED, 5 of 27. The delegated updates were refused whole, and the delegated deletes wrote extra rows (BOB for CAROL wroter4; ALICE for ERIN wroter1 r2 r3).!delegatorSetsat 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 inpredicateFloorDropIds, and the floor-dropped judge is computed and never read.-> d7f80d96aaab: RED, 2 of 27. ALICE's update askededit:r1..r4, notedit:r2 r4, and her delete did the same.5569e873e4a4 -> 628fcd57a9e3: RED, 2 of 27. Only 25 of the 60 rows were asked about, and the direct helper pin failed too.-> 819033e6e42f: RED, 2 of 27.-> 5d9ad8cb55d5: RED, 1 of 27. The composed predicate no longer names the organization.-> e54f5695cc91: RED, 1 of 27. Without it the added arm has no authored policy, so NARROW's closedr1 r4were matched and the write was refused whole (PERMISSION_DENIED). The early return is what keeps an authoredusingpolicy binding on this shape.Derived gates at c5208e4: 103 derived, 102 exit 0, 1 NOT MEASURED
dispatch-gates --commands --repo objectstack-ai/objectstackatc5208e4597derived 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-reactbuild; after that closure was built it reads346 prose examples type-check across 3 surface(s).check:i18n(exit 3) lacked the built CLI; after the@objectstack/cliclosure was built it readscheck-i18n-bundles: OK.check:query-options-erasure(exit 1) hitENOENTonpackages/client-react/.examples-build/client-react__context__1.tsx, a temp file that my concurrentcheck:skill-examplesrun wrote and removed while ESLint was listing it; re-run alone it readsratchet 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 ispnpm check:dual-build-cjs-loads, exit 3: it reads thedist/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/mainexits 0, with[BREAKING+bang+clause-②-narrowing] not-required (no-migration-prescription).check-changeset-no-major.mjsexits 0, withThis diff introduces no major bump.check-governed-merges --pr 35914reads NOT governed: 1,081 changed lines.CI check-runs at
c5208e4597: 55 runs, all completed, 40 success and 15 skipped, none failed.Human Minimum
packages/specholds no runtime logic.pnpm lintpasses. (CI runs it.)main, one pull request.packages/spectouched: not touched.content/docs/references/,packages/*/CHANGELOG.mdorcontent/docs/releases/.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.