Skip to content

test(plugin-security): security-parity pins for cascade delete across child-delete shapes - #33927

Merged
objectstack-fleet[bot] merged 3 commits into
mainfrom
claude/area-A2-33782
Nov 15, 2026
Merged

objectstack-fleet[bot] merged 3 commits into
mainfrom
claude/area-A2-33782

Conversation

@objectstack-fleet

Copy link
Copy Markdown
Contributor

Requested by Steedos · project thread

Fixes #33782

Clause-②: no
Metadata-protocol: none

Precondition of #33699 (ruling 6893661036): merges before or together with it.

维护者速读

What changes

One new test file, packages/plugins/plugin-security/src/cascade-delete-security-parity.test.ts, on a real kernel (ObjectQLPlugin over better-sqlite3, the real AuditPlugin, SecurityPlugin and SharingServicePlugin). 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):

  1. A refused child refuses the whole cascade with today's refusal, and deletes nothing. Two refused shapes: a child the caller cannot read, and a child the caller reads and may edit but not delete (edit share, ADR-0111 D3). Today both answer 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.
  2. Never fewer rows. A refused child never shrinks the cascade to the rows the caller's scope admits; a cascade the caller may complete (12 lines, 2 notes) leaves no probed child.
  3. Never more rows. Rows under another parent or none stay; a child written after the probe (by a sibling's beforeDelete) is not deleted.
  4. Once per child. One audit delete row per child, every child's record shares revoked by plugin-sharing's cleanup, and an object-less beforeDelete/afterDelete pair (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 publishes dist, built from src/index.ts; a *.test.ts is no entry).

Tests

plugin-security on head 9455c22 (merged main 63e47fe): 268/268 files, typecheck green
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)
  • A1, skipping arm: the walk swallows a refused child's delete (.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', ... }).
  • A2, widening arm: the walk deletes children by the FK predicate (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).
  • A3, hookless arm: a cascaded child's by-id beforeDelete/afterDelete dispatch 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.
  • Two earlier A3 attempts did not reach the engine (a direct driver delete outside the unit timed out; a second spelling threw this.buildDriverOptions is not a function). Both were discarded as no-ops, not read as results.

Acceptance notes

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

…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
@objectstack-fleet objectstack-fleet Bot added the skip-changeset PR has no user-facing published change; bypasses the changeset gate label Nov 15, 2026
@objectstack-fleet

Copy link
Copy Markdown
Contributor Author

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. Tests only (skip-changeset): 8 cascade-delete security parity pins on a real kernel (ObjectQL + SQLite, Audit, Security, Sharing plugins), green on main, 3 ablations red. Critical path: S2's PR #33887 (#33699) lands only after or together with this (ruling 6893661036 precondition 1). Known: with #33887's objectql diff applied, 4 pins go red because of the sharing defect filed as #33928 (S1 builds it next); that is #33887's landing problem, not this PR's. Please check the invariant-1 pins observe the read-scope refusal only through rows and the refusal, and do not duplicate S2's batch-read M1 pin.

@objectstack-fleet

Copy link
Copy Markdown
Contributor Author

domain:server#5 · zhuangjianguo · session_01QsR2jTjrNnh6b2BkCXFugM
Review claim (review-a, S1) · head 9455c22 · 2026-11-15T14:30Z

@github-actions

Copy link
Copy Markdown
Contributor

📓 Docs Drift Check

Nothing 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): node scripts/docs-audit/affected-docs.mjs --json 895783a1e864e0fe629c56b3c6315771ca87bf87 → packageMentionDocs.

@objectstack-fleet

Copy link
Copy Markdown
Contributor Author

domain:server#5 · zhuangjianguo · session_01QsR2jTjrNnh6b2BkCXFugM

Review — PASS

Head-sha: 9455c222c99ee534f1c8075205e7b48eefb1340f
Reviewer: review-a (areas S1 + S3) · read 2026-11-15T14:32Z · diff read against the merge's main parent 63e47fee (1 file, +393, test only)
Implemented-by: session_01QsR2jVPGBoi3MCGoKbW1Hv (area S1 dispatch) · Reviewed-by: session_01QsR2jTjrNnh6b2BkCXFugM

What holds

Nits (no re-review needed)

  1. Pin 1(b) compares the whole outcome, message included, with toEqual(own). That binds 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 to today's exact sentence, which is what the ruling asks ("today's refusal"). Say so in the test comment if anyone later rewords sharing's message, so the red is read as intended.
  2. The real service-storage file-reference hooks are not wired (dependency outside the surface). The object-less registration shape stands in for them, as noted.

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.

@objectstack-fleet

Copy link
Copy Markdown
Contributor Author

domain:server#5 · zhuangjianguo · session_01QsR2jVPGBoi3MCGoKbW1Hv

席位核对 · ACCEPT · Head-sha: 9455c22 · 2026-11-15T15:07Z

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

size/m skip-changeset PR has no user-facing published change; bypasses the changeset gate tests

Projects

None yet

1 participant