Skip to content

Commit 538121f

Browse files
committed
fix(metadata-protocol): an exact address naming no member replaces another package's item only with the holder's canonical member; ledger names every moved arrangement; pending #34441 note corrected
Co-authored-by: Claude <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_012MmDsS4GoHCgYwA2uv3n3C
1 parent 90b5cde commit 538121f

8 files changed

Lines changed: 103 additions & 31 deletions

‎.changeset/34441-shipped-base-canonical-member-one-answer.md‎

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ Skills-docs: none — `skills/objectstack-platform/SKILL.md` (the ADR-0146 parag
1515

1616
**Every moved answer, before → after.** On the runtime dispatcher, in both registration orders, before and after a restart.
1717

18-
- **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.
18+
- **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 only TO `404` on both sides of a restart: naming no member addresses the canonical member `en-US`, which A does not ship, so it answers as `/layers?member=en-US` does (a later change in the same release corrected the interim answer, A's `fr-FR`); 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.
1919
- **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.
2020

21-
**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.
21+
**Not moved.** `?member=CANONICAL` of the first shape (404 at `en-US`). The plain read and the execution read naming no member of the first shape, which served A's `fr-FR`, answer 404 in this release too, as `?member=en-US` does (registered as `bundle-without-canonical-member-bare-read-absent`). 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.

‎.changeset/34682-bundle-member-selector.md‎

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -11,16 +11,21 @@ Skills-docs: none — no page under `skills/**` or `content/docs/**` teaches the
1111

1212
<!-- adr-0087: registered bundle-without-canonical-member-bare-read-absent -->
1313

14-
**BREAKING**: for a bundled name with no canonical member, the read naming no member (`GET /meta/TYPE/NAME`, with or without `?package=`), `/layers` naming none and the execution read naming none move from serving another member (200) to `404 RESOURCE_NOT_FOUND` (the execution read: `null`). Name the member (`?member=fr-FR`) to read it, as before.
14+
**BREAKING**: where the address holds no canonical member of a bundled name, the read naming no member (`GET /meta/TYPE/NAME`, with or without `?package=`), `/layers` naming none and the execution read naming none move from serving another member (200) to `404 RESOURCE_NOT_FOUND` (the execution read: `null`). Name the member (`?member=fr-FR`) to read it, as before.
1515

1616
The by-name doors' member selector reads a request naming no member as the canonical one (`en-US` for `email_template`), and naming the canonical value is the same request. That is the selector's declared contract (`GetMetaItemRequest.member`). For a bundle with no canonical member, the two requests got different answers:
1717

1818
- The plain read `GET /api/v1/meta/email_template/NAME` and `/layers` served the bundle's other member (for example `fr-FR`, status 200). The execution read (`getMetaItemForExecution`) returned that member too.
1919
- `?member=en-US` and `/published` answered 404.
2020

21+
The same split held in two more arrangements:
22+
23+
- A base ships only `fr-FR` and a dependent that declares it stores `en-US`. The read naming no package and no member served the base's `fr-FR`.
24+
- `?package=X` where X ships no `en-US` while another package does (a dependent, or a disabled holder that the read naming no package re-addresses past to X). The read naming no member served X's `fr-FR`. `?package=X&member=en-US` answered nothing.
25+
2126
For a bundle that only stores a non-canonical row (a package-less `fr-FR` row with no `en-US` row), the plain read also changed across a restart. It answered 404 before the restart. After the restart it served the row (200), because the restart had moved the row into the registry's bare slot.
2227

23-
The plain read, `/layers` and the execution read now ask every layer for the canonical member when no member is named. They take the registry's bare-name answer only when it is that member. So each of these bundles answers 404 on every door naming no member, the same as `?member=en-US` and `/published`, before and after a restart.
28+
The plain read, `/layers` and the execution read now ask every layer for the canonical member when no member is named. They take the registry's bare-name answer only when it is that member. The base-address fallback serves only the base's canonical member, and an exact address (`?package=`) replaces another package's item only with the holder's item at the addressed member. So each of these arrangements answers 404 on every door naming no member, the same as `?member=en-US` and `/published`, before and after a restart.
2429

2530
A bundle that ships or stores its canonical member is served exactly as before. So is any named member, and so is every type with no members. A non-canonical member is still read with its own selector, for example `?member=fr-FR`, which the Studio list already links to for each member.
2631

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

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -58,6 +58,7 @@ import {
5858
import { ENVIRONMENT_ADDRESS_SEGMENT, readNamespacePositionSegment } from '@objectstack/spec/kernel';
5959
import { installedManifestsOfEngine } from './installed-manifests.js';
6060
import { canonicalizeMetaRequestType } from './protocol-meta-type-schema.js';
61+
import { bundleMemberDiscriminator } from './protocol-bundle-members.js';
6162
import type { ProtocolHost } from './protocol-host.js';
6263
import type { ServedOverrideRow } from './served-override.js';
6364

@@ -491,7 +492,15 @@ export function exactQualifierItem(
491492
address.registryHolders.map((holder) => ({ kind: 'package' as const, packageId: holder })));
492493
}
493494
const [holder] = address.registryHolders;
494-
return holder === undefined ? undefined : registry.getPackageScopedItem(request.type, request.name, holder, member);
495+
// [#34682] The admitted holder's item AT the addressed member: the named
496+
// one, else the canonical one (the selector's contract: naming no member
497+
// is naming the canonical value). Asked with the raw selector, a read
498+
// naming no member got the holder's FIRST member when it ships no
499+
// canonical one, while `?member=<canonical>` answered nothing. `undefined`
500+
// for a type with no members, which reads as before.
501+
return holder === undefined
502+
? undefined
503+
: registry.getPackageScopedItem(request.type, request.name, holder, bundleMemberDiscriminator(request.type, member));
495504
}
496505

497506
/**

‎packages/metadata-protocol/src/protocol-meta-layered-reads.ts‎

Lines changed: 2 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -449,13 +449,8 @@ export async function getMetaItemLayered(host: Pick<ProtocolHost, 'artifactLockL
449449
// now refused naming the holders (ruling 6917064203 on #34398).
450450
if (exactAddress === undefined) regItem = namedMemberOnly(runtimeOnly(registryAnswerAtAddress(host, request, regItem, member, isWantedMember, { refuse: true })));
451451
if (regItem !== undefined) code = regItem;
452-
// [#34682] No member-less artifact lookup follows: naming no member,
453-
// the code layer is the canonical member's artifact, asked above, or
454-
// none. FROM (`main` d947a93cf8): a bundle whose base ships no
455-
// canonical member took the member it ships as its code layer here
456-
// (#34441 cell 1), so `/layers` served A's `fr-FR` where
457-
// `/layers?member=en-US` answered 404. For a type with no members that
458-
// lookup repeated the artifact lookup above with the same arguments.
452+
// [#34682] Naming no member, the code layer is the canonical member's
453+
// artifact (asked above) or none: no lookup by name alone follows.
459454
}
460455

461456
// [#5840] The code half of the rule #5707 wrote for the overlay half,

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

Lines changed: 57 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -233,15 +233,22 @@ describe('[#31699] a bundled type (email_template): the exact qualifier reads a
233233
registry.installPackage({ ...(manifest(D) as object), dependencies: { [A]: '^1.0.0' } } as never, 'code');
234234
});
235235

236-
it('a dependent\'s added member (a locale its base does not ship): naming the dependent is admitted, with or without a member', async () => {
236+
it('a dependent\'s added member (a locale its base does not ship): naming the dependent is admitted at that member; naming no member is naming en-US, which the dependent does not hold', async () => {
237237
tpl('en-US', A);
238238
tpl('fr-FR', D);
239239
// R2: the addition holds no name for a bare read, so a caller with no package reads alpha's.
240240
expect(registry.packageScopedHoldersOf('email_template', 'welcome')).toEqual([A]);
241241
expect(labelOf(await read(D, 'fr-FR'))).toBe('alphaaddon fr-FR');
242-
// The read that names no member (the layered door's disabled-package probe
243-
// asks it) is the dependent's own holding, never `not-held-by-qualifier`.
244-
expect(labelOf(await read(D))).toBe('alphaaddon fr-FR');
242+
// [#34682] The read that names no member addresses the canonical member
243+
// (the member selector's declared sentence: naming the canonical value is
244+
// the same request), so at the dependent's address it answers as
245+
// `?member=en-US` does: absent, and never `not-held-by-qualifier`. FROM
246+
// (`main` d947a93cf8): it served the dependent's `fr-FR` (the holder's
247+
// first member, asked with no member).
248+
const bare = await read(D);
249+
const named = await read(D, 'en-US');
250+
const itemOf = (answer: unknown) => (answer as { item?: unknown } | undefined)?.item;
251+
expect([itemOf(bare), itemOf(named)]).toEqual([undefined, undefined]);
245252
});
246253

247254
it.each(['app', 'page', 'dashboard', 'report', 'book', 'analytics_cube', 'tool', 'skill', 'agent'])(
@@ -299,6 +306,52 @@ describe('[#31699] a bundled type (email_template): the exact qualifier reads a
299306
* registered; the `?package=` read for a name alpha and beta hold, naming gamma,
300307
* served alpha's.
301308
*/
309+
// [#34682] Naming no member is naming the canonical member (the member
310+
// selector's declared sentence in `packages/spec/src/api/protocol.zod.ts`:
311+
// "naming the canonical value is the same request"). A base that ships its
312+
// bundle in `fr-FR` only, beside another package that ships `en-US`, answers
313+
// the read naming no member at its address exactly as it answers `?member=en-US`:
314+
// absent, on the plain read and the layered read, at `?package=BASE` and
315+
// through the face's re-address to the served holder (`servedHolderAddressOf`,
316+
// beside a disabled holder). FROM (`main` d947a93cf8): the exact qualifier
317+
// swapped the other package's `en-US` for the base's item asked with no
318+
// member, so both reads served the base's `fr-FR` (200) where `?member=en-US`
319+
// answered nothing.
320+
describe('[#34682] a base shipping no canonical member: at its address, naming no member is naming en-US', () => {
321+
const D = 'com.acme.alphaaddon';
322+
const tpl = (locale: string, packageId: string) => registry.registerItem('email_template', {
323+
name: 'welcome', label: `${packageId.split('.').pop()} ${locale}`, locale,
324+
subject: `${packageId.split('.').pop()} ${locale}`, bodyHtml: '<p>x</p>',
325+
}, 'name' as never, packageId);
326+
const itemOf = (answer: unknown) => (answer as { item?: { label?: string } } | undefined)?.item?.label ?? null;
327+
const effectiveOf = (answer: unknown) => (answer as { effective?: { label?: string } | null } | undefined)?.effective?.label ?? null;
328+
/** The plain read and the layered read at one address and member, as labels (`null`: nothing served). */
329+
const both = async (packageId: string | undefined, member?: string) => {
330+
const request = { type: 'email_template', name: 'welcome', ...(packageId ? { packageId } : {}), ...(member ? { member } : {}) };
331+
return [itemOf(await protocol.getMetaItem(request as never)), effectiveOf(await protocol.getMetaItemLayered(request as never))];
332+
};
333+
334+
it.each([
335+
{ holder: 'a dependent ships en-US', other: D },
336+
{ holder: 'a disabled package ships en-US', other: B },
337+
])('$holder: ?package=BASE naming no member answers as naming en-US (absent); the base\'s fr-FR named is the base\'s', async ({ other }) => {
338+
if (other === D) registry.installPackage({ ...(manifest(D) as object), dependencies: { [A]: '^1.0.0' } } as never, 'code');
339+
tpl('fr-FR', A);
340+
tpl('en-US', other);
341+
if (other === B) registry.disablePackage(B);
342+
expect({ bare: await both(A), named: await both(A, 'en-US') }).toEqual({ bare: [null, null], named: [null, null] });
343+
expect(await both(A, 'fr-FR')).toEqual(['alpha fr-FR', 'alpha fr-FR']);
344+
});
345+
346+
it('through the re-address to the served holder (a disabled holder ships en-US): naming no package and no member answers as naming en-US', async () => {
347+
tpl('fr-FR', A);
348+
tpl('en-US', B);
349+
registry.disablePackage(B);
350+
expect({ bare: await both(undefined), named: await both(undefined, 'en-US') }).toEqual({ bare: [null, null], named: [null, null] });
351+
expect(await both(undefined, 'fr-FR')).toEqual(['alpha fr-FR', 'alpha fr-FR']);
352+
});
353+
});
354+
302355
describe('fail closed — a registry with no package-scoped resolver refuses what it cannot judge', () => {
303356
const SLICE = new Set([
304357
'readsByPackage', 'packageScopedHoldersOf', 'getEnvironmentScopedItem', 'getPackageScopedItem', 'resolveItem',

‎packages/runtime/src/domains/meta-bundle-member-one-request.test.ts‎

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -147,6 +147,10 @@ describe('[#34682] naming no member and naming the canonical member are one requ
147147
expect({ leg, name, read: bare.read, effective: (bare.layers[1] as unknown[] | undefined)?.[0], executed: bare.executed })
148148
.toEqual({ leg, name, read: [200, served], effective: served, executed: served });
149149
}
150+
// The preserved half: the `fr-FR` member, named, is served as before.
151+
const fr = await doors(b, 'email_template', name, 'fr-FR');
152+
const frSubject = name.startsWith('ship_') ? 'ship fr' : 'row fr';
153+
expect([leg, name, fr.read]).toEqual([leg, name, [200, { name, locale: 'fr-FR', subject: frSubject, label: frSubject }]]);
150154
// …and at the shipping package's own address (`?package=`), for a shipped bundle.
151155
if (name.startsWith('ship_')) {
152156
const atBase = await doors(b, 'email_template', name, undefined, A);

0 commit comments

Comments
 (0)