Skip to content

Commit 0763bf6

Browse files
fix(objectql, metadata-protocol)!: by-name doors judge a name's holders over the served set, so a disabled package's item is not a holder (ADR-0150 D3) (#32497)
<!-- claude-projects-attribution: {"github_login":"os-sales"} --> _Requested by **Sales** · [project thread](https://claude.ai/code/project/chan_01D5bWFY3rFzgJcytD5gD4Uu?thread=cmsg_01D5bWFY3rFzgJcytD5gD4UuAmK7jpGCVzwYLc9m88hQvG)_ epic:#31527#1 · os-sales · session_01L6bhgTkccuWPuLpWbpBTVu ## 维护者速读 - 改了什么:按名读取包作用域元数据时,「持有者」只算正在提供服务的包。一个名字由启用包和停用包同时持有时,由启用包作答,不再 409 列出两者;只有停用包持有的名字等同无人持有,不再点名停用包。存储引用回填、CLI 报告、picklist 判定这类持久判断仍读全部持有者,停用可逆,绑定不跟着动。权限集授予是固定例外:安全目录的解析和 `holdsPlatformPermissionSet` 读全部持有者,停用永远不会让授予变多(Sales 裁定 6824698376)。 - 为什么改:列表早已隐藏停用包的条目,按名读取却还把它算作持有者,于是列表里只有一个、按名读却 409,或拒绝信息点名一个看不见的包;运维停用撞名包这个补救手段不起作用(ADR-0150 D3,史诗 #31527)。 - 本轮(第 5 轮):#32513 落地后合了一次 main(`5f84ef0ec`,不 rebase)。按裁定 6815997281 补了落地义务:picklist 到达判定(`judgePicklistArrival`)前后都读全部持有者,与字段判定一致;#32507 的流程门按 R4-G 全部保持 main(读全部持有者,served 判定留给 #32670);触发器领取的派发键坐标(`flowDispatchHolder`)也保持 main,与重键回填一致。#32566 让 `action` 进入无包行判定,补了两条 pin,第 26、32 行扩到 `action`。按 Sales 裁定 6824698376,权限集改为固定例外,第 9、15 行撤回,第 14、21 行只剩 `action`;包列指向停用包仍不给、不改投(第 20 行)。 - 风险与回滚:多数答案是放宽(409 变 200),权限集授予不放宽。收窄有四处:进程内库 API、少数拒绝、停用基包的配对地址,以及停用包地址上只有配对行带的成员(后两处原来漏出停用包的内容,现在答 404),见下方 FROM → TO 表,第一方调用方都是 0。回滚即 revert。 - 先看:`packages/objectql/src/registry.ts` 的 `packageScopedHoldersOf`,再看下方 FROM → TO 表,最后看 `packages/core/src/security/security-catalog.ts`。 - 需要你做的:审本 PR。合 main 后对 `776474e8b` 共 3502 行(53 个文件,+3377 −125),超过 3000 行,落地前需要你批准。 Fixes #32183 Clause-②: no (narrowing) — for a name that only disabled packages hold, `SchemaRegistry.resolveItem`, `MetadataFacade.get` / `getEntry` and `SchemaRegistry.getApp` (`@objectstack/objectql`) answer `undefined` where they answered the disabled package's body, and `MetadataFacade.exists` answers false where it answered true. A package caller whose closure reaches a name only through a disabled package, while an enabled package outside the closure holds it, is refused `outside-closure`. At the `/meta` exact read, the pair address of a disabled base, and a disabled package's address at a member only its pair stores, answer 404 where they served the disabled package's customization. Every other moved answer widens, names fewer packages, or moves between a refusal and not-found; each is in the table below and in the changeset. Metadata-protocol: none Skills-docs: none — `content/docs/deployment/marketplace-handbook.mdx` already says a disabled module is hidden, and no skill or doc teaches the by-name answer for a name a disabled package holds. **Narrowing: yes** — first-party callers: **0** (measured on the predecessor's step 0: showcase 22 packages / 205 package-scoped names, crm 18 / 35, multi-package 16 / 27; no name has two holders and no package is disabled at boot). **Supersedes #32327.** This is #32327's branch (`claude/project-thread-ryhc4d` at `1b655c3cd`, contract review r3 PASS 6781597322) carried onto this branch with `main` merged in: this session may push only its own designated branch, so the resume opens here, as claim 6810227359 provides. Every commit of #32327 is in this branch's history unchanged. #32327 is left open for the seat to close. ## Moved answers (FROM → TO) FROM is `main` at `f0f729e7` with #32214's branch (`27abd458a`) merged in, the state `main` reached when #32214 landed (`f56354c2c`); TO is this head, `32f380061`, with `main` merged at `5f84ef0ec` (round 5). First-party count 0 on every row. Rows 10–12 and 16 come from doors `main` added since #32327's last merge, rows 23–26 from the exact-qualifier hunk (ruling (c)), rows 32–34 from the round-3 contract review (M2 and its should-fix), and row 35 from epic ruling R4 (R4-C). Rows 27–31 (the email template send) are withdrawn by R4-A and carried to #32670; their numbers are not reused. Rows 17, 26, 33 and 34 are extended this round, and their FROM, with row 35's, was measured on `216674301` (Verification). Rows 18a, 34a and 34b, and row 35's second state, are declared from the delta contract review's measurement (6821393023, N1 and N2), with no source change; their pins are on #32705. The other rows were declared on #32327 and are unchanged. Round 5: rows 9 and 15 are withdrawn by Sales ruling 6824698376 (the permission-set grant reads every holder, so they answer as on `main`), and their numbers are not reused; rows 14 and 21 keep only `action`. Rows 26 and 32 are extended to `action`, which #32566 (`279f55926`) brought into the package-less row judgment (`judgesPackageLessRows`); their FROM for `action` is `5f84ef0ec`. Row 4 is now reachable for `picklist`, `mapping`, `dataset` and `api`, which #32513 lets two namespaces hold; measured on this head (Verification). | # | Door or reader | Case | FROM | TO | Arm | Pin | |:--|:--|:--|:--|:--|:--|:--| | 1 | `SchemaRegistry.resolveItem`, `MetadataFacade.get` / `getEntry`, `getApp` | only disabled packages hold the name | the disabled body (`exists` true) | `undefined` (`exists` false) | narrowing (library) | objectql `package-scoped-e8-readers.test.ts` | | 2 | `packageScopedHoldersOf`, `resolvePackageScopedName`, `readPackageScopedItem`, `resolveActionByPackage` | same, caller with no package or outside the closure | `[DISABLED]`, resolved to it | `[]`, not-found | narrowing (library) | objectql `package-scoped-resolver.test.ts` | | 3 | `resolvePackageScopedName`, `resolveItem(type, name, caller)`, `resolveActionByPackage` | the caller's closure reaches the name only through a disabled package; an enabled one outside holds it | the disabled body | refused `outside-closure`, naming the enabled holder | narrowing | objectql `package-scoped-resolver.test.ts` | | 4 | bare `GET /meta/:type/:name`, every type of the live `PACKAGE_SCOPED_READ_TYPES` (now with `permission`), both transports; MCP `agent_prompt`, the dataset query door's bare `datasetName`, the import door's `mappingName`, a connector pull naming no package | two holders, one disabled | 409 naming both | 200, the enabled holder's item | widening | runtime `meta-qualified-item-read.test.ts`, rest `meta-qualified-item-route.test.ts` | | 5 | bare `/layers` | same | 409 naming both | 200, the enabled holder's stack (code layer, overlay row, lock) | widening | same, and `meta-disabled-holder-served-stack.test.ts` | | 6 | bare `/published` | same | 409 naming both | the enabled holder's row, else the service copy at its package, else 404 | widening | `meta-disabled-holder-artifact-door.test.ts`, `meta-disabled-package-doors.test.ts` | | 7 | `/meta/:type/:ns/:name` of a shareable namespace, and bare | two co-owners, one disabled | 409 `ambiguous-in-namespace` | 200, the enabled co-owner's item | widening | runtime / rest qualified-read files | | 8 | `resolveActionByPackage`, the REST route rung for a caller's package | caller with no package, or a closure holding both | refused | the enabled holder's declaration and handler | widening | objectql and runtime `action-package-addressing.test.ts`, `actions-disabled-holder-door.test.ts` | | 10 | **new** `?callerPackage=P` on `GET /meta/dataset/:name` and the dataset query doors (single, batch) | two holders in P's closure, one disabled | 409 naming both | 200, the enabled holder's dataset | widening | runtime / rest, `#32183 × #32310` describe | | 11 | **new** connector pull of a job's mapping, package caller | two holders in the closure, one disabled | 409 `mapping_name_refused` naming both | the enabled holder's mapping is pulled | widening | service-automation `connector-pull.test.ts` | | 12 | **new** flow credential channel write (the flow save door's store) | a flow name an enabled and a disabled package hold; a save that sets, clears or removes a stored credential | 409 naming both | written, rows stamped `flow_package` = the enabled holder | widening | service-automation `stored-reference-package-column.test.ts` (`flowHolderPackage`) | | 13 | `?package=NONHOLDER`, a non-holding namespace path, `_env` | two holders, one disabled | 409 naming both | 409 naming the enabled holder | names fewer | runtime / rest | | 14 | action caller outside both closures | same | refused naming both | refused naming the enabled holder | names fewer | objectql | | 16 | **new** `?callerPackage=P` | P's closure reaches the name only through a disabled package; an enabled one outside holds it | 404 (the disabled item, withheld) | 409 `outside-closure`, naming the enabled holder | refusal | runtime / rest, `#32183 × #32310` describe | | 17 | `?package=NONHOLDER` and its qualified path | only disabled packages hold the name, whatever row a layer of the read reached (R4-B: a row of a holder's customization pair at a member only it stores, which the metadata service answers by name) | 409 naming the disabled package | 404; only a row stored under the address's own package is served | not-found | runtime / rest; objectql `package-scoped-exact-qualifier.test.ts` (`a name only a disabled package holds, at an address that neither holds it nor pairs a holder`) | | 18 | bare read | two or more disabled packages, nothing else | 409 naming them | 404 | not-found | runtime / rest | | 18a | **declared (N1)** bare read | two or more holders, every one disabled, at a member only another row carries (a package-less row, a dependent's added locale, or the App pair's row the metadata service answers by name) | 409 naming them | 200 with that row (`main`'s answer with one holder) | widening | none here; carried to #32354 and #32705 | | 19 | shareable namespace path | both co-owners disabled | 409 `ambiguous-in-namespace` | 404 | not-found | runtime / rest | | 20 | stored permission-set column naming the disabled holder | two holders, one disabled | refused naming both | not-found, never re-targeted (kept by Sales ruling 6824698376) | not-found | core `security-catalog.test.ts` (`#32183 — a disabled holder still counts for a permission set`), both orders | | 21 | action caller outside the closure | only a disabled package holds the name | refused naming it | not-found | not-found | objectql | | 22 | REST action rung with `callerPackageId` | the execution read throws a package-scoped refusal | `degraded` | the declared 409 | refusal (no door reaches it) | runtime `action-package-addressing.test.ts` | | 23 | **new** `?package=<base>.custom`, the pair of a disabled base, both transports | an enabled holder of the name registered first | 200, the disabled base's body under the enabled holder's envelope (`_packageId`) | 404, the disabled base's withheld item | narrowing (door) | runtime / rest, `#32183 — a disabled package holds no name` describe (`address, namespace and pair`), every live type, both orders | | 24 | **new** `?package=<App>.custom`, an App's pair two modules share | one module disabled; the layer below reaches neither module's item | 409 `ambiguous-in-closure` naming both | 200, the enabled module's item | widening | objectql `package-scoped-exact-qualifier.test.ts` (`an App's pair two modules share`) | | 25 | **new** same | every base disabled | 409 naming them | 404 | not-found | same | | 26 | **new** a package-less row (the environment's item, or a package-less stored row) at the enabled holder's exact address | a name an enabled and a disabled package hold | 409 `ambiguous-in-closure` naming both (#32214's rule over every holder) | served as that holder's customization; re-enabled, refused naming both. At the enabled holder's pair (`?package=<enabled>.custom`, R4-D): 200 with the row when the enabled holder registered first; 404 when the disabled one did (#32501 location 1). Round 5, `action`: the environment's item at the enabled holder's exact address, and a package-less stored row in the layered read at that address (`?layers=true&package=`), reported as its overlay; FROM refused naming both | widening (the pair's 404: not-found) | objectql `package-scoped-exact-qualifier.test.ts` (`[#32183] agent` / `dashboard`; `?package=<enabled>.custom`, both orders, both row kinds, the 404 arm marked to flip when #32501 lands; for `action`, `[#32183] one of the two holders disabled`, both orders) | | 32 | **new** `?package=DISABLED` and `?package=DISABLED.custom` | beside a package-less row (the environment's item, or a package-less stored row) of a name an enabled and the disabled package hold | 409 `ambiguous-in-closure` naming both | 404, the disabled package's withheld item; re-enabled, refused naming both. Round 5, `action`: `?package=DISABLED` beside the environment's item, the same | not-found | objectql `package-scoped-exact-qualifier.test.ts` (`[#32183] dashboard (…, beside …)`; for `action`, `[#32183] one of the two holders disabled`), both orders, both row kinds | | 33 | **new** the list scoped to the enabled holder (`GET /meta/:type?package=`), and the execution list at its address (`getMetaItemsForExecution`, which a send resolved to that holder reads) | a package-less stored row of a name an enabled and a disabled package hold | the holder's own item | the stored row, as the holder's customization, in both lists; re-enabled, its own item | widening | same file (`the list scoped to the enabled holder, and its execution list`), with a CONTROL: the environment's item in the registry is in neither scoped list | | 34 | **new** an App's pair member row with no `overrides`, at the enabled module's exact address (`?package=X&member=`), in its scoped list and in its execution list | a bundle name two modules of the App hold, one disabled | 409 naming both; left out of both lists (a send resolved to X finds no template at that member) | served as its member; listed in both (the send finds that member); the disabled module's address answers its withheld item | widening | same file (`[#31699 F2]` describe, `one of the two holders disabled`), both orders | | 34a | **declared (N1)** the scoped list and the execution list of each module | the same member row, both modules disabled | left out | listed at both modules | widening | none here; carried to #32670 and #32705 | | 34b | **declared (N1)** a send made from either disabled module at that member | same | no template | that member | widening | same | | 35 | **new** `?package=DISABLED&member=`, `?package=DISABLED.custom&member=` and the disabled package's namespace path | a member only the disabled package's customization pair stores, one holder of the name or two, either order; or (N2) one holder, disabled, and a member only a package-less stored row carries | 200 with that row | 404, the disabled package's withheld item; re-enabled, that row | narrowing (door) | objectql `package-scoped-exact-qualifier.test.ts` (`` `?package=DISABLED&member=` where only the pair's row carries the member ``), at the protocol both transports read, one holder and two, both orders. The N2 state's pin and per-transport pins are on #32705. | **Restored by the hunk, not moved against `main`:** `?package=DISABLED`, the disabled package's namespace path, the pair of a disabled base where no enabled holder's envelope is reached, and `?callerPackage=P` when P's own holding is the disabled one beside an enabled dependency answer 404, as on `main`. The previous head (`1483899c0`) answered them 409 `not-held-by-qualifier` naming the enabled holder. They are pinned on both transports, for every live type, in both registration orders. The email template send door is not moved (R4-A): it asks the list for the same address, or throws the same refusal, as on `main`, a send made from the disabled holder included. What an address lists moves only as rows 33 and 34 declare. As on `main`, that send still sends a template in three one-holder states (beside a package-less row, over the built-in copy, and with a dependent's added locale). **Not moved:** `?package=DISABLED` and its namespace (above), except beside a package-less row (row 32) and at a member only its pair stores (row 35); the email template send door (`createRegistryEmailTemplateLoader`), which reads every holder, so a disabled package still counts there and a refusal still names it, until #32670 (what an address lists moves as rows 33, 34, 34a and 34b declare); `_env` of a name only disabled packages hold, which keeps `main`'s 409 naming them (R4-B2: with no served holder, its admission judges every holder); every holder's own read; the served lists, except the list scoped to an enabled holder and its execution list (rows 33 and 34); durable judgments (R1/R3, R4, R5/R6/R13, R7–R11, R20 backfills; `os migrate stored-references`, its pair-member and package-less-row sections included (seat ruling A); `picklistReferenceVerdict`), which read every holder; the install gate (`bareNamePackageHolders`, epic stance 6766291071) and the security catalog's item seam. Round 5 adds five: - **The permission-set grant, the fixed exception (Sales ruling 6824698376).** The security catalog's resolution (`resolvePermissionScoped`: a reference with no package column, a stale column, or a position's package) and `holdsPlatformPermissionSet` (`@objectstack/core`) read every holder, so a disable never makes a grant confer more. Two holders with one disabled stay refused naming both, and `holdsPlatformPermissionSet` is false. A name only a disabled package holds counts that package: a caller outside it is refused naming it, and no grant resolves to its set, never the metadata service's by-name body. Each as on `main`. Only a column naming the disabled holder moves (row 20), the same stance: it confers nothing and is never re-targeted. - **The picklist arrival judge** (`SchemaRegistry.judgePicklistArrival`) reads every holder before and after an arrival, as `picklistReferenceVerdict` does (ruling 6815997281), so the install audit and a field's options agree for a disabled holder: an install, upgrade, hot reload or late item is refused exactly as with the holder enabled. - **The flow doors of a name two packages hold (R4-G):** a flow action's and a flow endpoint's target (`flowServiceForCaller`, `endpointPackageOf`), the start admission's read walk (`flowWalkReads`, root and callee), `flowHolderForCaller`, the `/automation` bare-name refusal and addressed paths (`bareNameRefusal`, `admitAutomationAddress`'s shared branch), and the engine's slot table (`heldByMany`), its shared-name refusal (`sharedFlowNameRefusal`) and the shared branch of `resolveFlowKey`. A runtime disable keeps the disabled package's engine slot armed, so a served read there would move these doors both ways: with CRM disabled, HR's own flow action would reach the bare service, and a package whose closure holds both would run HR's flow. Their served judgment is carried to #32670. The flow execute door for a name one slot holds keeps judging the served holders, as do `flowHolder`, `flowHolderPackage` (row 12) and the activation ledger's `stillHolds`. - **The dispatch key a trigger claims** (`AutomationEngine.flowDispatchHolder`, D8 row R10) reads every holder, as the re-key backfill does (within R4-G, seat 13:20Z). On the previous head it read the served holders, so a flow only a disabled package holds lost its package segment while the re-key scoped it, and a name an enabled and a disabled package hold, asked by its bare name, dropped the collision guard (`claimBare` true). - **The bare action read's check for a disabled package's customization** (`servedFromDisabledHolder`, #32719) reads every holder, so it answers as on `main` (round 5, `28b37fbb7`). - **The metadata service's removal by name** (`storeRemovalKeys`, #32533) counts the store's own slots and reads no package state. This branch does not touch `package-slotted-store.ts`; its metadata delta is `getPublished(type, name, packageId?)`, and no reader touches both. ## What changes Unchanged from #32327 at `1b655c3cd` (its body is the full account; the contract review r3 PASS 6781597322 read it): - **The holder set is the served set** (`packages/objectql/src/registry.ts`, `packageScopedHoldersOf`): a disabled package's holding is left out, except the caller's own; `options.includeDisabledPackages: true` reads every holder, forwarded by `resolvePackageScopedName`, the action addressing wrapper and the install door's pending-manifest view. - **Durable judgments read every holder**: the stored-reference backfills (permission sets, sharing declarations, email templates, the activation ledger, R7–R11 through `AutomationEngine.durableFlowHolder` and the connector resolver's `options`), the CLI stored-reference report and `picklistReferenceVerdict`. - **The security catalog** never re-targets a disabled holder's column. Round 5 (Sales ruling 6824698376): a permission-set grant and `holdsPlatformPermissionSet` read every holder, the fixed exception, so they answer as on `main` (rows 9 and 15 withdrawn). - **The item face** answers a name every holder of which is disabled as that package's withheld item; **the bare reads take the served holder's stack** (`servedHolderAddressOf`, `isAnotherHoldersCopy`); both `/published` doors and `MetadataManager.getPublished(type, name, packageId?)` read at the served holder's package. - **The REST action rung** answers a thrown package-scoped refusal as the declared 409. This round (resume): - **`main` merged** at `f0f729e7` (no rebase), commit `7056f7084`. One textual conflict, `packages/runtime/src/action-package-addressing.test.ts`: both sides added a top-level `describe` after the review-F4 block (this branch's route-rung pins; `main`'s #32244 bare-action-read pins). Both are kept, in that order. Thirteen other files both sides touched merged cleanly; I read each overlap (registry, resolver, layered reads, metadata manager, `domains/meta.ts`, action execution, service-automation engine, plugin, connector scope and backfill). - **Doors `main` added, now judging the served set through the source** (no edit to their modules except one docblock): the `?callerPackage=` arm (#32310, rows 10 and 16), the connector pull's mapping for a package caller (#32294, row 11), and the flow credential channel's row stamp (#32302, row 12). Each is pinned and declared in the changeset. - **`packages/services/service-automation/src/connector-package-scope.ts`**: docblock only. `withholdDisabledHolder` said this change "does not touch" it and that a disabled holder beside an enabled one "still counts"; both are no longer true. Its `outside-closure` arm is now unreachable (the served set never names a disabled package outside the closure); I left the code, and the seat may drop it. - **Two pins `main` wrote for the old answer moved** (`connector-pull.test.ts`): the `CONTROL (#32183's class)` case (a disabled holder beside an enabled one still counts) and the no-package half of the case beside it. Both now assert the served answer and, re-enabled, the refusal. - **`permission` joined `PACKAGE_SCOPED_READ_TYPES` on `main` (#32162)**, and the served-holder pins iterate the live list, so they ship a permission set under two packages, which the security catalog's item seam refuses at registration. The three loops (objectql e8 readers, runtime and rest qualified reads) lift that one seam for `permission`, as `main`'s own `package-scoped-exact-qualifier.test.ts` does (`admitSecondPermissionHolder`). Rows 4–7, 13 and 17–19 now cover `permission`. - **Redundant, left as is:** `main`'s `refuseActionHeldByPackages` (#32361) filters disabled holders at the action door; the source filter makes that filter a no-op. Its store-refusal reader (`rethrowPackageScopedRefusal`) still matters, because the metadata service counts disabled holders. ### This round (2): #32214's branch merged, and the exact-qualifier hunk (ruling (c)) - **#32214's branch merged** at `27abd458a` (no rebase), merge `9aa83772c`, on the seat's word that it is accepted and landing. There were three conflicts, each two additions at one spot, and all are kept. `rest/src/meta-item-history-routes.ts`: the `/published` door's `withheld` starts from #32214's object mask posture, beside this branch's mixed-holder reads. `rest/src/meta-disabled-package-doors.test.ts` and `cli/src/utils/stored-package-references.literal-namespace.test.ts` keep both describes. #32214 then landed (`f56354c2c`), and `main` at `216674301` is merged as `c42636445`. There were four conflicts, in files #32214's squash brought onto `main`; `main`'s copy of each is byte-identical to `27abd458a`, so this branch's copy is kept (`protocol-exact-qualifier.ts`, `stored-package-references.ts` and its literal-namespace test, `package-scoped-exact-qualifier.test.ts`). The diff against `main` is now this PR's own: 46 files, +2443 −93, 2536 changed lines. - **Admission reads every holder** (`protocol-exact-qualifier.ts`, `admitExactQualifier`). A package that holds the name, disabled or not, is admitted at itself. A pair is read at its served bases, or, when every base is disabled, at one of them. A refusal names the served holders. `resolveMetaItemAddress` judges a namespace's owners over the served holders, and falls back to an owner that holds the name while disabled. - **The item face judges the address** (`protocol-meta-item-face.ts`, with `disabledExactAddressHolder`). An exact address that reads only disabled packages answers that package's withheld item, whichever envelope a layer reached, so layered step 1b answers absent too. The face's old check read the grafted envelope. A pair's envelope is looked up at the pair id and falls back to the first holder that ships the name, so the pair of a disabled base served the disabled body when an enabled holder registered first (row 23). Ablated: 15 of 30 red on each transport. - **The CLI report reads every holder** (seat ruling A): `pairMembers` and `packageLessRows` in `stored-package-references.ts`, with `packageLessRowOwners(..., { includeDisabledPackages: true })`. The exact read's `packageLessRowOwners` stays served (row 26). One pin each; ablated, 2 of 2 red each. ### This round (3): contract review M1 and M2 (epic ruling 6815997281) - **Superseded by round 4 (R4-A).** **The send door reads a disabled caller at its own address** (`plugin-email/src/template-loader.ts`, `bundleAddressOf`, the door #32214 added). The resolver keeps a caller's own holding, so a send from the disabled holder resolved to it. The holder count that follows reads the served holders without the caller, found one holder, and sent from the environment-wide list, which hides the disabled package: the enabled holder's template went out for a caller with no path to it. Now, when the resolved holder is the caller's own package and the served holders leave it out while every holder includes it, the send is read at that package's own address, where its items are withheld: no template, as on `main`. Rows 27–31 are declared. Pins: 8 cases × 2 registration orders × 2 reads (the protocol's execution list over the registry's served list, and the registry's own list), with CONTROLs for both holders enabled and for the enabled holder's own send. With the fix removed, the disabled holder's own send is red in all 4 combinations. With the served filter ablated, 20 of 32 are red (rows 27–31); the CONTROLs and the disabled holder's own send stay green, as on `main`. - **The sweep (R-A):** every non-test call site that resolves a name for a caller (`resolvePackageScopedName`, `resolvePackageScopedHolders`, `resolveActionByPackage`, `resolveCallerPackageAddress`), each with its answer for a caller whose own holding is the disabled one: - plugin-email `bundleAddressOf`: round 3 fixed it with an own-address branch; round 4 (R4-A) replaced that with reads over every holder, so it answers as `main` for every caller. The served judgment at the send is #32670. - plugin-email, the same function's addition path (a caller whose own holding is only an added locale): re-resolves from its closure to its base, the same on both trees. The base is in the caller's closure, not outside it. - objectql `resolvePackageScopedName`, `resolveItem(type, name, caller)`, `readPackageScopedItem`, and `resolveActionByPackage` through `actionOwnerScopedRegistry`: they count with the caller, so the answer is its own item (the stated "unchanged" stance). - runtime REST action rung (`resolveRouteActionByPackage`): resolves to the caller's own declaration, then reads it back at `?package=<caller>`, where the item face withholds it: no declaration. - metadata-protocol caller arm (`resolveCallerPackageAddress`, #32310): counts with the caller, reads at its address: 404 (pinned on both transports). - core security catalog (`resolvePermissionScoped`): counts with the caller; a resolved disabled set fails `servable`: not-found. Round 5: over every holder (6824698376), the same answer. - service-automation mapping pull (`mappingNameResolver`, #32294): `withholdDisabledHolder` after the resolve: `mapping_not_found`. - service-automation flow execute (`resolveFlowKey`) and the activation ledger's `stillHolds`: key the engine's slot of the resolved holder, and the engine keeps every package's slot: the caller's own flow, the same on both trees. - service-automation connector dispatch (`connectorNameRefusal`): would dispatch to the enabled holder's instance. Latent; carried to #31699 PR2 (Acceptance notes). - plugin-sharing `queueRecipientCaller`: resolves over `listedHoldersView`, which drops the caller's own disabled holding too, so the resolve and the count agree. Unchanged. - metadata `package-slotted-store` `readIdentity` (`MetadataManager.get` with a package): the caller's own slot. The store does not read package state, the same on both trees. - Caller-blind (`callerPackageId: null`) and durable reads have no caller to mix: runtime `automation-address`, webhooks `chooseDeclaration`, `refusedConnectorNames`, `refuseAmbiguousObjectLessAction`, `refuseActionHeldByPackages` (#32361), the flow credential channel (#32302), the backfills, the CLI report and `picklistReferenceVerdict`. - **M2 and its should-fix are declared and pinned** (rows 32–34). They follow from row 26: `packageLessRowOwners` and `pairMemberWithheldAt` judge the served holders. The row 32 pins cover the environment's item and a package-less stored row, in both orders, and the row 33 pin uses a package-less stored row, because the environment's item in the registry is not in a holder's scoped list on either tree (its CONTROL). With the served filter ablated: rows 32–34, 8 of 8 red; the CONTROL stays green. The "Not moved" lines here and in the changeset are corrected. ### This round (4): epic ruling R4 (6820114703), and R4-B2 (6820387912) - **R4-A, the send door reads every holder** (`plugin-email/src/template-loader.ts`, `bundleAddressOf`). The resolve, the holder count and the second resolve (the `shared` view) take `includeDisabledPackages: true`, and the round-3 own-address branch is deleted. The diff of `template-loader.ts` against `216674301` is those three arguments and a docblock paragraph. Rows 27–31 are withdrawn from the table and the changeset. The round-3 describe is replaced by one parity pin: one or two holders, each with and without a dependent's added locale; every caller (none, omitted or null; each holder; a closure holding both; a closure through BETA only; neither; the dependent); both registration orders; both reads. With each non-empty set of holders disabled, every caller's ask (the list address, or the refusal with its candidates and message) equals the ask with nothing disabled. The ask is spied: the protocol request's address, or, on the registry read, which item of a probe list survives. A CONTROL per state, order and read pins the enabled asks to `main`'s. 72 tests. - **R4-F CONTROL**: with nothing disabled, a non-auth name the built-in and one package hold, sent with the built-in package as the caller, sends the package's template, both orders, both reads (4 tests). No source was owed. - **R4-B, the item face** (`protocol-meta-item-face.ts`). When every holder of the name is disabled, an exact address now serves only a row stored under its own package. `disabledOnlyHolderOf` was applied only when the answer had no item; it now also applies when the exact read reached an item that is not stamped with the address's package. The contract review's case moves: only X (disabled) holds `welcome`, the App's pair stores an fr-FR row, and the metadata service answers it by name. `?package=Y&member=fr-FR` (Y is the App's other module) and its namespace path went from 409 naming X on `main` to 200 with the pair's row at `6655b7421`; they now answer 404, as row 17 declares. A row stored under Y is still served at Y. With X enabled, each answers `main`'s 409. - **R4-B2, `_env`** (`protocol-exact-qualifier.ts`, `admitEnvironmentQualifier`). At that member, `_env` was 409 naming X on `main` and 200 with the pair's row at `6655b7421`: it is admitted, then read as the bare read, which the face cannot tell apart from a bare read. On the seat's ruling (a), the admission judges every holder when no package serves the name, so `_env` keeps `main`'s 409 naming the disabled package(s). Row 17 no longer lists `_env`. The runtime and rest `_env/solo` pins move from 404 to 409 naming the disabled holder, as on `main`, and one objectql pin covers the pair-row member. The bare read at that member is 200 with the pair's row on both trees, enabled or disabled, so it is unchanged here and goes to #32354. - **R4-C, row 35.** `?package=DISABLED&member=` at a member only the pair's row carries was 200 with the pair's row on `main`, and is 404 here, with one holder or two, in either order. `?package=DISABLED.custom&member=` and the namespace path move the same way and are in the same row. The changeset carries a BREAKING line beside row 23, and its "keeps its 404" sentence now names this exception. - **R4-D, row 26 extended.** `?package=<enabled>.custom` beside a package-less row (the environment's item, or a package-less stored row): 409 naming both on `main`; 200 with the row when the enabled holder registered first; 404 when the disabled one did. That 404 comes from #32501 location 1, the same on both trees. No source change. Pinned in both orders with both row kinds, and the 404 arm carries a comment to flip it when #32501 lands. - **Rows 33 and 34 extended to the execution list** at the enabled holder's address. Row 33 (a package-less stored dashboard): `main` lists `beta dashboard`, here `stored dashboard`. Row 34 (the App pair's fr-FR member): `main` lists only `suitex en-US`, here `pair fr-FR` as well. The existing pins now also assert `getMetaItemsForExecution`, and re-enabled each answers as on `main`. - **R4-G**: no other door was found this round that sends or serves another package's body through this change. - **After the delta review (6821393023 PASS, red-line read 6821404403 PASS), text only** (commit `8ec8d78ea`, seat's ruling): N1's three answers are declared as rows 18a, 34a and 34b; N2's state is added to row 35 and its BREAKING line; N3's sentence now says the door asks the same address or throws the same refusal; N4 drops "both transports" from rows 17 and 35. No source or pin changed. The N2 pin and per-transport pins go to #32705; the seat read this delta (6821456566). ### This round (5): `main` merged after #32513, the landing duties of ruling 6815997281, and Sales ruling 6824698376 - **`main` merged** at `5f84ef0ec` (after #32513), no rebase, merge `061fd070f`. Three test conflicts, each two additions at one spot, both sides kept: `packages/cli/src/utils/stored-package-references.literal-namespace.test.ts` (this branch's disabled-holder report case and `main`'s narrowed-action case), `packages/rest/src/meta-qualified-item-route.test.ts` and `packages/runtime/src/domains/meta-qualified-item-read.test.ts` (this branch's caller-arm describe, then `main`'s; the runtime imports joined). - **`main` merged three times more**, at `f7a0fe0ea` (merge `d8644927b`), at `af90f307c` (merge `32f380061`) and at `776474e8b` (merge `649ae4718`), with no rebase. The first two had no conflict. The third had one, in `packages/runtime/src/domains/meta-qualified-item-read.test.ts`: both sides added a describe at one spot (this branch's `#32183 × #32310` caller-arm describe, then `main`'s `#32250` dispatcher `/layers` 409). Both are kept. #32569 and #32731, then #32687, touched `metadata-manager.ts` in hunks apart from `getPublished`. None of those commits adds a holder read outside tests: no new call of `packageScopedHoldersOf`, `resolvePackageScopedName`, `resolvePackageScopedHolders`, `resolveActionByPackage`, `readPackageScopedItem`, `durableFlowHolder`, `flowHolder` or `isPackageDisabled`. So no new door is declared from those. In the third merge, #32719 added one: `servedFromDisabledHolder` (`protocol-meta-item-reads.ts`) lists the disabled holders of an action name, to ask whether the service's package-less answer is a disabled package's customization. Over the served holders that list is always empty. On the merge, runtime `action-package-addressing.test.ts`'s `[#32560] the disabled B's customization …` went red (1 of 67): the bare read served B's customization. `28b37fbb7` makes that read every holder (`includeDisabledPackages`), so it answers as on `main` (67 of 67), and declares it in the changeset's "Not moved". Reverting it reds that case. - **The picklist arrival judge** (`0975e7608`, objectql `registry.ts`). In `judgePicklistArrival`'s memo, `before` (over the registry) and `after` (over the arrival's view) resolve with `includeDisabledPackages: true`. Judged over the served holders, a field resolving to a disabled package's list would read as refused already and be skipped, and an arrival making it ambiguous would be admitted: the field would silently lose its options once the package is re-enabled. Pin (`registry-bare-name-one-holder.test.ts`, `[#32183] a disabled holder is still a holder for the arrival judge`, both orders): an upgrade adding the list, and a late install beside an installed extension, are refused with the message the enabled case gives, naming the field and both holders. CONTROL: `picklistReferenceVerdict` resolves to the disabled holder while the served `resolvePackageScopedName` is not-found. - **The #32507 flow doors, held at `main` under R4-G** (`e6cf10f3a`). runtime `flow-slot-view.ts`: all seven `resolvePackageScopedName` calls read every holder (`EVERY_HOLDER`). `automation-address.ts`: `bareNameRefusal` reads every holder, and `admitAutomationAddress` counts every holder, so a name two packages hold is judged over both; a name one package holds keeps the served read. service-automation `engine.ts`: `heldByMany`, `sharedFlowNameRefusal` and `resolveFlowKey`'s shared branch read every holder. Pins are parity pins: in both registration orders, for every non-empty set of disabled holders, every door answers what it answers with nothing disabled. runtime `flow-caller-package.test.ts` covers the handover's six cases and two CONTROLs (caller none, CRM, HR, a dependent of CRM, a dependent of both, neither; four namespaces and `_env`). service-automation `flow-slots-per-package.test.ts` covers ten cases (runtime and boot disable) and two CONTROLs. - **The dispatch key a trigger claims** (`6052c6c8b`). `flowDispatchHolder` read the served holders through `flowHolder`. Measured on the previous head: one holder, disabled, gave `{ packageId: null, claimBare: true }` where `main` gives `{ packageId: <it>, claimBare: true }`, while the re-key backfill scopes that key to it. Two holders with one disabled, asked by the bare name, gave `{ packageId: <enabled>, claimBare: true }`, dropping the collision guard; a trigger binds a slot key for such a name, so that ask is not reached today. The method now reads `durableFlowHolder`, as `main` answers; `flowHolderPackage` keeps the served read for the credential channel (row 12). Pin (`stored-reference-package-column.test.ts`, `R10 at the trigger`): the disabled package's own flow keeps its scope, a clash keeps the guard, and re-enabled every coordinate is the same (CONTROL). - **#32533 and `storeRemovalKeys`.** Both of #32533's changes are `main`'s and kept as merged; this branch does not touch `package-slotted-store.ts` or the `removalOf` comment. Its metadata delta is `MetadataManager.getPublished(type, name, packageId?)`. No reader touches both: `metadata-manager.ts` and `package-slotted-store.ts` read no package state (0 matches for `isPackageDisabled` and `includeDisabledPackages`). So no shared-reader pin is owed, and the removal does not move. - **`action` in the package-less row judgment** (`ae55db373`, after #32566). objectql `package-scoped-exact-qualifier.test.ts`, inside the `[#32407]` describe, both orders: with one of two holders disabled, the environment's item is the enabled holder's on its exact address, and the disabled holder's address answers its withheld item; the layered read at the enabled holder reports a package-less stored row as its overlay; re-enabled, each is refused naming both. cli `stored-package-references.literal-namespace.test.ts`: the report still lists the package-less row naming both. Rows 26 and 32 are extended. - **#32513's types are reachable** (step 6). Two namespaces each install a `picklist`, `mapping`, `dataset` and `api` of one name. With nothing disabled, each bare read is refused naming both; with one disabled, each resolves to the other (rows 4 and 10). `picklistReferenceVerdict` is refused in both states, and the engine function read (`resolveFunctionEntry`) answers 409 holding both packages in both states: no move. - **Sales ruling 6824698376 (A), the permission-set exception** (`e6473e482`, core `security-catalog.ts`). `resolvePermissionScoped`'s column-less read and `holdsPlatformPermissionSet` pass `includeDisabledPackages: true`. The docblock states the exception. The separate "held in any package" reads are removed, since the rule's own read now counts every holder. The column path keeps its check: a column naming the disabled holder is not-found, never re-targeted (row 20). Pins (`security-catalog.test.ts`, `#32183 — a disabled holder still counts for a permission set`, both orders): crm and hr each hold `qa_reader`, hr disabled. No column, a null column, a stale column and a caller outside both are each refused naming both, equal to the answer with hr enabled. A column naming hr is not-found and not said stale, while crm's column reads crm's set. For a name only hr holds: no column is not-found; a caller outside is refused naming hr, as re-enabled; no grant resolves to its set or to the metadata service's body of that name. `holdsPlatformPermissionSet` is false for two holders with one disabled (as re-enabled) and for the sole disabled holder; CONTROLs: true for a platform-only name and for a name held nowhere. Rows 9 and 15 are withdrawn, rows 14 and 21 keep only `action`, and the changeset says the same. - **Changeset** (`4e32f00a4`, `018eb5f60`): the arrival judge, the R4-G flow doors, the dispatch key and the permission-set exception are in its "Not moved"; the `action` package-less row lines are added; the permission-set widening line and its two refusal lines are removed. ### Owed before ACCEPT 1. Done: `main` merged after #32513 (`5f84ef0ec`), then at `f7a0fe0ea` and `af90f307c` (each touched `metadata-manager.ts`), no rebase, no conflict after the first. 2. Done: the duties of ruling 6815997281 (the arrival judge, the #32507 flow doors under R4-G, #32533's reader) and Sales ruling 6824698376. 3. Done: the size, reported to the seat before the push: 3487 changed lines against `5f84ef0ec`, and 3488 against `af90f307c` (52 files, +3365 −123), over 3000. The maintainer approved #32497 (review 5876504068); the seat's delta review follows the push; the R4-G holds are not split out. 4. Then the landing read, measuring this change together with #32551 (landed, `067349bbe`), and the epic red-line read on the landing head. ## Acceptance notes - **Merge hazard with #32742 (#31698 PR-2), which lands after this.** Both edit the stored-column arm of `resolvePermissionScoped` in `packages/core/src/security/security-catalog.ts`. A trial merge of #32742's head `3f931144b` into this branch (not pushed) conflicts in that file only, at two spots. The resolution keeps this PR's disabled-holder check ahead of #32742's metadata-slot read, then #32742's namespace check. In the registry-less arm it takes #32742's metadata two-holder refusal, with this PR's "a disabled package included" sentence. Whichever lands second re-takes #32742's 17 row-9 pins (`protocol-permission-set-name-registry-reading.test.ts`). - **Filed by the seat: #32501.** A pair address takes the wrong envelope. When two enabled packages hold a name and the other one registered first, `?package=<second>.custom` serves the second's body under the first's `_packageId`. Not moved here, but it decides two answers: with a disabled holder registered first, the enabled base's pair answers 404. So the CONTROL that the enabled base's pair serves its item runs in the enabled-first order only, and the pins say why. - **Filed: #32501 (location 2).** An App's pair that two enabled modules share serves the item of the module registered first. `exactQualifierItem`'s docblock says such a pair is refused naming both. The code returns that item because it is one of the admitted bases. Measured the same before and after this change, so this change does not move it. - **Carried to #31699 PR2 (comment 6816295828): the connector dispatch for a caller whose own holding is disabled.** Latent; found by the sweep, read, not measured. `connectorNameRefusal` resolves the name for the flow's package. The caller's own holding is kept, so there is no refusal, and the call dispatches by name to the one instance the reconcile materialized. That instance is the answer a caller with no package gets, which is the enabled holder's. So a flow of the disabled package would dispatch to the enabled package's connector instance. On `main` the reconcile refused the name (it counted the disabled holder), so no instance was materialized. It is unreachable today: `connector` keeps one package holder per deployment, and the install gate (`bareNamePackageHolders`) counts a disabled holder. #31699 PR2 opens two-holder connectors, so it owns the fix. The shape to copy is to resolve and count over one holder set (R4-E), not the deleted round-3 branch. ## Why The served list (`listItems`) has withheld a disabled package's items since the disable landed, and the item face answers 404 for one. But `packageScopedHoldersOf` read the raw store, so every ADR-0150 D3 door still counted the disabled package as a holder. The epic ruling 6766102988 names the served list as the right holder set. ## Verification The battery ran on `d8644927b` (`main` merged at `f7a0fe0ea`), in this session's container, with `NODE_OPTIONS=--max-old-space-size=6144`. The head pushed, `32f380061`, merges `main` once more at `af90f307c`. There was no conflict: #32687 touches `metadata-manager.ts` in other hunks, and none of the eight commits adds a holder read. On that head `pnpm build` (exit 0), the metadata suite (1930 passed), its typecheck (exit 0), and the disabled-holder and `/published` files were re-run: objectql `package-scoped-exact-qualifier`, `package-scoped-e8-readers` and `registry-bare-name-one-holder` (420 passed); runtime `meta-disabled-holder-artifact-door`, `meta-disabled-holder-served-stack`, `meta-qualified-item-read` and `flow-caller-package` (201 passed); rest `meta-disabled-package-doors` and `meta-qualified-item-route` (172 passed). An earlier pass on `018eb5f60`, before the `f7a0fe0ea` merge, was green too, except the runtime test typecheck, fixed in `fa4547c24`. - **Build:** `pnpm install --frozen-lockfile`, then `pnpm build`, exit 0. - **Suites of the twelve touched packages, plus `mcp`:** | Package | Tests | |:--|:--| | objectql | 12576 passed | | core | 3349 passed | | runtime | 10228 passed, 19 skipped | | rest | 8066 passed, 332 skipped | | metadata-protocol | 22786 passed, 36 skipped | | service-automation | 3804 passed | | plugin-security | 6499 passed, 45 skipped | | plugin-approvals | 1607 passed | | plugin-sharing | 1511 passed | | plugin-email | 1018 passed | | metadata | 1882 passed | | mcp | 1057 passed | | cli (`--project unit`) | 5915 passed | Every suite exited 0 on the first run. - **Typecheck:** `pnpm --filter <pkg> typecheck` for all twelve packages, exit 0. The runtime test typecheck (`tsconfig.test.json`, `check:test-typecheck`) first found three errors in this round's parity pin (`flow-caller-package.test.ts`): the engine double's `execute` takes the name alone, and an address refusal carries `refusal` only on its 409 arm. Fixed in `fa4547c24`; the answers it records are unchanged. - **Lint:** `pnpm lint` (whole tree, `--no-inline-config`), exit 0. - **ADR-0087:** `node scripts/check-adr-0087-registration.mjs --base origin/main`, exit 0. - **Dispatch gates:** `node scripts/pm/dispatch-gates.mjs --commands` derived 84 commands, and all 84 were run once on `d8644927b`, each exit captured before any pipe. One, `check-plugin-teardown-shape --self-test`, exited 3 (PREREQUISITE NOT MET: the shallow clone could not read its pinned fixture commit). After that commit was fetched it was re-run and exited 0. `--ran` over the record with that re-run: 84 derived, 84 run, 0 NOT-MEASURED, 0 UNRUN, every exit 0. - **Size:** 53 files, +3377 −125, 3502 changed lines against `776474e8b`, over 3000. - **Dogfood battery:** on `32f380061`, alone under `bash scripts/pm/os-verify-lock.sh -c 'pnpm --filter @objectstack/dogfood test'`: 455 files passed and 3 skipped; 3814 tests passed and 42 skipped; `VERDICT command-exit 0`, lock held 2079s, waited 0s. CI on `32f380061`: 70 check runs, 57 success, 13 skipped, none failed. - **On `28b37fbb7`** (after the `776474e8b` merge and the `servedFromDisabledHolder` fix): `pnpm build` exit 0; metadata 1961 passed; metadata-protocol 22786 passed, 36 skipped; runtime 10238 passed, 19 skipped; core `security-catalog` and `resolve-authz-context.grant-set-by-name` 63 passed; rest `meta-disabled-package-doors` and `meta-qualified-item-route` 172 passed; typecheck of metadata-protocol, metadata, runtime, core and rest exit 0; eslint on the two changed files exit 0. The dogfood battery is not re-run here; the merge queue runs its Dogfood Gate. - **Ablation of this round's pins** (on this head's sources; each change reverted in place, the dependent package rebuilt where a suite reads its `dist`, then restored and rebuilt). Every CONTROL stays green under every ablation. | Change reverted | Pins | Red under ablation | |:--|:--|:--| | `judgePicklistArrival`'s two `includeDisabledPackages: true` | objectql `registry-bare-name-one-holder.test.ts` | 4 of 90 (the two arrival cases, both orders) | | runtime `flow-slot-view.ts` `EVERY_HOLDER` | runtime `flow-caller-package.test.ts` parity pins | 6 of 28 (every parity case) | | `bareNameRefusal` over every holder | same | 6 of 28 | | `admitAutomationAddress`'s shared branch | same | 6 of 28 | | engine `heldByMany` over every holder | service-automation `flow-slots-per-package.test.ts` | 4 of 51 (the boot-disable cases) | | engine `sharedFlowNameRefusal` over every holder | same | 2 of 51 | | engine `resolveFlowKey`'s shared branch | same | 10 of 51 | | `servedFromDisabledHolder` over every holder (`28b37fbb7`) | runtime `action-package-addressing.test.ts` | 1 of 67 (`[#32560] the disabled B's customization …`) | | `flowDispatchHolder` over every holder | service-automation `stored-reference-package-column.test.ts` and the two flow-slot files | 1 of 89 (`R10 at the trigger`) | | `packageLessRowOwners` judging every holder at the exact read | objectql `package-scoped-exact-qualifier.test.ts`, `-t 32183` | 16 red, the four new `action` pins among them | | core `resolvePermissionScoped`'s `includeDisabledPackages: true` | core `security-catalog.test.ts` | 5 of 40 (the four new pins, both orders, and the existing not-found pin for a resolved disabled set) | | core `holdsPlatformPermissionSet`'s `includeDisabledPackages: true` | same | 2 of 40 (both orders) | - **Round 2's, round 3's and round 4's ablations** are not repeated: this round touched none of their arms. ## Human Minimum - [x] 1. `packages/spec` is not touched. - [x] 2. New names follow their kind's casing. - [x] 3. No formatter ran; eslint is clean on the touched packages. - [x] 4. One issue, one branch (#32327's history, `main` merged at `f0f729e7`, then #32214's branch at `27abd458a`, then `main` at `216674301` after #32214 landed, then `main` at `5f84ef0ec` after #32513 landed), one PR. - [x] 5. The changeset is `patch` for the twelve packages whose `src` moves, with the BREAKING banner, before → after lines and the ADR-0087 disposition. Both declaration lines are here and in it. - [x] 6. Not applicable (`packages/spec` untouched). - [x] 7. No hand edits to generated docs or changelogs. - [x] 8. Title and body are in English, except the maintainer digest the project requires. 🤖 Generated with [Claude Code](https://claude.com/claude-code) https://claude.ai/code/session_01L6bhgTkccuWPuLpWbpBTVu <!-- signed: epic:#31527#1 · os-sales · session_01L6bhgTkccuWPuLpWbpBTVu --> <!-- signed: epic:#31527#1 · os-sales · session_01L6bhgXQnNkXTT1Wu7i7Y3i --> --------- Co-authored-by: Claude <noreply@anthropic.com> Co-authored-by: objectstack-fleet[bot] <332303061+objectstack-fleet[bot]@users.noreply.github.com>
1 parent ada6a42 commit 0763bf6

53 files changed

Lines changed: 3377 additions & 125 deletions

File tree

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

‎.changeset/32183-disabled-package-holds-no-name.md‎

Lines changed: 88 additions & 0 deletions
Large diffs are not rendered by default.

‎packages/cli/src/utils/stored-package-references.literal-namespace.test.ts‎

Lines changed: 58 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -74,6 +74,36 @@ describe('the upgrade report names an installed package under an address-literal
7474
});
7575
});
7676

77+
describe('#32183 — the stored-reference report judges every holder, as the backfills do', () => {
78+
const A = 'com.acme.alpha';
79+
const B = 'com.acme.beta';
80+
81+
// [contract review S2] Both registration orders.
82+
it.each([['enabled first', [A, B]], ['disabled first', [B, A]]] as const)('a row naming a template two packages hold stays refused while one of them is disabled, naming both (%s)', async (_order, order) => {
83+
for (const [id, namespace] of [[A, 'alpha'], [B, 'beta']]) registry.installPackage(manifest(id, namespace), 'marketplace');
84+
for (const id of order) {
85+
registry.registerItem('email_template', { name: 'shared_notice', label: 'n', subject: 'n', body: 'n', locale: 'en-US' }, 'name' as never, id);
86+
}
87+
registry.sealBareNameHolders();
88+
registry.disablePackage(B);
89+
vi.spyOn(registry, 'getObject').mockImplementation(((name: string) => (name === 'sys_email_template' ? { name } : undefined)) as never);
90+
let asked = 0;
91+
const engine = {
92+
find: async (table: string) => (table === 'sys_email_template' && asked++ === 0
93+
? [{ id: 't1', name: 'shared_notice', package_id: null }]
94+
: []),
95+
} as never;
96+
97+
const answer = await collectStoredPackageReferences(engine, registry as unknown as StoredReferenceRegistry);
98+
expect(answer.stored).toEqual([
99+
expect.objectContaining({
100+
d8: 'R20', table: 'sys_email_template', id: 't1', name: 'shared_notice', reason: 'ambiguous',
101+
candidates: order.map((packageId) => expect.objectContaining({ packageId })),
102+
}),
103+
]);
104+
});
105+
});
106+
77107
/**
78108
* [#31699 F2, the epic's ruling] A locale Studio added in an App's pair, which
79109
* two packages of the App both ship the template of, cannot say whose member
@@ -132,6 +162,15 @@ describe('[#31699 F2] the upgrade report lists a pair member row two holders cou
132162
}]);
133163
});
134164

165+
it('[#32183] one of the two holders disabled: the row is still listed naming both (the report reads every holder)', async () => {
166+
tpl(X);
167+
tpl(Y);
168+
pairRow();
169+
registry.disablePackage(Y);
170+
expect((await collectStoredPackageReferences(engine, carrying())).pairMembers.map((f) => f.candidates.map((c) => ('packageId' in c ? c.packageId : c.holder))))
171+
.toEqual([[X, Y]]);
172+
});
173+
135174
it('CONTROL: one holder of the pair, or a row that declares its base, is not listed', async () => {
136175
tpl(X);
137176
pairRow();
@@ -206,6 +245,15 @@ describe('[#31699] the upgrade report lists a package-less row two holders could
206245
]);
207246
});
208247

248+
it('[#32183] one of the two holders disabled: the package-less row is still listed naming both (the report reads every holder)', async () => {
249+
tpl(X);
250+
tpl(Y);
251+
envRow('row_fr', 'email_template', 'welcome', 'fr-FR');
252+
registry.disablePackage(Y);
253+
expect((await collectStoredPackageReferences(engine, carrying())).packageLessRows.map((f) => f.candidates.map((c) => ('packageId' in c ? c.packageId : c.holder))))
254+
.toEqual([[X, Y]]);
255+
});
256+
209257
it('[#32407] a narrowed type its readers do not read by package (`action`) is listed too', async () => {
210258
for (const id of [X, Y]) {
211259
registry.registerItem('action', { name: 'approve', label: 'Approve', type: 'url', target: 'https://example.com' }, 'name' as never, id);
@@ -221,6 +269,16 @@ describe('[#31699] the upgrade report lists a package-less row two holders could
221269
}]);
222270
});
223271

272+
it('[#32183 × #32407] one of two holders of a narrowed type (`action`) disabled: the package-less row is still listed naming both', async () => {
273+
for (const id of [X, Y]) {
274+
registry.registerItem('action', { name: 'approve', label: 'Approve', type: 'url', target: 'https://example.com' }, 'name' as never, id);
275+
}
276+
envRow('row_act', 'action', 'approve');
277+
registry.disablePackage(Y);
278+
expect((await collectStoredPackageReferences(engine, carrying())).packageLessRows.map((f) => f.candidates.map((c) => ('packageId' in c ? c.packageId : c.holder))))
279+
.toEqual([[X, Y]]);
280+
});
281+
224282
it('CONTROL: one holder, or a row bound to a package, is not listed', async () => {
225283
tpl(X);
226284
envRow('row_fr', 'email_template', 'welcome', 'fr-FR');

‎packages/cli/src/utils/stored-package-references.ts‎

Lines changed: 16 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -318,9 +318,18 @@ function fieldsOf(reference: StoredPackageReference, packageColumnPresent = true
318318
return [...fields];
319319
}
320320

321-
/** Ask the one rule, as the reference's backfill asks it. */
321+
/**
322+
* Ask the one rule, as the reference's backfill asks it: over every holder, a
323+
* disabled package's included (#32183), since a binding never moves with a
324+
* reversible disable. Every D8 backfill this report covers asks that way: the
325+
* flow rows (R7–R10) through the automation engine's `durableFlowHolder`, the
326+
* connector row (R11) through its resolver with `includeDisabledPackages`,
327+
* the rest through objectql's resolver or the registry's holder read with it.
328+
* So a row resolved here is one the next boot binds, its package disabled or
329+
* not.
330+
*/
322331
function ask(registry: StoredReferenceRegistry, type: ReferencedType, name: string, callerPackageId: string | null): PackageScopedResolution {
323-
return resolvePackageScopedName(registry, { type, name, callerPackageId });
332+
return resolvePackageScopedName(registry, { type, name, callerPackageId, includeDisabledPackages: true });
324333
}
325334

326335
/** The report's reading of a refusal (module doc). */
@@ -442,7 +451,10 @@ async function ambiguousPairMemberRows(engine: StoredReferenceEngine, registry:
442451
const pairId = row.package_id;
443452
if (id === null || id === undefined || typeof type !== 'string' || !types.includes(type) || typeof name !== 'string') continue;
444453
if (row.state !== 'active' || typeof pairId !== 'string' || !isCustomizationPackage(pairId)) continue;
445-
const owners = pairMemberOwners(pairId, registry.packageScopedHoldersOf(type, name) ?? [], installed, storedBody(row.metadata));
454+
// [#32183] Every holder, a disabled package's included: the report is a
455+
// durable judgment, so its listing never moves with a reversible disable.
456+
const every = registry.packageScopedHoldersOf(type, name, null, { includeDisabledPackages: true }) ?? [];
457+
const owners = pairMemberOwners(pairId, every, installed, storedBody(row.metadata));
446458
if (owners.length < 2) continue;
447459
findings.push({
448460
table: 'sys_metadata', id: String(id), type, name,
@@ -474,7 +486,7 @@ async function ambiguousPackageLessRows(engine: StoredReferenceEngine, registry:
474486
const { id, type, name } = row;
475487
if (id === null || id === undefined || typeof type !== 'string' || !types.includes(type) || typeof name !== 'string') continue;
476488
if (row.state !== 'active' || (row.package_id !== null && row.package_id !== undefined && row.package_id !== '')) continue;
477-
const owners = packageLessRowOwners(registry as never, type, name);
489+
const owners = packageLessRowOwners(registry as never, type, name, { includeDisabledPackages: true });
478490
if (owners.length < 2) continue;
479491
findings.push({
480492
table: 'sys_metadata', id: String(id), type, name,

‎packages/core/src/security/security-catalog.test.ts‎

Lines changed: 108 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@
33
import { describe, it, expect, vi } from 'vitest';
44
import {
55
createSecurityCatalogReader,
6+
holdsPlatformPermissionSet,
67
resolveCatalogReference,
78
storedPermissionSetScope,
89
type SecurityCatalogEntry,
@@ -265,7 +266,12 @@ describe('security catalog read — permission sets by (package, name) through t
265266
throwOnHolders?: boolean;
266267
}
267268

268-
/** The by-name reads of {@link registry}, plus the package-scoped reads a `SchemaRegistry` carries. */
269+
/**
270+
* The by-name reads of {@link registry}, plus the package-scoped reads a
271+
* `SchemaRegistry` carries — its served holders too (#32183): a disabled
272+
* package holds no name, the caller's own holding aside, unless
273+
* `includeDisabledPackages` asks for every holder.
274+
*/
269275
function scopedRegistry(
270276
byName: Record<string, Def[]>,
271277
opts: ScopedOptions = {},
@@ -278,10 +284,14 @@ describe('security catalog read — permission sets by (package, name) through t
278284
return {
279285
...registry(byName, { disabled: opts.disabled }),
280286
asked,
281-
packageScopedHoldersOf(type, name, caller) {
287+
packageScopedHoldersOf(type, name, caller, options) {
282288
if (opts.throwOnHolders) throw new Error('registry gone');
289+
// `asked` records every holder read of a permission set; each one is
290+
// over every holder (#32183, the fixed exception).
283291
if (type === 'permission') asked.push({ name, caller });
284-
return held(type, name).filter((h) => h.packageId !== null).map((h) => h.packageId as string);
292+
const disabled = new Set(opts.disabled ?? []);
293+
return held(type, name).filter((h) => h.packageId !== null).map((h) => h.packageId as string)
294+
.filter((id) => options?.includeDisabledPackages === true || id === caller || !disabled.has(id));
285295
},
286296
getPackageScopedItem: (type, name, packageId) => held(type, name).find((h) => h.packageId === packageId)?.item,
287297
getEnvironmentScopedItem: (type, name) => held(type, name).find((h) => h.packageId === null)?.item,
@@ -534,4 +544,99 @@ describe('security catalog read — permission sets by (package, name) through t
534544
expect(r.asked).toEqual([]);
535545
});
536546
});
547+
548+
/**
549+
* [#32183] The fixed exception (`resolvePermissionScoped`): a permission set
550+
* is judged over EVERY holder, a disabled package's included, so a disable
551+
* never makes a grant confer more. `main` (5f84ef0ec) read every holder here
552+
* alike, so these answers are `main`'s, pinned as parity: with HR disabled,
553+
* every grant answers as it does with HR enabled. One answer differs from
554+
* `main` and is this PR's: a column naming the disabled holder confers
555+
* nothing and is never re-targeted (`main` read it as stale and refused it
556+
* naming both; not-found here).
557+
*/
558+
// [contract review S2] Both registration orders: the holders as listed, and reversed.
559+
describe.each([
560+
{ order: 'crm registered first', reversed: false },
561+
{ order: 'hr registered first', reversed: true },
562+
])('#32183 — a disabled holder still counts for a permission set (the fixed exception), $order', ({ reversed }) => {
563+
const CRM = 'com.acme.crm';
564+
const HR = 'com.acme.hr';
565+
const GONE = 'com.acme.gone';
566+
const SYS = 'com.objectstack.kernel';
567+
const ordered = <T>(holders: T[]): T[] => (reversed ? [...holders].reverse() : holders);
568+
const held = (name: string, packageId: string, label = packageId) => ({ packageId, item: { name, _packageId: packageId, label } });
569+
const catalog = (disabled: readonly string[]) => scopedRegistry({}, {
570+
packages: { [P]: {}, [CRM]: {}, [HR]: {}, [GONE]: {}, [SYS]: { namespace: 'sys' } },
571+
disabled,
572+
holders: {
573+
qa_reader: ordered([held('qa_reader', CRM), held('qa_reader', HR)]),
574+
hr_only: [held('hr_only', HR)],
575+
admin_set: ordered([held('admin_set', SYS), held('admin_set', HR)]),
576+
sys_only: [held('sys_only', SYS)],
577+
},
578+
});
579+
const reader = (disabled: readonly string[], logger?: { warn: (...args: unknown[]) => void }) => createSecurityCatalogReader({
580+
registry: catalog(disabled),
581+
metadata: metadata({ permission: [{ name: 'hr_only', label: 'a metadata-service body of that name' }] }),
582+
...(logger ? { logger } : {}),
583+
});
584+
/** The grants a stored row or a position makes of `name`: no column, a null column, a stale column, a caller outside every holder. */
585+
const grantsOf = async (disabled: readonly string[], name: string) => {
586+
const r = reader(disabled);
587+
return {
588+
'no column': await resolveCatalogReference(r, 'permission', name),
589+
'null column': await resolveCatalogReference(r, 'permission', name, storedPermissionSetScope(null)),
590+
'stale column': await resolveCatalogReference(r, 'permission', name, storedPermissionSetScope(GONE)),
591+
'caller outside': await resolveCatalogReference(r, 'permission', name, at()),
592+
};
593+
};
594+
const namesOf = (answer: unknown) => (answer as { candidates?: string[] }).candidates;
595+
596+
it('⛔ two holders, HR disabled: no column, a stale column and a caller outside both confer nothing, refused naming both, as re-enabled', async () => {
597+
const disabled = await grantsOf([HR], 'qa_reader');
598+
expect(disabled).toEqual(await grantsOf([], 'qa_reader'));
599+
// CONTROL: what that answer is (`main`'s).
600+
for (const answer of Object.values(disabled)) {
601+
expect(answer.status).toBe('refused');
602+
expect(namesOf(answer)).toEqual(ordered([expect.stringContaining(CRM), expect.stringContaining(HR)]));
603+
}
604+
expect(disabled['caller outside']).toMatchObject({ reason: 'outside-closure' });
605+
});
606+
607+
it('⛔ a column naming the disabled holder confers nothing: not-found, never re-targeted to the enabled holder, and not said stale', async () => {
608+
const warn = vi.fn();
609+
const r = reader([HR], { warn });
610+
expect(await resolveCatalogReference(r, 'permission', 'qa_reader', storedPermissionSetScope(HR))).toEqual({ status: 'not-found' });
611+
expect(await r.resolve('permission', 'qa_reader', storedPermissionSetScope(HR, P))).toBeUndefined();
612+
expect(warn).not.toHaveBeenCalled();
613+
// CONTROL: the enabled holder's column reads its set; re-enabled, HR's column reads HR's.
614+
expect((await r.resolve('permission', 'qa_reader', storedPermissionSetScope(CRM)))?.definition.label).toBe(CRM);
615+
expect((await reader([]).resolve('permission', 'qa_reader', storedPermissionSetScope(HR)))?.definition.label).toBe(HR);
616+
});
617+
618+
it('⛔ a name only the disabled HR holds: counted, so a caller outside is refused naming it, and no grant resolves to its set, never the metadata service\'s by-name body', async () => {
619+
const disabled = await grantsOf([HR], 'hr_only');
620+
expect(disabled['no column']).toEqual({ status: 'not-found' });
621+
expect(disabled['null column']).toEqual({ status: 'not-found' });
622+
expect(disabled['caller outside']).toMatchObject({ status: 'refused', reason: 'outside-closure' });
623+
expect(namesOf(disabled['caller outside'])).toEqual([expect.stringContaining(HR)]);
624+
expect(await resolveCatalogReference(reader([HR]), 'permission', 'hr_only', storedPermissionSetScope(HR))).toEqual({ status: 'not-found' });
625+
// CONTROL: re-enabled, the caller outside is refused alike, and a grant with no column reads HR's set.
626+
const enabled = await grantsOf([], 'hr_only');
627+
expect(enabled['caller outside']).toEqual(disabled['caller outside']);
628+
expect(enabled['no column']).toMatchObject({ status: 'resolved', entry: { definition: { label: HR } } });
629+
});
630+
631+
it('holdsPlatformPermissionSet: two holders with one disabled hold nothing, as re-enabled; a name only a disabled package holds is no identity', () => {
632+
const holds = (disabled: readonly string[], name: string) => holdsPlatformPermissionSet({ registry: catalog(disabled) }, { permissions: [name] }, name);
633+
expect(holds([HR], 'admin_set')).toBe(false);
634+
expect(holds([], 'admin_set')).toBe(false);
635+
expect(holds([HR], 'qa_reader')).toBe(false);
636+
expect(holds([HR], 'hr_only')).toBe(false);
637+
// CONTROL: the platform's sole holder is its identity; a name the registry holds nowhere answers as a by-name read did.
638+
expect(holds([HR], 'sys_only')).toBe(true);
639+
expect(holds([HR], 'nowhere')).toBe(true);
640+
});
641+
});
537642
});

0 commit comments

Comments
 (0)