Skip to content

Commit e336a33

Browse files
fix(objectql)!: every reader of the registry's overlay slot binds a row of an App's customization pair by the exact read's owner rule (ADR-0150 D4) (#32815)
<!-- claude-projects-attribution: {"github_login":"os-sales"} --> _Requested by **Sales** · [project thread](https://claude.ai/code/project/chan_01D5bWFY3rFzgJcytD5gD4Uu?thread=cmsg_01D5bWFY3rFzgJcytD5gD4UuL52R8FMLzUQgRajtajcGYX)_ Supersedes #32557 (same work; its branch claude/project-thread-3e08el could not be pushed from this container). Its review history stays there: review records 6815300751 and 6815340803. Fixes #32408 Follow-up: #32561 Clause-②: yes (narrowing) — two refusals where a registration was admitted before. First (row 1), with the bare-name holders sealed, a package whose only members of an email template's name are locales the App ships none of, while the App's pair stores a row of that locale declaring another package of the App (`overrides.package`), is refused naming the App as an addition to the App's template, where it was admitted because the pair's row counted as the App's own member. Second (row 13), with the holders sealed, a package of another namespace on a package X that holds an email template's name alone (or one that X's dependencies reach), shipping only a locale X ships none of, while a package-less row of that locale (a legacy overlay in the environment's slot) customizes X's template, is refused naming X as an addition to X's template, where it was admitted because that row counted as X's member; once admitted, the row bound to neither package and the cold boot's seal reported the package. First-party packages in either position: 0. The previous head's admission beside X (row 12) is withdrawn (epic ruling 6838245909, option B): where a row of the App's pair now binds to X, the bare-name gate lends X no locale, so a package of another namespace on X shipping only that locale is refused and reported as on `main`, in either registration order; admitting it is #32899. Beside them, a read withholds a row it served: with every package of the App that holds the name disabled, a row of the App's pair is that disabled holder's, so the bare read and an addition's address withhold it as they withhold any name only disabled packages hold (rows 10 and 11). Every moved answer is in the table below and in the changeset. Metadata-protocol: narrowed Skills-docs: none — no file under `skills/**` or `content/docs/` describes how a customization pair's row binds in the registry; ADR-0146 D2/D3 and the epic's ruling on #31699 F2 already state the rule this PR makes every reader follow. ## 维护者速读 - 改了什么:App 的定制包(`APP.custom`)里存的一行,注册表的其余读者(持有者集合、bundle 成员、按包读取、环境项)现在和精确读(`?package=`)用同一条归属规则判它归谁:行声明了 `overrides.package` → 只归它;没声明时 App 自己持有 → 归 App;App 内只有一个包持有 → 归它;两个以上 → 谁也不归。 - 为什么改:ADR-0150 D4。以前只按 pair 的前缀找 base,pair 自己变成第三个「持有者」让裸读误报 409,或把声明给 X 的行算成 App 的。 - 风险与回滚:新拒绝是两处安装窄化(第一方都是 0 个),同一条 ADR-0087 语义条目登记两处(id 不变):第 1 行(pair 行声明给 X 的 locale,不再算 App 的)和第 13 行(环境槽里没有包戳的旧覆盖行;来者只出这个 locale,两道门现在把来者算作已登记,这行谁也不归,来者成了对 X 模板的追加,拒 422 点名 X;以前放行之后 X 丢了这行、冷启动 seal 报它)。上一版的第 12 行放行已按专题裁定 6838245909(B)撤回:裸名门读持有者成员时,pair 行只在按包读法也给同一持有者时才算数,所以 X 在门上拿不到这个 locale,W 在两种注册顺序下都和 main 一样被拒、被 seal 报告;放行改由 #32899 在按名读跟随绑定之后再做。合 main 后与「停用包不持有名字」(#32497)组合多出两处随之而来的答案(全部持有者停用时裸读不再给出这行),已声明并钉测;三处注册表答「无包」而精确读照给的残余分歧交 #32561;回滚即 revert。 - 先看:`packages/objectql/src/registry.ts` 的 `pairRowBinding` / `settledPairRowBinding` / `ownersHoldingAName`,以及裸名门自己的读法 `gateSlotBinding`,再看 changeset 的 FROM → TO 列表。 - 两分钟验证:`pnpm --filter @objectstack/objectql exec vitest run src/package-scoped-resolver.test.ts src/package-scoped-exact-qualifier.test.ts`,预期全部通过。 - 合同评审 6835646675 的回应:F1(语义条目第三条补救会被保存门拒)已删;F2 实测成立,当时补了第 12 行与 pin(本轮已撤回,见下),并修了它暴露的热路径/冷启动不一致;F5 表格第 10、11 行补了 Clause-② 臂;F3、F4 按席位记为接受偏差(见验收说明)。 - 增量评审 6837360468 的回应:N1 实测复现,保留到达计数,第 13 行在 changeset 的 Clause-② 行和 FROM → TO 里声明为窄化,三道门各钉一个 pin(去掉到达计数,两道门的 pin 变红),语义条目扩写了这一处(两条补救都在门上实测过);N2 的形状(够到两个 App 的包)走裸名门的同一读法,和 main 一样被拒,它的 pin 在 #32903 第 4 条。 - 专题红线复读 6838271054 与裁定 6838245909 的回应:席位选 B(6838268615),撤回第 12 行,三种形状、三道门、两种注册顺序都钉了 main 的答案;必修 3 因此由 seal 在反向顺序也照 main 报告而关闭;必修 1 即 N1。按名读四格交 #32899,两条旧缺陷交 #32900(p1)和 #32901(p2),nits 交 #32903。 - 增量红线读 6841098779(HOLD,仅文字)的回应:H1 在第 13 行、changeset 的第二处拒绝和条目的 surface 各补了镜像方向(X 的依赖触达到达包,同样拒绝、同样补救、同一条目);H2 在第 3 行和 changeset 的 `packageScopedHoldersOf` 一条补了半句(pair 行 L 声明给 X,W 是 App 的包、带 L 和一个 X 也有的 locale,W 停用时 L 的裸读由 409 变为扣下,不算放宽)。代码与测试未动。 - 本 PR 取代 #32557:同一份改动,换到本线程分支续做(原分支从本容器推不上去);#32557 上的评审记录照旧有效。 - 需要你做的:无,席位落地。 ## What the card asked, measured (step 1) Measured on `27abd458a8` (PR #32214's final head), App `A` (`type: app`) with packages `X`, `Y` (`type: module`, each declaring `A`), and a row stored in `A.custom` hydrated into the registry's bare slot: | Case | `overlaySlotBinding` (BASE) | `bundleMembersHeldBy` X / Y / A / pair (BASE) | `getEnvironmentScopedItem` (BASE) | |---|---|---|---| | X, Y hold; row declares X | the pair itself | en-US / en-US / — / fr-FR (the row is X's on no reader) | undefined | | X, Y hold; no declaration | the pair itself (a third holder) | en-US / en-US / — / fr-FR | undefined | | X holds; no declaration | the pair itself (a second holder) | en-US / — / — / fr-FR | undefined | | A, X hold; row declares X | A | en-US / — / **en-US, fr-FR** / — (X's row counted as the App's) | undefined | | A, X hold; no declaration | A (#28390 ruling A) | en-US / — / en-US, fr-FR / — | undefined | Both readers bound the row without reading `overrides.package`, and the binding never looked through the App (`isPairOf`): it read the pair's per-package base (`customizationBasePackageId`) only. `getEnvironmentScopedItem` never served a pair's row in any case, before or after: its reach is none. ## What changes `SchemaRegistry#overlaySlotBinding` (`packages/objectql/src/registry.ts`) asks a new `pairRowBinding` for a row stored in a customization pair when some holder of the name is a package that pair customizes (`isPairOf`, `@objectstack/metadata-core`). It reads the row the way the exact read's one owner check does (`pairRowOnAddress`, `@objectstack/metadata-protocol`): the declared holder when the pair customizes it, else the App whose own pair it is (#28390 ruling A), else the one owner, else no package. - Owners are counted as the exact read counts holders (`packageScopedHoldersOf`), over every holder of the name with every row bound to it (`ownersHoldingAName`): a bundle addition to another holder, of the App or outside it, holds no name (#28802); a package a row of the pair is declared for holds that row's locale; the undeclared rows of the pair being decided are left out (`settledPairRowBinding` splits them off). An addition that ships the row's own locale stays an owner, since the row may customize that package's member. - When the count would read an undeclared row of another shared pair, the row binds to no package (epic seat 1's ruling: no guess, no fixed point). - Every holder is counted, a disabled one included: a binding never moves with a reversible disable (ADR-0150 D3, #32183, merged with this branch). The served filter applies after the binding, in `packageScopedHoldersOf`. - A declared package the pair's holders do not include binds the row to no package. A pair no holder is customized by keeps the per-package reading, so every one-holder and legacy per-package-pair case binds as before. The registry imports the pair lookup from `@objectstack/metadata-core`; it does not import `@objectstack/metadata-protocol`. - **The bare-name gate reads a pair row its own way** (epic ruling 6838245909, option B). Both doors and the cold boot's seal read a holder's members through `registeredBundleHolding`, which now reads a bare-slot row through `gateSlotBinding`: the binding above, except that a row of a customization pair counts for a holder only where the per-package reading (the pair's base when it holds the name, else the pair itself) counts it for that holder too. Where the binding moved the row (to X, from the App or from the pair), the gate counts it for no holder. The App no longer holds a locale it shipped none of through a row declared for X (row 1); X does not gain the row's locale either, so a package of another namespace on X shipping only that locale stays an addition to X's template, refused at both doors and reported by the seal in either registration order, as on `main` (row 12, withdrawn). The reads keep the binding. Admitting that package waits on the by-name read following the binding (#32899): in that state the protocol's by-name read answers by registration order (red-line read 6838271054, "For the epic seat" item 2). - **The doors read a holder's members as if the arriving registration were registered** (contract review 6835646675 F2, delta review 6837360468 N1). `registeredBundleHolding` takes the arrival (`BundleArrival`: the members the registration adds) and reads the holder's members over a copy of the collection with those members in the arriving package's composite slot; both doors pass it (`registerItem`'s gate, `refuseBareNameConflicts`), and the seal reads the registered state. Under the gate's reading above it moves one answer, the package-less row's (no package stamp, or `sys_metadata`): such a row binds to the one composite holder of the name only while there is exactly one, so beside the arrival it binds to neither and the arrival's locale is an addition to X's template (row 13), as the seal already read it. The previous head also lent the incoming manifest to the pair-row binding at the package door. Under the gate's reading no pair row's count moves with the arrival, so that part is removed: ablated at the B code it turned nothing red (396 of 396 green over the two harness files and `registry-bare-name-one-holder.test.ts`). - The four readers (`packageScopedHoldersOf`, `bundleMembersHeldBy`, `getPackageScopedItem`, `getEnvironmentScopedItem`) share the one binding; the bare-name gate's member count (`gateSlotBinding`, above) is the one place a pair row is read otherwise, and only to withhold a member. After the merge with `main` (two commits moved `registry.ts` since the branch point: #32497 and #32513), `overlaySlotBinding` is still the only binding of a bare-slot row in the registry: #32497's served filter applies after it inside `packageScopedHoldersOf` (and its `includeDisabledPackages` read keeps every holder), and #32513's picklist re-judge reads holders through `resolvePackageScopedName`, so through `packageScopedHoldersOf`. No reader on the merged tree binds a pair row a second way. - **Upgrade guide**: the semantic entry `pair-row-locale-addition-refused` (`packages/spec/src/migrations/entries/semantic/18.pair-row-locale-addition-refused.ts`), registered by the changeset (`adr-0087: registered pair-row-locale-addition-refused`), with its own `@objectstack/spec` patch changeset. It names two remedies: ship a locale the holder ships too (the App, or X for the package-less row), or rename the template; the third one an earlier head named (drop the row's declaration, or declare the App) is gone, since the save door refuses both in the case the entry names (contract review F1). This round extends the same entry, id kept, to the package-less row (row 13): its `surface`, `replacement`, `reason` and `acceptanceCriteria` name both narrowings, and its `reason` says the gate no longer counts the pair row as the App's. Both remedies were measured at both doors for both shapes on the B code (scratch probe, not committed): renaming the template is admitted at the item door and the package door; shipping a locale the holder ships too is admitted at the package door in either member order, and at the item door when that shared locale registers first, while registering the L-only member first is still refused, so the entry says so. No automatic rewrite: which locale a package ships, and which base a pair row customizes, are judgements about that package and that row. Branch note (Duplicate Fix Guard): this PR replaces #32557. Its branch `claude/project-thread-iv3vz6` is this card thread's, which the platform assigns; it carries the whole history of #32557's branch `claude/project-thread-3e08el` (head `075fb318`), then `origin/main` merged in (`7bea2a2ae`) and the landing commits on top, never rebased, never force-pushed. `3e08el` is not pushable from this container. Since that merge `main` gained #32742 (its `registry.ts` change is the permission-set namespace claim only, no reader of a pair row), #32793, #32797 and #32801; a trial merge (`git merge-tree`) is clean, and the merge queue tests the merge. ### FROM → TO Re-measured on the merged tree (head `acc680227`, `origin/main` `2f80f2897` merged at `7bea2a2ae`): with the binding ablated (the per-package reading put back) every binding pin answers its FROM below; restored, its TO. Rows 10 and 11 are new on the merged tree: they follow from row 2 meeting `main`'s served holder set (#32497). Row 12, contract review F2's mirror of row 1 that the previous head admitted, is withdrawn (epic ruling 6838245909, option B): its shapes keep `main`'s answer in both registration orders and are pinned so. Row 13 is delta review 6837360468 N1: the doors' arrival count (not the binding) moves it. Its mirrored direction, where X's dependencies reach the arriving package, moves the same way: the delta red-line read 6841098779 measured it (H1; `main` admits, the head refuses naming X, both stamps, both doors), and the changeset and the entry's `surface` name it. Row 3's exception with a disabled arrival is that read's H2. | # | Surface | FROM | TO | Clause-② arm | Pinned in | |---|---|---|---|---|---| | 1 | Bare-name gate (`registerItem` / install, holders sealed): a package with only a locale the App does not ship, while the App's pair overrides that locale for X | admitted (the pair's row counted as the App's member, so no addition) | refused `NAMESPACE_CONFLICT` naming the App (#28802 addition rule) | narrowing | resolver harness, `NARROWING — a later package whose only locale…` | | 2 | `packageScopedHoldersOf`: the App holds no item of the name | the pair counted as a holder of its own | never a holder | — (feeds 3, 4, 10, 11) | `bound to X → only X`, `unbound with two…`, `unbound with one…` | | 3 | Bare read (`GET /meta/TYPE/NAME`, `resolvePackageScopedName`), one served package of the App holds the name | `409 ambiguous-in-environment` naming X and the pair | the row (X's customization), or X's own item when the row declares a non-holder; two real holders still refuse; with the row (of locale L) declared for X and a package W of the App holding the name through L and a locale X ships too, W disabled, the bare read of L is withheld (FROM `409`; no loosening) | widening (epic seat 1: a corrected false 409) | `unbound with one package…`; `CONTROL — two real holders…`; the door probe below | | 4 | Bare read and `?package=A` refusals, two packages of the App hold the name | `409` naming X, Y and the pair | `409` naming X and Y | — (candidate list) | `unbound with two packages…` | | 5 | `getPackageScopedItem(X)`: row declares X, or X is the one owner | X's own shipped item (none for an added locale) | the row, what `?package=X` already served (outside the residuals below) | — | `bound to X → only X`, `bound to X beside the App…`, `bound to X, a bundle member…`, `unbound with one…` | | 6 | `getPackageScopedItem(A.custom)` | the row | none (the pair is no holder; `?package=A.custom` still serves the row) | — | `unbound with two…` | | 7 | A holder's bundle members (`bundleMembersHeldBy`): row declares X | counted as the App's (or the pair's) | counted as X's | — (feeds 1) | `bound to X, a bundle member…` | | 8 | `?package=A`, row declares a package that holds no item of the name | the row (the exact read fell back to A's registry item, which was the row again) | A's own item | — (semantic) | `a row declaring a package that holds no item…`; the door probe below | | 9 | `getEnvironmentScopedItem` | undefined | undefined | — (unchanged, measured) | every case asserts it | | 10 | Bare read of the row's member, every package of the App holding the name disabled (two holders, or one) | the row (the pair an enabled holder of its own) | the disabled holder's withheld item, as for any name only disabled packages hold (ADR-0150 D3) | narrowing (a read withholds a row it served) | exact-read harness, `[#32408, #32183] a row of the App's pair is bound over every holder…`, `[#32408, #32183] a row of the App's pair bound to its one holder…` | | 11 | `?package=Z`, Z of the App an addition to the row's one holder X, X disabled | the row | X's withheld item (the address reads the disabled base) | narrowing (a read withholds a row it served) | `[#32408, #32183] a row of the App's pair bound to its one holder…` | | 12 | (withdrawn) Bare-name gate (item door, package door, cold boot), the App holding no item of the name: a package W of another namespace whose dependencies reach X ships only locale L, while a row of the App's pair of locale L binds to X (it declares X, with W of the App or outside it; or X is its one owner, with W outside the App); and the reverse order, W holding L first, then X arriving | refused `422 NAMESPACE_CONFLICT` naming X, and the seal reports W against X; reverse order: X refused naming W, and the seal reports X against W | unchanged: the gate lends the row's locale to no holder (the previous head admitted W at both doors, and its seal reported nothing in either order) | — (withdrawn; #32899) | resolver harness, `ROW 12 WITHDRAWN (epic ruling B), …` and `REVERSE ORDER (epic red-line read must-fix 3), …`, three shapes at three doors each | | 13 | Bare-name gate (item door and package door, holders sealed): X holds the name alone, a package-less row of locale L (no package stamp, or `sys_metadata`) customizes X's template, and a package of another namespace whose dependencies reach X (or that X's dependencies reach) ships only L | admitted (the row counted as X's member, so no addition); after it, the row bound to neither package, X's address no longer served it, and the seal reported the package against X | refused `422 NAMESPACE_CONFLICT` naming X (an addition to X's template); X keeps the row; the cold boot's seal reports the package against X, as before | narrowing | resolver harness, `NARROWING (delta review N1), item door / package door / cold boot` | Unchanged at the doors (contract review F2): the same package of the App beside an undeclared row of L that X is the one owner of is refused (and reported at the seal) as before, and X keeps the row: the gate lends the row's locale to no holder (`UNCHANGED at the door (contract review F2), …`). Delta review N2's shape (a package reaching two Apps whose namespace picks another, or none) takes the same reading: an App pair's row counts at the gate only for the holder the per-package reading names, which no arriving package's App moves; it is not pinned here (#32903 item 4). The same package declaring X's namespace is refused before and after. Unchanged, measured on the protocol (`getMetaItem`) for the same cases: `?package=X`, `?package=Y`, `?package=A.custom`, and `?package=A` outside row 8, serve or refuse as before; the App's own address keeps an undeclared row of its pair (`CONTROL — the App's own address keeps #28390 ruling A`). ## Tests - `packages/objectql/src/package-scoped-resolver.test.ts` (the shared harness): one describe, 38 cases. New in this round, 21: `NARROWING (delta review N1)` at the item door, the package door and the cold boot's seal (row 13); `ROW 12 WITHDRAWN (epic ruling B)` and `REVERSE ORDER (epic red-line read must-fix 3)`, each in three shapes (a row declaring X with W of the App, the same with W outside the App, an undeclared row X alone owns with W outside the App) at the same three, in place of the previous head's three `WIDENING` pins. From the previous round, three: `UNCHANGED at the door` (an undeclared row X is the one owner of, W of the App). The other 14: The card's three pins (bound to X → only X, with and without the App holding, and as a bundle member; unbound with two → neither; unbound with one → that one), the narrowing, the declared non-holder, the ruling-A CONTROL, the epic seat's CONTROL (two independent holders still refuse the bare read, with or without a pair row beside them), contract review F1's pair and its CONTROL, F4's two (b and a), and F6's CONTROL. - `packages/objectql/src/package-scoped-exact-qualifier.test.ts` (its #31699 F2 describe): the F1 case read through `?package=X`, served there and bound to X by the registry alike; the F4 (b) case, refused at `?package=X` naming X and the addition, and bound to no package alike. New on the merged tree, two cases: one of two holders disabled, `?package=X` serves the row while the registry binds it to no package (CONTROL, residual 3), then both disabled, the bare read withholds it (row 10); a row bound to its one holder, disabled, withheld at the bare read and at an addition's address (rows 10, 11). - **Ablations on the final head** (`scripts/ablation-replace.mjs`, at `acc680227`, the two harness files, 306 tests; each mutation landed (anchor 1 → 0) and each restored by the tool, blob equal to HEAD `0777d5ee621d` and `git diff HEAD` empty): - The gate's own reading removed (`return bound === perPackage ? bound : undefined;` replaced by `return bound; // ABLATED #32408 B`, so the gate reads the binding as the reads do): **13 failed / 293 passed**. The nine `ROW 12 WITHDRAWN` pins (each package admitted, or at the cold boot nothing reported), the three cold-boot `REVERSE ORDER` pins (nothing reported), and the package-door `UNCHANGED` pin (without the gate's reading, the package door judges before the arriving package is installed, so the binding does not yet count it an owner of the pair and the undeclared row stays X's). The item-door and package-door `REVERSE ORDER` pins stay green: the doors refused X naming W on `main` and at the previous head alike. - The doors' arrival count removed (`opts.incomingArrival && { packageId: incomingPackageId, ...opts.incomingArrival })` replaced by `undefined) // ABLATED #32408 N1`): **2 failed / 304 passed**, exactly the item-door and package-door `NARROWING (delta review N1)` pins (each package admitted). Under the gate's reading the `UNCHANGED` door pins no longer hang on the arrival; the cold-boot pins stay green, as the seal reads the registered state. Under the same ablation a scratch probe of row 13 (both stamps: none and `sys_metadata`) read its FROM cells: admitted at both doors, X's address no longer serving the row afterwards, a second seal reporting the package against X; at the head the probe reads the TO cells (refused naming X, X keeping the row, the reseal empty). - The binding put back to the per-package reading (the anchor below): **22 failed / 284 passed**: every binding pin, the item-door and package-door `UNCHANGED` and `ROW 12 WITHDRAWN` pins on their `X keeps the row` cells (row 5's TO; each refusal holds), and none of the cold-boot or `REVERSE ORDER` pins, whose answers are `main`'s. - **Ablations on the previous rounds' code**: at `7509d920b` (288 tests), binding 19 failed / 269 passed and arrival count 2 failed / 286 passed (the two door `UNCHANGED` pins); at `58a13fd61` (291 tests), binding 19 / 272 and arrival count 4 / 287 (the two door `UNCHANGED` pins and the two door N1 pins). The incoming manifest the package door lent the pair-row binding, ablated at `3b168f1ba` (the B code before its removal), turned nothing red over the two harness files and `registry-bare-name-one-holder.test.ts` (396 of 396 green). - **Ablation on the round-2 head** (`e94a8de8f`): `const paired = this.pairRowBinding(type, stamped, item, name, collection, composite);` replaced by `const paired = NOT_A_PAIR_ROW_OF_A_HOLDER; // ABLATED #32408` (the per-package reading put back), mutation landed (anchor 1 → 0, blob `e84fc254dea3` → `50f62a28a05c`). The two harness files: **14 failed / 268 passed** of 282 — every binding pin red, the two new disable pins included; the controls stay green (ruling A, two independent Apps, F1's CONTROL, F6's CONTROL). Restored by the tool: blob equal to HEAD (`e84fc254dea3`), `git diff HEAD` empty. The FROM cells of rows 3, 4, 10 and 11 at the door were read under the same ablation (at `6d317e68b`, the binding code identical) through a scratch protocol probe of the same shapes (not committed): bare read `409` naming X and the pair (row 3), `409` naming X, Y and the pair (row 4), the bare read and `?package=Z` serving the row with every holder disabled (rows 10, 11). At the head the same probe reads every TO cell of those rows, and row 8's `?package=A` answers the App's own item (its FROM is the earlier rounds' door measurement). - Earlier rounds (on `075fb318`, before the merge): the full ablation 12 failed / 207 passed of 219; F1, F4 and F6 ablated each at their own head, each pin red (records 6814943264, 6815176250, 6815340803). ## Acceptance notes - **Residual divergence, accepted by the seat and the epic seat (red-line read 6814925975: the registry is the side that does not guess), carried by #32561** (the exact read adopts the registry's count). Three shapes; in each the registry binds the row to no package while the exact read serves it: - (1) An undeclared pair row of the very locale a bundle addition of another package of the App ships. Pinned as a CONTROL on the registry side. - (2) Contract review F6, per epic seat 1's ruling: a pair's undeclared row while another shared pair stores an undeclared row of the name. Pinned as a CONTROL. - (3) New on the merged tree: an undeclared row of a pair two holders share while one of them is disabled. The registry counts every holder (a binding never moves with a disable); the exact read counts the served holders, so `?package=X` of the enabled one serves the row (the bare read serves it too, through the protocol's stored-row read). Pinned as a CONTROL in the exact-read harness. - The card's surface guess (`packages/metadata`) was wrong: both readers are in objectql's `SchemaRegistry`. `getEnvironmentScopedItem` is never reached by a pair row (reach none). - `overrides.package` naming a package the save gate would not accept (a non-holder, or one the pair does not customize) is off-door data; such a row now binds to no package instead of to the App or the pair. - **Accepted deviations (contract review 6835646675, the seat's call)**: - F3: the Clause-② line and the entry's `surface` leave out two conditions the refusal needs (the package reaches the App through its declared dependencies, and it declares another namespace than the App). The text over-declares, on the safe side. - F4: the cold boot's seal reads the same members. Measured in a scratch probe, row 1's shape with every item registered before the seal: FROM no conflict TO two (X against the App, and the later package against the App). `BARE_NAME_COLD_BOOT_MODE` is `warn`, so the boot logs them and refuses nothing; X re-registering its item after the seal is admitted (it already holds the name). X is listed because, without the pair row lending the App its locale, X shipping only a locale the App ships none of is itself an addition to the App's template under the #28802 rule `main` applies. - **Routed by the epic ruling 6838245909 and the seat (6838268615)**: the admission beside X and the by-name read's four cells (red-line read item 2) → #32899 (p2); the bare slot keeping only the row hydrated last → #32900 (p1); the item door judging a package member by member → #32901 (p2); the nits, delta review N2's pin among them → #32903. The disabled-X cell is not a disclosure (ruling item 4) and is not reachable through the doors under B. - Line budget: +763 / -26 over 6 files (789 changed lines, merge base `2f80f2897`): `registry.ts` +266 / -26, the resolver harness +338, the exact-read harness +64, the changeset +29, the semantic entry +56, its changeset +10; under the ~1500 order cap and the 3000-line threshold; 0 governed paths (`check-governed-merges --branch HEAD`). ## Verification Text-only round on head `463a1752b` (delta red-line read 6841098779, H1 and H2): the changeset and the semantic entry edited, the code and the tests unchanged since `acc680227`. On `463a1752b`: `@objectstack/spec` rebuilt, `pnpm --filter @objectstack/spec check:generated` all 14 generated artifacts up to date, `node scripts/check-adr-0087-registration.mjs --base origin/main` exit 0, `node scripts/check-nul-bytes.mjs` OK. Everything below was measured on `acc680227`. Measured on head `acc680227` (`origin/main` `2f80f2897` merged at `7bea2a2ae`, never rebased; `main` not merged this round), after the earlier rounds' full `pnpm install --frozen-lockfile`, `pnpm build` (119/119 tasks, with declarations) and dogfood closure build, then `@objectstack/spec` and `@objectstack/objectql` rebuilt for this round's source changes (the spec `src/migrations/` suites: 5 files, 198 tests passed): - `node scripts/pm/dispatch-gates.mjs --commands --repo objectstack-ai/objectstack`: **94** families derived on the 6 paths (the same list as the previous heads), each run with its exit code captured before any pipe: **94/94 exit 0**. `--ran` on the record: 94 derived, 94 run, **0 NOT-MEASURED, 0 UNRUN**, a derived zero (every line carries its exit code). `node scripts/check-nul-bytes.mjs`: OK. - `node scripts/check-adr-0087-registration.mjs --base origin/main`: exit 0, `registered pair-row-locale-addition-refused (new here)`. `pnpm --filter @objectstack/spec check:generated`: all 14 generated artifacts up to date. - `pnpm lint`: exit 0. `pnpm --filter @objectstack/objectql typecheck`: exit 0. - `pnpm --filter @objectstack/objectql test`: **589 files passed; 12633 tests passed**. - **Dogfood battery** (`pnpm --filter @objectstack/dogfood test` under `scripts/pm/os-verify-lock.sh`, no shard, no path, at `acc680227`): **455 files passed, 3 skipped; 3817 tests passed, 42 skipped**; VERDICT command-exit 0. - `node scripts/pm/check-governed-merges.mjs --branch HEAD`: 0 of 6 paths governed. `dispatch-gates --tier`: no path-derived mandate (the semantic entry under `packages/spec` makes the review face `packages/spec`, CONTRACT_REVIEW_TIER by surface). ## Human Minimum - [x] 1. Schemas start as Zod; `packages/spec` holds no runtime logic (one migration entry). - [x] 2. Every name I added uses the casing for its kind. - [x] 3. No formatter ran; `pnpm lint` passes on the final head. - [x] 4. One issue, one branch, one pull request (this PR replaces #32557; its branch carries that PR's whole history, merged with `main`). - [x] 5. A change that publishes carries a changeset, and both declaration lines are filled in here and in the changeset. - [x] 6. `packages/spec` touched: one entry file; the registry, `spec-changes.json` and the upgrade guide are generated, git-ignored projections (`check:generated` all up to date). - [x] 7. No hand edits to `content/docs/references/`, `packages/*/CHANGELOG.md` or `content/docs/releases/`. - [x] 8. Title, body and comments are in English. Development by the os-dev session `session_01Utp6CbGpwJzMFhChu9a91Q` (PR #32557); `main` merge and landing round by the card thread `session_01L6bhgUJkevgE12tpg42pZA` for the seat `domain:server#1`. 🤖 Generated with [Claude Code](https://claude.com/claude-code) https://claude.ai/code/session_01L6bhgUJkevgE12tpg42pZA <!-- signed: domain:server#1 · os-sales · session_01L6bhgVaKJ9TPfXPRhdqx3e --> --------- Co-authored-by: Claude <noreply@anthropic.com> Co-authored-by: objectstack-fleet[bot] <332303061+objectstack-fleet[bot]@users.noreply.github.com>
1 parent 152b53c commit e336a33

6 files changed

Lines changed: 763 additions & 26 deletions

File tree

Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
---
2+
'@objectstack/objectql': minor
3+
---
4+
5+
fix(objectql)!: every reader of the registry's overlay slot binds a row of an App's customization pair by the exact read's owner rule (ADR-0150 D4)
6+
7+
Clause-②: yes (narrowing) — two refusals where a registration was admitted before. First, with the bare-name holders sealed, a package whose only members of an email template's name are locales the App ships none of, while the App's pair stores a row of that locale declaring another package of the App as its base (`overrides.package`), is refused `422 NAMESPACE_CONFLICT` naming the App as an addition to the App's template (#28802), where it was admitted because the pair's row counted as the App's own member. First-party packages in that position: 0. Second, with the holders sealed, a package of another namespace whose dependencies reach a package X that holds an email template's name alone (or that X's dependencies reach), shipping only a locale X ships none of, while a package-less row of that locale (a legacy overlay in the environment's slot) customizes X's template, is refused `422 NAMESPACE_CONFLICT` naming X as an addition to X's template, where it was admitted because that row counted as X's member; once admitted, the row bound to neither package and the cold boot's seal reported the package. The doors now count the arriving package as the seal counts it (listed below). First-party packages in that position: 0. The bare-name gate does not move the other way: where a row of the App's pair now binds to X, it lends X no locale at the doors or the seal, so a package of another namespace on X shipping only that locale is still refused and reported, in either registration order (listed below; admitting it is #32899). Beside them, a read withholds a row it served: with every package of the App that holds the name disabled, a row of the App's pair is that disabled holder's, so the bare read and an addition's address withhold it as they withhold any name only disabled packages hold (listed below).
8+
Metadata-protocol: narrowed
9+
10+
<!-- adr-0087: registered pair-row-locale-addition-refused -->
11+
12+
**BREAKING** for two registrations. A package that ships only a locale of an email template the App does not ship, while the App's pair overrides that locale for another package of the App, is now refused as an addition to the App's template. A package of another namespace on a package X that holds a template alone (or that X depends on), shipping only a locale X does not ship while a package-less row of that locale customizes X's template, is now refused as an addition to X's template. For either: ship a locale the holder ships too (declared in the manifest, or registered first), or rename the template. Nothing in the workspace is in either position.
13+
14+
`SchemaRegistry`'s per-package overlay slot (`overlaySlotBinding`) read a row stored in a customization pair (`<app>.custom`) by the pair's per-package base only, never by the App whose pair it is (ADR-0146 D3: one pair per App, shared by every package of the App) and never by the base the row declares (`overrides.package`, ADR-0146 D2). The exact read (`?package=`, `pairRowOnAddress` in `@objectstack/metadata-protocol`) has read both since the epic's ruling on #31699 F2; its other readers now bind the row the same way: the holder the row declares, when the pair customizes it; else the App whose own pair it is (#28390 ruling A); else the one package of the App holding the name, counted as the exact read counts holders: over every holder of the name, each with the rows bound to it, so a bundle addition to another holder (of the App or outside it) holds no name (#28802) unless it ships the row's own locale, which the row may customize, and a package a row of the pair is declared for holds that row's locale; else, with two or more, no package. A row whose count would read an undeclared row of another shared pair (whose binding waits on that pair's own count) binds to no package. A declaration naming a package the pair does not customize, or one that holds no item of the name, binds it to no package. A row of a pair no holder of the name is customized by keeps its per-package reading.
15+
16+
What each reader answers now, with a package X of App A holding the name and a row of `A.custom` (each line says what moves FROM what TO what):
17+
18+
- `SchemaRegistry#packageScopedHoldersOf`: FROM the pair counted as a holder of its own when the App holds no item of the name TO the pair never a holder. A bare read (`GET /meta/TYPE/NAME`, `resolvePackageScopedName`) of a name one package of the App holds moves FROM `409 RESOURCE_CONFLICT` (`ambiguous-in-environment`, naming X and the pair) TO the row, X's customization (widening), except that, with the row (of locale L) declared for X and a package W of the App holding the name through L and a locale X ships too, W disabled, the bare read of L moves FROM `409` TO withheld (no loosening); with two packages of the App holding it, the bare read and `?package=A` still refuse `409`, now naming the two packages without the pair.
19+
- `SchemaRegistry#getPackageScopedItem` naming X: FROM X's own shipped item (none, for an added locale) TO the row, when the row declares X or X is the one package of the App holding the name — what `?package=X` already served. Naming the pair: FROM the row TO none (the pair is no holder; `?package=A.custom` serves the row as before).
20+
- A holder's bundle members (`bundleMembersHeldBy`, read by the bundle-addition rule of the bare read): FROM the row's locale counted as the App's when the row declares X, and as the pair's when the App holds no item of the name, TO counted as X's (declared, or the one package holding it) or as no holder's (two).
21+
- The bare-name gate (the item door, the package door and the cold boot's seal) reads a holder's members its own way: a row of a customization pair counts for a holder only where the per-package reading counts it for that holder too (the pair's base when it holds the name, else the pair itself). Where the binding moved the row (to X, from the App or the pair), the gate counts it for no holder. The App no longer holds a locale it ships none of through a row declared for X: the first refusal above. X does not gain the row's locale at the gate either, so nothing moves for a package of another namespace whose dependencies reach X and that ships only L, with the App holding no item of the name: it is refused `422 NAMESPACE_CONFLICT` naming X at both doors and reported by the seal against X, as before, whether the row declares X or X is its one owner and whether the package is of the App or outside it; with that package holding L first, X arriving is refused naming it and the seal reports X against it, as before. Admitting that package waits on the by-name read following the binding (#32899).
22+
- A package-less row (no package stamp, or `sys_metadata`) of locale L over a name X alone holds: it binds to X only while X is the one package holding the name, and the doors now count the arriving package as a holder. A package of another namespace whose dependencies reach X (or that X's dependencies reach) and that ships only L moves FROM admitted at the item door and the package door (after which the row bound to neither package, X's address no longer served it, and the cold boot's seal reported the package against X) TO refused `422 NAMESPACE_CONFLICT` naming X, an addition to X's template, with X keeping the row (narrowing). The seal's answer over the same state is unchanged: it reports the package against X before and after.
23+
- A row declaring a package the pair's holders do not include (one that holds no item of the name, or one the pair does not customize): FROM bound to the App (or to the pair, when the App holds no item of the name) TO no package. `?package=A` moves FROM the row TO the App's own item: the exact read had already judged the row no member of A's address and fallen back to A's registry item, which was the row again. A bare read of a name one package of the App holds moves FROM `409` naming that package and the pair TO that package's own item.
24+
- With a disabled holder (a disabled package holds no name, ADR-0150 D3): the binding counts every holder, disabled or not, so a disable never moves it. With every package of the App that holds the name disabled, the bare read of the row's member moves FROM the row (the pair, an enabled holder of its own) TO the disabled holder's withheld item, as for any name only disabled packages hold; so does the address of a package of the App whose holding is an addition to the disabled one (`?package=Z`).
25+
- `SchemaRegistry#getEnvironmentScopedItem`: unchanged. A pair's row is never the environment's item, before or after (measured on every case above).
26+
27+
One shape still reads apart, and the registry is the side that does not guess: an undeclared row of the very locale a bundle addition of another package of the App ships binds to no package here (it may customize that addition's member), while `?package=X` serves it, because the exact read's holder count leaves the addition out. So does a row of a pair while another shared pair stores an undeclared row of the name: the registry binds it to no package, where the exact read may serve it or refuse it. And so does an undeclared row of a pair two holders share while one of them is disabled: the registry binds it to no package, while `?package=X` of the enabled one serves it, because the exact read counts the served holders. The exact read adopting these counts is #32561.
28+
29+
Unchanged: apart from the `?package=A` move above, the exact read of every address (`?package=X`, `?package=Y`, `?package=A`, `?package=A.custom`) serves or refuses as before, measured on the protocol for the same cases; the App's own address keeps an undeclared row of its pair (#28390 ruling A); a row stored under a package that holds the name in its own slot, or under a pair whose holders include none it customizes, binds as before.
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 registrations #32408 narrows: a package whose only locales of an email template are ones the App ships none of, while the App's customization pair stores a row of that locale declaring another package of the App, is refused naming the App as an addition to the App's template; and a package of another namespace on a package X that holds the template alone (or that X's dependencies reach), whose only locales of it are ones X ships none of, while a package-less row of that locale customizes X's template, is refused naming X as an addition to X's template (#32408)
6+
7+
Clause-②: no
8+
Metadata-protocol: none
9+
10+
The semantic entry `pair-row-locale-addition-refused` (`packages/spec/src/migrations/entries/semantic/18.pair-row-locale-addition-refused.ts`) registers the narrowing `.changeset/32408-pair-row-binding-every-reader.md` declares (ADR-0087, `adr-0087: registered`): no automatic rewrite, because which locale a package ships and which base a pair row customizes are judgements about that package and that row. It adds no key and no export.

‎packages/objectql/src/package-scoped-exact-qualifier.test.ts‎

Lines changed: 64 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -856,6 +856,70 @@ describe('[#31699 F2] a pair member row two holders could own is refused on both
856856
expect(await listed(APP)).not.toContain('pair fr-FR');
857857
});
858858

859+
it('[#32408, contract review F1] a bundle addition of another package of the App is no second owner: X\'s exact read serves the row, and the registry binds it to X alike', async () => {
860+
const Z = 'com.acme.zeta';
861+
registry.installPackage({ ...(memberOf(Z) as object), dependencies: { [APP]: '^1.0.0', [X]: '^1.0.0' } } as never, 'code');
862+
tpl('en-US', X);
863+
tpl('fr-FR', Z);
864+
const pairDe = { name: 'welcome', label: 'pair de-DE', locale: 'de-DE', subject: 'pair de-DE', bodyHtml: '<p>p</p>' };
865+
rows.push({ id: 'row_de', type: 'email_template', name: 'welcome', state: 'active', package_id: PAIR, bundle_member: 'de-DE', metadata: JSON.stringify(pairDe) });
866+
registry.registerItem('email_template', { ...pairDe, _packageId: PAIR, _provenance: 'org' }, 'name' as never);
867+
expect(registry.packageScopedHoldersOf('email_template', 'welcome')).toEqual([X]);
868+
expect(labelOf(await read(X, 'de-DE'))).toBe('pair de-DE');
869+
expect(registry.getPackageScopedItem<{ label: string }>('email_template', 'welcome', X, 'de-DE')?.label).toBe('pair de-DE');
870+
});
871+
872+
it('[#32408, contract review F4] a pair row declaring an addition\'s package for a member another holder ships makes it a holder: X\'s exact read refuses an undeclared row beside it naming both, and the registry binds it to no package alike', async () => {
873+
const Z = 'com.acme.zeta';
874+
registry.installPackage({ ...(memberOf(Z) as object), dependencies: { [APP]: '^1.0.0', [X]: '^1.0.0' } } as never, 'code');
875+
tpl('en-US', X);
876+
tpl('fr-FR', Z);
877+
// Admitted while Z shipped en-US; it outlives an upgrade of Z that drops the locale.
878+
const pairEn = { name: 'welcome', label: 'pair en-US', locale: 'en-US', subject: 'pair en-US', bodyHtml: '<p>p</p>', overrides: { package: Z } };
879+
const pairDe = { name: 'welcome', label: 'pair de-DE', locale: 'de-DE', subject: 'pair de-DE', bodyHtml: '<p>p</p>' };
880+
rows.push({ id: 'row_en', type: 'email_template', name: 'welcome', state: 'active', package_id: PAIR, bundle_member: null, metadata: JSON.stringify(pairEn) });
881+
rows.push({ id: 'row_de', type: 'email_template', name: 'welcome', state: 'active', package_id: PAIR, bundle_member: 'de-DE', metadata: JSON.stringify(pairDe) });
882+
for (const row of [pairEn, pairDe]) registry.registerItem('email_template', { ...row, _packageId: PAIR, _provenance: 'org' }, 'name' as never);
883+
expect(registry.packageScopedHoldersOf('email_template', 'welcome')).toEqual([X, Z]);
884+
const err = await refusalOf(() => read(X, 'de-DE'));
885+
expect([err.code, err.status]).toEqual(['RESOURCE_CONFLICT', 409]);
886+
expect(err.refusal.candidates).toEqual([{ kind: 'package', packageId: X }, { kind: 'package', packageId: Z }]);
887+
expect(registry.getPackageScopedItem('email_template', 'welcome', X, 'de-DE')).toBeUndefined();
888+
});
889+
890+
it('[#32408, #32183] a row of the App\'s pair is bound over every holder, so a disable never moves it: with one of two holders disabled X\'s exact read serves it while the registry binds it to no package, and with both disabled the bare read withholds it (BASE: the pair, an enabled holder of its own, so the bare read refused naming X and the pair, then served the row)', async () => {
891+
tpl('en-US', X);
892+
tpl('en-US', Y);
893+
const pairDe = { name: 'welcome', label: 'pair de-DE', locale: 'de-DE', subject: 'pair de-DE', bodyHtml: '<p>p</p>' };
894+
rows.push({ id: 'row_de', type: 'email_template', name: 'welcome', state: 'active', package_id: PAIR, bundle_member: 'de-DE', metadata: JSON.stringify(pairDe) });
895+
registry.registerItem('email_template', { ...pairDe, _packageId: PAIR, _provenance: 'org' }, 'name' as never);
896+
registry.disablePackage(Y);
897+
expect(registry.packageScopedHoldersOf('email_template', 'welcome')).toEqual([X]);
898+
expect(registry.packageScopedHoldersOf('email_template', 'welcome', null, { includeDisabledPackages: true })).toEqual([X, Y]);
899+
// CONTROL (residual, #32561): the exact read counts the served holders, the registry's binding every holder.
900+
expect(labelOf(await read(X, 'de-DE'))).toBe('pair de-DE');
901+
expect(registry.getPackageScopedItem('email_template', 'welcome', X, 'de-DE')).toBeUndefined();
902+
registry.disablePackage(X);
903+
const bare = await protocol.getMetaItem({ type: 'email_template', name: 'welcome', member: 'de-DE' } as never) as { item?: unknown };
904+
expect(bare?.item).toBeUndefined();
905+
});
906+
907+
it('[#32408, #32183] a row of the App\'s pair bound to its one holder is that holder\'s: with the holder disabled, the bare read and the address of an addition to it withhold the row (BASE: both served it, the pair an enabled holder of its own)', async () => {
908+
const Z = 'com.acme.zeta';
909+
registry.installPackage({ ...(memberOf(Z) as object), dependencies: { [APP]: '^1.0.0', [X]: '^1.0.0' } } as never, 'code');
910+
tpl('en-US', X);
911+
tpl('fr-FR', Z);
912+
const pairDe = { name: 'welcome', label: 'pair de-DE', locale: 'de-DE', subject: 'pair de-DE', bodyHtml: '<p>p</p>' };
913+
rows.push({ id: 'row_de', type: 'email_template', name: 'welcome', state: 'active', package_id: PAIR, bundle_member: 'de-DE', metadata: JSON.stringify(pairDe) });
914+
registry.registerItem('email_template', { ...pairDe, _packageId: PAIR, _provenance: 'org' }, 'name' as never);
915+
registry.disablePackage(X);
916+
expect(registry.getPackageScopedItem<{ label: string }>('email_template', 'welcome', X, 'de-DE')?.label).toBe('pair de-DE');
917+
const bare = await protocol.getMetaItem({ type: 'email_template', name: 'welcome', member: 'de-DE' } as never) as { item?: unknown };
918+
expect(bare?.item).toBeUndefined();
919+
const atZ = await read(Z, 'de-DE') as { item?: unknown; packageId?: string };
920+
expect([atZ?.item, atZ?.packageId]).toEqual([undefined, X]);
921+
});
922+
859923
it('a sole owner keeps its member: another package of the pair does not serve it (delta review S2; through the doors the qualifier refuses the non-holder first)', async () => {
860924
tpl('en-US', X);
861925
pairRow();

0 commit comments

Comments
 (0)