Repository navigation
Commit fdfcc7a
feat(spec, plugin-sharing): ownership-queue reads take the caller package, so a declared rule's queue recipient resolves by ADR-0150 D3 (#31789)
<!-- claude-projects-attribution: {"github_login":"os-steve"} -->
_Requested by **Steve** · [project
thread](https://claude.ai/code/project/chan_01FdL1XeUyvVNxLreh3F4Qi9?thread=cmsg_01FdL1XeUyvVNxLreh3F4Qi9TtV9zn69iQ2y6yezQxLz2i)_
Fixes #31734
Clause-②: yes (widening); narrowing per ADR-0150 D3 declared below
Metadata-protocol: none
Narrowing (ADR-0150 D3): a declared sharing rule whose package P depends
on a disabled package D, where an unrelated package U declares a queue
of the same name. Before (main `43fb4822`): the rule granted to U's
queue members, silently. After: the recipient is refused,
`outside-closure`, naming U, logged once at `warn` (D3 never reaches U,
and a disabled package holds nothing for this read); U's members gain no
grant, grants the rule already holds are kept, as for any refused
recipient. Pin: `refuses when the holder the caller reaches is disabled,
naming the unrelated holder as outside the closure — never serving it,
never silent` (ablations A4–A6). First-party: 0 (no first-party package
declares a queue). Seat 3 ruled it the D3 answer.
## 维护者速读
-
改了什么:所有权队列服务契约(`IOwnershipQueueService`)的三个按队列名读取的方法(`resolveQueue`、`expandMembers`、`isMember`)加了一个可选的「调用方软件包」参数。共享插件在读「声明的共享规则」的队列接收方时,把规则所在的包传进去,队列就从这个包出发解析:本包的队列,否则它声明依赖的包里唯一持有者,否则拒绝并列出全部候选。不传参数时与今天完全一样。
- 为什么改:E4(#31728)落地时契约里没有调用方,只能整环境解析,所以「规则的依赖包和一个无关包都有同名队列」会被拒绝。这比
ADR-0150 D3 更严。本卡把这半补上(专题 #31527)。
- 风险与回滚:只影响「两个已安装的包声明了同名队列,且某个包里的共享规则把它当接收方」的部署。第一方实测 0
个包声明队列。另有一个边角情形(规则依赖的那个包被禁用、无关包有同名队列):以前悄悄发给了无关包的成员,现在拒绝,日志 warn
一次,点名那个无关包。回滚即 revert 本 PR。
-
先看:`packages/plugins/plugin-sharing/src/package-scoped-declarations.ts`
的 `resolveDeclaredName`(调用方分支);`sharing-rule-service.ts` 的
`queueRecipientCaller`;`packages/spec/src/contracts/ownership-queue-service.ts`
的新可选键。
- 两分钟验证:`pnpm --filter @objectstack/plugin-sharing exec vitest run
src/package-scoped-declarations.test.ts`,预期 23 个用例全绿(新增 6 个)。
- 需要你做的:无,席位落地。
## What changes
- **Contract (`@objectstack/spec/contracts`).** `resolveQueue`,
`expandMembers` and `isMember` take an optional `callerPackageId` (new
exported type `OwnershipQueueCallerPackage` = `string | null`). With a
package id the name resolves from that package (ADR-0150 D3). Omitted,
`null` or `''`, the read is environment-wide, as before. `queuesOf` and
`hasAnyQueue` name no queue and take none. `declaredQueueNamed` (the
activation door's lookup) is unchanged: the door belongs to no package.
An implementation written before the key still satisfies the contract
(pinned).
- **Resolution (`package-scoped-declarations.ts`).**
`resolveDeclaredName` takes an optional caller package. With one and a
registry that carries the package-scoped slice, the answer is objectql's
`resolvePackageScopedName` from that package, final: no one-listed-item
shortcut (the one listed item may be outside the package's reach), and
no first-registered fallback. The listing still bounds it: the resolver
is asked over `listedHoldersView(registry)`, which leaves out a holder
whose package is disabled (the filter `listItems` applies) and changes
nothing else. So a package whose one reachable holder is disabled gets
the resolver's own `outside-closure` refusal naming every holder still
served, never the disabled holder's item and never silence. Without a
caller package nothing changes.
- **Queue service (`ownership-queue-service.ts`).** The three reads pass
`callerPackageId` to that resolution. Refusals answer as E4's do: `null`
/ `[]` / `false`, or under `onFailedRead: 'refuse'` a
`PackageScopedNameRefusedError` (`409 RESOURCE_CONFLICT`, every
candidate named), reported once per name and caller.
- **Rule service (`sharing-rule-service.ts`).**
`assertQueueRecipientReachable` becomes `queueRecipientCaller`: the same
P-side check (now over the same `listedHoldersView`), which still throws
and reports its refusal first, and then it hands the rule's package to
`isMember` / `expandMembers`. The check stays ahead of the read on
purpose, so a queue service written before the key (environment-wide)
can never serve a holder outside P's reach. New
`queueRecipientPackageOf(rule)` answers the rule's package for a
look-through that grants nothing.
- **BU look-through (`sharing-plugin.ts`).** "Does this queue recipient
read the BU tree?" now resolves the rule's queue from the rule's
package, so it reads the queue the grants are read from.
- **Position look-through (`queuesNaming`).** It reads every declared
holder's specifications, not only the names an environment-wide read
serves. Without this, a rule served by D's `q` (a name U also declares)
would not be re-evaluated when a position moves in D's queue, and its
grants would go stale. Including a name more often only re-evaluates a
rule, which then answers as before.
- Changeset: patch for `@objectstack/spec` and
`@objectstack/plugin-sharing`, with both declaration lines.
## Step 0: every implementer and caller of the contract
Measured at `43fb4822` (main with E4).
| Site | Method | Caller package after this PR |
|:--|:--|:--|
| plugin-sharing `OwnershipQueueService` (the one registered
implementation) | implements all | reads it |
| spec `ownership-queue-failed-read.pin.test.ts` `legacy` double |
implements, no key | compiles unchanged (pinned) |
| plugin-sharing `sharing-rule-service.ts` (rule recompute, per-user
pass) | `expandMembers`, `isMember` | **the declared rule's package** |
| plugin-sharing `sharing-plugin.ts` (BU-tree look-through) |
`resolveQueue` | **the declared rule's package** |
| plugin-sharing `sharing-service.ts` (sitting-record access path) |
`queuesOf`, `isMember` | none (no package asks) |
| plugin-security `authz-middleware`, `explain-access` | `isMember` |
none |
| plugin-security `ownership-queue-gate.ts`,
`kernel-queue-membership.ts` | `resolveQueue`, `queuesOf` | none |
| plugin-hono-server `current-user-endpoints.ts` | `hasAnyQueue` | none
(takes no name) |
| runtime `catalog-activation.ts` (activation door) |
`declaredQueueNamed` | none (unchanged method) |
| objectql `assignment-rules.ts` (assignment pool) | `resolveQueue`,
`expandMembers` | none: see Acceptance notes |
| plugin-approvals `approval-service.ts` (approver slate) |
`expandMembers` | none: see Acceptance notes |
Every caller that passes no key compiles and answers as before. Test
doubles in objectql, plugin-approvals and plugin-security are untouched.
## Tests
New top-level `describe` in the E4 harness
`src/package-scoped-declarations.test.ts` (6 cases, real
`SchemaRegistry`):
- P = ALPHA depends on D = BETA; U = GAMMA is unrelated; BETA and GAMMA
each declare queue `support`. From ALPHA, `resolveQueue` answers BETA's
queue, `expandMembers` answers `['u_beta']` (also under `refuse`),
`isMember` is `true` for `u_beta` and `false` for `u_gamma`. **Red on
main.**
- The declared rule in ALPHA naming `support`: the standing grant to
`u_beta` is still desired (`revokeRuleGrantsForRetiredRecipients`
returns `0`). **Red on main** (main throws the two-holder refusal).
- ALPHA depends on BETA and GAMMA, both declare `support`: refused,
`ambiguous-in-closure`, candidates BETA and GAMMA, `409
RESOURCE_CONFLICT` under `refuse`, nothing under `nobody`.
- No caller package (`undefined`, `null`, `''`), same fixture as the
first case: refused environment-wide naming BETA and GAMMA, exactly as
main.
- BETA disabled: from ALPHA `resolveQueue` is `null` and `expandMembers`
`[]`; under `refuse` a `409` `outside-closure` refusal naming GAMMA; the
queue service warns once naming GAMMA; the declared rule's recompute
throws the same refusal and the rule service warns naming GAMMA. **Red
on main** (main serves GAMMA's members, silently).
- `queuesNaming('position', …)` finds `support` from either holder's
position. **Red on main.**
Forced test change:
`packages/spec/src/contracts/ownership-queue-failed-read.pin.test.ts`
pinned the exact option keys (`_ExpandOptionKeys`,
`_IsMemberOptionKeys`); both now include `callerPackageId`. The file
gains a second `describe` with the new key's type pins. No other
existing test was edited.
## Acceptance notes
- **Claim's "only the D-and-U case moves".** Measured by running the new
block against main's plugin source (`git restore --source=43fb4822` on
the four source files, then restored, `git diff HEAD` empty): 5 of the 6
new cases are red on main, 18 of 23 in the file green. The D-and-U case
moves from refused to resolved, as the card asks. Two other cases also
move, and both are declared here for the seat:
- **A disabled dependency.** P depends on D, D is disabled, U holds the
same queue name. Main serves U's queue to P's rule, silently (the P-side
check passes through D, then the environment-wide listing sees only U).
This PR refuses it, naming U as outside P's closure, and reports it.
That is a narrowing of a wrong answer, first-party count 0 (no
first-party package declares a queue). Seat 3 accepted it as the D3
answer; the epic seat asked that it be reported, naming U; declared on
the `Narrowing` line above and in the changeset.
- **The position look-through.** It now includes names two packages
declare. A rule naming such a name re-evaluates on a position write; for
a rule with no package that re-evaluation answers the refusal it already
answers on every other recompute (its grants are kept and it warns), so
the visible difference is that warning on one more path.
- The two-holders-in-closure case refuses on both trees; only the
refusal's vocabulary moves (`ambiguous-in-environment` with no caller on
main, `ambiguous-in-closure` naming ALPHA here). Same candidates, same
`409`.
- **Other package-written queue references.** A declared assignment
rule's queue (objectql `assignment-rules.ts`) and an approval step's
queue (plugin-approvals) are also written inside a package and still
read environment-wide. That is stricter than D3, never looser, the same
interim E4 accepted for this card. Outside this card's file surface;
carrier: epic #31527 seat.
- **New public name** `OwnershipQueueCallerPackage` and the option key
`callerPackageId` (the resolver's own `PackageScopedQuery` key). The
seat's call.
## Verification
Head `f9c4e48b`. Source last changed at `d1d77686` (the listed-holders
view and the disabled-dependency refusal); `f9c4e48b` only rewords the
changeset, and `check-adr-0087-registration`,
`check-changeset-no-major`, `check-empty-changeset`,
`check:issue-citations`, `check:nul-bytes` and `check:doc-authoring`
re-ran exit 0 on it.
- On `d1d77686`: `pnpm --filter @objectstack/plugin-sharing test` (under
the lock): Test Files 72 passed (72), Tests 1493 passed (1493). New
block 6/6; harness file 23/23. `typecheck` exit 0. Root `eslint
--no-inline-config packages/plugins/plugin-sharing/src` exit 0;
`packages/spec/src/contracts` exit 0 (on `20a19d69`, unchanged since).
- `@objectstack/spec`: `typecheck` exit 0; `check:test-typecheck` OK (52
files / 240 errors / 131 signatures held, unchanged); contract pin file
2/2; `check:generated` after `--fix`: `api-surface` and `export-origins`
regenerated (`+OwnershipQueueCallerPackage`, 1 added, 0 breaking).
- Contract consumers (a spec contract changed): `typecheck` exit 0 for
`@objectstack/objectql`, `plugin-approvals`, `plugin-security`,
`plugin-hono-server` and `runtime`; their queue suites green: objectql
`ownership-queue.test.ts` 41/41, plugin-security
`kernel-queue-membership` + `ownership-queue-gate` 46/46,
plugin-approvals `approval-service.test.ts` 463/463.
- `dispatch-gates --ran` on `d1d77686` (re-derived; a full `turbo run
build --filter=./packages/**` ran first on `20a19d69`, lock VERDICT exit
0): 94 derived, 94 run, 0 NOT-MEASURED, 0 UNRUN, every one exit 0. Also
94/94 exit 0 on `20a19d69`.
- Dogfood, full battery on `20a19d69` under the lock (not owed: no `!`
and no narrowing arm): Test Files 440 passed, 3 skipped (443); Tests
3652 passed, 41 skipped (3693); VERDICT command-exit 0. Not re-run on
`d1d77686`: the only behaviour that moved since is the
disabled-dependency refusal, which no first-party package can reach (0
queues declared).
<details><summary>Ablations: five legs, each red, each restored
(scripts/ablation-replace.mjs)</summary>
plugin-sharing tests import its source directly; no dist leg. Each leg:
anchor 1 to 0, blob changed, run red, restored with blob == HEAD and
`git diff HEAD` empty.
- A1, the caller-package refusal answered as the first listed holder
(`resolveDeclaredName`): 1 red, `refuses when the caller's closure
reaches two holders, naming both`.
- (A2, run on `20a19d69` against the earlier silent not-found, is
superseded: that code is gone.)
- A3, the no-caller refusal answered as the first listed holder: 9 red,
the 8 E4 `two holders` pins and `reads environment-wide without a caller
package …`.
- On `d1d77686`, for the epic seat's condition (the disabled-dependency
refusal is reported, naming U):
- A4, the caller-package refusal silenced (answered `not-found`): 2 red,
`refuses when the caller's closure reaches two holders …` and `refuses
when the holder the caller reaches is disabled, naming the unrelated
holder …`.
- A5, `listedHoldersView` unfiltered (a disabled holder counted): 1 red,
the disabled-dependency pin (the disabled holder's queue served).
- A6, the rule service's own check over the raw registry instead of the
view: 1 red, the same pin (its warning naming GAMMA missing). That is
the guard that holds for a queue service written before the key.
</details>
🤖 Generated with [Claude Code](https://claude.com/claude-code)
<!-- signed: domain:server#3 · os-steve ·
session_01ADHkmQs1r4citFGcqUhPZE -->
---------
Co-authored-by: Claude <noreply@anthropic.com>1 parent 6be71ab commit fdfcc7a
10 files changed
Lines changed: 479 additions & 44 deletions
File tree
- .changeset
- packages
- plugins/plugin-sharing/src
- spec
- api-surface
- export-origins
- src/contracts
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
| 1 | + | |
| 2 | + | |
| 3 | + | |
| 4 | + | |
| 5 | + | |
| 6 | + | |
| 7 | + | |
| 8 | + | |
| 9 | + | |
| 10 | + | |
| 11 | + | |
| 12 | + | |
| 13 | + | |
| 14 | + | |
| 15 | + | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
30 | 30 | | |
31 | 31 | | |
32 | 32 | | |
| 33 | + | |
| 34 | + | |
| 35 | + | |
| 36 | + | |
| 37 | + | |
| 38 | + | |
| 39 | + | |
| 40 | + | |
33 | 41 | | |
34 | 42 | | |
35 | 43 | | |
| |||
85 | 93 | | |
86 | 94 | | |
87 | 95 | | |
| 96 | + | |
88 | 97 | | |
89 | 98 | | |
90 | 99 | | |
| |||
239 | 248 | | |
240 | 249 | | |
241 | 250 | | |
242 | | - | |
243 | | - | |
| 251 | + | |
| 252 | + | |
| 253 | + | |
| 254 | + | |
| 255 | + | |
| 256 | + | |
244 | 257 | | |
245 | 258 | | |
246 | 259 | | |
247 | 260 | | |
248 | 261 | | |
249 | 262 | | |
250 | | - | |
| 263 | + | |
| 264 | + | |
251 | 265 | | |
252 | | - | |
| 266 | + | |
| 267 | + | |
| 268 | + | |
| 269 | + | |
| 270 | + | |
| 271 | + | |
253 | 272 | | |
254 | 273 | | |
255 | | - | |
| 274 | + | |
256 | 275 | | |
257 | | - | |
258 | | - | |
259 | | - | |
260 | | - | |
| 276 | + | |
| 277 | + | |
| 278 | + | |
| 279 | + | |
| 280 | + | |
261 | 281 | | |
262 | 282 | | |
263 | 283 | | |
| |||
293 | 313 | | |
294 | 314 | | |
295 | 315 | | |
296 | | - | |
| 316 | + | |
| 317 | + | |
| 318 | + | |
| 319 | + | |
| 320 | + | |
297 | 321 | | |
298 | 322 | | |
299 | 323 | | |
300 | | - | |
| 324 | + | |
301 | 325 | | |
302 | 326 | | |
303 | 327 | | |
| |||
312 | 336 | | |
313 | 337 | | |
314 | 338 | | |
315 | | - | |
| 339 | + | |
316 | 340 | | |
317 | 341 | | |
318 | 342 | | |
319 | 343 | | |
320 | | - | |
| 344 | + | |
321 | 345 | | |
322 | 346 | | |
323 | 347 | | |
| |||
390 | 414 | | |
391 | 415 | | |
392 | 416 | | |
393 | | - | |
394 | | - | |
| 417 | + | |
| 418 | + | |
| 419 | + | |
| 420 | + | |
395 | 421 | | |
396 | | - | |
397 | | - | |
| 422 | + | |
| 423 | + | |
398 | 424 | | |
399 | 425 | | |
400 | 426 | | |
| |||
414 | 440 | | |
415 | 441 | | |
416 | 442 | | |
| 443 | + | |
| 444 | + | |
| 445 | + | |
| 446 | + | |
| 447 | + | |
| 448 | + | |
| 449 | + | |
417 | 450 | | |
418 | 451 | | |
419 | 452 | | |
420 | 453 | | |
421 | 454 | | |
422 | 455 | | |
423 | | - | |
| 456 | + | |
424 | 457 | | |
425 | 458 | | |
426 | 459 | | |
| |||
605 | 638 | | |
606 | 639 | | |
607 | 640 | | |
| 641 | + | |
| 642 | + | |
| 643 | + | |
| 644 | + | |
| 645 | + | |
| 646 | + | |
| 647 | + | |
| 648 | + | |
| 649 | + | |
| 650 | + | |
| 651 | + | |
| 652 | + | |
608 | 653 | | |
609 | 654 | | |
610 | 655 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
357 | 357 | | |
358 | 358 | | |
359 | 359 | | |
| 360 | + | |
| 361 | + | |
| 362 | + | |
| 363 | + | |
| 364 | + | |
| 365 | + | |
| 366 | + | |
| 367 | + | |
| 368 | + | |
| 369 | + | |
| 370 | + | |
| 371 | + | |
| 372 | + | |
| 373 | + | |
| 374 | + | |
| 375 | + | |
| 376 | + | |
| 377 | + | |
| 378 | + | |
| 379 | + | |
| 380 | + | |
| 381 | + | |
| 382 | + | |
| 383 | + | |
| 384 | + | |
| 385 | + | |
| 386 | + | |
| 387 | + | |
| 388 | + | |
| 389 | + | |
| 390 | + | |
| 391 | + | |
| 392 | + | |
| 393 | + | |
| 394 | + | |
| 395 | + | |
| 396 | + | |
| 397 | + | |
| 398 | + | |
| 399 | + | |
| 400 | + | |
| 401 | + | |
| 402 | + | |
| 403 | + | |
| 404 | + | |
| 405 | + | |
| 406 | + | |
| 407 | + | |
| 408 | + | |
| 409 | + | |
| 410 | + | |
| 411 | + | |
| 412 | + | |
| 413 | + | |
| 414 | + | |
| 415 | + | |
| 416 | + | |
| 417 | + | |
| 418 | + | |
| 419 | + | |
| 420 | + | |
| 421 | + | |
| 422 | + | |
| 423 | + | |
| 424 | + | |
| 425 | + | |
| 426 | + | |
| 427 | + | |
| 428 | + | |
| 429 | + | |
| 430 | + | |
| 431 | + | |
| 432 | + | |
| 433 | + | |
| 434 | + | |
| 435 | + | |
| 436 | + | |
| 437 | + | |
| 438 | + | |
| 439 | + | |
| 440 | + | |
| 441 | + | |
| 442 | + | |
| 443 | + | |
| 444 | + | |
| 445 | + | |
| 446 | + | |
| 447 | + | |
| 448 | + | |
| 449 | + | |
| 450 | + | |
| 451 | + | |
| 452 | + | |
| 453 | + | |
| 454 | + | |
| 455 | + | |
| 456 | + | |
| 457 | + | |
| 458 | + | |
| 459 | + | |
| 460 | + | |
| 461 | + | |
| 462 | + | |
| 463 | + | |
| 464 | + | |
| 465 | + | |
| 466 | + | |
| 467 | + | |
| 468 | + | |
| 469 | + | |
| 470 | + | |
| 471 | + | |
| 472 | + | |
| 473 | + | |
| 474 | + | |
| 475 | + | |
| 476 | + | |
| 477 | + | |
| 478 | + | |
| 479 | + | |
| 480 | + | |
| 481 | + | |
| 482 | + | |
| 483 | + | |
| 484 | + | |
| 485 | + | |
| 486 | + | |
| 487 | + | |
| 488 | + | |
| 489 | + | |
| 490 | + | |
| 491 | + | |
| 492 | + | |
| 493 | + | |
| 494 | + | |
| 495 | + | |
| 496 | + | |
| 497 | + | |
| 498 | + | |
| 499 | + | |
| 500 | + | |
| 501 | + | |
| 502 | + | |
| 503 | + | |
| 504 | + | |
| 505 | + | |
| 506 | + | |
| 507 | + | |
| 508 | + | |
| 509 | + | |
| 510 | + | |
| 511 | + | |
| 512 | + | |
| 513 | + | |
| 514 | + | |
| 515 | + | |
| 516 | + | |
| 517 | + | |
| 518 | + | |
| 519 | + | |
| 520 | + | |
| 521 | + | |
| 522 | + | |
| 523 | + | |
| 524 | + | |
| 525 | + | |
| 526 | + | |
| 527 | + | |
| 528 | + | |
| 529 | + | |
| 530 | + | |
| 531 | + | |
| 532 | + | |
| 533 | + | |
| 534 | + | |
| 535 | + | |
| 536 | + | |
| 537 | + | |
| 538 | + | |
| 539 | + | |
| 540 | + | |
0 commit comments