Skip to content

Commit 019fbe0

Browse files
committed
test(cli,client,plugin-security): install the packages these fixtures save into
The named-base rule now refuses a save naming a package the registry does not hold, for every type. These suites saved views and permission sets into package ids nothing installed. Each now installs the package first, as a boot or POST /packages does: the client and cli door harnesses install both packages (depending on the package that owns `task`), the kernel integration tests create theirs through protocol.installPackage under a valid hyphenated id, and plugin-security's real registry installs the runtime package while its stub registry answers getPackage for it. Claude-Session: https://claude.ai/code/session_01FEkQ5nhhuhjVQJ8R3qK9UB Co-authored-by: Claude <noreply@anthropic.com>
1 parent d100218 commit 019fbe0

8 files changed

Lines changed: 57 additions & 4 deletions

‎packages/cli/src/commands/meta/delete-reset-carriers.test.ts‎

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -308,6 +308,16 @@ async function bootDoor() {
308308
engine.registry.registerObject(SysMetadataObject as any, TEST_PACKAGE_ID);
309309
engine.registry.registerObject(SysMetadataHistoryObject as any, TEST_PACKAGE_ID);
310310
engine.registry.registerObject(SysMetadataAuditObject as any, TEST_PACKAGE_ID);
311+
// [#26708] A save naming a package the registry does not hold is refused,
312+
// so the two packages the item is saved into are installed first, as a
313+
// boot or `POST /packages` does. Each depends on the package owning
314+
// `task`, so a view over `task` stays inside its closure.
315+
for (const id of [PKG, OTHER_PKG]) {
316+
engine.registry.installPackage(
317+
{ id, name: id, version: '1.0.0', dependencies: { [TEST_PACKAGE_ID]: '*' } } as any,
318+
'authored',
319+
);
320+
}
311321
// Real DDL — the overlay rows the assertions read are physically there.
312322
await engine.syncSchemas();
313323

‎packages/cli/src/commands/meta/register-package.test.ts‎

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -240,6 +240,16 @@ async function bootDoor() {
240240
engine.registry.registerObject(SysMetadataObject as any, TEST_PACKAGE_ID);
241241
engine.registry.registerObject(SysMetadataHistoryObject as any, TEST_PACKAGE_ID);
242242
engine.registry.registerObject(SysMetadataAuditObject as any, TEST_PACKAGE_ID);
243+
// [#26708] A save naming a package the registry does not hold is refused,
244+
// so the two packages the item is saved into are installed first, as a
245+
// boot or `POST /packages` does. Each depends on the package owning
246+
// `task`, so a view over `task` stays inside its closure.
247+
for (const id of [PKG, OTHER_PKG]) {
248+
engine.registry.installPackage(
249+
{ id, name: id, version: '1.0.0', dependencies: { [TEST_PACKAGE_ID]: '*' } } as any,
250+
'authored',
251+
);
252+
}
243253
await engine.syncSchemas();
244254

245255
const protocol: any = new ObjectStackProtocolImplementation(engine as any);

‎packages/cli/test/permission-set-zero-row.integration.test.ts‎

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -44,9 +44,9 @@ import { SecurityPlugin, appSecurityPluginOptions } from '@objectstack/plugin-se
4444
const ENV = 'env_zero_row';
4545
const TABLE = 'sys_permission_set';
4646
/** A package whose drafts the package door publishes. */
47-
const DRAFT_PKG = 'app.zero_row_drafts';
47+
const DRAFT_PKG = 'app.zero-row-drafts';
4848
/** A writable base that publishes its set directly (ADR-0070). */
49-
const BASE_PKG = 'app.zero_row_base';
49+
const BASE_PKG = 'app.zero-row-base';
5050

5151
const stack: any = {
5252
manifest: { id: 'com.example.zero_row', name: 'zero_row', version: '0.0.1', type: 'app' },
@@ -117,6 +117,11 @@ for (const kind of ['host', 'environment'] as Kind[]) {
117117
const protocol = await kernel.getServiceAsync('protocol');
118118
const set = (name: string) => ({ name, label: name, isDefault: true, objects: { zero_doc: { allowRead: true } } });
119119

120+
// [#26708] A save naming a package the registry does not hold is
121+
// refused, so both packages are created first, as `POST /packages` does.
122+
await protocol.installPackage({ manifest: { id: DRAFT_PKG, name: 'Zero row drafts', version: '0.1.0', type: 'app', namespace: 'zrd' } });
123+
await protocol.installPackage({ manifest: { id: BASE_PKG, name: 'Zero row base', version: '0.1.0', type: 'app', namespace: 'zrb' } });
124+
120125
// The package door: a draft into the package, then its atomic publish.
121126
await protocol.saveMetaItem({ type: 'permission', name: 'zero_pkg_default', item: set('zero_pkg_default'), packageId: DRAFT_PKG, mode: 'draft' });
122127
const published = await protocol.publishPackageDrafts({ packageId: DRAFT_PKG, actor: 'system' });

‎packages/cli/test/security-catalog-echo-env-kernel.integration.test.ts‎

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -52,7 +52,7 @@ const ENV = 'env_catalog_echo';
5252
const SYS = { context: { isSystem: true } } as any;
5353

5454
/** A writable runtime package, never installed as code. */
55-
const RUNTIME_PKG = 'app.catalog_echo';
55+
const RUNTIME_PKG = 'app.catalog-echo';
5656
/** Its default set: `isDefault: true`, no `packageId` in the body. */
5757
const PKG_SET = 'echo_pkg_default';
5858
/** A set saved into no package. */
@@ -143,6 +143,9 @@ function scenario(kind: Kind) {
143143
const { ql, protocol, org } = state as Required<typeof state>;
144144
expect(protocol.environmentId ?? null, 'topology').toBe(kind === 'environment' ? ENV : null);
145145
const set = (name: string) => ({ name, label: name, isDefault: true, objects: { echo_doc: { allowRead: true } } });
146+
// [#26708] A save naming a package the registry does not hold is refused,
147+
// so the runtime package is created first, as `POST /packages` does.
148+
await protocol.installPackage({ manifest: { id: RUNTIME_PKG, name: 'Catalog echo', version: '0.1.0', type: 'app', namespace: 'cecho' } });
146149
await protocol.saveMetaItem({ type: 'permission', name: PKG_SET, item: set(PKG_SET), packageId: RUNTIME_PKG, mode: 'draft' });
147150
const published = await protocol.publishPackageDrafts({ packageId: RUNTIME_PKG, actor: 'system' });
148151
expect(published, JSON.stringify(published)).toMatchObject({ outcome: 'published', failed: [] });

‎packages/client/src/meta-delete-item-carriers.test.ts‎

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -503,6 +503,16 @@ async function bootDoor() {
503503
engine.registry.registerObject(SysMetadataObject as any, TEST_PACKAGE_ID);
504504
engine.registry.registerObject(SysMetadataHistoryObject as any, TEST_PACKAGE_ID);
505505
engine.registry.registerObject(SysMetadataAuditObject as any, TEST_PACKAGE_ID);
506+
// [#26708] A save naming a package the registry does not hold is refused,
507+
// so the two packages the item is saved into are installed first, as a
508+
// boot or `POST /packages` does. Each depends on the package owning
509+
// `task`, so a view over `task` stays inside its closure.
510+
for (const id of [PKG, 'com.qa.beta']) {
511+
engine.registry.installPackage(
512+
{ id, name: id, version: '1.0.0', dependencies: { [TEST_PACKAGE_ID]: '*' } } as any,
513+
'authored',
514+
);
515+
}
506516
// Real DDL — the overlay rows the assertions read are physically there.
507517
await engine.syncSchemas();
508518

‎packages/client/src/meta-publish-item-package.test.ts‎

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -263,6 +263,16 @@ async function bootDoor() {
263263
engine.registry.registerObject(SysMetadataObject as any, TEST_PACKAGE_ID);
264264
engine.registry.registerObject(SysMetadataHistoryObject as any, TEST_PACKAGE_ID);
265265
engine.registry.registerObject(SysMetadataAuditObject as any, TEST_PACKAGE_ID);
266+
// [#26708] A save naming a package the registry does not hold is refused,
267+
// so the two packages the item is saved into are installed first, as a
268+
// boot or `POST /packages` does. Each depends on the package owning
269+
// `task`, so a view over `task` stays inside its closure.
270+
for (const id of [PKG, OTHER_PKG]) {
271+
engine.registry.installPackage(
272+
{ id, name: id, version: '1.0.0', dependencies: { [TEST_PACKAGE_ID]: '*' } } as any,
273+
'authored',
274+
);
275+
}
266276
// Real DDL — the overlay rows the assertions read are physically there.
267277
await engine.syncSchemas();
268278

‎packages/plugins/plugin-security/src/permission-set-env-kernel-registry-write-through.test.ts‎

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -170,6 +170,9 @@ async function boot(kind: Kernel) {
170170
version: '1.0.0',
171171
permissions: [{ name: CODE_SET, label: 'CRM read-only', isDefault: true, objects: {} }],
172172
});
173+
// [#26708] A save naming a package the registry does not hold is refused,
174+
// so the runtime package is installed as a boot or `POST /packages` does.
175+
engine.registry.installPackage({ id: RUNTIME_PKG, name: RUNTIME_PKG, version: '1.0.0' } as never, 'authored');
173176
const metadata = makeMetadataService();
174177
const protocol = new ObjectStackProtocolImplementation(
175178
engine as never,

‎packages/plugins/plugin-security/src/security-catalog-echo.test.ts‎

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -95,7 +95,9 @@ function makeEngine() {
9595
getArtifactItem: (type: string, name: string) =>
9696
(type === 'permission' ? codeArtifacts.find((item) => item.name === name) : undefined),
9797
isPackageDisabled: () => false,
98-
getPackage: () => undefined,
98+
// [#26708] The runtime package is installed: a save naming a package the
99+
// registry does not hold is refused.
100+
getPackage: (id: string) => (id === RUNTIME_PKG ? { manifest: { id, name: id, version: '1.0.0' } } : undefined),
99101
getAllPackages: () => [],
100102
registerItem: (type: string, item: Row, _key: string, packageId?: string) => {
101103
if (type === 'position') positions.set(String(item.name), { ...item, _packageId: packageId });

0 commit comments

Comments
 (0)