Skip to content

Commit b1ea4bc

Browse files
committed
test(runtime): the legacy pair's removal on both topologies; changeset names runtime
Co-Authored-By: Claude <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_017ihL2dM9PvPPB9BMVdhf2R
1 parent fb2fd21 commit b1ea4bc

3 files changed

Lines changed: 68 additions & 59 deletions

File tree

‎.changeset/29594-app-customization-pair.md‎

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,9 +3,10 @@
33
'@objectstack/metadata-protocol': minor
44
'@objectstack/objectql': minor
55
'@objectstack/lint': minor
6+
'@objectstack/runtime': minor
67
---
78

8-
feat(metadata-core, metadata-protocol, objectql, lint)!: an App and the modules that declare it share one customization pair
9+
feat(metadata-core, metadata-protocol, objectql, lint, runtime)!: an App and the modules that declare it share one customization pair
910

1011
Clause-②: yes (narrowing) — the ensure door refuses two asks it accepted: a package that reaches several Apps and whose namespace picks none of them (was `201` with its own pair, now `409`, merge question 11), and a module whose earlier per-package pair holds the App's pair namespace (was `201`/`200`, now `409 RESOURCE_CONFLICT` naming that pair, merge question 12); `appOf` now returns `string | undefined`. The widening half: a module of an App gets the App's pair (`200`, where it was `422 NAMESPACE_CONFLICT` when the App held the namespace), and `@objectstack/metadata-core` exports `pairsOf`, `AppOfRefusal` and `PairOfRefusal`. Ruling 6691022506; ADR-0146 D3 as amended by #31027.
1112
Metadata-protocol: semantic

‎packages/runtime/src/domains/meta-legacy-pair-served.test.ts‎

Lines changed: 64 additions & 57 deletions
Original file line numberDiff line numberDiff line change
@@ -63,7 +63,7 @@ function makeRes() {
6363
return res;
6464
}
6565

66-
async function boot() {
66+
async function boot(environmentId?: string) {
6767
const engine = new ObjectQL();
6868
liveEngines.push(engine);
6969
engine.registerDriver(new SqlDriver({
@@ -91,7 +91,7 @@ async function boot() {
9191
dependencies: { [MODULE]: '^6' },
9292
} as any, 'authored');
9393
await engine.syncSchemas();
94-
const protocol: any = new ObjectStackProtocolImplementation(engine as any, () => new Map());
94+
const protocol: any = new ObjectStackProtocolImplementation(engine as any, () => new Map(), environmentId);
9595

9696
// The reads: the dispatcher's catch-all.
9797
const get = (n: string) => (n === 'protocol' ? protocol : n === 'objectql' ? engine : null);
@@ -141,58 +141,65 @@ const listedLabel = (body: any) => {
141141
};
142142
const effectiveLabel = (body: any) => (body?.data ?? body)?.effective?.label;
143143

144-
describe('[#29594] merge question 12: a legacy per-package pair of an App\'s module is honoured as before', () => {
145-
it('the pair still saves a declared override of the module\'s item (the write gate admits it)', async () => {
146-
const { protocol, read } = await boot();
147-
await protocol.saveMetaItem({
148-
type: 'dashboard', name: BOARD, packageId: LEGACY_PAIR,
149-
item: { ...board(CUSTOMIZED), overrides: { package: MODULE, basedOn: '6.1.0' } },
150-
});
151-
const byName = await read(`/meta/dashboard/${BOARD}`, { package: MODULE });
152-
expect([byName.status, labelOf(byName.body)]).toEqual([200, CUSTOMIZED]);
153-
}, 60_000);
154-
155-
it('its declared override is served at the module\'s address (by name, list, layered); it removes it, and the module\'s item is served again', async () => {
156-
const { read, remove, seedLegacyOverride } = await boot();
157-
158-
// Precondition: the module ships the board.
159-
const shipped = await read(`/meta/dashboard/${BOARD}`, { package: MODULE });
160-
expect([shipped.status, labelOf(shipped.body)], JSON.stringify(shipped.body).slice(0, 400)).toEqual([200, SHIPPED]);
161-
162-
// The legacy pair holds its declared override of the module's board.
163-
await seedLegacyOverride('dashboard', board(CUSTOMIZED));
164-
165-
const byName = await read(`/meta/dashboard/${BOARD}`, { package: MODULE });
166-
const list = await read('/meta/dashboard', { package: MODULE });
167-
const layered = await read(`/meta/dashboard/${BOARD}/layers`, { package: MODULE });
168-
expect({
169-
byName: [byName.status, labelOf(byName.body)],
170-
list: [list.status, listedLabel(list.body)],
171-
layered: [layered.status, effectiveLabel(layered.body)],
172-
}, JSON.stringify({ byName: byName.body, layered: layered.body }).slice(0, 800)).toEqual({
173-
byName: [200, CUSTOMIZED],
174-
list: [200, CUSTOMIZED],
175-
layered: [200, CUSTOMIZED],
176-
});
177-
178-
// "Restore package original": the legacy pair removes its own override.
179-
const removed = await remove('dashboard', BOARD, { package: LEGACY_PAIR });
180-
expect(removed.status, JSON.stringify(removed.body).slice(0, 600)).toBe(200);
181-
182-
const after = await read(`/meta/dashboard/${BOARD}`, { package: MODULE });
183-
const layeredAfter = await read(`/meta/dashboard/${BOARD}/layers`, { package: MODULE });
184-
expect([labelOf(after.body), effectiveLabel(layeredAfter.body)]).toEqual([SHIPPED, SHIPPED]);
185-
}, 60_000);
186-
187-
it('a doc (no overlay channel) the legacy pair overrides is served, and its removal passes the sealed-removal refusal as the pair\'s own', async () => {
188-
const { read, remove, seedLegacyOverride } = await boot();
189-
await seedLegacyOverride('doc', guide(CUSTOMIZED));
190-
const byName = await read(`/meta/doc/${GUIDE}`, { package: MODULE });
191-
expect([byName.status, labelOf(byName.body)], JSON.stringify(byName.body).slice(0, 400)).toEqual([200, CUSTOMIZED]);
192-
193-
const removed = await remove('doc', GUIDE, { package: LEGACY_PAIR });
194-
expect(removed.status, JSON.stringify(removed.body).slice(0, 600)).toBe(200);
195-
const after = await read(`/meta/doc/${GUIDE}`, { package: MODULE });
196-
expect([after.status, labelOf(after.body)]).toEqual([200, SHIPPED]);
197-
}, 60_000);
198-
});
144+
// Both topologies: an environment kernel (`environmentId` set) asks the
145+
// protocol's removal door — `refusePackagedBaseRemoval` and the pair-row
146+
// removal's pass past it — and a host-config kernel only the repository's
147+
// delete gate.
148+
for (const environmentId of [undefined, 'env_hotcrm'] as const) {
149+
const topology = environmentId === undefined ? 'host-config kernel' : 'environment kernel';
150+
describe(`[#29594] merge question 12 (${topology}): a legacy per-package pair of an App's module is honoured as before`, () => {
151+
it('the pair still saves a declared override of the module\'s item (the write gate admits it)', async () => {
152+
const { protocol, read } = await boot(environmentId);
153+
await protocol.saveMetaItem({
154+
type: 'dashboard', name: BOARD, packageId: LEGACY_PAIR,
155+
item: { ...board(CUSTOMIZED), overrides: { package: MODULE, basedOn: '6.1.0' } },
156+
});
157+
const byName = await read(`/meta/dashboard/${BOARD}`, { package: MODULE });
158+
expect([byName.status, labelOf(byName.body)]).toEqual([200, CUSTOMIZED]);
159+
}, 60_000);
160+
161+
it('its declared override is served at the module\'s address (by name, list, layered); it removes it, and the module\'s item is served again', async () => {
162+
const { read, remove, seedLegacyOverride } = await boot(environmentId);
163+
164+
// Precondition: the module ships the board.
165+
const shipped = await read(`/meta/dashboard/${BOARD}`, { package: MODULE });
166+
expect([shipped.status, labelOf(shipped.body)], JSON.stringify(shipped.body).slice(0, 400)).toEqual([200, SHIPPED]);
167+
168+
// The legacy pair holds its declared override of the module's board.
169+
await seedLegacyOverride('dashboard', board(CUSTOMIZED));
170+
171+
const byName = await read(`/meta/dashboard/${BOARD}`, { package: MODULE });
172+
const list = await read('/meta/dashboard', { package: MODULE });
173+
const layered = await read(`/meta/dashboard/${BOARD}/layers`, { package: MODULE });
174+
expect({
175+
byName: [byName.status, labelOf(byName.body)],
176+
list: [list.status, listedLabel(list.body)],
177+
layered: [layered.status, effectiveLabel(layered.body)],
178+
}, JSON.stringify({ byName: byName.body, layered: layered.body }).slice(0, 800)).toEqual({
179+
byName: [200, CUSTOMIZED],
180+
list: [200, CUSTOMIZED],
181+
layered: [200, CUSTOMIZED],
182+
});
183+
184+
// "Restore package original": the legacy pair removes its own override.
185+
const removed = await remove('dashboard', BOARD, { package: LEGACY_PAIR });
186+
expect(removed.status, JSON.stringify(removed.body).slice(0, 600)).toBe(200);
187+
188+
const after = await read(`/meta/dashboard/${BOARD}`, { package: MODULE });
189+
const layeredAfter = await read(`/meta/dashboard/${BOARD}/layers`, { package: MODULE });
190+
expect([labelOf(after.body), effectiveLabel(layeredAfter.body)]).toEqual([SHIPPED, SHIPPED]);
191+
}, 60_000);
192+
193+
it('a doc (no overlay channel) the legacy pair overrides is served, and its removal passes the sealed-removal refusal as the pair\'s own', async () => {
194+
const { read, remove, seedLegacyOverride } = await boot(environmentId);
195+
await seedLegacyOverride('doc', guide(CUSTOMIZED));
196+
const byName = await read(`/meta/doc/${GUIDE}`, { package: MODULE });
197+
expect([byName.status, labelOf(byName.body)], JSON.stringify(byName.body).slice(0, 400)).toEqual([200, CUSTOMIZED]);
198+
199+
const removed = await remove('doc', GUIDE, { package: LEGACY_PAIR });
200+
expect(removed.status, JSON.stringify(removed.body).slice(0, 600)).toBe(200);
201+
const after = await read(`/meta/doc/${GUIDE}`, { package: MODULE });
202+
expect([after.status, labelOf(after.body)]).toEqual([200, SHIPPED]);
203+
}, 60_000);
204+
});
205+
}

‎packages/runtime/src/domains/packages.ts‎

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3996,7 +3996,8 @@ async function readPackageCustomizations(
39963996
const pairs = pairsOf(baseId, installedManifestsOf(registry));
39973997
type Extension = GetPackageCustomizationsResponse['extensions'][number];
39983998
const extensions: Extension[] = [];
3999-
if (typeof registry?.getAllObjects === 'function') for (const pairId of pairs) {
3999+
const pairIdsToRead = typeof registry?.getAllObjects === 'function' ? pairs : [];
4000+
for (const pairId of pairIdsToRead) {
40004001
for (const object of registry.getAllObjects(pairId) as Array<{ name?: unknown }>) {
40014002
const name = object?.name;
40024003
if (typeof name !== 'string' || registry.getObjectOwner(name)?.packageId !== baseId) continue;

0 commit comments

Comments
 (0)