Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
17 commits
Select commit Hold shift + click to select a range
0571f19
fix(metadata-protocol, rest): every /layers refusal of a name several…
claude Nov 15, 2026
ee6fa50
fix(metadata-protocol): the layered read naming no package refuses a …
claude Nov 15, 2026
d0a5dbd
chore(changeset): the layered read of a name two packages hold refuse…
claude Nov 15, 2026
6e50dbd
test(runtime): pay the metadata service's first load at collection in…
claude Nov 15, 2026
02d6109
Merge remote-tracking branch 'origin/main' into claude/area-E1-32622
claude Nov 15, 2026
75f99bb
Merge remote-tracking branch 'origin/main' into claude/area-E1-32622
claude Nov 15, 2026
fa7fb66
changeset: declare the two-holder layered read refusal as a narrowing
claude Nov 15, 2026
e516f35
docs(metadata-protocol): the layered read refusal docblock names its …
claude Nov 15, 2026
113f192
fix(metadata-protocol): the bare layered read serves a member's decla…
claude Nov 15, 2026
880bcc4
chore(changeset): the bare layered read serves a member's declared ov…
claude Nov 15, 2026
a7eed83
Merge remote-tracking branch 'origin/main' into claude/area-E1-32849-…
claude Nov 15, 2026
e57e7c0
changeset: declare the REST /published move; docblock @throws for the…
claude Nov 15, 2026
96a0a52
test(objectql): pin the bare layered read's effective to the document…
claude Nov 15, 2026
6cb93cc
Merge remote-tracking branch 'origin/claude/area-E1-32622' into claud…
claude Nov 15, 2026
24ecb57
Merge remote-tracking branch 'origin/main' into claude/area-E1-32849-…
claude Nov 15, 2026
f23319f
Merge remote-tracking branch 'origin/main' into claude/area-E1-32849-…
claude Nov 15, 2026
c9112d2
Merge remote-tracking branch 'origin/main' into claude/area-E1-32849-…
claude Nov 16, 2026
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 12 additions & 0 deletions .changeset/32849-bare-layered-read-declared-override.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
---
'@objectstack/metadata-protocol': patch
---

fix(metadata-protocol): the layered read naming no package serves an App pair's declared override of a bundle addition's own member as `effective`

Clause-②: no
Metadata-protocol: none

An App's customization pair (`<app>.custom`) can store a row that declares `overrides: { package: Z }` for the bundle member a bundle addition Z ships, for example the `fr-FR` locale Z adds to an email template another package of the App ships in `en-US`. The plain read naming no package (`?member=fr-FR`) and `?package=Z&member=fr-FR&layers=true` already served that row. The layered read naming no package (`?member=fr-FR&layers=true`, `getMetaItemLayered` without a package) answered Z's shipped `fr-FR` as `effective`, with no `overlay`, and so disagreed with the read it describes.

It now reads such a member at the one enabled package that ships it, as the plain read does: `code` is Z's shipped member, `overlay` the pair's row, `effective` the override, and the envelope names Z. The pending draft layer stays the one the strict draft read serves. Nothing else moves: a member two packages ship, a row declaring another package, an undeclared pair row, the environment's own item and a disabled shipper answer as before. No stored row changes shape.
5 changes: 3 additions & 2 deletions packages/metadata-protocol/src/protocol-meta-item-face.ts
Original file line number Diff line number Diff line change
Expand Up @@ -422,9 +422,10 @@ export function isAnotherHoldersCopy(registry: any, type: string, name: string,
* another package (the #32606 shape), an undeclared pair row, the
* environment's own item, a disabled shipper, and the strict draft read.
* The rows are read through `host.readItemActiveRows`, so the read below takes
* them instead of reading them again (#24371).
* them instead of reading them again (#24371). The layered read naming no
* package takes the same address for its layers (`getMetaItemLayered`).
*/
async function declaredMemberOverrideAddressOf(
export async function declaredMemberOverrideAddressOf(
host: ServedRowHost,
type: string, name: string, member: string | undefined,
): Promise<string | undefined> {
Expand Down
24 changes: 19 additions & 5 deletions packages/metadata-protocol/src/protocol-meta-layered-reads.ts
Original file line number Diff line number Diff line change
Expand Up @@ -78,7 +78,7 @@ import { boundPackageOf, withRowBinding } from './protocol-package-bindings.js';
import type { RowlessExpandedView } from './protocol-stored-overlay-types.js';
import { type ServedOverrideRow, isServedOverrideRowOf } from './served-override.js';
import { installedManifestsOfEngine } from './installed-manifests.js';
import { isAnotherHoldersCopy, servedAddressJudgment } from './protocol-meta-item-face.js';
import { declaredMemberOverrideAddressOf, isAnotherHoldersCopy, servedAddressJudgment } from './protocol-meta-item-face.js';
import { packagelessAddressAmbiguityRefusal } from './sys-metadata-repository.js';

/** The body of `ObjectStackProtocolImplementation#packagelessLayeredReadRefusal`; the method's docblock there is its contract. */
Expand Down Expand Up @@ -216,6 +216,18 @@ export async function getMetaItemLayered(host: Pick<ProtocolHost, 'artifactLockL
: await servedAddressJudgment(host, request.type, request.name, resolveBundleMemberSelector(request.type, request.member));
const servedAddress = judged?.kind === 'served' ? judged.packageId : undefined;
if (servedAddress !== undefined) request = { ...request, packageId: servedAddress };
// [#32849, ADR-0150 D4, ADR-0146 D8 item 2] …and, judged neither way, a
// member whose one shipper's declared override is stored is read at that
// shipper, as the plain read takes it ({@link declaredMemberOverrideAddressOf}):
// `effective` is then the override `?package=<shipper>` serves, never the
// shipper's own member beside it. The draft layer stays at the address the
// strict draft read takes, which this arm does not move (the plain read
// leaves its strict draft read where it was).
const declaredOverrideAt = request.packageId || judged !== undefined
? undefined
: await declaredMemberOverrideAddressOf(host, request.type, request.name, resolveBundleMemberSelector(request.type, request.member));
const draftPackageId = request.packageId;
if (declaredOverrideAt !== undefined) request = { ...request, packageId: declaredOverrideAt };
// [#26699] Ruling 6116165299 (Q2 i), extended to this read by the
// option-A ruling on #26649: ONE member of a bundled type, the
// selector's or else the canonical one, read exactly as
Expand Down Expand Up @@ -647,16 +659,16 @@ export async function getMetaItemLayered(host: Pick<ProtocolHost, 'artifactLockL
let draft: unknown | null | undefined;
if (opts.withDraft === true) {
draft = null;
const draftAddress = request.packageId
const draftAddress = draftPackageId
? undefined
: await host.strictDraftReadAddress(request.type, request.name, member);
try {
let draftRow = (await host.findServedOverlayRow({
type: request.type,
name: request.name,
state: 'draft',
...(request.packageId
? { packageId: request.packageId }
...(draftPackageId
? { packageId: draftPackageId }
: draftAddress ? { packageId: draftAddress.packageId } : {}),
...memberOption(member),
}))?.row;
Expand All @@ -680,7 +692,9 @@ export async function getMetaItemLayered(host: Pick<ProtocolHost, 'artifactLockL
// package-less draft of a name two or more packages hold is
// refused naming every holder, and another holder's draft is
// no draft here. The layer itself stays the draft as stored.
if (exactAddress) {
// [#32849] A draft read at the address the strict draft read
// takes is no exact address's.
if (exactAddress && draftPackageId) {
const stamped = withRowBinding(draft, (draftRow as { package_id?: unknown }).package_id);
if ((isPackageLessRow(draftRow) && declinesPackageLessRowAt(host, request.type, request.name, draftRow as ServedOverrideRow))
|| exactQualifierItem(host, request, exactAddress, stamped, member) !== stamped) {
Expand Down
91 changes: 91 additions & 0 deletions packages/objectql/src/package-scoped-exact-qualifier.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -1276,6 +1276,97 @@ describe('[#31699 F2] a pair member row two holders could own is refused on both
});
});

/**
* [#32849, ADR-0146 D8 item 2, ADR-0150 D4] The bare LAYERED read of an
* addition's own member whose declared override the App's pair stores. X
* ships `welcome` (`en-US`), the addition Z on X ships its `fr-FR`, and a row
* of the App's pair declares `overrides.package` Z for `fr-FR`. The plain read
* naming no package serves that override since the bare member read's fix
* (`declaredMemberOverrideAddressOf`); the layered read is "what `getMetaItem`
* would return" as `effective`, so it reads the member at Z too.
*
* BASE (measured on `claude/area-E1-32622` e516f353, this fixture, before the
* change): bare `getMetaItemLayered({ member: 'fr-FR' })` answered `code`
* and `effective` `zeta fr-FR` with `overlay` null in both install orders,
* while `?package=Z` answered `effective` `pair fr-FR` and the plain bare read
* `pair fr-FR`; the door's step 1c (`packagelessLayeredReadRefusal`) refused
* nothing.
*/
describe('[#32849] the bare layered read serves the pair\'s declared override of an addition Z\'s own locale as `effective`, as `?package=Z` does', () => {
const APP = 'com.acme.suite';
const X = 'com.acme.suitex';
const Z = 'com.acme.zeta';
const PAIR = `${APP}.custom`;
const moduleOf = (id: string, dependencies: Record<string, string>) => ({
id, name: id, version: '1.0.0', type: 'module', namespace: id.split('.').pop()!, dependencies,
}) as never;
const installZ = () => registry.installPackage(moduleOf(Z, { [APP]: '^1.0.0', [X]: '^1.0.0' }), 'code');
const tpl = (locale: string, packageId: string) => registry.registerItem('email_template', {
name: 'welcome', label: `${packageId.split('.').pop()} ${locale}`, locale,
subject: `${packageId.split('.').pop()} ${locale}`, bodyHtml: '<p>x</p>',
}, 'name' as never, packageId);
/** A row of the App's pair for `fr-FR`; an active one is hydrated as the boot lays it. */
const pairRow = (over: Record<string, unknown> = {}, state: 'active' | 'draft' = 'active') => {
const body = { name: 'welcome', label: state === 'draft' ? 'pair fr-FR draft' : 'pair fr-FR', locale: 'fr-FR', subject: 'pair fr-FR', bodyHtml: '<p>p</p>', ...over };
rows.push({ id: `row_fr_${state}`, type: 'email_template', name: 'welcome', state, package_id: PAIR, bundle_member: 'fr-FR', metadata: JSON.stringify(body) });
if (state === 'active') registry.registerItem('email_template', { ...body, _packageId: PAIR, _provenance: 'org' }, 'name' as never);
};
type Layers = { code?: { label?: string } | null; overlay?: { label?: string } | null; effective?: { label?: string; _packageId?: string } | null; draft?: { label?: string } | null; packageId?: string };
const layered = (member: string, packageId?: string, withDraft = false) => protocol.getMetaItemLayered({
type: 'email_template', name: 'welcome', member, ...(packageId ? { packageId } : {}),
} as never, { withDraft } as never) as Promise<Layers>;
const layersOf = (a: Layers) => [a.code?.label ?? null, a.overlay?.label ?? null, a.effective?.label ?? null, a.packageId];

beforeEach(() => {
registry.installPackage(manifest(APP), 'code');
registry.installPackage(moduleOf(X, { [APP]: '^1.0.0' }), 'code');
registry.installPackage(manifest(PAIR), 'code');
});

it.each([
['addition installed first', () => { installZ(); tpl('en-US', X); tpl('fr-FR', Z); pairRow({ overrides: { package: Z } }); }],
['row stored first', () => { tpl('en-US', X); pairRow({ overrides: { package: Z } }); installZ(); tpl('fr-FR', Z); }],
] as const)('the bare layered read of `fr-FR` answers Z\'s layers with the override as `effective` (%s; BASE: `effective` `zeta fr-FR`, no overlay)', async (_order, arrange) => {
arrange();
const atZ = await layered('fr-FR', Z);
expect(layersOf(atZ), 'CONTROL: `?package=Z&member=fr-FR&layers=true` (UNCHANGED)').toEqual(['zeta fr-FR', 'pair fr-FR', 'pair fr-FR', Z]);
expect(await protocol.packagelessLayeredReadRefusal({ type: 'email_template', name: 'welcome', member: 'fr-FR' } as never), 'the door\'s step 1c refuses nothing').toBeUndefined();
const bare = await layered('fr-FR');
expect(layersOf(bare), 'bare `?member=fr-FR&layers=true`').toEqual(['zeta fr-FR', 'pair fr-FR', 'pair fr-FR', Z]);
expect(bare.effective, '`effective` is the document `?package=Z` serves').toEqual(atZ.effective);
expect(labelOf(await protocol.getMetaItem({ type: 'email_template', name: 'welcome', member: 'fr-FR' } as never)), '`effective` is what the plain bare read serves').toBe('pair fr-FR');
// CONTROL: X's own member is untouched by the override of Z's.
expect(layersOf(await layered('en-US')), 'bare `?member=en-US` (UNCHANGED)').toEqual(['suitex en-US', null, 'suitex en-US', X]);
});

it('the draft layer stays the strict draft read\'s, which the arm does not move: the pair\'s pending draft of `fr-FR` (UNCHANGED; at Z\'s address it is no draft)', async () => {
installZ(); tpl('en-US', X); tpl('fr-FR', Z);
pairRow({ overrides: { package: Z } });
pairRow({ overrides: { package: Z } }, 'draft');
const strictDraft = labelOf(await protocol.getMetaItem({ type: 'email_template', name: 'welcome', member: 'fr-FR', state: 'draft' } as never));
expect(strictDraft, 'the plain bare strict draft read').toBe('pair fr-FR draft');
const bare = await layered('fr-FR', undefined, true);
expect([bare.effective?.label, bare.draft?.label ?? null], 'bare `?member=fr-FR&layers=true` with drafts').toEqual(['pair fr-FR', strictDraft]);
expect((await layered('fr-FR', Z, true)).draft ?? null, 'CONTROL: `?package=Z` reads no draft there (UNCHANGED)').toBeNull();
});

it.each([
['no row stored', () => { installZ(); tpl('en-US', X); tpl('fr-FR', Z); }],
['an undeclared pair row of the locale', () => { installZ(); tpl('en-US', X); tpl('fr-FR', Z); pairRow(); }],
] as const)('CONTROL — no override of Z declared (%s): the bare layered read answers Z\'s own `fr-FR` and no overlay (UNCHANGED)', async (_order, arrange) => {
arrange();
expect(layersOf(await layered('fr-FR'))).toEqual(['zeta fr-FR', null, 'zeta fr-FR', Z]);
});

it('CONTROL — the row declares X (the #32606 shape): the bare layered read is not moved to Z, and keeps its refusal naming both (UNCHANGED)', async () => {
installZ(); tpl('en-US', X); tpl('fr-FR', Z);
pairRow({ overrides: { package: X } });
const err = await refusalOf(() => layered('fr-FR'));
expect([err.code, err.status, err.refusal.candidates.map((c) => (c as { packageId?: string }).packageId).sort()])
.toEqual(['RESOURCE_CONFLICT', 409, [X, Z].sort()]);
});
});

/**
* [#33817, from #33131 N1] A package X of an App holds the name only through
* its own stored row (`package_id` X, hydrated into the bare slot), and that
Expand Down
Loading