Skip to content

Commit 89d7bef

Browse files
fix(metadata-protocol)!: the exact read no longer serves an undeclared App-pair row the registry binds to no package; it adopts SchemaRegistry#overlayRowBinding over the served holders (ADR-0150 D4) (#33148)
<!-- claude-projects-attribution: {"github_login":"os-elon-musk"} --> _Requested by **Elon** · [project thread](https://claude.ai/code/project/chan_01WedDzV26nniwxv7jC88B9D?thread=cmsg_01WedDzV26nniwxv7jC88B9DXz8JJapH4ybVrJL1L6Fv5X)_ Fixes #32561 Clause-②: yes (narrowing) Metadata-protocol: narrowed Skills-docs: none — `skills/objectstack-platform/SKILL.md` teaches the declared form (`overrides: { package }`) and an undeclared pair row only at a locale the base does not ship, the path the save door accepts; nothing in `skills/**` teaches the exact read of an undeclared pair row whose locale a later bundle addition also ships, or of a row beside another App's shared pair, the two reads this narrows (grep of `skills/**` for `overrides.package`, `.custom`, `?package=` and `email_template` at head `dd283faf40`). > **BREAKING** (ADR-0087 `registered`, semantic entry `pair-row-exact-read-no-owner`): two exact reads of an undeclared row of an App's customization pair stop serving a row the registry binds to no package. First-party packages in either position: 0. Remedy the save door already accepts: declare the base with `overrides.package`. ## 维护者速读 - 改了什么:App 的定制配对(`<app>.custom`)里一条**未声明基准包**的行(没有 `overrides.package`),如果注册表判定它“不属于任何包”(因为同 App 的另一个包作为附加包也出货了同一个语言成员,或另一个 App 的共享配对也存了同名未声明行),按包精确读(`?package=X`)以前仍把它当 X 的定制返回;现在精确读采用注册表的判定,`?package=X` 只回答 X 自己出货的成员(没有就 404),`?package=<app>.custom` 仍能读到这条行。 - 为什么改:两个读取口对同一条行给出不同归属,精确读等于替作者猜了一个包(违反史诗红线 2:歧义要报告,不能猜)。新增一个只读公开方法 `SchemaRegistry#overlayRowBinding`,让精确读直接问注册表,不再自己另数一遍。 - 风险与回滚:收紧(narrowing,BREAKING,minor)。只影响“未声明 + 有歧义”的配对行,第一方包为 0;声明了 `overrides.package` 的行、单一归属的行、两个持有包可归属时的 409 都不变;一个持有包被禁用时,启用那个包的地址仍保有该行(R4-A 裁决)。回滚 = revert 本 PR。 - 先看:`packages/metadata-protocol/src/protocol-exact-qualifier.ts` 的 `pairRowOnAddress` 新增一行判定;`packages/objectql/src/registry.ts` 新增的 `overlayRowBinding`(只数被服务的持有包);`packages/objectql/src/package-scoped-exact-qualifier.test.ts` 的 `[#32561]` 组。 - 两分钟验证:`pnpm --filter @objectstack/objectql exec vitest run src/package-scoped-exact-qualifier.test.ts`,预期全部通过;其中 `[#32561]` 组的 NARROWING(两种安装顺序 + 跨 App 配对)与 CONTROL(声明行、禁用一个持有包两种顺序)全绿。 - 需要你做的:无,席位落地。 ## What changes The exact read's owner check (`pairRowOnAddress`, `@objectstack/metadata-protocol`) counted holders after the registry had bound the row: a bundle addition was no holder there, and another App's shared pair was never read. The registry (`SchemaRegistry#pairRowBinding`, since #32408 / PR #32815) counts an addition that ships the row's member as a second owner, and binds a row whose count would read another shared pair's undeclared row to no package. The two readers had no common answer (the card's divergence). Now the exact read adopts the registry's binding instead of counting again: - `SchemaRegistry#overlayRowBinding(type, name, item)` (new, public, read-only, `packages/objectql/src/registry.ts`): the binding `overlaySlotBinding` answers, counted over the **served** holders (a disabled package holds no name, ADR-0150 D3), in the order `packageScopedHoldersOf` counts the exact read's owner: the pair's owners are the served holders it customizes, and the bundle-addition rule is settled over **every** holder, the disabled ones left out afterwards, so a disable never promotes a dependent's addition to an owner (contract review M1). The holders are the ones `packageScopedHoldersOf` counts: every composite slot, then the package each bare-slot entry binds to, so a package holding the name only through its own stored row is an owner here too (contract review n1). The registry's own readers keep counting every holder, so a disable never moves their binding. - `pairRowOnAddress` takes the binding lazily (`registryBinding`) and treats an undeclared pair row as not this address's member when its one owner is not the one the registry binds it to. Both callers (`exactQualifierItem`, `pairMemberWithheldAt`) pass it; a registry without `overlayRowBinding` keeps the exact read's own count. | Read (App A; X holds the email template; Z, on X, ships only `fr-FR` as an addition; `A.custom` stores an undeclared `fr-FR` row) | Before | Now | |:--|:--|:--| | `?package=X&member=fr-FR` (Z installed before the row, or after it) | the row | X's own `fr-FR`: none, `404` | | X's list and execution list | carry the row | leave it out | | `?package=Z&member=fr-FR` | Z's own `fr-FR` | unchanged | | `?package=A.custom&member=fr-FR` | the row | unchanged | | `?package=Y` / `?package=P` when App A's pair and App B's pair each store an undeclared row of the name (registry binds neither) | the pair's row | the package's own item of that member (none) | Unchanged (CONTROL pins): a row declaring its base (`overrides.package`) binds and serves as declared; two holders that could own a row still refuse `409` naming both; a row whose one owner the registry binds it to is served as before; with one of two holders disabled, the enabled holder's address, list and execution list keep the undeclared row (residual (3), ruled C in 6837007729, keeping #32183 R4-A), re-enabled it is refused naming both; and the same when the disabled holder is the base of a bundle addition (Z on the App and on Y ships only `fr-FR`, Y disabled): Z stays an addition, X keeps the row; and when X holds the name only through its own stored row in the bare slot, X's address keeps the undeclared pair row as on `main`. Files: `protocol-exact-qualifier.ts`, `registry.ts`, the pins in `package-scoped-exact-qualifier.test.ts` (and one comment line in `package-scoped-resolver.test.ts`), the semantic entry `packages/spec/src/migrations/entries/semantic/18.pair-row-exact-read-no-owner.ts`, and two changesets (`metadata-protocol` + `objectql` minor, BREAKING, `adr-0087: registered`; `spec` patch for the entry). ## Tests `packages/objectql/src/package-scoped-exact-qualifier.test.ts`, describe `[#32561] …`: - NARROWING, residual 1: an undeclared row of the very locale a bundle addition of another package of the App ships, addition installed first; and the other order (row stored while X alone held the name, CONTROL that X served it, then Z installed). Each asserts the registry binds it to no package, `?package=X` answers nothing, `?package=Z` Z's own, `?package=A.custom` the row, X's list and X's execution list leave it out (contract review S1), and X's own `en-US` stays X's. - CONTROL: a row declaring X keeps X's address beside the addition. - NARROWING, residual 2 (contract review F6 of #32408): two Apps' pairs each storing an undeclared row of the name; neither package address serves either row, each pair's own address does. - CONTROL, residual 3, both registration orders: one of two holders disabled keeps the row on the enabled holder's address, list and execution list; re-enabled, refused naming both. - CONTROL, contract review M1, both registration orders: X and Y ship `en-US`, Z (on the App and on Y) ships only `fr-FR`, an undeclared `de-DE` pair row, Y disabled: the owner count is `[X]`, the adoption binds the row to X, `?package=X&member=de-DE` serves it and both of X's lists keep it, Z keeps its own `fr-FR`; re-enabled, refused naming X and Y. **Red on `72c8a9c8ef`** (2 failed / 249 passed in the file: `AssertionError: the adoption counts as the exact read does: expected undefined to be 'com.acme.suitex'`), green at `5a9d589a80`. - UNCHANGED, contract review n1, both registration orders (X's holding first, the pair row first): X holds the name only through its own stored row in the bare slot (a row with `package_id` X hydrated, no composite slot) and the App's pair stores an undeclared `de-DE` row: the adoption binds the row to X, `?package=X&member=de-DE` serves it, X's own `en-US` stays X's. **Red on `5a9d589a80`** (2 failed: ``AssertionError: the adoption counts X as the exact read does: expected 'com.acme.suite.custom' to be 'com.acme.suitex'``), green at `dd283faf40`. Beside it, the CONTROL with X's item in its composite slot, both orders, also pins X's list and execution list. Ablations on head `dd283faf40` (each through `scripts/ablation-replace.mjs`, landing proved, restored to the HEAD blob with `git diff HEAD` empty): | Ablation | Red / green of 375 (the two harness files) | |:--|:--| | A1: `pairRowOnAddress`'s new line guarded off; `metadata-protocol` rebuilt, `ablation-dist-preflight` marker present in 2 built files (restore: rebuilt, absent from all 24) | **3 / 372**: the three NARROWING pins. ``AssertionError: `?package=X`: X ships no fr-FR: expected { name: 'welcome', …(6) } to be undefined`` | | A2: `overlayRowBinding` keeps every holder, a disabled one included (`registry.ts` is imported relatively by the suite, no build) | **7 / 368**: the two residual-3 CONTROLs, the two M1 CONTROLs, the three #32183 / #32408 disable pins. `AssertionError: the adoption counts the served holders: expected undefined to be 'com.acme.suitex'` | | A3: the addition rule settled over the served holders only (round 1's shape) | **2 / 373**: the two M1 CONTROLs. `AssertionError: the adoption counts as the exact read does: expected undefined to be 'com.acme.suitex'` | | A4: the adoption counts composite slots only (round 1's holder set) | **2 / 373**: the two n1 pins. ``AssertionError: the adoption counts X as the exact read does: expected 'com.acme.suite.custom' to be 'com.acme.suitex'`` | | restored | 375 / 375 | ## Acceptance notes - This branch resumes `claude/project-thread-04ua2f@c233053` and merges `origin/main` once (`bf02d33bd`, merge commit `72c8a9c8ef`). The branch had carried PR #32815's round-3 head; the four conflicts (`objectql/src/registry.ts`, the two `package-scoped-*` test files, `18.pair-row-locale-addition-refused.ts`) each take main's landed copy (`e336a33eb`) with the card's own four commits replayed onto it, and the two `32408-*` changesets stay deleted (consumed by version packages #29963). Measured: the card's `+/-` lines vs main equal the branch's delta over PR #32815's head `c3cc324b1` line for line, apart from main's own permission-set lines. The diff against `main` is the card's seven files only. Main's #33130 (#32354) and #33126 (#32613) are in the merged head; `protocol-exact-qualifier.ts` merged without conflict. - Residual shape from the epic red-line read 6841098779 (card comment 6841146506): measured in 6863197549, `main`'s and not moved here (W's exact address, list and execution list serve a row **declared** for X when X holds nothing, on `main` and at this head alike); the seat routes it. - Contract review n1, answered: reachable with the harness double (X holding the name only through its own stored row in the bare slot), where round 1's adoption withheld the App's undeclared pair row at `?package=X` while `main` served it. Fixed here (the adoption counts the holders as `packageScopedHoldersOf` does) and pinned; no second move to declare. Observed beside it and not moved: in that state X's list and execution list leave the row out, on `main` and at this head alike (the list door's own count), while X's exact address serves it; outside this card, left for the seat to route. - The bare member read ignoring a declared pair override stays with the follow-up card (sub-issue of this card, blocked by it); this PR does not touch it. - #32607 shares `protocol-exact-qualifier.ts` and runs after this card lands. ## Verification All local readings on head `dd283faf40` (round 2: `5a9d589a80` for M1 and S1, then `dd283faf40` for n1; no commit after it). <details><summary>Affected suites and typecheck</summary> - `pnpm --filter @objectstack/metadata-protocol test`: Test Files 337 passed, 7 skipped (344); Tests 22803 passed, 36 skipped (22839). `typecheck` exit 0. Lock `VERDICT command-exit 0`. - `pnpm --filter @objectstack/objectql test`: Test Files 595 passed (595); Tests 12843 passed (12843). `typecheck` exit 0. Lock `VERDICT command-exit 0`. - Focused files (`package-scoped-exact-qualifier.test.ts`, `package-scoped-resolver.test.ts`): 375/375 (369 at `72c8a9c8ef`, plus the two M1 CONTROLs and the four n1 pins). </details> <details><summary>dispatch-gates</summary> `node scripts/pm/dispatch-gates.mjs --commands` derived the same 94 commands from the same 7 paths vs merge base `bf02d33bd`. All 94 exit 0 (`check:dual-build-cjs-loads` measured this round: the dogfood closure build gave it its prerequisite). `check:type-check-debt` first answered exit 3 `PREREQUISITE NOT MET` (its closure build never got the verify lock while the dogfood battery held it); re-run under the lock: exit 0, "0 ledger entr(ies) re-measured … none above its recorded number". `dispatch-gates --ran`: "94 derived famil(ies) accounted for — 94 run, 0 NOT-MEASURED". ```text node scripts/check-adr-0087-registration.mjs --base origin/main :: exit 0 node scripts/check-adr-0087-registration.mjs --self-test :: exit 0 node scripts/check-changeset-no-major.mjs --base origin/main :: exit 0 node scripts/check-closing-keyword-parity.mjs :: exit 0 node scripts/check-closing-keyword-parity.mjs --self-test :: exit 0 node scripts/check-comment-mask-adoption.mjs :: exit 0 node scripts/check-comment-mask-adoption.mjs --self-test :: exit 0 node scripts/check-comment-mask-corpus.mjs :: exit 0 node scripts/check-dev-prereqs.mjs --self-test :: exit 0 node scripts/check-dts-emitted.mjs --self-test :: exit 0 node scripts/check-empty-changeset.mjs --base origin/main :: exit 0 node scripts/check-empty-changeset.mjs --self-test :: exit 0 node scripts/check-engine-split-ratio.mjs --self-test :: exit 0 node scripts/check-issue-citations.mjs :: exit 0 node scripts/check-plugin-teardown-shape.mjs :: exit 0 node scripts/check-plugin-teardown-shape.mjs --self-test :: exit 0 node scripts/ci/assert-turbo-remote-cache.mjs --self-test :: exit 0 node scripts/ci/plan-test-core-shards.mjs --self-test :: exit 0 node scripts/ci/prune-turbo-cache.mjs --self-test :: exit 0 node scripts/ci/snapshot-next.mjs --self-test :: exit 0 node scripts/docs-audit/check-affected-docs.mjs :: exit 0 node scripts/docs-audit/check-drift-comment.mjs :: exit 0 node scripts/pm/release-rehearsal-clone.mjs --self-test :: exit 0 node scripts/release-pending-publish.mjs --self-test :: exit 0 pnpm --filter @objectstack/lint run check:doc-formula-expressions :: exit 0 pnpm --filter @objectstack/spec run check:api-surface :: exit 0 pnpm --filter @objectstack/spec run check:authorable-surface :: exit 0 pnpm --filter @objectstack/spec run check:browser-reachable-entries :: exit 0 pnpm --filter @objectstack/spec run check:docs :: exit 0 pnpm --filter @objectstack/spec run check:dual-source-exports :: exit 0 pnpm --filter @objectstack/spec run check:duration-unit-keys :: exit 0 pnpm --filter @objectstack/spec run check:empty-state :: exit 0 pnpm --filter @objectstack/spec run check:entry-nameability :: exit 0 pnpm --filter @objectstack/spec run check:error-code-provenance :: exit 0 pnpm --filter @objectstack/spec run check:export-origins :: exit 0 pnpm --filter @objectstack/spec run check:exported-any :: exit 0 pnpm --filter @objectstack/spec run check:liveness :: exit 0 pnpm --filter @objectstack/spec run check:llms-txt :: exit 0 pnpm --filter @objectstack/spec run check:skill-refs :: exit 0 pnpm --filter @objectstack/spec run check:spec-changes :: exit 0 pnpm --filter @objectstack/spec run check:strictness-ledger :: exit 0 pnpm --filter @objectstack/spec run check:upgrade-guide :: exit 0 pnpm --filter @objectstack/spec run check:variant-docs :: exit 0 pnpm check:adr-symbol-anchors :: exit 0 pnpm check:changeset-gate-self-tests :: exit 0 pnpm check:ci-filter-parity :: exit 0 pnpm check:cli-command-ids :: exit 0 pnpm check:closed-ceremony-text :: exit 0 pnpm check:cross-package-test-inputs :: exit 0 pnpm check:dispatcher-error-vocabulary :: exit 0 pnpm check:doc-authoring :: exit 0 pnpm check:driver-memory-census :: exit 0 pnpm check:dts-closure :: exit 0 pnpm check:dual-build-cjs-loads :: exit 0 pnpm check:durability-log-level :: exit 0 pnpm check:engine-double-contract :: exit 0 pnpm check:error-status-conformance :: exit 0 pnpm check:gitlink-declared :: exit 0 pnpm check:init-service-contract :: exit 0 pnpm check:issue-citations :: exit 0 pnpm check:keyed-text-bounds :: exit 0 pnpm check:lean-entry-closure :: exit 0 pnpm check:logger-receiver-detach :: exit 0 pnpm check:merge-driver :: exit 0 pnpm check:nul-bytes :: exit 0 pnpm check:object-def-param-keys :: exit 0 pnpm check:objectql-double-limit :: exit 0 pnpm check:optional-error-sink :: exit 0 pnpm check:org-identifier :: exit 0 pnpm check:page-declaration-shape :: exit 0 pnpm check:platform-object-tenancy-census :: exit 0 pnpm check:pm-prior-rulings :: exit 0 pnpm check:published-files :: exit 0 pnpm check:query-options-erasure :: exit 0 pnpm check:refd-timer-probe :: exit 0 pnpm check:registry-log-declared :: exit 0 pnpm check:rest-log-declared :: exit 0 pnpm check:rest-log-spy-declared :: exit 0 pnpm check:role-word :: exit 0 pnpm check:settings-bind-window :: exit 0 pnpm check:slot-lookup :: exit 0 pnpm check:sourcemap-no-sources-content :: exit 0 pnpm check:spec-docblock-symbol-anchors :: exit 0 pnpm check:spec-parsed-alias :: exit 0 pnpm check:startup-registry-verdict :: exit 0 pnpm check:system-context-census :: exit 0 pnpm check:test-source-alias :: exit 0 pnpm check:tier-file-adoption :: exit 0 pnpm check:type-check-coverage :: exit 0 pnpm check:type-check-debt :: exit 0 pnpm check:undeclared-dep-imports :: exit 0 pnpm check:vouch-for-reference-callers :: exit 0 pnpm check:watch-hint-literal :: exit 0 pnpm check:where-matcher :: exit 0 ``` </details> <details><summary>Lint and dogfood</summary> `pnpm lint` (eslint, whole repo) on `dd283faf40`: exit 0. Full dogfood battery once on the final head `dd283faf40` (`Clause-②: yes (narrowing)`): closure `pnpm --filter '@objectstack/dogfood^...' build` (lock `VERDICT command-exit 0`), then `pnpm --filter @objectstack/dogfood test` under the lock, no shard, no path: `VERDICT command-exit 0` · Test Files 460 passed, 3 skipped (463) · Tests 3886 passed, 42 skipped (3928) · no failure. (Round 1's run on `72c8a9c8ef` read the same counts.) </details> --- _Generated by [Claude Code](https://claude.ai/code/session_016WV4cwzajrQVjjx4Dh1CA5)_ <!-- signed: epic:#31527#2 · os-elon-musk · session_016WV4czFhtRVZNBeHdQA6PW --> --------- Co-authored-by: Claude <noreply@anthropic.com> Co-authored-by: objectstack-fleet[bot] <332303061+objectstack-fleet[bot]@users.noreply.github.com>
1 parent 3eac63a commit 89d7bef

7 files changed

Lines changed: 350 additions & 9 deletions

File tree

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
---
2+
'@objectstack/metadata-protocol': minor
3+
'@objectstack/objectql': minor
4+
---
5+
6+
fix(metadata-protocol)!: the exact read (`?package=X`) no longer serves an undeclared App-pair row the registry binds to no package (ADR-0150 D4, red line 2)
7+
8+
Clause-②: yes (narrowing) — two exact reads that served a row of an App's customization pair now answer the address's own shipped item: `?package=X` for an undeclared pair row of the very bundle member a bundle addition of another package of the App ships, and a package's address for an undeclared pair row while another App's shared pair stores an undeclared row of the name. In both the registry binds the row to no package. First-party packages in either position: 0. The widening is one public method: `SchemaRegistry#overlayRowBinding(type, name, item)`, the registry's binding of a stored row, read-only, which the exact read asks.
9+
Metadata-protocol: narrowed
10+
11+
<!-- adr-0087: registered pair-row-exact-read-no-owner -->
12+
13+
**BREAKING** for two exact reads, both of an undeclared row of an App's customization pair (`<app>.custom`, a row with no `overrides.package`). An undeclared row that could customize either of two packages' members is not attributed to one of them (red line 2). To keep such a row on the package whose locale it customizes, save it with `overrides.package` naming that package, the package of the App that ships the locale: the save door accepts it (it already prescribes it, refusing `403 NOT_OVERRIDABLE` a new undeclared row of a locale an installed package ships), and `?package=<that package>` then serves the row. A row of a locale no package ships stays readable at `?package=<app>.custom`.
14+
15+
The exact read's owner check (`pairRowOnAddress`) counted the holders after the registry had bound the row, so a bundle addition was no holder there, and it never read another App's pair. The registry (`SchemaRegistry#pairRowBinding`, since #32408) counts an addition that ships the row's member as a second owner, and binds a row whose count would read another shared pair's undeclared row to no package. The exact read now adopts that binding: `SchemaRegistry#overlayRowBinding(type, name, item)`, a new read-only method, answers it over the holders the exact read serves (a disabled package holds no name, ADR-0150 D3), and `pairRowOnAddress` treats an undeclared pair row as no member of an address whose one owner it does not bind the row to. It adds no count of its own.
16+
17+
What moves (each line FROM → TO), with App A, X a package of A holding an email template's name, Z a package of A depending on X that ships only `fr-FR` of it (a bundle addition), and `A.custom` storing an undeclared `fr-FR` row:
18+
19+
- `?package=X&member=fr-FR`: FROM the row TO X's own `fr-FR` (none, `404`). X's list and execution list: FROM carrying the row TO leaving it out. Either order: Z installed before the row (reached by a hydrated row; the save door refuses that write `403 NOT_OVERRIDABLE`, prescribing the declaration) or after it (the row saved and published while X alone held the name, then Z installed). `?package=Z` keeps Z's own `fr-FR`; `?package=A.custom` keeps the row.
20+
- `?package=Y` / `?package=P` when App A's pair and App B's pair each store an undeclared row of the name (the registry binds neither): FROM the pair's row TO the package's own item of that member (none). Each pair's own address keeps its row.
21+
22+
Unchanged: a row declaring its base (`overrides.package`) binds and serves as declared; the App's own address keeps an undeclared row of its own pair (#28390 ruling A); two holders that could own a row still refuse `409` naming both; a row whose one owner the registry binds it to is served there as before; a registry without `overlayRowBinding` keeps the exact read's own count. With one of two holders of the name disabled, the enabled holder's address, list and execution list keep an undeclared row of the pair (#32183, epic ruling R4-A): the adoption counts the served holders, as the exact read does, while the registry's own readers keep counting every holder, so a disable never moves their binding.
Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
---
2+
'@objectstack/spec': patch
3+
---
4+
5+
docs(spec): the protocol upgrade guide names the two exact reads #32561 narrows: an undeclared row of an App's customization pair is no member of a package's address when the registry binds it to no package, because another package of the App ships its locale as a bundle addition or another App's shared pair stores an undeclared row of the name
6+
7+
Clause-②: no
8+
Metadata-protocol: none
9+
10+
The semantic entry `pair-row-exact-read-no-owner` (`packages/spec/src/migrations/entries/semantic/18.pair-row-exact-read-no-owner.ts`) registers the narrowing `.changeset/32561-exact-read-adopts-pair-row-binding.md` declares (ADR-0087, `adr-0087: registered`). There is no automatic rewrite, because which package's locale a pair row customizes is a judgement about that row. The remedy it names is the one the save door accepts: declare the package that ships the locale (`overrides.package`). It adds no key and no export.

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

Lines changed: 40 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -85,6 +85,16 @@ interface ExactQualifierRegistry {
8585
getEnvironmentScopedItem(type: string, name: string, member?: string): unknown;
8686
getPackageScopedItem(type: string, name: string, packageId: string, member?: string): unknown;
8787
getPackage?(id: string): unknown;
88+
/**
89+
* [#32561] The package the registry binds a stored row of `(type, name)`
90+
* to (objectql's `overlayRowBinding`, the one owner rule every registry
91+
* reader asks, counted over the served holders as this read counts them):
92+
* a package id, `null` for the environment's own item, or `undefined` for
93+
* no package. The exact read adopts it for an undeclared pair row
94+
* ({@link pairRowOnAddress}); a registry without it keeps the exact read's
95+
* own count.
96+
*/
97+
overlayRowBinding?(type: string, name: string, item: unknown): string | null | undefined;
8898
}
8999

90100
/**
@@ -422,7 +432,8 @@ export function exactQualifierItem(
422432
const bases = [address.packageId, ...address.registryHolders];
423433
if (bases.some((base) => isPairOf(served, base, installed))) {
424434
const verdict = pairRowOnAddress(served, item, address.packageId, bases,
425-
registry.packageScopedHoldersOf(request.type, request.name) ?? [], installed);
435+
registry.packageScopedHoldersOf(request.type, request.name) ?? [], installed,
436+
registryRowBinding(registry, request.type, request.name, item));
426437
if (verdict === 'serve') return item;
427438
if (verdict !== 'not-member') {
428439
throw refusal(request.type, request.name, address.packageId, 'ambiguous-in-closure',
@@ -716,7 +727,22 @@ export function pairMemberWithheldAt(
716727
const registry = exactQualifierRegistry(host);
717728
if (!registry || (registry as { readsByPackage?(type: string): boolean }).readsByPackage?.(type) !== true) return false;
718729
return pairRowOnAddress(pairId, item, base, [base], registry.packageScopedHoldersOf(type, name) ?? [],
719-
installedManifestsOfEngine(host.engine)) !== 'serve';
730+
installedManifestsOfEngine(host.engine), registryRowBinding(registry, type, name, item)) !== 'serve';
731+
}
732+
733+
/**
734+
* [#32561] The registry's binding of the stored row `item`, read lazily
735+
* ({@link ExactQualifierRegistry.overlayRowBinding}), or `undefined` when the
736+
* registry does not answer it (the exact read then keeps its own count).
737+
*/
738+
function registryRowBinding(
739+
registry: ExactQualifierRegistry,
740+
type: string,
741+
name: string,
742+
item: unknown,
743+
): (() => string | null | undefined) | undefined {
744+
const read = registry.overlayRowBinding;
745+
return typeof read === 'function' ? () => read.call(registry, type, name, item) : undefined;
720746
}
721747

722748
/**
@@ -735,6 +761,16 @@ export function pairMemberWithheldAt(
735761
* - Else two or more holders could own it: refuse, naming every one (F2).
736762
* - Else a sole owner that is not one of the address's bases owns it: not
737763
* this address's member (S2).
764+
* - [#32561] Else a sole owner the registry does not bind the row to
765+
* (`registryBinding`, the registry's one owner rule: `pairRowBinding`
766+
* counts a bundle addition that ships the row's member as an owner, and
767+
* binds a row whose count would read another shared pair's undeclared row
768+
* to no package) is no owner of it: not this address's member, so the
769+
* address answers its own shipped item (epic ruling, red line 2). The
770+
* exact read adopts the registry's count rather than counting again. Both
771+
* count the served holders (a disabled package holds no name, ADR-0150
772+
* D3): with one of two holders disabled, the row stays the enabled one's
773+
* member (#32183, epic ruling R4-A).
738774
* - Else (the sole owner is a base, or no holder pairs it) it is served.
739775
*/
740776
export function pairRowOnAddress(
@@ -744,13 +780,15 @@ export function pairRowOnAddress(
744780
bases: readonly string[],
745781
holders: readonly string[],
746782
installed: InstalledManifestLookup,
783+
registryBinding?: () => string | null | undefined,
747784
): 'serve' | 'not-member' | { refuse: string[] } {
748785
const declared = declaredOverrideBase(item);
749786
if (declared !== undefined) return bases.includes(declared) ? 'serve' : 'not-member';
750787
if (isAppPairOf(pairId, addressPackageId, installed)) return 'serve';
751788
const owners = pairMemberOwners(pairId, holders, installed, item);
752789
if (owners.length > 1) return { refuse: owners };
753790
if (owners.length === 1 && !bases.includes(owners[0]!)) return 'not-member';
791+
if (owners.length === 1 && registryBinding !== undefined && registryBinding() !== owners[0]) return 'not-member';
754792
return 'serve';
755793
}
756794

0 commit comments

Comments
 (0)