Skip to content

Commit 2e9e1ac

Browse files
fix(metadata-protocol)!: the read naming no bundle member addresses the canonical member alone, as ?member=en-US and /published do (#34910)
Fixes #34682 Clause-②: no (narrowing) Metadata-protocol: none Skills-docs: none — no page under `skills/**` or `content/docs/**` teaches the read naming no member of a bundle that has no canonical member; `content/docs/references` prints the selector sentence this change now follows, and the ADR-0146 paragraph of `skills/objectstack-platform/SKILL.md` names members only at a base or a package address. No taught sentence moves. ## 维护者速读 - 改了什么:邮件模板这类“分成员”的元数据,按名字读且不指定成员时,现在只读规范成员 `en-US`;如果这个模板根本没有 `en-US`,普通读、`/layers`、执行读都答 404,和 `?member=en-US`、`/published` 一致。 - 为什么改:规范写明“不指定成员 = 规范成员,写出 `en-US` 是同一个请求”,但旧代码对没有 `en-US` 的模板会悄悄返回另一种语言(如 `fr-FR`),同一请求两种写法得到 200 和 404;只存了 `fr-FR` 行的模板甚至在重启前后答案不同。 - 风险与回滚:只影响“没有 `en-US` 成员的邮件模板,不带 `?member=` 读”这一种请求,由 200 变 404;邮件发送走列表读,不受影响;Studio 列表按行带 `?member=` 打开,不受影响。回滚即 revert 本 PR。 - 先看:`packages/metadata-protocol/src/protocol-meta-item-reads.ts`(成员判断那一行)、`packages/metadata-protocol/src/protocol-meta-layered-reads.ts`(删掉的无成员回退)、`packages/spec/src/migrations/entries/semantic/18.bundle-without-canonical-member-bare-read-absent.ts`(升级说明)。 - 两分钟验证:`pnpm --filter @objectstack/runtime exec vitest run src/domains/meta-bundle-member-one-request.test.ts`,预期 1 个测试通过。 - 需要你做的:无,席位落地(这次由 200 变 404 已按收窄申报并补 ADR-0087 登记,契约审查档 L2 由席位安排)。 ## What changes The governing text is the member selector's declared contract, `BUNDLE_MEMBER_SELECTOR_DESCRIPTION` in `packages/spec/src/api/protocol.zod.ts`, which every by-name request's `member` carries: > "Absent, the canonical member (`en-US` for `email_template`), which is what a bare-name read answers; naming the canonical value is the same request. [...] A well-formed member with nothing stored or shipped answers as that door answers an absent item." The two pairs the card names are both this one request. Measured on `origin/main` d947a93, through `HttpDispatcher.dispatch` on a booted kernel, for a bundle that ships or stores no `en-US` member: | request | `main` | this PR | |:--|:--|:--| | A ships `fr-FR` only: plain read | 200, the `fr-FR` member | 404 `RESOURCE_NOT_FOUND` | | same: `?member=en-US` | 404 `RESOURCE_NOT_FOUND` | 404 `RESOURCE_NOT_FOUND` | | same: `/published` | 404 `RESOURCE_NOT_FOUND` | 404 `RESOURCE_NOT_FOUND` | | same: `/layers` / `/layers?member=en-US` | 200 `fr-FR` / 404 | 404 / 404 | | same: execution read / with `en-US` | the `fr-FR` item / null | null / null | | same, `?package=A` naming no member (also with a dependent's `en-US` row stored) | 200 `fr-FR` | 404 `RESOURCE_NOT_FOUND` | | `?package=A` naming no member, A ships `fr-FR` only and a dependent or a disabled holder ships `en-US` (and the bare read re-addressed to A beside a disabled holder) | 200 `fr-FR` | 404 `RESOURCE_NOT_FOUND` | | canonical member stored over a package that ships only `fr-FR`: `/layers` naming no member, `code` | the `fr-FR` body | `null` (status and `effective` unchanged) | | a name the environment stores only in `fr-FR`, `?package=X` naming no member, X a non-holder, after a restart | 409 `RESOURCE_CONFLICT` | 404 `RESOURCE_NOT_FOUND` | | package-less `fr-FR` row only: plain read | 404 before a restart, 200 `fr-FR` after it | 404 on both sides | | same: `?member=en-US`, `/published`, `/layers` | 404 on both sides | 404 on both sides | The producer of the stray member is the registry's bare-name read (`SchemaRegistry.getItem` with no member), which still answers a bundle with no canonical member with its first member. That is the registry's own documented contract for its other callers, so it is left alone. The by-name reads now ask for the member this request addresses: - `readMetaItem` (the plain read and the execution read): the code layers' answer is kept only when it is the addressed member, the canonical one when none was named. Before this PR that check ran only for a named member. - `getMetaItemLayered`: the same check on the registry answer, and the member-less artifact lookup added for the #34441 cell 1 case is removed. For a type with no members, that lookup repeated the artifact lookup above it with the same arguments, so removing it changes nothing for such a type. - `registryMemberServedAt` (the base-address step of `readMetaItem`): naming no member, it falls back to the base's own canonical member only. Before, it fell back to the base's first shipped member. CI on 3cb177c found this path (Test Core, `packages/objectql/src/protocol-bundle-member-base-address.test.ts`): `?package=BASE` naming no member, and the read naming no package once a dependent stores `en-US`, still served the base's `fr-FR`. - `exactQualifierItem` (`protocol-exact-qualifier.ts`, the exact-address step both reads end in): when the item in hand is another package's, it is replaced only by the admitted holder's item at the addressed member, the canonical one when none is named. Before, it asked the holder with the raw selector, which answered its first member, so `?package=X` naming no member served X's `fr-FR` whenever another package (a dependent, or a disabled holder the bare read re-addresses past) shipped `en-US`. The L2 review on 538121f found this path (S1). - `admitExactQualifier`: the environment's item that decides whether `?package=X` is refused is asked at the addressed member, the canonical one when none is named. Before, a name the environment stores only in `fr-FR` was refused `409` (`not-held-by-qualifier`, naming the environment) at any non-holder address once a restart hydrated the row, while `?member=en-US` answered `404` (L2 S4). - `resolveBundleMemberSelector`'s docblock states the canonical-member rule. The orphan-report comment in the layered read is updated to match. - One ADR-0087 semantic entry, `packages/spec/src/migrations/entries/semantic/18.bundle-without-canonical-member-bare-read-absent.ts`, registers the narrowing. It follows the shape of `18.shipped-base-dependent-canonical-row-not-published.ts`. The registry is generated from it (`gen:migration-registry`, gitignored output), and the changeset carries `adr-0087: registered bundle-without-canonical-member-bare-read-absent` with a BREAKING banner. No key, stored shape or export moves. Also moved (L2 S3 b): a type with no members, `/layers?package=X` beside a disabled sole holder: `code` goes from the disabled holder's artifact to `null`. Unchanged in status and served body: a bundle that ships or stores `en-US`, and every named member. The moves listed above are the exceptions. `/published` is unchanged. It takes no selector and already read the canonical member. **Narrowing:** this narrows what a caller receives. One served answer becomes 404: the read naming no member of a bundle with no canonical member. The seat ruled the `(narrowing)` arm (L1 rework round 1; revised claim 6953428610), following PR #34644. So the title takes `!`, and the changeset takes the BREAKING banner and the ADR-0087 registration above. The entry names three arrangements: no layer holds the canonical member; a dependent stores the canonical member over a base that ships only another; and `?package=X` where X ships no canonical member but another package does, including the disabled-holder re-address. The sibling entry `18.shipped-base-dependent-canonical-row-not-published` now points at it. The 18.6.0 release notes stated two answers this change reverses; this PR's changeset quotes both (`/layers` naming no member no longer answers A's `fr-FR` with 200; the plain read is no longer "not moved"). A contract-review-tier L2 is owed for the narrowing and the `packages/spec/src/**` path. ## Tests - New `packages/runtime/src/domains/meta-bundle-member-one-request.test.ts` boots a kernel on a file database and reads before and after a restart. - Pair 2: `?member=en-US` equals the read naming no member, including the whole served envelope, on the plain read, `/layers` and the execution read. Covered for a shipped `fr-FR`-only bundle and a stored `fr-FR`-only row (both 404/null), and for a shipped `en-US` bundle and a stored `en-US` row (both served). - Pair 1: `/published` and the plain read give the same answer for those no-canonical bundles (404) and for a stored canonical row (200, same document). `/published?member=en-US` is a 400 `VALIDATION_ERROR`. - CONTROL, a type with no members (`dashboard`): `?member=en-US` is refused 400 `VALIDATION_ERROR` on the plain read, `/layers` and the execution read. A stored row is served alike by the plain read and `/published`. - Every refusal asserts `status` and `code`. - `meta-disabled-holder-served-stack.test.ts` cell 1: the CONTROL (no D row) moves to the canonical answer (plain read, `/layers` 404, execution read null). The comment above S1 that said no shipped CONTROL could be pinned is corrected. - `protocol.lookup-artifact-item-call-sites.test.ts`: the removed `getMetaItemLayered` site leaves the ledger (26 to 25 sites). - `packages/objectql/src/protocol-bundle-member-base-address.test.ts`: the no-canonical case now pins 404 on the read naming no member, at the base's address and naming no package, the same as `?member=en-US`. The base's `fr-FR`, named, is still the base's, and the dependent's `en-US` is still served at its own address. The new runtime pin also compares `?package=A` with and without `?member=en-US` for the shipped bundles. - `packages/objectql/src/package-scoped-exact-qualifier.test.ts`: the dependent-addition leg flips (naming no member at the dependent is absent, as naming `en-US` is), and a new describe pins the base-address mirror at `?package=A` and through the re-address, on the plain and the layered read. The runtime pin gains a preserved `?member=fr-FR` leg per name. - Runtime pin: `mixed_fr_mail` (the `/layers` code layer, before and after a restart) and the `?package=A` non-holder leg for `row_fr_mail`. objectql `package-scoped-exact-qualifier.test.ts`: the N6 leg (two unrelated holders in different non-canonical members) and the disabled-sole-holder `doc` `/layers` leg. - Not changed, same class, left for a follow-up: the `_env` address admission (`admitEnvironmentQualifier`) and the caller-arm resolver still ask with the raw selector; no observable split was measured. ## Acceptance notes - Not the member selector's: `/published` answers 404 for an item that only code ships, bundled or not. The plain read serves 200 for the same item. The new test pins this for `dashboard` and `email_template` alike, and the existing `SPECIMENS` pin in `meta-disabled-holder-served-stack.test.ts` already holds it for a code-only agent and dashboard. So `/published` and the plain read give one answer wherever a published document exists or none does, which is the scope of the card's pair 1. This is an observation and was not filed. - The registry's bare-name read (`registry-items.ts`) keeps answering a bundle with no canonical member with its first member, for its other callers. No by-name door takes that answer now. Changing the registry would widen the change to `@objectstack/objectql`, and nothing here asks for it. - The new pin is a new file, as the dispatch named it. The selector's existing harness, `protocol.bundle-member-selector.test.ts`, is a pure unit test with no doors, and the `/published` door lives in `packages/runtime`. ## Verification L2 round 2, final head e90a02e (origin/main c809deb merged), under the shared verify lock: metadata-protocol 357 passed | 9 skipped files, 23207 passed | 45 skipped tests, typecheck exit 0; objectql exact-qualifier and base-address files 468 tests passed, check:test-typecheck OK; runtime 6 meta-* files 608 passed, typecheck OK; cli guidance 3 passed; check-adr-0087-registration exit 0; `dispatch-gates --ran` 96 accounted for, 0 NOT-MEASURED; overlap-check clean. Ablation 5 (S4): `?package=A` naming no member threw 409 against null at `en-US` under the mutation; restored clean. Dogfood battery on e90a02e: command exit 0, 482 passed | 3 skipped files, 4092 passed | 68 skipped tests. Round 1, on head ce8d6e7 (after merging `origin/main` e8a78c4, 18.6.0; the released `34441` changeset stays deleted), under the shared verify lock: <details><summary>Dogfood battery on ce8d6e7 (the `(narrowing)` arm)</summary> ``` pnpm --filter '@objectstack/dogfood^...' build && pnpm --filter @objectstack/dogfood test Test Files 482 passed | 3 skipped (485) Tests 4092 passed | 68 skipped (4160) os-verify-lock: VERDICT command-exit 0 (held 2643s) ``` </details> <details><summary>Suites, typechecks, gates on ce8d6e7</summary> ``` metadata-protocol vitest: 356 passed | 9 skipped files; 23180 passed | 45 skipped tests; typecheck exit 0 objectql vitest: 615 files, 13884 tests passed; check:test-typecheck OK runtime (6 meta-* domain files): 608 tests passed; typecheck OK spec test: 855 files, 27364 passed | 1 todo cli test/migrate-meta-engine-guidance.test.ts: 3 passed check-adr-0087-registration: exit 0 · check:type-check-debt: exit 0 dispatch-gates --ran: 96 accounted for, 0 NOT-MEASURED overlap-check on ce8d6e7: origin/main merges cleanly, 0 PR heads share a file, VERDICT clean exit 0 ``` </details> <details><summary>Ablation 4 (S1): exactQualifierItem reverted to the raw selector</summary> ``` mutation landed (blob 6c39d74 -> 34c37cc94782); dist marker present in 1 built file objectql package-scoped-exact-qualifier.test.ts: 4 failed | 452 passed restored: blob == HEAD; rebuilt; tree clean; the file passes again ``` </details> Earlier rounds, superseded by the readings above: Rework round 1, on head 90b5cde: <details><summary>Dogfood battery, once on the final head (the `(narrowing)` arm)</summary> ``` pnpm --filter '@objectstack/dogfood^...' build && pnpm --filter @objectstack/dogfood test Test Files 479 passed | 3 skipped (482) Tests 4072 passed | 68 skipped (4140) os-verify-lock: VERDICT exit 0 for this part (held 2577s; check:type-check-debt ran first in the same hold, exit 0) ``` An earlier battery on 3cb177c gave the same counts. That head is superseded. </details> <details><summary>Suites, typechecks, ADR-0087 entry, cli guidance</summary> ``` pnpm --filter @objectstack/metadata-protocol exec vitest run --maxWorkers=2 Test Files 349 passed | 9 skipped (358) Tests 23100 passed | 45 skipped (23145) pnpm --filter @objectstack/metadata-protocol typecheck (exit 0) pnpm --filter @objectstack/objectql exec vitest run --maxWorkers=2 Test Files 607 passed (607) Tests 13661 passed (13661) pnpm --filter @objectstack/objectql typecheck check:test-typecheck: OK pnpm --filter @objectstack/runtime exec vitest run (6 meta-* domain files incl. the new pin) Test Files 6 passed (6) Tests 608 passed (608) pnpm --filter @objectstack/runtime typecheck check:test-typecheck: OK pnpm --filter @objectstack/cli exec vitest run test/migrate-meta-engine-guidance.test.ts Test Files 1 passed (1) Tests 3 passed (3) node scripts/check-adr-0087-registration.mjs --base origin/main check-adr-0087-registration: 1 declared-breaking changeset(s), each carrying an ADR-0087 disposition. pnpm --filter @objectstack/lint exec vitest run src/validate-expressions.flow-null-guards.test.ts Test Files 1 passed (1) (the CI Test Core 5/10 red on 3cb177c was a 5000 ms timeout in this untouched lint file) os-verify-lock: VERDICT command-exit 0 pnpm --filter @objectstack/spec test && typecheck (on 3cb177c; spec unchanged since except one entry string) Test Files 848 passed (848) pnpm --filter @objectstack/spec check:generated All 14 generated artifacts are up to date ``` </details> <details><summary>Ablation 3: the base-address canonical check removed</summary> ``` ablation-replace: ok mutation landed: anchor 1 -> 0, blob ed838c1 -> 5f49b6cdbaa5 dist/: marker present in 2 built files objectql protocol-bundle-member-base-address.test.ts: 1 failed -- ?package=BASE naming no member [Base late FR, fr-FR] vs 404 runtime meta-bundle-member-one-request.test.ts: passed (this path needs a dependent's row; the objectql pin carries it) ablation-replace: ok restored: blob == HEAD (ed838c1) restore leg: rebuilt; dist/: marker absent from all 24 built files; tree clean ``` </details> <details><summary>Derived gate families on 90b5cde, 95 of 95</summary> ``` 95 derived, 95 run, each exit 0, recorded with exit codes (check:type-check-debt first queued out behind a sibling's lock hold, exit 3; rerun inside the dogfood hold, exit 0) dispatch-gates --ran: 95 accounted for, 0 NOT-MEASURED (a DERIVED zero) overlap-check on 90b5cde: origin/main merges cleanly; VERDICT clean exit 0 ``` </details> Round 0, on head af88513 (after merging `origin/main` fc5913e). Later commits add the spec entry, the changeset, the base-address fix and pins, so these are superseded by the readings above: <details><summary>metadata-protocol suite and typecheck; runtime pins and typecheck</summary> ``` pnpm --filter @objectstack/metadata-protocol exec vitest run --maxWorkers=2 Test Files 349 passed | 9 skipped (358) Tests 23100 passed | 45 skipped (23145) pnpm --filter @objectstack/metadata-protocol typecheck (exit 0) pnpm --filter @objectstack/runtime exec vitest run --maxWorkers=2 (6 meta-* domain files incl. the new pin) Test Files 6 passed (6) Tests 608 passed (608) pnpm --filter @objectstack/runtime typecheck check:test-typecheck: OK os-verify-lock: VERDICT command-exit 0 ``` </details> <details><summary>Ablation 1: the item-read check reverted to its main form (member, not wantedMember)</summary> ``` ablation-replace: ok mutation landed: anchor 1 -> 0, blob 4f52545 -> 6fd49b7a4ee5 dist/: marker present in 2 built files Test Files 1 failed (1) -- read naming no member [200, ship fr] vs ?member=en-US [404] ablation-replace: ok restored: blob == HEAD (4f52545) restore leg: rebuilt; dist/: marker absent from all 24 built files; tree clean; pin 1 passed ``` </details> <details><summary>Ablation 2: the layered check reverted to its main form</summary> ``` ablation-replace: ok mutation landed: anchor 1 -> 0, blob b9443f7 -> 011d7e9620de dist/: marker present in 2 built files Test Files 1 failed (1) -- /layers naming no member [200, ship fr] vs ?member=en-US [404] ablation-replace: ok restored: blob == HEAD (b9443f7) restore leg: rebuilt; dist/: marker absent from all 24 built files; tree clean ``` </details> <details><summary>Round 0 derived gate families (dispatch-gates --commands), 71 of 71</summary> ``` 71 derived, 71 run, each exit 0, recorded with exit codes dispatch-gates --ran: 71 accounted for, 0 NOT-MEASURED (a DERIVED zero) overlap-check: origin/main merges cleanly; #34850 merges cleanly; VERDICT clean exit 0 ``` </details> Not run locally (CI owns it): `test:repo`, `pnpm lint`, the full `check:*` set. --- _Generated by [Claude Code](https://claude.ai/code/session_012MmDsS4GoHCgYwA2uv3n3C)_ <!-- signed: repo:objectstack#4 · os-lizheng · session_012MmDsS4GoHCgYwA2uv3n3C --> --------- Co-authored-by: Claude <noreply@anthropic.com>
1 parent 35c6331 commit 2e9e1ac

13 files changed

Lines changed: 520 additions & 56 deletions
Lines changed: 41 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,41 @@
1+
---
2+
'@objectstack/metadata-protocol': patch
3+
'@objectstack/spec': patch
4+
---
5+
6+
fix(metadata-protocol)!: the read naming no bundle member addresses the canonical member alone, as `?member=en-US` and `/published` do
7+
8+
Clause-②: no (narrowing)
9+
Metadata-protocol: none
10+
Skills-docs: none — no page under `skills/**` or `content/docs/**` teaches the read naming no member of a bundle that has no canonical member; `content/docs/references` prints the selector sentence this change now follows, and the ADR-0146 paragraph of `skills/objectstack-platform/SKILL.md` names members only at a base or a package address. No taught sentence moves.
11+
12+
<!-- adr-0087: registered bundle-without-canonical-member-bare-read-absent -->
13+
14+
**BREAKING**: where the address holds no canonical member of a bundled name, the read naming no member (`GET /meta/TYPE/NAME`, with or without `?package=`), `/layers` naming none and the execution read naming none move from serving another member (200) to `404 RESOURCE_NOT_FOUND` (the execution read: `null`). Name the member (`?member=fr-FR`) to read it, as before.
15+
16+
The by-name doors' member selector reads a request naming no member as the canonical one (`en-US` for `email_template`), and naming the canonical value is the same request. That is the selector's declared contract (`GetMetaItemRequest.member`). For a bundle with no canonical member, the two requests got different answers:
17+
18+
- The plain read `GET /api/v1/meta/email_template/NAME` and `/layers` served the bundle's other member (for example `fr-FR`, status 200). The execution read (`getMetaItemForExecution`) returned that member too.
19+
- `?member=en-US` and `/published` answered 404.
20+
21+
The same split held in two more arrangements:
22+
23+
- A base ships only `fr-FR` and a dependent that declares it stores `en-US`. The read naming no package and no member served the base's `fr-FR`.
24+
- `?package=X` where X ships no `en-US` while another package does (a dependent, or a disabled holder that the read naming no package re-addresses past to X). The read naming no member served X's `fr-FR`. `?package=X&member=en-US` answered nothing.
25+
26+
For a bundle that only stores a non-canonical row (a package-less `fr-FR` row with no `en-US` row), the plain read also changed across a restart. It answered 404 before the restart. After the restart it served the row (200), because the restart had moved the row into the registry's bare slot.
27+
28+
The plain read, `/layers` and the execution read now ask every layer for the canonical member when no member is named. They take the registry's bare-name answer only when it is that member. The base-address fallback serves only the base's canonical member, and an exact address (`?package=`) replaces another package's item only with the holder's item at the addressed member. So each of these arrangements answers 404 on every door naming no member, the same as `?member=en-US` and `/published`, before and after a restart.
29+
30+
A bundle that ships or stores its canonical member keeps its status and served body, and so does any named member. Three more answers move:
31+
32+
- `/layers` naming no member, where the canonical member is stored over a package that ships only another member: `code` goes from that member's body to `null`, as `/layers?member=en-US` already answered. Status and `effective` do not move.
33+
- For a type with no members, `/layers?package=X`, where X holds nothing of the name and the only holder is disabled: `code` goes from the disabled holder's artifact to `null`. A disabled package holds no name.
34+
- `?package=X` naming no member, where X does not hold the name and the environment stores it only in a non-canonical member: the read was refused `409 RESOURCE_CONFLICT` (`not-held-by-qualifier`, naming the environment) once a restart had hydrated the row. It now answers the `404` that `?member=en-US` already answered, on the plain read and `/layers`. A non-canonical member is still read with its own selector, for example `?member=fr-FR`, which the Studio list already links to for each member.
35+
36+
**Reverses two statements of the 18.6.0 note** for the arrangement where base A ships `email_template` `welcome` in `fr-FR` only and dependent D, which declares A, stores `en-US`:
37+
38+
- 18.6.0 said "`GET /meta/email_template/welcome/layers` (no member) moves FROM `404` after a restart TO A's `fr-FR` (200)". Now `/layers` naming no member answers `404 RESOURCE_NOT_FOUND` on both sides of a restart, as `/layers?member=en-US` does.
39+
- 18.6.0 said "**Not moved.** The plain read, `?member=CANONICAL` and the execution read of the first shape (A's `fr-FR` naming no member, 404 at `en-US`)." Now only `?member=CANONICAL` is unmoved. The plain read naming no member answers 404 and the execution read naming no member answers `null`, where both served A's `fr-FR`.
40+
41+
Migration: a caller that read a bundle with no canonical member without naming a member must name the member it wants (`?member=fr-FR`). The email template loader reads the list (`getMetaItemsForExecution`) and does not use this read, so it is not affected.

‎packages/metadata-protocol/src/protocol-bundle-members.ts‎

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -47,6 +47,13 @@ export const BUNDLE_MEMBER_MAX_LENGTH = 100;
4747
* well-formed member with nothing stored or shipped is not refused here: each
4848
* door answers it as it answers an absent item.
4949
*
50+
* [#34682] …the canonical member included, named or not: a bundle that ships
51+
* or stores no canonical member answers the read naming no member as absent,
52+
* as it answers `?member=en-US` and `/published`. The registry's bare-name
53+
* read still answers such a bundle with its first member; the by-name reads
54+
* (`getMetaItem`, `getMetaItemLayered`) take that answer only when it is the
55+
* canonical member, so it reaches no door.
56+
*
5057
* Refuses, with a located 400 `VALIDATION_ERROR` — the code the REST door's
5158
* recognition refusal answers for a misspelled selector on the same routes —
5259
* a selector on a type whose identity is its name alone, and a value that

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

Lines changed: 17 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -58,6 +58,7 @@ import {
5858
import { ENVIRONMENT_ADDRESS_SEGMENT, readNamespacePositionSegment } from '@objectstack/spec/kernel';
5959
import { installedManifestsOfEngine } from './installed-manifests.js';
6060
import { canonicalizeMetaRequestType } from './protocol-meta-type-schema.js';
61+
import { bundleMemberDiscriminator } from './protocol-bundle-members.js';
6162
import type { ProtocolHost } from './protocol-host.js';
6263
import type { ServedOverrideRow } from './served-override.js';
6364

@@ -364,7 +365,13 @@ export async function admitExactQualifier(
364365
}
365366

366367
const candidates: PackageScopedHolder[] = holders.map((holder) => ({ kind: 'package' as const, packageId: holder }));
367-
if (registry.getEnvironmentScopedItem(request.type, request.name, request.member) !== undefined) {
368+
// [#34682] The environment's item AT the addressed member: the named one,
369+
// else the canonical one (naming no member is naming the canonical value).
370+
// Asked with the raw selector, a read naming no member counted the
371+
// environment's first member of a bundle it holds only in another member,
372+
// so `?package=X` was refused 409 naming the environment where
373+
// `?package=X&member=<canonical>` was admitted and answered 404.
374+
if (registry.getEnvironmentScopedItem(request.type, request.name, bundleMemberDiscriminator(request.type, request.member)) !== undefined) {
368375
candidates.push({ kind: 'environment' });
369376
}
370377
// No holder anywhere: nothing to name, and the read answers its own miss.
@@ -491,7 +498,15 @@ export function exactQualifierItem(
491498
address.registryHolders.map((holder) => ({ kind: 'package' as const, packageId: holder })));
492499
}
493500
const [holder] = address.registryHolders;
494-
return holder === undefined ? undefined : registry.getPackageScopedItem(request.type, request.name, holder, member);
501+
// [#34682] The admitted holder's item AT the addressed member: the named
502+
// one, else the canonical one (the selector's contract: naming no member
503+
// is naming the canonical value). Asked with the raw selector, a read
504+
// naming no member got the holder's FIRST member when it ships no
505+
// canonical one, while `?member=<canonical>` answered nothing. `undefined`
506+
// for a type with no members, which reads as before.
507+
return holder === undefined
508+
? undefined
509+
: registry.getPackageScopedItem(request.type, request.name, holder, bundleMemberDiscriminator(request.type, member));
495510
}
496511

497512
/**

‎packages/metadata-protocol/src/protocol-meta-item-reads.ts‎

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1363,9 +1363,12 @@ export async function readMetaItem(host: Pick<ProtocolHost, 'artifactLockLayerAt
13631363
// member's stored row; when there is none, the member is the code
13641364
// layer's — the artifact that ships it — and then the registry's, asked
13651365
// for that member. The registry's bare-name read answers the canonical
1366-
// member wherever it sits (its own [#22877] note), and still answers a
1367-
// bundle that ships no canonical member at all; a named member that no
1366+
// member wherever it sits (its own [#22877] note); a member that no
13681367
// layer holds answers nothing, so the door answers it as absent.
1368+
// [#34682] …the canonical member included: naming no member is the
1369+
// request that names it (the selector's contract), so a bundle that
1370+
// ships or stores no canonical member answers this read as absent, as
1371+
// `?member=<canonical>` and `/published` answer it.
13691372
// [ADR-0150 D3/D5] Whether the answer below is the code layers' (the
13701373
// artifact lookup and the registry), judged at the end of step 3.
13711374
const reachedCodeLayers = item === undefined;
@@ -1404,7 +1407,10 @@ export async function readMetaItem(host: Pick<ProtocolHost, 'artifactLockLayerAt
14041407
// [#22877] A registry that does not narrow by member (a host
14051408
// double, an older registry) can answer another member of the
14061409
// bundle for a named one; that answer is not this member.
1407-
if (member !== undefined && item !== undefined && !isWantedMember(item)) item = undefined;
1410+
// [#34682] …nor is the member the registry's bare-name read answers
1411+
// for a bundle with no canonical member, when none was named: this
1412+
// read addresses the canonical member ({@link resolveBundleMemberSelector}).
1413+
if (wantedMember !== undefined && item !== undefined && !isWantedMember(item)) item = undefined;
14081414
// [#20946] The registry half — see `storedRowDeclined` above.
14091415
// `getItem` answers the bare slot first, and for a shipped flow name
14101416
// that slot holds the hydrated stored row, which is not one of the

‎packages/metadata-protocol/src/protocol-meta-layered-reads.ts‎

Lines changed: 16 additions & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -410,14 +410,16 @@ export async function getMetaItemLayered(host: Pick<ProtocolHost, 'artifactLockL
410410
// [#26699] Each lookup is asked for the addressed member, exactly
411411
// as {@link getMetaItem}'s are: the artifact at the member (the
412412
// canonical one when none was named), and the registry for the
413-
// member named. The registry's bare-name read still answers a
414-
// bundle that ships no canonical member; a registry that does not
415-
// narrow by member can answer another one for a NAMED member, and
416-
// that answer is not this member's layer.
413+
// member named. A registry that does not narrow by member can answer
414+
// another one for a NAMED member, and that answer is not this
415+
// member's layer. [#34682] Nor, naming none, is the member the
416+
// registry's bare-name read answers for a bundle with no canonical
417+
// member: this read addresses the canonical member, as
418+
// `?member=<canonical>` does, and that bundle has no layer of it.
417419
const runtimeOnly = (item: unknown): unknown =>
418420
item !== undefined && isTenantAuthored(item) ? undefined : item;
419421
const namedMemberOnly = (item: unknown): unknown =>
420-
member !== undefined && item !== undefined && !isWantedMember(item) ? undefined : item;
422+
wantedMember !== undefined && item !== undefined && !isWantedMember(item) ? undefined : item;
421423
// [#32365] The bare action read's judged answer: the one enabled
422424
// holder's artifact (looked up at that holder), or the environment's
423425
// own item (a runtime registration; a stored row is the overlay layer).
@@ -447,22 +449,8 @@ export async function getMetaItemLayered(host: Pick<ProtocolHost, 'artifactLockL
447449
// now refused naming the holders (ruling 6917064203 on #34398).
448450
if (exactAddress === undefined) regItem = namedMemberOnly(runtimeOnly(registryAnswerAtAddress(host, request, regItem, member, isWantedMember, { refuse: true })));
449451
if (regItem !== undefined) code = regItem;
450-
451-
// [#34441 cell 1, #21059] Naming no member, the bare-name read answers
452-
// a bundle that ships no canonical member with the member it ships,
453-
// until a stored row is hydrated into that bare slot: the hydrated
454-
// row is no artifact read (dropped above), and the shipped member it
455-
// displaced is the artifact the bare name reads. Without this the same
456-
// read answered `code` = the base's `fr-FR` before a restart and
457-
// `null` after it (404 on `/layers`), with a dependent's `en-US` row
458-
// stored. A named member is never answered here (its own lookups ran).
459-
// [#34248] Nor is a bare doc read's environment entry: beside two
460-
// enabled holders that entry is the read's answer, and the artifact
461-
// lookup's first composite is the holder registered first, which the
462-
// read never serves (as for the bare action read's judged answer).
463-
if (code === null && member === undefined && bareActionAnswer === undefined && bareDocEnvironmentEntry === undefined) {
464-
code = host.lookupArtifactItem(request.type, request.name, request.packageId) ?? null;
465-
}
452+
// [#34682] Naming no member, the code layer is the canonical member's
453+
// artifact (asked above) or none: no lookup by name alone follows.
466454
}
467455

468456
// [#5840] The code half of the rule #5707 wrote for the overlay half,
@@ -661,14 +649,13 @@ export async function getMetaItemLayered(host: Pick<ProtocolHost, 'artifactLockL
661649
// package's in id order.
662650
let orphaned = false;
663651
// [#34441 cell 1] …and only over a code layer of the member this read
664-
// addresses. Naming no member, a bundle whose base ships no canonical
665-
// member takes the base's other member as its code layer (the registry's
666-
// bare-name read, above); a dependent's row of the canonical member is
667-
// then no row the base's document shadows but the dependent's addition
668-
// (#28802 R2), and reported as an orphan it became `/published`'s
669-
// document, before a restart only. FROM (`main` 31096af83d): A ships
670-
// `fr-FR` only, D stores `en-US`: `/published` served D's row (200), where
671-
// with no D row it answers 404.
652+
// addresses: a dependent's row of a member the base does not ship is no
653+
// row the base's document shadows but the dependent's addition (#28802
654+
// R2), and reported as an orphan it became `/published`'s document.
655+
// FROM (`main` 31096af83d): A ships `fr-FR` only, D stores `en-US`:
656+
// `/published` served D's row (200), where with no D row it answers 404.
657+
// [#34682] Naming no member, the code layer is the canonical member's
658+
// alone (above), so this guard now also holds by that construction.
672659
if (overlay === null && code !== null && isWantedMember(code) && typeof contentPackageId === 'string' && contentPackageId !== '') {
673660
const base = contentPackageId;
674661
let rows: readonly StoredOverlayRow[] = [];

‎packages/metadata-protocol/src/protocol-write-gates.ts‎

Lines changed: 10 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -45,7 +45,7 @@ import { baseAddressServesMember, readOnlyShippingPackages, shippingPackageIds }
4545
import { canonicalMetaType, canonicalizeMetaRequestType } from './protocol-meta-type-schema.js';
4646
import { boundPackageOf } from './protocol-package-bindings.js';
4747
import type { ShippingPackages } from './protocol-package-bindings.js';
48-
import { memberOption } from './protocol-bundle-members.js';
48+
import { bundleMemberDiscriminator, memberOption } from './protocol-bundle-members.js';
4949
import type { MetadataAuditEntry } from './protocol-audit-entry.js';
5050
import { packagedBaseRegimeRow, packagedBaseRegimeSentence } from './packaged-base-regime.js';
5151
import { packagelessCloseSubject } from './protocol-packageless-overlay-migration.js';
@@ -688,17 +688,22 @@ export class ProtocolWriteGatesFacet {
688688
* [#28802] The registry's answer `item` for a bundle member read on the
689689
* address of `base`, when that address serves it
690690
* ({@link baseServesBundleMember}); else, for a read that named no
691-
* member, the base's own member its artifact answers canonical-first,
692-
* and otherwise nothing. An address that ships no member of the name is
693-
* no base of it: `item` as before.
691+
* member, the base's own CANONICAL member, and otherwise nothing. An
692+
* address that ships no member of the name is no base of it: `item` as
693+
* before. [#34682] A read naming no member addresses the canonical member
694+
* (the selector's contract), so a base that ships none answers it with
695+
* nothing, as `?member=<canonical>` is answered; FROM (`main` d947a93cf8):
696+
* the base's first shipped member (`fr-FR`).
694697
*/
695698
static registryMemberServedAt(host: Pick<ProtocolHost, 'baseServesBundleMember' | 'engine' | 'shippedArtifactsOf' | 'shippingPackagesOf' | 'shipsBundleName'>, type: string, name: string, base: string, item: unknown, member: string | undefined): unknown {
696699
const shipping = host.shippingPackagesOf(type);
697700
if (!host.shipsBundleName(type, name, base, shipping)) return item;
698701
if (host.baseServesBundleMember(type, name, base, item, shipping)) return item;
699702
if (member !== undefined) return undefined;
703+
const canonical = bundleMemberDiscriminator(type, undefined);
700704
const own = host.shippedArtifactsOf(type, name, shipping)
701-
.find((artifact) => (artifact as { _packageId?: unknown } | null)?._packageId === base);
705+
.find((artifact) => (artifact as { _packageId?: unknown } | null)?._packageId === base
706+
&& itemDiscriminator(canonicalMetaType(type), artifact) === canonical);
702707
if (own === undefined) return undefined;
703708
const candidate = host.engine.registry.getItem(type, name, base, itemDiscriminator(canonicalMetaType(type), own));
704709
return candidate !== undefined && host.baseServesBundleMember(type, name, base, candidate, shipping) ? candidate : undefined;

‎packages/metadata-protocol/src/protocol.lookup-artifact-item-call-sites.test.ts‎

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -146,8 +146,6 @@ const SITES: ReadonlyArray<Site & { readonly noPackage: boolean; readonly dispos
146146
why: '[#22877] a bundled type\'s addressed member (the selector\'s, else the canonical one) when no stored row of it exists: the served body IS this artifact, and the envelope is looked up at its own package' },
147147
{ file: LAYERED_READS_FILE, member: 'getMetaItemLayered', args: 'request.type, request.name, request.packageId || judgedPackageId, wantedMember', noPackage: true, disposition: 'no',
148148
why: 'the layered read\'s code LAYER: body and envelope are one artifact, and its provenance fields are read off that layer; [#26699] at the addressed member (the selector\'s, else the canonical one); [#32365] a bare action read at the one enabled holder its judge answered' },
149-
{ file: LAYERED_READS_FILE, member: 'getMetaItemLayered', args: 'request.type, request.name, request.packageId', noPackage: true, disposition: 'no',
150-
why: '[#34441 cell 1] the layered read\'s code LAYER again, naming no member, when the registry\'s bare slot answered a hydrated stored row (dropped as no artifact read): the artifact the bare name reads, so body and envelope are one artifact, as on the row above' },
151149
{ file: 'protocol-discovery-and-bases.ts', member: 'packagedArtifactBase', args: 'type, name', noPackage: true, disposition: 'no',
152150
why: 'the packaged base the translators compare a served body against: nothing of it is grafted onto the body' },
153151
{ file: 'protocol-discovery-and-bases.ts', member: 'readCodeLayerForCarryForward', args: 'type, name, pkg', noPackage: true, disposition: 'no',

0 commit comments

Comments
 (0)