Skip to content

Commit cca7404

Browse files
committed
test(#29594): kernel verdict pins, legacy kernel pair stays served, closes reopen; changeset
Co-Authored-By: Claude <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01L9qibzCo6pa7SSUFmosQD8
1 parent 98e6c22 commit cca7404

3 files changed

Lines changed: 91 additions & 6 deletions

File tree

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
---
2+
'@objectstack/metadata-core': patch
3+
'@objectstack/metadata-protocol': patch
4+
'@objectstack/objectql': patch
5+
'@objectstack/runtime': patch
6+
'@objectstack/cli': patch
7+
'@objectstack/cloud-connection': patch
8+
'@objectstack/lint': patch
9+
'@objectstack/service-automation': patch
10+
'@objectstack/service-datasource': patch
11+
---
12+
13+
feat(metadata-protocol, metadata-core)!: the ensure door creates no customization pair for a kernel package, and every pair question carries the installed manifests
14+
15+
Clause-②: yes (narrowing) — `POST /api/v1/packages/:id/ensure-customization` (and the protocol's `ensureCustomizationPackage`) answers a kernel base, a package of scope `system` or `cloud`, with `409 RESOURCE_CONFLICT` and a sentence saying kernel objects are not customizable in this version, where it created `<id>.custom`. Beside it, the exported `pairOf`, `isPairOf` and `appOf` (`@objectstack/metadata-core`), `isServedOverrideRowOf` and the `installed` member of `OverrideWriteClosure` (`@objectstack/metadata-protocol`), and `resolveFlowPrecedence` / `describeFlowContender` (`@objectstack/service-automation`) take the installed-manifest lookup as a required argument.
16+
Metadata-protocol: none
17+
18+
<!-- adr-0087: not-required (no-migration-prescription) no key of any schema is added, removed or re-shaped and no stored row is read differently, converted or dropped: the narrowing is one runtime refusal at one door, for one kind of base, whose remedy is that no pair exists to create; the existing pairs and the overrides in them stay served exactly as before. The retyped exports are runtime functions with no metadata surface, and the compiler names every caller that has not passed the new argument, so there is nothing for `objectstack migrate meta` to rewrite. -->
19+
20+
**BREAKING** for a caller that ensures the customization pair of a kernel package — a platform package of scope `system` (users, organizations, security, settings and the rest of the platform suite) or `cloud` — and for a TypeScript importer of the pair helpers named above.
21+
22+
- **Why (ruling records 6691022506 and 6691217245 on ADR-0146 D3).** The customization unit is the App, and the kernel is not an App a customer owns: it ships with the runtime at the runtime's version and is always installed whole. In this version no kernel object is customizable, so the door creates no pair for one. Which kernel objects a later version opens (a whitelist) is that version's decision.
23+
- **What the door answers.** `409 RESOURCE_CONFLICT`, the status and code the door already answers when a base's state rules the pair out (a writable base, no namespace, a version that is not SemVer). Nothing is created or written. Every other base is answered exactly as before.
24+
- **A kernel pair that already exists stays.** An earlier version of the door may have created `<kernel id>.custom` on a deployment. It stays installed, the overrides inside it stay served by every read of the kernel item's name, and a further save into it is still admitted. Only the ensure call is refused.
25+
- **The closes that named the pair.** A package-less save, or a save naming the kernel package, onto a kernel item was refused naming the pair as the fix. That fix no longer exists, so those two closes leave the save open, as they already do for every other base the ensure door refuses.
26+
- **The lookup.** Which pair customizes a package is asked through the installed manifests of the registry the caller serves (`installedManifestsOf(registry)`). Today the answer is unchanged for every package: `appOf` is still the identity. The argument is threaded through every site now so that resolving a module to its App is one change in `appOf`.
27+
- **`os validate`'s customization-namespace advisory** now skips a package that is itself a pair through `isCustomizationPackage`, the one spelling of that question. An id ending in `.custom` that no base derives (`a.custom.custom`, a bare `.custom`) is now judged like any other package.
28+
- **Who moves, and the fix.** A script or client that ensured a kernel package's pair drops that call: the kernel item is served as it ships, and an existing pair keeps serving what it holds. A TypeScript importer of the helpers passes `installedManifestsOf(engine.registry)`, or `installedManifestsOf(undefined)` where it holds no registry.

‎packages/objectql/src/protocol-custom-override-effective-read.test.ts‎

Lines changed: 55 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -168,8 +168,9 @@ const listBody = (columns: readonly string[]) => ({
168168
},
169169
});
170170

171-
function baseManifest(): Record<string, unknown> {
171+
function baseManifest(extra: Record<string, unknown> = {}): Record<string, unknown> {
172172
return {
173+
...extra,
173174
id: BASE,
174175
name: 'showcase',
175176
version: '1.0.0',
@@ -194,7 +195,7 @@ function baseManifest(): Record<string, unknown> {
194195
};
195196
}
196197

197-
async function boot() {
198+
async function boot(base: Record<string, unknown> = baseManifest()) {
198199
const engine = new ObjectQL();
199200
const { driver, stores } = makeMemoryDriver();
200201
engine.registerDriver(driver, true);
@@ -203,7 +204,7 @@ async function boot() {
203204
for (const o of [SysMetadataHistoryObject, SysMetadataAuditObject, SysMetadataCommitObject]) {
204205
engine.registry.registerObject(o as any, 'test-package');
205206
}
206-
engine.registerApp(baseManifest());
207+
engine.registerApp(base);
207208
const protocol = new ObjectStackProtocolImplementation(engine, () => new Map());
208209
const rowsOf = (name: string) => Array.from(stores.get('sys_metadata')?.values() ?? [])
209210
.filter((r) => r.type === 'view' && r.name === name);
@@ -461,3 +462,54 @@ describe('[#28409] a same-named item outside X\'s closure is served under its ow
461462
expect(columnsOf(await read(protocol, OUTSIDE))).toEqual(DEPENDENT_COLUMNS);
462463
});
463464
});
465+
466+
/**
467+
* [#29594, ruling record 6691217245] The ensure door creates no pair for a
468+
* kernel package (scope `system` / `cloud`) in this version. Before that
469+
* verdict it did, so a deployment may already hold a kernel base's
470+
* `<kernel>.custom` with overrides in it. The verdict refuses the ENSURE call
471+
* only: the pair stays installed, the overrides in it stay served by every
472+
* read of the base's name, and a further override saved into it is admitted
473+
* by the write gate, which never asks the ensure door.
474+
*/
475+
describe('[#29594] a kernel base\'s pair an earlier version created keeps serving its overrides', () => {
476+
it('the ensure call is refused 409; the override already in the pair is served, and another save into it lands', async () => {
477+
const { protocol, rowsOf } = await boot(baseManifest({ scope: 'system' }));
478+
// The pair as today's ensure door would have written it.
479+
await install(protocol, PAIR);
480+
await saveInto(protocol, PAIR, OVERRIDE_COLUMNS, { overrides: { ...DECLARATION } });
481+
expect(rowsOf(VIEW).map((r) => [r.package_id, r.state])).toEqual([[PAIR, 'active']]);
482+
483+
await expect(protocol.ensureCustomizationPackage({ basePackageId: BASE }))
484+
.rejects.toMatchObject({ statusCode: 409, message: expect.stringContaining(`Package '${BASE}' is a kernel package (scope 'system')`) });
485+
486+
for (const scope of [undefined, BASE]) {
487+
const served = await read(protocol, scope);
488+
expect(columnsOf(served), `read ${scope ?? '(no package)'}`).toEqual(OVERRIDE_COLUMNS);
489+
expect(served._packageId).toBe(BASE);
490+
expect(columnsOf((await layered(protocol, scope)).effective)).toEqual(OVERRIDE_COLUMNS);
491+
}
492+
expect(await listed(protocol)).toEqual([[BASE, OVERRIDE_COLUMNS]]);
493+
494+
// A further change to the override is still written into the pair.
495+
await saveInto(protocol, PAIR, BASE_COLUMNS.slice(0, 3), { overrides: { ...DECLARATION } });
496+
expect(columnsOf(await read(protocol))).toEqual(BASE_COLUMNS.slice(0, 3));
497+
});
498+
499+
it('the closes that named the pair leave a kernel item\'s save open: there is no pair to send it to', async () => {
500+
const body = listBody(UNBOUND_COLUMNS);
501+
// Control: an App's item — the package-less save and the save naming the base are closed onto the pair.
502+
const app = await boot();
503+
await expect(app.protocol.saveMetaItem({ type: 'view', name: VIEW, item: body, mode: 'draft' } as any))
504+
.rejects.toMatchObject({ code: 'NOT_OVERRIDABLE', status: 403, message: expect.stringContaining(PAIR) });
505+
await expect(app.protocol.saveMetaItem({ type: 'view', name: VIEW, item: body, mode: 'draft', packageId: BASE } as any))
506+
.rejects.toMatchObject({ code: 'NOT_OVERRIDABLE', status: 403, message: expect.stringContaining(PAIR) });
507+
508+
// A kernel item: the ensure door creates no pair, so neither close names one.
509+
const kernel = await boot(baseManifest({ scope: 'system' }));
510+
await kernel.protocol.saveMetaItem({ type: 'view', name: VIEW, item: body, mode: 'draft' } as any);
511+
expect(kernel.rowsOf(VIEW).map((r) => r.package_id ?? null)).toEqual([null]);
512+
await kernel.protocol.saveMetaItem({ type: 'view', name: VIEW, item: body, mode: 'draft', packageId: BASE } as any);
513+
expect(kernel.rowsOf(VIEW).map((r) => r.package_id ?? null)).toEqual([null, BASE]);
514+
});
515+
});

‎packages/runtime/src/domains/automation-flow-clone-custom-package.test.ts‎

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -63,8 +63,12 @@ afterAll(() => {
6363

6464
/** `registry.registerObject` requires a package id (see the sibling real-stack tests). */
6565
const TEST_PACKAGE_ID = 'objectstack-test';
66-
/** The base: an installed app the customer cannot author into (a platform scope). */
67-
const BASE = { id: 'com.acme.crm', name: 'CRM', version: '3.4.1', type: 'app', namespace: 'crm', scope: 'system' };
66+
/**
67+
* The base: an installed app the customer cannot author into — held as code,
68+
* the way an installed app's packages are. Not a `system` scope: that is the
69+
* kernel's, which has no pair in this version (ruling record 6691217245).
70+
*/
71+
const BASE = { id: 'com.acme.crm', name: 'CRM', version: '3.4.1', type: 'app', namespace: 'crm' };
6872
const PAIR = 'com.acme.crm.custom';
6973
/** A writable package that depends on the base: a legal explicit target. */
7074
const EXT = { id: 'com.acme.ext', name: 'Ext', version: '1.0.0', type: 'module', namespace: 'ext', dependencies: { [BASE.id]: '^3' } };
@@ -118,7 +122,8 @@ async function boot(options: { parse?: boolean } = {}) {
118122
engine.registry.registerObject(SysMetadataAuditObject as any, TEST_PACKAGE_ID);
119123
await engine.syncSchemas();
120124
(engine.registry as unknown as { logLevel: string }).logLevel = 'silent';
121-
engine.registry.installPackage(BASE as any, 'marketplace');
125+
engine.registry.installPackage(BASE as any, 'code');
126+
(engine as unknown as { manifests: Map<string, unknown> }).manifests.set(BASE.id, BASE);
122127
engine.registry.installPackage(EXT as any, 'code');
123128
engine.registry.installPackage(OTHER as any, 'code');
124129
engine.registry.installPackage(SEALED as any, 'marketplace');

0 commit comments

Comments
 (0)