Skip to content

Commit 89d5a41

Browse files
fix(metadata-protocol)!: an exact ?package= read answers its own package's item or a 409 naming the holders, and a bare doc read beside two holders serves the environment's own entry (#34347)
<!-- claude-projects-attribution: {"github_login":"zhuangjianguo"} --> _Requested by **Steedos** · [project thread](https://claude.ai/code/project/chan_018ETKaNwMZCNRYD7D8Q9Ubb?thread=cmsg_018ETKaNwMZCNRYD7D8Q9UbbBePzY6g11h3hyWk5ud4vWy)_ Fixes #34247 Part of #34248 (delivered here; the area closes it on merge, as with PR #34324) Clause-②: no (narrowing) Metadata-protocol: none Skills-docs: none — no skill teaches a moved answer: `skills/**` teaches `?package=` reads of a holder or of its pair (objectstack-platform SKILL.md, "Customizing an installed package"), which do not move, and never the read of a package that holds no item of the name or the bare doc read beside a package-less entry > **BREAKING.** Served answers become refusals. `?package=X` of a name X ships no item of, while another package ships it, now answers `409 RESOURCE_CONFLICT`, reason `not-held-by-qualifier`, with `details.candidates` naming the holders (ruling 6917064203 on #34398), on the plain read and `/layers`. A name nothing holds stays 404. The read gate answers before the `not-held-by-qualifier` refusal names any holder: a caller the ADR-0046 §6.7 docs audience refuses a `doc` gets the gate's 401/403, and a member the list view audience refuses a `view` gets the gate's 403. The bare doc read of a name two enabled packages ship, beside the environment's own package-less entry, now serves that entry instead of the package registered last. ADR-0087 disposition: `not-required (no-migration-prescription)` (in the changeset). No schema key, stored row or registry slot changes. ## 维护者速读 - 改了什么:带 `?package=X` 读取文档、视图等 8 类元数据时,如果 X 没有这个名字而别的包有,返回 409 `not-held-by-qualifier` 并列出持有包,不再返回别的包的内容;谁都没有的名字仍是 404。`/layers?package=X` 同样处理。文档和视图先过各自的门禁:文档受众门禁拒绝的成员和匿名访问者拿到门禁自己的 403/401,视图受众门禁(`requiredPermissions`)拒绝的成员拿到 403,门禁放行的才拿到 409。两个包都发布同名文档、环境里又有一条无包条目时,不带包名的读取(普通读取、`/layers`、`/published`)返回这条环境条目。Console 文档页和扁平永久链接(跨文档引用都改写到它)在应用包不持有该文档时改为按名字读,跨包引用照常显示,或显示持有包的受众拒绝。 - 为什么改:ADR-0150 D3/D5 规定精确地址只回答该持有者;裁决 6917064203(#34398)定为 409 并列出持有者;裁决 6893582352 规定环境自己的条目优先。原来包名写错的作者会悄悄拿到别的包的内容。 - 风险与回滚:200→409 是收窄(BREAKING),只影响"包名不持有、别的包持有"的地址;环境条目那一行是 200→200 换内容。持有者自己的地址、配对包地址、无包条目、`object`、已覆盖类型、`position`/`capability` 都不变。回滚即 revert 本 PR。 - 先看:`packages/metadata-protocol/src/protocol-meta-item-reads.ts`(`registryAnswerAtAddress` 的拒绝分支与安全目录排除)、`packages/rest/src/meta-item-read-gate.ts`(`gateHolderNamingRefusal`,门禁先于拒绝)、`ui/apps/console/src/pages/DocsSlug.tsx` 与 `doc-address.ts`(按名字回退)。 - 两分钟验证:`pnpm --filter @objectstack/runtime exec vitest run --maxWorkers=2 src/domains/meta-holder-refusal-audience-gate.test.ts src/domains/meta-disabled-holder-artifact-door.test.ts`,预期 58 通过、4 跳过(两个文件合计);文档门禁拒绝的成员得 403、匿名得 401,视图门禁拒绝的成员得 403,放行者得 409 并列出持有包,`[#34247]` 组在四种装配下非持有包地址返回 409,`[#34248]` 各条在两种注册顺序下三个入口一致。 - 需要你做的:无,席位落地。 ## What changes **#34247 (exact address, X holds no item of the name).** PR #34241 made step 2 of `readMetaItem` decline the metadata service's copy of another package at `?package=X`, for the types the exact qualifier (ADR-0150 D5) does not judge. When X held no item of the name, step 3 still read `getItem`, whose last tier is the first composite across packages, so the address answered another package's item. Now the code layers' answer at such an address goes through `registryAnswerAtAddress`. An item stamped with another installed package (the same test as `serviceCopyOfAnotherPackage`: not X, not a customization pair either way) is replaced by the registry's package slot for X. When X has no slot: - If other packages hold the name, the read is refused `409 RESOURCE_CONFLICT`, reason `not-held-by-qualifier`, `details.candidates` naming each holder (`notHeldByQualifierRefusal` in `protocol-exact-qualifier.ts`). This is the refusal the covered types already answer, and it uses existing vocabulary only (ruling 6917064203 on #34398). - If nothing holds the name, the answer is nothing, and the door answers its own 404. - A qualifier that names no installed package (the Console's app-name segment) gets the same answer (ruling item 3). - The read gate answers before the `not-held-by-qualifier` refusal names any holder (`gateHolderNamingRefusal` in `@objectstack/rest`, asked by both transports' plain read and `/layers` read). For a `doc`, the ADR-0046 §6.7 docs gate judges a doc by its name, so it needs no holder's item: a caller it refuses gets the gate's `403 PERMISSION_DENIED`, or `401 UNAUTHENTICATED` when anonymous. For a `view`, the list view audience gate (`filterViewForUser`) judges a view by its body, so every holder the refusal names is read at its own address (a package at its `?package=`, the environment's own item at the address naming no package) and judged: a member it refuses for any one of them gets the gate's `403 PERMISSION_DENIED`. A holder that cannot be read fails closed: both transports' plain read and `/layers` answer the same `500 INTERNAL_ERROR`, which names no holder. A caller the gate admits gets the 409. The family is the eight types PR #34241 enumerated: `doc`, `view`, `translation`, `field`, `seed`, `datasource`, `external_catalog`, `object_extension`. The security catalog types `position` and `capability` are excluded in code (`isSecurityCatalogType`, ADR-0131 D3). The registry keeps one package holder of such a name, so their code layers' answer is unchanged. A CONTROL pin for each type proves it. **Aligned in the same direction.** - `getMetaItemLayered` (`/layers?package=X`): the code layer declines the service's copy of another package and reads X's own item. At an address X holds none of, it gives the same refusal as the plain read (ruling item 2). - `readCodeLayerForCarryForward` (the save's credential carry-forward, read when no stored row is at the address the save writes): the same decline and the same registry answer, but it **keeps "carries none"**. It does not refuse (ruling item 2 leaves this choice open). The reason: the carry-forward is no read answer. The save door already judges the address on its own path, and a refusal here would turn a save that main accepted into a 409 for a reason the save door never names. Of the family only `datasource` has a credential redactor, so only a datasource save moves. It carried the credential of the package the service kept (or of the first registered holder). It now carries X's own, or none when X ships no datasource of the name. **#34248 (bare doc read beside a package-less entry).** Take two enabled holders and a package-less entry in the registry's bare slot. The registry exempts the bare doc read from PR #34036's refusal and serves the entry, and so does `MetadataFacade.get`. The protocol's plain read, `/layers` and `/published` served the metadata service's copy instead, which is the holder registered last. Now the environment's entry answers first (ruling 6893582352) on every bare door: - `refuseAmbiguousBareDocRead` still refuses two holders with no such entry (409, as on main). When an entry sits beside two or more enabled holders, it returns that entry. - `readMetaItem` step 2 and the layered read decline a package-stamped service copy in that case (`bareDocServiceCopyDisplacesEntry`). - With no overlay stored, both `/published` doors (`packages/runtime/src/domains/meta.ts` and `packages/rest/src/meta-item-history-routes.ts`, about four lines each, beside the #32183 `mixedOwner` swap) serve the layered read's answer in place of a package-stamped service copy. **Review M1: the hydrated row as the hydrator lays it.** `hydrateOverlayIntoRegistry` stamps a package-less stored row `_provenance: 'org'` with no `_packageId` (`stateTenantAuthorship`). Such an entry is tenant-authored, so it is never the code layer (#21059). At `989f4ad7` the plain read served the row while `/layers` answered `effective: null`, because the sealed doc's package-less row was declined. Both `/published` doors served 200 with an empty body. Now the layered read lets the environment's row answer when the bare slot holds that row's tenant-authored entry and no code layer (`environmentRowAnswers`: the entry is tenant-authored and `code` is null). `/layers` reports `code: null` with the row as `overlay` and `effective`, and both `/published` doors serve the row, consistent with the plain read. The same row hydrated **after** the artifacts registered (`loadMetaFromDb`, and boot hydration after the artifact door) wears the first registered holder's envelope (`mergeArtifactProtection` grafts it: `_packageId` = first holder, `_provenance: 'package'`). No package-less entry exists then, and the bare doors stay refused 409 naming both, as on main. Both orders are pinned on the composed rig. **Review S4: a stamp-less entry beside a different stored row.** `environmentRowAnswers` first held for any bare-doc environment entry beside a package-less stored row. With a stamp-less runtime registration (a code layer) and a different package-less stored row, `/layers` `effective` and both `/published` doors moved to the row while the plain read kept the entry. It now holds only where the entry is the row's tenant-authored copy (`code` is null). In the mixed state all three doors serve the registration, with the row as `/layers` `overlay`, as at `989f4ad7`. Pinned in both orders. **Review S1: one holder beside a stamp-less entry.** I took the minimal option: pin the cell and declare it. The bare doors serve the holder's doc while the registry's `resolveItem` serves the entry. The test is `[measured, unresolved]` and it runs for each one-holder composition. The cell stays out of scope because card #34248's acceptance names two or more holders, and ruling 6893582352 was argued beside two holders. Moving the one-holder cell would change a 200 answer that no card or ruling names. It is declared in the changeset under "Not moved". Follow-up card: #34452 (needs a ruling first). **Review M2 and ruling item 6: the Console doc doors.** Two Console doors read a doc under the route's package segment, with X as ADR-0048 prefer-local context: the reader (`DocPage`, `/apps/X/docs/BOOK/NAME`) and the flat permalink (`DocsSlug`, `/apps/X/docs/NAME`, which every cross-reference is rewritten to by `doc-links.ts`). The permalink's single-item read (objectui#10188) tells a name the member may not read from an absent one. When either read answers the `not-held-by-qualifier` 409 (X not among the candidates) or a 404, the door now reads the name again by name. Both share one rule, `readsByNameAfter` in `ui/apps/console/src/pages/doc-address.ts`. The result: - A cross-reference from X's docs to another package's doc renders that doc, as on main. - The app-name segment of a package that ships several apps (which names no package) renders the doc's one holder, as on main. - On the flat permalink, a doc the member may not read renders its holder's audience refusal (`DocRefusal`), as on main, for both segment kinds. Before this round it fell to the name-prefix redirect or "Documentation not found". - A name two other packages ship shows the candidate list (#34070), where main showed one of them by registration order. A 404 stays the page's "not found" (not turned into a refusal). Opening the single named holder directly is left as the optional follow-up the ruling names. ## FROM → TO | Read | FROM (main) | TO | |---|---|---| | `GET /meta/doc/NAME?package=X`, X ships no doc of NAME (installed, or not installed), another package does; dispatcher and REST, both registration orders | 200, a holder's doc | 409 `RESOURCE_CONFLICT`, `details.candidates` = the holders (ruling 6917064203 on #34398) | | same address for `view`, `translation`, `field`, `seed`, `datasource`, `external_catalog`, `object_extension` | 200, a holder's item | 409 `not-held-by-qualifier` naming the holders | | `?package=X` of a name no package holds, any of the eight types | 404 | unchanged | | `GET /meta/doc/NAME?package=X` and `/layers`, X ships none, another does, caller refused by the ADR-0046 §6.7 docs audience; both transports | 403 `PERMISSION_DENIED` (401 `UNAUTHENTICATED` anonymous): the gate on the holder's doc | unchanged: the gate answers before the 409 | | `GET /meta/view/NAME?package=X` and `/layers`, X ships none, another does, a member the list view audience (`requiredPermissions`) refuses; both transports | 403 `PERMISSION_DENIED`: the gate on the holder's view | unchanged: the gate answers before the 409 | | `GET /meta/doc/NAME/layers?package=X`, X ships none, another does | 200, a holder's `code` and `effective` | 409, as the plain read | | `GET /meta/doc/NAME/layers?package=X`, X and Y ship NAME, Y registered last | 200, Y's `code` and `effective` | 200, X's | | bare `GET /meta/doc/NAME`, `/layers`, `/published`, two enabled holders plus a stamp-less bare entry; both transports, both orders | 200, the holder registered last | 200, the entry (`/layers`: `code` and `effective`) | | same, with a different package-less stored row beside the stamp-less entry | 200, the holder registered last | 200, the entry on all three doors (`/layers`: the entry as `code` and `effective`, the row as `overlay`) | | same, with a package-less stored row hydrated before the artifacts (`_provenance: 'org'` entry) | see "Hydration readings" below | 200, the row (`/layers`: `code: null`, the row as `overlay` and `effective`) | | same row hydrated after the artifacts (envelope grafted from the first holder) | 409 naming both | unchanged | | same name, two holders, no package-less entry | 409 naming both | unchanged | | save naming X of a `datasource` with no stored row at X (credential carry-forward) | carries another holder's credential | carries X's own credential, or none (never refuses) | | Console reader `/apps/X/docs/BOOK/NAME`, X ships none of NAME | the doc one holder ships (or one of two by registration order) | the doc one holder ships; two holders show the candidate list | | Console flat permalink `/apps/X/docs/NAME` (cross-references), X ships none of NAME, a doc the member may not read | the holder's audience refusal | unchanged (read again by name after the 409) | | a holder's own address; a pair's address of its base's item; an item bound to no package; `object`; `position` and `capability`; one holder beside a stamp-less entry (measured, unresolved); any other read naming no package | as on main | unchanged | | the covered types (`action`, `hook`, `job`, `sharing_rule`, `queue`, `assignment_rule`) at a third package | 409 `not-held-by-qualifier` | unchanged | ## Hydration readings (dispatch task 1; review M1) Measured with the real hydrator on the composed artifact rig (`MetadataPlugin` artifact door plus `AppPlugin`, SQL driver, a stored package-less `sys_metadata` row of a doc two packages ship), on the dispatcher and on `RestServer`, in both registration orders. Scratch test files were not committed. - **Hydrated after the artifacts** (boot hydration, and `loadMetaFromDb` after the artifact door): the entry carries the first holder's `_packageId` with `_provenance: 'package'`. The bare doors answer 409 naming both. The answer is identical at origin/main `c934631723` and at head `72dc8ca25e`, and it stays so at this head (CONTROL pin). The save door answers 403 `NOT_OVERRIDABLE`, so no new row is stored. - **Hydrated before the artifacts** (the hydrator's own `_provenance: 'org'` entry): measured at the merge base `6cc3f97465` (main as this PR forks it) and at this head: | Door | main `6cc3f97465` | head `de137717ef` | |---|---|---| | bare plain read, both transports | 200, the holder registered last (`beta doc` with alpha first, `alpha doc` with beta first) | 200, `environment doc` (the row) | | bare `/layers` | 200, `code` = the holder registered last, `overlay` = the row, `effective` = the holder registered last | 200, `code: null`, `overlay` and `effective` = the row | | bare `/published`, both doors | 200, the holder registered last | 200, the row | | each holder's own address | its own doc | unchanged | At `989f4ad7` (this PR before the M1 fix) the same state answered: plain read the row; `/layers` `code: null`, `overlay` the row, `effective: null`; both `/published` doors 200 with an empty body. That is the inconsistency M1 named. The head answers are the green pin `[#34248] a hydrated package-less row (hydrated before the artifacts)` in the rig; the M1 ablation turns it red in both orders. - **The exact address of a non-holder** at main `6cc3f97465`, same rig: `?package=com.qa.gamma` (installed, ships none) and `?package=com.qa.unknown` (not installed) answer 200 with a holder's doc. The plain read gives the first composite (`alpha doc` with alpha first, `beta doc` with beta first). `/layers` gives the service's copy (the holder registered last) as `code` and `effective`. With beta alone shipping, `?package=com.qa.alpha` answers 200 `beta doc`. At this head every one of these answers 409 `RESOURCE_CONFLICT` with `details.candidates` = the holders. ## Ruling item 5: the read gate answers first Rule: the read gate answers before the `not-held-by-qualifier` refusal names any holder. At `?package=X` of a doc X holds none of, on the plain read and `/layers` of both transports: - a member the docs audience refuses gets the gate's `403 PERMISSION_DENIED`, with no candidates; - an anonymous caller gets the gate's `401 UNAUTHENTICATED`, with no candidates; - CONTROL: a caller the gate admits gets the `409 RESOURCE_CONFLICT` naming the holders; - CONTROL: a doc of the `org` audience gets the 409 for a member. The same order holds for a `view` at the same address (the list view audience, `requiredPermissions`): a member it refuses gets the gate's `403 PERMISSION_DENIED`, with no candidates; CONTROL: a member it admits gets the 409 naming the holders; CONTROL: at the holder's own address the two members get the gate's 403 and the view. Every holder the refusal names is judged, the environment's own item included: a view only the environment holds answers a member its audience refuses the gate's 403 (CONTROL: an admitted member gets the 409), and a view a package and the environment both hold answers the gate's 403 to a member the package's view admits and the environment's refuses (CONTROL: a member both admit gets the 409). Pinned in `packages/runtime/src/domains/meta-holder-refusal-audience-gate.test.ts`. Its transports and the gate are real; the protocol is a double that throws the protocol's own refusal shape. ## Tests - `packages/objectql/src/package-scoped-exact-qualifier.test.ts`, the #34247 describe (between the #34040 and #34041 describes; #34354's describe is kept intact after the merge). It contains: - the family pin; - per type, in both registration orders, the 409 naming both holders at `?package=` of a third installed package and of `com.acme.unknown`, on the plain read and `getMetaItemLayered`, whichever holder's copy the service keeps; - one holder: another package's address is refused naming that holder, and the holder reads its body; - CONTROLs: a name no package holds is the read's own miss; a pair's read of its base's item and a package-less entry are served; every covered type is still the exact qualifier's 409; `position` and `capability` keep the holder's item (S2); - the datasource carry-forward pin with the real redactor. - `packages/runtime/src/domains/meta-disabled-holder-artifact-door.test.ts` (composed artifact rig, both transports): - over four compositions, the non-holder 409 with `details.candidates` on the plain read and `/layers` for an installed and a non-installed package; - CONTROL: a name no package ships is 404 at any package address; - each holder's own address; - the one-holder CONTROL; - the S1 `[measured, unresolved]` pin; - the #34248 pins: stamp-less entry, hydrated-before-artifacts `_provenance: 'org'` row (M1), a stamp-less entry beside a different package-less stored row (S4: all three doors serve the entry, the row as `overlay`), and the hydrated-after-artifacts CONTROL through the real `loadMetaFromDb`. - `packages/runtime/src/domains/meta-holder-refusal-audience-gate.test.ts` (both transports, the real gate): the gate's 403 for a refused member and 401 for an anonymous caller at `?package=` of a package holding none, on the plain read and `/layers`; CONTROLs: an admitted caller and an `org`-audience doc get the 409 naming the holders. A second describe pins the view gate at the same address on both transports: a member the view audience refuses gets the gate's 403 with no candidates; CONTROLs: a member it admits gets the 409, and the holder's own address answers the two members the gate's 403 and the view. A third describe pins every holder the refusal names, the environment's own item included: a view only the environment holds, and one a package and the environment both hold, each with a refused member's 403 and an admitted member's 409 CONTROL. A fourth describe pins a holder the view gate cannot read: on both transports' plain read and `/layers`, a refused and an admitted member alike get `500 INTERNAL_ERROR` with no candidates; CONTROL: the same address with a holder that reads is the gate's answer (409). The environment-holder pins are driven by candidates the protocol double supplies; for a `view`, the refusal this PR adds names package holders only, so those pins hold the helper's rule rather than a row today's protocol produces (accepted, no contract effect). - `ui/apps/console/src/pages/docs-portal.test.tsx`, "objectstack#34247 — a doc the route's package ships none of is read by name": - a cross-reference renders the other package's doc (reads `['com.example.alpha', undefined]`); - the app-name segment renders its holder's doc; - two holders show the candidate list; - CONTROL: the own package is read only at its address; - CONTROL: a name nobody ships is not found; - the flat permalink (`DocsSlug`), under `WORLD.exact`: a cross-package link to a doc the member may not read renders the holder's refusal (reads `['com.example.alpha', undefined]`), and so does the app-name segment of a multi-app package (reads `['alpha_suite', undefined]`); CONTROL: under the holder's own package it reads that address only. ## Verification Final head `0bc781b5` (taken over by seat repo:objectstack#2 from area o1-D). Since `24a7664b` (L1-b delta ACCEPT 6932779854, review#2 PASS 6932891519) the delta is 7 files: `.changeset`, rest `index.ts`, `meta-item-read-gate.ts`, `meta-item-read-routes.ts`, `rest-server.ts`, runtime `domains/meta.ts` and `meta-holder-refusal-audience-gate.test.ts`. Commits since: `4b5f2e4b`, `0ba6987a` (the sentence narrowed to the refusal the helper judges), `f45378bb` (the view gate answers before the refusal names a holder), `735dd6a9` (one holder reader in the dispatcher that rejects when the protocol has no by-name read), `b6f7c36f` (the view gate judges every holder the refusal names, the environment's own item included; a holder that cannot be read fails closed), `0bc781b5` (the dispatcher's plain read answers an unreadable gate input with the fault status its layered read answers; pinned on both transports). Merge base with origin/main is still `24b6ae5501`; `git merge-tree` against origin/main is clean. Main's one commit on a file of this PR (`protocol-meta-item-reads.ts`, the ADR-0156 compiled-answer cache) caches only reads that name no package, of types other than `doc`, so it does not reach the reads this PR moves. Readings at `0bc781b5`, on a shared box, each heavy run as its own verify-lock call (exit codes captured before any pipe): - Closure build (`turbo run build --filter '@objectstack/dogfood^...'`): exit 0. - `pnpm --filter @objectstack/runtime exec vitest run --maxWorkers=2 src/domains/meta-holder-refusal-audience-gate.test.ts src/domains/meta-disabled-holder-artifact-door.test.ts`: exit 0, Test Files 2 passed, Tests 58 passed, 4 skipped. - typecheck (`NODE_OPTIONS=--max-old-space-size=8192`; at the default heap the runtime test-layer check dies of a V8 heap OOM with no diagnostics): `@objectstack/rest` 0, `@objectstack/runtime` 0. - `pnpm exec vitest run` in `packages/runtime`, every file: exit 0, Test Files 614 passed; Tests 12661 passed, 23 skipped. Same in `packages/rest`: exit 0, Test Files 419 passed; Tests 8864 passed, 373 skipped. (At `b6f7c36f`, `pnpm --filter … test`: runtime 11304 passed, 23 skipped; rest 8564 passed, 350 skipped.) - `dispatch-gates --commands` from the merge base, at `0bc781b5` (the same 79 as at `b6f7c36f`): 79 derived, 79 run to exit 0. `--ran`: "79 derived famil(ies) accounted for — 79 run, 0 NOT-MEASURED". - Dogfood battery (title carries `!`): `pnpm --filter @objectstack/dogfood test`, no shard, no path: exit 0; Test Files 478 passed, 3 skipped (481); Tests 4030 passed, 44 skipped (4074). No failure. Also exit 0 with the same counts at `b6f7c36f`, `735dd6a9`, `f45378bb` and `0ba6987a`. Readings from earlier heads, kept for the record: <details><summary>Builds, typechecks and package suites (exit codes captured before any pipe)</summary> - At `24a7664b`, after `pnpm install --frozen-lockfile`: closure build (`--filter '@objectstack/dogfood^...'`): `VERDICT command-exit 0`. - At `24a7664b`, CI: `TypeScript Type Check` success, `Test Core` and `Test Core (1/8)`–`(8/8)` success, `Type Check UI` success, `Test UI` success. Package suites were not rerun locally this round; the merge brought only main. - At `c47c71b4` (code unchanged since; `2496009b` changed one changeset line): typecheck `metadata-protocol` 0, `objectql` 0, `runtime` 0, `rest` 0. `@objectstack/objectql` test 0 (Test Files 603 passed; Tests 13520 passed). `@objectstack/runtime` test 0 (Test Files 609 passed; Tests 11222 passed, 23 skipped). `@objectstack/metadata-protocol` test 0 (Test Files 346 passed, 9 skipped; Tests 22968 passed, 45 skipped). `@objectstack/rest` test 0 (Test Files 413 passed; Tests 8552 passed, 350 skipped). `@object-ui/console` test 0 (Test Files 322 passed; Tests 3321 passed). `eslint --no-inline-config` on the changed files: 0 errors. `check-platform-checklist --changed-from origin/main`: OK, 36 anchors judged, 0 lost. </details> <details><summary>Derived gate families (dispatch-gates --commands, from the merge base, at 24a7664)</summary> - 79 derived, 78 run to exit 0, `check:nul-bytes`, `check:doc-authoring`, `check:issue-citations` and `check:test-source-alias` among them. `check:type-check-debt` first answered exit 3 while the battery held the verify lock; rerun, it exited 0 ("0 raw tsc error(s) total, none above its recorded number"). - `check:dual-build-cjs-loads` exit 3 (PREREQUISITE NOT MET: no `packages/qa/scenarios/dist`; it needs a full build). NOT MEASURED locally; CI's `Lint & Repo Gates` is success. - `dispatch-gates --ran` (with recorded exit codes): "79 derived famil(ies) accounted for — 78 run, 1 NOT-MEASURED (1 DERIVED from a recorded exit 3)". - Earlier rounds: CI at `8c929a55` was red on `check:test-source-alias`. The new audience-gate pin reached `import('@objectstack/metadata')` through the dispatcher without a module-top load. Fixed at `c47c71b4` by a module-top `import '@objectstack/metadata'` in that test. </details> <details><summary>Ablations (one per guard; each restore proved: blob = HEAD, `git diff HEAD` empty, a protocol marker absent from dist after the final rebuild)</summary> Not rerun: no guard changed after `c47c71b4`. At `8c929a55` and `c47c71b4`: | Guard ablated | Suite | Result | |---|---|---| | G `gateHolderNamingRefusal` (returns nothing) | runtime `meta-holder-refusal-audience-gate.test.ts` | 2 failed: the refused member's 403 and the anonymous 401 (the two CONTROLs stay green) | | DS `DocsSlug` by-name fallback | Console `docs-portal.test.tsx` | 2 failed: the flat permalink's cross-package link and app-name segment | | S4 `code === null && isTenantAuthored(...)` in `environmentRowAnswers` | runtime rig | 2 failed: the mixed-state pin, both orders | - G and DS are in source the suites alias, so no build: the marker was counted in the file (injected 1). - S4 was rebuilt, and its marker was proved present in `@objectstack/metadata-protocol`'s `dist` before the run was read. - The first S4 pass is void and was rerun. Its marker (`'ABL_S4_MARKER' !== ''`) was constant-folded out of `dist`, and the preflight refused it. The rerun used a property-read marker that survives the build: the preflight exited 0, and after the restore `--absent` exited 0 with a clean tree. From `de137717` (guards unchanged since), with the same restore proofs: | Guard ablated | objectql exact-qualifier file | runtime rig | Console docs-portal | |---|---|---|---| | M1 `environmentRowAnswers` (layered read) | — | 2 failed: the hydrated-before-artifacts pin, both orders | — | | S2 `isSecurityCatalogType` exclusion | 2 failed: the `position` and `capability` CONTROLs | — | — | | R1 `refuse` in `readMetaItem` | 26 failed | 4 failed: the non-holder 409 pin, four compositions | — | | R2 `refuse` in the layered read | 16 failed | 4 failed: the non-holder 409 pin, four compositions | — | | UI the by-name fallback in `DocPage` | — | — | 2 failed: the cross-reference and the app-name segment | At `f45378bb`, with the same restore proof (`git checkout HEAD --`, clean `git status --porcelain`, marker count 0): the view arm of `gateHolderNamingRefusal` ablated (the early return kept `doc` alone) turns 1 pin red in `meta-holder-refusal-audience-gate.test.ts`, the refused member's view 403 (1 failed, 6 passed); the source is aliased, so no build. At `b6f7c36f`, same restore proof: the environment's item skipped by the view arm turns exactly 2 pins red, the environment-only and the co-held refused member's 403 (2 failed, 9 passed); the two CONTROLs stay green. At `0bc781b5` (same code as its pre-reword commit), same restore proof: the dispatcher plain read's fault answer removed (the gate's rejection left to the handler's outer catch) turns exactly 1 pin red, the unreadable-holder fault pin (1 failed, 12 passed); its CONTROL stays green. </details> <details><summary>Dogfood battery (title carries `!`)</summary> - Head `24a7664b12`, after the closure build above: `pnpm --filter @objectstack/dogfood test` under its own lock call, no shard, no path. - `os-verify-lock: VERDICT command-exit 0 · held the lock 2265s (37m45s)`. - Test Files 478 passed, 3 skipped (481); Tests 4030 passed, 44 skipped (4074). No failure. - Superseded: at `c47c71b4`, VERDICT command-exit 0; Test Files 474 passed, 3 skipped (477); Tests 4006 passed, 42 skipped (4048). </details> CI at `0bc781b5` when this body was written: 43 check-runs success, 10 skipped, none in progress or failed; all eleven required contexts success. Taken over from repo:objectstack#1 · os-project-manager · session_01FEkQ5obaLbqgzRUR9xXfft. repo:objectstack#2 · os-steve · session_01ADHkmNkZcGApqG4pHHMLeY 🤖 Generated with [Claude Code](https://claude.com/claude-code) https://claude.ai/code/session_01ADHkmNkZcGApqG4pHHMLeY <!-- signed: repo:objectstack#2 · os-steve · session_01ADHkmNkZcGApqG4pHHMLeY --> --------- Co-authored-by: Claude <noreply@anthropic.com> Co-authored-by: objectstack-fleet[bot] <332303061+objectstack-fleet[bot]@users.noreply.github.com>
1 parent 1538596 commit 89d5a41

18 files changed

Lines changed: 1388 additions & 81 deletions
Lines changed: 40 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,40 @@
1+
---
2+
'@objectstack/metadata-protocol': patch
3+
'@objectstack/runtime': patch
4+
'@objectstack/rest': patch
5+
'@object-ui/console': patch
6+
---
7+
8+
fix(metadata-protocol)!: an exact `?package=X` read of a doc, view or other type the exact qualifier does not judge answers X's own item, never another package's: where another package holds the name it is refused 409 `not-held-by-qualifier` naming the holders (ruling 6917064203 on #34398), and a name nothing holds stays 404; a bare doc read of a name two enabled packages ship, beside the environment's own package-less entry, serves that entry, never the package registered last (ADR-0150 D3/D5, red line 2, ruling 6893582352)
9+
10+
Clause-②: no (narrowing)
11+
Metadata-protocol: none
12+
Skills-docs: none — no skill teaches a moved answer: `skills/**` teaches `?package=` reads of a holder or of its pair (objectstack-platform SKILL.md, "Customizing an installed package"), which do not move, and never the read of a package that holds no item of the name or the bare doc read beside a package-less entry
13+
14+
<!-- adr-0087: not-required (no-migration-prescription) No key of any schema is added, removed, renamed or re-shaped, and no export changes shape. The moved answers are by-name reads and one save's code-layer read: no stored row, registry slot or package binding changes, so there is nothing for a migration to rewrite and no tombstone. -->
15+
16+
**BREAKING** for a caller that reads `?package=X` of a name X ships no item of, for the types the exact qualifier does not judge (`doc`, `view`, `translation`, `field`, `seed`, `datasource`, `external_catalog`, `object_extension`). Measured on the composed artifact rig (the `MetadataPlugin` artifact door plus `AppPlugin`), on the dispatcher and on `RestServer`, in both registration orders:
17+
18+
- `GET /meta/TYPE/NAME?package=X`, where X ships no item of NAME and another package does: was 200 with that package's item (the registry's first composite, or the metadata service's copy). It is now `409 RESOURCE_CONFLICT`, reason `not-held-by-qualifier`, with `details.candidates` naming each package that holds NAME (ruling 6917064203 on #34398), the refusal the covered types already answer. X need not be an installed package: a qualifier that names none (the Console's app-name segment) gets the same answer. A name no package holds stays the read's own 404. The read gate answers before the `not-held-by-qualifier` refusal names any holder: for a `doc`, a caller the ADR-0046 §6.7 docs audience refuses is answered the gate's `401 UNAUTHENTICATED` or `403 PERMISSION_DENIED`; for a `view`, a member the list view audience (`requiredPermissions`) refuses is answered the gate's `403 PERMISSION_DENIED`, as the holder's own address answers them. A caller the gate admits is answered the 409.
19+
- `GET /meta/TYPE/NAME/layers?package=X`, same address: was 200 with another package's `code` and `effective`. It is now the same 409.
20+
- `GET /meta/TYPE/NAME/layers?package=X`, where X and Y ship NAME and Y registered last: was 200 with Y's `code` and `effective` (the metadata service keeps such a type by name alone). It is now X's, as the plain read answers since #34040.
21+
- `GET /meta/doc/NAME` and its `/layers` and `/published`, where two enabled packages ship NAME and the registry's bare slot holds a package-less entry: was 200 with the doc of the package the metadata service registered last. It is now 200 with the environment's own item, as the registry and `MetadataFacade.get` already served it. Without such an entry the read stays refused 409 naming both (#34036). Per entry:
22+
- A stamp-less runtime registration: the plain read and `/published` serve its body; `/layers` reports it as `code` and `effective`.
23+
- The same registration beside a different package-less stored row: all three doors serve the registration; `/layers` reports it as `code` and `effective` and the row as `overlay`.
24+
- A stored package-less row the hydrator registered before any package shipped the name (its entry is tenant-authored, `_provenance: 'org'`, so it is no code layer): the plain read and `/published` serve the row; `/layers` reports `code: null` and the row as `overlay` and `effective`.
25+
- Both `/published` doors (the dispatcher's and `RestServer`'s) serve that item in place of the metadata service's package copy.
26+
- The same stored row hydrated after the packages' artifacts registered wears the first registered holder's envelope (the hydrator grafts it), so no package-less entry exists: the bare doors stay refused 409 naming both, as before.
27+
- A save naming package X of a `datasource` with no stored row at X (the credential carry-forward reads the code layer, `readCodeLayerForCarryForward`): carried forward the credential of the package the metadata service kept, or of the first registered holder. It now carries X's own credential, or none when X ships no datasource of the name (the incoming body is kept as sent; the carry-forward is no read answer, so it does not refuse). Of this family only `datasource` carries a credential, so no other save moves. Path: a save door naming the package (`PUT /meta/datasource/NAME?package=X`), its draft save, and any carry-forward of a body whose credentials the read redacted.
28+
29+
**Console.** The doc page under an app (`/apps/X/docs/...`) and the flat permalink every cross-reference is rewritten to (`/apps/X/docs/NAME`, whose single-item read tells a refused name from an absent one) read with X as ADR-0048 prefer-local context. When that read answers the `not-held-by-qualifier` 409 (X not among the candidates) or a 404, each now reads the name again by name. A cross-reference from X's docs to another package's doc, and the app-name segment of a package that ships several apps (which names no package), keep rendering the doc's one holder, or its holder's audience refusal on the flat permalink; a name two other packages ship lists them (the 409 candidate list), where it showed one of them by registration order.
30+
31+
**Not moved.**
32+
- A holder's own address, a customization pair's address of its base's item, and an item bound to no package (the environment's entry).
33+
- Any read naming no package other than the bare doc case above.
34+
- `object`, and the covered types (`action`, `hook`, `job`, `sharing_rule`, `queue`, `assignment_rule`), whose exact qualifier already refuses 409 `not-held-by-qualifier`.
35+
- The security catalog types `position` and `capability`: the registry keeps one package holder of such a name, so `?package=` of another package keeps the code layers' answer (that holder's item).
36+
- One enabled holder beside a stamp-less bare entry: the bare doors serve the holder's doc while the registry and `MetadataFacade.get` serve the entry (measured, unresolved here; the entry answers first beside two or more holders only). Follow-up card #34452 carries this cell; it needs a ruling first on whether the environment's entry answers first beside one holder, before any reader moves.
37+
38+
**No migration.** No schema key, stored row or registry slot changes; nothing is rewritten.
39+
40+
The fix for a caller: address a package the refusal names (or its pair), or read with no package. For the bare doc read beside the environment's own entry, address a holder with `?package=` to read that holder's doc.

‎packages/metadata-protocol/src/protocol-discovery-and-bases.ts‎

Lines changed: 14 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,7 @@
3737
import type { SysMetadataRepository } from './sys-metadata-repository.js';
3838
import { PLURAL_TO_SINGULAR, SINGULAR_TO_PLURAL, unrecognisedMetaTypeRefusal } from '@objectstack/spec/shared';
3939
import type { TranslationBundle } from '@objectstack/spec/system';
40-
import { engineCanRollBack, readAuthoredTranslationLayer } from '@objectstack/core';
40+
import { engineCanRollBack, isPackageScopedType, readAuthoredTranslationLayer } from '@objectstack/core';
4141
import { restoreTranslatedEchoes } from './protocol-translated-echo.js';
4242
import type { RestoredTranslatedSlot } from './protocol-translated-echo.js';
4343
import {
@@ -49,6 +49,7 @@ import {
4949
import { pairsOf } from '@objectstack/metadata-core';
5050
import { installedManifestsOfEngine } from './installed-manifests.js';
5151
import { storedBodyForCarryForward } from './protocol-credential-carry-forward.js';
52+
import { registryAnswerAtAddress, serviceCopyOfAnotherPackage } from './protocol-meta-item-reads.js';
5253
import type { Equal, MetaTypesListing } from './protocol-meta-types-listing.js';
5354
import {
5455
HAND_CRAFTED_SCHEMAS,
@@ -1121,13 +1122,24 @@ export class ProtocolDiscoveryAndBasesFacet {
11211122
name: string,
11221123
packageId: string | null,): Promise<unknown> {
11231124
const pkg = packageId ?? undefined;
1125+
// [ADR-0150 D3/D5, red line 2] At a package address of a type the
1126+
// exact qualifier does not judge, the code layer is that package's
1127+
// own item or none, as the by-name read's code steps answer there
1128+
// ({@link serviceCopyOfAnotherPackage}, {@link registryAnswerAtAddress}):
1129+
// the service keeps such a type by name alone, and a package holding
1130+
// no item of the name read another package's first composite, so the
1131+
// save carried that package's credential forward.
1132+
const address = { type, name, ...(pkg !== undefined ? { packageId: pkg } : {}) };
1133+
const atAddress = pkg !== undefined && !isPackageScopedType(type);
11241134
const fromService = await host.readItemFromMetadataService(type, name, pkg);
1125-
if (fromService.data !== undefined && fromService.data !== null) return fromService.data;
1135+
if (fromService.data !== undefined && fromService.data !== null
1136+
&& !(atAddress && serviceCopyOfAnotherPackage(host, address, fromService.data))) return fromService.data;
11261137
let item: unknown = host.lookupArtifactItem(type, name, pkg) ?? host.engine.registry.getItem(type, name, pkg);
11271138
if (item === undefined) {
11281139
const alt = PLURAL_TO_SINGULAR[type] ?? SINGULAR_TO_PLURAL[type];
11291140
if (alt) item = host.engine.registry.getItem(alt, name, pkg);
11301141
}
1142+
if (atAddress) item = registryAnswerAtAddress(host, address, item, undefined, () => true);
11311143
if (item !== undefined && item !== null) return item;
11321144
if (fromService.degraded) host.throwMetadataServiceUnavailable(fromService.errors);
11331145
return undefined;

‎packages/metadata-protocol/src/protocol-exact-qualifier.ts‎

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -271,6 +271,23 @@ function refusal(
271271
return new PackageScopedNameRefusedError({ ...base, message: packageScopedRefusalMessage(base) });
272272
}
273273

274+
/**
275+
* [ruling 6917064203 on #34398, ADR-0150 D5] The refusal of an address naming
276+
* a package that holds no item of the name, for a type outside the exact
277+
* qualifier ({@link admitExactQualifier} judges the covered set): the same
278+
* `not-held-by-qualifier` refusal, naming each package that holds the name.
279+
* Asked only where another package holds it; a name nothing holds is the
280+
* read's own miss.
281+
*/
282+
export function notHeldByQualifierRefusal(
283+
type: string,
284+
name: string,
285+
packageId: string,
286+
holders: readonly string[],
287+
): PackageScopedNameRefusedError {
288+
return refusal(type, name, packageId, 'not-held-by-qualifier', holders.map((holder) => ({ kind: 'package' as const, packageId: holder })));
289+
}
290+
274291
/**
275292
* Judge a by-name read that names package `packageId` as its exact qualifier.
276293
*

0 commit comments

Comments
 (0)