Skip to content

Commit e4729b3

Browse files
committed
test(runtime): pin the run doors while a holder is disabled; add the changeset
Co-authored-by: Claude <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_016WV4cx5ZPCyTk8ckTsx4ut
1 parent 4c1cd11 commit e4729b3

2 files changed

Lines changed: 77 additions & 1 deletion

File tree

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
---
2+
'@objectstack/runtime': patch
3+
'@objectstack/service-automation': patch
4+
---
5+
6+
fix(runtime,service-automation)!: the flow doors and the connector address judge the served holders of a name two packages hold, so a disabled holder's slot answers no bare name (ADR-0150 D3, #33386)
7+
8+
Clause-②: yes (narrowing)
9+
Metadata-protocol: none
10+
11+
<!-- adr-0087: not-required (no-migration-prescription) No key of any schema is added, removed, renamed or re-shaped, and no export changes shape. The moved answers are door and run reads under a reversible package state: no stored row, slot key, run key or dispatch key changes, so there is nothing for a migration to rewrite and no tombstone. -->
12+
13+
**BREAKING** for a caller of a flow or connector name that two packages hold while one of them is disabled. A disabled package holds no name (ADR-0150 D3). Until now the `/automation` by-name doors, the flow action and endpoint, the start admission's record-read walk and the engine's bare entries still counted a disabled holder for such a name. They now count only the packages that serve it. With no holder disabled, every answer is unchanged. Measured over a real `SchemaRegistry` (its `disablePackage`), in both registration orders. Packages CRM and HR each hold the flow `convert` and the connector `mail`, one engine slot or instance each, and CRM is disabled:
14+
15+
- A bare name with no package (`POST /automation/convert/trigger`, `GET /automation/convert`, the run doors, `GET /automation/connectors/mail/connection`, the engine's `execute`, `getFlow` and `toggleFlow`) was refused 409 naming CRM and HR. It is now served from HR's slot or instance.
16+
- A flow action, a subflow call or a walk read from a package whose closure holds both was refused 409 naming both. It now reaches HR's flow (widening).
17+
- CRM's own flow action, or a subflow call from CRM's own flow, ran CRM's flow. It now gets no flow (not found), and never HR's.
18+
- A package that reaches the name only through CRM ran CRM's flow. It is now refused 409 `outside-closure` naming HR. A package that reaches neither holder is refused naming HR only (before: both).
19+
- An address naming CRM (`/automation/crm/convert/…`, `/automation/trigger/crm/convert`) ran CRM's slot. It is now refused 409 `not-held-by-qualifier` naming HR. `/automation/connectors/crm/mail/connection` reached the service, which answered 404; it is now refused 409 naming HR, and the service is not asked.
20+
- `_env` or another namespace (`/automation/_env/convert/…`, `/automation/connectors/ops/mail/connection`) was refused 409 naming both. It is now refused naming HR only.
21+
- With CRM and HR both disabled, no door and no run reaches a flow. An address answers 404. The bare name and `_env` answer as for a flow the engine does not hold.
22+
23+
**Not moved.** HR's own address and HR's own callers answer as before. The durable coordinates stay judged over every holder, served or not: the engine's slot keys, a run's key, the schedule dispatch key (`flowDispatchHolder`), the credential channel's scoping, the subflow guards' arming verdicts, and which slot a run row is filed under. A disable is reversible, so it re-points no slot. A run filed under CRM's slot key is no served holder's: the run doors answer it as a run nobody holds, and it is never read or acted on as HR's. A definition write (`PUT`/`DELETE`, clone) of the shared name keeps its 409 naming every holder. A name only one package holds is judged as before.
24+
25+
The fix for a caller: re-enable the package, or address the served holder by its namespace.

‎packages/runtime/src/domains/automation-run-doors-per-slot.test.ts‎

Lines changed: 52 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -50,6 +50,8 @@ interface HarnessOptions {
5050
bareKeys?: boolean;
5151
/** `getRun` answers `null` for every run: only the suspended-run list names it. */
5252
getRunBlind?: boolean;
53+
/** [#33386] Packages disabled in the registry: the served holder read leaves them out (the caller's own holding stays). */
54+
disabled?: string[];
5355
}
5456

5557
function harness(options: HarnessOptions = {}) {
@@ -88,10 +90,14 @@ function harness(options: HarnessOptions = {}) {
8890
});
8991
}
9092
const namespaces: Record<string, string> = { [CRM]: 'crm', [HR]: 'hr' };
91-
const holdersOf = (type: string, name: string) => (type === 'flow' && name === NAME ? [CRM, HR] : []);
93+
const disabled = new Set(options.disabled ?? []);
94+
const holdersOf = (type: string, name: string, caller?: string | null, read?: { includeDisabledPackages?: boolean }) =>
95+
(type === 'flow' && name === NAME ? [CRM, HR] : [])
96+
.filter((id) => read?.includeDisabledPackages === true || id === caller || !disabled.has(id));
9297
const registry = {
9398
getNamespaceOwners: (ns: string) => Object.keys(namespaces).filter((id) => namespaces[id] === ns),
9499
packageScopedHoldersOf: holdersOf,
100+
isPackageDisabled: (id: string) => disabled.has(id),
95101
getPackageScopedItem: (type: string, name: string, packageId: string) =>
96102
(holdersOf(type, name).includes(packageId) ? { name, _packageId: packageId } : undefined),
97103
getEnvironmentScopedItem: () => undefined,
@@ -266,3 +272,48 @@ describe('[ADR-0150 D4, #31696] a bare run door on a shared name acts on the run
266272
expect(answer.body?.data?.flowName ?? answer.body?.flowName).toBe(NAME);
267273
});
268274
});
275+
276+
/**
277+
* [ADR-0150 D3, #33386; seat ruling 6884403301, amendments 2 and 3] The run
278+
* doors while a holder is disabled: a run carries its slot key, and a run of
279+
* the disabled holder's slot is no served holder's — never read or acted on
280+
* as another package's, at the bare door or under any address. The served
281+
* holder's run is served at the bare door and under its own address.
282+
*/
283+
/** {@link expectAnsweredAsNobodys} in the same disabled state: the answer the door gives a run nobody holds there. */
284+
async function expectNobodysWhile(disabled: string[], door: Door, prefix: string, runId: string) {
285+
const answer = await send(harness({ disabled }), door, prefix, runId);
286+
const nobody = await send(harness({ disabled }), door, prefix, 'r-nobody');
287+
expect(JSON.stringify(answer).split(runId).join('RUNID'), `${prefix} ${runId}`).toBe(JSON.stringify(nobody).split('r-nobody').join('RUNID'));
288+
}
289+
290+
describe('[#33386] the run doors while a holder is disabled', () => {
291+
for (const door of DOORS) {
292+
describe(door.label, () => {
293+
it('CRM disabled: HR\'s run is served bare and under `hr`; CRM\'s run is nobody\'s at the bare door, and its verb is never called', async () => {
294+
const h = harness({ disabled: [CRM] });
295+
for (const prefix of ['/send_digest', '/hr/send_digest']) {
296+
const answer = await send(h, door, prefix, 'r-hr');
297+
expect(answer.status, `${prefix} ${JSON.stringify(answer.body)}`).toBe(200);
298+
}
299+
expect(verbRunIds(h, door.verb).filter((id: string) => id === 'r-hr').length).toBeGreaterThanOrEqual(door.verb === 'getRun' ? 1 : 2);
300+
await expectNobodysWhile([CRM], door, '/send_digest', 'r-crm');
301+
if (WRITES.has(door.verb)) expect(verbRunIds(h, door.verb)).not.toContain('r-crm');
302+
});
303+
304+
it('CRM disabled: CRM\'s address is refused 409 naming HR only (FROM: CRM\'s run served), nothing acted on', async () => {
305+
const h = harness({ disabled: [CRM] });
306+
const answer = await send(h, door, '/crm/send_digest', 'r-crm');
307+
expect([answer.status, codeOf(answer), candidatesOf(answer)]).toEqual([409, 'RESOURCE_CONFLICT', [{ kind: 'package', packageId: HR }]]);
308+
if (WRITES.has(door.verb)) expect(h.automation[door.verb]).not.toHaveBeenCalled();
309+
});
310+
311+
it('both disabled: either address answers 404; at the bare door each run is nobody\'s', async () => {
312+
const h = harness({ disabled: [CRM, HR] });
313+
for (const prefix of ['/crm/send_digest', '/hr/send_digest']) expect((await send(h, door, prefix, 'r-crm')).status, prefix).toBe(404);
314+
for (const runId of ['r-crm', 'r-hr']) await expectNobodysWhile([CRM, HR], door, '/send_digest', runId);
315+
if (WRITES.has(door.verb)) expect(h.automation[door.verb]).not.toHaveBeenCalled();
316+
});
317+
});
318+
}
319+
});

0 commit comments

Comments
 (0)