Repository navigation
fix(sharing): a predicate update or delete also writes the rows an app-authored update or delete policy admits - #38131
Conversation
…ilter-shaped twin of checkAuthoredRowWrite Claude-Session: https://claude.ai/code/session_017xRBcVFZPt78r8HPjDVLC9 Co-authored-by: Claude <noreply@anthropic.com>
…, with pins Claude-Session: https://claude.ai/code/session_017xRBcVFZPt78r8HPjDVLC9 Co-authored-by: Claude <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_017xRBcVFZPt78r8HPjDVLC9 Co-authored-by: Claude <noreply@anthropic.com>
…o the fix Claude-Session: https://claude.ai/code/session_017xRBcVFZPt78r8HPjDVLC9 Co-authored-by: Claude <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_017xRBcVFZPt78r8HPjDVLC9 Co-authored-by: Claude <noreply@anthropic.com>
…ed-members pin lists the new member Claude-Session: https://claude.ai/code/session_017xRBcVFZPt78r8HPjDVLC9 Co-authored-by: Claude <noreply@anthropic.com>
…authored policy admits, as by id Claude-Session: https://claude.ai/code/session_017xRBcVFZPt78r8HPjDVLC9 Co-authored-by: Claude <noreply@anthropic.com>
📓 Docs Drift CheckThis PR changes 3 package(s): 12 hand-written doc(s) NAME something this change touched and may need an implementation-accuracy re-verification:
⛔ 11 release-owned page(s) also name something this change touched. These are read-only:
What this run could not see
Coarse fallback — 180 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 fe6a23a1415f2d728f3666daea5253d8b6be0d73 && git checkout fe6a23a1415f2d728f3666daea5253d8b6be0d73
# afterwards, rebuild it from the two parents, which stay fetchable
git fetch origin 10321fa22d5dd75a25dfd779b077aa94a563e3e2 c2c17a47a2b90095f5780cdd6ee31b3312449563 && git checkout -B drift-repro 10321fa22d5dd75a25dfd779b077aa94a563e3e2 && git merge --no-ff c2c17a47a2b90095f5780cdd6ee31b3312449563
node scripts/docs-audit/affected-docs.mjs --json 10321fa22d5dd75a25dfd779b077aa94a563e3e2
|
|
repo:objectstack#8 · sunhaolin · session_017xRBcSAaBEfQpU2yJexSJ8 Contract-review-claim: session_017xRBcSAaBEfQpU2yJexSJ8 · head c2c17a4 · 2026-11-28T03:48Z The lane seat runs the owed CONTRACT_REVIEW_TIER review (face: published schema, |
|
repo:objectstack#8 · sunhaolin · session_017xRBcSAaBEfQpU2yJexSJ8 Contract reviewServed-tier: PR #38131 for card #37535, read against the ruled terms (i) to (v) and the premise clause copied into the card body from ruling record 7190344023. Read-only: the card and its four comments, the PR body, file list and net diff against ① Derived judgments
② Semver levelThree changesets, one per moved package (
Clause-②: yes — right. The diff changes a published contract ( ③ Boundary flagsOpen question 1, the third pin ( Open question 2, the member name Dev deviations: the extra files ( SQL push-down: no finding. The new answer is a compiled predicate ORed into the write's Ruled prohibitions: ④ Design judgmentNo must-fix, no should-fix.
Trying to break it. The ruling's premise is predicate rows = by-id rows. At the sharing gate the two are the same expression: by id,
Implementing files, against the contract:
Nits (no effect on correctness or the contract; a fix would move the head, so each is left as an accepted deviation):
Implemented-by: VERDICT: PASS |
|
repo:objectstack#8 · sunhaolin · session_017xRBcSAaBEfQpU2yJexSJ8 L1: ACCEPT · head 席位核对
Landing — non-governed, ≤3000 lines, L2 PASS on this head: the seat lands it through the ordinary queue. |
|
repo:objectstack#8 · sunhaolin · session_017xRBcSAaBEfQpU2yJexSJ8 Landing · 2026-11-28T04:05Z · head
State: ready for review + auto-merge (L1 ACCEPT 7233671627). |
Fixes #37535
Clause-②: yes
Metadata-protocol: none
维护者速读
What changes
Ruling record 7190344023 on #35934, option 2a: the security service gains an optional, filter-shaped answer, and the record sharing middleware ORs it into its bulk write scope.
@objectstack/spec:ISecurityService.getAuthoredRowWriteFilter?(object, operation, context), the filter-shaped twin ofcheckAuthoredRowWrite. It is optional, typed on the sameAuthoredRowWriteOperation(update/delete), andundefinedis the answer that widens nothing (absence, abstention, failure).@objectstack/plugin-security: the head ofcheckAuthoredRowWrite(principal, on-behalf-of, sets, the authoredusingpre-check, Layer 0 + Layer 1 compiled with the floor taken out of the sets by provenance) moved, unedited, into one helper,authoredRowWriteLayers. The verdict and the newgetAuthoredRowWriteFilterboth read it, so a row matches the filter iff the verdict admits it, and there is a pin for that. The filter islayer0 AND layer1, the verdict's probe predicate without its{ id }term. It does no read. The member is served on the registeredsecurityservice (security-plugin-security-service.ts, which is where the registration lives since cut 11, besidesecurity-plugin.ts).@objectstack/plugin-sharing:SharingSecurityProbedeclares the member.SharingService.probeAuthoredRowWriteFilteris a passthrough that answersnullfor an absent service or member, a principal-less or delegated context, a throw (logged once atwarn), or anything that is not a filter object. The middleware's bulk branch (sharing-plugin.ts, after the ADR-0090 D10 delegator intersection) setswriteFilter = { $or: [writeFilter, authoredScope] }before the existingast.where = composeAnd(...). The branch is skipped when the scope is alreadynulland for an on-behalf-of write.Ruled terms, as implemented:
onBehalfOf.usingpolicy, or any failure leaves today's scope.buildWriteFilter,checkEditandcheckDeleteare not edited. There is no per-row probe on the bulk path.content/docs/permissions/rls.mdx: one paragraph said a policy-admitted row "is not reached" by a predicate write and told authors to write it by id. This change makes that false, so the paragraph now states the widened bulk scope.Why
By id, a row an app-authored
usingupdate or delete policy admits was written (the sharing gate defers tocheckAuthoredRowWrite). A predicate write left the same row out, silently, with a smaller count. The ruling replaces the 2026-08-08 deferral on #5493 (Q2 = A1) and the #6736 reopen condition, and states the bulk composition semantics that hold required.Tests
The premise clause, measured first at
f72f3353(this branch's base):predicate-write-floor-deferral.test.ts:632-637expected by idr1–r4and by predicater1,r2.grep -rn -A8 "rowLevelSecurity" examples packages/apps --include=*.ts | grep -E "operation|using"finds one authored row policy, the showcase'sselectpolicy, and no authored update or delete widener. Pull is still zero. The ruling decided it anyway.packages/qa/dogfood/test/bulk-widener-probe.dogfood.test.ts, the one file PR test(dogfood): probe app-authored RLS wideners on the bulk write path (#6736) #7274 added (read off its file list).git grep 7274misses it because the file cites#6736. Without the fix (ablation below) its MEASURE cases read exactly their old pins: update touches['n_bob_open'], and delete leaves['d_alice_stale_1', 'd_alice_stale_2'].r1–r4, by idr1–r4;n_alice_open_1,n_alice_open_2,n_bob_open=declaredAdmitted,affected: 3; delete removes all 3,survivors: [],affected: 3;usingpolicy (ALICE and CAROL under the rep set, ALICE under a check-only policy), and the scope answersundefinedfor them.Pins moved (term (v)), plus one more:
predicate-write-floor-deferral.test.ts, "the relief only ever adds rows": the predicate expectation moves from['r1','r2']to['r1','r2','r3','r4'].bulk-widener-probe.dogfood.test.ts, the two MEASURE cases: update 1 → 3 and delete 1 → 3, held todeclaredAdmitted. The header is rewritten from "pins the defect" to "pins the fix".plugin-security/src/operator-id-write-gate-33928.test.tspinned the same divergence on aprivateobject with a read share. A two-key{ id, stage }predicate undermulti: true"leaves the row" the policy admits. It now writes it, as the by-id write does. See Acceptance notes.New pins:
predicate-write-floor-deferral.test.ts,[#37535]describe, realSecurityPlugin+SharingServicemiddleware over better-sqlite3. Each case is the plugin-security: the #5492 floor deferral covers only by-id writes; a predicate (multi) update still appliesowner_only_writes, so Modify All and edit shares silently match only self-created rows #35802 three-way comparison: predicate rows = by-id rows = the named set.r1–r4. BOB update withr1closed:r2,r3,r4. CAROL delete withr2closed:r1,r3,r4. Tenant wall: an open deal in another org is not written.r1–r4) and not delete (r1,r2), and the reverse.[]as by id. A spy shows the scope is never asked.r1,r2or answerundefined.checkAuthoredRowWriteadmits, for both verbs.plugin-sharing/src/authored-row-write-deferral.test.ts: the old "the BULK path is untouched" describe is replaced. It pins the exact composedwhere({ $and: [pred, { $or: [sharing, authored] }] }), the delete verb asked as delete, an unchanged scope for a no-policy caller, no call for a delegated write, and unchanged scope for an absent member, a throw (onewarn), a non-object answer (4 shapes) and no security service.spec/src/contracts/security-service.test.ts: the member is optional (unguarded call is a compile error,@ts-expect-error), not listable as required, its operation isAuthoredRowWriteOperation(selectrefused), and absence isundefined.registered-security-service-members.pin.test.tslists the member (its typecheck reds until it does). The two plugin-sharing middleware doubles (lifecycle-verb-write-gate,operator-id-write-gate-33928) serveprobeAuthoredRowWriteFilter: async () => null.Red without the fix (ablations, each through
scripts/ablation-replace.mjswith adist/preflight, restore proven by blob hash and a rebuilt cleandist/):predicate-write-floor-deferral.test.tsgo red (relief pin, 4 widening, 2 verb-for-verb, tenant wall) and so does the composition pin inauthored-row-write-deferral.test.ts. All controls stay green. Against the dogfood probe: both MEASURE cases red (expected [ 'n_bob_open' ]; 2 survivors), integrity/C1/C2 green. The plugin-security full run at2d086e65, before the third pin moved, showed that pin red under the fix in the other direction.expected [ 'r1', 'r2', 'r3', 'r4' ] to deeply equal []).voidmarker was dropped by esbuild. The preflight caught the second. Neither counted.Acceptance notes
security-plugin-security-service.ts. Thesecurityservice registration lives there since cut 11 andsecurity-plugin.tsonly hands it the host.sharing-service.test.tsgets no new case: the passthrough is pinned inauthored-row-write-deferral.test.ts, the existing harness for its by-id twin (AGENTS.md: a new pin for a component with a shared harness goes into that file).operator-id-write-gate-33928.test.ts. Its expectation was the divergence the ruling removes, on aprivateobject with a read share. Which branch each shape takes is still pinned against the engine's dispatch decision in plugin-sharing's file of the same name.getAuthoredRowWriteFilter, on the precedent ofgetReadFilter(filter-shaped,undefined= no answer) andcheckAuthoredRowWrite(the same question as a verdict). It is open to the veto window.null(org write depth, public objects, no owner field) the authored scope is not asked. There is nothing to widen.Verification
Two-minute check:
pnpm --filter @objectstack/plugin-security exec vitest run --maxWorkers=2 src/predicate-write-floor-deferral.test.ts. Expect 109 passed, including the[#37535]describe.Read first, by risk:
packages/plugins/plugin-sharing/src/sharing-plugin.ts, the bulk branch: the newif (writeFilter && !exec?.onBehalfOf?.userId)hunk.packages/plugins/plugin-security/src/security-plugin-authored-row-write.ts:authoredRowWriteLayers(moved head) andgetAuthoredRowWriteFilter.packages/plugins/plugin-sharing/src/sharing-service.ts:probeAuthoredRowWriteFilter.Readings, head
c2c17a47(this branch merged withorigin/mainat8e3980a9; the merge touches none of this diff's sources):Package suites and typecheck
pnpm --filter @objectstack/plugin-security testatace203aa(the last code commit before the merge): 290/290 files, 7330 passed, 45 skipped. At2d086e65, beforeoperator-id-write-gate-33928.test.tsmoved, 2 failed there: its two pins of the old divergence.pnpm --filter @objectstack/plugin-sharing testat2d086e65: 78/78 files, 1754 passed, 11 skipped. Before the two middleware doubles were completed, 25 failed withservice.probeAuthoredRowWriteFilter is not a function.pnpm --filter @objectstack/plugin-security typecheck: exit 0. Beforeregistered-security-service-members.pin.test.tslisted the member, 1 error, which is that pin doing its job.pnpm --filter @objectstack/plugin-sharing typecheck: exit 0.pnpm --filter @objectstack/spec build && pnpm --filter @objectstack/spec check:generated: all 14 generated artifacts up to date.c2c17a47, focused: plugin-security 3 files / 115 tests, plugin-sharing 3 / 76, spec contract 1 / 32, dogfoodbulk-widener-probe+authored-row-write-scope2 / 17. All green.The #7274 probe readings (dogfood, real stack)
declaredAdmitted=touched=n_alice_open_1, n_alice_open_2, n_bob_open,authoredScope: { stage: open },affected: 3. Delete:survivors: [],affected: 3.touched=n_bob_openonly, and delete keeps the two Alice rows. These are the pins as they stood on main.Derived gate families
node scripts/pm/dispatch-gates.mjs --commands: 119 families. All run onc2c17a47, and--ranreconciles 119 derived, 118 run, 1 NOT MEASURED, 0 unrun.node scripts/check-plugin-teardown-shape.mjs --self-testexits 3 (its positive control is pinned to a commit this shallow clone cannot reach). CI runs it on a full checkout.lintdist;pnpm installnot yet re-run for a dependencyservice-knowledgegained; a CLI build behind it):check:docs-transcript-drift,check:i18n,check:type-check-debt. Each was green after the refresh AGENTS.md § 9 orders, re-run on the same head.check:dev-prereqs: exit 1, "35 of 110 workspace packages … not on disk". This worktree built only this diff's closures; it is a reading of the local tree, not of the diff.Dogfood battery: not owed (no
!in the title and no narrowing arm).Test Core,Lint & Repo Gatesand the rest run in CI.Human Minimum
packages/specholds no runtime logic.pnpm lintpasses (CI).main, one pull request.packages/spectouched: its generated artifacts are regenerated and committed (check:generated: all 14 up to date, nothing to regenerate).content/docs/references/,packages/*/CHANGELOG.mdorcontent/docs/releases/.Generated by Claude Code