From 42667cd1f5c22d9d5772bebf778b90758ce6ab9e Mon Sep 17 00:00:00 2001 From: Claude Date: Sun, 15 Nov 2026 11:39:01 +0000 Subject: [PATCH] fix(runtime): a channel list with a member off the declared shape is not judged at the automation save doors A getKnownChannels() list with any member that is not { id: string } is now an unreadable registry (not judged), like a reader that throws or answers no list; dropping such members left a roster that refused every channel. The notify-channel-unknown-refused semantic entry now names every not-judged case and the paths a refusal names. Data text only in packages/spec. Co-Authored-By: Claude Claude-Session: https://claude.ai/code/session_01QsR2jUZKdq3PK2Sab53cT3 --- ...-notify-channel-roster-malformed-member.md | 13 ++++++++++++ ...automation-authoring-doors-durable.test.ts | 20 ++++++++++++++++++- packages/runtime/src/domains/automation.ts | 19 ++++++++++-------- .../18.notify-channel-unknown-refused.ts | 12 ++++++----- 4 files changed, 50 insertions(+), 14 deletions(-) create mode 100644 .changeset/32733-notify-channel-roster-malformed-member.md diff --git a/.changeset/32733-notify-channel-roster-malformed-member.md b/.changeset/32733-notify-channel-roster-malformed-member.md new file mode 100644 index 00000000000..e3d6d40c8e7 --- /dev/null +++ b/.changeset/32733-notify-channel-roster-malformed-member.md @@ -0,0 +1,13 @@ +--- +'@objectstack/runtime': patch +'@objectstack/spec': patch +--- + +fix(runtime): a channel list with a member off the declared shape is not judged at the automation save doors, so it no longer refuses every channel + +Clause-②: no +Metadata-protocol: none + +The `/automation` write doors (`POST /api/v1/automation`, `PUT /api/v1/automation/NAME`, `POST /api/v1/automation/NAME/clone`) read the messaging service's `getKnownChannels()` to refuse a `notify` node naming a channel nothing registers. A reader that throws or answers no list was already not judged. A list whose members were not all `{ id: string }` (the declared shape) had those members dropped instead, so a reader answering bare channel ids left an empty roster and every named channel was refused `400 VALIDATION_FAILED`. Such a list is now an unreadable registry like the other two: not judged, and the save goes on as it did before the check existed. No first-party messaging service answers that shape; `MessagingService.getKnownChannels()` answers the declared one, and a flow naming an unknown channel on it is refused exactly as before. + +The `notify-channel-unknown-refused` entry `os migrate meta` prints now lists every not-judged case the doors have (a save before `kernel:ready` has settled, and an unreadable channel reader, beside the four it named) and the paths a refusal names (`nodes.N.config.channels`, `nodes.N.config.channels.M` for a list member, a longer path inside a region body). Data text only. diff --git a/packages/runtime/src/domains/automation-authoring-doors-durable.test.ts b/packages/runtime/src/domains/automation-authoring-doors-durable.test.ts index 5aab987f96a..0170338da8b 100644 --- a/packages/runtime/src/domains/automation-authoring-doors-durable.test.ts +++ b/packages/runtime/src/domains/automation-authoring-doors-durable.test.ts @@ -66,7 +66,9 @@ const storeRefusal = () => Object.assign(new Error('flow/x failed spec validatio * And whether the kernel's `kernel:ready` has settled (`hasBootPhaseSettled`). */ interface ChannelComposition { - messaging?: ReadonlyArray<{ id: string; configured: boolean }> | 'no-reader' | 'reader-throws' | 'reader-not-a-list'; + messaging?: + | ReadonlyArray<{ id: string; configured: boolean }> + | 'no-reader' | 'reader-throws' | 'reader-not-a-list' | 'reader-bare-ids' | 'reader-one-bare-id'; /** `'throws'`: the kernel's boot-phase reader itself throws, so the check cannot finish. */ ready?: boolean | 'throws'; } @@ -101,6 +103,10 @@ function boot({ protocol: mode = 'real', messaging, ready = false }: { protocol? if (messaging === 'no-reader') services.messaging = { emit: async () => ({}) }; else if (messaging === 'reader-throws') services.messaging = { getKnownChannels: () => { throw new Error('registry unreadable'); } }; else if (messaging === 'reader-not-a-list') services.messaging = { getKnownChannels: () => ({ inbox: true }) }; + else if (messaging === 'reader-bare-ids') services.messaging = { getKnownChannels: () => ['inbox', 'email'] }; + else if (messaging === 'reader-one-bare-id') { + services.messaging = { getKnownChannels: () => [{ id: 'inbox', configured: true }, 'email'] }; + } else if (messaging) services.messaging = { getKnownChannels: () => messaging.map((entry) => ({ ...entry })) }; const resolve = (name: string): unknown => services[name]; const kernel = { @@ -387,6 +393,18 @@ describe('a notify node naming a channel no plugin registers is refused at the s } }); + it('a list with any member that is not a `{ id: string }` is unreadable, not judged: a channel it names is never refused', async () => { + // The reader knows `email`, spelled off the declared shape: dropping the + // member would leave a roster without it and refuse the node. + for (const messaging of ['reader-bare-ids', 'reader-one-bare-id'] as const) { + const h = boot({ messaging, ready: true }); + const { response } = await h.dispatcher.handleAutomation('', 'POST', notifyFlowOf(NEW, 'email'), AUTHOR(), undefined); + expect(statusOf(response), messaging).toBe(200); + expect(h.saveMetaItem, messaging).toHaveBeenCalledTimes(1); + expect(h.held(NEW), messaging).toBeDefined(); + } + }); + it('a check that cannot finish undoes the registration before the error leaves: nothing registered-but-unsaved', async () => { const h = boot({ messaging: STOCK_CHANNELS, ready: 'throws' }); const before = h.held(CUSTOMER); diff --git a/packages/runtime/src/domains/automation.ts b/packages/runtime/src/domains/automation.ts index 2ff2dc9a289..9580228d1f0 100644 --- a/packages/runtime/src/domains/automation.ts +++ b/packages/runtime/src/domains/automation.ts @@ -2298,8 +2298,9 @@ function notifyChannelEntries(value: unknown): NotifyChannelEntry[] { * delivers nothing whatever it names (it records a skipped step), and a * messaging service with no `getKnownChannels()` (another implementation of * the service) cannot be enumerated: neither is judged. Nor is a reader - * that throws or answers something other than a list: an unreadable - * registry gives no verdict, and the save goes on as before. + * that throws, answers something other than a list, or answers a list + * with any member that is not a `{ id: string }`: an unreadable registry + * gives no verdict, and the save goes on as before. * * Read per request and recorded nowhere: the answer is the registry as it * stands at this save (AGENTS.md, "Startup registry reads"). @@ -2328,8 +2329,10 @@ async function refuseUnknownNotifyChannels( // A reader that throws, or answers anything but a list, is a registry this // door cannot read: not judged, like a service with no reader at all. The // save goes on as it did before this check existed, and a delivery on an - // unknown channel still reports itself at run time. Members that are not a - // `{ id: string }` are not channels and are left out of the roster. + // unknown channel still reports itself at run time. So is a list with any + // member that is not a `{ id: string }` (the declared `NotifyChannelRegistry` + // shape): dropping such members would leave a roster that misses channels + // the reader does know, and refuse every name it carries. let read: unknown; try { read = messaging.getKnownChannels(); @@ -2337,10 +2340,10 @@ async function refuseUnknownNotifyChannels( return undefined; } if (!Array.isArray(read)) return undefined; - const known = (read as unknown[]).filter( - (entry): entry is { id: string; configured: boolean } => - !!entry && typeof entry === 'object' && typeof (entry as { id?: unknown }).id === 'string', - ); + const isChannel = (entry: unknown): entry is { id: string; configured: boolean } => + !!entry && typeof entry === 'object' && typeof (entry as { id?: unknown }).id === 'string'; + if (!(read as unknown[]).every(isChannel)) return undefined; + const known = read as Array<{ id: string; configured: boolean }>; const knownIds = known.map((entry) => entry.id); const lines: string[] = []; diff --git a/packages/spec/src/migrations/entries/semantic/18.notify-channel-unknown-refused.ts b/packages/spec/src/migrations/entries/semantic/18.notify-channel-unknown-refused.ts index e85b8ab567f..67b864fd1ff 100644 --- a/packages/spec/src/migrations/entries/semantic/18.notify-channel-unknown-refused.ts +++ b/packages/spec/src/migrations/entries/semantic/18.notify-channel-unknown-refused.ts @@ -15,11 +15,13 @@ export const entry: SemanticMigration = { 'A channel is code a plugin registers with the messaging service, so a name nothing registers is a typo or a ' + 'missing plugin. The automation write doors saved such a flow with 200; every delivery on that channel then ' + 'failed at run time with "channel NAME not registered" and a step warning. The doors now refuse it 400 ' - + 'VALIDATION_FAILED at nodes.N.config.channels, naming the node and the channel with a did-you-mean and listing ' - + 'the registered channels. A channel whose transport is not configured yet (email with no email service) is ' - + 'known and still accepted. Not judged: a deployment with no messaging service, a flow a package ships, a flow ' - + 'stored through the metadata door, and a stored row re-registered at boot. There is no mechanical rewrite: ' - + 'only the author knows which channel was meant.', + + 'VALIDATION_FAILED, naming the node and the channel at its path (nodes.N.config.channels, ' + + 'nodes.N.config.channels.M for a list member, a longer path inside a region body) with a did-you-mean and ' + + 'listing the registered channels. A channel whose transport is not configured yet (email with no email ' + + 'service) is known and still accepted. Not judged: a deployment with no messaging service, one whose channel ' + + 'reader throws, answers no list or answers a list with a member that is not a channel, a save before ' + + 'kernel:ready has settled, a flow a package ships, a flow stored through the metadata door, and a stored row ' + + 're-registered at boot. There is no mechanical rewrite: only the author knows which channel was meant.', acceptanceCriteria: 'POST /api/v1/automation with the flow, every notify node naming registered channels, answers 200, and ' + 'GET /api/v1/automation/NAME serves it.',