Skip to content

fix(sharing): a predicate update or delete also writes the rows an app-authored update or delete policy admits - #38131

Merged
objectstack-fleet[bot] merged 8 commits into
mainfrom
claude/issue-37535-bulk-authored-scope
Nov 28, 2026
Merged

objectstack-fleet[bot] merged 8 commits into
mainfrom
claude/issue-37535-bulk-authored-scope

Conversation

@objectstack-fleet

Copy link
Copy Markdown
Contributor

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 of checkAuthoredRowWrite. It is optional, typed on the same AuthoredRowWriteOperation (update / delete), and undefined is the answer that widens nothing (absence, abstention, failure).
  • @objectstack/plugin-security: the head of checkAuthoredRowWrite (principal, on-behalf-of, sets, the authored using pre-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 new getAuthoredRowWriteFilter both read it, so a row matches the filter iff the verdict admits it, and there is a pin for that. The filter is layer0 AND layer1, the verdict's probe predicate without its { id } term. It does no read. The member is served on the registered security service (security-plugin-security-service.ts, which is where the registration lives since cut 11, beside security-plugin.ts).
  • @objectstack/plugin-sharing: SharingSecurityProbe declares the member. SharingService.probeAuthoredRowWriteFilter is a passthrough that answers null for an absent service or member, a principal-less or delegated context, a throw (logged once at warn), or anything that is not a filter object. The middleware's bulk branch (sharing-plugin.ts, after the ADR-0090 D10 delegator intersection) sets writeFilter = { $or: [writeFilter, authoredScope] } before the existing ast.where = composeAnd(...). The branch is skipped when the scope is already null and for an on-behalf-of write.

Ruled terms, as implemented:

  • (i) The bulk scope is sharing scope OR authored scope, then ANDed into the write as today. plugin-security's own layers are untouched.
  • (ii) Verb for verb: the operation is the middleware's write class, and the policies are collected per operation.
  • (iii) A delegated write is not widened: the middleware, the passthrough and the security helper each abstain on onBehalfOf.
  • (iv) An absent member, no authored using policy, or any failure leaves today's scope.
  • (v) The pins moved. See Tests.
  • buildWriteFilter, checkEdit and checkDelete are not edited. There is no per-row probe on the bulk path.
  • The 2026-08-15 ruling block (no filter-provenance marking on this merge) is intact. The new composition is unmarked, as that block requires.

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 using update or delete policy admits was written (the sharing gate defers to checkAuthoredRowWrite). 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):

  • Premise 10 holds. The relief pin predicate-write-floor-deferral.test.ts:632-637 expected by id r1–r4 and by predicate r1, r2.
  • Premise 12 holds. grep -rn -A8 "rowLevelSecurity" examples packages/apps --include=*.ts | grep -E "operation|using" finds one authored row policy, the showcase's select policy, and no authored update or delete widener. Pull is still zero. The ruling decided it anyway.
  • The PR test(dogfood): probe app-authored RLS wideners on the bulk write path (#6736) #7274 probe is 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 7274 misses 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'].
  • Named premise: holds. With the authored scope ORed in, the rows a predicate write changes equal the rows the by-id write admits:
    • on the relief fixture: predicate r1–r4, by id r1–r4;
    • on the test(dogfood): probe app-authored RLS wideners on the bulk write path (#6736) #7274 fixtures: update touches n_alice_open_1, n_alice_open_2, n_bob_open = declaredAdmitted, affected: 3; delete removes all 3, survivors: [], affected: 3;
    • no row changes for a caller who holds no authored using policy (ALICE and CAROL under the rep set, ALICE under a check-only policy), and the scope answers undefined for 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 to declaredAdmitted. The header is rewritten from "pins the defect" to "pins the fix".
  • Not named by (v): plugin-security/src/operator-id-write-gate-33928.test.ts pinned the same divergence on a private object with a read share. A two-key { id, stage } predicate under multi: 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, real SecurityPlugin + SharingService middleware over better-sqlite3. Each case is the plugin-security: the #5492 floor deferral covers only by-id writes; a predicate (multi) update still applies owner_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.
    • Widening: ALICE update and delete r1–r4. BOB update with r1 closed: r2, r3, r4. CAROL delete with r2 closed: r1, r3, r4. Tenant wall: an open deal in another org is not written.
    • Verb for verb: an update-only policy widens update (r1–r4) and not delete (r1, r2), and the reverse.
    • CONTROLS: no authored policy, check-only policy, and a delegated write (ALICE on behalf of FRANK, both under the wideners, FRANK a plain member so his half keeps a sharing scope) writes [] as by id. A spy shows the scope is never asked.
    • Absent member, a rejecting member, and an internal compile failure all leave r1, r2 or answer undefined.
    • One answer: over a mixed matrix, the scope's rows equal the rows checkAuthoredRowWrite admits, 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 composed where ({ $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 (one warn), 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 is AuthoredRowWriteOperation (select refused), and absence is undefined.
  • registered-security-service-members.pin.test.ts lists the member (its typecheck reds until it does). The two plugin-sharing middleware doubles (lifecycle-verb-write-gate, operator-id-write-gate-33928) serve probeAuthoredRowWriteFilter: async () => null.

Red without the fix (ablations, each through scripts/ablation-replace.mjs with a dist/ preflight, restore proven by blob hash and a rebuilt clean dist/):

  • A: the middleware's OR line replaced by a never-true guard. 8 widening pins in predicate-write-floor-deferral.test.ts go red (relief pin, 4 widening, 2 verb-for-verb, tenant wall) and so does the composition pin in authored-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 at 2d086e65, before the third pin moved, showed that pin red under the fix in the other direction.
  • B: the three delegated guards removed. Both delegated controls go red (expected [ 'r1', 'r2', 'r3', 'r4' ] to deeply equal []).
  • Two first attempts were no-ops and were re-run: a deleted line failed the DTS build, and a void marker was dropped by esbuild. The preflight caught the second. Neither counted.

Acceptance notes

  • Landing point: as named on the card, plus security-plugin-security-service.ts. The security service registration lives there since cut 11 and security-plugin.ts only hands it the host. sharing-service.test.ts gets no new case: the passthrough is pinned in authored-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).
  • A third pin moved beyond (v)'s two: plugin-security's operator-id-write-gate-33928.test.ts. Its expectation was the divergence the ruling removes, on a private object 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.
  • Member name getAuthoredRowWriteFilter, on the precedent of getReadFilter (filter-shaped, undefined = no answer) and checkAuthoredRowWrite (the same question as a verdict). It is open to the veto window.
  • Where the sharing scope is already 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:

  1. packages/plugins/plugin-sharing/src/sharing-plugin.ts, the bulk branch: the new if (writeFilter && !exec?.onBehalfOf?.userId) hunk.
  2. packages/plugins/plugin-security/src/security-plugin-authored-row-write.ts: authoredRowWriteLayers (moved head) and getAuthoredRowWriteFilter.
  3. packages/plugins/plugin-sharing/src/sharing-service.ts: probeAuthoredRowWriteFilter.

Readings, head c2c17a47 (this branch merged with origin/main at 8e3980a9; the merge touches none of this diff's sources):

Package suites and typecheck
  • pnpm --filter @objectstack/plugin-security test at ace203aa (the last code commit before the merge): 290/290 files, 7330 passed, 45 skipped. At 2d086e65, before operator-id-write-gate-33928.test.ts moved, 2 failed there: its two pins of the old divergence.
  • pnpm --filter @objectstack/plugin-sharing test at 2d086e65: 78/78 files, 1754 passed, 11 skipped. Before the two middleware doubles were completed, 25 failed with service.probeAuthoredRowWriteFilter is not a function.
  • pnpm --filter @objectstack/plugin-security typecheck: exit 0. Before registered-security-service-members.pin.test.ts listed 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.
  • On c2c17a47, focused: plugin-security 3 files / 115 tests, plugin-sharing 3 / 76, spec contract 1 / 32, dogfood bulk-widener-probe + authored-row-write-scope 2 / 17. All green.
The #7274 probe readings (dogfood, real stack)
  • With the fix: update declaredAdmitted = touched = n_alice_open_1, n_alice_open_2, n_bob_open, authoredScope: { stage: open }, affected: 3. Delete: survivors: [], affected: 3.
  • Ablation A: update touched = n_bob_open only, 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 on c2c17a47, and --ran reconciles 119 derived, 118 run, 1 NOT MEASURED, 0 unrun.
  • NOT MEASURED: node scripts/check-plugin-teardown-shape.mjs --self-test exits 3 (its positive control is pinned to a commit this shallow clone cannot reach). CI runs it on a full checkout.
  • Three families first read red only because the merge left stale state (a pre-merge lint dist; pnpm install not yet re-run for a dependency service-knowledge gained; 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.
  • Local-only 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 Gates and the rest run in CI.

Human Minimum

  • 1. Schemas start as Zod; packages/spec holds no runtime logic.
  • 2. Every name I added uses the casing for its kind.
  • 3. No formatter ran; pnpm lint passes (CI).
  • 4. One issue, one branch off an up-to-date main, one pull request.
  • 5. A change that publishes carries a changeset, and both declaration lines are filled in here and in the changeset.
  • 6. packages/spec touched: its generated artifacts are regenerated and committed (check:generated: all 14 up to date, nothing to regenerate).
  • 7. No hand edits to content/docs/references/, packages/*/CHANGELOG.md or content/docs/releases/.
  • 8. Title, body and comments are in English.

Generated by Claude Code

…ilter-shaped twin of checkAuthoredRowWrite

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>
@github-actions github-actions Bot added size/l documentation Improvements or additions to documentation tests tooling Fix lands in tooling, not a product package — enters pm:queue only with Unblocks: or a named surface labels Nov 28, 2026
@github-actions

Copy link
Copy Markdown
Contributor

📓 Docs Drift Check

This PR changes 3 package(s): @objectstack/plugin-security, @objectstack/plugin-sharing, @objectstack/spec, touching 40 documentable anchor(s).

12 hand-written doc(s) NAME something this change touched and may need an implementation-accuracy re-verification:

  • content/docs/kernel/contracts/index.mdx (via ISecurityService (symbol, a top-level interface))
  • content/docs/kernel/runtime-services/index.mdx (via ISecurityService (symbol, a top-level interface))
  • content/docs/kernel/runtime-services/sharing-service.mdx (via SharingService (symbol, a top-level class))
  • content/docs/permissions/attachments-access.mdx (via ISecurityService (symbol, a top-level interface), SecurityPlugin (symbol, a top-level class))
  • content/docs/permissions/field-level-security.mdx (via SecurityPlugin (symbol, a top-level class))
  • content/docs/permissions/index.mdx (via SecurityPlugin (symbol, a top-level class))
  • content/docs/permissions/permissions-matrix.mdx (via computeLayeredRlsFilter (literal, a string literal in authoredRowWriteLayers; a string literal in getAuthoredRowWriteFilter))
  • content/docs/permissions/sharing-rules.mdx (via computeLayeredRlsFilter (literal, a string literal in authoredRowWriteLayers; a string literal in getAuthoredRowWriteFilter), getReadFilter (literal, a string literal in registerSecurityService; a string literal in start))
  • content/docs/permissions/system-context.mdx (via SecurityPlugin (symbol, a top-level class), buildSharingMiddleware (symbol, a top-level function), registerSecurityService (symbol, a top-level function), canExport (literal, a string literal in registerSecurityService; a string literal in start), canReadObject (literal, a string literal in registerSecurityService; a string literal in start), canWriteObject (literal, a string literal in registerSecurityService; a string literal in start), checkControlledByParentWrite (literal, a string literal in registerSecurityService; a string literal in start), describeEffectiveAccess (literal, a string literal in registerSecurityService; a string literal in start), explainAccessForCaller (literal, a string literal in registerSecurityService; a string literal in start), getMetadataReadableWithheldFields (literal, a string literal in registerSecurityService; a string literal in start), getReadFilter (literal, a string literal in registerSecurityService; a string literal in start), getReadableFields (literal, a string literal in registerSecurityService; a string literal in start), getWritableFields (literal, a string literal in registerSecurityService; a string literal in start))
  • content/docs/plugins/packages.mdx (via SecurityPlugin (symbol, a top-level class))
  • content/docs/protocol/knowledge.mdx (via getQueryableFields (literal, a string literal in registerSecurityService; a string literal in start), getReadableFields (literal, a string literal in registerSecurityService; a string literal in start))
  • content/docs/ui/forms.mdx (via SecurityPlugin (symbol, a top-level class))

⛔ 11 release-owned page(s) also name something this change touched. These are read-only:

  • content/docs/releases/implementation-status.mdx (via SecurityPlugin (symbol, a top-level class))
  • content/docs/releases/v15.mdx (via getReadFilter (literal, a string literal in registerSecurityService; a string literal in start))
  • content/docs/releases/v17/17-0.mdx (via ISecurityService (symbol, a top-level interface))
  • content/docs/releases/v17/17-3.mdx (via SharingService (symbol, a top-level class))
  • content/docs/releases/v17/17-5.mdx (via ISecurityService (symbol, a top-level interface), canReadObject (literal, a string literal in registerSecurityService; a string literal in start), canWriteObject (literal, a string literal in registerSecurityService; a string literal in start), getEffectiveObjectPermissions (literal, a string literal in registerSecurityService; a string literal in start))
  • content/docs/releases/v17/17-6.mdx (via ISecurityService (symbol, a top-level interface), canExport (literal, a string literal in registerSecurityService; a string literal in start), canReadObject (literal, a string literal in registerSecurityService; a string literal in start), getMetadataReadableFields (literal, a string literal in registerSecurityService; a string literal in start), getQueryableFields (literal, a string literal in registerSecurityService; a string literal in start), getReadFilter (literal, a string literal in registerSecurityService; a string literal in start), getReadableFields (literal, a string literal in registerSecurityService; a string literal in start), getWritableFields (literal, a string literal in registerSecurityService; a string literal in start))
  • content/docs/releases/v17/17-7.mdx (via ISecurityService (symbol, a top-level interface))
  • content/docs/releases/v18/18-0.mdx (via ISecurityService (symbol, a top-level interface), SecurityPlugin (symbol, a top-level class))
  • content/docs/releases/v18/18-1.mdx (via SharingService (symbol, a top-level class))
  • content/docs/releases/v18/18-3.mdx (via SharingService (symbol, a top-level class), getRecordFieldAccess (literal, a string literal in registerSecurityService; a string literal in start))
  • content/docs/releases/v18/18-4.mdx (via ISecurityService (symbol, a top-level interface))

content/docs/releases/ is RELEASE-OWNED (AGENTS.md "Documentation Guardrails"): release
notes are written centrally at release time, and a code PR that edits them is the exact PR
that guardrail exists to stop. They are still audited — read-only. If one of them is actually
wrong, file an issue or open a dedicated docs-only PR; do not edit it here.

What this run could not see
  • 1 name(s) were too generic to anchor anything (single lowercase words)
  • the SDK route bridge reached 69 of 252 client-bound route-ledger rows — the other 183 have no registrar path: tail to select them, so pages documenting THEIR client methods cannot appear above, on this or any run. Of those 183: 0 are remediable by widening that discovery convention (an in-repo file declares the path; the convention did not scan it); 59 are structural — on a ledger where NOT ONE row is declared in-repo, so no discovery change reaches them at any price; 124 are undecided (no in-repo declaration, on a ledger that has other in-repo registrars — absence and an unreadable spelling are not distinguishable here). The rows themselves: node scripts/docs-audit/affected-docs.mjs --bridge-coverage
  • a page that states a rule by its inputs shares no identifier with the emitter that implements the rule, so an emitter-only diff cannot list it — not on this run and not on any run. Measured on fix(driver-sql): emit varchar(maxLength) for a text field a declared index keys on #11430: content/docs/protocol/objectql/types.mdx documents the text-family column mapping by the ObjectQL type names it maps FROM (text / textarea / html) while the diff changed createColumn; it went unlisted, and it was the page that diff falsified, in four places. No shared token exists to detect this on, so a rule your change carries has to be re-read by hand in the pages that restate it.
  • a key NAME is not a key, so the hand re-read the line above prescribes can land on the wrong schema. The same spelling is authorable on one governed type and a [REMOVED] tombstone on another for each of active, aria, joins, objects, template, tools and version (censused on [finding] tools is a key on BOTH AgentSchema (tombstoned, dead) and SkillSchema (live, cloud-attested), so a name-based search attributes skill examples to the agent key — it produced a false stop-the-line alarm on PR #19059 #19093 over the liveness ledger's governed types, top-level keys); nothing in a search result distinguishes the two, so a grep hit on a LIVE example reads as evidence about the DEAD key. Measured on fix(spec): the agent.tools liveness row says dead — it claimed live on a key the schema tombstoned #19059: content/docs/ai/agents.mdx was reported as contradicting the agent.tools tombstone over its tools: example at :161, which is inside the defineSkill({ block opened at :155 — the page was already correct. Settle ownership by PARSING the value against both schemas, never by the name: that literal PASSES SkillSchema, and as an AgentSchema it FAILS at tools with the tombstone prescription. ⛔ These names are not the whole class — a key retired through a .strict() guidance map leaves no tombstone in the walked shape and none of them here (tool.category, live as AIToolDefinition.category).

Coarse fallback — 180 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 10321fa22d5dd75a25dfd779b077aa94a563e3e2 → packageMentionDocs.

Which tree this was computed on

This run read content/docs from fe6a23a1415f2d728f3666daea5253d8b6be0d73 — the merge of head c2c17a47a2b90095f5780cdd6ee31b3312449563 into base 10321fa22d5dd75a25dfd779b077aa94a563e3e2, which is what actions/checkout gives a pull_request run. Not the PR head.

A worktree cut from an older main holds a different content/docs, so re-deriving there can legitimately return a different list — that is a different tree, not a wrong row. To answer on the same tree:

# 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

⚠️ That checkout carried uncommitted changes, so the commit above does not fully identify what was read.

Advisory only, and a precision-first one (#9192): a page is listed because it names a
symbol, wire route or SDK method this diff touched — not because it mentions a changed
package. Each row says which anchor put it there, so a wrong row is reportable rather than
merely annoying. To re-verify, run the docs-accuracy-audit workflow scoped to these files:
node scripts/docs-audit/affected-docs.mjs 10321fa22d5dd75a25dfd779b077aa94a563e3e2 → pass the list as
args.docs, on the commit named under Which tree this was computed on.

@objectstack-fleet

Copy link
Copy Markdown
Contributor Author

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, packages/spec/src/contracts/security-service.ts) through an isolated at-tier subagent.

@objectstack-fleet

Copy link
Copy Markdown
Contributor Author

repo:objectstack#8 · sunhaolin · session_017xRBcSAaBEfQpU2yJexSJ8

Contract review

Served-tier: CONTRACT_REVIEW_TIER
Head-sha: c2c17a47a2b90095f5780cdd6ee31b3312449563
Local-runs: none
Scope: packages/spec/src/contracts/security-service.ts + packages/plugins/plugin-security/src/security-plugin-authored-row-write.ts, packages/plugins/plugin-security/src/security-plugin.ts, packages/plugins/plugin-security/src/security-plugin-security-service.ts, packages/plugins/plugin-sharing/src/sharing-service.ts, packages/plugins/plugin-sharing/src/sharing-plugin.ts
Security-touching: yes
Rule-change-verified: none

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 main, the check-runs on this head, and the cited code in the head tree. Security-touching: yes because the hunks change permission behaviour: a predicate update or delete now writes rows an app-authored policy admits. No path under .claude/** is touched, so no hunk changes a rule.

① Derived judgments

  • Public surface, spec: one optional member on ISecurityService, getAuthoredRowWriteFilter?(object, operation, context), returning Promise of FilterCondition | undefined. Right: it is the ruling's "optional filter-shaped answer ... for an object, a verb and a caller". It reuses AuthoredRowWriteOperation and FilterCondition, adds no type and no Zod schema, and an implementation that predates it still satisfies the contract.
  • Accept-set, behaviour: a predicate (multi: true) update or delete under record sharing now reaches the rows an authored using policy for that verb admits. This is a widening, and it is the one the ruling ordered (term (i)). Right. Nothing accepted before is refused after, so no narrowing arm is owed.
  • Accept-set, unchanged cases: a caller with no authored using policy, a check-only policy, a delegated write, a sharing scope that is already null, a security service without the member, and any failure all keep the scope main has. Right, by terms (iii) and (iv).
  • Registered service: registered-security-service-members.pin.test.ts lists the member as optional, and the registration in security-plugin-security-service.ts serves it. Right.
  • plugin-sharing surface: SharingSecurityProbe gains the optional structural member and SharingService gains the public method probeAuthoredRowWriteFilter. ISharingService in the spec is not touched. Right: the composition is the middleware's own, as the ruling says.
  • Gate verdicts on this head: 42 check-runs concluded success and 10 skipped, none failed. That includes Lint & Repo Gates, Check Changeset, Spec property liveness, Governed Surface Queue Guard, Type Check · source gates, Type Check · consumer gates, Build Core and the Dogfood Regression Gate. 15 runs had not concluded when this record was rendered: Test Core shards 1, 2, 5, 6 and 7 of 10, Type Check · workspace, Type Check UI, and eight Test UI shards. Those Test Core shards and the workspace type check are the runs that carry the moved pins, so this record gives no gate verdict for them. It judges the contract and the design; the queue's required checks still have to conclude green on this head.

② Semver level

Three changesets, one per moved package (@objectstack/spec, @objectstack/plugin-security, @objectstack/plugin-sharing), each patch, each carrying both declaration lines.

  • Metadata-protocol: none is right. Nothing a metadata author can write changes: no key, value or metadata type is added, removed or re-read. By the AGENTS.md rule the level follows that kind alone, so none takes patch on all three, including the additive contract member and the behaviour change.
  • No BREAKING banner and no ADR-0087 marker are owed: nothing is removed, renamed or refused.

Clause-②: yes — right. The diff changes a published contract (ISecurityService) and published write behaviour. The bare yes is well formed; a (widening) arm would also have been true and is optional. The PR body and all three changesets carry the same line.

③ Boundary flags

Open question 1, the third pin (plugin-security/src/operator-id-write-gate-33928.test.ts): answered A, accepted as within the ruling. Term (v) names two pins, but it lists them as what moves, not as a limit on what may move. The governing words are term (i), "Bulk scope = sharing scope OR authored scope", and the named premise, "the rows a predicate write changes equal the rows the by-id write admits". The old expectation in this file was the negation of that sentence on one row: the two-key { id, stage } predicate "leaves the row" while the by-id write of the same row writes it. It cannot stay green under the ruled behaviour, and its new expectation is the premise itself (the predicate writes the row, as by id). No product choice moved. I checked the dev's claim that the file's other purpose survives: plugin-sharing's file of the same name still pins which branch each option shape takes (admitsByIdWrite against buildWriteFilter, over the engine's dispatch table). Nothing here needs the maintainer.

Open question 2, the member name getAuthoredRowWriteFilter: answered A, keep. The ruling names no member. Its words are "an optional filter-shaped answer: the authored policies' own scope for an object, a verb and a caller, with the platform ownership floor taken out". The signature (object, operation, context) is that object, verb and caller, and the name follows the two precedents on the same contract: getReadFilter for a filter that answers undefined, and checkAuthoredRowWrite for the same question as a verdict. One caution, which the jsdoc already covers: getReadFilter narrows and this member may only widen, and the jsdoc says so with its own ⛔ and in the contract header's failure-class list. No escalation.

Dev deviations: the extra files (security-plugin-security-service.ts, the members pin, the two middleware doubles, the dogfood probe, rls.mdx) are each forced by the change or by term (v). security-plugin-security-service.ts is where the registration lives, so it is in my scope and is judged in ④. The tests, the dogfood probe, the changesets' prose and content/docs/permissions/rls.mdx are the lane seat's ACCEPT at TIER_DEFAULT. One note for that seat: the moved plugin-security test's header still opens "The declared narrowing of the sharing write gate", above a body that now pins the opposite.

SQL push-down: no finding. The new answer is a compiled predicate ORed into the write's where; the diff adds no id materialisation, no in-app join and no read. The ruling's "does not probe row by row on the bulk path" holds: the bulk branch makes one call per write and getAuthoredRowWriteFilter reads nothing.

Ruled prohibitions: buildWriteFilter, checkEdit and checkDelete are not in the diff's hunks. The 2026-08-15 no-marking block above the bulk branch is intact and the new composition is unmarked, as that block requires.

④ Design judgment

No must-fix, no should-fix.

packages/spec/src/contracts/security-service.ts (hit), read against the ruling and its first consumer, the sharing middleware's bulk branch:

  • "a row matches the filter iff checkAuthoredRowWrite answers admit for it": holds by construction. Both read one helper, authoredRowWriteLayers; the verdict probes { id } AND layer0 AND layer1 and the filter is layer0 AND layer1. A pin compares the two row for row on both verbs.
  • "with the platform's ownership floor taken out" and the tenant wall kept: holds. The floor leaves through the sets by provenance, and Layer 0 is ANDed beside Layer 1.
  • "undefined is the fail-closed answer", with its five listed cases: each maps to a null from the helper or to the catch. The superuser case rests on computeLayeredRlsFilter answering a null Layer 1, which the verdict's existing docblock states and which this diff does not change.
  • "Verb for verb" and "a caller maps lifecycle verbs onto these two classes itself": the middleware passes rlsOperationForVerb(op).
  • "Evidence, not authorization" and "only to WIDEN ... by OR, never to narrow": the one consumer ORs it, and plugin-security's own layers still run on the write.
  • "OPTIONAL ... callers feature-detect": the consumer checks typeof probe.getAuthoredRowWriteFilter !== 'function'.

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, admitsByIdWrite is the per-verb gate OR the verdict; in bulk, the scope is buildWriteFilter OR the filter.

  • A private object, cross-owner row, no read grant. By id the row is refused by plugin-security's pre-image read. If the bulk path lacked that read bound, the new OR would write rows by predicate that by id refuses. It does not: plugin-security ANDs readableRowsScopeForPredicateWrite into every addressed predicate write, so the row is not matched. The two paths agree.
  • Delegated write. By id, both identities are gated and the verdict abstains. In bulk, the middleware guard, the passthrough and the helper each abstain on onBehalfOf, and the delegator intersection is composed before the OR and never widened. Three guards for one rule is redundant but safe, and ablation B shows the controls go red without them.
  • Order of composition. The OR sits after the delegator AND and before composeAnd(ast.where, ...), so the caller's own predicate still bounds the write and the authored scope cannot escape it.
  • A sharing scope that denies everything. It is non-null, so the authored scope is ORed in. By id the same caller is admitted by the verdict alone, so this is equal, not wider.
  • A null sharing scope. Not asked, and correct: nothing narrows there, so there is nothing to widen.
  • A hostile or broken answer. The passthrough accepts only a non-array object and logs a throw once. An empty object would match every row, but only if plugin-security itself compiled an authored Layer 1 to that, in which case the verdict admits every row by id too.

Implementing files, against the contract:

  • security-plugin-authored-row-write.ts: the moved head is the old body line for line, with return 'abstain' turned into return null. checkAuthoredRowWrite keeps its guards in the same order, then the helper, then the same elevated id-only probe. The by-id verdict does not change.
  • security-plugin.ts and security-plugin-security-service.ts: the method and the registration follow the existing host-literal shape, and the docblock agrees with the spec jsdoc.
  • sharing-service.ts: probeAuthoredRowWriteFilter mirrors probeAuthoredRowWrite guard for guard, and feeds none of buildWriteFilter, checkEdit or checkDelete.
  • sharing-plugin.ts: the hunk is terms (i) to (iv) and nothing more.

Nits (no effect on correctness or the contract; a fix would move the head, so each is left as an accepted deviation):

  • N1 (nit) — the module header of security-plugin-authored-row-write.ts still describes a module that holds the verdict alone, "moved ... otherwise unedited". It now also holds authoredRowWriteLayers and the exported getAuthoredRowWriteFilter.
  • N2 (nit) — both catch blocks call this.logger.warn?.(...), which would itself throw if logger were unset, against "never throws outward". This is the verdict's existing pattern, and the service is registered only after start() assigns the logger.

Implemented-by: claude/issue-37535-bulk-authored-scope
Reviewed-by: session_017xRBcSAaBEfQpU2yJexSJ8

VERDICT: PASS

@objectstack-fleet

Copy link
Copy Markdown
Contributor Author

repo:objectstack#8 · sunhaolin · session_017xRBcSAaBEfQpU2yJexSJ8

L1: ACCEPT · head c2c17a47a2b90095f5780cdd6ee31b3312449563 · 2026-11-28T04:04Z · card #37535

席位核对

  1. Shape — l1-face.mjs --pr 38131 clean: draft on main, mergeable_state clean, first line Fixes #37535 only, three changesets (@objectstack/spec, plugin-security, plugin-sharing), Clause-②: yes · Metadata-protocol: none on the body and all three. Fixes is right: the card's four done-when lines (the optional member, the OR per (i)–(iv), (v)'s pins moved, the premise measured and stated) are each in the diff and the PR body.
  2. Premise measured — the ruling's premise clause: premises 10 and 12 of 7187970489 re-run, and the PR test(dogfood): probe app-authored RLS wideners on the bulk write path (#6736) #7274 probe located (packages/qa/dogfood/test/bulk-widener-probe.dogfood.test.ts, the one file test(dogfood): probe app-authored RLS wideners on the bulk write path (#6736) #7274 added; it cites Authored RLS update-wideners are silently ineffective on the bulk write path — buildWriteFilter ANDs them away (fewer rows, no error) #6736, which is why git grep 7274 missed it). Named premise holds: predicate rows = by-id rows on the relief and test(dogfood): probe app-authored RLS wideners on the bulk write path (#6736) #7274 fixtures, no row changes for a caller without an authored using policy. Ablation A (OR line neutralised) ⇒ 8 widening pins + the composition pin red, both dogfood MEASURE cases red, controls green; ablation B (delegated guards removed) ⇒ both delegated controls red.
  3. Gates at this head — check-runs: 60 success · 10 expected skip · 0 failed · 0 pending; Lint & Repo Gates and TypeScript Type Check success. check-governed-merges.mjs --pr 38131: NOT governed (+705/−160 ≤ 3000). landing-k.mjs: K = 6.
  4. L2 — the owed CONTRACT_REVIEW_TIER review (face: published schema packages/spec/src/contracts/security-service.ts) is PASS on this head, record 7233479562 (isolated at-tier subagent; no must-fix, no should-fix; nits N1, N2 accepted). It answered the dev's two open questions as A within the ruling: the third moved pin (operator-id-write-gate-33928.test.ts) is the negation of the ruling's premise on one row; the member name follows getReadFilter / checkAuthoredRowWrite on the same contract.
  5. Read by the seat — the three changesets sentence by sentence: true to the diff and to terms (i)–(iv) ("buildWriteFilter, checkEdit and checkDelete are unchanged" holds — none is in a hunk). content/docs/permissions/rls.mdx 116-125: the old sentence ("a predicate write does not reach it … address it by id alone") was made false by this change and is corrected; the new text is true (verb for verb, read bound kept, delegated writes not widened). The Known limitation callout below it still holds: the read bound stays ANDed on every predicate write (L2 ④). Accepted deviations: the dev's surface additions (registration producer, members pin, middleware doubles, dogfood probe, rls.mdx), each forced by the change or term (v); the moved plugin-security test's header line still opens "The declared narrowing of the sharing write gate" (L2 note) — nit, not moved.
  6. Out of scope — the rls.mdx sentence → corrected here (Acceptance notes). Skills-docs: not owed (kind none). Security-touching: yes — the permission behaviour moved is the maintainer's ruled 2a (7190344023), nothing beyond it.

Landing — non-governed, ≤3000 lines, L2 PASS on this head: the seat lands it through the ordinary queue.

@objectstack-fleet

Copy link
Copy Markdown
Contributor Author

repo:objectstack#8 · sunhaolin · session_017xRBcSAaBEfQpU2yJexSJ8

Landing · 2026-11-28T04:05Z · head c2c17a47

probe reading
check-governed-merges.mjs --pr 38131 NOT governed · +705/−160 ≤ 3000
landing-k.mjs --pr 38131 K = 6 < 15
L2 on this head PASS · record 7233479562 · CONTRACT_REVIEW_TIER

State: ready for review + auto-merge (L1 ACCEPT 7233671627).

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

Labels

documentation Improvements or additions to documentation size/l tests tooling Fix lands in tooling, not a product package — enters pm:queue only with Unblocks: or a named surface

Projects

None yet

Development

Successfully merging this pull request may close these issues.

sharing: a predicate bulk write also honours app-authored update/delete policies (authored scope ORed into the middleware bulk write scope)

2 participants