Skip to content

Commit 6f9228c

Browse files
committed
test(objectql): fixtures install the packages their saves name
A save naming a package no installed package has is now refused for every type. Each fixture installs the authored or code package its saves name, as a boot does, and registers the object a grid binds where the package's closure now judges it. Claude-Session: https://claude.ai/code/session_01FEkQ5nhhuhjVQJ8R3qK9UB Co-authored-by: Claude <noreply@anthropic.com>
1 parent 05cd073 commit 6f9228c

15 files changed

Lines changed: 88 additions & 2 deletions

‎packages/objectql/src/protocol-adopt-orphans-object-registry.test.ts‎

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -184,6 +184,10 @@ describe('#23646 — an orphan adoption moves an adopted object\'s registry owne
184184
engine.registerDriver(makeMemoryDriver(stores, drops), true);
185185
await kernel.use(new ObjectQLPlugin({ ql: engine }));
186186
await kernel.bootstrap();
187+
// [#26708] The workspaces the saves below name are installed, as
188+
// authored bases: a save naming a package no installed package has
189+
// is refused before it is written.
190+
for (const id of [Q, R]) engine.registry.installPackage({ id, name: id, version: '1.0.0' } as any, 'authored');
187191
return { kernel, engine, protocol: kernel.getService('protocol') };
188192
}
189193

‎packages/objectql/src/protocol-boot-object-package-binding.test.ts‎

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -106,6 +106,10 @@ function keyOf(w: Record<string, unknown>) {
106106
function makeSession(seed: { rows?: Row[]; history?: HistoryRow[] } = {}) {
107107
const registry = new SchemaRegistry({ multiTenant: false });
108108
registry.logLevel = 'silent';
109+
// [#26708] The authored packages the saves below name are installed, as
110+
// every boot rehydrates them: a save naming a package no installed
111+
// package has is refused before it is written.
112+
for (const id of [APP_PKG, OTHER_PKG]) registry.installPackage({ id, name: id, version: '1.0.0' } as any, 'authored');
109113
const rows = new Map<string, Row>();
110114
for (const r of seed.rows ?? []) rows.set(keyOf(r), { ...r });
111115
const historyRows: HistoryRow[] = (seed.history ?? []).map((h) => ({ ...h }));

‎packages/objectql/src/protocol-commit-history.test.ts‎

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -337,6 +337,12 @@ function makeRealRepoHarness(seedCommits: any[] = [], opts: { controlPlane?: boo
337337
const environmentId: string | undefined = opts.controlPlane === true ? undefined : 'env_test';
338338
const registry = new SchemaRegistry({ multiTenant: false });
339339
(registry as any).logLevel = 'silent';
340+
// [#26708] The package every save below names is installed, as an authored
341+
// base: a save naming a package no installed package has is refused. An
342+
// installed package's write is judged against its closure, so the `case`
343+
// object its grid binds is one it ships.
344+
registry.installPackage({ id: APP_PKG, name: APP_PKG, version: '1.0.0' } as any, 'authored');
345+
registry.registerObject({ name: 'case', label: 'Case', fields: { title: { type: 'text', label: 'Title' } } } as never, APP_PKG);
340346
const rows = new Map<string, any>();
341347
const historyRows: any[] = [];
342348
const commits: any[] = [...seedCommits];

‎packages/objectql/src/protocol-delete-boot-hydrated-object-heal.test.ts‎

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -195,6 +195,10 @@ describe('#23645 — a runtime object hydrated at boot, then deleted', () => {
195195
await kernel.use(new ObjectQLPlugin({ ql: engine }));
196196
beforeBoot?.(engine);
197197
await kernel.bootstrap();
198+
// [#26708] The workspaces the saves below name are installed, as
199+
// authored bases: a save naming a package no installed package has
200+
// is refused before it is written.
201+
for (const id of [P, Q]) engine.registry.installPackage({ id, name: id, version: '1.0.0' } as any, 'authored');
198202
return {
199203
kernel,
200204
engine,

‎packages/objectql/src/protocol-delete-object-registry-heal.test.ts‎

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -75,6 +75,11 @@ function makeHarness(opts: { controlPlane?: boolean } = {}) {
7575
const environmentId: string | undefined = opts.controlPlane === true ? undefined : 'env_test';
7676
const registry = new SchemaRegistry({ multiTenant: false });
7777
(registry as any).logLevel = 'silent';
78+
// [#26708] The authored packages the saves below name are installed: a save
79+
// naming a package no installed package has is refused before it is written.
80+
for (const id of [APP_PKG, 'app.pkg_p', 'app.pkg_q']) {
81+
registry.installPackage({ id, name: id, version: '1.0.0' } as any, 'authored');
82+
}
7883
const rows = new Map<string, any>();
7984
const historyRows: any[] = [];
8085
const dataRows: any[] = [];

‎packages/objectql/src/protocol-derived-provenance-doors.test.ts‎

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -171,6 +171,10 @@ async function boot(driver: unknown) {
171171
await engine.init();
172172
engine.registry.registerObject(sysMetadataObject as any);
173173
for (const o of [SysMetadataHistoryObject, SysMetadataAuditObject, SysMetadataCommitObject]) engine.registry.registerObject(o as any);
174+
// [#26708] The tenant's own package is installed, as an authored base: a
175+
// save naming a package no installed package has is refused before it is
176+
// written.
177+
engine.registry.installPackage({ id: PKG, name: PKG, version: '1.0.0' } as any, 'authored');
174178
const protocol = new ObjectStackProtocolImplementation(engine as any, undefined, ENV);
175179
return { engine, protocol };
176180
}
@@ -336,6 +340,8 @@ describe('#16702 door 2 — hydration restates the fact for EVERY type, not only
336340
for (const o of [SysMetadataHistoryObject, SysMetadataAuditObject, SysMetadataCommitObject]) engine.registry.registerObject(o as any);
337341
// environmentId omitted — the unscoped (control-plane) kernel is the
338342
// only one whose list read hydrates the process-wide registry.
343+
// [#26708] The tenant's own package is installed, as in `boot`.
344+
engine.registry.installPackage({ id: PKG, name: PKG, version: '1.0.0' } as any, 'authored');
339345
const protocol = new ObjectStackProtocolImplementation(engine as any);
340346

341347
await protocol.getMetaItems({ type: 'app' });

‎packages/objectql/src/protocol-lock-artifact-package-axis.test.ts‎

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -60,8 +60,16 @@ function protocolFor(arrangement: Arrangement, order: readonly string[]) {
6060
...(lock ? { protection: { lock, reason: `Packaged lock of ${packageId}.` } } : {}),
6161
} as Record<string, unknown>, 'name' as never, packageId);
6262
}
63-
for (const packageId of arrangement.disabled ?? []) {
63+
// [#26708] Every package that ships the view is installed, as its boot
64+
// installs it: a save naming a package no installed package has is
65+
// refused before the lock this file pins is reached.
66+
for (const packageId of order) {
6467
registry.installPackage({ id: packageId, name: packageId, version: '1.0.0', type: 'app' } as never, 'code');
68+
}
69+
for (const packageId of arrangement.disabled ?? []) {
70+
if (!order.includes(packageId)) {
71+
registry.installPackage({ id: packageId, name: packageId, version: '1.0.0', type: 'app' } as never, 'code');
72+
}
6573
registry.disablePackage(packageId);
6674
}
6775
const rows = arrangement.rowLock === undefined ? [] : [{

‎packages/objectql/src/protocol-meta.test.ts‎

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -260,6 +260,12 @@ describe('ObjectStackProtocolImplementation - Metadata Persistence', () => {
260260
// overwrite) package A's same-name overlay — that is what lets two
261261
// installed packages keep independent customizations.
262262
mockEngine.findOne.mockResolvedValue(null);
263+
// [#26708] Package B is installed: a save naming a package no
264+
// installed package has is refused before it is written.
265+
registry.installPackage({ id: 'com.acme.beta', name: 'Beta', version: '1.0.0' } as any, 'authored');
266+
// …and the object its grid binds is one it ships: an installed
267+
// package's write is judged against its closure.
268+
registry.registerObject({ name: 'test_task', label: 'Task', fields: { title: { type: 'text', label: 'Title' } } } as never, 'com.acme.beta');
263269

264270
// [#6190] `app` -> `view` for the same reason as the org-persistence
265271
// case above: the package dimension this pins is untouched, but the

‎packages/objectql/src/protocol-object-overlay-layer.test.ts‎

Lines changed: 13 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -207,6 +207,10 @@ function makeSession(opts: { controlPlane?: boolean; seed?: any[] } = {}) {
207207
*/
208208
async function persistOverlayRow(name: string, packageId?: string): Promise<any[]> {
209209
const s = makeSession();
210+
// [#26708] The package the row names is installed while it is written — an
211+
// authored base, before any code ships the name: a save naming a package
212+
// no installed package has is refused before it is written.
213+
if (packageId) s.registry.installPackage({ id: packageId, name: packageId, version: '1.0.0' } as any, 'authored');
210214
await s.protocol.saveMetaItem({
211215
type: 'object',
212216
name,
@@ -568,6 +572,9 @@ describe('ADR-0029 D9.9 / #6995 — the row\'s package_id is provenance, never a
568572
it('different package — the WRITE is refused with an ADR-0112 envelope, and nothing is persisted', async () => {
569573
const seed = await persistOverlayRow('myapp_invoice', APP_PKG);
570574
const { protocol, registry, rows } = await bootWithPackage(seed);
575+
// [#26708] The other package is a real, installed one: a save naming a
576+
// package no installed package has is refused before this door.
577+
registry.installPackage({ id: OTHER_PKG, name: OTHER_PKG, version: '1.0.0' } as any, 'authored');
571578

572579
// [ADR-0131 D6] Under the hatch this write used to reach the D9.9
573580
// package check (`OBJECT_OVERLAY_PACKAGE_MISMATCH` / 422). Managed
@@ -624,7 +631,12 @@ describe('ADR-0029 D9.9 / #6995 — the row\'s package_id is provenance, never a
624631
* registry can represent that — so nothing here narrows them.
625632
*/
626633
it('a non-object type with a different binding is untouched by the rule', async () => {
627-
const { protocol } = makeSession();
634+
const { protocol, registry } = makeSession();
635+
// [#26708] Installed, with the object its grid binds: a save naming a
636+
// package no installed package has is refused, and an installed
637+
// package's write is judged against its closure.
638+
registry.installPackage({ id: OTHER_PKG, name: OTHER_PKG, version: '1.0.0' } as any, 'authored');
639+
registry.registerObject({ name: 'task', label: 'Task', fields: { name: { type: 'text', label: 'Name' } } } as never, OTHER_PKG);
628640
const res = await protocol.saveMetaItem({
629641
type: 'view', name: 'shared_grid', packageId: OTHER_PKG,
630642
item: { name: 'shared_grid', type: 'grid', columns: ['name'], object: 'task', viewKind: 'list' }, // [#7741] the inline arm requires the object binding pair

‎packages/objectql/src/protocol-org-overlay-registry-gate.test.ts‎

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -419,6 +419,13 @@ describe('#6780 — the registry heal is org-gated: an org DELETE never evicts t
419419
registry = new SchemaRegistry({ multiTenant: false });
420420
registry.logLevel = 'silent';
421421
engine = makeEngine(registry);
422+
// [#26708] The package that ships the artifact is installed, as its
423+
// boot installs it: a save naming a package no installed package has
424+
// is refused before it is written.
425+
registry.installPackage({ id: PKG, name: PKG, version: '1.0.0' } as any, 'code');
426+
// …with the object its grid binds: an installed package's write is
427+
// judged against its closure.
428+
registry.registerObject({ name: 'showcase_task', label: 'Task', fields: { name: { type: 'text', label: 'Name' } } } as never, PKG);
422429
// No environmentId — the unscoped control-plane kernel #5086 measured
423430
// the flagship showcase booting with, and the one whose registry every
424431
// org in the process shares.

0 commit comments

Comments
 (0)