Skip to content

Commit e373cc1

Browse files
committed
test(runtime): pin the base export for the five types the registry still holds in its bare slot
On a showcase-shaped boot a published page, app, dataset, doc or book override still drops the item from the base export after the dashboard and report copies left the bare slot; the export-read fix covers them too. Claude-Session: https://claude.ai/code/session_01JQwxbac7S1AsbGi5a46PrB Co-authored-by: Claude <noreply@anthropic.com>
1 parent 8738ca5 commit e373cc1

3 files changed

Lines changed: 75 additions & 19 deletions

File tree

‎.changeset/29649-base-export-keeps-overridden-items.md‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,4 +5,4 @@
55
Clause-②: no
66
Metadata-protocol: none
77

8-
`GET /packages/<base>/export` carries the base's own document again while its `.custom` pair's override of a dashboard or report is live (ADR-0146 D8 item 3). On a boot that also holds the base's code documents in the metadata service, as every `defineStack` host does, the per-package layer listed only the override copy under the base's name, and the export's override filter (#29563) left the item out of the base's export. The export now serves the base's code artifact in that item's place, so the base's export is byte-identical with or without a published override, and still carries no `overrides` block.
8+
`GET /packages/<base>/export` carries the base's own document again while its `.custom` pair's override of an item is live (measured for dashboard, report, page, app, dataset, doc and book) (ADR-0146 D8 item 3). On a boot that also holds the base's code documents in the metadata service, as every `defineStack` host does, the per-package layer listed only the override copy under the base's name, and the export's override filter (#29563) left the item out of the base's export. The export now serves the base's code artifact in that item's place, so the base's export is byte-identical with or without a published override, and still carries no `overrides` block.

‎packages/runtime/src/domains/packages-export-base-showcase-boot.integration.test.ts‎

Lines changed: 71 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -17,19 +17,25 @@
1717
* So the base's slot of the name holds the override alone, and the export's
1818
* "never an override of THIS package" filter (#29563) left nothing in it.
1919
* Measured on a real showcase boot at b391feb1: dashboards 3 → 2, reports
20-
* 4 → 3, views 36 → 36.
20+
* 4 → 3, views 36 → 36. #29640 (7dae3b3c) took the dashboard and report copy
21+
* out of the bare slot; on a real showcase boot at 7dae3b3c a published page,
22+
* app, dataset, doc or book override still dropped the item (pages 29 → 28,
23+
* apps 1 → 0, datasets 4 → 3, docs 8 → 7, books 1 → 0).
2124
*
22-
* Per type (view, dashboard, report), over the real door
25+
* Per type (view, dashboard, report, and the five types #29640 left in the
26+
* registry's bare slot: page, app, dataset, doc, book), over the real door
2327
* (`HttpDispatcher.handlePackages`), the real protocol, the real `ObjectQL`
2428
* engine on a SQLite file and the real `MetadataManager`:
2529
*
2630
* - the base's export after the override is published is byte-identical to
2731
* the base's export before it, so the item is present and equal, and no
2832
* item in it carries an `overrides` block;
2933
* - the same holds on a restart over the same database;
30-
* - the pair's export carries the overriding item with its `overrides` block;
31-
* - CONTROL: the effective read of the base's name serves the override, so
32-
* the base export's answer is the export's own.
34+
* - the pair's export carries the overriding item with its `overrides` block
35+
* (view, dashboard, report; see `pairServed`);
36+
* - CONTROL: the pair's override row is published, and for view, dashboard
37+
* and report the effective read of the base's name serves it, so the base
38+
* export's answer is the export's own.
3339
*/
3440
import { afterAll, afterEach, beforeAll, beforeEach, describe, expect, it, vi } from 'vitest';
3541
import { mkdtempSync, rmSync } from 'node:fs';
@@ -93,10 +99,37 @@ const reports = () => [
9399
report('showcase_task_overview', 'Task Overview'),
94100
];
95101

102+
/**
103+
* The base's collections the metadata service holds besides its views, as the
104+
* artifact door files them: plural collection → metadata type. Every one is a
105+
* type a `.custom` pair can publish an override of.
106+
*/
107+
const SERVICE_COLLECTIONS = {
108+
apps: 'app',
109+
pages: 'page',
110+
datasets: 'dataset',
111+
dashboards: 'dashboard',
112+
reports: 'report',
113+
docs: 'doc',
114+
books: 'book',
115+
} as const;
116+
117+
/**
118+
* `pairServed`: whether the pair's export and the effective read serve the
119+
* override. For the five types #29640 left in the bare slot neither does on
120+
* this boot shape (the pair's per-package layer lists none of them, and the
121+
* effective read serves the base's document; #29613), so only the base's half
122+
* is pinned for them.
123+
*/
96124
const TYPES = [
97-
{ type: 'view', plural: 'viewItems', name: VIEW },
98-
{ type: 'dashboard', plural: 'dashboards', name: DASHBOARD },
99-
{ type: 'report', plural: 'reports', name: REPORT },
125+
{ type: 'view', plural: 'viewItems', name: VIEW, pairServed: true },
126+
{ type: 'dashboard', plural: 'dashboards', name: DASHBOARD, pairServed: true },
127+
{ type: 'report', plural: 'reports', name: REPORT, pairServed: true },
128+
{ type: 'page', plural: 'pages', name: 'showcase_start_here', pairServed: false },
129+
{ type: 'app', plural: 'apps', name: 'showcase_app', pairServed: false },
130+
{ type: 'dataset', plural: 'datasets', name: 'showcase_task_metrics', pairServed: false },
131+
{ type: 'doc', plural: 'docs', name: 'showcase_index', pairServed: false },
132+
{ type: 'book', plural: 'books', name: 'showcase_manual', pairServed: false },
100133
] as const;
101134

102135
/** The base's body, as the showcase's `defineStack` carries it: one fresh copy per reader. */
@@ -122,9 +155,19 @@ function baseBody(): Record<string, any> {
122155
dimensions: [{ name: 'status', label: 'Status', field: 'status', type: 'string' }],
123156
measures: [{ name: 'task_count', label: 'Tasks', aggregate: 'count' }],
124157
}],
158+
apps: [{ name: 'showcase_app', label: 'Showcase', navigation: [] }],
159+
pages: [
160+
{ name: 'showcase_capability_map', label: 'Capability Map', type: 'app', regions: [] },
161+
{ name: 'showcase_start_here', label: 'Start Here', type: 'app', regions: [] },
162+
],
125163
views: [viewContainer()],
126164
dashboards: dashboards(),
127165
reports: reports(),
166+
docs: [
167+
{ name: 'showcase_docs_guide', label: 'Docs Guide', content: '# Docs guide' },
168+
{ name: 'showcase_index', label: 'Showcase', content: '# Showcase' },
169+
],
170+
books: [{ name: 'showcase_manual', label: 'Showcase Manual', groups: [] }],
128171
};
129172
}
130173

@@ -145,8 +188,9 @@ async function metadataServiceOf(): Promise<MetadataManager> {
145188
await manager.register('view', view.name, stamp(view as any), { notify: false });
146189
}
147190
}
148-
for (const dashboard of body.dashboards) await manager.register('dashboard', dashboard.name, stamp(dashboard), { notify: false });
149-
for (const item of body.reports) await manager.register('report', item.name, stamp(item), { notify: false });
191+
for (const [plural, type] of Object.entries(SERVICE_COLLECTIONS)) {
192+
for (const item of body[plural]) await manager.register(type, item.name, stamp(item), { notify: false });
193+
}
150194
return manager;
151195
}
152196

@@ -211,6 +255,10 @@ async function boot(dir: string, { installPair }: { installPair: boolean }) {
211255

212256
return {
213257
protocol,
258+
/** The pair's active (published) rows of `(type, name)`, read off the store. */
259+
async publishedRows(type: string, name: string): Promise<unknown[]> {
260+
return await driver.find('sys_metadata', { where: { type, name, package_id: PAIR, state: 'active' } } as any) as unknown[];
261+
},
214262
async exported(id: string): Promise<Record<string, any>> {
215263
const res = await dispatcher.handlePackages(`/${encodeURIComponent(id)}/export`, 'GET', undefined, {}, CALLER);
216264
expect(res.response?.status, JSON.stringify(res.response?.body)).toBe(200);
@@ -236,7 +284,7 @@ const overridingItems = (manifest: Record<string, any>): string[] => Object.entr
236284
.map((item) => `${plural}/${item.name}`));
237285

238286
describe('[#29649] GET /packages/<base>/export carries the base unchanged on a showcase-shaped boot', () => {
239-
for (const { type, plural, name } of TYPES) {
287+
for (const { type, plural, name, pairServed } of TYPES) {
240288
it(`${type}: the base's export is byte-identical with the override published, and after a restart`, async () => {
241289
const dir = mkdtempSync(join(tmpdir(), 'os-29649-db-'));
242290
cleanup.push(() => rmSync(dir, { recursive: true, force: true }));
@@ -248,18 +296,24 @@ describe('[#29649] GET /packages/<base>/export carries the base unchanged on a s
248296

249297
await door.override(type, name, { ...shipped[0], label: OVERRIDE_LABEL, overrides: { ...DECLARATION } });
250298

251-
// CONTROL: the effective read of the base's name serves the published override.
252-
const effective: any = await door.protocol.getMetaItem({ type, name, packageId: BASE });
253-
expect(effective?.item?.label, `the effective ${type} read`).toBe(OVERRIDE_LABEL);
299+
// CONTROL: the override is published, and, where the protocol serves
300+
// it, the effective read of the base's name serves it.
301+
expect(await door.publishedRows(type, name), `the pair's published ${type} row`).toHaveLength(1);
302+
if (pairServed) {
303+
const effective: any = await door.protocol.getMetaItem({ type, name, packageId: BASE });
304+
expect(effective?.item?.label, `the effective ${type} read`).toBe(OVERRIDE_LABEL);
305+
}
254306

255307
const after = await door.exported(BASE);
256308
expect(itemsOf(after, plural, name), `the base's ${type} with the override live`).toEqual(shipped);
257309
expect(overridingItems(after), `the base's export carries no override`).toEqual([]);
258310
expect(JSON.stringify(after), `the base's whole export with the ${type} override live`).toBe(JSON.stringify(before));
259311

260-
const pair = itemsOf(await door.exported(PAIR), plural, name);
261-
expect(pair.map((item) => item.label), `the pair's ${type} export`).toEqual([OVERRIDE_LABEL]);
262-
expect(pair[0].overrides).toEqual(DECLARATION);
312+
if (pairServed) {
313+
const pair = itemsOf(await door.exported(PAIR), plural, name);
314+
expect(pair.map((item) => item.label), `the pair's ${type} export`).toEqual([OVERRIDE_LABEL]);
315+
expect(pair[0].overrides).toEqual(DECLARATION);
316+
}
263317

264318
// A restart over the same database: the published row is hydrated from storage.
265319
const restarted = await boot(dir, { installPair: false });

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

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3465,7 +3465,9 @@ context: HttpProtocolContext,
34653465
// `(name, package)` slot, so the copy wearing the base's envelope takes
34663466
// the base's slot and the base's own item is not listed at all.
34673467
// Measured on a real showcase boot: a published dashboard or report
3468-
// override left the base's export without the item. The package's own
3468+
// override left the base's export without the item, and after #29640
3469+
// took those two out of the bare slot, a page, app, dataset, doc or
3470+
// book override still did (#29613 holds them). The package's own
34693471
// document is its code artifact, read prefer-local from the registry
34703472
// (`getArtifactItem` with the package's id: the composite slot
34713473
// `registerApp` filled, which the bare-slot copy never reaches), the

0 commit comments

Comments
 (0)