Skip to content

Commit 38ddd86

Browse files
committed
test(#29594): a copy of a kernel-shipped flow with no package named answers the ensure door's 409
The flow clone door lands the copy in the source's pair through the ensure door; a kernel package has none in this version, so the door relays the 409 and the registration made before the landing is undone: no copy in the engine, no row, no pair. Co-Authored-By: Claude <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01L9qibzCo6pa7SSUFmosQD8
1 parent 3ddfa1c commit 38ddd86

1 file changed

Lines changed: 33 additions & 3 deletions

File tree

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

Lines changed: 33 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -110,7 +110,7 @@ interface Answer {
110110
* protocol refuses (an illegal machine name among it) throws the way the real
111111
* engine throws. The default rig's engine is a map that accepts anything.
112112
*/
113-
async function boot(options: { parse?: boolean } = {}) {
113+
async function boot(options: { parse?: boolean; baseScope?: 'system' | 'cloud' } = {}) {
114114
const engine = new ObjectQL();
115115
liveEngines.push(engine);
116116
engine.registerDriver(new SqlDriver({
@@ -124,8 +124,9 @@ async function boot(options: { parse?: boolean } = {}) {
124124
engine.registry.registerObject(SysMetadataAuditObject as any, TEST_PACKAGE_ID);
125125
await engine.syncSchemas();
126126
(engine.registry as unknown as { logLevel: string }).logLevel = 'silent';
127-
engine.registry.installPackage(BASE as any, 'code');
128-
(engine as unknown as { manifests: Map<string, unknown> }).manifests.set(BASE.id, BASE);
127+
const base = options.baseScope === undefined ? BASE : { ...BASE, scope: options.baseScope };
128+
engine.registry.installPackage(base as any, 'code');
129+
(engine as unknown as { manifests: Map<string, unknown> }).manifests.set(BASE.id, base);
129130
engine.registry.installPackage(EXT as any, 'code');
130131
engine.registry.installPackage(OTHER as any, 'code');
131132
engine.registry.installPackage(SEALED as any, 'marketplace');
@@ -259,6 +260,35 @@ describe('[#28149] the default target: the copy lands in <base>.custom, switched
259260
}, 60_000);
260261
});
261262

263+
/**
264+
* [#29594, ruling record 6691217245] A kernel package (scope `system` /
265+
* `cloud`) has no pair in this version: the ensure door refuses it 409. The
266+
* flow door's default landing IS the ensure door, so a copy of a kernel-shipped
267+
* flow with no `package` named answers that refusal as relayed, and the
268+
* registration made before the landing is undone (`restoreFlowRegistration`):
269+
* the engine holds no copy, nothing is stored, and no pair is created.
270+
*/
271+
describe('[#29594] a kernel-shipped flow: no pair to land the copy in', () => {
272+
for (const baseScope of ['system', 'cloud'] as const) {
273+
it(`scope '${baseScope}', no \`package\` named: 409 with the ensure door's sentence, and the engine holds no copy`, async () => {
274+
const rig = await boot({ baseScope });
275+
const before = [...rig.flows.keys()].sort();
276+
277+
const answer = await rig.clone(SOURCE, { name: 'acme_lead_followup', label: 'Lead follow-up (ACME)' });
278+
279+
expect(answer.status, JSON.stringify(answer.body)).toBe(409);
280+
expect(answer.code).toBe('RESOURCE_CONFLICT');
281+
expect(JSON.stringify(answer.body)).toContain(`Package '${BASE.id}' is a kernel package (scope '${baseScope}')`);
282+
expect(rig.flows.has('acme_lead_followup')).toBe(false);
283+
expect([...rig.flows.keys()].sort()).toEqual(before);
284+
expect(await rig.rows('acme_lead_followup')).toEqual([]);
285+
expect(rig.installed()).not.toContain(PAIR);
286+
// The original keeps running, untouched.
287+
expect(rig.flows.get(SOURCE)?.status).toBe('active');
288+
}, 60_000);
289+
}
290+
});
291+
262292
describe('[#29650, ADR-0146 D2/D4] New similar while the source\'s override is live', () => {
263293
/**
264294
* Customize the base's flow the way Studio does: ensure the pair, save the

0 commit comments

Comments
 (0)