Skip to content

Commit 69783b7

Browse files
fix(metadata-protocol,spec)!: the bare item read refuses a package-less row beside two row holders, and reads a row-held base at its dependent's added member (ADR-0150 D3) (#34355)
<!-- claude-projects-attribution: {"github_login":"zhuangjianguo"} --> _Requested by **Steedos** · [project thread](https://claude.ai/code/project/chan_018ETKaNwMZCNRYD7D8Q9Ubb?thread=cmsg_018ETKaNwMZCNRYD7D8Q9UbbBePzY6g11h3hyWk5ud4vWy)_ Fixes #33210 Clause-②: no (narrowing) Metadata-protocol: none Skills-docs: none — `skills/objectstack-platform/SKILL.md` (the ADR-0146 paragraph) and `content/docs/concepts/metadata-lifecycle.mdx` teach that a locale a dependent adds under a base's name is served only under its own `?package=`, and that the read naming no package answers `404` for it. Both sentences were true only for a base that ships the name, and are now true for a row-held base too, at a dependent's named locale other than the canonical one, however many dependents each add one. Nothing in `skills/**` or `content/docs/**` teaches what the read naming no package answers for a package-less row beside two packages' rows. > **BREAKING**: two answers of the `/meta` item read that names no package move from served to refused (table below). Name the package (`?package=`) to read the row, as before. ADR-0087: `registered row-held-base-addition-bare-read-at-base, two-row-holders-bare-read-refused`. **Clause-② arm.** `no (narrowing)`, as contract review record 6915442261 ② confirmed: nothing moves from refused to served. **Round 2 (contract review record 6915442261, VERDICT FAIL at b959edb; delta record 6922561329, PASS at 2b9293e with S2 and N3 open).** M1, S1, N1 and N2 are addressed below and closed by 6922561329. S2 is fixed at 5e2b663 (below). N3 is this body. The earlier body called `protocol-meta-layered-reads.ts` "area-approved" and the new spec entry "seat-approved". No record of either approval is on #33210 or this thread, so both attributions are withdrawn. Both files are declared here as extensions of the claim's file surface: one call site in the layered read, and the ADR-0087 entry the (c) move needs. **Round 3 (L1-b 6925025713, REWORK R1 to R3; delta record 6931462446, PASS at 4542737 with S3, N5 and N6 open).** R1 and R2 (body half) are this body; R3 is `6f4fdf19` (the RestServer `[#33210]` refusals pinned by `[status, code]`). S3 and N5 are `891338265`: the changeset's last "Not moved" sentence said the package-less save beside two holders still edits the row; measured on the bare-save harness, that save is refused `409 RESOURCE_CONFLICT` naming E and F and writes nothing, before and after this change, so the note now says so and cites #34348 only for its own shape. The S2 pin now reads the shared member `?member=en-US`. N6 is this body. `origin/main` merged at `3bbce494e` (merge only, no conflict). ## 维护者速读 - 改了什么:不带 `?package=` 的元数据按名读取有两处改为拒绝/404。(a) 同名项只有两个包的存储行加一条无包行、且没有包在代码中发布时,普通读取、`/published` 与执行读取一律 409 点名两个包(与 `/layers` 一致),不再按保存顺序挑一行;(c) 基础包只以存储行持有某名、依赖包在另一非规范成员(如 `fr-FR`)加了一行时,不带包的读取在该成员上答 404,与基础包在代码中发布时一致;多个依赖包各加一个成员时同样成立。 - 为什么改:ADR-0150 红线 2(歧义只报告、不猜),卡片 #33210 的 (a)(c) 两项;(d) 修正 ADR-0087 条目 `two-row-holders-bare-read-refused` 的 `reason` 文字。第二轮按合同复审 6915442261 修 M1(两个依赖包时第一轮仍按 200 返回)与 S1(规范成员镜像不再被挪动),并按 6922561329 修 S2(依赖包同时存了基础包的成员时,按注册表规则仍算追加)。 - 风险与回滚:收窄:上述两种形态的裸读从 200 变为 409/404;精确地址 `?package=` 不变,写入不变,不点名成员的读取(规范成员与 `/published`)不变。首方应用无此形态(计数 0)。回滚即还原本 PR。 - 先看:`packages/metadata-protocol/src/protocol-meta-item-face.ts` 的 `rowHeldBaseAddressOf`(每个包按自己的依赖闭包判定是否为追加;只对点名的非规范成员生效),以及 `servedRowHolderOf` / `storedRowHoldersRefusal` 的无包行分支。 - 两分钟验证:`pnpm --filter @objectstack/runtime exec vitest run --maxWorkers=2 src/domains/meta-disabled-holder-served-stack.test.ts -t "M1 two dependents|S1|S2"`,预期 10 个用例全部通过(两个依赖包 4 个、共享成员 4 个、规范成员镜像 2 个)。 - 需要你做的:无,席位落地(需一次覆盖 spec 面的 L2 合同复审,针对本轮新 head)。 ## What changes - `packages/metadata-protocol/src/protocol-meta-item-face.ts` - (a) `storedRowHoldersRefusal` (the no-disabled arm of the item face's served-holder judgment) refuses naming the holders when a package-less row sits beside two or more of them, as `/layers` does. Beside one holder or none, the package-less row still leaves the read as it was (CONTROL). - (a) `servedRowHolderOf` reads the rows before honouring the registry's environment item on the item face. After a reboot that item is the bare slot's entry, the row hydrated last, so it was the package-less row whenever that row was saved last. With rows bound to two or more packages beside it, it is judged with them. Beside a disabled holder the read is left as it was. (N2) Its docblock now says so. - (c) `rowHeldBaseAddressOf`. The read naming no package, at a named non-canonical bundle member that only dependents' additions hold over a base holding the name only as stored rows, takes the base's address, as it does when the base ships the name. (M1) Each row-holding package is judged against its own declared dependency closure, as the registry's `isBundleAddition` judges it. A package is an addition when some other row holder is in its closure and it is not in that holder's. The base is the one row holder that is no addition. So a second dependent (D1 `fr-FR`, D2 `de-DE` over A's `en-US`) leaves A the base at both members, in either registration order. At b959edb the rule was "exactly one row holder without a row at the member", which found A and D2 at `fr-FR` and served D1's row. (S1) The arm moves only a named member other than the canonical one; the canonical-member mirror is left as it was (below). (S2) No member clashes on this arm: the registry counts a clash only at a member shipped in code (`codeMembersOf`), and the arm runs only for a name no package ships. So a dependent that also stores a member the base stores (D's `en-US` and `fr-FR` over A's `en-US`) stays an addition. At 2b9293e any shared member was a clash, which gave two bases and served D's `fr-FR` (200). - `packages/metadata-protocol/src/protocol-meta-layered-reads.ts`: one call to `rowHeldBaseAddressOf` beside `declaredMemberOverrideAddressOf`, so `/layers` agrees with the plain read. - `packages/spec/src/migrations/entries/semantic/18.two-row-holders-bare-read-refused.ts` (d): only the `reason` text changes. - `packages/spec/src/migrations/entries/semantic/18.row-held-base-addition-bare-read-at-base.ts`: the ADR-0087 semantic entry for (c). Round 2: the `surface` and `acceptanceCriteria` say "named member other than the canonical one" and "one or more dependents", and the surface says the read naming no member and `/published` do not move. (N1) The `reason` no longer attributes "a bundle addition holds no name" to ADR-0150 D3; the header comment cites the rule's source (the `packageScopedHoldersOf` docblock, epic child R2). - `.changeset/33210-packageless-row-two-holders.md`: `patch` on `@objectstack/metadata-protocol` and `@objectstack/spec`. Its second bullet and `Skills-docs:` sentence now say what the code does (M1, S1). ### FROM → TO (every moved answer) | Shape | Door (naming no package) | FROM (`main`) | TO | |:---|:---|:---|:---| | (a) E's row + F's row + a package-less row, no shipper | plain read, `/published`, execution read | 200, the row stored first (package-less, E's or F's, by save order) | 409 `RESOURCE_CONFLICT`, `details.candidates` = E, F | | (a) same | `/layers` | 409 naming E, F | unchanged | | (a) same, package-less row saved last, after a reboot | plain read | 200, E's row | 409 naming E, F | | (c) base A's `en-US` row, dependent D's `fr-FR` row, no shipper | plain read, `/layers`, execution read at `?member=fr-FR` | 200, D's row | 404 `RESOURCE_NOT_FOUND` | | (c) same with a second dependent D2's `de-DE` row (M1) | same, at `fr-FR` and at `de-DE` | 200, each dependent's row | 404 | | (c) D also stores `en-US` beside its `fr-FR` (S2) | same, at `fr-FR` | 200, D's row | 404 | | (c) A ships `en-US` (CONTROL) | same | 404 | unchanged | | CONTROL: E's row + a package-less row | every bare door | 200, E's row | unchanged | | CONTROL (S1): A's `fr-FR` row, D's canonical `en-US` row | the read naming no member, `?member=en-US`, `/published`, `/layers`, execution read | 200, D's row | unchanged | | any | `?package=E` / `?package=F` / `?package=D&member=fr-FR` | own row | unchanged | **S1, which option and why.** The arm is guarded to a named non-canonical member rather than pinned beside a shipped CONTROL. Measured on a booted kernel: with A shipping only `fr-FR` and D storing the canonical `en-US`, the read naming no member serves A's `fr-FR`, and `/published` and `/layers` move across a reboot (200 D's row, then 404). There is no single shipped answer to align the row-held cell with. Unguarded (b959edb), the row-held cell answered 404 before a reboot and A's `fr-FR` after it. Guarded, it serves D's row on every door in both save orders, before and after a reboot, as on `main`. The shipped cell's own movement is reported to the seat as a separate finding, not fixed here. ## Tests - `packages/rest/src/meta-disabled-package-doors.test.ts`: describe `[#33210]`, all 6 save orders of the three rows on every door plus each exact address, and a one-holder CONTROL in both save orders. - `packages/runtime/src/domains/meta-disabled-holder-served-stack.test.ts`: - (a) Three save orders × two registration orders, before and after a reboot, plus the CONTROL. - (c) M2: the row-held base in both save orders, and the shipped base as CONTROL, before and after a reboot. - (c) M1, new: two dependents (D1 `fr-FR`, D2 `de-DE`) registered and saved A, D1, D2 and D2, D1, A, row-held and shipped (CONTROL), before and after a reboot. Each member answers 404 on the plain read, `/layers` and the execution read, and is served at its own address. The base's `en-US` stays the base's. - S2, new: D storing `en-US` and `fr-FR` over A's `en-US`, registered and saved A, D and D, A, row-held and shipped (CONTROL), before and after a reboot. `fr-FR` answers 404 on the plain read, `/layers` and the execution read, and `?package=D` serves it. (N5) The shared member `?member=en-US` naming no package is not moved: the shipped base serves its own row (200), and over a row-held base A's and D's rows of it are refused `409 RESOURCE_CONFLICT` naming both. - S1, new: the canonical-member mirror in both save orders, before and after a reboot. Every door naming no package serves D's row, and the base's `fr-FR` stays the base's (CONTROL). ## Acceptance notes - Out of scope, carried by #34440: a package-less row beside a disabled holder and served holders. The plain read follows save order, `/published` serves the package-less row, and `/layers` refuses naming the disabled package. This was measured, and the disabled arm is unchanged from `main`. - Out of scope, carried by #34441: with a shipped base holding only a non-canonical member and a dependent's canonical row, the read naming no member serves the base's other member, and `/published` and `/layers` move across a reboot. - Writes, not moved: in shape (a) the save naming no package is refused `409 RESOURCE_CONFLICT` naming E and F and writes nothing, on both transports and in both save orders, measured before this change (where the plain read served a row by save order) and after it (where the read refuses as well). A save that edits a package-unbound row while the read refuses is another shape, two enabled packages that ship the name with no package's row stored, and is #34348 (decision open). - Out of scope, carried by #34441 (folded there as its second cell, 6933869894): in the S2 shape the shared canonical member `?member=en-US` answers differently by how the base holds the name: a shipped base's row (200), or over a row-held base `409` naming A and D. This change does not move it (measured before it, before a reboot, on the same harness). ## Verification Final head `3bbce494e` (`origin/main` merged at that commit). Each step below ran as its own call under the shared verify lock, after `pnpm install --frozen-lockfile` and the closure build `pnpm --filter '@objectstack/dogfood^...' build` (exit 0) at that head. <details><summary>Suites and typecheck at 3bbce49</summary> - runtime `meta-disabled-holder-served-stack.test.ts`: 157/157. rest `meta-disabled-package-doors.test.ts`: 58/58. - `typecheck` of runtime, rest, metadata-protocol and spec: exit 0 each. - At `5e2b66314c` (metadata-protocol source unchanged since): `pnpm --filter @objectstack/metadata-protocol test` 346 files passed, 9 skipped; 22968 tests passed, 45 skipped. `pnpm --filter @objectstack/spec test` ran at 2b9293e. </details> <details><summary>Save measurement (S3) and the shared-member read (N5)</summary> One-off probe on the existing bare-save harness (`[#32605]` describe, both transports, both registration orders), not kept as a test: authored packages E and F each store a row and a package-less row is stored, in two save orders (package-less first, package-less last). - This branch (`45427375`): bare read `409 RESOURCE_CONFLICT`; bare save `409 RESOURCE_CONFLICT` naming both packages; the stored rows are unchanged. - Without this change (the two metadata-protocol sources restored from `152cd1fa6`, the package rebuilt, `rowHeldBaseAddressOf` proved absent from `dist/`): bare read 200; bare save `409 RESOURCE_CONFLICT` naming both; the stored rows are unchanged. The sources were then restored from HEAD (blob hashes matched) and the package rebuilt. - N5, the S2 shape at `?member=en-US` naming no package: shipped base 200 with the base's row; row-held base `409 RESOURCE_CONFLICT` naming A and D on the plain read, `/layers` and the execution read, before and after a reboot. Without this change, row-held, before a reboot: the same `409`. </details> <details><summary>Ablations (rounds 1 and 2; code unchanged since)</summary> At 2b9293e: - A1, the unbound refusal off: REST `[#33210]` 6 failed, 2 CONTROL passed; runtime `[#33210] saved` 6 failed. - A2, the environment-item hunk off: runtime 2 failed ('E, F, package-less' after a reboot, one per registration order). At 5e2b663, over the `[#32607 M1, M2]` describe (14 tests): - A3, `rowHeldBaseAddressOf` off: 6 failed (M2, M1 two dependents and S2, the row-held cells); every shipped CONTROL passed. - A4, M1 off (one base beside the member's holders): 4 failed: M1 two dependents (2), and S1's `?member=fr-FR` CONTROL (2), where without the per-package closure the base itself reads as an addition. Observed direction: more diagnostics than the two pins targeted. - A5, the S1 guard off: S1 2 failed. - A6, S2 off (a shared stored member is a clash): S2 row-held 2 failed; the shipped CONTROLs passed. </details> <details><summary>Dogfood battery and derived gates at 3bbce49</summary> - Dogfood battery: `pnpm --filter @objectstack/dogfood test`, lock VERDICT command-exit 0; 478 test files passed, 3 skipped; 4030 tests passed, 44 skipped. - `dispatch-gates --commands` (change set from merge base `bdd51769e`, 7 paths): 93 derived; 91 exit 0; 2 NOT MEASURED, both exit 3 before reaching the gate body: `check:dual-build-cjs-loads` (PREREQUISITE NOT MET, it needs a full `pnpm build`; only the dogfood closure was built) and `check:type-check-debt` (its own lock wait timed out behind the battery). `--ran` reconciliation: 93 derived, 91 run, 2 NOT-MEASURED, 0 UNRUN. CI runs both. - CI check-runs at this head: not read here; for the seat. </details> 🤖 Generated with [Claude Code](https://claude.com/claude-code) https://claude.ai/code/session_01FEkQ5obaLbqgzRUR9xXfft <!-- signed: repo:objectstack#2 · os-steve · session_01ADHkmRPxhTmqbUbMrqygh4 --> --------- Co-authored-by: Claude <noreply@anthropic.com> Co-authored-by: objectstack-fleet[bot] <332303061+objectstack-fleet[bot]@users.noreply.github.com>
1 parent b1efa37 commit 69783b7

7 files changed

Lines changed: 560 additions & 24 deletions

File tree

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
---
2+
'@objectstack/metadata-protocol': patch
3+
'@objectstack/spec': patch
4+
---
5+
6+
fix(metadata-protocol)!: the bare item read refuses a package-less row beside two packages' rows, and reads a row-held base at its dependent's added member (ADR-0150 D3, red line 2)
7+
8+
Clause-②: no (narrowing)
9+
Metadata-protocol: none
10+
Skills-docs: none — `skills/objectstack-platform/SKILL.md` (the ADR-0146 paragraph) and `content/docs/concepts/metadata-lifecycle.mdx` teach that a locale a dependent adds under a base's name is served only under its own `?package=`, and that the read naming no package answers `404` for it. Both sentences were true only for a base that ships the name, and are now true for a row-held base too, at a dependent's named locale other than the canonical one, however many dependents each add one. Nothing in `skills/**` or `content/docs/**` teaches what the read naming no package answers for a package-less row beside two packages' rows. No taught sentence moves.
11+
12+
<!-- adr-0087: registered row-held-base-addition-bare-read-at-base, two-row-holders-bare-read-refused -->
13+
14+
**BREAKING**: two answers of the `/meta` item read that names no package move from served to refused. Name the package (`?package=`) to read the row, as before.
15+
16+
**Every moved answer, before → after.** Both transports (`RestServer` and the runtime `HttpDispatcher`), every save order, both registration orders, and on the runtime dispatcher before and after a reboot. First-party count 0: no first-party app stores either shape.
17+
18+
- **A package-less row beside two packages' rows of a name no package ships** (packages E and F each store a row of `dash`, and a package-less row of `dash` is stored too). The plain read `GET /meta/dashboard/dash`, `GET /meta/dashboard/dash/published` and the execution read move FROM the row stored first (E's, F's or the package-less one) TO `409 RESOURCE_CONFLICT` naming E and F in `details.candidates`. `GET /meta/dashboard/dash/layers` already refused it, and still does with the package-less writes' sentence. The package-less row is never served in their place: it is a customization of a name it cannot say whose (red line 2). After a reboot, the registry's environment item of such a name is the bare slot's entry, the row hydrated last. With rows bound to two or more packages beside it, that entry no longer counts as the environment's own item.
19+
- **A member that only a dependent's addition holds, over a base that holds the name only as stored rows** (base A stores `welcome` in `en-US`, dependent D, which declares A, stores `fr-FR`, and no package ships `welcome`). `GET /meta/email_template/welcome?member=fr-FR`, `GET /meta/email_template/welcome/layers?member=fr-FR` and the execution read at `fr-FR` move FROM D's row (200) TO `404 RESOURCE_NOT_FOUND`. That is the answer the same reads already gave when A ships `welcome`: a bundle addition holds no name, so the read takes the base's address, which holds no `fr-FR`. Each dependent is judged against its own declared dependencies, so with a second dependent D2 storing `de-DE` the reads at `fr-FR` and at `de-DE` both answer `404`, in either registration order. A dependent that also stores a member the base stores (D storing `en-US` as well as `fr-FR`) is still an addition, as the registry judges it (a member held only as stored rows is no clash), so its `fr-FR` answers `404` too.
20+
21+
**Not moved.** One package's row beside a package-less row is that package's, served on every bare door in both save orders, before and after a reboot. Each exact address (`?package=E`, `?package=F`, `?package=D&member=fr-FR`) serves its own row. The base's own member (`?member=en-US`) is the base's; where the dependent stores it too over a row-held base, the read there refuses naming both, as before. The read naming no member (the canonical member, `GET /meta/email_template/welcome` and `/published`) is not moved, even where a dependent stores the canonical member over a row-held base that holds only another one. A name with a disabled holder keeps its own judgment (#32354), and a package-less row beside a disabled holder leaves the read as it was (that shape, with the plain read following save order while `/layers` refuses, is #34440). The canonical member of a shipped base that holds only another member answers differently before and after a restart (#34441); this change does not move it. The writes do not move: in the first shape the save naming no package was already refused `409 RESOURCE_CONFLICT` naming E and F, writing nothing, and still is, so it now agrees with the read. A save that edits a package-unbound row while the read refuses is another shape, two enabled packages that ship the name with no package's row stored (#34348, decision open); this change does not move it either.
22+
23+
The ADR-0087 entry `row-held-base-addition-bare-read-at-base` registers the second move. The first is the narrowing `two-row-holders-bare-read-refused` already registers: two or more enabled packages hold the name only as stored rows. That entry's `reason` now says how the holders are judged: by the packages the rows are bound to at the member read, with the registry's holders only helping recognise a customization pair.

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

Lines changed: 149 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -43,11 +43,11 @@ import type { ObjectStackProtocolImplementation } from './protocol.js';
4343
import { shippingPackageIds } from './protocol-environment-rows.js';
4444
import { bundleMemberDiscriminator, resolveBundleMemberSelector } from './protocol-bundle-members.js';
4545
import { installedManifestsOfEngine } from './installed-manifests.js';
46-
import { pairsOf } from '@objectstack/metadata-core';
46+
import { packageDependencyClosure, pairsOf, type PackageClosureRegistry } from '@objectstack/metadata-core';
4747
import { disabledExactAddressHolder } from './protocol-exact-qualifier.js';
4848
import type { PrereadActiveRows } from './protocol-meta-item-reads.js';
4949
import { PLURAL_TO_SINGULAR } from '@objectstack/spec/shared';
50-
import { overlayMemberWhere } from './migrations/overlay-index.js';
50+
import { overlayMemberValue, overlayMemberWhere } from './migrations/overlay-index.js';
5151
import { isServedOverrideRowOf } from './served-override.js';
5252
import {
5353
isActionWithheldByDisabledPackage,
@@ -274,7 +274,12 @@ const SERVED_HOLDER_JUDGED_ELSEWHERE: ReadonlySet<string> = new Set(['object', '
274274
* it: {@link servedHolderAddressOf} and `packagelessContentPackage` judge
275275
* it), and when no package-less row and no
276276
* environment item is stored (a customization of no one holder, judged as
277-
* before). Then the holders are the registry's served holders and the
277+
* before). [#33210] On the item face (`options.refuseWithoutDisabled`) a
278+
* package-less row, or the registry's environment item, beside rows bound to
279+
* two or more packages with no disabled package among them is judged with
280+
* those rows instead ({@link storedRowHoldersRefusal}), so it is refused
281+
* naming them; beside one holder, none, or a disabled holder the read is left
282+
* as it was. Then the holders are the registry's served holders and the
278283
* packages the active rows are bound to, less every disabled package:
279284
*
280285
* - one → `{ kind: 'served' }`, read at its address, as the registry's
@@ -332,9 +337,9 @@ export async function servedRowHolderOf(
332337
return undefined;
333338
}
334339
if ([...shippingPackageIds(host.shippedArtifactsOf(type, name, undefined, member))].some((id) => !disabled(id))) return undefined;
335-
if (typeof registry.getEnvironmentScopedItem === 'function' && registry.getEnvironmentScopedItem(type, name, member) !== undefined) {
336-
return undefined;
337-
}
340+
const environmentItem = typeof registry.getEnvironmentScopedItem === 'function'
341+
&& registry.getEnvironmentScopedItem(type, name, member) !== undefined;
342+
if (environmentItem && options.refuseWithoutDisabled !== true) return undefined;
338343
// The item's active rows, read once: every row binds a holder, and only
339344
// the rows the reads serve make a served one (S4). An unprovisioned store
340345
// holds no row.
@@ -346,10 +351,21 @@ export async function servedRowHolderOf(
346351
activeRows = [];
347352
}
348353
const rows = await host.packagelessAddress(type, name, member, 'active', activeRows);
349-
if (rows.unbound) return undefined;
354+
// [#33210, ADR-0150 D3] The registry's environment item of a name no
355+
// package ships is the bare slot's entry, the row hydrated last: after a
356+
// reboot that is the package-less row whenever it was saved last. Beside
357+
// rows bound to two or more packages it is no environment item but a
358+
// customization of a name it cannot say whose, judged with them below, so
359+
// the answer follows no save order. Otherwise the environment's own item
360+
// leaves the read as it was.
361+
if (environmentItem && !(rows.unbound && rows.candidates.length > 1)) return undefined;
350362
const every: readonly string[] = registry.packageScopedHoldersOf(type, name, null, { includeDisabledPackages: true }) ?? [];
351363
const anyDisabled = [...every, ...rows.candidates].some(disabled);
364+
// [#33210] The no-disabled arm judges a package-less row itself
365+
// ({@link storedRowHoldersRefusal}); beside a disabled holder it leaves
366+
// the read as it was.
352367
if (!anyDisabled) return options.refuseWithoutDisabled === true ? storedRowHoldersRefusal(host, type, name, member, every, activeRows, rows.candidates) : undefined;
368+
if (rows.unbound) return undefined;
353369
const installed = installedManifestsOfEngine(host.engine);
354370
const pairRow = (row: { package_id?: unknown }): boolean =>
355371
typeof row.package_id === 'string' && every.some((holder) => pairsOf(holder, installed).includes(row.package_id as string));
@@ -406,7 +422,13 @@ const STORED_ROW_HOLDERS_REFUSAL: unique symbol = Symbol.for('objectstack.metada
406422
* ({@link ObjectStackProtocolImplementation.declinesStoredRow}) and a row of a
407423
* customization pair of another package the rows or the registry name
408424
* (`pairsOf`), which is that package's customization, never a holder of its
409-
* own. An unbound package-less row among them leaves the read as it was.
425+
* own.
426+
*
427+
* [#33210, ADR-0150 red line 2] A package-less row among them is no holder
428+
* and no tie-break: beside two or more holders the read is refused naming
429+
* them, as `/layers` refuses the same rows (`packagelessLayeredReadRefusal`),
430+
* where it served a row by store order; beside one holder or none it leaves
431+
* the read as it was.
410432
*/
411433
async function storedRowHoldersRefusal(
412434
host: ServedRowHost,
@@ -423,7 +445,13 @@ async function storedRowHoldersRefusal(
423445
&& known.some((holder) => holder !== row.package_id && pairsOf(holder, installed).includes(row.package_id as string));
424446
const holding = await host.packagelessAddress(type, name, member, 'active', activeRows.filter((row) =>
425447
!host.declinesStoredRow(type, name, row) && !pairOfAnother(row)));
426-
if (holding.unbound) return undefined;
448+
// [#33210, ADR-0150 red line 2] A package-less row beside two or more
449+
// holders is a customization of a name it cannot say whose (the
450+
// registry binds it to no package): reading past it still leaves those
451+
// holders, so it is refused naming them below, as `/layers` refuses it,
452+
// and never served in their place. Beside one holder or none it leaves
453+
// the read as it was.
454+
if (holding.unbound && holding.candidates.length < 2) return undefined;
427455
// [#32662 scope note (b), ADR-0150 D3] One holder whose rows are its own
428456
// and its customization pair's: the read is that holder's, at its address,
429457
// as `/published` reads it, so the layer served is its own row in both
@@ -572,6 +600,111 @@ export async function declaredMemberOverrideAddressOf(
572600
: undefined;
573601
}
574602

603+
/**
604+
* [#33210 (c), ADR-0150 D3, #28802 R2] The address a read naming no package
605+
* takes for a bundle member that only a dependent's ADDITION holds, over a
606+
* base that holds the name only as stored rows: that base. The read then
607+
* answers the base's member, which it does not hold (404), as it does when the
608+
* base ships the name, where `packagelessContentPackage` reads the shipper.
609+
* `undefined` leaves the read as it was.
610+
*
611+
* Measured on `main` 66f6638fa4, on a booted kernel, before and after a
612+
* reboot. Base A holds `welcome` in `en-US`, and dependent D, which declares
613+
* A, holds `fr-FR`. When A ships `en-US`, the plain read, `/layers` and the
614+
* execution face at `fr-FR` answered 404. When A holds `en-US` only as a
615+
* stored row, all three served D's row. In both, the registry named A the
616+
* name's one holder (a bundle addition holds no name). The two differed only
617+
* in the grain the base was read at: the shippers at the name, the rows'
618+
* bindings at the member.
619+
*
620+
* Judged at the rows' grain, as the registry judges an addition
621+
* (`isBundleAddition`, read by `packageScopedHoldersOf`). Every active row at
622+
* the member is bound to a package, and none is declined
623+
* ({@link ObjectStackProtocolImplementation.declinesStoredRow}). Each package
624+
* holding members of the name as active rows is judged against its OWN
625+
* declared dependency closure: it is an addition when some other row-holding
626+
* package B is in that closure and it is not in B's. [#33210 contract review
627+
* S2] A member both hold is no clash here: the registry counts a clash only
628+
* at a member either package ships in code (`codeMembersOf`, #33127), and
629+
* this arm runs only for a name no package ships, so a member two packages
630+
* hold only as stored rows never clashes. A dependent that also stores a
631+
* member the base stores (D's `en-US` and `fr-FR` over A's `en-US`) stays an
632+
* addition, as the registry names A the one holder there; the read at the
633+
* shared member is left to the rows' own judgment (A holds a row there). The
634+
* base is the one row-holding package that is no addition;
635+
* the read is moved only when there is exactly one, it holds no row at the
636+
* member, and no package at the member is a customization pair of another
637+
* row-holding package (`pairsOf`: a pair's added member is served on its
638+
* base's address already, #28802 ruling A). So a second dependent adding a
639+
* member of its own (D1 `fr-FR`, D2 `de-DE` over A's `en-US`) leaves A the
640+
* base at each dependent's member, as the registry names A the one holder
641+
* whichever packages are installed, and a dependent of a dependent is an
642+
* addition to it. The arm applies only to a bundled type the registry reads
643+
* by package, for a name no package ships (a shipped name is the shipper's
644+
* already), at a named member other than the canonical one, with no
645+
* environment item at the member and no disabled package among the
646+
* row-holding packages (the served-holder judgment above reads those).
647+
*/
648+
export async function rowHeldBaseAddressOf(
649+
host: ServedRowHost,
650+
type: string, name: string, member: string | undefined,
651+
): Promise<string | undefined> {
652+
const registry: any = host.engine?.registry;
653+
if (typeof registry?.readsByPackage !== 'function' || registry.readsByPackage(type) !== true) return undefined;
654+
const singular = PLURAL_TO_SINGULAR[type] ?? type;
655+
// [#33210 contract review S1] A NAMED non-canonical member only.
656+
// `overlayMemberValue` answers null for the canonical member, named or
657+
// not, and the read naming no member addresses it (reachable without
658+
// `?member=` and from `/published`). That mirror is left as it was: with
659+
// a shipped base holding only another member, its answers move across a
660+
// reboot and the read naming no member serves the base's other member,
661+
// so there is no one shipped answer to align it with.
662+
if (typeof overlayMemberValue(singular, member) !== 'string') return undefined;
663+
if (shippingPackageIds(host.shippedArtifactsOf(type, name)).size > 0) return undefined;
664+
if (typeof registry.getEnvironmentScopedItem === 'function' && registry.getEnvironmentScopedItem(type, name, member) !== undefined) {
665+
return undefined;
666+
}
667+
let activeRows: Awaited<ReturnType<ServedRowHost['readItemActiveRows']>>;
668+
try {
669+
activeRows = await host.readItemActiveRows(type, name);
670+
} catch (error) {
671+
host.rethrowUnlessMetadataStoreUnprovisioned(error, 'sys_metadata');
672+
activeRows = [];
673+
}
674+
const rows = activeRows.filter((row) => rowMatchesOverlayWhere(row, { type: singular, name, state: 'active' }));
675+
const memberWhere = { type: singular, name, state: 'active', ...overlayMemberWhere(singular, member) };
676+
const atMember = rows.filter((row) => rowMatchesOverlayWhere(row, memberWhere));
677+
const packageOf = (row: { package_id?: unknown }): string | undefined =>
678+
typeof row.package_id === 'string' && row.package_id !== '' ? row.package_id : undefined;
679+
if (atMember.length === 0 || atMember.some((row) => packageOf(row) === undefined || host.declinesStoredRow(type, name, row))) {
680+
return undefined;
681+
}
682+
const holders = [...new Set(rows
683+
.filter((row) => !host.declinesStoredRow(type, name, row))
684+
.map(packageOf)
685+
.filter((id): id is string => id !== undefined))];
686+
if (typeof registry.isPackageDisabled === 'function' && holders.some((id) => registry.isPackageDisabled(id) === true)) {
687+
return undefined;
688+
}
689+
const closure = (id: string): readonly string[] => packageDependencyClosure(id, registry as PackageClosureRegistry)?.dependencies ?? [];
690+
// [#33210 contract review M1] Each package against its own closure, as
691+
// `isBundleAddition` judges it: an addition to ANY other holder it
692+
// declares, never to one base every package must share. [S2] No member
693+
// clashes: no package ships the name here, and the registry's clash is
694+
// a member shipped in code (`codeMembersOf`), never one held only as
695+
// stored rows.
696+
const isAdditionTo = (id: string, other: string): boolean => other !== id
697+
&& closure(id).includes(other) && !closure(other).includes(id);
698+
const bases = holders.filter((id) => !holders.some((other) => isAdditionTo(id, other)));
699+
if (bases.length !== 1) return undefined;
700+
const [base] = bases;
701+
const additions = new Set(atMember.map((row) => packageOf(row)!));
702+
if (additions.has(base)) return undefined;
703+
const installed = installedManifestsOfEngine(host.engine);
704+
const isPairOfAHolder = (id: string): boolean => holders.some((other) => other !== id && pairsOf(other, installed).includes(id));
705+
return [...additions].some(isPairOfAHolder) ? undefined : base;
706+
}
707+
575708
/** The body of `ObjectStackProtocolImplementation#readMetaItemFace`; the method's docblock there is its contract. */
576709
export async function readMetaItemFace(
577710
this: Pick<MetaItemFaceHost, 'readMetaItem'> & ServedRowHost,
@@ -612,10 +745,16 @@ export async function readMetaItemFace(
612745
// [#32849] …and a member whose one shipper's declared override is stored
613746
// is read at that shipper ({@link declaredMemberOverrideAddressOf}).
614747
const member = request.packageId ? undefined : resolveBundleMemberSelector(request.type, request.member);
748+
// [#33210 (c)] …and a member only a dependent's addition holds, over a
749+
// base holding the name only as stored rows, is read at that base
750+
// ({@link rowHeldBaseAddressOf}), as it is when the base ships the name.
615751
const servedAddress = request.packageId
616752
? undefined
617753
: await servedAddressOf(judgeHost, request.type, request.name, member, { refuseWithoutDisabled: true })
618-
?? (request.state === 'draft' ? undefined : await declaredMemberOverrideAddressOf(judgeHost, request.type, request.name, member));
754+
?? (request.state === 'draft'
755+
? undefined
756+
: await declaredMemberOverrideAddressOf(judgeHost, request.type, request.name, member)
757+
?? await rowHeldBaseAddressOf(judgeHost, request.type, request.name, member));
619758
const answer = await this.readMetaItem(servedAddress === undefined ? request : { ...request, packageId: servedAddress }, { face, ...(activeRows !== undefined ? { activeRows } : {}) });
620759
// [#28877] The served read of an `action` also withholds one that launches
621760
// into a disabled package, as the served list does.

0 commit comments

Comments
 (0)