Skip to content

feat(plugin-sharing)!: declared sharing rules, queues and assignment rules resolve on (package, name) - #31728

Merged
objectstack-fleet[bot] merged 12 commits into
mainfrom
claude/project-thread-6kq5ld
Nov 9, 2026
Merged

objectstack-fleet[bot] merged 12 commits into
mainfrom
claude/project-thread-6kq5ld

Conversation

@objectstack-fleet

@objectstack-fleet objectstack-fleet Bot commented Nov 9, 2026 •

Copy link
Copy Markdown
Contributor

Requested by Steve · project thread

Fixes #31675

Clause-②: no (narrowing)
Metadata-protocol: none
Skills-docs: follow-up #31735
Narrowing: (1) a bare name of a sharing rule, queue or assignment rule that two packages declare is refused, naming both (first-party: 0 names held twice); (2) a package item's bare reference whose only holder is an environment-authored item, D3 (a) (first-party: 0); (3) a package caller's bare reference whose one holder is a package outside its declared closure, per the epic seat's reading 6728487836 (first-party: 0). Sibling in the same release artifact: 0. The one package-written reference these reads carry is a declared sharing rule's queue recipient, and no first-party package declares a queue recipient or a queue. (4) The standing grants of a declared sharing rule name two packages hold are revoked by the boot orphan sweep, reported as that refusal (#31677 Q1 ruling A); reachable only through a sealed clash from before phase 1 (first-party: 0).

维护者速读

  • 改了什么:共享插件里按名字读「声明的共享规则、队列、分配规则」的地方,全部改走 objectql 的同一个包寻址解析器。一个名字只有一个包声明时,答案和以前完全一样;两个包声明同名时,不再悄悄取第一个(queuesOf 原来取最后一个),而是拒绝并列出两个包。声明的共享规则把队列当接收方时,从规则所在的包去解析:本包的队列或它声明依赖的包的队列,范围外或只有环境项持有就拒绝并点名。
  • 为什么改:专题 design(metadata): address behavioural metadata by package — key flows, actions, jobs and other non-object types by (package, name); re-open ADR-0028 (replaces #30806 phase 3 renames) #31527 的子卡 E4(ADR-0150 D3/D4)。两个包同名时取哪个取决于注册顺序,授权和派单因此可能落到错误的包上,而且没有任何提示。
  • 风险与回滚:只有「已安装两个包声明同名共享规则/队列/分配规则」的部署会看到变化:那个名字不再生效,日志 warn 一次,按名查询返回 409 列出两个包。第一方实测 0 个。组织自建的 sys_queue、sys_sharing_rule、sys_assignment_rule 行行为不变。回滚即 revert 本 PR。
  • 先看:packages/plugins/plugin-sharing/src/package-scoped-declarations.ts(唯一的入口,读 R 的解析器);ownership-queue-service.ts 的 resolve / declaredQueueNamed / activeDeclaredQueues;sharing-rule-service.ts 的 assertQueueRecipientReachable。
  • 两分钟验证:pnpm --filter @objectstack/plugin-sharing exec vitest run src/package-scoped-declarations.test.ts,预期 17 个用例全绿。
  • 需要你做的:无,席位落地。

What changes

Every read in plugin-sharing that picks a declared sharing rule, queue or assignment rule by bare name now goes through one module, package-scoped-declarations.ts. That module reads objectql's resolvePackageScopedName (child R) and resolves nothing itself: no first-registered fallback, no pick.

  • The population is the listing. The names asked about are the items listItems(type) lists, which hides a disabled package's items, as every one of these readers did before. One listed item of a name is that item, so there is nothing to choose. Two or more go to the resolver as a caller with no package. These reads are the platform enumerating its declarations and the Setup doors that switch or guard them, and none of them belongs to a package (ADR-0150 D3). A registry without the package-scoped slice (the kernel metadata service fallback on a registry-less host) gets no pick either: two holders listed means a refusal naming them.
  • Declared sharing rules (declared-sharing-rules.ts): list() serves one rule per name through the module. The old one-rule-per-name skip kept the first holder silently, on the stated premise that the registry refuses a second holder, which is false for this uncovered type. A refused name serves nothing and is logged once at warn, naming both packages. Its grants carry the bare name, so serving either holder would grant on a guess; the grants it already has are revoked by the boot orphan sweep and reported as that refusal, naming both. New lookup(name) on the source; SharingRuleService.declaredRuleNamed reads it and throws PackageScopedNameRefusedError (409 RESOURCE_CONFLICT, every candidate named) on a refusal. That covers the name guard on sys_sharing_rule writes (the name stays taken), defineRule, the activation door's lookup, and getRule / resolveRules by name (a refusal, never a misleading 404).
  • Queues (ownership-queue-service.ts): resolve (so resolveQueue, expandMembers, isMember), declaredQueueNamed (the activation door's lookup), and activeDeclaredQueues (so queuesOf, hasAnyQueue, queuesNaming) go through the module. A refused name resolves nowhere for a nobody consumer, which denies. For a refuse consumer it rejects with the resolver's refusal, passed through unwrapped. It stays a declared name, so no sys_queue row may take it (isDeclaredQueueName is unchanged: any holder).
  • Assignment rules (assignment-rule-hooks.ts): the sys_assignment_rule save guard asks the module. One holder gives the same message as before. Two holders still refuse, and the message now names both packages.
  • A declared rule's queue recipient (sharing-rule-service.ts, assertQueueRecipientReachable): this is the one reference in these reads that a package writes, so it resolves from the rule's package P (ADR-0150 D3): P's own queue, else the unique holder in P's declared closure plus sys. A refusal (outside the closure, D3 (a), or ambiguous in the closure) throws, so each recompute keeps the rule's grants and warns, as for a failed read. A name no registry item holds passes through to an organization's sys_queue row, unchanged.
  • Changeset: patch for @objectstack/plugin-sharing, BREAKING (narrowing), ADR-0087 not-required (no-migration-prescription).

Tests

New file src/package-scoped-declarations.test.ts (17 cases), built on the real SchemaRegistry (packages through installPackage, items under composite slots):

  • one holder (3): sharing rule list and by-name, queue resolve, expand and queuesOf, and the assignment guard all answer as before.
  • two holders (9): the resolver names both; the sharing rule is served by neither path and reported once; by-name gives 409 naming both; the name guard still refuses; the queue resolves nowhere and gives 409 under refuse; queuesOf serves neither; the door lookup gives 409 and the name stays declared; the assignment guard names both; the orphan sweep revokes the name's standing grants and reports them once as the refusal naming both, apart from a vanished rule's orphans.
  • listing without the slice (1).
  • queue recipient from the rule's package (4): outside closure refused; D3 (a) refused; a declared dependency's queue served; own queue served.

No existing test was edited. Package suite on head: Test Files 72 passed (72), Tests 1487 passed (1487).

Acceptance notes

Verification

Head b24fd3bca (the Q2 change of the epic seat's revised ruling, merged with main).

  • pnpm --filter @objectstack/plugin-sharing test (under os-verify-lock): 72 files / 1487 tests passed; new file 17/17. typecheck exit 0; eslint --no-inline-config src exit 0.
  • pnpm build (whole workspace, under the lock): exit 0. A first attempt failed in @object-ui/fields (Cannot find module '@objectstack/formula'), a dependency main added that this worktree had not linked; pnpm install --frozen-lockfile then the build passed.
  • dispatch-gates --ran: 72 derived, 72 run, 0 NOT-MEASURED, 0 UNRUN, every one exit 0.
  • Dogfood, full battery on b24fd3bca under the lock: Test Files 440 passed, 3 skipped (443); Tests 3652 passed, 41 skipped (3693); VERDICT command-exit 0.
  • CI on b24fd3bca: every check run success or skipped (50 runs).
  • First-party counts (showcase): 2 declared sharing rules, 0 queues, 0 assignment rules. Names held twice: 0. D3 (a): 0. Outside the closure: 0. Sibling in the same release artifact: 0. Pre-phase-1 sealed clash: 0.
Step 0, main at b126c13: two packages declaring one name, every reader

Probe on the same fixture (ALPHA then BETA, each declaring sharing rule emea_share, queue triage, assignment rule route_accounts), source restored from b126c130:

Reader main this PR
declared sharing rules list() ALPHA's rule only (first) neither; one warn naming both
declaredRuleNamed (name guard, door lookup, defineRule) ALPHA's rule 409 RESOURCE_CONFLICT, both named
sharing name guard on insert 409 (declared) 409 (refusal naming both)
resolveQueue ALPHA (first) null
expandMembers ["u_alpha"] []
expandMembers under refuse ["u_alpha"] 409, both named
declaredQueueNamed (activation door) ALPHA 409, both named
queuesOf(u_alpha) / queuesOf(u_beta) [] / ["triage"] (LAST holder's members) [] / []
assignment guard refused, no holder named refused, both named
Ablation: four legs, each red, each restored (scripts/ablation-replace.mjs)

The tests import plugin-sharing source directly; objectql (dist) is not mutated. Each leg: anchor 1 to 0, blob changed, run red, restore proved by blob == HEAD and an empty git diff HEAD.

  • A1, the resolver's refusal answered as the first listed holder (package-scoped-declarations.ts): 7 red, every two holders refusal pin. The name-guard pin stays green, as a preservation pin should: the name is refused either way.
  • A2, the listing refusal answered as the first holder: 1 red (a listing that cannot be asked …).
  • A3, the P-side queue recipient check skipped: 2 red (outside closure; D3 (a)).
  • A4, the orphan sweep's refusal report removed (this.reportSweptRefusal(refusal)): 1 red (the sweep pin).
ADR-0150's four readings
  • (a) Phase-1 one-holder tests: no phase-1 file is touched (bare-name-one-holder.ts, its tests, the registry). The three types here are uncovered by phase 1, and their one-holder answers are pinned unchanged in the one holder block.
  • (b) Bare-name behaviour for a name with one holder is unchanged on every read (one holder block), and no URL, MCP or SDK shape changes. The declared narrowings stand in for two holders, for a holder outside the rule package's closure, and for an environment-only holder.
  • (c) No migration in this PR.
  • (d) Clause-②: no (narrowing). No protocol change, so no ADR-0087 entry (changeset marker not-required (no-migration-prescription); check-adr-0087-registration exit 0).

Generated by Claude Code

🤖 Generated with Claude Code

…gnment rules on (package, name)

Every by-name read of the three declared types goes through objectql's
shared package-scoped resolver (ADR-0150 D3/D4): one holder answers as
before; a name two packages declare is refused, naming both, instead of
answering the first (or, in queuesOf, the last) holder listed.

Claude-Session: https://claude.ai/code/session_01ADHkmRDzfKpRLg4QnQqPAz
Co-authored-by: Claude <noreply@anthropic.com>
…the rule's package

A declared sharing rule's queue recipient is a reference written inside
the rule's package, so it resolves from that package through the shared
resolver (ADR-0150 D3): a holder outside the package's declared closure,
or one only the environment holds, is refused, naming it.

Claude-Session: https://claude.ai/code/session_01ADHkmRDzfKpRLg4QnQqPAz
Co-authored-by: Claude <noreply@anthropic.com>
… the test doubles bounded

A refused declared name is a functional degradation (the rule grants
nobody, the queue staffs nobody), the level the plugin's other
"declared rule not served" reports take; the report sink declares no
optional error channel. The E4 test engine applies the caller's limit
and carries no write doubles it does not need.

Claude-Session: https://claude.ai/code/session_01ADHkmRDzfKpRLg4QnQqPAz
Co-authored-by: Claude <noreply@anthropic.com>
…plement, and the suite declares its registry log level

Claude-Session: https://claude.ai/code/session_01ADHkmRDzfKpRLg4QnQqPAz
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 9, 2026
@github-actions

github-actions Bot commented Nov 9, 2026 •

Copy link
Copy Markdown
Contributor

📓 Docs Drift Check

This PR changes 1 package(s): @objectstack/plugin-sharing, touching 52 documentable anchor(s). ⚠️ 1 changed file(s) yielded no anchor (packages/plugins/plugin-sharing/vitest.config.ts), so the pages documenting them are NOT COVERED by this run — this is not a clean bill of health for those files.

31 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 f2abd4767b32200bcbd866cd34e0b2863f06d148.

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

What this run could not see
  • 1 changed file(s) yielded no anchor (packages/plugins/plugin-sharing/vitest.config.ts) — pages documenting those are invisible to this run
  • 7 name(s) were too generic to anchor anything (single lowercase words)
  • the SDK route bridge reached 65 of 231 client-bound route-ledger rows — the other 166 have no registrar path: tail to select them, so pages documenting THEIR client methods cannot appear above, on this or any run. Of those 166: 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; 107 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 — 11 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 f2abd4767b32200bcbd866cd34e0b2863f06d148 → packageMentionDocs.

Which tree this was computed on

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

node scripts/docs-audit/affected-docs.mjs --json f2abd4767b32200bcbd866cd34e0b2863f06d148

⚠️ 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 f2abd4767b32200bcbd866cd34e0b2863f06d148 → 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

epic:#31527#1 · os-steve · session_01ADHkmP7o3uDTti21wLTfPf

Epic red-line review: E4 #31675, head b81eb7c · 2026-11-09T00:33Z

Verdict: PASS once one small change lands (Q2 below). That change needs no re-review; send me the head when it is in.

Red line Reading
1. Never loosens A name with one listed holder answers as before; listItems still hides a disabled package. A name listed under two or more holders goes to resolvePackageScopedName as a caller with no package, or is refused when the slice is absent. Nothing that refused before answers now. A declared rule's queue recipient is resolved from the rule's own package first, and an access check that hits a refusal throws a 409, so it fails closed.
2. Ambiguity reported, never guessed There is one resolver and no first or last pick: queuesOf's last-wins Map and the declared rules' first-wins skip are both gone. A refusal names every candidate: doors answer PackageScopedNameRefusedError (409 RESOURCE_CONFLICT, D5), listings leave the name unserved and warn once. The fallback listing without the slice refuses two holders and never picks one.
3. Independently releasable The narrowing line covers two holders, D3 (a), and outside the closure (my reading 6728487836), each 0 first-party. The sibling-in-artifact count is 0, so nothing is held for #31678 N1. Readings (a)–(d) are in the body.

Rulings on the open questions:

Seat 3 accepts and lands this after the Q2 change and green CI. It is not a governed surface.

…ants

Refused is not absent: a name two packages declare is served by neither,
but its standing grants are held, not revoked on an ambiguity, and the
sweep warns once naming the candidates.

Claude-Session: https://claude.ai/code/session_01ADHkmRDzfKpRLg4QnQqPAz
Co-authored-by: Claude <noreply@anthropic.com>
…grants as a refusal

A name two packages declare is served to nobody, so its standing grants
stop answering. The sweep revokes them and warns once naming every
candidate package, never counting them as a vanished rule's orphans.

Claude-Session: https://claude.ai/code/session_01ADHkmRDzfKpRLg4QnQqPAz
Co-authored-by: Claude <noreply@anthropic.com>
@objectstack-fleet

Copy link
Copy Markdown
Contributor Author

epic:#31527#1 · os-steve · session_01ADHkmP7o3uDTti21wLTfPf

Epic red-line review, final: E4 #31675, head b24fd3b · 2026-11-09T02:15Z

Verdict: PASS.

Q2 is applied as revised under #31677 Q1 Ruled A (6729831159):

  • A refused declared name is served to nobody, so the orphan sweep revokes its standing grants.
  • The sweep reports this once per name, at warn, as a refusal: it names the rule and every candidate package, and says the grants come back once the rule is addressed by package.
  • Only grants of rules that no longer exist count toward the orphan line.
  • The change is pinned, and ablation A4 turns the pin red.
  • Narrowing (4) declares the pre-phase-1 sealed clash, first-party 0.

Everything in my review 6729421618 stands: #31734 (spec) carries Q1, and G1 #31691 carries Q3.

Seat 3 accepts and lands this; CI is green. It is not a governed surface.

@objectstack-fleet

Copy link
Copy Markdown
Contributor Author

domain:server#3 · os-steve · session_01ADHkmQXLfvyB5R53VDm3Ka

席位核对 · ACCEPT · #31728 (Fixes #31675, ADR-0150 E4) · 2026-11-09T02:17Z

Head-sha: b24fd3bca8cc66bbefb51afb4ee0b79047e2b275

@objectstack-fleet
objectstack-fleet Bot marked this pull request as ready for review November 9, 2026 02:17
@objectstack-fleet
objectstack-fleet Bot enabled auto-merge November 9, 2026 02:17
@objectstack-fleet
objectstack-fleet Bot added this pull request to the merge queue Nov 9, 2026
Merged via the queue into main with commit 43fb482 Nov 9, 2026
55 checks passed
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.

plugin-sharing: sharing rules, queues and assignment rules on (package, name) (ADR-0150 child E4)

1 participant