diff --git a/.changeset/34441-shipped-base-canonical-member-one-answer.md b/.changeset/34441-shipped-base-canonical-member-one-answer.md new file mode 100644 index 00000000000..4e21d2daa86 --- /dev/null +++ b/.changeset/34441-shipped-base-canonical-member-one-answer.md @@ -0,0 +1,21 @@ +--- +'@objectstack/metadata-protocol': patch +'@objectstack/spec': patch +--- + +fix(metadata-protocol)!: a dependent's row of a bundle member moves no read naming no package across a restart, and a row-held base's own member is served beside a dependent's copy of it (#28802 R2, ADR-0150 red line 2) + +Clause-②: no (narrowing) +Metadata-protocol: none +Skills-docs: none — `skills/objectstack-platform/SKILL.md` (the ADR-0146 paragraph) and `content/docs/concepts/metadata-lifecycle.mdx` teach that a locale a dependent adds under a base's name is served only under its own `?package=`. This change makes `/published` and `/layers` hold to that for the canonical member of a base that ships only another member, before and after a restart, and makes a row-held base's own member the base's. No taught sentence moves. + + + +**BREAKING**: one answer of `GET /meta/TYPE/NAME/published` naming no package moves from served to 404. Name the package (`?package=DEPENDENT&member=CANONICAL`) to read the row, as before. + +**Every moved answer, before → after.** On the runtime dispatcher, in both registration orders, before and after a restart. + +- **A dependent's canonical member over a base that ships only another one** (base A ships `email_template` `welcome` in `fr-FR` only; dependent D, which declares A, stores `en-US`). `GET /meta/email_template/welcome/published` moves FROM D's row (200, before a restart only) TO `404 RESOURCE_NOT_FOUND`, its answer with no D row stored. `GET /meta/email_template/welcome/layers` (no member) moves FROM `404` after a restart TO A's `fr-FR` (200), its answer with no D row stored and before a restart; before a restart its `overlay` layer moves FROM D's row TO `null`, as with no D row stored. The layered read had reported D's row as an orphan of A's name although A ships no `en-US`, and after a restart the hydrated row took the registry's bare slot the code layer read A's `fr-FR` from. +- **A member a row-held base and its dependent both store** (A stores `en-US`, D stores `en-US` and `fr-FR`, no package ships the name). Each door below moves FROM `409 RESOURCE_CONFLICT` naming A and D (the execution read threw `PackageScopedNameRefusedError`) TO A's row (200), as when A ships `en-US`. D's row of it is a bundle addition, never a second holder. Bundled types only (a type with no members has no additions). Naming the member: `GET /meta/email_template/welcome?member=en-US`, `/layers?member=en-US` and the execution read at `en-US`. Naming no member, which addresses the canonical member `en-US`: the plain read (`packageId` A), `/layers` (effective and overlay A's row), `/published` (A's row) and the execution read. The writes naming no package do not move: the save, delete, publish, draft and history doors still refuse these rows naming A and D, so `/layers` loads A's stack where the save it then sends is refused; a follow-up card judges whether the writes follow the base. + +**Not moved.** The plain read, `?member=CANONICAL` and the execution read of the first shape (A's `fr-FR` naming no member, 404 at `en-US`). Each exact address (`?package=D&member=en-US` serves D's row). A package-less row beside two holders is still refused (#33210). A dependent's canonical row over a base that holds only another member as a row is still served (the `S1` pin of #33210). Two dependents storing the same member over a base that holds none of it are still refused naming both. A name of a type with no members (`dashboard`, `permission`, `tool`, …) that a base and its dependent both store as rows, no package shipping it, is still refused naming both on every door naming no package (#32607). The shipped CONTROL of the second shape (A ships `en-US`): the plain read and the execution read serve A's `en-US`, and `/layers` naming no member and `/published` report D's row as the overlay A's code shadows (#28409), as before. diff --git a/packages/metadata-protocol/src/protocol-meta-item-face.ts b/packages/metadata-protocol/src/protocol-meta-item-face.ts index 03a8198a1fa..404bc51e43d 100644 --- a/packages/metadata-protocol/src/protocol-meta-item-face.ts +++ b/packages/metadata-protocol/src/protocol-meta-item-face.ts @@ -429,6 +429,11 @@ const STORED_ROW_HOLDERS_REFUSAL: unique symbol = Symbol.for('objectstack.metada * them, as `/layers` refuses the same rows (`packagelessLayeredReadRefusal`), * where it served a row by store order; beside one holder or none it leaves * the read as it was. + * + * [#34441 cell 2] Not refused, of a bundled type: two or more holders at the + * member where one is the base the others' rows are bundle additions to + * ({@link rowHeldBaseAddressOf}), with no package-less row beside them. The + * read is that base's, as a shipped base's own member is served. */ async function storedRowHoldersRefusal( host: ServedRowHost, @@ -463,6 +468,16 @@ async function storedRowHoldersRefusal( return ownAndPair ? { kind: 'served', packageId: holder } : undefined; } if (holding.candidates.length < 2) return undefined; + // [#34441 cell 2, ADR-0146] Two or more packages holding the member as + // rows, where one is the base and every other one's row is a bundle + // addition to it ({@link rowHeldBaseAddressOf}): no ambiguity, as the + // registry names the base the one holder. The read is the base's, as a + // shipped base's own member is. Beside a package-less row the refusal + // above stands (#33210). + if (!holding.unbound) { + const rowHeldBase = await rowHeldBaseAddressOf(host, type, name, member, activeRows); + if (rowHeldBase !== undefined && holding.candidates.includes(rowHeldBase)) return { kind: 'served', packageId: rowHeldBase }; + } const base = { status: 'refused' as const, reason: 'ambiguous-in-environment' as const, @@ -630,46 +645,102 @@ export async function declaredMemberOverrideAddressOf( * hold only as stored rows never clashes. A dependent that also stores a * member the base stores (D's `en-US` and `fr-FR` over A's `en-US`) stays an * addition, as the registry names A the one holder there; the read at the - * shared member is left to the rows' own judgment (A holds a row there). The + * shared member is A's (below, #34441 cell 2). The * base is the one row-holding package that is no addition; - * the read is moved only when there is exactly one, it holds no row at the - * member, and no package at the member is a customization pair of another - * row-holding package (`pairsOf`: a pair's added member is served on its - * base's address already, #28802 ruling A). So a second dependent adding a + * the read is moved only when there is exactly one and no package at the + * member is a customization pair of another row-holding package (`pairsOf`: + * a pair's added member is served on its base's address already, #28802 + * ruling A). Where the base holds no row at the member, the read moves at a + * named non-canonical member only (the S1 guard); where it holds one, see + * the #34441 cell 2 paragraph below. So a second dependent adding a * member of its own (D1 `fr-FR`, D2 `de-DE` over A's `en-US`) leaves A the * base at each dependent's member, as the registry names A the one holder * whichever packages are installed, and a dependent of a dependent is an - * addition to it. The arm applies only to a bundled type the registry reads - * by package, for a name no package ships (a shipped name is the shipper's - * already), at a named member other than the canonical one, with no - * environment item at the member and no disabled package among the - * row-holding packages (the served-holder judgment above reads those). + * addition to it. Both arms apply only to a bundled type the registry reads + * by package (a type with no members has no additions: its row holders stay + * holders, #34441 contract review M1), for a name no package ships (a shipped + * name is the shipper's already), with no environment item at the member and + * no disabled package among the row-holding packages (the served-holder + * judgment above reads those). + * + * [#34441 cell 2] …and, at ANY member the base itself holds as a row (the + * canonical one included), beside one or more dependents' rows of the same + * member: that base, as the registry names it the one holder there and as a + * shipped base's own member is served. The dependents' rows of it are + * additions, served at their own addresses. The item face's refusal of two + * row holders ({@link storedRowHoldersRefusal}) and the layered door's + * (`packagelessLayeredReadRefusal`) ask this first, so the plain read, + * `/layers` and the execution face serve the base's row where they refused + * naming both; beside a package-less row they still refuse (#33210). The + * writes naming no package do not ask it: the save, delete, publish, draft + * and history doors still refuse these rows naming base and dependent + * (`packagelessAddress`), so the read serves the base's stack where the + * write it would send is refused (#34441 contract review S1). + * `preread` is the item's active rows when the caller read them already. */ export async function rowHeldBaseAddressOf( host: ServedRowHost, type: string, name: string, member: string | undefined, + preread?: Awaited>, ): Promise { + const judged = await rowHeldBaseJudgment(host, type, name, member, preread); + if (judged === undefined || judged.pairAmongHolders) return undefined; + const { base, atMember } = judged; + // [#34441 cell 2] A member the base holds as a row beside a dependent's + // addition of the same member (D's `en-US` over A's `en-US`, the canonical + // member included) is the base's, as the registry names A the one holder + // there and as a shipped base's own member is served: the dependent's row + // is an addition, never a second holder. FROM (`main` 31096af83d): two + // holders, refused `409` naming A and D, where a shipped base served A's. + if (atMember.has(base)) return atMember.size >= 2 ? base : undefined; + // [#33210 contract review S1] A member only additions hold moves for a + // NAMED non-canonical member only. `overlayMemberValue` answers null for + // the canonical member, named or not, and the read naming no member + // addresses it (reachable without `?member=` and from `/published`). That + // mirror is left as it was: a dependent's canonical row over a base that + // holds only another member is served naming no package (the S1 pin). + return typeof overlayMemberValue(PLURAL_TO_SINGULAR[type] ?? type, member) === 'string' ? base : undefined; +} + +/** + * The row-grain judgment {@link rowHeldBaseAddressOf} answers from: over a + * name no package ships, of a bundled type the registry reads by package, the + * one row-holding package that is no addition to another (the base), the + * packages holding a row at `member`, and whether one of those is a + * customization pair of a holder. `undefined` when the shape does not apply + * (see that function's docblock for each exclusion). `preread` is the item's + * active rows when the caller read them already (#24371: one read). + */ +async function rowHeldBaseJudgment( + host: ServedRowHost, + type: string, name: string, member: string | undefined, + preread?: Awaited>, +): Promise<{ base: string; atMember: ReadonlySet; pairAmongHolders: boolean } | undefined> { const registry: any = host.engine?.registry; if (typeof registry?.readsByPackage !== 'function' || registry.readsByPackage(type) !== true) return undefined; const singular = PLURAL_TO_SINGULAR[type] ?? type; - // [#33210 contract review S1] A NAMED non-canonical member only. - // `overlayMemberValue` answers null for the canonical member, named or - // not, and the read naming no member addresses it (reachable without - // `?member=` and from `/published`). That mirror is left as it was: with - // a shipped base holding only another member, its answers move across a - // reboot and the read naming no member serves the base's other member, - // so there is no one shipped answer to align it with. - if (typeof overlayMemberValue(singular, member) !== 'string') return undefined; + // [#34441 contract review M1] A bundled type only. For a type with no + // members every row of the name is at the member, and the registry names + // every holder (`packageScopedHoldersOf` with no discriminator: a bundle + // addition exists only for a bundled type), so two packages holding such + // a name as rows stay two holders, refused naming both (#32607), whatever + // their dependencies. Judged before the rows are read: such a read reads + // nothing more than it did. + if (overlayMemberValue(singular, member) === undefined) return undefined; if (shippingPackageIds(host.shippedArtifactsOf(type, name)).size > 0) return undefined; if (typeof registry.getEnvironmentScopedItem === 'function' && registry.getEnvironmentScopedItem(type, name, member) !== undefined) { return undefined; } let activeRows: Awaited>; - try { - activeRows = await host.readItemActiveRows(type, name); - } catch (error) { - host.rethrowUnlessMetadataStoreUnprovisioned(error, 'sys_metadata'); - activeRows = []; + if (preread !== undefined) { + activeRows = preread; + } else { + try { + activeRows = await host.readItemActiveRows(type, name); + } catch (error) { + host.rethrowUnlessMetadataStoreUnprovisioned(error, 'sys_metadata'); + activeRows = []; + } } const rows = activeRows.filter((row) => rowMatchesOverlayWhere(row, { type: singular, name, state: 'active' })); const memberWhere = { type: singular, name, state: 'active', ...overlayMemberWhere(singular, member) }; @@ -698,11 +769,10 @@ export async function rowHeldBaseAddressOf( const bases = holders.filter((id) => !holders.some((other) => isAdditionTo(id, other))); if (bases.length !== 1) return undefined; const [base] = bases; - const additions = new Set(atMember.map((row) => packageOf(row)!)); - if (additions.has(base)) return undefined; + const atMemberPackages = new Set(atMember.map((row) => packageOf(row)!)); const installed = installedManifestsOfEngine(host.engine); const isPairOfAHolder = (id: string): boolean => holders.some((other) => other !== id && pairsOf(other, installed).includes(id)); - return [...additions].some(isPairOfAHolder) ? undefined : base; + return { base, atMember: atMemberPackages, pairAmongHolders: [...atMemberPackages].some(isPairOfAHolder) }; } /** The body of `ObjectStackProtocolImplementation#readMetaItemFace`; the method's docblock there is its contract. */ @@ -727,7 +797,9 @@ export async function readMetaItemFace( // [#32607] …and refuses two enabled row holders of a name nobody ships. // The rows that judgment reads are read on the face's key and handed to // the read below, which takes them instead of reading them again - // (#24371: the item's active rows, one read). + // (#24371: the item's active rows, one read). [#34441 cell 2] Every + // judgment below that reads them takes the rows read already, so the + // served-holder and row-held-base judgments together are still one read. let activeRows: PrereadActiveRows | undefined; const host = this; const judgeHost: ServedRowHost = { @@ -737,6 +809,7 @@ export async function readMetaItemFace( declinesStoredRow: (...a) => this.declinesStoredRow(...a), rethrowUnlessMetadataStoreUnprovisioned: (...a) => this.rethrowUnlessMetadataStoreUnprovisioned(...a), readItemActiveRows: async (type, name) => { + if (activeRows !== undefined && activeRows.type === type && activeRows.name === name) return [...activeRows.rows]; const rows = await this.readItemActiveRows(type, name, true); activeRows = { type, name, rows }; return rows; diff --git a/packages/metadata-protocol/src/protocol-meta-layered-reads.ts b/packages/metadata-protocol/src/protocol-meta-layered-reads.ts index f69964ba224..03a63b9de10 100644 --- a/packages/metadata-protocol/src/protocol-meta-layered-reads.ts +++ b/packages/metadata-protocol/src/protocol-meta-layered-reads.ts @@ -102,6 +102,15 @@ export async function packagelessLayeredReadRefusal(host: Pick 1 && !address.unbound) { + const base = await rowHeldBaseAddressOf(host, type, name, member); + if (base !== undefined && address.candidates.includes(base)) return undefined; + } return address.candidates.length > 1 ? withPackageCandidates( packagelessAddressAmbiguityRefusal('layered read', type, name, address.candidates), @@ -404,6 +413,18 @@ export async function getMetaItemLayered(host: Pick unknown) => [r.status, r.status === 200 ? pick(unwrap(r.body)) : codeOf(r.body)]; + const bare = { + read: at(await get(b.kernel, '/meta/email_template/sharedmail'), (u) => [u?.item?.subject, u?.packageId ?? null]), + layers: at(await get(b.kernel, '/meta/email_template/sharedmail/layers'), (u) => [u?.effective?.subject, u?.overlay?.subject ?? null]), + published: at(await get(b.kernel, '/meta/email_template/sharedmail/published'), (u) => u?.subject), + executed: await (b.kernel.getService('protocol') as any).getMetaItemForExecution({ type: 'email_template', name: 'sharedmail' }) + .then((r: any) => r?.item?.subject ?? null, (e: any) => ['threw', e?.name, e?.code ?? null]), + }; + const overlay = ships ? 'addon en' : 'base en'; + expect({ leg, ...bare }).toEqual({ + leg, read: [200, ['base en', A]], layers: [200, ['base en', overlay]], published: [200, overlay], executed: 'base en', + }); + // [#34441 cell 2] The shared member `en-US`, naming no package, is + // the base's, however A holds the name: D's row of it is a bundle + // addition, never a second holder, so the plain read, /layers and + // the execution face serve A's row, as a shipped base serves its + // own. FROM (`main` 31096af83d): over a row-held base A's and D's + // rows of it were two holders, refused 409 naming both. const shared = await get(b.kernel, '/meta/email_template/sharedmail', { member: 'en-US' }); - if (ships) { - expect([leg, shared.status, unwrap(shared.body)?.item?.subject, unwrap(shared.body)?.packageId], JSON.stringify(shared.body)).toEqual([leg, 200, 'base en', A]); - } else { - expect([leg, shared.status, codeOf(shared.body)], JSON.stringify(shared.body)).toEqual([leg, 409, 'RESOURCE_CONFLICT']); - for (const id of [A, D]) expect(JSON.stringify(shared.body), leg).toContain(id); - } + const sharedLayers = await get(b.kernel, '/meta/email_template/sharedmail/layers', { member: 'en-US' }); + const sharedExecuted = await (b.kernel.getService('protocol') as any).getMetaItemForExecution({ type: 'email_template', name: 'sharedmail', member: 'en-US' }); + expect([leg, shared.status, unwrap(shared.body)?.item?.subject, unwrap(shared.body)?.packageId, + sharedLayers.status, unwrap(sharedLayers.body)?.effective?.subject, sharedExecuted?.item?.subject], + JSON.stringify([shared.body, sharedLayers.body])) + .toEqual([leg, 200, 'base en', A, 200, 'base en', 'base en']); + // D's own address still serves D's row of it. + const sharedOwn = await get(b.kernel, '/meta/email_template/sharedmail', { member: 'en-US', package: D }); + expect([leg, sharedOwn.status, unwrap(sharedOwn.body)?.item?.subject], JSON.stringify(sharedOwn.body)).toEqual([leg, 200, 'addon en']); }; try { for (const id of registered) { @@ -777,6 +806,56 @@ describe('[#32607 M1, M2] the no-disabled arm judges holders at the rows\' grain } }, 240_000); + // [#34441 contract review M1] A type with no members has no bundle + // additions: the registry names every package holding the name a holder + // (`packageScopedHoldersOf` with no discriminator), whatever their + // dependencies. So base A and dependent D (which declares A) each storing + // a row of a `dashboard` no package ships stay two holders, and every door + // naming no package refuses naming both (#32607), in both registration + // orders, before and after a reboot; each exact address serves its own + // row. FROM (head 1aff827bd5, the cell-2 arm unguarded for such a type): + // the plain read, `/layers`, `/published` and the execution read served A's. + it.each([ + { order: 'registered and saved A, D', registered: [A, D] }, + { order: 'registered and saved D, A', registered: [D, A] }, + ])('M1 guard, $order: a non-bundled name a base and its dependent both store is refused naming both on every door naming no package, before and after a reboot', async ({ registered }) => { + const file = freshFile(); + const manifests = registered.map((id) => (id === A ? appManifest(A) : appManifest(D, { dependencies: { [A]: '*' } }))); + let booted = await bootManifests(manifests, file); + const observe = async (b: Booted, leg: string) => { + const refusal = (r: { status?: number; body: any }) => [r.status, codeOf(r.body), + [...(r.body?.error?.details?.candidates ?? [])].map((c: any) => c.packageId).sort()]; + const bare = { + read: refusal(await get(b.kernel, '/meta/dashboard/basedep_dash')), + layers: refusal(await get(b.kernel, '/meta/dashboard/basedep_dash/layers')), + published: refusal(await get(b.kernel, '/meta/dashboard/basedep_dash/published')), + executed: await (b.kernel.getService('protocol') as any).getMetaItemForExecution({ type: 'dashboard', name: 'basedep_dash' }) + .then((r: any) => ['served', r?.item?.label ?? null], (e: any) => ['threw', e?.code ?? null, e?.httpStatus ?? null]), + }; + const both = [A, D].sort(); + expect({ leg, ...bare }).toEqual({ + leg, read: [409, 'RESOURCE_CONFLICT', both], layers: [409, 'RESOURCE_CONFLICT', both], + published: [409, 'RESOURCE_CONFLICT', both], executed: ['threw', 'RESOURCE_CONFLICT', 409], + }); + for (const id of [A, D]) { + const own = await get(b.kernel, '/meta/dashboard/basedep_dash', { package: id }); + expect([leg, id, own.status, unwrap(own.body)?.item?.label], JSON.stringify(own.body)).toEqual([leg, id, 200, id === A ? 'base row' : 'addon row']); + } + }; + try { + for (const id of registered) await layRow(booted.engine, 'dashboard', 'basedep_dash', id, { label: id === A ? 'base row' : 'addon row', widgets: [] }); + await observe(booted, 'before a reboot'); + } finally { + await down(booted); + } + booted = await bootManifests(manifests, file); + try { + await observe(booted, 'after a reboot'); + } finally { + await down(booted); + } + }, 240_000); + // [#33210 contract review S1] The canonical-member mirror is left as it // was: a dependent's row of the CANONICAL member (`en-US`) over a base that // holds the name only as a stored row of another member (`fr-FR`). The @@ -823,6 +902,63 @@ describe('[#32607 M1, M2] the no-disabled arm judges holders at the rows\' grain await down(booted); } }, 240_000); + + // [#34441 cell 1, #28802 R2] A dependent's canonical member over a base + // that SHIPS only another member (A ships `fr-FR`, D stores `en-US`) moves + // no door naming no package: each answers what it answers with no D row + // (the CONTROL), in both registration orders, before and after a restart. + // The dependent's row is an addition, served only at its own address. + // FROM (`main` 31096af83d): `/published` served D's row before a restart + // (the layered read reported it as an orphan of A's name, though A ships + // no `en-US`), and `/layers` naming no member answered 404 after it (the + // hydrated row took the bare slot the code layer read A's `fr-FR` from). + it.each([ + { order: 'registered A, D', registered: [A, D] }, + { order: 'registered D, A', registered: [D, A] }, + ])('cell 1, $order: a dependent\'s canonical row over a base shipping only another member answers every door naming no package as with no such row, before and after a restart', async ({ registered }) => { + const file = freshFile(); + const manifests = registered.map((id) => (id === A + ? appManifest(A, { emailTemplates: [{ name: 'shipfrmail', ...template('fr-FR', 'base fr') }] }) + : appManifest(D, { dependencies: { [A]: '*' } }))); + let booted = await bootManifests(manifests, file); + const answers = async (b: Booted) => { + const at = (r: { status?: number; body: unknown }, pick: (u: any) => unknown) => [r.status, r.status === 200 ? pick(unwrap(r.body)) : codeOf(r.body)]; + const protocol = b.kernel.getService('protocol') as any; + return { + read: at(await get(b.kernel, '/meta/email_template/shipfrmail'), (u) => u?.item?.subject), + named: at(await get(b.kernel, '/meta/email_template/shipfrmail', { member: 'en-US' }), (u) => u?.item?.subject), + layers: at(await get(b.kernel, '/meta/email_template/shipfrmail/layers'), (u) => [u?.effective?.subject, u?.overlay?.subject ?? null]), + layersNamed: at(await get(b.kernel, '/meta/email_template/shipfrmail/layers', { member: 'en-US' }), (u) => u?.effective?.subject), + published: at(await get(b.kernel, '/meta/email_template/shipfrmail/published'), (u) => u?.subject), + executed: (await protocol.getMetaItemForExecution({ type: 'email_template', name: 'shipfrmail' }))?.item?.subject ?? null, + executedNamed: (await protocol.getMetaItemForExecution({ type: 'email_template', name: 'shipfrmail', member: 'en-US' }))?.item?.subject ?? null, + }; + }; + // The CONTROL, read on this boot before D's row is stored. + const control = { + read: [200, 'base fr'], named: [404, 'RESOURCE_NOT_FOUND'], layers: [200, ['base fr', null]], layersNamed: [404, 'RESOURCE_NOT_FOUND'], + published: [404, 'RESOURCE_NOT_FOUND'], executed: 'base fr', executedNamed: null, + }; + const own = async (b: Booted, leg: string) => { + const r = await get(b.kernel, '/meta/email_template/shipfrmail', { member: 'en-US', package: D }); + expect([leg, r.status, unwrap(r.body)?.item?.subject], JSON.stringify(r.body)).toEqual([leg, 200, 'addon en']); + }; + try { + expect({ leg: 'no D row', ...(await answers(booted)) }).toEqual({ leg: 'no D row', ...control }); + await layRow(booted.engine, 'email_template', 'shipfrmail', D, template('en-US', 'addon en')); + expect({ leg: 'before a restart', ...(await answers(booted)) }).toEqual({ leg: 'before a restart', ...control }); + await own(booted, 'before a restart'); + } finally { + await down(booted); + } + booted = await bootManifests(manifests, file); + try { + expect({ leg: 'after a restart', ...(await answers(booted)) }).toEqual({ leg: 'after a restart', ...control }); + await own(booted, 'after a restart'); + } finally { + await down(booted); + } + }, 240_000); }); // --------------------------------------------------------------------------- diff --git a/packages/spec/src/migrations/entries/semantic/18.shipped-base-dependent-canonical-row-not-published.ts b/packages/spec/src/migrations/entries/semantic/18.shipped-base-dependent-canonical-row-not-published.ts new file mode 100644 index 00000000000..ead7abae2da --- /dev/null +++ b/packages/spec/src/migrations/entries/semantic/18.shipped-base-dependent-canonical-row-not-published.ts @@ -0,0 +1,38 @@ +// Copyright (c) 2026 ObjectStack. Licensed under the Apache-2.0 license. + +import type { SemanticMigration } from '../../types.js'; + +// A narrowing of the bare published read, not of any key: #34441 (cell 1) has +// `/published` naming no package stop serving a dependent's stored row of the +// canonical bundle member when the base ships the name only in another member. +// The rule is #28802 / epic #31527 child R2 (a bundle addition holds no name): +// the read naming no package reads the base's address, which holds no +// canonical member, so it answers what it answers with no such row (404). It +// served the dependent's row there, and only until a restart: the layered read +// reported that row as an orphan of the base's name (#28409) although the base +// ships no member it could shadow. No key is added, removed or re-shaped and no +// stored row changes shape, so no tombstone and no D2 conversion: the +// dependent's row stays at its own address. No relevance question: the move +// turns on which members a base ships and which a dependent stores, which no +// question over one stack can name. +export const entry: SemanticMigration = { + id: 'shipped-base-dependent-canonical-row-not-published', + surface: + 'GET /api/v1/meta/TYPE/NAME/published, naming no package, for a bundled metadata name a base package ships ' + + 'only in members other than the canonical one, where a dependent package (one that declares the base) stores ' + + 'a row of the canonical member. Before a restart it served the dependent\'s row; after one it answered 404. ' + + 'The plain read, ?member=CANONICAL and the execution read do not move', + replacement: + 'Name the dependent: GET /api/v1/meta/TYPE/NAME?package=DEPENDENT&member=CANONICAL serves its row, as before.', + reason: + 'A bundle addition holds no name (the rule the registry applies when it counts a name\'s holders): the read ' + + 'naming no package reads the base\'s address, which ships no canonical member, so it answers as it does with ' + + 'no dependent row stored. /published served the dependent\'s row only until a restart, so the same request ' + + 'answered two ways. There is no mechanical rewrite: whether a caller meant the dependent\'s member is a ' + + 'judgement about that caller.', + acceptanceCriteria: + 'For every bundled name a base ships only in non-canonical members and a dependent extends with a stored row ' + + 'of the canonical member: every caller that reads /published without ?package= reads the dependent\'s row from the item read ' + + 'GET /api/v1/meta/TYPE/NAME?package=DEPENDENT&member=CANONICAL instead; /published without ?package= answers 404, before and after a ' + + 'restart, as with no dependent row stored.', +};