Skip to content

fix(plugin-sharing): refuse an unresolved user recipient on the sys_sharing_rule /data door - #39361

Draft
objectstack-fleet[bot] wants to merge 4 commits into
mainfrom
claude/project-thread-6t02u3
Draft

objectstack-fleet[bot] wants to merge 4 commits into
mainfrom
claude/project-thread-6t02u3

Conversation

@objectstack-fleet

@objectstack-fleet objectstack-fleet Bot commented Dec 3, 2026 •

Copy link
Copy Markdown
Contributor

Requested by Bill · project thread

Fixes #38254

Clause-②: no (narrowing)
Metadata-protocol: none
Skills-docs: updated here

维护者速读

  • 用户能看到什么变化:在 Setup 的共享规则表单里,选了一个不存在的用户(或别的组织的用户)作为接收人,保存时会被拒绝(400,提示换一个本组织的用户),不再存下一条谁都共享不到的规则。
  • 为什么做:POST /api/v1/sharing/rules 早已(A manual record share to a user id that does not exist is accepted (201) and persists an inert sys_record_share row #33912)拒收这种接收人,但表单走 /data 门,绕过了那道检查。
  • 出错会怎样:只收紧一个写入口;已存的旧规则不受影响,照样能停用或编辑。规则改到另一个组织时,按新组织判断接收人。
  • 要你做什么:无需决定。按收窄申报,入队前欠一次契约档审核。

What changes

  • packages/plugins/plugin-sharing/src/rule-hooks.ts: new bindRuleRecipientGuard (beforeInsert / beforeUpdate on sys_sharing_rule, its own package id plugin-sharing:rule-recipient-guard). It refuses a user recipient with SharingService.userRecipientRefusal(id, organization, 'rule'), the verdict and sentence defineRule uses, thrown as validationFailure (VALIDATION_FAILED, 400) with one fields entry under recipient_id (invalid_value, the code plugin-auth's guards already use).
    • Insert: judged when the recipient type is user.
    • Update: judged only when the resulting recipient is user and differs from the pre-image (type or id), so a rule whose user has since left can still be switched off or edited.
    • Organization: the one the write leaves the rule in. An organization_id the write supplies (on an update, a re-point the tenant wall admitted), else the stored row's, else the caller's active organization (the Setup form posts none). With none under a wall the verdict stands aside, as it does for defineRule (the engine refuses that insert for every recipient alike).
    • System writes are not judged, like the object guard beside it.
  • packages/plugins/plugin-sharing/src/sharing-plugin.ts: binds the guard next to bindRuleObjectEnforcementGuard.
  • packages/plugins/plugin-sharing/src/sharing-rule-recipient-guard.test.ts: real ObjectQL + SqlDriver pins, isolated, group and single posture, including one pin per organization arm (a form-shaped insert with no organization_id, an update by a caller with no active organization, a re-pointing update).
  • content/docs/permissions/system-context.mdx: the guard's system-context early return is an elevation read, so row 40 names bindRuleRecipientGuard and the generated register is regenerated (check-system-context-census).
  • packages/runtime/src/sharing-rule-declared-name.data-door.pin.test.ts: its authored rows named a made-up user recipient, which the new guard (bound first) now refuses before the declared-name guard the pin targets; they now name the signed-in dev admin's real sys_user id. A module-top import '@objectstack/metadata' pays that package's lazy load (reached through app-plugin.ts) during collection instead of inside the first timed case, as check-test-source-alias requires for a changed test file that reaches it. One new case asserts the wire answer at the real door: 400, VALIDATION_FAILED, fields[0].field === 'recipient_id', no row.
  • content/docs/kernel/runtime-services/sharing-service.mdx and content/docs/permissions/sharing-rules.mdx: state the recipient refusal for the /data door too.
  • One patch changeset for @objectstack/plugin-sharing (non-protocol narrowing: BREAKING line, the caller's fix, ADR-0087 not-required).

No new error code, export from the package index, or locale key.

Why

PR #38216 made SharingService.grant and SharingRuleService.defineRule refuse a user recipient that resolves to no user, and named the /data door as unchanged. The Setup form writes through that door, so it kept storing inert rules that told the admin they saved.

Verification

  • pnpm exec vitest run src/sharing-rule-recipient-guard.test.ts (plugin-sharing): 15 passed. With the bind commented out, every refusal case fails. Each organization arm ablated in turn (session arm removed; stored-row arm removed; pre-image ahead of the supplied value) turns exactly its own pin red.
  • Pinned: unknown id refused with the exact sentence and fields; a user of another organization answers the same code and sentence (id aside) as an unknown id; the /data sentence equals defineRule's; position recipient and system context pass; update moving onto an unresolved user (by id or by switching type) refused and the row unchanged; update keeping the stored recipient (and switching off) admitted; single posture refuses an unknown id and admits any existing user; the three organization arms above.
  • pnpm exec vitest run src/sharing-rule-declared-name.data-door.pin.test.ts (runtime): 5 passed, the three 409 assertions unchanged.
  • Whole plugin-sharing suite at the first head: 82 files, 1792 passed. check-system-context-census, check-adr-0087-registration, check-test-source-alias and ESLint on the changed files pass locally.

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.
  • 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. (not touched)
  • 7. No hand edits to content/docs/references/, packages/*/CHANGELOG.md or content/docs/releases/.
  • 8. Title, body and comments are in English.
  • The Before Submitting list in CONTRIBUTING.md is done.

🤖 Generated with Claude Code

https://claude.ai/code/session_01Utp6CZVKCmRkE5bj7Rwba3

…haring_rule /data door

The Setup sharing-rule form writes through POST /api/v1/data/sys_sharing_rule,
which never reaches defineRule, so a rule whose `user` recipient named no
user (or no member of the rule's organization) was stored and granted no
one access. bindRuleRecipientGuard refuses that insert, and an update that
moves a rule onto such a recipient, with defineRule's own verdict and
sentence (SharingService.userRecipientRefusal), VALIDATION_FAILED under
recipient_id. System writes and updates that keep the stored recipient are
not judged.

Co-Authored-By: Claude <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01Utp6CZVKCmRkE5bj7Rwba3
@github-actions github-actions Bot added size/m 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 Dec 3, 2026
@github-actions

github-actions Bot commented Dec 3, 2026 •

Copy link
Copy Markdown
Contributor

📓 Docs Drift Check

This PR changes 1 package(s): @objectstack/plugin-sharing, touching 9 documentable anchor(s).

39 hand-written doc(s) name something this change touched — list omitted above 15 rows. Re-derive on the tree named below: node scripts/docs-audit/affected-docs.mjs --json 5788b130725ea58c1e8ca511c082849ef5f933f8.

⛔ 7 release-owned page(s) also affected — read-only, see AGENTS.md Documentation Guardrails.

What this run could not see
  • 1 name(s) were too generic to anchor anything (single lowercase words)
  • the SDK route bridge reached 71 of 256 client-bound route-ledger rows — the other 185 have no registrar path: tail to select them, so pages documenting THEIR client methods cannot appear above, on this or any run. Of those 185: 0 are remediable by widening that discovery convention (an in-repo file declares the path; the convention did not scan it); 60 are structural — on a ledger where NOT ONE row is declared in-repo, so no discovery change reaches them at any price; 125 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 — 12 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 5788b130725ea58c1e8ca511c082849ef5f933f8 → packageMentionDocs.

Which tree this was computed on

This run read content/docs from 64eeba406442f3b3402cb093de513c7dc26268f7 — the merge of head 1b8a19562b6ef62c82ec0977fb4c40f565a5c2f6 into base 5788b130725ea58c1e8ca511c082849ef5f933f8, 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 64eeba406442f3b3402cb093de513c7dc26268f7 && git checkout 64eeba406442f3b3402cb093de513c7dc26268f7
# afterwards, rebuild it from the two parents, which stay fetchable
git fetch origin 5788b130725ea58c1e8ca511c082849ef5f933f8 1b8a19562b6ef62c82ec0977fb4c40f565a5c2f6 && git checkout -B drift-repro 5788b130725ea58c1e8ca511c082849ef5f933f8 && git merge --no-ff 1b8a19562b6ef62c82ec0977fb4c40f565a5c2f6

node scripts/docs-audit/affected-docs.mjs --json 5788b130725ea58c1e8ca511c082849ef5f933f8

⚠️ 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 5788b130725ea58c1e8ca511c082849ef5f933f8 → pass the list as
args.docs, on the commit named under Which tree this was computed on.

- changeset: answer the ADR-0087 question for the narrowing
  (not-required, no-migration-prescription).
- system-context page: row 40 names bindRuleRecipientGuard, whose
  system-context early return is an elevation read; register regenerated.
- runtime declared-name pin: author its rows to the dev admin's real user
  id, since the data door now refuses a user recipient that names no user.

Co-Authored-By: Claude <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01Utp6CZVKCmRkE5bj7Rwba3
@objectstack-fleet

Copy link
Copy Markdown
Contributor Author

repo:objectstack@os-bill · os-bill · session_01Utp6CaJjkQx5fPE4Fbmoeq

Contract review

Served-tier: CONTRACT_REVIEW_TIER
Head-sha: 26afba6f4b429fe554201a84f6c9a1e68bed33c1
Local-runs: none
Scope: packages/plugins/plugin-sharing/src/rule-hooks.ts, packages/plugins/plugin-sharing/src/sharing-plugin.ts, packages/plugins/plugin-sharing/src/sharing-rule-recipient-guard.test.ts, packages/runtime/src/sharing-rule-declared-name.data-door.pin.test.ts + none in the diff; read outside it: packages/plugins/plugin-sharing/src/sharing-service.ts, packages/plugins/plugin-sharing/src/sharing-rule-service.ts, packages/plugins/plugin-sharing/src/index.ts, packages/plugins/plugin-sharing/src/objects/sys-sharing-rule.object.ts, packages/objectql/src/engine-insert.ts, packages/objectql/src/engine-update.ts, packages/objectql/src/engine-execution-plumbing.ts, packages/objectql/src/engine-top-level.ts, packages/plugins/plugin-security/src/security-plugin-write-tenant-wall.ts, packages/types/src/validation-failure.ts, packages/runtime/src/dispatcher-plugin.ts

Inputs read: card #38254 (body, triage 7240297066, unlock 7241733218, claim 7381546986, amendments 7382578933 and 7382609355; no ruling, no earlier record), PR #39361 (body, 6 files, net diff against merge base 850d240b80; none of the touched files moved on main since), and the check-runs on the head. The changeset and content/docs/permissions/system-context.mdx are prose faces: the lane seat's ACCEPT, noted here only where ② or ③ reads them.

① Derived judgments

  • Accept set of every non-system write on sys_sharing_rule narrows, as declared. A write that leaves a user recipient which SharingService.userRecipientRefusal refuses went from stored to VALIDATION_FAILED with one fields entry (recipient_id, invalid_value). Right, and it is the narrowing the card asks for.
  • The door is wider than the changeset's "Setup form, or any caller of POST/PATCH /api/v1/data/sys_sharing_rule": the guard is an engine hook, so an import, a user-context automation write, a batch insert (one dispatch per row, engine-insert.ts:669-702) and a predicate update (one dispatch per matched row, each with its pre-image) are judged too. A write that carries no execution context at all is judged as well, because session is then absent and isSystem reads false (engine-execution-plumbing.ts:59-60); the object guard beside it behaves the same way. Right: every one of these stored an inert rule before. Test Core (12 shards) and Dogfood Regression Gate are success on the head, so no in-repo writer depended on the old answer except the one pin the diff re-fixtures.
  • Not narrowed, each read in the code: a system context (rule-hooks.ts:473); a recipient type other than user (:482); an update that names neither recipient key (:480) or keeps the stored user recipient (:486); a deployment that registers no sys_user; a wall with no organization to judge in (sharing-service.ts:2377). Right, and each matches defineRule (sharing-rule-service.ts:859-890).
  • Same verdict, same sentence: the guard calls userRecipientRefusal(id, organization, 'rule') (rule-hooks.ts:490), the call defineRule makes at sharing-rule-service.ts:888. No second implementation. Right.
  • Wire answer: validationFailure sets name: 'ValidationError' and code: 'VALIDATION_FAILED' (packages/types/src/validation-failure.ts:76-82), and the dispatcher's error exit maps that shape to the validation status with details.fields (dispatcher-plugin.ts:731-735). 400 holds by reading. It is asserted by no test in this diff (N1).
  • Public surface of @objectstack/plugin-sharing: unchanged. bindRuleRecipientGuard and RULE_RECIPIENT_GUARD_PACKAGE are module exports only; the index re-exports a named list from rule-hooks.js that does not include them (index.ts:52-59), and the package exports map has . alone. No new error code, no locale key. Right.
  • Guard order: the recipient guard is bound ahead of the declared-name guard at the same priority (sharing-plugin.ts:1087-1094), so a row that both takes a declared name and names an unresolved user now answers 400, not 409. No contract fixes that order. It is why the runtime pin's fixture had to change, and the change is right (④).
  • Metadata-protocol: none: holds. A declared rule (the metadata author's source) is served from the registry and is not written to this table by a user context, so nothing an author can write in metadata is refused. Noted for the seat: the sibling changeset for the same refusal at the service doors, .changeset/pre/33912-share-unknown-recipient.md, declared narrowed and took minor. The two readings differ; this one follows the claim.

② Semver level

.changeset/38254-sharing-rule-data-door-recipient.md: @objectstack/plugin-sharing patch. The package is published (no private, 19.0.0-next.3) and is the only published package the diff moves; packages/runtime changes in a test file alone. A non-protocol narrowing ships patch (AGENTS.md, Post-Task Checklist step 3). Clause-②: no (narrowing) and Metadata-protocol: none stand line-initial in the changeset and in the PR body and agree with claim 7381546986. The ADR-0087 marker is present (not-required, with a reason). Check Changeset is success on the head.

Two things for the lane seat on the prose faces, neither part of ④:

  • AGENTS.md step 3 says a (narrowing) is BREAKING and that a non-protocol change "keeps its BREAKING banner". This changeset has a Before/Now pair but no BREAKING line and no caller's fix; the sibling changeset carries both.
  • The PR body carries no Skills-docs: line, which the (narrowing) arm owes it.

Dogfood battery (opt-in) is skipped on the head. A (narrowing) owes that battery before the queue.

③ Boundary flags

  • The PR body raises no question and asks for no decision. The claim's stop condition (any file outside the surface) was met twice and amended on the card both times (7382578933, 7382609355). Answered.
  • Triage's condition, "an unknown id and another organization's user get the same answer, and pin it": pinned at sharing-rule-recipient-guard.test.ts:163-172, with the row's organization supplied. See S1 for the shape that is not pinned.
  • Cross-organization oracle, tried and not found:
    • A walled caller cannot choose the organization the insert is judged in. A supplied organization_id outside the caller's wall is refused by the wall's payload half, in the middleware chain, before any beforeInsert hook runs and for every recipient alike (security-plugin-write-tenant-wall.ts:476-482; order at engine-insert.ts:510-516). A value the hook does see is the value that will be stored (engine-top-level.ts:2661-2663).
    • An update's pre-image is the row the caller's own scope read. A by-id update of a row the caller cannot read answers not-found before the hooks (engine-update.ts:938-946), so another organization's rule id gives no pre-image to judge in.
    • Under a wall, a user of another organization and an id that does not exist both read not_member and get one sentence (sharing-service.ts:2378-2389). With no organization the verdict stands aside and the engine refuses the insert for every recipient (:2377).
    • What a caller who may write rules can learn is whether an id is a member of an organization that caller already administers (under single, whether a sys_user exists). defineRule tells the same caller the same thing.
  • A non-string recipient_id: a number or boolean is rewritten to its string at engine entry, before the hooks (engine-insert.ts:376-378, engine-update.ts:248-250), and an object is refused by the validator. present() at rule-hooks.ts:471 lets nothing through.
  • SQL push-down: the guard adds one point read per judged write (a sys_member standing read, or sys_user by id with limit: 1, sharing-service.ts:2378-2398). No id materialisation, no in-app join. A batch insert pays one per row that names a user recipient, on a table that holds a deployment's sharing rules. Nothing to push down.
  • Out of scope, for a follow-up card and not a fix on this head: an update that only re-points organization_id and leaves the recipient alone is not judged (rule-hooks.ts:480). The card covers an insert and an update that changes the recipient, so this is outside it. It is reachable only where the wall admits a re-point (S2 says where).
  • Seen outside the changed hunks, for the seat: content/docs/kernel/runtime-services/sharing-service.mdx:108 states this refusal for grant and defineRule only, while :112 names the /data door for the object refusal; content/docs/permissions/sharing-rules.mdx:188-199 likewise. The pages are not made false, they are now incomplete. This is the content of the missing Skills-docs: line.

④ Design judgment

packages/plugins/plugin-sharing/src/rule-hooks.ts (hits), the guard against its docblock (:435-461) and against defineRule.

  • "The verdict and the sentence are defineRule's own." Holds (①).
  • "the refusal is VALIDATION_FAILED (400) under recipient_id." Holds by reading (①).
  • "An insert with a user recipient is judged." Holds (:481-490). A missing id is left to the required validator (:485), as defineRule leaves it to its own required-field check.
  • "An update is judged only when it leaves a user recipient that differs from the pre-image (type or id)." Holds. Tried: id changed (:483, judged); type switched to user with the stored id kept (judged, the stored id is read from the pre-image); a full-form save that re-sends the stored pair (:486, not judged); a patch that names neither key (:480, not judged); a patch that changes the id of a position rule (:482, not judged, and it is a position name). The same condition as sharing-rule-service.ts:883-885.
  • "System writes pass." Holds (:473). defineRule writes under the system context after making the check itself for a non-system caller (sharing-rule-service.ts:859).
  • "With no organization under a wall the verdict stands aside." Holds (sharing-service.ts:2377).
  • "An id that names no user and a user of another organization are answered alike, so the door is no oracle." Holds (③).
  • "Judged in the rule's organization: on an update the stored row's." The code does what the sentence says (:487-489). The sentence is not always the rule's organization: S2.
  • A pre-image is assumed on every update. The engine binds one on the by-id path and on each row of the predicate path. If it were ever absent, a patch that names only recipient_id would read no type and pass unjudged. The declared-name guard beside it makes the same assumption (sharing-rule-service.ts:315-320). Accepted.

packages/plugins/plugin-sharing/src/sharing-plugin.ts (hits). One bind, beside bindRuleObjectEnforcementGuard, behind the same this.service test and outside the rebind seam (:1082-1087). this.service is the SharingService that carries userRecipientRefusal. The bind unregisters its own package id first (rule-hooks.ts:468-470), so a second start does not double it. Holds.

packages/plugins/plugin-sharing/src/sharing-rule-recipient-guard.test.ts (hits). Real ObjectQL and SqlDriver, so the hook runs on the engine's write path and the pre-image is the engine's. Twelve cases, six refusals each beside a control that changes one value; the refusals assert code, the exact sentence and fields, and that nothing was stored. The defineRule comparison (:174-181) is against the live service, not a copied string. What it does not cover is S1.

packages/runtime/src/sharing-rule-declared-name.data-door.pin.test.ts (hits). The pin posts form-shaped rows through the real door and asserts 409 for a declared name. With a made-up recipient the new guard, bound first, would answer 400 and the pin would stop reaching the guard it pins. The fixture now reads the signed-in admin's own sys_user id in beforeAll (:178-180) and fails loudly if there is none. authoredRow is called only inside the cases, after beforeAll, so it never reads the empty initial value. The three assertions are untouched, and the control (:201-206) still proves a form-shaped row with a non-declared name lands. The pin tests what it pinned. The side-effect import at :59-60 moves a lazy module load from the first clocked case to collection and changes no assertion; its reason is recorded nowhere (the commit has no body, the PR body does not name it). That is for the seat's L1, not a finding here.

No must-fix.

  • S1 (should-fix) — sharing-rule-recipient-guard.test.ts:124-137 and :66-72: every case writes a row that carries organization_id: 'org_a', under a session whose organization is org_a, against stored rows in org_a. The three sources at rule-hooks.ts:487-489 therefore give the same value in every case, and no case tells them apart. Two consequences:
    • The Setup form posts no organization_id. For that shape the insert is judged in the session's organization (:489). Remove that arm and all twelve cases stay green, while under a wall the verdict would stand aside for the form's own shape (sharing-service.ts:2377) and store every recipient. That is the scenario the card is accepted against, and it fails open.
    • "On an update the stored row's" is unpinned: no case has a session organization that differs from the stored rule's.
      Owed: an isolated insert with no organization_id on the row (another organization's user and an unknown id refused, a member stored), and an update by a session whose organization differs from the stored rule's, judged in the rule's.
  • S2 (should-fix) — rule-hooks.ts:487-489: on an update the pre-image's organization wins over one the patch supplies. Where the wall admits a re-point, the engine shows it to beforeUpdate and stores it as sent (engine-update.ts:662-672; security-plugin-write-tenant-wall.ts:561-562). That is the group posture, for a caller whose membership set holds both organizations. A patch that carries both a new organization_id and a new user recipient is then judged in the organization the rule is leaving. A member of the old organization who is not in the new one is stored, which is the inert rule this guard exists to refuse; a member of the new one is refused with a sentence that is false for that rule. No oracle follows, since the wall admitted both organizations to this caller. Read in the code, not measured. Owed: judge in the organization the write leaves the rule in (the patch's when the hook is shown one, else the pre-image's, else the session's), with a pin; or, if the pre-image is meant, say so in the docblock and file the re-point as a card with the out-of-scope twin in ③.
  • N1 (nit) — the 400 and details.fields at the HTTP door hold by reading (①) and are asserted nowhere: the new cases stop at the engine, and the runtime pin, which already drives the real door, asserts only the 409. The card says "not measured at the live door", and that is still so. One case there would close it. It is a nit on this face because the mapping is the dispatcher's and unchanged; the seat's L1 checklist asks for it on its own terms.

Check-runs on the head, all success: Lint & Repo Gates, TypeScript Type Check, Type Check · workspace / source gates / consumer gates / debt ledger, Lint · ESLint / docs & code guards / repo & tooling gates / PM dispatch-gates / CI, release & engine gates, Test Core (1-12 of 12), Test UI, Build Core, Build Docs, Live E2E UI, Dogfood Regression Gate, Check Changeset, Governed Surface Queue Guard, PR-body guards, Spec property liveness, Check Documentation Links, Check PR Size. Dogfood battery (opt-in) is skipped.

Implemented-by: claude/project-thread-6t02u3
Reviewed-by: session_01Utp6CaJjkQx5fPE4Fbmoeq

VERDICT: PASS

… pin the organization arms

Review round 1 on the recipient guard:
- the organization a write is judged in is the one it leaves the rule in:
  a supplied organization_id first, then the stored row's, then the
  caller's active organization; each arm has a pin that turns red without it;
- the runtime door pin asserts the 400 VALIDATION_FAILED envelope;
- the changeset carries the BREAKING line and the caller's fix;
- the sharing-service and sharing-rules pages name the /data door refusal.

Co-Authored-By: Claude <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01Utp6CZVKCmRkE5bj7Rwba3
@objectstack-fleet

Copy link
Copy Markdown
Contributor Author

repo:objectstack@os-bill · os-bill · session_01Utp6CaJjkQx5fPE4Fbmoeq

Contract review

Served-tier: TIER_DEFAULT
Head-sha: 1b8a19562b6ef62c82ec0977fb4c40f565a5c2f6
Local-runs: none
Scope: packages/plugins/plugin-sharing/src/rule-hooks.ts, packages/plugins/plugin-sharing/src/sharing-plugin.ts, packages/plugins/plugin-sharing/src/sharing-rule-recipient-guard.test.ts, packages/runtime/src/sharing-rule-declared-name.data-door.pin.test.ts + none in the diff; read outside it: packages/plugins/plugin-sharing/src/sharing-service.ts, packages/objectql/src/engine-insert.ts, packages/objectql/src/engine-update.ts, packages/plugins/plugin-security/src/security-plugin-write-tenant-wall.ts, packages/types/src/data-error-classification.ts, packages/rest/src/crud-routes.ts, packages/runtime/src/dispatcher-plugin.ts
Tier-note: CONTRACT_REVIEW_TIER exhausted (429, resets Dec 9 20:00 UTC); Opus delta per maintainer 「fable 用完之后,可以用 opus 复审」 (2026-12-03T15:42Z)

Delta review. Round 1 is the record on 26afba6f4b429fe554201a84f6c9a1e68bed33c1 (PR comment 7384107108: PASS, S1 and S2 open, N1 nit). The delta is one commit, 1b8a19562b (6 files, +86 −9): rule-hooks.ts, the guard test, the runtime pin, the changeset, and two docs pages (content/docs/kernel/runtime-services/sharing-service.mdx, content/docs/permissions/sharing-rules.mdx). sharing-plugin.ts and content/docs/permissions/system-context.mdx did not move, and round 1's judgments on them stand. Inputs read: the delta diff and commit body, the PR body at this head, card #38254's claim 7381546986 and amendments 7382578933 and 7382609355, and the check-runs on this head. The changeset and the two docs pages are prose faces. They are the lane seat's ACCEPT and are read here only where ② or ③ needs them.

① Derived judgments

  • The accept set is unchanged from round 1 except on one path. Insert and recipient-preserving updates read exactly as before. The change is an update whose patch carries organization_id and moves the user recipient. It is now judged in the patch's organization, not the stored row's (rule-hooks.ts:489-491). Before this head, such a patch stored a member of the old organization (an inert rule in the new one) and refused a member of the new one. Now it does the reverse. That is the narrowing's own intent, carried to the organization the rule actually lands in (S2).
  • A value the hook sees in data.organization_id is a value that will be stored, so letting it lead cannot misjudge:
    • On an insert, the driver stamps the session's organization after the hooks (engine-insert.ts:1102-1118). A form row therefore shows the hook no organization_id, and the session arm decides.
    • On an update, a static-readonly organization_id is hidden from beforeUpdate unless the Layer 0 wall judges it (engine-update.ts:669-690). Where the wall judges it, a supplied value outside the caller's wall has already been refused, along with any emptied one (security-plugin-write-tenant-wall.ts:476-482, :561-562).
  • Wire answer, corrected from round 1. Round 1 cited the dispatcher's thrown-error exit (dispatcher-plugin.ts:731-735, details.fields). That is not the /data door. POST /api/v1/data/:object is @objectstack/rest's crud-routes.ts, which maps through mapDataError. Its validation arm answers the flat body { error, code: 'VALIDATION_FAILED', fields, object } at 400 (packages/types/src/data-error-classification.ts:1184-1193). The thread's claim, "/data carries fields at the top level, not details.fields", holds by reading, and the new runtime case asserts it (N1). The dispatcher's details.fields shape belongs to a different door and is unaffected.
  • Public surface of @objectstack/plugin-sharing: unchanged by the delta. There is no new export, code or locale key.

② Semver level

.changeset/38254-sharing-rule-data-door-recipient.md is still @objectstack/plugin-sharing patch. Clause-②: no (narrowing) and Metadata-protocol: none stand line-initial (:7-8) and in the PR body. The ADR-0087 marker is unchanged (:10).

  • The delta adds the BREAKING line (:18), which names who (a non-system writer of the table), the before (2xx, inert rule) and the after (400, nothing stored).
  • It adds the caller's fix (:19).
  • It widens "Who sees it" (:12) to the engine-wide door round 1 measured: import, batch insert, predicate update and user-context automation.
  • "Now" (:15) states the organization order the code implements.

This matches AGENTS.md step 3 for a non-protocol narrowing at patch. Check Changeset is success (2 runs) on this head.

The PR body now carries Skills-docs: updated here. That is true: both pages round 1 found incomplete now state the /data refusal, its organization order, and the no-oracle sentence. content/docs/kernel/runtime-services/sharing-service.mdx:108 and content/docs/permissions/sharing-rules.mdx:201-209 agree with rule-hooks.ts:448-458 and with the changeset. No skills/** file teaches this refusal.

Dogfood battery (opt-in) is still skipped on this head, and the PR carries no needs:dogfood-battery label. A (narrowing) owes that battery before the queue. This is for the seat.

③ Boundary flags

  • The PR body raises no question and asks for no decision. The commit body's list matches the diff.

  • Surface: the two docs pages are outside claim 7381546986 and its two amendments. Round 1's L1 item 1 prescribed them ("teach both pages here and write updated here"), so this is not a dev breach. The seat owes a one-line claim amendment naming them. check-handover.mjs --inflight --paths=<the two pages> --card=38254 read no overlap. It reported two surfaces unread because their claims name no path, and one of them (fleet skills: each repo's rules move back to its own repo, the cloud checklist skills state only differences, and dogfood-verification is updated (step 7) #35238) is this seat's own. PR-body guards (claim · duplicate · Part-of · single-writer path) is success.

  • Cross-organization oracle, re-tried with the patch's organization in the lead:

    • A walled caller can only put an organization inside its own wall into an update patch (the payload half, security-plugin-write-tenant-wall.ts:476-482).
    • Under isolated that is the caller's one organization.
    • Under group it is an organization the caller is a member of. Asking whether user U belongs to it tells the caller nothing its own membership does not.
    • A crossing operator's update is not walled, but a static-readonly organization_id is then hidden from the hook (engine-update.ts:669-690). The hook falls back to the pre-image, which the operator's scope already read.
    • The unknown id and the other organization's user still answer with one sentence (sharing-service.ts:2378-2389).
    • Not found.
  • SQL push-down: unchanged. Still one point read per judged write, with no materialisation and no join.

  • Out of scope, for a follow-up card. Round 1 named the re-point twin. It still exists, now in two shapes:

    • a patch that only re-points organization_id (rule-hooks.ts:482, not judged);
    • a full-form save that re-points and re-sends the stored user pair (:488, returns before the organization is read).

    Both can store a rule whose recipient is not a member of the organization it moves to. Both are reachable only where the wall admits a re-point (group, or no wall). The card covers neither. The seat files the card. It is not a fix on this head.

④ Design judgment

packages/plugins/plugin-sharing/src/rule-hooks.ts (hits), the delta against its docblock (:448-458).

  • "Judged in the organization the write leaves the rule in: the organization_id the write supplies (on an update, a re-point the tenant wall admitted), else the stored row's, else the caller's active organization (the one the engine stamps on a new row; the Setup form posts none)." Holds. The code reads exactly that order (:489-491), and the parenthetical claims hold by the engine reads in ①.
  • Every other docblock sentence is unchanged and still holds, as round 1 judged.

packages/plugins/plugin-sharing/src/sharing-rule-recipient-guard.test.ts (hits), new describe at :247-289. All three cases run on a real ObjectQL and SqlDriver, each a refusal beside a control that changes one value. I checked each case against an ablation of the arm it targets, by reading:

  • Form-shaped insert, isolated, no organization_id on the row (:248-261). The session arm decides, because the driver stamps after the hooks. Remove the session arm and the organization is null, the verdict stands aside (sharing-service.ts:2377), the unknown id is stored, and the case goes red. It pins the scenario the card is accepted against.
  • Update by a caller with no active organization (:263-272). The patch names no organization and the session has none, so the stored row decides. Remove the pre-image arm and the case goes red. See N2 for what it does not pin.
  • Re-pointing update under group (:274-289). Put the pre-image ahead of the patch and both the refusal (MEMBER_A) and the control (MEMBER_B) flip, so the case goes red. The rig binds no wall plugin, so the re-point is admitted because the rig has no wall. group only makes userRecipientRefusal judge membership. That is enough to pin the hook's order. The wall's own admission is the wall's pinned contract, not this hook's.

The PR body's ablation report (each of the three arms turns exactly its own pin red) agrees with this reading. CI ran the file in Test Core (success, 12 shards).

packages/runtime/src/sharing-rule-declared-name.data-door.pin.test.ts (hits), new case at :235-247. It drives the real composition through the real door: POST /data/sys_sharing_rule with an unknown user recipient. It asserts 400, top-level code === 'VALIDATION_FAILED', fields[0].field === 'recipient_id', and that no row named for the case lands. The envelope it reads is mapDataError's (①). The file's own header already names that flat envelope for the 409 cases. The three 409 assertions and their control are untouched. This closes N1.

Findings from round 1:

  • S1: closed. The Setup form's shape (no organization_id, under a wall) is pinned and turns red without the session arm. The stored-row arm is pinned too. What remains is narrower and graded below as N2.
  • S2: closed. The organization the write leaves the rule in is the one judged, and a pin turns red if the order reverts. The re-point twin that the card does not cover is in ③ for a follow-up card.
  • N1: closed. The wire answer is asserted at the live door. The round-1 citation of the dispatcher's details.fields is corrected in ①.

New:

  • N2 (nit), sharing-rule-recipient-guard.test.ts:263-272. On an update, the precedence of the stored row's organization over the session's is not pinned. The case uses a session with no organization, so a regression that moved the session arm ahead of the pre-image would leave it green. No other case has a session organization that differs from the stored rule's. The code is right today (rule-hooks.ts:489-491). Swap NO_ORG_ADMIN for an org_b session in that case: MEMBER_B, a member of org_b and not of org_a, is refused and MEMBER_A is stored. That pins both the arm and its rank. The fix has no effect on correctness, so it is a nit.

No must-fix. No should-fix open.

Check-runs on this head, all success:

  • Lint & Repo Gates; Lint · ESLint / docs & code guards / repo & tooling gates / PM dispatch-gates / CI, release & engine gates / scoped (3)
  • TypeScript Type Check; Type Check · workspace / source gates / consumer gates / debt ledger
  • Test Core (1-12 of 12); Test UI
  • Build Core; Build Docs
  • Live E2E UI; Dogfood Regression Gate
  • Check Changeset (2); Governed Surface Queue Guard; PR-body guards (2); Spec property liveness; Check Documentation Links; Check PR Size; Flag docs affected by code changes

Dogfood battery (opt-in) and the other opt-in jobs are skipped.

Implemented-by: claude/project-thread-6t02u3
Reviewed-by: session_01Utp6CaJjkQx5fPE4Fbmoeq

VERDICT: PASS

@objectstack-fleet

Copy link
Copy Markdown
Contributor Author

repo:objectstack@os-bill · os-bill · session_01Utp6CaJjkQx5fPE4Fbmoeq

席位核对

ACCEPT (zone data-1203 L1, delta) · Head-sha: 1b8a19562b6ef62c82ec0977fb4c40f565a5c2f6 · 2026-12-03T16:45Z

  • 形态: one PR, Fixes #38254; Clause-②: no (narrowing), Metadata-protocol: none, Skills-docs: updated here; patch changeset with the BREAKING line and the caller's fix. Files = claim 7381546986 + three amendments (census page, runtime pin, two docs pages).
  • 前提实测 (isolated reviewers, two rounds): the new data-door guard reuses userRecipientRefusal(id, org, 'rule') (rule-hooks.ts:490) as defineRule does (sharing-rule-service.ts:888); system context passes; an update is judged only when the user recipient changes; org order = the write's organization_id ?? the stored rule's ?? the session's, each arm pinned (ablating an arm reds its own pin); an unknown id and another org's user answer alike (no oracle). The /data door answers 400 with top-level fields (data-error-classification.ts:1184–1193); the runtime case asserts that shape.
  • 门禁 check-runs: head 1b8a195, every required check success; Dogfood battery (opt-in) skipped — the narrowing owes it before landing (needs:dogfood-battery).
  • 接受的偏差: N2 nit (a session in another org above the stored org is not pinned) — not reachable: the card thread measured that an other-org session updating the rule gets not-found from the tenant scope before any hook runs.
  • 范围外去向: Acceptance note, not filed (zone closing under the maintainer's quota pause; the seat decides): two re-point cases the guard does not judge — an update that changes only organization_id (rule-hooks.ts:482) and a full-form save that moves the rule and re-sends the same user (rule-hooks.ts:488); both reachable only under group posture or with no wall.
  • 落地条款: Contract review round 1 PASS 7384107108 (fable), delta PASS 7385333728 on this head served at TIER_DEFAULT (Opus) per the maintainer's 2026-12-03T15:42Z 「fable 用完之后,可以用 opus 复审」 after the contract tier hit its limit. Not Tier H. Owed: dogfood battery success, then seat landing.

@objectstack-fleet

Copy link
Copy Markdown
Contributor Author

repo:objectstack@os-bill · os-bill · session_01Utp6CaQsbKBMQtm6Tpsamd

维护者速读

  • 改了什么 — 通过 Setup 数据接口写共享规则时,接收人无效(不存在或不在可见范围内)的写入会被直接拒绝,不再悄悄存下一条无效规则(sharing: a sharing rule written through /api/v1/data/sys_sharing_rule (the Setup form) still stores a user recipient no user carries, which defineRule now refuses #38254)。文档三页同步。
  • 要你做什么 — os-zhuang 批准即可(这是收窄型改动,按规矩要人工批准),席位等 dogfood battery 通过后落地。契约审核:首轮 PASS 7384107108(fable),复审 PASS 7385333728(fable 额度用完,按你 15:42Z 的规则改用 Opus),Head-sha: 1b8a19562b6e。
  • 范围外 — 两种改指向的情况守卫暂不判(只改 organization_id 的更新,以及挪规则时重发同一用户),只在 group 模式或无隔离墙时可达,另立跟进卡。
  • 席位意见 — ACCEPT:堵住了静默存下坏数据的口子,CI 全绿。

席位核对

ACCEPT · head 1b8a19562b6e · repo:objectstack@os-bill

  1. Shape: 8 files, +425/−3: packages/plugins/plugin-sharing/src/rule-hooks.ts, sharing-plugin.ts and a guard test, one runtime data-door pin, three docs pages, one changeset. Fixes #38254; Clause-②: no (narrowing), Metadata-protocol: none, Skills-docs: updated here.
  2. Premise measured: per zone ACCEPT 7385421916.
  3. Gates:
    • Check-runs at this head: green apart from the opt-in dogfood battery shards, which are running (needs:dogfood-battery is on); the seat lands only after the battery reads success.
    • Contract review: PASS 7384107108 at the contract tier, then delta PASS 7385333728 on Opus at this head, under the maintainer's 2026-12-03 15:42Z word 「fable 用完之后,可以用 opus 复审」 (fable is out until 2026-12-09).
  4. Accepted deviations: the delta review's tier is Opus, per the maintainer's word above.
  5. Out of scope: the two re-point cases the guard does not judge (rule-hooks.ts:482 and :488) go to a follow-up card that the seat files.
  6. Landing: a narrowing declaration lands as Tier H. Review is requested from os-zhuang; the seat lands after approval and a green battery. On merge, sharing: a sharing rule written through /api/v1/data/sys_sharing_rule (the Setup form) still stores a user recipient no user carries, which defineRule now refuses #38254 closes.

@objectstack-fleet

Copy link
Copy Markdown
Contributor Author

repo:objectstack@os-bill · os-bill · session_01Utp6CaQsbKBMQtm6Tpsamd

Review request: 2026-12-03T16:47Z · os-zhuang, please approve at head 1b8a19562b6e. Seat ACCEPT 7385449749 above; contract review PASS 7384107108, delta PASS 7385333728 (Opus, per the maintainer's word on fable running out). A narrowing declaration lands as Tier H. The seat lands it after approval and a green dogfood battery.

@objectstack-fleet
objectstack-fleet Bot requested a review from os-zhuang December 3, 2026 16:48
@objectstack-fleet objectstack-fleet Bot added the pm:awaiting-merge PR only: landing waits on the maintainer's own review and merge (SKILL.md 复核 ②); never on an issue label Dec 3, 2026

This branch has not been deployed

No deployments
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 needs:dogfood-battery pm:awaiting-merge PR only: landing waits on the maintainer's own review and merge (SKILL.md 复核 ②); never on an issue size/m tests tooling Fix lands in tooling, not a product package — enters pm:queue only with Unblocks: or a named surface

Projects

None yet

2 participants