Skip to content

Commit 5590865

Browse files
committed
test(objectql): a residual top-level dataset registers under the stack's manifest id (red)
Claude-Session: https://claude.ai/code/session_01JQwxbaRjbDqdsjbNUjKQJZ Co-authored-by: Claude <noreply@anthropic.com>
1 parent ff827bc commit 5590865

1 file changed

Lines changed: 42 additions & 0 deletions

File tree

‎packages/objectql/src/manifest-service-residual-objects.test.ts‎

Lines changed: 42 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -388,6 +388,48 @@ describe('ADR-0130 D4 — the manifest service registers the residual\'s flows',
388388
});
389389
});
390390

391+
/**
392+
* [ADR-0130 D4] A residual DATASET (the ADR-0021 analytics kind, `datasets:`)
393+
* reaches the registry under the stack's manifest id and version, as a body's
394+
* does under its package's. Before, the residual rule did not walk `datasets`
395+
* at all, so a top-level dataset no body declared was neither registered nor
396+
* refused: the boot booted, `listItems('dataset')` answered the bodies' own,
397+
* and a dashboard or report naming it failed at run time, far from the cause.
398+
*/
399+
describe('ADR-0130 D4 — the manifest service registers the residual\'s datasets', () => {
400+
const dataset = (name = 'acme_case_metrics') => ({
401+
name,
402+
label: 'Case metrics',
403+
object: 'acme_case',
404+
dimensions: [{ name: 'subject', field: 'subject', type: 'string' }],
405+
measures: [{ name: 'case_count', aggregate: 'count' }],
406+
});
407+
const datasetOwners = (ql: ObjectQL) =>
408+
(ql.registry.listItems('dataset') as Array<{ name?: string; _packageId?: string; _packageVersion?: string }>)
409+
.map((d) => [d.name, d._packageId, d._packageVersion])
410+
.sort((a, b) => String(a[0]).localeCompare(String(b[0])));
411+
412+
it('registers a residual dataset under the stack\'s manifest id and version, beside a body\'s own', async () => {
413+
const residualEntry = dataset();
414+
const { kernel } = await boot(registering('app', [
415+
residualStack(noteObj(), { datasets: [residualEntry] }, { datasets: [dataset('acme_case_body')] }),
416+
]));
417+
expect(datasetOwners(engineOf(kernel))).toEqual([
418+
['acme_case_body', SERVICE_ID, '2.4.0'],
419+
['acme_case_metrics', RELEASE_ID, '1.0.0'],
420+
]);
421+
// The artifact's own entry is left as it arrived.
422+
expect((residualEntry as { _packageId?: string })._packageId).toBeUndefined();
423+
});
424+
425+
it('CONTROL: a top-level dataset a body repeats is the body\'s, registered once', async () => {
426+
const { kernel } = await boot(registering('app', [
427+
residualStack(noteObj(), { datasets: [dataset()] }, { datasets: [dataset()] }),
428+
]));
429+
expect(datasetOwners(engineOf(kernel))).toEqual([['acme_case_metrics', SERVICE_ID, '2.4.0']]);
430+
});
431+
});
432+
391433
/**
392434
* [ADR-0130 D4] EVERY other residual type a package body's collections take
393435
* into the registry reaches it too, under the stack's manifest id and version:

0 commit comments

Comments
 (0)