From 04e0ebcf4fb92e1798caf4ef65122cf22f6352a5 Mon Sep 17 00:00:00 2001 From: Claude Date: Sun, 29 Nov 2026 16:17:37 +0000 Subject: [PATCH 1/9] fix(metadata-protocol): the bare doc doors serve the environment's entry beside one enabled holder Beside one enabled holder of a doc name, a package-less entry in the registry's bare slot (a stamp-less registration, or the hydrated package-less row) is the environment's own item, and it answers first, as it already does beside two holders. The bare plain read, /layers and both /published doors now serve it, agreeing with the registry and MetadataFacade.get; the holder's own address still reads its doc. Claude-Session: https://claude.ai/code/session_01ADHkmQmQ1jpFsNcARMbY56 Co-authored-by: Claude --- .../src/protocol-meta-item-reads.ts | 23 +++-- .../src/protocol-meta-layered-reads.ts | 6 +- packages/rest/src/meta-item-history-routes.ts | 2 +- ...meta-disabled-holder-artifact-door.test.ts | 90 +++++++++++++++---- packages/runtime/src/domains/meta.ts | 2 +- 5 files changed, 94 insertions(+), 29 deletions(-) diff --git a/packages/metadata-protocol/src/protocol-meta-item-reads.ts b/packages/metadata-protocol/src/protocol-meta-item-reads.ts index e143df965b1..ac8a8b5c414 100644 --- a/packages/metadata-protocol/src/protocol-meta-item-reads.ts +++ b/packages/metadata-protocol/src/protocol-meta-item-reads.ts @@ -340,13 +340,18 @@ export async function judgeBareActionRead( * slot (a stamp-less registration, or a hydrated or saved row stamped with * the store's sentinel) exempts the name: it is the environment's own item, * which answers first, as the registry and `MetadataFacade.get` serve it. - * That entry is returned when two or more enabled packages hold the name, + * That entry is returned when one or more enabled packages hold the name, * because the layers must then serve it: the MetadataService keeps a doc by - * name alone, so its copy is the holder registered last, and it answered - * first ({@link bareDocServiceCopyDisplacesEntry}). + * name alone, so its copy is a holder's (the one registered last), and it + * answered first ({@link bareDocServiceCopyDisplacesEntry}). * - * @returns the environment's entry beside two or more enabled holders, else - * `undefined` (no such entry, or a name one package or none holds). + * [#34452, ruling 6942962369] Beside ONE enabled holder too: the + * environment's own item answers first whatever number of packages hold the + * name, so the bare doors agree with the registry and `MetadataFacade.get`. + * They served the one holder's doc while those two served the entry. + * + * @returns the environment's entry beside one or more enabled holders, else + * `undefined` (no such entry, or a name no enabled package holds). * @throws {PackageScopedNameRefusedError} two or more enabled package holders. */ export function refuseAmbiguousBareDocRead(host: Pick, name: string, member: string | undefined): unknown { @@ -357,9 +362,9 @@ export function refuseAmbiguousBareDocRead(host: Pick, n if (typeof registry?.resolveItem !== 'function') return undefined; const answer = registry.resolveItem('doc', name, null, member); // The registry's answer naming no package is the exempting entry (or a - // name one package or none holds, which the count below leaves alone). + // name no enabled package holds, which the count below leaves alone). if (answer === undefined || answer === null || storedItemPackageId(answer) !== undefined) return undefined; - return (registry.packageScopedHoldersOf?.('doc', name) ?? []).length >= 2 ? answer : undefined; + return (registry.packageScopedHoldersOf?.('doc', name) ?? []).length >= 1 ? answer : undefined; } /** @@ -1372,8 +1377,8 @@ export async function readMetaItem(host: Pick { - const label = `${ships[0]!.split('.').pop()} doc`; + // [#34452, ruling 6942962369] The environment's own item answers first + // beside ONE enabled holder too, as beside two (#34248): the bare doors + // serve a package-less entry in the registry's bare slot, agreeing with + // the registry and `MetadataFacade.get`, never the holder's doc; the + // holder's own address still reads its doc. FROM (origin/main 7213177e, + // measured on this rig, both orders): every bare door, both transports, + // served the holder's doc while the registry and the facade answered the + // entry (pinned here as `[measured, unresolved]` by #34347). + const withBareDocEntry = async (entry: Record, body: () => Promise) => { const bareSlot = (booted!.engine.registry as unknown as { metadata: Map> }).metadata.get('doc')!; const before = bareSlot.has('shared_doc') ? { held: bareSlot.get('shared_doc') } : undefined; - booted!.engine.registry.registerItem('doc', { name: 'shared_doc', label: 'bare entry', content: '# bare' } as never, 'name' as never); + booted!.engine.registry.registerItem('doc', { name: 'shared_doc', content: '# bare', ...entry } as never, 'name' as never); try { - expect((booted!.engine.registry.resolveItem('doc', 'shared_doc', null) as { label?: string } | undefined)?.label).toBe('bare entry'); - for (const answer of await bareDoors(booted!, 'doc', 'shared_doc')) { - const served = answer.door.endsWith('/layers') ? answer.body?.effective?.label : (answer.body?.item ?? answer.body)?.label; - expect([answer.status, served, answer.door], JSON.stringify(answer.body)).toEqual([200, label, answer.door]); - } + await body(); } finally { if (before) bareSlot.set('shared_doc', before.held); else bareSlot.delete('shared_doc'); } + }; + /** The registry and the facade, each naming no package: the readers the bare doors agree with. */ + const registryReaders = async () => [ + (booted!.engine.registry.resolveItem('doc', 'shared_doc', null) as { label?: string } | undefined)?.label, + (await new MetadataFacade(booted!.engine.registry).get('doc', 'shared_doc') as { label?: string } | undefined)?.label, + ]; + /** Each bare door's answer: the plain read and `/published` the item, `/layers` its code, overlay and effective layers. */ + const bareDoorLabels = async () => (await bareDoors(booted!, 'doc', 'shared_doc')).map((answer) => [ + answer.door, answer.status, + ...(answer.door.endsWith('/layers') + ? [answer.body?.code?.label, answer.body?.overlay?.label, answer.body?.effective?.label] + : [(answer.body?.item ?? answer.body)?.label]), + ]); + const expectHolderAddressReadsOwnDoc = async () => { + const holder = ships[0]!; + for (const answer of await exactDocAndLayers(booted!, holder)) { + const served = answer.door.includes('/layers') + ? [answer.body?.code?.label, answer.body?.effective?.label] + : [(answer.body?.item ?? answer.body)?.label]; + const label = `${holder.split('.').pop()} doc`; + expect([answer.status, ...served, answer.door], JSON.stringify(answer.body)).toEqual([200, ...served.map(() => label), answer.door]); + } + }; + + it.runIf(ships.length === 1)('[#34452] one holder beside a stamp-less bare entry: the plain read, /layers (the entry as code and effective) and /published serve the entry on both transports, as the registry and MetadataFacade.get do; the holder\'s address reads its own doc', async () => { + await withBareDocEntry({ label: 'bare entry' }, async () => { + expect(await registryReaders()).toEqual(['bare entry', 'bare entry']); + for (const [door, status, ...served] of await bareDoorLabels()) { + const want = String(door).endsWith('/layers') ? ['bare entry', undefined, 'bare entry'] : ['bare entry']; + expect([door, status, ...served]).toEqual([door, 200, ...want]); + } + await expectHolderAddressReadsOwnDoc(); + }); + // The entry gone: the holder's doc again (the CONTROL above). + for (const [door, status, ...served] of await bareDoorLabels()) { + expect([door, status, served.at(-1)]).toEqual([door, 200, `${ships[0]!.split('.').pop()} doc`]); + } + }); + + // [#34452 acceptance 4] The hydrated package-less row the hydrator lays + // when it reads the row before the holder's artifact (the stored row and, + // in the bare slot, a tenant-authored body with no `_packageId`): the row + // answers first, as beside two holders (#34248): no code layer, the row as + // overlay and effective. FROM (origin/main 7213177e, measured): the bare + // doors served the holder's doc (`/layers` the row as overlay over the + // holder's effective doc) while the registry and the facade answered the row. + it.runIf(ships.length === 1)('[#34452] one holder beside a hydrated package-less row: the plain read, /layers (no code layer, the row as overlay and effective) and /published serve the row on both transports, as the registry and MetadataFacade.get do; the holder\'s address reads its own doc', async () => { + await booted!.engine.insert('sys_metadata', { + type: 'doc', name: 'shared_doc', namespace: 'default', package_id: null, scope: 'platform', strategy: 'merge', state: 'active', version: 1, + metadata: JSON.stringify({ name: 'shared_doc', label: 'environment doc', content: '# env' }), + }, { context: { isSystem: true } } as any); + try { + await withBareDocEntry({ label: 'environment doc', content: '# env', _provenance: 'org' }, async () => { + expect(await registryReaders()).toEqual(['environment doc', 'environment doc']); + for (const [door, status, ...served] of await bareDoorLabels()) { + const want = String(door).endsWith('/layers') ? [undefined, 'environment doc', 'environment doc'] : ['environment doc']; + expect([door, status, ...served]).toEqual([door, 200, ...want]); + } + await expectHolderAddressReadsOwnDoc(); + }); + } finally { + await booted!.engine.delete('sys_metadata', { where: { type: 'doc', name: 'shared_doc' }, multi: true, context: { isSystem: true } } as any); + } }); it('CONTROL: each holder\'s address answers its own doc on the plain read and /layers (code and effective), both transports', async () => { diff --git a/packages/runtime/src/domains/meta.ts b/packages/runtime/src/domains/meta.ts index 2f5ca071175..2ce0b60ea27 100644 --- a/packages/runtime/src/domains/meta.ts +++ b/packages/runtime/src/domains/meta.ts @@ -1740,7 +1740,7 @@ export async function handleMetadataRequest(deps: DomainHandlerDeps, path: strin if (mixedOwner !== undefined && typeof stamp === 'string' && stamp !== mixedOwner && mixedHolders.includes(stamp)) return publishedCode; // [#34248, ruling 6893582352] …and a bare doc's package copy where // the layered read's code layer is the environment's own - // package-less entry (two enabled holders beside it): that entry + // package-less entry (one or more enabled holders beside it, #34452): that entry // answers first, never the holder registered last. const codeStamp = (publishedCode as { _packageId?: unknown } | null | undefined)?._packageId; return publishedType === 'doc' && publishedCode != null && (typeof codeStamp !== 'string' || codeStamp === '' || codeStamp === 'sys_metadata') From 4bd94501b8e309cb19fcefa4536b82bf410fcb5d Mon Sep 17 00:00:00 2001 From: Claude Date: Sun, 29 Nov 2026 16:34:06 +0000 Subject: [PATCH 2/9] fix(metadata-protocol): the in-process layered read refuses a doc two enabled packages hold, as the plain read does Criterion (#34190): getMetaItemLayered naming no package, of a doc two or more enabled packages hold with no package-less environment entry, refuses 409 RESOURCE_CONFLICT naming each holder (refusal.candidates), as getMetaItem does; each holder's address reads its own layers. It swallowed the refusal and served the layers of the holder registered first. The HTTP transports already refused through their own step; the environment entry beside them still answers first (#34452, ruling 6942962369). Claude-Session: https://claude.ai/code/session_01ADHkmQmQ1jpFsNcARMbY56 Co-authored-by: Claude --- .../src/protocol-meta-layered-reads.ts | 20 +++++++++---------- ...meta-disabled-holder-artifact-door.test.ts | 19 ++++++++++++++++++ 2 files changed, 29 insertions(+), 10 deletions(-) diff --git a/packages/metadata-protocol/src/protocol-meta-layered-reads.ts b/packages/metadata-protocol/src/protocol-meta-layered-reads.ts index 349a0de4b17..a41a53a5b71 100644 --- a/packages/metadata-protocol/src/protocol-meta-layered-reads.ts +++ b/packages/metadata-protocol/src/protocol-meta-layered-reads.ts @@ -319,16 +319,16 @@ async function getGenericMetaItemLayered(host: LayeredReadHost, request: { // [#34248, #34452, ruling 6893582352] …and a bare doc read of a name one // or more enabled packages hold, beside the environment's own entry, reads that entry as // {@link getMetaItem} serves it ({@link refuseAmbiguousBareDocRead}): as - // its code layer, never the package copy the service kept. Its refusal - // without such an entry stays the door's, as before. - let bareDocEnvironmentEntry: unknown; - if (!request.packageId && request.type === 'doc') { - try { - bareDocEnvironmentEntry = refuseAmbiguousBareDocRead(host, request.name, member); - } catch (error) { - if (packageScopedRefusalOf(error) === undefined) throw error; - } - } + // its code layer, never the package copy the service kept. + // [#34190, ADR-0150 D3/D5] Without such an entry, a name two or more + // enabled packages hold is refused here as the plain read refuses it + // (`409 RESOURCE_CONFLICT` naming each holder), before any layer is read. + // The refusal was dropped and left to the doors, so an in-process caller + // (`getMetaItemLayered` naming no package) read the layers of the holder + // the metadata service registered last while `getMetaItem` refused. + const bareDocEnvironmentEntry: unknown = !request.packageId && request.type === 'doc' + ? refuseAmbiguousBareDocRead(host, request.name, member) + : undefined; // [ADR-0150 D3, #32914] …and, naming no package, a type addressed by // package is judged by the registry's package-scoped resolver, as the // plain read judges it ({@link getMetaItem}, its `packagelessScopedRead`): diff --git a/packages/runtime/src/domains/meta-disabled-holder-artifact-door.test.ts b/packages/runtime/src/domains/meta-disabled-holder-artifact-door.test.ts index 298cc34b6e6..256eaae3774 100644 --- a/packages/runtime/src/domains/meta-disabled-holder-artifact-door.test.ts +++ b/packages/runtime/src/domains/meta-disabled-holder-artifact-door.test.ts @@ -493,6 +493,25 @@ describe.each([ await expectExactReadsOwnDoc(); }); + // [#34190, ADR-0150 D3/D5] In process, the layered read naming no package + // refuses as the plain read does, naming both holders with candidates. + // FROM (origin/main 7213177e, measured on this rig, both orders): + // `getMetaItemLayered({ type: 'doc', name })` answered 200 with the layers + // of the holder the metadata service registered last while `getMetaItem` + // refused 409; the doors refused only because they ask the plain read. + it('[#34190] in process: getMetaItemLayered naming no package refuses 409 naming both, as getMetaItem does; naming each holder reads its own layers', async () => { + const protocol = booted!.kernel.getService('protocol'); + for (const read of [() => protocol.getMetaItem({ type: 'doc', name: 'shared_doc' }), () => protocol.getMetaItemLayered({ type: 'doc', name: 'shared_doc' })]) { + const refusal = await read().then((resolved: unknown) => ({ resolved }), (error: unknown) => error as any); + expect([refusal?.code, refusal?.status], JSON.stringify(refusal?.resolved ?? String(refusal?.message))).toEqual(['RESOURCE_CONFLICT', 409]); + expect((refusal?.refusal?.candidates ?? []).map((c: { packageId?: string }) => c.packageId).sort()).toEqual([ALPHA, BETA].sort()); + } + for (const [packageId, label] of [[ALPHA, 'alpha doc'], [BETA, 'beta doc']] as const) { + const layers = await protocol.getMetaItemLayered({ type: 'doc', name: 'shared_doc', packageId }); + expect([layers?.code?.label, layers?.effective?.label]).toEqual([label, label]); + } + }); + /** Each bare door's answer: the plain read and `/published` the item, `/layers` its code, overlay and effective layers. */ const expectBareDoorsServe = async (expected: { item: string; code: string | undefined; overlay: string | undefined }) => { for (const answer of await bareDoors(booted!, 'doc', 'shared_doc')) { From 586b7edc60d02dce993ccd0c75ca80011ff204ee Mon Sep 17 00:00:00 2001 From: Claude Date: Sun, 29 Nov 2026 16:42:04 +0000 Subject: [PATCH 3/9] fix(metadata-protocol): a package-less row beside a disabled holder reads as it does without that holder Criterion (#34440): a name no enabled package ships, held as stored rows by a disabled package and enabled ones beside a package-less row, reads on every bare door (plain, /layers, /published, execution) as it reads when the disabled holder is absent (#33210): two or more enabled holders are refused 409 naming exactly them, never the disabled package and never serving the package-less row; one enabled holder is served. Every save order, both registration orders, before and after a reboot; ?package=DISABLED stays 404. The served-set judgment left a package-less row beside a disabled holder as it was, so the read followed save order (the order D, package-less, E answered 404) and /layers named the disabled package. Claude-Session: https://claude.ai/code/session_01ADHkmQmQ1jpFsNcARMbY56 Co-authored-by: Claude --- .../src/protocol-meta-item-face.ts | 31 +++-- .../src/meta-disabled-package-doors.test.ts | 92 ++++++++++++++ .../meta-disabled-holder-served-stack.test.ts | 116 ++++++++++++++++++ 3 files changed, 228 insertions(+), 11 deletions(-) diff --git a/packages/metadata-protocol/src/protocol-meta-item-face.ts b/packages/metadata-protocol/src/protocol-meta-item-face.ts index 960ea88d718..6380a47b0d1 100644 --- a/packages/metadata-protocol/src/protocol-meta-item-face.ts +++ b/packages/metadata-protocol/src/protocol-meta-item-face.ts @@ -273,14 +273,16 @@ const SERVED_HOLDER_JUDGED_ELSEWHERE: ReadonlySet = new Set(['object', ' * package ships no code item of the name (otherwise the shipped item is the * name's, ADR-0048 §3.3, and a row of another package never stands in for * it: {@link servedHolderAddressOf} and `packagelessContentPackage` judge - * it), and when no package-less row and no - * environment item is stored (a customization of no one holder, judged as - * before). [#33210] On the item face (`options.refuseWithoutDisabled`) a + * it). [#33210] On the item face (`options.refuseWithoutDisabled`) a * package-less row, or the registry's environment item, beside rows bound to * two or more packages with no disabled package among them is judged with * those rows instead ({@link storedRowHoldersRefusal}), so it is refused - * naming them; beside one holder, none, or a disabled holder the read is left - * as it was. Then the holders are the registry's served holders and the + * naming them; beside one holder or none the read is left as it was. + * [#34440] Beside rows bound to two or more packages a disabled one among + * them, it is judged below with those rows on every door, as the item face + * judges it with no disabled holder: a package-less row is no holder and no + * tie-break. Beside one bound package or none the read is left as it was. + * Then the holders are the registry's served holders and the * packages the active rows are bound to, less every disabled package: * * - one → `{ kind: 'served' }`, read at its address, as the registry's @@ -306,8 +308,7 @@ const SERVED_HOLDER_JUDGED_ELSEWHERE: ReadonlySet = new Set(['object', ' * package's address, so it makes that package no holder here: counted, it * re-addressed the read to an address that serves nothing, and two of them * were refused naming two such addresses. It still counts toward whether a - * disabled package holds the name, and an unbound one still leaves the read - * as it was. + * disabled package holds the name. * * [#32354 contract review N2, #32408] Nor does a row bound to a holder's * customization pair (`pairsOf`): a pair row is bound over every holder it @@ -340,7 +341,11 @@ export async function servedRowHolderOf( if ([...shippingPackageIds(host.shippedArtifactsOf(type, name, undefined, member))].some((id) => !disabled(id))) return undefined; const environmentItem = typeof registry.getEnvironmentScopedItem === 'function' && registry.getEnvironmentScopedItem(type, name, member) !== undefined; - if (environmentItem && options.refuseWithoutDisabled !== true) return undefined; + // [#34440] Not left as it was here when a package is disabled: the + // environment item may be a package-less row beside rows bound to two or + // more packages, a disabled one among them, which is judged below over + // the served set on every door (the plain read's face, `/layers`'s + // refusal and the save door alike). // The item's active rows, read once: every row binds a holder, and only // the rows the reads serve make a served one (S4). An unprovisioned store // holds no row. @@ -363,10 +368,14 @@ export async function servedRowHolderOf( const every: readonly string[] = registry.packageScopedHoldersOf(type, name, null, { includeDisabledPackages: true }) ?? []; const anyDisabled = [...every, ...rows.candidates].some(disabled); // [#33210] The no-disabled arm judges a package-less row itself - // ({@link storedRowHoldersRefusal}); beside a disabled holder it leaves - // the read as it was. + // ({@link storedRowHoldersRefusal}). if (!anyDisabled) return options.refuseWithoutDisabled === true ? storedRowHoldersRefusal(host, type, name, member, every, activeRows, rows.candidates) : undefined; - if (rows.unbound) return undefined; + // [#34440, ADR-0150 D3] Beside a disabled holder a package-less row is + // judged over the served set as it is with no disabled holder (#33210): + // two or more served holders are refused naming only them, one is served + // at its address, so every bare door gives the answer it gives when the + // disabled holder is absent. Left as it was, the read followed save + // order (one order answered 404) and `/layers` named the disabled package. const installed = installedManifestsOfEngine(host.engine); const pairRow = (row: { package_id?: unknown }): boolean => typeof row.package_id === 'string' && every.some((holder) => pairsOf(holder, installed).includes(row.package_id as string)); diff --git a/packages/rest/src/meta-disabled-package-doors.test.ts b/packages/rest/src/meta-disabled-package-doors.test.ts index 3daa5a0107c..388c500f421 100644 --- a/packages/rest/src/meta-disabled-package-doors.test.ts +++ b/packages/rest/src/meta-disabled-package-doors.test.ts @@ -989,6 +989,98 @@ describe('[#33210] RestServer: a package-less row beside two enabled row holders }, 60_000); }); +/** + * [#34440, ADR-0150 D3] A package-less row beside a disabled holder's row and + * enabled holders' rows, no shipper: every bare door gives the answer it + * gives when the disabled holder is absent (#33210 above). Two enabled + * holders are refused naming exactly them, never the disabled package, and + * the package-less row is never served in their place; one enabled holder is + * served. Every save order, both registration orders. + * + * FROM (`main` 7213177e, the card's re-measure): the judgment left a + * package-less row beside a disabled holder as it was, so the plain read and + * the execution face followed save order, `/published` served the + * package-less row and `/layers` refused naming the disabled package too; one + * enabled holder saved after the disabled one and the package-less row + * answered 404. + */ +describe('[#34440] RestServer: a package-less row beside a disabled holder\'s row', () => { + const THIRD_PKG = 'app.third_demo'; + const label = (pkg: string | null) => (pkg === OTHER_PKG ? 'healthy row' : pkg === THIRD_PKG ? 'third row' : pkg === PKG ? 'disabled row' : 'package-less row'); + const lay = (host: ReturnType, name: string, pkg: string | null) => (host.protocol as any).engine.insert('sys_metadata', { + type: 'dashboard', name, package_id: pkg, state: 'active', scope: 'platform', strategy: 'merge', version: 1, + metadata: JSON.stringify({ name, label: label(pkg), widgets: [] }), + }); + const ORDERS = [['disabled first', [PKG, OTHER_PKG, THIRD_PKG]], ['enabled first', [OTHER_PKG, THIRD_PKG, PKG]]] as const; + const tagOf = (pkg: string | null) => (pkg === null ? 'package-less' : label(pkg).split(' ')[0]); + const candidatesOf = (body: any) => [...(body?.details?.candidates ?? body?.error?.details?.candidates ?? [])].map((c: any) => c.packageId).sort(); + const noTrace = (answers: ReadonlyArray<{ body: unknown }>) => { + for (const answer of answers) { + const text = JSON.stringify(answer.body ?? null); + expect(text).not.toMatch(/(disabled|package-less) row/); + expect(text).not.toContain(PKG); + } + }; + const boot = async (packages: readonly string[], name: string, saved: readonly (string | null)[]) => { + const host = setup(); + for (const pkg of packages) host.registry.installPackage({ id: pkg, name: pkg, version: '1.0.0' } as any, 'code'); + for (const pkg of saved) await lay(host, name, pkg); + host.registry.disablePackage(PKG); + return host; + }; + + const TWO: ReadonlyArray = [ + [OTHER_PKG, THIRD_PKG, PKG, null], [null, PKG, THIRD_PKG, OTHER_PKG], [PKG, null, OTHER_PKG, THIRD_PKG], + ]; + it.each(ORDERS.flatMap(([order, packages]) => TWO.map((saved) => [`${order}, saved ${saved.map(tagOf).join(' then ')}`, packages, saved] as const)))( + '%s: two enabled holders are refused on every bare door naming exactly them', + async (_label, packages, saved) => { + const host = await boot(packages, 'pl_two_dash', saved); + const read = await host.plain('dashboard', 'pl_two_dash'); + const layers = await host.layers('dashboard', 'pl_two_dash'); + const published = await host.published('dashboard', 'pl_two_dash'); + for (const [door, answer] of [['plain', read], ['layers', layers], ['published', published]] as const) { + expect([door, answer.status, answer.body?.code ?? answer.body?.error?.code], JSON.stringify(answer.body)) + .toEqual([door, 409, 'RESOURCE_CONFLICT']); + for (const pkg of [OTHER_PKG, THIRD_PKG]) expect(JSON.stringify(answer.body)).toContain(pkg); + } + expect(candidatesOf(read.body), JSON.stringify(read.body)).toEqual([OTHER_PKG, THIRD_PKG].sort()); + expect(candidatesOf(layers.body), JSON.stringify(layers.body)).toEqual([OTHER_PKG, THIRD_PKG].sort()); + noTrace([read, layers, published]); + const executed = await host.protocol.getMetaItemForExecution({ type: 'dashboard', name: 'pl_two_dash' }).then( + () => 'served', + (error: any) => [error?.code, error?.httpStatus, [...(error?.refusal?.candidates ?? [])].map((c: any) => c.packageId).sort()], + ); + expect(executed).toEqual(['RESOURCE_CONFLICT', 409, [OTHER_PKG, THIRD_PKG].sort()]); + for (const pkg of [OTHER_PKG, THIRD_PKG]) { + const exact = await host.plainWith('dashboard', 'pl_two_dash', { package: pkg }); + expect([exact.status, exact.body?.item?.label], JSON.stringify(exact.body)).toEqual([200, label(pkg)]); + } + const withheld = await host.plainWith('dashboard', 'pl_two_dash', { package: PKG }); + expect(withheld.status, JSON.stringify(withheld.body)).toBe(404); + }, 60_000); + + const ONE: ReadonlyArray = [ + [OTHER_PKG, PKG, null], [null, OTHER_PKG, PKG], [PKG, null, OTHER_PKG], + ]; + it.each(ORDERS.flatMap(([order, packages]) => ONE.map((saved) => [`${order}, saved ${saved.map(tagOf).join(' then ')}`, packages, saved] as const)))( + '%s: one enabled holder is served on every bare door, and none names the disabled package', + async (_label, packages, saved) => { + const host = await boot(packages, 'pl_one_dash', saved); + const read = await host.plain('dashboard', 'pl_one_dash'); + expect([read.status, read.body?.item?.label, read.body?.packageId], JSON.stringify(read.body)).toEqual([200, 'healthy row', OTHER_PKG]); + const layers = await host.layers('dashboard', 'pl_one_dash'); + expect([layers.status, layers.body?.effective?.label], JSON.stringify(layers.body)).toEqual([200, 'healthy row']); + const published = await host.published('dashboard', 'pl_one_dash'); + expect([published.status, published.body?.label], JSON.stringify(published.body)).toEqual([200, 'healthy row']); + noTrace([read, layers, published]); + const executed: any = await host.protocol.getMetaItemForExecution({ type: 'dashboard', name: 'pl_one_dash' }); + expect(executed?.item?.label).toBe('healthy row'); + const withheld = await host.plainWith('dashboard', 'pl_one_dash', { package: PKG }); + expect(withheld.status, JSON.stringify(withheld.body)).toBe(404); + }, 60_000); +}); + /** * [ruling record 6787890900] An object the caller may not read is answered on * every object door exactly as a name with nothing behind it — decided BEFORE diff --git a/packages/runtime/src/domains/meta-disabled-holder-served-stack.test.ts b/packages/runtime/src/domains/meta-disabled-holder-served-stack.test.ts index cbd40aa26b3..ae16d23c8b4 100644 --- a/packages/runtime/src/domains/meta-disabled-holder-served-stack.test.ts +++ b/packages/runtime/src/domains/meta-disabled-holder-served-stack.test.ts @@ -508,6 +508,122 @@ describe.each([ }, 240_000); }); +// --------------------------------------------------------------------------- +// [#34440, ADR-0150 D3] A package-less row beside the rows of a disabled +// holder and of enabled ones: every bare door gives the answer it gives when +// the disabled holder is absent (#33210). Two enabled holders are refused +// naming exactly them, never the disabled one, and the package-less row is +// never served in their place; one enabled holder is served. Every save +// order, both registration orders, before and after a reboot. +// +// Measured on `main` 7213177e (the card's re-measure): with E, F and D rows +// and a package-less row, the plain read and the execution read followed save +// order, `/published` served the package-less row and `/layers` refused 409 +// naming E, D and F; with E and D rows and a package-less row, the answer +// followed save order, and the order D, package-less, E answered 404 on every +// bare door. The CONTROL without a package-less row is the ruling-Q2 test +// above (409 naming E and F). +// --------------------------------------------------------------------------- + +describe.each([ + { regOrder: 'disabled first', registered: [ROW_D, ROW_E, ROW_F] }, + { regOrder: 'enabled first', registered: [ROW_E, ROW_F, ROW_D] }, +])('[#34440] a package-less row beside a disabled holder\'s row, packages registered $regOrder', ({ registered }) => { + const roots: string[] = []; + afterAll(() => { for (const dir of roots) rmSync(dir, { recursive: true, force: true }); }); + const freshFile = () => { + const dir = mkdtempSync(join(tmpdir(), 'os-meta-pl-disabled-db-')); + roots.push(dir); + return join(dir, 'meta.sqlite'); + }; + const down = async (booted: Booted) => { + if (booted.kernel.getState() === 'running') await booted.kernel.shutdown(); + roots.push(booted.root); + }; + const label = (id: string | null) => (id === null ? 'package-less row' : `${rowTag(id)} row`); + const noTrace = (answers: ReadonlyArray<{ body: unknown }>, door: string) => { + noDisabledTrace(answers); + for (const answer of answers) expect(JSON.stringify(answer.body ?? null), door).not.toContain('package-less row'); + }; + const expectExactAddresses = async (b: Booted, name: string, enabled: readonly string[]) => { + for (const id of enabled) { + const exact = await get(b.kernel, `/meta/dashboard/${name}`, { package: id }); + expect([exact.status, unwrap(exact.body)?.item?.label], JSON.stringify(exact.body)).toEqual([200, label(id)]); + } + const withheld = await get(b.kernel, `/meta/dashboard/${name}`, { package: ROW_D }); + expect([withheld.status, codeOf(withheld.body)], JSON.stringify(withheld.body)).toEqual([404, 'RESOURCE_NOT_FOUND']); + }; + const candidatesOf = (body: any) => [...(body?.error?.details?.candidates ?? [])].map((c: any) => c.packageId).sort(); + + const expectRefusedNamingEnabled = async (b: Booted, name: string) => { + const read = await get(b.kernel, `/meta/dashboard/${name}`); + expect([read.status, codeOf(read.body)], JSON.stringify(read.body)).toEqual([409, 'RESOURCE_CONFLICT']); + expect(candidatesOf(read.body), JSON.stringify(read.body)).toEqual([ROW_E, ROW_F].sort()); + const layers = await get(b.kernel, `/meta/dashboard/${name}/layers`); + expect([layers.status, codeOf(layers.body)], JSON.stringify(layers.body)).toEqual([409, 'RESOURCE_CONFLICT']); + expect(candidatesOf(layers.body), JSON.stringify(layers.body)).toEqual([ROW_E, ROW_F].sort()); + const published = await get(b.kernel, `/meta/dashboard/${name}/published`); + expect([published.status, codeOf(published.body)], JSON.stringify(published.body)).toEqual([409, 'RESOURCE_CONFLICT']); + for (const id of [ROW_E, ROW_F]) expect(JSON.stringify(published.body)).toContain(id); + noTrace([read, layers, published], name); + const protocol: any = b.kernel.getService('protocol'); + const executed = await protocol.getMetaItemForExecution({ type: 'dashboard', name }).then( + (answer: unknown) => ({ answer }), + (error: any) => ({ error: { code: error?.code, httpStatus: error?.httpStatus, candidates: [...(error?.refusal?.candidates ?? [])].map((c: any) => c.packageId).sort() } }), + ); + expect(executed).toEqual({ error: { code: 'RESOURCE_CONFLICT', httpStatus: 409, candidates: [ROW_E, ROW_F].sort() } }); + await expectExactAddresses(b, name, [ROW_E, ROW_F]); + }; + + const expectServedEnabled = async (b: Booted, name: string) => { + const read = await get(b.kernel, `/meta/dashboard/${name}`); + expect([read.status, unwrap(read.body)?.item?.label, unwrap(read.body)?.packageId], JSON.stringify(read.body)).toEqual([200, 'enabled row', ROW_E]); + const layers = await get(b.kernel, `/meta/dashboard/${name}/layers`); + expect([layers.status, unwrap(layers.body)?.effective?.label], JSON.stringify(layers.body)).toEqual([200, 'enabled row']); + const published = await get(b.kernel, `/meta/dashboard/${name}/published`); + expect([published.status, unwrap(published.body)?.label], JSON.stringify(published.body)).toEqual([200, 'enabled row']); + noDisabledTrace([read, layers, published]); + const executed = await (b.kernel.getService('protocol') as any).getMetaItemForExecution({ type: 'dashboard', name }); + expect(executed?.item?.label).toBe('enabled row'); + await expectExactAddresses(b, name, [ROW_E]); + }; + + const run = async (name: string, saved: ReadonlyArray, expectAnswer: (b: Booted, name: string) => Promise) => { + const file = freshFile(); + let booted = await bootRowKernel(registered, file); + try { + for (const id of saved) await layStoredRow(booted.engine, name, id, label(id)); + booted.engine.registry.disablePackage(ROW_D); + await expectAnswer(booted, name); + } finally { + await down(booted); + } + booted = await bootRowKernel(registered, file); + try { + booted.engine.registry.disablePackage(ROW_D); + await expectAnswer(booted, name); + } finally { + await down(booted); + } + }; + + it.each([ + { saveOrder: 'E, F, D, package-less', saved: [ROW_E, ROW_F, ROW_D, null] }, + { saveOrder: 'package-less, D, F, E', saved: [null, ROW_D, ROW_F, ROW_E] }, + { saveOrder: 'D, package-less, E, F', saved: [ROW_D, null, ROW_E, ROW_F] }, + ])('two enabled holders, saved $saveOrder: every bare door refuses naming exactly E and F, before and after a reboot', async ({ saved }) => { + await run('pl_two_dash', saved, expectRefusedNamingEnabled); + }, 240_000); + + it.each([ + { saveOrder: 'E, D, package-less', saved: [ROW_E, ROW_D, null] }, + { saveOrder: 'package-less, E, D', saved: [null, ROW_E, ROW_D] }, + { saveOrder: 'D, package-less, E', saved: [ROW_D, null, ROW_E] }, + ])('one enabled holder, saved $saveOrder: every bare door serves E\'s row and none names D, before and after a reboot', async ({ saved }) => { + await run('pl_one_dash', saved, expectServedEnabled); + }, 240_000); +}); + // --------------------------------------------------------------------------- // [#32607 contract review M1, M2, n1] The no-disabled arm judges a name's // holders at the rows' grain alone, never united with the registry's one bare From ef33907bdfb427aa9c6966d289e6822bd59e8514 Mon Sep 17 00:00:00 2001 From: Claude Date: Sun, 29 Nov 2026 16:42:38 +0000 Subject: [PATCH 4/9] chore(spec): the ADR-0087 ledger names the two same-name bare read moves, with their changeset Two semantic entries under step 19: doc-bare-read-environment-entry-first (#34452, #34190) and disabled-holder-package-less-row-bare-read-judged-as-absent (#34440). The changeset declares the narrowing and its FROM and TO. Claude-Session: https://claude.ai/code/session_01ADHkmQmQ1jpFsNcARMbY56 Co-authored-by: Claude --- .changeset/34452-same-name-bare-reads.md | 19 ++++++++ ...age-less-row-bare-read-judged-as-absent.ts | 42 +++++++++++++++++ ...9.doc-bare-read-environment-entry-first.ts | 45 +++++++++++++++++++ 3 files changed, 106 insertions(+) create mode 100644 .changeset/34452-same-name-bare-reads.md create mode 100644 packages/spec/src/migrations/entries/semantic/19.disabled-holder-package-less-row-bare-read-judged-as-absent.ts create mode 100644 packages/spec/src/migrations/entries/semantic/19.doc-bare-read-environment-entry-first.ts diff --git a/.changeset/34452-same-name-bare-reads.md b/.changeset/34452-same-name-bare-reads.md new file mode 100644 index 00000000000..f742f909b8b --- /dev/null +++ b/.changeset/34452-same-name-bare-reads.md @@ -0,0 +1,19 @@ +--- +'@objectstack/metadata-protocol': patch +'@objectstack/spec': patch +--- + +fix(metadata-protocol)!: the reads that name no package give one answer per name: the environment's doc entry first, and a disabled holder read as absent + +Clause-②: no (narrowing) +Metadata-protocol: none + + + +**BREAKING** for a caller that reads a shared name without naming a package, shipped as `patch`: no key an author writes changes (`Metadata-protocol: none`). Three reads that named no package answered by registration or save order, or disagreed with the registry's own read of the same name; each now gives one answer. Naming the package (`?package=ID`, or `packageId` in process) reads that package's item exactly as before. + +- **A doc the environment stores beside one enabled package's doc of the same name** (#34452, ruling 6942962369). FROM `GET /api/v1/meta/doc/NAME`, `/layers` and `/published` serving the package's doc while the registry and the metadata facade served the environment's own entry, TO every read that names no package serving the environment's entry, as it already did beside two or more holders. `?package=ID` still reads the package's doc. +- **The in-process layered read of a doc two or more enabled packages hold, with no environment entry** (#34190). FROM the layered read naming no package serving the layers of the package registered first, TO a `409 RESOURCE_CONFLICT` rejection naming each holder in `refusal.candidates`, as the item read and every HTTP door already answered. +- **A package-less row beside a disabled package's row and enabled packages' rows of a name no enabled package ships** (#34440). FROM the plain read and the execution read following save order, `/published` serving the package-less row, `/layers` refusing with the disabled package among the candidates, and one save order answering 404, TO the answer the reads give without the disabled holder: two or more enabled holders refused `409 RESOURCE_CONFLICT` naming exactly them in `details.candidates`, one enabled holder served, in every save order and after a restart. `?package=` of the disabled package still answers 404. + +The fix for a caller that relied on the old answer: name the package it means. `os migrate meta --from 18` lists both entries. diff --git a/packages/spec/src/migrations/entries/semantic/19.disabled-holder-package-less-row-bare-read-judged-as-absent.ts b/packages/spec/src/migrations/entries/semantic/19.disabled-holder-package-less-row-bare-read-judged-as-absent.ts new file mode 100644 index 00000000000..60719f4949a --- /dev/null +++ b/packages/spec/src/migrations/entries/semantic/19.disabled-holder-package-less-row-bare-read-judged-as-absent.ts @@ -0,0 +1,42 @@ +// Copyright (c) 2026 ObjectStack. Licensed under the Apache-2.0 license. + +import type { SemanticMigration } from '../../types.js'; + +// A narrowing (and, in one save order, a widening) of the bare item read, not +// of any key: ADR-0150 D3 (#34440) has the read that names no package judge a +// package-less row beside a disabled holder's row over the served holders, +// giving the answer it gives when the disabled holder is absent (#33210, +// entry two-row-holders-bare-read-refused): two or more enabled holders are +// refused naming exactly them, one is served. The answer followed save order +// there (the package-less row, one holder's row, or 404), and the layered +// read's refusal named the disabled package. No key is added, removed or +// re-shaped and no stored row changes shape, so no tombstone and no D2 +// conversion. No relevance question: the move turns on which installed +// packages are disabled, which no question over one stack can name. +export const entry: SemanticMigration = { + id: 'disabled-holder-package-less-row-bare-read-judged-as-absent', + surface: + 'The read of a metadata item that names no package (GET /api/v1/meta/TYPE/NAME, ' + + 'GET /api/v1/meta/TYPE/NAME/layers, GET /api/v1/meta/TYPE/NAME/published, and the execution read of the same ' + + 'name) of a type the registry reads by package, for a name no enabled package ships in code, held as stored ' + + 'rows by a disabled package and one or more enabled packages while a package-less row of the name is stored', + replacement: + 'Name the package: GET /api/v1/meta/TYPE/NAME?package=PACKAGE serves that enabled package\'s row. Beside two ' + + 'or more enabled holders the read that names no package answers 409 RESOURCE_CONFLICT (reason ' + + 'ambiguous-in-environment) naming exactly those holders in details.candidates, never the disabled package and ' + + 'never the package-less row; beside one it serves that holder\'s row, in every save order.', + reason: + 'A disabled package holds no name (ADR-0150 D3), so a name it shares with enabled packages must read as it reads ' + + 'without it. Beside a package-less row the judgment left the read as it was: the plain read and the execution ' + + 'read served whichever row was stored first, GET /api/v1/meta/TYPE/NAME/published served the package-less row, ' + + 'GET /api/v1/meta/TYPE/NAME/layers refused naming the disabled package too, and one enabled holder saved after ' + + 'the disabled one and the package-less row answered 404. The read now judges that row as it does with no ' + + 'disabled holder: a package-less row is no holder and no tie-break. There is no mechanical rewrite: which ' + + 'package\'s row a caller meant is a judgement about that caller.', + acceptanceCriteria: + 'For every such name while its disabled holder stays disabled: with two or more enabled holders every read ' + + 'that names no package answers 409 RESOURCE_CONFLICT naming exactly the enabled holders in ' + + 'details.candidates, and each ?package=PACKAGE read of an enabled holder answers its own row; with one enabled ' + + 'holder every read that names no package answers that holder\'s row; GET /api/v1/meta/TYPE/NAME?package=ID of ' + + 'the disabled package answers 404, in every save order and after a restart.', +}; diff --git a/packages/spec/src/migrations/entries/semantic/19.doc-bare-read-environment-entry-first.ts b/packages/spec/src/migrations/entries/semantic/19.doc-bare-read-environment-entry-first.ts new file mode 100644 index 00000000000..211a629dbf5 --- /dev/null +++ b/packages/spec/src/migrations/entries/semantic/19.doc-bare-read-environment-entry-first.ts @@ -0,0 +1,45 @@ +// Copyright (c) 2026 ObjectStack. Licensed under the Apache-2.0 license. + +import type { SemanticMigration } from '../../types.js'; + +// A change of answer of the doc reads that name no package, not of any key: +// ruling 6942962369 (#34452) has the environment's own package-less doc entry +// answer first whatever number of enabled packages hold the same name, and +// the reads agree with the registry's own read of the name. Beside ONE holder +// the doors served that holder's doc, while the registry and the facade read +// served the environment's entry; beside two or more they already served the +// entry. And with no such entry the in-process layered read of a doc two or +// more enabled packages hold (#34190) refuses as the plain read does, where it +// served the holder registered first. No key is added, removed or re-shaped +// and no stored row changes shape, so no tombstone and no D2 conversion. No +// relevance question: the move turns on which installed packages hold a name, +// which no question over one stack can name. +export const entry: SemanticMigration = { + id: 'doc-bare-read-environment-entry-first', + surface: + 'The read of a doc that names no package (GET /api/v1/meta/doc/NAME, GET /api/v1/meta/doc/NAME/layers, ' + + 'GET /api/v1/meta/doc/NAME/published, and the in-process item read and layered read with no packageId) for a ' + + 'name one enabled package holds while the environment stores its own package-less doc of the same name ' + + '(a doc registered with no package, or a package-less sys_metadata row); and the in-process layered read with ' + + 'no packageId of a doc two or more enabled packages hold with no such entry', + replacement: + 'To read the package\'s doc, name the package: GET /api/v1/meta/doc/NAME?package=PACKAGE (and the in-process ' + + 'reads with packageId) serve that package\'s own doc, beside the environment\'s entry or not. To read the ' + + 'environment\'s entry, name no package. An in-process layered read that names no package of a doc two or more ' + + 'enabled packages hold now rejects with 409 RESOURCE_CONFLICT naming each holder in refusal.candidates, as the ' + + 'item read and every HTTP door already did; name the package there too.', + reason: + 'The environment\'s own item answers first whatever number of packages hold the same name, and reads and writes ' + + 'give the same answer (ruling 6942962369). Beside one holder the doors that name no package served the ' + + 'holder\'s doc while the registry and the metadata facade served the environment\'s entry, so the same name ' + + 'answered two different docs depending on which reader asked; beside two or more holders the doors already ' + + 'served the entry. The in-process layered read swallowed the refusal the item read gives two holders and served ' + + 'the holder registered first, so its answer followed registration order. There is no mechanical rewrite: which ' + + 'doc a caller meant is a judgement about that caller.', + acceptanceCriteria: + 'For every doc name the environment stores a package-less entry of and one or more enabled packages hold: every ' + + 'read that names no package answers the environment\'s entry, and GET /api/v1/meta/doc/NAME?package=PACKAGE ' + + 'answers that package\'s doc. For every doc name two or more enabled packages hold with no such entry: every ' + + 'read that names no package, the in-process layered read included, answers 409 RESOURCE_CONFLICT naming each ' + + 'holder, and each read naming a holder answers its own doc.', +}; From e10d0b250f8d8bd0f7f7fb3e18a18b7e81f35590 Mon Sep 17 00:00:00 2001 From: Claude Date: Mon, 30 Nov 2026 00:20:24 +0000 Subject: [PATCH 5/9] chore(spec): the bare doc read entry names the holder the layered read served, the one registered last Contract review S1 and N1 on #38640: the entry's header and reason, and the changeset's #34190 FROM, said the in-process layered read served the holder registered FIRST; the card's measured reading, the layered read's comment and the [#34190] pin say LAST. The entry's surface now says a package-less row is the environment's entry once it is in the registry's bare slot (a row only the store holds is no exemption), as refuseAmbiguousBareDocRead reads it. Claude-Session: https://claude.ai/code/session_01ADHkmQmQ1jpFsNcARMbY56 Co-authored-by: Claude --- .changeset/34452-same-name-bare-reads.md | 2 +- .../semantic/19.doc-bare-read-environment-entry-first.ts | 9 +++++---- 2 files changed, 6 insertions(+), 5 deletions(-) diff --git a/.changeset/34452-same-name-bare-reads.md b/.changeset/34452-same-name-bare-reads.md index f742f909b8b..54b2d99eb73 100644 --- a/.changeset/34452-same-name-bare-reads.md +++ b/.changeset/34452-same-name-bare-reads.md @@ -13,7 +13,7 @@ Metadata-protocol: none **BREAKING** for a caller that reads a shared name without naming a package, shipped as `patch`: no key an author writes changes (`Metadata-protocol: none`). Three reads that named no package answered by registration or save order, or disagreed with the registry's own read of the same name; each now gives one answer. Naming the package (`?package=ID`, or `packageId` in process) reads that package's item exactly as before. - **A doc the environment stores beside one enabled package's doc of the same name** (#34452, ruling 6942962369). FROM `GET /api/v1/meta/doc/NAME`, `/layers` and `/published` serving the package's doc while the registry and the metadata facade served the environment's own entry, TO every read that names no package serving the environment's entry, as it already did beside two or more holders. `?package=ID` still reads the package's doc. -- **The in-process layered read of a doc two or more enabled packages hold, with no environment entry** (#34190). FROM the layered read naming no package serving the layers of the package registered first, TO a `409 RESOURCE_CONFLICT` rejection naming each holder in `refusal.candidates`, as the item read and every HTTP door already answered. +- **The in-process layered read of a doc two or more enabled packages hold, with no environment entry** (#34190). FROM the layered read naming no package serving the layers of the package registered last, TO a `409 RESOURCE_CONFLICT` rejection naming each holder in `refusal.candidates`, as the item read and every HTTP door already answered. - **A package-less row beside a disabled package's row and enabled packages' rows of a name no enabled package ships** (#34440). FROM the plain read and the execution read following save order, `/published` serving the package-less row, `/layers` refusing with the disabled package among the candidates, and one save order answering 404, TO the answer the reads give without the disabled holder: two or more enabled holders refused `409 RESOURCE_CONFLICT` naming exactly them in `details.candidates`, one enabled holder served, in every save order and after a restart. `?package=` of the disabled package still answers 404. The fix for a caller that relied on the old answer: name the package it means. `os migrate meta --from 18` lists both entries. diff --git a/packages/spec/src/migrations/entries/semantic/19.doc-bare-read-environment-entry-first.ts b/packages/spec/src/migrations/entries/semantic/19.doc-bare-read-environment-entry-first.ts index 211a629dbf5..a82aacff269 100644 --- a/packages/spec/src/migrations/entries/semantic/19.doc-bare-read-environment-entry-first.ts +++ b/packages/spec/src/migrations/entries/semantic/19.doc-bare-read-environment-entry-first.ts @@ -10,7 +10,7 @@ import type { SemanticMigration } from '../../types.js'; // served the environment's entry; beside two or more they already served the // entry. And with no such entry the in-process layered read of a doc two or // more enabled packages hold (#34190) refuses as the plain read does, where it -// served the holder registered first. No key is added, removed or re-shaped +// served the holder registered last. No key is added, removed or re-shaped // and no stored row changes shape, so no tombstone and no D2 conversion. No // relevance question: the move turns on which installed packages hold a name, // which no question over one stack can name. @@ -20,8 +20,9 @@ export const entry: SemanticMigration = { 'The read of a doc that names no package (GET /api/v1/meta/doc/NAME, GET /api/v1/meta/doc/NAME/layers, ' + 'GET /api/v1/meta/doc/NAME/published, and the in-process item read and layered read with no packageId) for a ' + 'name one enabled package holds while the environment stores its own package-less doc of the same name ' - + '(a doc registered with no package, or a package-less sys_metadata row); and the in-process layered read with ' - + 'no packageId of a doc two or more enabled packages hold with no such entry', + + '(a doc registered with no package, or a package-less sys_metadata row once it is hydrated or saved into ' + + 'the registry\'s bare slot; a row only the store holds is no such entry); and the in-process layered read ' + + 'with no packageId of a doc two or more enabled packages hold with no such entry', replacement: 'To read the package\'s doc, name the package: GET /api/v1/meta/doc/NAME?package=PACKAGE (and the in-process ' + 'reads with packageId) serve that package\'s own doc, beside the environment\'s entry or not. To read the ' @@ -34,7 +35,7 @@ export const entry: SemanticMigration = { + 'holder\'s doc while the registry and the metadata facade served the environment\'s entry, so the same name ' + 'answered two different docs depending on which reader asked; beside two or more holders the doors already ' + 'served the entry. The in-process layered read swallowed the refusal the item read gives two holders and served ' - + 'the holder registered first, so its answer followed registration order. There is no mechanical rewrite: which ' + + 'the holder registered last, so its answer followed registration order. There is no mechanical rewrite: which ' + 'doc a caller meant is a judgement about that caller.', acceptanceCriteria: 'For every doc name the environment stores a package-less entry of and one or more enabled packages hold: every ' From 65e2140d0328624a7cf242e8e7b9ae73b70fb78e Mon Sep 17 00:00:00 2001 From: Claude Date: Mon, 30 Nov 2026 00:20:24 +0000 Subject: [PATCH 6/9] fix(metadata-protocol): beside rows bound to one package a package-less row is left as it was beside a disabled holder too Contract review S2 on #38640 (#34440). With `if (rows.unbound) return undefined` removed, a package-less row beside rows bound to ONE enabled package, the disabled package holding the name only as code, reached the served-set judgment and was re-addressed to that package: every bare door moved from 404 to 200 serving the enabled package's row, outside the declared surface (rows bound to two or more packages, a disabled one among them) and unpinned. The guard its twin storedRowHoldersRefusal keeps (unbound, fewer than two bound packages) is restored, and a CONTROL pins the cell at its main answer with and without an environment item in the registry's bare slot. Claude-Session: https://claude.ai/code/session_01ADHkmQmQ1jpFsNcARMbY56 Co-authored-by: Claude --- .../src/protocol-meta-item-face.ts | 6 +++++ .../src/meta-disabled-package-doors.test.ts | 23 +++++++++++++++++++ 2 files changed, 29 insertions(+) diff --git a/packages/metadata-protocol/src/protocol-meta-item-face.ts b/packages/metadata-protocol/src/protocol-meta-item-face.ts index 6380a47b0d1..2003c48e00a 100644 --- a/packages/metadata-protocol/src/protocol-meta-item-face.ts +++ b/packages/metadata-protocol/src/protocol-meta-item-face.ts @@ -370,6 +370,12 @@ export async function servedRowHolderOf( // [#33210] The no-disabled arm judges a package-less row itself // ({@link storedRowHoldersRefusal}). if (!anyDisabled) return options.refuseWithoutDisabled === true ? storedRowHoldersRefusal(host, type, name, member, every, activeRows, rows.candidates) : undefined; + // [#34440 contract review S2] Beside rows bound to one package or none, a + // package-less row leaves the read as it was, as its twin + // {@link storedRowHoldersRefusal} leaves it (`holding.unbound` with fewer + // than two candidates): whether the bare slot holds an environment item + // then moves no answer. + if (rows.unbound && rows.candidates.length < 2) return undefined; // [#34440, ADR-0150 D3] Beside a disabled holder a package-less row is // judged over the served set as it is with no disabled holder (#33210): // two or more served holders are refused naming only them, one is served diff --git a/packages/rest/src/meta-disabled-package-doors.test.ts b/packages/rest/src/meta-disabled-package-doors.test.ts index 388c500f421..88c3dab2e63 100644 --- a/packages/rest/src/meta-disabled-package-doors.test.ts +++ b/packages/rest/src/meta-disabled-package-doors.test.ts @@ -1079,6 +1079,29 @@ describe('[#34440] RestServer: a package-less row beside a disabled holder\'s ro const withheld = await host.plainWith('dashboard', 'pl_one_dash', { package: PKG }); expect(withheld.status, JSON.stringify(withheld.body)).toBe(404); }, 60_000); + + // [#34440 contract review S2] CONTROL: beside rows bound to ONE package (an + // enabled package's row and a package-less row), with the disabled package + // holding the name only as code, the read is left as it was on `main`: + // every bare door answers 404, with or without an environment item in the + // registry's bare slot. The judgment above is the one beside rows bound to + // two or more packages. (With the guard removed these doors served the + // enabled package's row, a move outside the declared surface.) + it.each(ORDERS)('CONTROL %s: one bound package beside a disabled code holder is left as it was, whatever the bare slot holds', async (_order, packages) => { + for (const environmentItem of [false, true]) { + const host = setup(); + for (const pkg of packages) host.registry.installPackage({ id: pkg, name: pkg, version: '1.0.0' } as any, 'code'); + host.registry.registerItem('dashboard', { name: 'pl_s2_dash', label: 'disabled code', widgets: [] } as any, 'name', PKG); + for (const pkg of [OTHER_PKG, null]) await lay(host, 'pl_s2_dash', pkg); + if (environmentItem) host.registry.registerItem('dashboard', { name: 'pl_s2_dash', label: 'package-less row', widgets: [] } as any, 'name'); + host.registry.disablePackage(PKG); + const read = await host.plain('dashboard', 'pl_s2_dash'); + const layers = await host.layers('dashboard', 'pl_s2_dash'); + const published = await host.published('dashboard', 'pl_s2_dash'); + expect([environmentItem, read.status, layers.status, published.status], JSON.stringify([read.body, layers.body, published.body])) + .toEqual([environmentItem, 404, 404, 404]); + } + }, 60_000); }); /** From db578537d67cec35b5d32402c4563d8d6b4bc063 Mon Sep 17 00:00:00 2001 From: Claude Date: Mon, 30 Nov 2026 00:42:18 +0000 Subject: [PATCH 7/9] chore(spec): the bare doc read entry names its known envelope deviation, tracked in #38659 Contract review S3 on #38640: beside one holder the plain read naming no package now serves the environment's entry, but under the holder's envelope (`_packageId` that holder, `_provenance: package`): the read grafts the envelope from the artifact the name lookup answers. It did the same beside two or more holders before this change, and #34417's hydration fix does not reach it (measured). The entry's acceptance and the changeset name it as a known deviation with its carrier. Claude-Session: https://claude.ai/code/session_01ADHkmQmQ1jpFsNcARMbY56 Co-authored-by: Claude --- .changeset/34452-same-name-bare-reads.md | 2 +- .../semantic/19.doc-bare-read-environment-entry-first.ts | 4 +++- 2 files changed, 4 insertions(+), 2 deletions(-) diff --git a/.changeset/34452-same-name-bare-reads.md b/.changeset/34452-same-name-bare-reads.md index 54b2d99eb73..01685d89149 100644 --- a/.changeset/34452-same-name-bare-reads.md +++ b/.changeset/34452-same-name-bare-reads.md @@ -12,7 +12,7 @@ Metadata-protocol: none **BREAKING** for a caller that reads a shared name without naming a package, shipped as `patch`: no key an author writes changes (`Metadata-protocol: none`). Three reads that named no package answered by registration or save order, or disagreed with the registry's own read of the same name; each now gives one answer. Naming the package (`?package=ID`, or `packageId` in process) reads that package's item exactly as before. -- **A doc the environment stores beside one enabled package's doc of the same name** (#34452, ruling 6942962369). FROM `GET /api/v1/meta/doc/NAME`, `/layers` and `/published` serving the package's doc while the registry and the metadata facade served the environment's own entry, TO every read that names no package serving the environment's entry, as it already did beside two or more holders. `?package=ID` still reads the package's doc. +- **A doc the environment stores beside one enabled package's doc of the same name** (#34452, ruling 6942962369). FROM `GET /api/v1/meta/doc/NAME`, `/layers` and `/published` serving the package's doc while the registry and the metadata facade served the environment's own entry, TO every read that names no package serving the environment's entry, as it already did beside two or more holders. `?package=ID` still reads the package's doc. Known deviation, tracked in #38659: the plain read naming no package serves the entry under a holder's envelope (`_packageId` that holder, `_provenance: package`), as it already did beside two or more holders. - **The in-process layered read of a doc two or more enabled packages hold, with no environment entry** (#34190). FROM the layered read naming no package serving the layers of the package registered last, TO a `409 RESOURCE_CONFLICT` rejection naming each holder in `refusal.candidates`, as the item read and every HTTP door already answered. - **A package-less row beside a disabled package's row and enabled packages' rows of a name no enabled package ships** (#34440). FROM the plain read and the execution read following save order, `/published` serving the package-less row, `/layers` refusing with the disabled package among the candidates, and one save order answering 404, TO the answer the reads give without the disabled holder: two or more enabled holders refused `409 RESOURCE_CONFLICT` naming exactly them in `details.candidates`, one enabled holder served, in every save order and after a restart. `?package=` of the disabled package still answers 404. diff --git a/packages/spec/src/migrations/entries/semantic/19.doc-bare-read-environment-entry-first.ts b/packages/spec/src/migrations/entries/semantic/19.doc-bare-read-environment-entry-first.ts index a82aacff269..2e2a60a9bc3 100644 --- a/packages/spec/src/migrations/entries/semantic/19.doc-bare-read-environment-entry-first.ts +++ b/packages/spec/src/migrations/entries/semantic/19.doc-bare-read-environment-entry-first.ts @@ -42,5 +42,7 @@ export const entry: SemanticMigration = { + 'read that names no package answers the environment\'s entry, and GET /api/v1/meta/doc/NAME?package=PACKAGE ' + 'answers that package\'s doc. For every doc name two or more enabled packages hold with no such entry: every ' + 'read that names no package, the in-process layered read included, answers 409 RESOURCE_CONFLICT naming each ' - + 'holder, and each read naming a holder answers its own doc.', + + 'holder, and each read naming a holder answers its own doc. Known deviation, tracked in #38659: the plain read ' + + 'naming no package serves the environment\'s entry under a holder\'s envelope (`_packageId` that holder, ' + + '`_provenance` `package`), as it already did beside two or more holders; the content served is the entry\'s.', }; From 9a03d077f4d953d470db9eda05f676621ea9b911 Mon Sep 17 00:00:00 2001 From: Claude Date: Mon, 30 Nov 2026 01:41:56 +0000 Subject: [PATCH 8/9] chore(spec): the bare doc read entry's printed guidance names no tracker for its known deviation The CLI pin that every semantic entry's printed guidance carries no tracker number (migrate-meta-engine-guidance) read #38659 in the acceptance added by db578537. The acceptance now says a follow-up card carries the deviation; the entry's header comment names the card. Claude-Session: https://claude.ai/code/session_01ADHkmQmQ1jpFsNcARMbY56 Co-authored-by: Claude --- .../semantic/19.doc-bare-read-environment-entry-first.ts | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/packages/spec/src/migrations/entries/semantic/19.doc-bare-read-environment-entry-first.ts b/packages/spec/src/migrations/entries/semantic/19.doc-bare-read-environment-entry-first.ts index 2e2a60a9bc3..985a8f5b58b 100644 --- a/packages/spec/src/migrations/entries/semantic/19.doc-bare-read-environment-entry-first.ts +++ b/packages/spec/src/migrations/entries/semantic/19.doc-bare-read-environment-entry-first.ts @@ -13,7 +13,8 @@ import type { SemanticMigration } from '../../types.js'; // served the holder registered last. No key is added, removed or re-shaped // and no stored row changes shape, so no tombstone and no D2 conversion. No // relevance question: the move turns on which installed packages hold a name, -// which no question over one stack can name. +// which no question over one stack can name. The known envelope deviation the +// acceptance names is carried by #38659 (the printed guidance names no tracker). export const entry: SemanticMigration = { id: 'doc-bare-read-environment-entry-first', surface: @@ -42,7 +43,7 @@ export const entry: SemanticMigration = { + 'read that names no package answers the environment\'s entry, and GET /api/v1/meta/doc/NAME?package=PACKAGE ' + 'answers that package\'s doc. For every doc name two or more enabled packages hold with no such entry: every ' + 'read that names no package, the in-process layered read included, answers 409 RESOURCE_CONFLICT naming each ' - + 'holder, and each read naming a holder answers its own doc. Known deviation, tracked in #38659: the plain read ' + + 'holder, and each read naming a holder answers its own doc. Known deviation, carried by a follow-up card: the plain read ' + 'naming no package serves the environment\'s entry under a holder\'s envelope (`_packageId` that holder, ' + '`_provenance` `package`), as it already did beside two or more holders; the content served is the entry\'s.', }; From 2aa6a1c4bf7496b84d91d65b0b6ce679d8a90bc8 Mon Sep 17 00:00:00 2001 From: Claude Date: Mon, 30 Nov 2026 02:25:06 +0000 Subject: [PATCH 9/9] chore(spec): the disabled-holder entry names a holder that holds the name in code alone, and a pin holds that cell Contract review S4 on #38640: the entry's surface and the servedRowHolderOf jsdoc said the disabled package holds the name as a stored row, but the judgment asks whether any holder of the name is disabled, registry holders and rows together. So with two enabled packages' rows, a package-less row and a disabled package holding the name in code alone, every bare door now refuses 409 naming the two enabled packages; on main (measured, the face's judgment as on main) the plain read, /layers and /published answered 404. The surface, the reason, the jsdoc and the changeset's FROM now name that holder form, and a RestServer pin holds the cell in both registration orders and two save orders. N3: the changeset's deviation sentence names the lock too. Claude-Session: https://claude.ai/code/session_01ADHkmQmQ1jpFsNcARMbY56 Co-authored-by: Claude --- .changeset/34452-same-name-bare-reads.md | 4 +-- .../src/protocol-meta-item-face.ts | 10 +++++--- .../src/meta-disabled-package-doors.test.ts | 25 +++++++++++++++++++ ...age-less-row-bare-read-judged-as-absent.ts | 12 ++++++--- 4 files changed, 42 insertions(+), 9 deletions(-) diff --git a/.changeset/34452-same-name-bare-reads.md b/.changeset/34452-same-name-bare-reads.md index 01685d89149..89d5735f4cc 100644 --- a/.changeset/34452-same-name-bare-reads.md +++ b/.changeset/34452-same-name-bare-reads.md @@ -12,8 +12,8 @@ Metadata-protocol: none **BREAKING** for a caller that reads a shared name without naming a package, shipped as `patch`: no key an author writes changes (`Metadata-protocol: none`). Three reads that named no package answered by registration or save order, or disagreed with the registry's own read of the same name; each now gives one answer. Naming the package (`?package=ID`, or `packageId` in process) reads that package's item exactly as before. -- **A doc the environment stores beside one enabled package's doc of the same name** (#34452, ruling 6942962369). FROM `GET /api/v1/meta/doc/NAME`, `/layers` and `/published` serving the package's doc while the registry and the metadata facade served the environment's own entry, TO every read that names no package serving the environment's entry, as it already did beside two or more holders. `?package=ID` still reads the package's doc. Known deviation, tracked in #38659: the plain read naming no package serves the entry under a holder's envelope (`_packageId` that holder, `_provenance: package`), as it already did beside two or more holders. +- **A doc the environment stores beside one enabled package's doc of the same name** (#34452, ruling 6942962369). FROM `GET /api/v1/meta/doc/NAME`, `/layers` and `/published` serving the package's doc while the registry and the metadata facade served the environment's own entry, TO every read that names no package serving the environment's entry, as it already did beside two or more holders. `?package=ID` still reads the package's doc. Known deviation, tracked in #38659: the plain read naming no package serves the entry under a holder's envelope (`_packageId` that holder, `_provenance: package`, lock `full`), as it already did beside two or more holders. - **The in-process layered read of a doc two or more enabled packages hold, with no environment entry** (#34190). FROM the layered read naming no package serving the layers of the package registered last, TO a `409 RESOURCE_CONFLICT` rejection naming each holder in `refusal.candidates`, as the item read and every HTTP door already answered. -- **A package-less row beside a disabled package's row and enabled packages' rows of a name no enabled package ships** (#34440). FROM the plain read and the execution read following save order, `/published` serving the package-less row, `/layers` refusing with the disabled package among the candidates, and one save order answering 404, TO the answer the reads give without the disabled holder: two or more enabled holders refused `409 RESOURCE_CONFLICT` naming exactly them in `details.candidates`, one enabled holder served, in every save order and after a restart. `?package=` of the disabled package still answers 404. +- **A package-less row beside a disabled package's row and enabled packages' rows of a name no enabled package ships** (#34440). FROM the plain read and the execution read following save order, `/published` serving the package-less row, `/layers` refusing with the disabled package among the candidates, and one save order answering 404 (every bare door answered 404 when the disabled package held the name in code alone beside two or more enabled packages' rows), TO the answer the reads give without the disabled holder: two or more enabled holders refused `409 RESOURCE_CONFLICT` naming exactly them in `details.candidates`, one enabled holder served, in every save order and after a restart. `?package=` of the disabled package still answers 404. The fix for a caller that relied on the old answer: name the package it means. `os migrate meta --from 18` lists both entries. diff --git a/packages/metadata-protocol/src/protocol-meta-item-face.ts b/packages/metadata-protocol/src/protocol-meta-item-face.ts index 2003c48e00a..206d8ae1935 100644 --- a/packages/metadata-protocol/src/protocol-meta-item-face.ts +++ b/packages/metadata-protocol/src/protocol-meta-item-face.ts @@ -278,10 +278,12 @@ const SERVED_HOLDER_JUDGED_ELSEWHERE: ReadonlySet = new Set(['object', ' * two or more packages with no disabled package among them is judged with * those rows instead ({@link storedRowHoldersRefusal}), so it is refused * naming them; beside one holder or none the read is left as it was. - * [#34440] Beside rows bound to two or more packages a disabled one among - * them, it is judged below with those rows on every door, as the item face - * judges it with no disabled holder: a package-less row is no holder and no - * tie-break. Beside one bound package or none the read is left as it was. + * [#34440] Beside rows bound to two or more packages, with a disabled holder + * of the name (its own stored row among them, or the name in its code alone: + * contract review S4), it is judged below with those rows on every door, as + * the item face judges it with no disabled holder: a package-less row is no + * holder and no tie-break. Beside one bound package or none the read is left + * as it was. * Then the holders are the registry's served holders and the * packages the active rows are bound to, less every disabled package: * diff --git a/packages/rest/src/meta-disabled-package-doors.test.ts b/packages/rest/src/meta-disabled-package-doors.test.ts index 88c3dab2e63..a7bbe4c5c4e 100644 --- a/packages/rest/src/meta-disabled-package-doors.test.ts +++ b/packages/rest/src/meta-disabled-package-doors.test.ts @@ -1080,6 +1080,31 @@ describe('[#34440] RestServer: a package-less row beside a disabled holder\'s ro expect(withheld.status, JSON.stringify(withheld.body)).toBe(404); }, 60_000); + // [#34440 contract review S4] The disabled package may hold the name in + // code alone: beside two enabled packages' rows and a package-less row the + // judgment runs as it does beside its stored row, and every bare door + // refuses naming exactly the two enabled packages, whichever saves first. + it.each(ORDERS.flatMap(([order, packages]) => [[OTHER_PKG, THIRD_PKG, null], [null, THIRD_PKG, OTHER_PKG]].map((saved) => [`${order}, saved ${saved.map(tagOf).join(' then ')}`, packages, saved] as const)))( + '%s: two enabled holders beside a disabled code holder are refused on every bare door naming exactly them', + async (_label, packages, saved) => { + const host = setup(); + for (const pkg of packages) host.registry.installPackage({ id: pkg, name: pkg, version: '1.0.0' } as any, 'code'); + host.registry.registerItem('dashboard', { name: 'pl_s4_dash', label: 'disabled code', widgets: [] } as any, 'name', PKG); + for (const pkg of saved) await lay(host, 'pl_s4_dash', pkg); + host.registry.disablePackage(PKG); + const read = await host.plain('dashboard', 'pl_s4_dash'); + const layers = await host.layers('dashboard', 'pl_s4_dash'); + const published = await host.published('dashboard', 'pl_s4_dash'); + for (const [door, answer] of [['plain', read], ['layers', layers], ['published', published]] as const) { + expect([door, answer.status, answer.body?.code ?? answer.body?.error?.code], JSON.stringify(answer.body)) + .toEqual([door, 409, 'RESOURCE_CONFLICT']); + for (const pkg of [OTHER_PKG, THIRD_PKG]) expect(JSON.stringify(answer.body)).toContain(pkg); + } + expect(candidatesOf(read.body), JSON.stringify(read.body)).toEqual([OTHER_PKG, THIRD_PKG].sort()); + expect(candidatesOf(layers.body), JSON.stringify(layers.body)).toEqual([OTHER_PKG, THIRD_PKG].sort()); + noTrace([read, layers, published]); + }, 60_000); + // [#34440 contract review S2] CONTROL: beside rows bound to ONE package (an // enabled package's row and a package-less row), with the disabled package // holding the name only as code, the read is left as it was on `main`: diff --git a/packages/spec/src/migrations/entries/semantic/19.disabled-holder-package-less-row-bare-read-judged-as-absent.ts b/packages/spec/src/migrations/entries/semantic/19.disabled-holder-package-less-row-bare-read-judged-as-absent.ts index 60719f4949a..f7074c9a3bc 100644 --- a/packages/spec/src/migrations/entries/semantic/19.disabled-holder-package-less-row-bare-read-judged-as-absent.ts +++ b/packages/spec/src/migrations/entries/semantic/19.disabled-holder-package-less-row-bare-read-judged-as-absent.ts @@ -9,7 +9,10 @@ import type { SemanticMigration } from '../../types.js'; // entry two-row-holders-bare-read-refused): two or more enabled holders are // refused naming exactly them, one is served. The answer followed save order // there (the package-less row, one holder's row, or 404), and the layered -// read's refusal named the disabled package. No key is added, removed or +// read's refusal named the disabled package. The disabled holder may hold the +// name as a stored row, or in code alone beside two or more enabled packages' +// rows, where every bare door answered 404 (contract review S4 on #38640, +// measured). No key is added, removed or // re-shaped and no stored row changes shape, so no tombstone and no D2 // conversion. No relevance question: the move turns on which installed // packages are disabled, which no question over one stack can name. @@ -19,7 +22,9 @@ export const entry: SemanticMigration = { 'The read of a metadata item that names no package (GET /api/v1/meta/TYPE/NAME, ' + 'GET /api/v1/meta/TYPE/NAME/layers, GET /api/v1/meta/TYPE/NAME/published, and the execution read of the same ' + 'name) of a type the registry reads by package, for a name no enabled package ships in code, held as stored ' - + 'rows by a disabled package and one or more enabled packages while a package-less row of the name is stored', + + 'rows by one or more enabled packages and held by a disabled package while a package-less row of the name is ' + + 'stored: the disabled package holding it as a stored row, or in code alone beside the stored rows of two or ' + + 'more enabled packages', replacement: 'Name the package: GET /api/v1/meta/TYPE/NAME?package=PACKAGE serves that enabled package\'s row. Beside two ' + 'or more enabled holders the read that names no package answers 409 RESOURCE_CONFLICT (reason ' @@ -30,7 +35,8 @@ export const entry: SemanticMigration = { + 'without it. Beside a package-less row the judgment left the read as it was: the plain read and the execution ' + 'read served whichever row was stored first, GET /api/v1/meta/TYPE/NAME/published served the package-less row, ' + 'GET /api/v1/meta/TYPE/NAME/layers refused naming the disabled package too, and one enabled holder saved after ' - + 'the disabled one and the package-less row answered 404. The read now judges that row as it does with no ' + + 'the disabled one and the package-less row answered 404; with the disabled package holding the name in code ' + + 'alone beside two or more enabled packages\' rows, every read that names no package answered 404. The read now judges that row as it does with no ' + 'disabled holder: a package-less row is no holder and no tie-break. There is no mechanical rewrite: which ' + 'package\'s row a caller meant is a judgement about that caller.', acceptanceCriteria: