Skip to content

Commit 9673030

Browse files
fix(metadata-protocol)!: the read naming no package withholds a customization pair's row of a name every holder of which is disabled (ADR-0150 D3) (#33383)
<!-- claude-projects-attribution: {"github_login":"os-elon-musk"} --> _Requested by **Elon** · [project thread](https://claude.ai/code/project/chan_01WedDzV26nniwxv7jC88B9D?thread=cmsg_01WedDzV26nniwxv7jC88B9D75mRNRrsy6GfiJD9q7La4j)_ Fixes #32814 Clause-②: no (narrowing) Metadata-protocol: none Skills-docs: none — no skill and no doc teaches what the read naming no package answers at a member only a customization pair stores (`skills/**` and `content/docs/**` grepped for disabled packages: the hits are action and component `disabled` predicates, package lifecycle references and a release page); `content/docs/deployment/marketplace-handbook.mdx` already says a disabled module is hidden. > **BREAKING** (ADR-0087 `registered`, semantic entry `disabled-holder-pair-row-bare-read-withheld`): the read naming no package, at a member only a customization pair (an App's `PACKAGE.custom`) stores, for a name every installed package holding it has disabled, answers the holder's withheld item (404 `RESOURCE_NOT_FOUND`) where it served the pair's row. First-party count: 0. Remedy: re-enable a holder. ## 维护者速读 - 改了什么:某个名字(如 email_template `welcome`)的所有持有包都被停用、而某个语言成员(如 `fr-FR`)只存在于 App 定制配对包(`APP.custom`)的存储行里时,不带 `?package=` 的裸读(`GET /meta/TYPE/NAME?member=`、`/layers`、执行读)现在答 404(停用持有者的“已隐藏”条目),以前会把那行配对定制返回出来。 - 为什么改:停用包的内容不应再被服务(专题红线 1,ADR-0150 D3);带 `?package=APP.custom` 的精确读早已答 404,裸读却还漏出这一行。裸读以前只在“什么都没读到”时才判断持有者是否全部停用,读到配对行就直接返回了。 - 风险与回滚:收紧(narrowing,BREAKING,metadata-protocol patch,Metadata-protocol: none——作者能写的东西没有变),第一方 0 处。重新启用持有者、同一配对另有启用的持有者、持有者自己的行、无包行、精确读,答案都不变。回滚 = revert 本 PR。 - 先看:`packages/metadata-protocol/src/protocol-meta-item-face.ts` 的 `isHoldersPairRow` 与 `readMetaItemFace` 里 `withheldHolder` 的三元判断(风险 hunk:裸读分支新增的判定);`packages/objectql/src/package-scoped-exact-qualifier.test.ts` 末尾的 `[#32814]` 组;`packages/rest/src/meta-disabled-package-doors.test.ts` 末尾的 `[#32814]` 组。 - 两分钟验证:`pnpm --filter @objectstack/objectql exec vitest run --maxWorkers=2 src/package-scoped-exact-qualifier.test.ts -t 32814`,预期 12 个全部通过:两种保存顺序 × 是否水合 × 模块/App 自身作持有者,裸读都答 404;重新启用后与两持有者 CONTROL 仍返回配对行。 - 需要你做的:无,席位落地。 ## What changes `readMetaItemFace` (`@objectstack/metadata-protocol`, the body behind `getMetaItem` and `getMetaItemForExecution`) judges whether every package holding the name is disabled (`disabledOnlyHolderOf`, #32183) only when the read reached nothing, or, on an exact read, when it reached a row not stored under the named package (epic ruling R4-B). On the read naming no package, a row it did reach was returned unjudged. For a bundled type such as `email_template`, the member a customization pair adds (an App pair's `fr-FR` row beside a module's shipped `en-US`) is reached that way, so with the module disabled the bare read served the pair's row, while `?package=APP.custom` at the same member already answered the withheld item (ruling R4-C, `disabledExactAddressHolder`). Now, on the read naming no package, a row stamped with a customization pair (`pairsOf`) of a package holding the name (`isHoldersPairRow`) is judged the same way: when every holder is disabled, the answer is the holder's withheld item, the answer the same read gives with no row stored. A pair row is bound over the holders it is a pair of and is never a holder of its own (#32354 contract review N2, #32408), so it is withheld with them. | state (member `fr-FR` stored only under `APP.custom`) | door, naming no package | FROM `main` e540baf | TO this head | arm | |:--|:--|:--|:--|:--| | the only holder (a module of the App, or the App itself) disabled; row saved before or after the disable; hydrated or not | plain read `?member=fr-FR` | 200, the pair's row | 404 `RESOURCE_NOT_FOUND` (protocol: no item, `packageId` = the holder) | narrowing | | the same | `/layers?member=fr-FR` (`RestServer`) | 200, the pair's row as the effective layer | 404 `RESOURCE_NOT_FOUND` | narrowing | | the same | execution face (`getMetaItemForExecution`) | the pair's row | no item | narrowing | | the holder enabled again | all of the above | the pair's row | the pair's row | none (CONTROL) | | two modules of the App hold the name, one disabled, either registration order | plain read | the pair's row | the pair's row | none (CONTROL) | | both modules disabled | plain read | 404 | 404 | none | | no row stored, holder disabled | plain read | 404 | 404 | none (CONTROL) | | a package-less row, a row of a package outside the App, the holder's own row | plain read | as before | as before | none (not judged here, measured) | The other doors of the same name were measured but are outside this card: the list reads (`getMetaItems`, `getMetaItemsForExecution`) still list the pair's row while every holder is disabled (`protocol-meta-list-reads.ts`, an E1 hot file this order may not edit; see Acceptance notes). ## Tests - `packages/objectql/src/package-scoped-exact-qualifier.test.ts`, new top-level `describe` `[#32814]` at the end of the file (no overlap with the `[#32561]` block #33251 edits): 8 negative pins (module of the App / the App itself × row before / after the disable × hydrated or not) asserting no item, `packageId` = the holder, no byte of the pair's row, and no item on the execution face, each followed by a re-enable CONTROL; 2 pins that the answer with the pair's row stored equals the answer with none (the envelope's `version` left out, see Acceptance notes); 2 CONTROLs (two modules of the App, both registration orders: one enabled serves the pair's row, both disabled withhold it). - `packages/rest/src/meta-disabled-package-doors.test.ts`, new top-level `describe` `[#32814]` at the end: the plain read and `/layers` at the member answer 404 `RESOURCE_NOT_FOUND` in both save orders, then the pair's row once re-enabled; CONTROL: no row stored answers the same 404. ## Acceptance notes - **Metadata-protocol: none, by measurement.** The card expected `narrowed`. Nothing an author can write is refused, re-shaped or changes meaning: the pair row is still accepted on save and served again on re-enable. Only what a read serves while every holder is disabled moves, the same classification #33130 (the served-set sibling) declared. The narrowing is carried by `Clause-②: no (narrowing)`, the BREAKING banner and the registered semantic entry. - **Not moved on purpose: a package-less row.** With the only holder disabled, a package-less `fr-FR` row is still served by the bare read (measured on `main` and on this head). `servedRowHolderOf` documents that a name with a package-less row is "judged as before" (a customization of no one holder); whether it is the disabled holder's customization is not ruled, so it is reported, not guessed. - **List reads.** `getMetaItems` / `getMetaItemsForExecution` with no package list the pair's row while every holder is disabled (measured on `main` e540baf, both save orders). Reported for a separate card; `protocol-meta-list-reads.ts` is a hot file for this order. - **Envelope `version`.** The protocol's withheld envelope keeps the `version` of what the read reached on every withheld arm (a disabled holder's own stored row keeps its row's version, measured), so the no-row equality pin compares everything else. No door serves it: both REST doors answer 404. - **`/published`** takes no member, and the bare read at the canonical member was already withheld on `main`; not moved. ## Verification Premise, on `origin/main` e540baf (a probe over the same fixtures, not committed): with the only holder disabled, the bare read at `fr-FR` served the pair's row in all four save/hydration orders, for a module of the App and for the App itself; with no row stored it answered the holder's withheld item. Every other probed state (holder enabled, two holders, a package outside the App, a package-less row, the holder's own row) answered the same on this head as on `main`. <details><summary>Pins and ablation (one mutation: the bare-read arm of the new judgment replaced with a constant false)</summary> - Fix head 51b589e, `pnpm --filter @objectstack/objectql exec vitest run --maxWorkers=2 src/package-scoped-exact-qualifier.test.ts -t 32814`: `Tests 12 passed`. - Ablated (`scripts/ablation-replace.mjs`, then `pnpm --filter @objectstack/metadata-protocol build`, `ablation-dist-preflight.mjs` marker present in `dist/index.js` and `dist/index.cjs`): `Tests 10 failed | 2 passed` — the 8 withheld pins and the 2 no-row equality pins red, the 2 two-module CONTROLs green. - Restored (blob == HEAD, `git diff HEAD` empty, rebuilt, preflight `--absent` and whole-tree clean): `Tests 12 passed`. - REST, `pnpm --filter @objectstack/rest exec vitest run --maxWorkers=2 src/meta-disabled-package-doors.test.ts`: `Tests 44 passed (44)`. Ablated: `-t 32814` `Tests 2 failed | 1 passed` (both save orders red, the no-row CONTROL green). Restored: `Tests 3 passed`. </details> <details><summary>Local gates and type checks (head 28c3513, after merging origin/main 199e362)</summary> - `pnpm --filter @objectstack/metadata-protocol typecheck`, `@objectstack/objectql typecheck`, `@objectstack/rest typecheck`: `VERDICT command-exit 0` each. - `node scripts/pm/dispatch-gates.mjs --commands` (86 families) run locally, reconciled with `--ran`: `86 derived, 84 run, 2 NOT-MEASURED, 0 UNRUN`. The two exit 3 (prerequisite: a full workspace build): `check:dual-build-cjs-loads`, `check:type-check-debt`. Every other family exit 0. - NOT MEASURED locally, reason: the shared verify lock was held for 88+ minutes by another session's full affected-set test run while this was written: `@objectstack/spec` typecheck (queue-timeout), the full `@objectstack/metadata-protocol`, `@objectstack/objectql`, `@objectstack/rest` suites on the merged head, `pnpm lint`. CI runs them on this PR. </details> 🤖 Generated with [Claude Code](https://claude.com/claude-code) https://claude.ai/code/session_016WV4cy1y7UNVbT2QAdmgdn --------- Co-authored-by: Claude <noreply@anthropic.com>
1 parent 6859b2f commit 9673030

6 files changed

Lines changed: 248 additions & 1 deletion

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+
---
4+
5+
fix(metadata-protocol)!: the read naming no package withholds a customization pair's row of a name every holder of which is disabled (ADR-0150 D3, #32814)
6+
7+
Clause-②: no (narrowing)
8+
Metadata-protocol: none
9+
Skills-docs: none — no skill and no doc teaches what the read naming no package answers at a member only a customization pair stores (`skills/**` and `content/docs/**` grepped for disabled packages: the hits are action and component `disabled` predicates, package lifecycle references and a release page); `content/docs/deployment/marketplace-handbook.mdx` already says a disabled module is hidden.
10+
11+
<!-- adr-0087: registered disabled-holder-pair-row-bare-read-withheld -->
12+
13+
**BREAKING** answer narrowing at the `/meta` item read that names no package: at a member only a customization pair (an App's `PACKAGE.custom`) stores, for a name every installed package holding it has disabled, the read answers the holder's withheld item (404 `RESOURCE_NOT_FOUND` on the doors), where it served the pair's row. It is the answer the same read gives with no row stored, and the answer the pair's own address (`?package=PACKAGE.custom`) already gave.
14+
15+
The read judged the name's holders (`disabledOnlyHolderOf`) only when it reached nothing. It now also judges them when it reaches a row stamped with a customization pair (`pairsOf`) of a package that holds the name. A pair row is bound over the holders it is a pair of and is never a holder of its own, so it is withheld with them.
16+
17+
**Every moved answer, before → after.** Both save orders (row before and after the disable), with and without the boot's hydration of the row into the registry, for a module of an App and for the App itself as the holder. First-party count 0: no first-party app disables a package at boot.
18+
19+
- Bare `GET /meta/:type/:name?member=MEMBER`: 200 with the pair's row → 404 `RESOURCE_NOT_FOUND`.
20+
- Bare `GET /meta/:type/:name/layers?member=MEMBER`: 200 with the pair's row as the effective layer → 404 `RESOURCE_NOT_FOUND` (the layered chain asks the plain read whether a disable withheld the item).
21+
- The execution face (`getMetaItemForExecution`) of the same name and member: the pair's row → no item.
22+
23+
**Not moved.** Re-enabling a holder serves the pair's row again. Two modules of the App holding the name with one of them enabled: the pair's row is the enabled module's customization and is served as before, in either registration order. A row stored under a holder of the name, a package-less row, a row of a package that is no holder's pair, and every read naming a package are judged as before. The list reads (`getMetaItems`, `getMetaItemsForExecution`) are not changed here.
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 bare item read #32814 narrows: a customization pair's row of a name every holder of which is disabled is withheld instead of served
6+
7+
Clause-②: no
8+
Metadata-protocol: none
9+
10+
The semantic entry `disabled-holder-pair-row-bare-read-withheld` (`packages/spec/src/migrations/entries/semantic/18.disabled-holder-pair-row-bare-read-withheld.ts`) registers the narrowing `.changeset/32814-disabled-holder-pair-row-bare-read.md` declares (ADR-0087, `adr-0087: registered`). There is no automatic rewrite, because whether a disabled package should be enabled again is a judgement about the deployment. It adds no key and no export.

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

Lines changed: 33 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -94,6 +94,30 @@ function isStoredUnder(item: unknown, packageId: string): boolean {
9494
return (item as { _packageId?: unknown } | null | undefined)?._packageId === packageId;
9595
}
9696

97+
/**
98+
* [#32814] Whether `item` is a row of a customization pair (`pairsOf`) of a
99+
* package holding `(type, name)`, a disabled one included: stamped
100+
* (`_packageId`) with such a pair, and with no holder of the name. A pair row
101+
* is bound over every holder it is a pair of, never a holder of its own
102+
* (#32354 contract review N2, #32408), so on the read naming no package it is
103+
* judged as the name's holders are ({@link disabledOnlyHolderOf}): when only
104+
* disabled packages hold the name, it is their customization and withheld
105+
* with them, as the exact address of such a pair is (ruling (c),
106+
* `disabledExactAddressHolder`). A row stamped with a holder is that holder's
107+
* item ({@link isItemOfDisabledPackage} judges it); a row of no holder's pair
108+
* (a package-less row, another package's row) is not judged here.
109+
*/
110+
function isHoldersPairRow(engine: unknown, type: string, name: string, item: unknown): boolean {
111+
const stamp = (item as { _packageId?: unknown } | null | undefined)?._packageId;
112+
if (typeof stamp !== 'string' || stamp === '') return false;
113+
const registry: any = (engine as { registry?: unknown } | undefined)?.registry;
114+
if (typeof registry?.packageScopedHoldersOf !== 'function') return false;
115+
const every: readonly string[] = registry.packageScopedHoldersOf(type, name, null, { includeDisabledPackages: true }) ?? [];
116+
if (every.includes(stamp)) return false;
117+
const installed = installedManifestsOfEngine(engine);
118+
return every.some((holder) => pairsOf(holder, installed).includes(stamp));
119+
}
120+
97121
/**
98122
* [#32183] The package whose stack a read naming no package takes, for a
99123
* name a disabled package also holds: the one holder ADR-0150 D3 resolves
@@ -419,10 +443,18 @@ export async function readMetaItemFace(
419443
// only disabled packages hold, unless the read reached a row stored under
420444
// that address's own package: a sibling module's address must not serve a
421445
// disabled holder's pair row (row 17).
446+
// [#32814] …and the read naming no package that reached a row of a
447+
// holder's customization pair ({@link isHoldersPairRow}) judges the
448+
// name's holders too, as it does when it reached nothing: a pair row of a
449+
// name only disabled packages hold is their withheld item, the answer the
450+
// same read gives with no row stored.
422451
const withheldHolder = request.type === 'object' || request.type === 'package'
423452
? undefined
424453
: (request.packageId ? disabledExactAddressHolder(this, { type: request.type, name: request.name, packageId: request.packageId }) : undefined)
425-
?? (answer?.item == null || (request.packageId && !isStoredUnder(answer.item, request.packageId))
454+
?? (answer?.item == null
455+
|| (request.packageId
456+
? !isStoredUnder(answer.item, request.packageId)
457+
: isHoldersPairRow(this.engine, request.type, request.name, answer.item))
426458
? disabledOnlyHolderOf(this.engine?.registry, request.type, request.name)
427459
: undefined);
428460
if (withheldHolder === undefined && (request.type === 'object' || request.type === 'package'

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

Lines changed: 92 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2528,3 +2528,95 @@ describe('[#32183] an App\'s pair two modules share, one of them disabled', () =
25282528
expect(JSON.stringify(neither ?? null)).not.toMatch(/(suitex|suitey) dashboard/);
25292529
});
25302530
});
2531+
2532+
/**
2533+
* [#32814] The read naming no package, at the member only a holder's
2534+
* customization pair stores, where every package holding the name is
2535+
* disabled. FROM (`main` e540baf88, measured): 200 with the pair's row
2536+
* (stamped with the pair), in every save and hydration order below, on the
2537+
* served and the execution face; with no row stored, the same read answered
2538+
* the holder's withheld item. TO: that withheld item, the no-row answer: a pair
2539+
* row is bound over the holders it is a pair of, never a holder of its own, so
2540+
* it is withheld with them, as `?package=PAIR` already is (R4-C above).
2541+
* Re-enabled, and beside an enabled holder of the same pair, as FROM.
2542+
*/
2543+
describe('[#32814] the read naming no package withholds a pair row of a name only disabled packages hold', () => {
2544+
const APP = 'com.acme.suite';
2545+
const X = 'com.acme.suitex';
2546+
const Y = 'com.acme.suitey';
2547+
const PAIR = `${APP}.custom`;
2548+
const moduleOf = (id: string) => ({
2549+
id, name: id, version: '1.0.0', type: 'module', namespace: id.split('.').pop()!, dependencies: { [APP]: '^1.0.0' },
2550+
}) as never;
2551+
const tpl = (packageId: string) => registry.registerItem('email_template', {
2552+
name: 'welcome', label: `${packageId.split('.').pop()} en-US`, locale: 'en-US', subject: 'en', bodyHtml: '<p>x</p>',
2553+
}, 'name' as never, packageId);
2554+
const storePairRow = () => rows.push({
2555+
id: 'row_fr', type: 'email_template', name: 'welcome', state: 'active', package_id: PAIR, bundle_member: 'fr-FR',
2556+
metadata: JSON.stringify({ name: 'welcome', label: 'pair fr-FR', locale: 'fr-FR', subject: 'pair fr-FR', bodyHtml: '<p>p</p>' }),
2557+
});
2558+
/** The boot's hydration: the list read lays the stored row into the registry's slot. */
2559+
const hydrate = () => protocol.getMetaItems({ type: 'email_template' } as never);
2560+
const bare = () => protocol.getMetaItem({ type: 'email_template', name: 'welcome', member: 'fr-FR' } as never);
2561+
const bareForExecution = () => protocol.getMetaItemForExecution({ type: 'email_template', name: 'welcome', member: 'fr-FR' } as never);
2562+
2563+
beforeEach(() => {
2564+
registry.installPackage(manifest(APP), 'code');
2565+
registry.installPackage(moduleOf(X), 'code');
2566+
registry.installPackage(moduleOf(Y), 'code');
2567+
registry.installPackage(manifest(PAIR), 'code');
2568+
});
2569+
2570+
const HOLDERS = [['a module of the App', X], ['the App itself', APP]] as const;
2571+
const ORDERS = [
2572+
['the row saved, then the holder disabled', false, false],
2573+
['the holder disabled, then the row saved', true, false],
2574+
['the row saved and hydrated, then the holder disabled', false, true],
2575+
['the holder disabled, then the row saved and hydrated', true, true],
2576+
] as const;
2577+
const CASES = HOLDERS.flatMap(([holderLabel, holder]) => ORDERS.map(([order, disableFirst, hydrated]) =>
2578+
[holderLabel, order, holder, disableFirst, hydrated] as const));
2579+
2580+
it.each(CASES)('%s holds the name, %s: the bare read at the member answers the holder\'s withheld item (BASE: the pair\'s row); re-enabled, the pair\'s row', async (_holder, _order, holder, disableFirst, hydrated) => {
2581+
tpl(holder);
2582+
if (disableFirst) registry.disablePackage(holder);
2583+
storePairRow();
2584+
if (hydrated) await hydrate();
2585+
if (!disableFirst) registry.disablePackage(holder);
2586+
const answer = await bare();
2587+
expect(answer?.item).toBeUndefined();
2588+
expect((answer as { packageId?: string } | undefined)?.packageId).toBe(holder);
2589+
expect(JSON.stringify(answer ?? null)).not.toContain('pair fr-FR');
2590+
expect((await bareForExecution())?.item).toBeUndefined();
2591+
// CONTROL — the holder enabled again: the pair's row, as on BASE.
2592+
registry.enablePackage(holder);
2593+
expect(labelOf(await bare())).toBe('pair fr-FR');
2594+
expect(labelOf(await bareForExecution())).toBe('pair fr-FR');
2595+
});
2596+
2597+
// `version` is left out of the comparison: the withheld envelope keeps the
2598+
// version of what the read reached, on every withheld arm (a disabled
2599+
// holder's own stored row keeps its row's too), and no door serves it.
2600+
it.each(HOLDERS)('%s holds the name, disabled: the answer with the pair\'s row stored is the answer with none', async (_holder, holder) => {
2601+
tpl(holder);
2602+
registry.disablePackage(holder);
2603+
const { version: _noRowVersion, ...withoutRow } = (await bare()) as Record<string, unknown>;
2604+
storePairRow();
2605+
const { version: _rowVersion, ...withRow } = (await bare()) as Record<string, unknown>;
2606+
expect(withRow).toEqual(withoutRow);
2607+
});
2608+
2609+
it.each([['the disabled holder registered first', [X, Y]], ['the enabled holder registered first', [Y, X]]] as const)(
2610+
'CONTROL — two modules of the App hold the name, %s, X disabled: the bare read serves the pair\'s row (Y\'s customization), as on BASE; both disabled, withheld',
2611+
async (_order, order) => {
2612+
for (const id of order) tpl(id);
2613+
storePairRow();
2614+
registry.disablePackage(X);
2615+
expect(labelOf(await bare())).toBe('pair fr-FR');
2616+
registry.disablePackage(Y);
2617+
const neither = await bare();
2618+
expect(neither?.item).toBeUndefined();
2619+
expect(JSON.stringify(neither ?? null)).not.toContain('pair fr-FR');
2620+
},
2621+
);
2622+
});

‎packages/rest/src/meta-disabled-package-doors.test.ts‎

Lines changed: 53 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -882,3 +882,56 @@ describe('[ruling record 6787890900] RestServer: an object the caller may not re
882882
.toEqual({ status: 503, code: 'FIELD_VISIBILITY_UNRESOLVED' });
883883
}, 60_000);
884884
});
885+
886+
/**
887+
* [#32814] The bare doors at the member only a holder's customization pair
888+
* stores, where every package holding the name is disabled: an `email_template`
889+
* one module of an App ships (`en-US`), the App's pair (`<App>.custom`)
890+
* storing an undeclared `fr-FR` row. FROM (`main` e540baf88, measured on the
891+
* protocol): the plain read served the pair's row. TO: the missing name, as
892+
* with no row stored, on the plain read and the layered view; re-enabled, the
893+
* pair's row on both.
894+
*/
895+
describe('[#32814] RestServer: a pair row of a name only a disabled package holds, read naming no package', () => {
896+
const APP = 'com.qa.suite';
897+
const MODULE = 'com.qa.suitex';
898+
const PAIR = `${APP}.custom`;
899+
const install = (host: ReturnType<typeof setup>) => {
900+
host.registry.installPackage({ id: APP, name: APP, version: '1.0.0', type: 'app', namespace: 'suite' } as any, 'code');
901+
host.registry.installPackage({ id: MODULE, name: MODULE, version: '1.0.0', type: 'module', namespace: 'suitex', dependencies: { [APP]: '^1.0.0' } } as any, 'code');
902+
host.registry.registerItem('email_template', {
903+
name: 'welcome', label: 'suitex en-US', locale: 'en-US', subject: 'en', bodyHtml: '<p>x</p>',
904+
} as any, 'name', MODULE);
905+
};
906+
const pairRow = (host: ReturnType<typeof setup>) => (host.protocol as any).engine.insert('sys_metadata', {
907+
type: 'email_template', name: 'welcome', package_id: PAIR, bundle_member: 'fr-FR', state: 'active', scope: 'platform', strategy: 'merge', version: 1,
908+
metadata: JSON.stringify({ name: 'welcome', label: 'pair fr-FR', locale: 'fr-FR', subject: 'pair fr-FR', bodyHtml: '<p>p</p>' }),
909+
});
910+
911+
it.each([['the row saved, then the module disabled', false], ['the module disabled, then the row saved', true]] as const)('%s: the plain read and `/layers` at the member answer 404, never the pair\'s row; re-enabled, the pair\'s row', async (_order, disableFirst) => {
912+
const host = setup();
913+
install(host);
914+
if (disableFirst) host.registry.disablePackage(MODULE);
915+
await pairRow(host);
916+
if (!disableFirst) host.registry.disablePackage(MODULE);
917+
const read = await host.plainWith('email_template', 'welcome', { member: 'fr-FR' });
918+
const layers = await host.layers('email_template', 'welcome', { member: 'fr-FR' });
919+
expect([read.status, read.body?.error?.code], JSON.stringify(read.body)).toEqual([404, 'RESOURCE_NOT_FOUND']);
920+
expect([layers.status, layers.body?.error?.code], JSON.stringify(layers.body)).toEqual([404, 'RESOURCE_NOT_FOUND']);
921+
for (const answer of [read, layers]) expect(JSON.stringify(answer.body ?? null)).not.toContain('pair fr-FR');
922+
// CONTROL — the module enabled again: the pair's row on both doors.
923+
host.registry.enablePackage(MODULE);
924+
const again = await host.plainWith('email_template', 'welcome', { member: 'fr-FR' });
925+
const againLayers = await host.layers('email_template', 'welcome', { member: 'fr-FR' });
926+
expect([again.status, again.body?.item?.label], JSON.stringify(again.body)).toEqual([200, 'pair fr-FR']);
927+
expect([againLayers.status, againLayers.body?.effective?.label], JSON.stringify(againLayers.body)).toEqual([200, 'pair fr-FR']);
928+
}, 60_000);
929+
930+
it('CONTROL — no row stored: the plain read at the member answers the same 404', async () => {
931+
const host = setup();
932+
install(host);
933+
host.registry.disablePackage(MODULE);
934+
const read = await host.plainWith('email_template', 'welcome', { member: 'fr-FR' });
935+
expect([read.status, read.body?.error?.code], JSON.stringify(read.body)).toEqual([404, 'RESOURCE_NOT_FOUND']);
936+
}, 60_000);
937+
});
Lines changed: 37 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,37 @@
1+
// Copyright (c) 2026 ObjectStack. Licensed under the Apache-2.0 license.
2+
3+
import type { SemanticMigration } from '../../types.js';
4+
5+
// A narrowing of the bare item read, not of any key: ADR-0150 D3 (#32814) has
6+
// the read that names no package withhold a row stored under a customization
7+
// pair of the packages holding a name when every one of them is disabled,
8+
// where it served the row (epic red line 1: a disabled package is not served).
9+
// A pair row is bound over the holders it is a pair of, never a holder of its
10+
// own, so it is withheld with them, as the pair's exact address already was.
11+
// No key is added, removed or re-shaped and no stored row changes shape, so no
12+
// tombstone and no D2 conversion: whether to re-enable the holder is the
13+
// operator's judgement. No relevance question: the move turns on which
14+
// installed packages are disabled, which no question over one stack can name.
15+
export const entry: SemanticMigration = {
16+
id: 'disabled-holder-pair-row-bare-read-withheld',
17+
surface:
18+
'The read of a metadata item that names no package (GET /api/v1/meta/TYPE/NAME?member=MEMBER, '
19+
+ 'GET /api/v1/meta/TYPE/NAME/layers?member=MEMBER, and the execution read of the same name), at a member only a '
20+
+ 'customization pair (an App\'s PACKAGE.custom) stores, for a name every installed package holding it has '
21+
+ 'disabled, of a type the registry reads by package',
22+
replacement:
23+
'Re-enable a package that holds the name: the read naming no package then serves the pair\'s row again. '
24+
+ 'While every holder stays disabled, the read answers what it answers with no row stored: the holder\'s '
25+
+ 'withheld item (404 RESOURCE_NOT_FOUND).',
26+
reason:
27+
'A disabled package\'s items are withheld from the served reads, and so is its customization pair\'s row at '
28+
+ 'the pair\'s own address (?package=PACKAGE.custom). The read naming no package still served that row when '
29+
+ 'it reached it, because it judged the name\'s holders only when it reached nothing. It now judges them when '
30+
+ 'it reaches a row of a holder\'s pair too. A row stored under a holder of the name, a package-less row, and '
31+
+ 'a pair row beside an enabled holder of the same pair are served as before. There is no mechanical '
32+
+ 'rewrite: whether the disabled package should be enabled again is a judgement about the deployment.',
33+
acceptanceCriteria:
34+
'For every name whose holders are all disabled and whose member is stored only under a holder\'s '
35+
+ 'customization pair: GET /api/v1/meta/TYPE/NAME?member=MEMBER answers 404 RESOURCE_NOT_FOUND, never the '
36+
+ 'pair\'s row; once a holder is enabled again, the same read answers the pair\'s row.',
37+
};

0 commit comments

Comments
 (0)