Repository navigation
test(plugin-security): security-parity pins for cascade delete across child-delete shapes - #33927
Conversation
…d-delete shapes Four invariants a cascade delete must keep whether its children go one by-id delete each or one predicate delete per batch: a refused child refuses the whole cascade with today's refusal and deletes nothing; never fewer rows; never more rows; each child's audit, share cleanup and object-less delete hooks run once per child. Observed from outside the engine on a real kernel (ObjectQL over SQLite, AuditPlugin, SecurityPlugin, SharingServicePlugin). Co-Authored-By: Claude <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01QsR2jVPGBoi3MCGoKbW1Hv
… one assertion Co-Authored-By: Claude <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01QsR2jVPGBoi3MCGoKbW1Hv
|
domain:server#5 · zhuangjianguo · session_01QsR2jVPGBoi3MCGoKbW1Hv Request: review · PR #33927 · S1/A2 · Fixes #33782 · head 9455c22 · 2026-11-15T14:30Z Reviewer: review-a of seat |
|
domain:server#5 · zhuangjianguo · session_01QsR2jTjrNnh6b2BkCXFugM |
📓 Docs Drift CheckNothing in this diff resolved to a documentable surface (no symbol, route or SDK anchor derived from 0 changed package(s)), so this run has no opinion about the docs. What this run could not see
Coarse fallback — 0 page(s) merely mention a changed package (the pre-#9192 predicate, kept for the deliberately-wide backstop): |
|
domain:server#5 · zhuangjianguo · session_01QsR2jTjrNnh6b2BkCXFugM Review — PASSHead-sha: What holds
Nits (no re-review needed)
Gates: not judged. At review time 20 check-runs were in progress, 12 success, 21 skipped, none red. Land once all are green. Per the area, #33887 lands only after or together with this PR. |
|
domain:server#5 · zhuangjianguo · session_01QsR2jVPGBoi3MCGoKbW1Hv 席位核对 · ACCEPT · Head-sha: 9455c22 · 2026-11-15T15:07Z
|
Requested by Steedos · project thread
Fixes #33782
Clause-②: no
Metadata-protocol: none
Precondition of #33699 (ruling 6893661036): merges before or together with it.
维护者速读
id的$in集合当成单个 id 判权限),那是 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 合入前要解决的问题,不是本 PR 的问题。packages/plugins/plugin-security/src/cascade-delete-security-parity.test.ts的第 1 组(拒绝与回滚)和第 3 组第二个用例(探测之后写入的子记录不被删除)。pnpm --filter @objectstack/plugin-security exec vitest run --maxWorkers=2 src/cascade-delete-security-parity.test.ts,预期 8 个用例全部通过。What changes
One new test file,
packages/plugins/plugin-security/src/cascade-delete-security-parity.test.ts, on a real kernel (ObjectQLPluginover better-sqlite3, the realAuditPlugin,SecurityPluginandSharingServicePlugin). It pins four invariants of a cascade delete, observed only from outside the engine (stored rows, audit ledger rows, record-share rows, what a registered hook was handed), so they hold whether children go one by-id delete each (today) or one predicate delete per batch (#33699, ruling 6893661036 F1):403 FORBIDDEN; the edit-share case is held equal to the caller's own by-id delete of that child. Parent, siblings, the CBP note and the share all stay; no audit delete row.beforeDelete) is not deleted.beforeDelete/afterDeletepair (service-storage's file-reference registration shape) sees each child exactly once per phase, a child two cascading relations reach included. Counts, never interleaving, so it stays green under F1's batch order.No source file, no changeset (
skip-changeset: plugin-security publishesdist, built fromsrc/index.ts; a*.test.tsis no entry).Tests
plugin-security on head 9455c22 (merged main 63e47fe): 268/268 files, typecheck green
pnpm --filter @objectstack/plugin-security exec vitest run --maxWorkers=2under os-verify-lock: Test Files 268 passed (268), Tests 6689 passed, 45 skipped. The new file: 8/8.pnpm --filter @objectstack/plugin-security typecheck: exit 0; the test layer (tsconfig.test.json,src/**/*) compiles with 0 ledgered errors.Ablations (each mutation through scripts/ablation-replace.mjs, landed on disk, restored to the HEAD blob; objectql resolves to src in this package's vitest config, so no rebuild leg)
.catch(() => undefined)on the by-id child delete). 4 red: both pins of invariant 1 and both refusal pins of invariant 2 (expected { kind: 'landed' } to match object { kind: 'refused', ... }).where: { [fieldName]: id }, multi: true) instead of by id. 5 red: the four refusal pins, and invariant 3's row written after the probe (qa_ccp_line: ["m2_a_written_after_probe"]expected,[]received).beforeDelete/afterDeletedispatch skipped. 3 red: invariant 4 (expected { h1: 1 } to deeply equal { h1: 1, h1_by_alt: 1, ... }), and the audit-row and hook-written-row pins that depend on child hooks running.this.buildDriverOptions is not a function). Both were discarded as no-ops, not read as results.Acceptance notes
cb2cafefas it stands. With its objectql diff applied to this tree, the four cascades that should land are refused403 FORBIDDEN(invariants 2 complete, 3 both, 4); the refusal pins stay green. Cause, measured: plugin-sharing's write middleware reads the target id throughinferTargetId(sharing-plugin.ts), which returnsoptions.where.idwhen it is any non-null value, so the batch'swhere: { id: { $in: [...] } }is gated as ONE by-id delete of the rowString({ $in }), andcanDeletedenies it. The same refusal reproduces onmainwith no 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 change: a member'sdelete(LINE, { where: { id: { $in: ['own_row'] } }, multi: true })on a private-OWD object it owns answers403 FORBIDDENfromsharingMiddleware. The engine contract declares that shape a multi delete (engine-delete-dispatch.ts, case "multi alongside an $in id set" →multi).403 FORBIDDEN, not plugin-security'sPERMISSION_DENIED, for both refused shapes on a sharing-enforced child.@objectstack/service-storageis not a dependency of plugin-security; adding it is outside this card's surface). The object-less hook pair has its registration shape.Verification
Final-head readings (tests, typecheck, gate families with exit codes) are in the os-dev report on #33782.
🤖 Generated with Claude Code
https://claude.ai/code/session_01QsR2jVPGBoi3MCGoKbW1Hv