Repository navigation
fix(plugin-sharing)!: the write gate judges by id exactly the writes the engine runs by id - #34033
Conversation
…ed by the bulk write filter
The write gate stringified `where.id` even when it was an operator object
such as `{ $in: [...] }`, and judged the row "[object Object]", so a member's
multi-row delete of rows it owns was refused. Only a scalar id now names the
row the by-id gate judges, the engine's own dispatch rule; any other value
takes the bulk branch, where buildWriteFilter scopes the predicate.
Co-Authored-By: Claude <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01QsR2jVPGBoi3MCGoKbW1Hv
…ed id on a real stack Co-Authored-By: Claude <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01QsR2jVPGBoi3MCGoKbW1Hv
Co-Authored-By: Claude <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01QsR2jVPGBoi3MCGoKbW1Hv
Co-Authored-By: Claude <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01QsR2jVPGBoi3MCGoKbW1Hv
…one, on an object of its own A where with a second key reaches the gate in another shape, so it never exercised the by-id misreading; measured by ablating the gate. Co-Authored-By: Claude <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01QsR2jVPGBoi3MCGoKbW1Hv
…at reaches the gate as where.id The engine lowers $nin and $ne to a null-aware $and before any middleware, so neither ever met the by-id misreading. Co-Authored-By: Claude <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01QsR2jVPGBoi3MCGoKbW1Hv
📓 Docs Drift CheckThis PR changes 1 package(s): 1 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 — 11 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 e1c7d659357646a6cd0eaec6260e20a2375ff188 && git checkout e1c7d659357646a6cd0eaec6260e20a2375ff188
# afterwards, rebuild it from the two parents, which stay fetchable
git fetch origin 98a4449f8767e9356b138e54ee5a7c9d79a7f11e 00cff2ba9051e9998f30f31fc8b4bb899ea9abba && git checkout -B drift-repro 98a4449f8767e9356b138e54ee5a7c9d79a7f11e && git merge --no-ff 00cff2ba9051e9998f30f31fc8b4bb899ea9abba
node scripts/docs-audit/affected-docs.mjs --json 98a4449f8767e9356b138e54ee5a7c9d79a7f11e
|
|
domain:server#5 · zhuangjianguo · session_01QsR2jVPGBoi3MCGoKbW1Hv Contract reviewServed-tier: ① Derived judgments
② Semver levelpatch: a server-side gate answer widens for a malformed-as-by-id predicate; no schema, key, export or wire field moves. ③ Boundary flags
Implemented-by: VERDICT: PASS |
|
domain:server#5 · zhuangjianguo · session_01QsR2jVPGBoi3MCGoKbW1Hv Request: review · PR #34033 · S1/A2 · Fixes #33928 · head eb28a95 (declared final, all checks green: 35 success, 16 skipped) · 2026-11-15T17:38Z Reviewer: review-a, ordinary ACCEPT read per review-checklist.md. Critical path: S2's #33887 (#33699) needs it. TIER_DEFAULT contract record (Clause-② yes widening) is the comment above. The dev's os-dev report follows on #33928 after its last locked local re-run (the |
|
domain:server#5 · zhuangjianguo · session_01QsR2jTjrNnh6b2BkCXFugM Review claim (review-a, S1) · head eb28a95 · 2026-11-15T17:39Z |
|
domain:server#5 · zhuangjianguo · session_01QsR2jTjrNnh6b2BkCXFugM Review — FAILHead-sha: Contract face: What holds
Must-fix
Nits (no re-review needed)
Gates: at review time 35 success, 16 skipped, none red, so every check is green. Next: a new head with item 1. I review the delta only. #33887 stays behind this PR, as the area ordered. |
…n dispatch decision The gate judges by id exactly the writes the engine runs by id, and every other write meets the bulk write scope. The branch is taken from the engine's dispatch helpers for the same options bag, and the pins state the rule over every option shape the gate is handed. Co-Authored-By: Claude <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01QsR2jVPGBoi3MCGoKbW1Hv
Co-Authored-By: Claude <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01QsR2jVPGBoi3MCGoKbW1Hv
…s; the by-id verdict pin drives each verb in the engine's shape Co-Authored-By: Claude <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01QsR2jVPGBoi3MCGoKbW1Hv
Co-Authored-By: Claude <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01QsR2jVPGBoi3MCGoKbW1Hv
|
review#2 · os-tesla · session_01L9qibxTeW8xHnxoHxWNHWW Contract-review-claim: session_01L9qibxTeW8xHnxoHxWNHWW · head b1d5f9a · 2026-11-15T20:04Z |
|
review#2 · os-tesla · session_01L9qibxTeW8xHnxoHxWNHWW Contract reviewServed-tier: Read at 2026-11-15T20:16Z. First review of this head by this seat, taken on patrol as owed; claim: comment 6900497162; prior record 6898545771 is on an earlier head. Independence: implemented in a zhuangjianguo lane (domain:server#5); neither dispatched nor implemented by os-tesla. Everything below is derived by reading the diff against merge base ① Derived judgmentsWhat the head does. The private Judged against the questions put to this review:
Prior records and comments, judged by id:
Findings: M1 (must-fix) — the declaration face does not describe this head, and the head carries an arm the declaration denies. Making the branch the engine's dispatch moved more than operator ids off the by-id judgment. Two scalar shapes that the base judged by id are judged by the bulk scope now: a scalar S1 (should-fix) — the shapes whose answer changed at this head have no door-level pin. The real-stack block pins S2 (should-fix) — no ablation reading for the mechanism at this head. The A1 to A3 readings on the PR and the card were taken on N1 (nit) — the table's title says every option shape the gate is handed; it has no falsy-id row and no N2 (nit) — ② Semver levelpatch on
CI at this head: 51 check-runs, all completed, 35 success and 16 skipped, none failing or pending. The FAIL below is on the contract, not on the checks. ③ Boundary flags
④ Design judgment
Implemented-by: VERDICT: FAIL |
…d the falsy-id and refused rows of the dispatch table Co-Authored-By: Claude <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01QsR2jVPGBoi3MCGoKbW1Hv
Co-Authored-By: Claude <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01QsR2jVPGBoi3MCGoKbW1Hv
… the two predicate shapes Co-Authored-By: Claude <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01QsR2jVPGBoi3MCGoKbW1Hv
|
domain:server#5 · zhuangjianguo · session_01QsR2jVPGBoi3MCGoKbW1Hv Request: delta review · PR #34033 · S1/A2 · Fixes #33928 · head 185f9d4 · 2026-11-16T00:54Z The area declares this head final. It answers contract record 6900670881 (FAIL at b1d5f9a) and review-a's 6898587580. Two reads are owed:
What changed:
Delta report: 6904304476. CI at this head: 35 success, 18 skipped, 0 red. Two body-edit re-runs are still queued. |
|
domain:server#5 · zhuangjianguo · session_01QsR2jTjrNnh6b2BkCXFugM Review — PASS (delta)Head-sha: Must-fix 1: fixed.
The new declaration holds. The narrowing is declared as two shapes the engine runs as a predicate, but the old gate judged by id: a
The title carries Contract face: a declared narrowing is owed a Gates: at review time 36 success, 18 skipped, none red. One |
|
review#2 · os-tesla · session_01L9qibxTeW8xHnxoHxWNHWW Contract-review-claim: session_01L9qibxTeW8xHnxoHxWNHWW · head 185f9d4 · 2026-11-16T01:01Z |
|
review#2 · os-tesla · session_01L9qibxTeW8xHnxoHxWNHWW Contract reviewServed-tier: Read at 2026-11-16T01:11Z. Delta review of this head against FAIL 6900670881 at b1d5f9a; claim: comment 6904431188; no lane request (owed per check-owed-reviews). Independence: implemented in a project thread for domain:server#5; reviewed by os-tesla, who neither dispatched nor implemented it. Everything below is derived by reading the diff, the cited code and docs at this head, the PR body, the card and the head's check-runs. Nothing was built or run. Readings quoted from the area (ablation, base against head, batteries) are the area's reports, not re-run here. ① Derived judgmentsWhat moved since
The rule at this head, unchanged from last round: the sharing write gate judges by id exactly the writes the engine runs by id, and every other write meets the bulk write scope. I re-derived nothing new against it; the judgments of record 6900670881 section ① on operator ids, update and delete both, the recycle-bin doors and system or elevated callers stand for this head because the code is the same bytes. Prior findings of record 6900670881, by id:
Does every predicate shape have a refused pin and a control:
Findings at this head: M1 (must-fix) — new at this head, on the line the narrowing arm added. S1 (should-fix) — new, grows out of prior M1. The arm that makes this BREAKING (a row written before only through an application row policy, no longer written by the two shapes, still written by id) has no pin in the tree. The door block composes no plugin-security, and the base-against-head measurement is, by the body's own word, not committed. A declared narrowing with a stated remedy should have the narrowed answer and the remedy pinned side by side, so that neither moves again unannounced. S2 (should-fix) — continues prior S1 and N1. A call the engine refuses at dispatch (a scalar id beside another key without N1 (nit) — continues prior S1. ② Semver levelpatch on Is the narrowing now honestly declared:
CI at this head: 55 check-runs, all completed, 37 success and 18 skipped, none failing and none pending, ③ Boundary flags
④ Design judgmentThe narrowing against the published contract: it does take a capability away at the consumer. A caller who wrote a conditional single-row write in the spelling the engine documents, on a row it could write only through an application row policy, was served and is no longer. It also makes a rule real: one authority, the engine's dispatch, now decides what a by-id write is for both gates. The seat ruled the trade and the declaration carries it with a remedy, so the narrowing itself is accepted here. What is not yet consistent is the docs line beside it (M1).
To close: M1 alone blocks. It needs the Implemented-by: VERDICT: FAIL |
Co-Authored-By: Claude <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01QsR2jVPGBoi3MCGoKbW1Hv
…edy with plugin-security composed, and the engine's dispatch refusal at the door Co-Authored-By: Claude <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01QsR2jVPGBoi3MCGoKbW1Hv
|
domain:server#5 · zhuangjianguo · session_01QsR2jVPGBoi3MCGoKbW1Hv Request: delta review · PR #34033 · S1/A2 · Fixes #33928 · head 00cff2b · 2026-11-16T02:36Z The area declares this head final. It answers L2 FAIL 6904564182 (at 185f9d4). The changes since then:
The gate code is byte-identical to 185f9d4. origin/main is merged at Two reads are owed: the L2 delta at |
|
domain:server#5 · zhuangjianguo · session_01QsR2jTjrNnh6b2BkCXFugM |
|
domain:server#5 · zhuangjianguo · session_01QsR2jTjrNnh6b2BkCXFugM Review — PASS (delta)Head-sha: The gate code carries. I compared each path's net patch against its main parent with the patch at The L2 findings are answered at this head:
Contract face: the narrowing's Gates: at review time 37 success, 18 skipped, none red or pending, including the Can land once a PASS L2 delta record is on record at this head. |
|
review#2 · os-tesla · session_01L9qibxTeW8xHnxoHxWNHWW Contract-review-claim: session_01L9qibxTeW8xHnxoHxWNHWW · head 00cff2b · 2026-11-16T03:02Z |
|
review#2 · os-tesla · session_01L9qibxTeW8xHnxoHxWNHWW Contract reviewServed-tier: Read at 2026-11-16T03:08Z. Delta review of this head against FAIL 6904564182 at 185f9d4; claim: comment 6906094333; no lane request (owed per check-owed-reviews). Independence: implemented in a project thread for domain:server#5; reviewed by os-tesla, who neither dispatched nor implemented it. Everything below is derived by reading the diff, the cited code and docs at this head, the PR body, the cards and the head's check-runs. Nothing was built or run. Test counts and ablation readings quoted from the area are the area's reports, not re-run here. ① Derived judgmentsWhat moved since
Does #34031 change a premise of this PR. No, on three counts:
Prior findings of record 6904564182, by id:
Every predicate shape now has its refused pin and its control, and the one served-to-smaller arm has its pin beside its remedy. Findings at this head: No must-fix, no should-fix. N1 (nit) — new, on the body only. The Acceptance note says all three pages "still describe the two narrowed shapes the way the old rule treated them". Only the v17.2 note names one of the shapes; N2 (nit) — new. The new changeset sentence is true of this gate, which is its subject. Where another plane's gate is composed and answers first, that answer is unchanged by this PR; the sentence does not say otherwise, and a reader should not take it as a statement about the whole stack. ② Semver levelpatch on The declaration at this head, line by line:
CI at this head: 55 check-runs, all completed, 37 success and 18 skipped, none failing and none pending. ③ Boundary flags
④ Design judgmentThe narrowing itself was judged and accepted in the last record: one authority, the engine's dispatch, decides what a by-id write is, at the price of two spellings moving to the bulk scope, declared with a remedy. This head makes that declaration consistent with the tree: the docs line is true and the narrowed answer is pinned.
CI completed before posting: 55 check-runs on this head, 37 success, 18 skipped, none failed. Implemented-by: VERDICT: PASS |
|
domain:server#5 · zhuangjianguo · session_01QsR2jVPGBoi3MCGoKbW1Hv 席位核对 · ACCEPT · Head-sha: 00cff2b · 2026-11-16T03:10Z
|
Requested by Steedos · project thread
Fixes #33928
Clause-②: no (narrowing)
Metadata-protocol: none
Skills-docs: follow-up #34219
维护者速读
$in批量删改自己的记录在私有对象上一律 403,还挡住了 engine: cascade delete runs one id read + one set-based DELETE/UPDATE per relation instead of a full engine write per dependent (epic #33631 R7) #33699 的批量级联删除;同时补上闸门 id 推断的一处规则缺口。multi: true下 where 里标量 id 旁带其它键、或 id 为假值,这两种写法改按批量范围判。按 id 的写法不变。回滚即还原engineByIdTarget一个函数。packages/plugins/plugin-sharing/src/sharing-plugin.ts末尾的engineByIdTarget;operator-id-write-gate-33928.test.ts的门口用例与分派表;changeset 的 BREAKING 段。pnpm --filter @objectstack/plugin-sharing exec vitest run src/operator-id-write-gate-33928.test.ts,预期Tests 44 passed (44);pnpm --filter @objectstack/plugin-security exec vitest run src/operator-id-write-gate-33928.test.ts,预期Tests 2 passed (2)。What changes
This closes a rule-level gap in the gate's id inference. The rule:
resolveEngineDeleteDispatch/resolveEngineUpdateDispatch, the helpers the engine'sdelete()/update()call on the same bag, imported from@objectstack/objectql. A write the engine dispatches by id meetsadmitsByIdWriteexactly as before: the per-verb gate, the ADR-0090 D10 delegator gate, and the deferral to an application row policy.buildWriteFilter, plus the delegator's, is ANDed into the AST the engine runs. That covers an$inor$eqonid, the two shapes above, and a call the engine refuses at dispatch; such a call now gets the engine's own refusal, the answer a system caller gets, instead of this gate's 403 first. It is refused either way and nothing is written. Such a write writes the rows the caller may update or delete, leaves the others as they were, and answers no error, the answer every bulk write already gives (ADR-0111 D3). An owned-only$innow lands where it answered 403.Tests
packages/plugins/plugin-sharing/src/operator-id-write-gate-33928.test.ts, 44 tests:Real stack, 14 pins (ObjectKernel + ObjectQLPlugin over better-sqlite3 + SharingServicePlugin):
$in/$eq:$indelete lands;$indelete deletes fewer rows and answers no error;$inupdate writes the editable rows only;$eqdelete writes the owned row only.'',0, inwhereand in the payload) and$in: []: the discriminating assertion is the answer, no error;$eq/$inupdate of a row the caller holds only a read share on, which writes nothing, and an$equpdate of an owned row, which writes it;multi, a payload id beside a where predicate): the member gets exactly the refusal the system context gets, not a sharing 403, and nothing is written;Dispatch table, 30 rows, against the middleware itself. It covers every option shape the gate is handed, each with and without
multi, for update and delete:Each row states the branch the engine dispatches it to, by id with its row or bulk. The branch is written out, not computed.
packages/plugins/plugin-security/src/operator-id-write-gate-33928.test.ts, 2 tests, withSecurityPlugincomposed (the platform permission sets plus an application writer set whose row-level policy admits an update or delete of anopendeal). The narrowed answer and the remedy sit side by side on one row: another member'sopendeal, shared to the caller for reading only, and readable by the caller (asserted first).{ where: { id, stage: 'open' }, multi: true }answers no error and leaves the row; then{ where: { id } }writes it.{ where: { id } }deletes it.Base against head on a composed stack (plugin-security + plugin-sharing), the narrowing measured
Real kernel over better-sqlite3, composing
SecurityPlugin(the platform permission sets plus an app writer set with an RLS update/delete widener) andSharingServicePlugin.529ed7d9'ssharing-plugin.tswas built intodist/(ablation-dist-preflight --absenton the head's marker: exit 0), then restored to the HEAD blob and rebuilt (marker present: exit 0).multi: true)529ed7d9{ id, stage }{ id, stage }{ id, stage }{ id, stage }{ id, stage }{ id: '' }/{ id: 0 }, update{ id: '' }{ id, stage: 'open' }{ id, stage: 'open' }{ id, stage }The by-id controls answer the same on base and head:
{ where: { id } }of the caller's row: written;Where the object's app RLS itself refuses the row, the security gate answers first: 403 on base and head alike, for every shape above.
Green, ablation and S2 runs (local, under the verify lock, head `00cff2ba9`)
Main tree,
origin/maindfb8ed357merged in. Theplugin-security^...closure was built.Tests 44 passed (44); plugin-security fileTests 2 passed (2).Tests 22 failed | 22 passed (44).Tests 34 failed | 10 passed (44).$in/$eqpins, the six door pins (scalar beside predicate, falsy id,$in: [], read-share update,$eqowned-update control, dispatch refusal), and table rows 4-7 and 10-29.dist/, plugin-security file. plugin-security reads plugin-sharing fromdist/, so the mutated source was built (exit 0) andablation-dist-preflightfound the mutation's marker indist/(exit 0). Result:Tests 2 failed (2). Both fail on the narrowed assertion, the row left as it was, because that rule writes it. After the restore: rebuild exit 0, the marker absent fromdist/(exit 0),Tests 2 passed (2).Each mutation went through
scripts/ablation-replace.mjs: the anchor count went 1 to 0, and each run restored to the HEAD blob withgit diff HEADempty. The plugin-sharing file imports./sharing-plugin.jsfrom source, so no rebuild is owed there.pnpm --filter @objectstack/plugin-sharing test:Test Files 75 passed (75),Tests 1581 passed (1581).plugin-sharing typecheck: exit 0.pnpm --filter @objectstack/plugin-security test:Test Files 271 passed (271),Tests 6720 passed | 45 skipped (6765).plugin-security typecheck: exit 0.--no-inline-configon the two test files: exit 0.The gate code is byte-identical to
185f9d424, where it was measured on S2's head for #33699 (616735ceb) with theplugin-security^...closure built anddist/carrying it. Results there: #33927's 8 cascade parity pinsTests 8 passed (8), and this PR's plugin-sharing file 42/42. Since then only tests, the changeset and main's range changed, so neither was re-run.The full dogfood battery owed by the
(narrowing)arm ran on185f9d424, after its@objectstack/dogfood^...closure was built:VERDICT command-exit 0,Test Files 467 passed | 3 skipped (470),Tests 3962 passed | 42 skipped (4004). This head adds tests and changeset text only, so the battery was not re-run.Acceptance notes
vama-write-path-convergence.test.ts: a stale comment now states the gate's rule. Comment only.Skills-docs: follow-up #34219:content/docs/permissions/rls.mdx,content/docs/permissions/permissions-matrix.mdxand the v17.2 release note still describe the two narrowed shapes the way the old rule treated them. The docs card carries the correction, and this PR leaves those pages unchanged.Verification
Derived gates and declarations
node scripts/pm/dispatch-gates.mjs --commandsat00cff2ba9derived 73 families. 70 were run locally, each exit 0.--rannames the other 3 as unrun; they are declared to CI:check:dual-build-cjs-loads,check:i18n,check:type-check-debt.GITHUB_EVENT_PATH, each exit 0:check-changeset-no-major --base origin/main(LEVEL AXIS:Clause-②: no (narrowing),Metadata-protocol: none),check-adr-0087-registration --base origin/main(one declared-breaking changeset, dispositionnot-required (no-migration-prescription)),check-closing-keyword-parity, andcheck-partof-closing-keyword.check-closing-target-claimneeds the platform and is left topr-body-guards.Clause-②: no (narrowing), for the two shapes above.Metadata-protocol: none.git merge-tree --write-treeagainstorigin/main98a4449f8and S2's head616735ceb: exit 0 for both.Generated by Claude Code
🤖 Generated with Claude Code
https://claude.ai/code/session_01QsR2jVPGBoi3MCGoKbW1Hv