From 02e654dbc07f4ac5feffc794f592d5a98845817f Mon Sep 17 00:00:00 2001 From: Claude Date: Sun, 15 Nov 2026 06:05:37 +0000 Subject: [PATCH 1/9] fix(runtime)!: the confirmation an action declares travels with the flow it starts An AI service account does not confirm an action for itself. When an action of type 'flow' whose target is a flow declares ai.requiresConfirmation: true, the trigger routes (POST /automation/:name/trigger and the legacy /automation/trigger/:name) refuse the account with the action door's own 428 ACTION_CONFIRMATION_REQUIRED, through the one flow start admission predicate, before any run exists and whatever the request carries. A person, an OAuth-delegated agent, a flow no confirmation-gated action targets, and the action door's own gate are unchanged. Claude-Session: https://claude.ai/code/session_017xRBcT1w3zpekijraHJE4f Co-authored-by: Claude --- .../flow-start-carries-action-confirmation.md | 16 ++ packages/runtime/src/domains/automation.ts | 46 ++- .../src/endpoint-policy.auth-gate.pin.test.ts | 13 + packages/runtime/src/flow-start-admission.ts | 144 +++++++++- ...ow-start-confirmation-gated-target.test.ts | 262 ++++++++++++++++++ 5 files changed, 469 insertions(+), 12 deletions(-) create mode 100644 .changeset/flow-start-carries-action-confirmation.md create mode 100644 packages/runtime/src/flow-start-confirmation-gated-target.test.ts diff --git a/.changeset/flow-start-carries-action-confirmation.md b/.changeset/flow-start-carries-action-confirmation.md new file mode 100644 index 00000000000..407e675746e --- /dev/null +++ b/.changeset/flow-start-carries-action-confirmation.md @@ -0,0 +1,16 @@ +--- +'@objectstack/runtime': patch +--- + +fix(runtime)!: the confirmation an action declares travels with the flow it starts — an AI service account does not start by name a flow that a confirmation-gated action targets + +Clause-②: no (narrowing) +Metadata-protocol: none + + + +**BREAKING** for an AI service account (an agent principal acting for itself, with no person it acts for) that starts a flow by name. An AI service account does not confirm an action for itself, and the action door already refuses it an action declaring `ai.requiresConfirmation: true` whatever the call sends. The same confirmation now travels with the flow such an action starts: when an action of `type: 'flow'` whose `target` is the flow declares `ai.requiresConfirmation: true`, `POST /api/v1/automation/:name/trigger` and the legacy `POST /api/v1/automation/trigger/:name` refuse the account with the action door's own refusal, `428 ACTION_CONFIRMATION_REQUIRED`, its `details` naming the action and the confirmation member, before any run exists and whatever the request carries (`confirm: true` included). Every declaration of such an action counts, whichever package holds it and whether it is embedded on an object or a standalone item; a read of the declarations that fails refuses the start rather than admitting it. + +**Not moved.** A person, an OAuth-delegated agent and the system principal start the flow as before, and the action declarations are not read for them. An AI service account starts a flow no confirmation-gated action targets as before. The action door's own gate (`POST /api/v1/actions/...` and MCP `run_action`) answers as before. A declared `type: 'flow'` endpoint on its default `authRequired` admits a session only, so an API key is refused there before the flow, as before. + +**Who moves:** an integration that starts such a flow through the trigger routes under an AI service account's own key. A person starts it now (through the trigger route, or through the action, confirming it), as the action door already requires; or the action's author declares `ai.requiresConfirmation: false` when the flow is safe to start unattended. diff --git a/packages/runtime/src/domains/automation.ts b/packages/runtime/src/domains/automation.ts index cb06136162b..fee8ac0d1f7 100644 --- a/packages/runtime/src/domains/automation.ts +++ b/packages/runtime/src/domains/automation.ts @@ -83,6 +83,8 @@ import { flowStartRefusal, isAiServiceAccount } from '../flow-start-admission.js import { apiForwardCredentialKind, callData, + collectActionDeclarations, + readMergedItems, refuseUnreadableFlowStartRecords, type FlowStartRecordKeys, } from '../action-execution.js'; @@ -3004,6 +3006,37 @@ async function unregisterAndDeleteFlow( return undefined; } +/** + * [ADR-0151 D3 rule 3] The action declarations the request's environment + * serves, read the way the `/actions` door reads them + * (`collectActionDeclarations` over the protocol's merged object and action + * listings, else the metadata service's): what flow start admission's rule 2b + * reads, for an AI service account only, to find an action that targets the + * flow and declares `ai.requiresConfirmation: true` + * (`../flow-start-admission.ts`). A host with neither listing serves no action + * declaration, so none is found; a listing that throws travels to the caller, + * which refuses the start rather than admitting it. + */ +async function servedActionDeclarations( + deps: DomainHandlerDeps, + context: HttpProtocolContext, +): Promise> { + const resolved = async (name: string): Promise => { + try { + return await deps.resolveService(context, name, context?.environmentId); + } catch { + return undefined; + } + }; + const protocol = await resolved('protocol'); + if (typeof protocol?.getMetaItems === 'function') { + const objects = await readMergedItems(protocol, 'object'); + const actions = await readMergedItems(protocol, 'action'); + return collectActionDeclarations(deps, undefined, objects, actions); + } + return collectActionDeclarations(deps, await resolved('metadata')); +} + /** * [#9378] The ONE mapper both trigger doors answer through — `POST * /:name/trigger` and the legacy `POST /trigger/:name`, which @@ -3136,12 +3169,23 @@ async function respondToFlowTrigger( // account is therefore refused an elevated (`runAs: 'system'`) flow at // this route, and told where the opt-in stands: an `ai.exposed` action // that targets the flow, run through `/actions` or MCP `run_action`. - const startRefusal = await flowStartRefusal(automationService, flowName, context?.executionContext, { aiExposed: false }); + // + // [ADR-0151 D3 rule 3] And the confirmation an action declares travels + // with what it starts: this door states the environment's action + // declarations, read as the `/actions` door reads them, so an account's + // start of a flow that a confirmation-gated action targets is refused with + // that door's own `428`, whatever the request carries. + const startRefusal = await flowStartRefusal(automationService, flowName, context?.executionContext, { + aiExposed: false, + actionDeclarations: () => servedActionDeclarations(deps, context), + }); if (startRefusal) { + const details = 'details' in startRefusal ? startRefusal.details : undefined; return { handled: true, response: deps.error(startRefusal.message, startRefusal.status, { code: startRefusal.code, + ...(details ?? {}), }), }; } diff --git a/packages/runtime/src/endpoint-policy.auth-gate.pin.test.ts b/packages/runtime/src/endpoint-policy.auth-gate.pin.test.ts index 5fc2a3446a8..ff9a5a509e2 100644 --- a/packages/runtime/src/endpoint-policy.auth-gate.pin.test.ts +++ b/packages/runtime/src/endpoint-policy.auth-gate.pin.test.ts @@ -332,6 +332,19 @@ describe('ADR-0069 at the declared-endpoint fallback (real boot, real socket)', expect(observed.taskReads).toBe(1); }); + // [ADR-0151 D3 rule 3] The declared `type: 'flow'` endpoint is a door that + // starts a flow by name, and an AI service account authenticates by key: + // on the default `authRequired`, a key alone is refused before the + // executor, so no key starts the endpoint's flow there (the trigger routes + // judge the account instead, `flow-start-confirmation-gated-target.test.ts`). + it('API KEY alone: a flow endpoint on the default authRequired answers 401 UNAUTHENTICATED, and its flow never runs', async () => { + const res = await request(WRITE, undefined, { 'x-api-key': API_KEY }); + const text = await res.text(); + expect(res.status, text).toBe(401); + expect((JSON.parse(text) as { error?: { code?: string } }).error?.code).toBe('UNAUTHENTICATED'); + expect(observed.flowRuns, 'the endpoint ran its flow').toBe(0); + }); + it('API KEY beside a held session: the key answers, the session is not asked', async () => { const res = await request(READ, 'u_held_mfa', { 'x-api-key': API_KEY }); expect(res.status, await res.text()).toBe(200); diff --git a/packages/runtime/src/flow-start-admission.ts b/packages/runtime/src/flow-start-admission.ts index fac1b4d2ebc..a9d744d3e8f 100644 --- a/packages/runtime/src/flow-start-admission.ts +++ b/packages/runtime/src/flow-start-admission.ts @@ -14,7 +14,7 @@ * (`action-execution.ts`); * - a declared endpoint of `type: 'flow'` (`endpoint-executor.ts`). * - * Three rules, asked in this order through ONE entry, {@link flowStartRefusal}: + * Four rules, asked in this order through ONE entry, {@link flowStartRefusal}: * * 1. **The elevated self-triggered rule** (the maintainer's ruling, letter B at * the trigger door, extended to every door that starts a flow by name by @@ -40,6 +40,21 @@ * declares an AI opt-in — so at those two an account's start of an * elevated flow is refused, and the refusal names the door that admits * it. No capability opens it either, so it answers before rule 3. + * 2b. **The confirmation an action declares travels with what it starts** + * (ADR-0151 D3 rule 3): an AI service account does not confirm an action + * for itself, and the action door refuses it an action that declares + * `ai.requiresConfirmation: true` whatever the request carries + * (`actionConfirmationRefusal`, `action-execution.ts`). A door that starts + * by NAME a flow such an action targets would start the same run with no + * confirmation asked, so at the doors that state the environment's action + * declarations ({@link FlowStartDoor.actionDeclarations}: the trigger + * routes) an account's start of that flow is refused with the action + * door's own refusal, `428 ACTION_CONFIRMATION_REQUIRED`, naming the + * action, whatever the request carries — no confirmation member is read + * for an account. A person, an OAuth-delegated agent and the system + * principal are not judged by it, and a flow no confirmation-gated action + * targets is admitted as before. No capability opens it, so it answers + * before rule 3. * 3. **The flow's own `requiredPermissions`** (ruling record 6377848497, * letter A): `screen` and `api` flows stay the doors their author designed, * elevated or not, and the flow says who may walk through them. A caller @@ -73,8 +88,9 @@ * asked of the keys the action door did not load itself, and asked at the * trigger routes and a declared endpoint too: a door that hands a run a row * the caller has not shown it can read is the gap this module exists to close. - * It lives beside the load it reuses, so this module imports nothing from - * `action-execution.ts` and the two stay a one-way edge; the declarations it + * It lives beside the load it reuses, so this module imports no value from + * `action-execution.ts` (one type, the confirmation refusal's shape, which + * erases) and the two stay a one-way edge; the declarations it * reads are this module's ({@link flowRunsElevated}, * {@link flowDeclaredRecordReads}). * @@ -105,8 +121,10 @@ * * Admission only. Elevation stays the engine's: the check reads three * declared keys (`type`, `runAs`, `requiredPermissions`) off the definition the - * service serves, and the one fact a door states about itself - * ({@link FlowStartDoor}), and never re-implements the engine's run-as policy. A door's own gates are untouched and keep their + * service serves, what a door states about itself ({@link FlowStartDoor}) — + * its AI opt-in, and the action declarations its environment serves, of + * which it reads three keys (`type`, `target`, `ai.requiresConfirmation`) — + * and never re-implements the engine's run-as policy. A door's own gates are untouched and keep their * place: the action's declared `requiredPermissions` (ADR-0066 D4) still * answers first at the action door, and a declared endpoint's policy chain * (`authRequired`, `rateLimit`) still runs before its executor. This check @@ -116,7 +134,15 @@ import type { FlowParsed } from '@objectstack/spec/automation'; import { collectFlowGraphs } from '@objectstack/spec/automation'; +// The confirmation member's SPELLING is the contract, imported as the action +// door imports it, never hand-spelled (Prime Directive #12). +import { AI_ACTION_CONFIRMATION_MEMBER, type ActionConfirmationRequiredDetails } from '@objectstack/spec/contracts'; +import { isObjectLessActionKey } from '@objectstack/objectql'; +// A TYPE only, erased at runtime: the action door's refusal shape, so the code +// and status rule 2b answers are the action door's own literals, checked at +// compile time, with no value edge back into `action-execution.ts`. +import type { ActionConfirmationRefusal } from './action-execution.js'; import { missingCapabilities } from './required-capabilities.js'; /** @@ -164,7 +190,7 @@ export const ELEVATED_START_REFUSAL = Object.freeze({ * cannot name — and nothing else about the flow: not its name, its type or its * run-as declaration. */ -export function requiredPermissionsRefusal(required: readonly string[], missing: readonly string[]): FlowStartRefusal { +export function requiredPermissionsRefusal(required: readonly string[], missing: readonly string[]): FlowStartPermissionRefusal { return { code: 'PERMISSION_DENIED', status: 403, @@ -195,13 +221,84 @@ export const AI_ACCOUNT_ELEVATED_START_REFUSAL = Object.freeze({ + 'flow, and have the account run that action (the REST actions route or the MCP `run_action` tool).', } as const); -/** The ADR-0112 refusal a door answers for a start it does not admit. */ -export interface FlowStartRefusal { +/** The ADR-0112 `403` a door answers for a start rules 1, 2 and 3 do not admit. */ +export interface FlowStartPermissionRefusal { code: 'PERMISSION_DENIED'; status: 403; message: string; } +/** + * The refusal rule 2b answers: the action door's own (`428 + * ACTION_CONFIRMATION_REQUIRED`, ADR-0112), its code, status and `details` + * typed to that door's shape, so the two cannot drift. ⛔ No new code. + */ +export type FlowStartConfirmationRefusal = ActionConfirmationRefusal; + +/** The ADR-0112 refusal a door answers for a start it does not admit. */ +export type FlowStartRefusal = FlowStartPermissionRefusal | FlowStartConfirmationRefusal; + +/** + * One action declaration a door's environment serves, as the door reads it + * (`collectActionDeclarations`, `action-execution.ts`): the declaration, and + * the object it is declared on or bound to (the object-less key for none). + */ +export interface FlowStartActionDeclaration { + action: unknown; + objectName?: string; +} + +/** + * The action declaration that makes a start of `flowName` confirmation-gated + * (rule 2b), or `undefined`: an action of `type: 'flow'` whose `target` is the + * flow and that declares `ai.requiresConfirmation: true` — the DECLARED flag + * alone, the reading the action door's gate makes (`!== true` is no gate). + * Every holder counts, whichever package declares it: a name two packages + * hold is judged against all of them, so an account is refused rather than + * admitted on a guess about which holder the start reaches. With several, the + * first by object and action name, so the refusal names the same action on + * every call. + */ +export function confirmationGatedStarterOf( + declarations: readonly FlowStartActionDeclaration[], + flowName: string, +): FlowStartActionDeclaration | undefined { + const gated = declarations.filter((row) => { + const action = row?.action as { type?: unknown; target?: unknown; ai?: { requiresConfirmation?: unknown } } | null | undefined; + return action?.type === 'flow' && action.target === flowName && action.ai?.requiresConfirmation === true; + }); + const keyOf = (row: FlowStartActionDeclaration): string => + `${row.objectName ?? ''}\u0000${String((row.action as { name?: unknown }).name ?? '')}`; + return gated.sort((a, b) => (keyOf(a) < keyOf(b) ? -1 : keyOf(a) > keyOf(b) ? 1 : 0))[0]; +} + +/** + * Rule 2b's refusal for `declaration`: the action door's own refusal of an AI + * service account (`actionConfirmationRefusal`), naming the action, its + * object and the confirmation member in `details` as that door does. The + * message states the rule and prescribes no retry: nothing the account adds + * to the request starts this flow. It names the action, which is the thing + * that declares the gate, and nothing of the flow's definition. + */ +export function confirmationGatedStartRefusal(declaration: FlowStartActionDeclaration): FlowStartConfirmationRefusal { + const actionName = String((declaration.action as { name?: unknown }).name ?? ''); + const objectName = isObjectLessActionKey(declaration.objectName) ? undefined : declaration.objectName; + const details: ActionConfirmationRequiredDetails = { + actionName, + ...(objectName ? { objectName } : {}), + confirmationMember: AI_ACTION_CONFIRMATION_MEMBER, + }; + const on = objectName ? ` on '${objectName}'` : ''; + return { + code: 'ACTION_CONFIRMATION_REQUIRED', + status: 428, + message: + `Action '${actionName}'${on} starts this flow and declares ai.requiresConfirmation: true — nothing was run. ` + + 'An AI service account does not confirm an action for itself: a person starts this flow.', + details, + }; +} + /** * Whether `executionContext` is an AI service account's (ADR-0151 D3): the * agent principal that is its own subject, `principalKind: 'agent'` with no @@ -234,6 +331,21 @@ export interface FlowStartDoor { * declares an AI opt-in. */ aiExposed: boolean; + /** + * [ADR-0151 D3 rule 3] Rule 2b's input: the action declarations this + * door's environment serves, read the way the `/actions` door reads them, + * and read ONLY when the caller is an AI service account. Stated by the + * trigger routes, which start a flow by name with no action in hand. A + * read that throws refuses the start (the door answers the failure, and + * nothing runs), never admits it. + * + * The action door states none: the action it runs is asked its own + * confirmation gate first (`actionConfirmationRefusal`), which this rule + * leaves exactly as it is. A declared endpoint states none either: it + * admits a session caller only (an API key is refused before its + * executor), and an AI service account authenticates by key. + */ + actionDeclarations?: () => Promise; } /** @@ -519,7 +631,9 @@ async function declaredReadsOf( * answers for this caller starting `flowName`, or `null` when the start is * admitted. Rule 1 ({@link isElevatedSelfTriggered}) answers first, then rule 2 * (an AI service account at an elevated flow, {@link FlowStartDoor}), then - * rule 3 (the flow's `requiredPermissions`). + * rule 2b (an AI service account at a flow a confirmation-gated action + * targets, {@link FlowStartDoor.actionDeclarations}), then rule 3 (the flow's + * `requiredPermissions`). * * What stays exactly as it was, and why each is outside this check: * @@ -535,8 +649,8 @@ async function declaredReadsOf( * - **A flow that declares no `requiredPermissions`** (or an empty list) and is * not elevated-and-self-triggered: admitted, as before — for every caller * but an AI service account at an elevated flow, which rule 2 judges. - * - **A person, and an OAuth-delegated agent**, are not judged by rule 2: it - * reads the account alone ({@link isAiServiceAccount}). The delegated + * - **A person, and an OAuth-delegated agent**, are not judged by rule 2 or + * rule 2b: each reads the account alone ({@link isAiServiceAccount}). The delegated * agent's token is honoured on the MCP endpoint only, where `run_action` * asks the opt-in of every action. * - **A flow that runs as the user**: an account starts it as before, and the @@ -572,6 +686,14 @@ export async function flowStartRefusal( if (flow.runAs === 'system' && isAiServiceAccount(executionContext) && door.aiExposed !== true) { return AI_ACCOUNT_ELEVATED_START_REFUSAL; } + // [ADR-0151 D3 rule 3] Rule 2b: the confirmation an action declares + // travels with what it starts. Asked of an account alone, so the + // declarations are read for no other caller; nothing the request carries + // is read here, so no confirmation member admits an account. + if (isAiServiceAccount(executionContext) && door.actionDeclarations) { + const gated = confirmationGatedStarterOf(await door.actionDeclarations(), flowName); + if (gated) return confirmationGatedStartRefusal(gated); + } const missing = missingCapabilities(flow.requiredPermissions, executionContext); if (missing.length > 0) return requiredPermissionsRefusal(flow.requiredPermissions as string[], missing); return null; diff --git a/packages/runtime/src/flow-start-confirmation-gated-target.test.ts b/packages/runtime/src/flow-start-confirmation-gated-target.test.ts new file mode 100644 index 00000000000..34e03758f83 --- /dev/null +++ b/packages/runtime/src/flow-start-confirmation-gated-target.test.ts @@ -0,0 +1,262 @@ +// Copyright (c) 2026 ObjectStack. Licensed under the Apache-2.0 license. + +/** + * The confirmation an action declares travels with what it starts (ADR-0151 + * D3 rule 3; `flow-start-admission.ts`, rule 2b). + * + * An AI service account (`principalKind: 'agent'`, no `onBehalfOf`) does not + * confirm an action for itself, so the action door refuses it an action that + * declares `ai.requiresConfirmation: true`, whatever the request carries. The + * trigger routes start a flow by name; when such an action targets the flow, + * they refuse the account with the action door's own refusal (`428 + * ACTION_CONFIRMATION_REQUIRED`) through the one flow start admission + * predicate, before any run exists, whatever the request carries. + * + * CONTROLS, each on the same harness: a person and an OAuth-delegated agent + * start the flow as before; a flow no confirmation-gated action targets is + * still started by the account; the action door's own gate still answers its + * 428 to the account. The declared `type: 'flow'` endpoint, the third door that + * starts a flow by name, admits a session only and refuses an API key before + * its executor: pinned on a real boot in `endpoint-policy.auth-gate.pin.test.ts`. + * + * Driven with a scripted automation service, as the other flow start + * admission pins are (`flow-start-required-permissions.test.ts`): `getFlow` + * serves the declaration, and `execute` is a spy, so "nothing ran" is a fact + * about the engine call rather than an inference from a status code. + */ + +import { describe, it, expect, vi } from 'vitest'; +// The dispatcher's reach loads `@objectstack/metadata` inside a function body +// (`standalone-stack.ts`); paid here, during collection, so no case's clocked +// window pays that first load (`check:test-source-alias`). +import '@objectstack/metadata'; + +import { HttpDispatcher } from './http-dispatcher.js'; +import { confirmationGatedStarterOf } from './flow-start-admission.js'; + +const OBJECT = 'fcg_invoice'; +const FLOW = 'fcg_void_invoice'; +const OTHER_FLOW = 'fcg_send_reminder'; +const GATED_ACTION = 'void_invoice'; + +/** An AI service account with zero grants: the agent principal that is its own subject. */ +const ACCOUNT_EC = { userId: 'acct_1', principalKind: 'agent', systemPermissions: [] as string[] }; +/** A person, signed in, holding nothing. */ +const PERSON_EC = { userId: 'u_person', principalKind: 'human', systemPermissions: [] as string[] }; +/** An OAuth-delegated agent acting for the person it names. */ +const DELEGATED_EC = { + userId: 'u_person', + principalKind: 'agent', + systemPermissions: [] as string[], + onBehalfOf: { userId: 'u_person', principalKind: 'human' }, +}; + +const ROUTES = { + 'POST /automation/:name/trigger': `/${FLOW}/trigger`, + 'POST /automation/trigger/:name (legacy)': `/trigger/${FLOW}`, +} as const; +type Route = keyof typeof ROUTES; +const ROUTE_NAMES = Object.keys(ROUTES) as Route[]; + +/** The request bodies an account may send: none of them confirms for it. */ +const BODIES = { + 'without confirm': {}, + 'with confirm: true': { confirm: true }, + 'with confirm: true beside params': { params: {}, confirm: true }, +} as const; + +interface Answer { status: number; code?: string; details?: Record } + +type Source = 'object' | 'standalone' | 'merged'; + +interface Harness { + /** Whether the action that targets {@link FLOW} declares `ai.requiresConfirmation: true`. */ + gated?: boolean; + /** Where the action is declared: embedded on the object, a standalone item, or the protocol's merged listing. */ + source?: Source; + /** The gated action targets this flow instead of {@link FLOW}. */ + target?: string; + /** The listing read throws. */ + listingFails?: boolean; +} + +/** One user-run screen flow, the action that targets it, and the trigger routes and action door over them. */ +function makeDoors(opts: Harness = {}) { + const { gated = true, source = 'object', target = FLOW, listingFails = false } = opts; + const execute = vi.fn(async (_name: string, _context?: unknown) => ({ success: true, output: {} })); + const getFlow = vi.fn(async (name: string) => + name === FLOW || name === OTHER_FLOW ? { name, type: 'screen', runAs: 'user' } : null); + const automation: Record = { execute, getFlow }; + + const action = { + name: GATED_ACTION, + label: 'Void invoice', + objectName: OBJECT, + type: 'flow', + target, + ai: { + exposed: true, + description: 'Voids the invoice through its flow, for this test.', + ...(gated ? { requiresConfirmation: true } : {}), + }, + }; + const objectDef = { name: OBJECT, actions: source === 'object' ? [action] : [] }; + const standalone = source === 'standalone' ? [action] : []; + const schemaOf = (n: string) => (n === OBJECT ? objectDef : undefined); + const ql: any = { + executeAction: vi.fn(async () => ({ ran: 'script' })), + getSchema: schemaOf, + registry: { getObject: schemaOf, getItem: () => undefined }, + find: vi.fn(async () => []), + insert: vi.fn(), update: vi.fn(), delete: vi.fn(), + }; + const listObjects = vi.fn(async () => { + if (listingFails) throw new Error('metadata listing unavailable'); + return [objectDef]; + }); + const metadata: any = { + load: vi.fn(async () => null), + loadDiagnosed: vi.fn(async () => ({ data: null, degraded: false, errors: [] })), + listObjects, + loadMany: vi.fn(async (type: string) => (type === 'action' ? standalone : [])), + getObject: vi.fn(async (n: string) => schemaOf(n)), + }; + const getMetaItems = vi.fn(async ({ type }: { type: string }) => ({ + type, + items: type === 'object' ? [{ ...objectDef, actions: [] }] : type === 'action' ? [action] : [], + })); + const protocol = source === 'merged' ? { getMetaItems } : null; + const resolve = (n: string) => + n === 'objectql' || n === 'data' ? ql + : n === 'metadata' ? metadata + : n === 'automation' ? automation + : n === 'protocol' ? protocol + : null; + const kernel: any = { getService: resolve, getServiceAsync: async (n: string) => resolve(n), context: { getService: resolve } }; + const dispatcher = new HttpDispatcher(kernel); + + const trigger = async (route: Route, ec: unknown, body: unknown = {}): Promise => { + const res: any = await dispatcher.handleAutomation(ROUTES[route], 'POST', body, { + request: {}, executionContext: ec, + } as any); + const error = res.response?.body?.error; + return { status: res.response?.status, code: error?.code, details: error?.details }; + }; + + const actionDoor = async (ec: unknown, body: unknown = {}): Promise => { + const res: any = await dispatcher.handleActions(`/${OBJECT}/${GATED_ACTION}`, 'POST', body, { + request: {}, environmentId: 'platform', executionContext: ec, + } as any); + const error = res.response?.body?.error; + return { status: res.response?.status, code: error?.code, details: error?.details }; + }; + + return { trigger, actionDoor, execute, listObjects, getMetaItems }; +} + +/** The action door's own refusal, as the trigger routes answer it, and nothing ran. */ +function expectConfirmationRefusal(answer: Answer, execute: ReturnType): void { + expect(answer.status).toBe(428); + expect(answer.code).toBe('ACTION_CONFIRMATION_REQUIRED'); + expect(answer.details).toMatchObject({ actionName: GATED_ACTION, objectName: OBJECT, confirmationMember: 'confirm' }); + expect(execute).not.toHaveBeenCalled(); +} + +describe('an AI service account does not start, by name, a flow that a confirmation-gated action targets', () => { + for (const route of ROUTE_NAMES) { + for (const [label, body] of Object.entries(BODIES)) { + it(`${route}: the account is refused 428 ACTION_CONFIRMATION_REQUIRED ${label}, and nothing runs`, async () => { + const { trigger, execute } = makeDoors(); + + expectConfirmationRefusal(await trigger(route, ACCOUNT_EC, body), execute); + }); + } + + for (const source of ['standalone', 'merged'] as const) { + it(`${route}: the gated action counts wherever it is declared (${source} listing)`, async () => { + const { trigger, execute } = makeDoors({ source }); + + expectConfirmationRefusal(await trigger(route, ACCOUNT_EC, { confirm: true }), execute); + }); + } + + it(`${route}: an action-declaration read that fails refuses the account's start, and nothing runs`, async () => { + const { trigger, execute } = makeDoors({ listingFails: true }); + + const answer = await trigger(route, ACCOUNT_EC); + + expect(answer.status).toBeGreaterThanOrEqual(400); + expect(execute).not.toHaveBeenCalled(); + }); + } +}); + +describe('CONTROLS — what the confirmation-gated start rule leaves exactly as it was', () => { + for (const route of ROUTE_NAMES) { + it(`${route}: a person still starts the flow, and the action declarations are not read for one`, async () => { + const { trigger, execute, listObjects } = makeDoors(); + + const answer = await trigger(route, PERSON_EC); + + expect(answer.status).toBe(200); + expect(execute).toHaveBeenCalledTimes(1); + expect(execute.mock.calls[0]?.[0]).toBe(FLOW); + expect(listObjects).not.toHaveBeenCalled(); + }); + + it(`${route}: an OAuth-delegated agent is unchanged — it starts the flow`, async () => { + const { trigger, execute } = makeDoors(); + + expect((await trigger(route, DELEGATED_EC)).status).toBe(200); + expect(execute).toHaveBeenCalledTimes(1); + }); + + it(`${route}: a flow no confirmation-gated action targets is still started by the account`, async () => { + const { trigger, execute } = makeDoors({ gated: false }); + + expect((await trigger(route, ACCOUNT_EC)).status).toBe(200); + expect(execute).toHaveBeenCalledTimes(1); + }); + + it(`${route}: a confirmation-gated action that targets ANOTHER flow does not gate this one`, async () => { + const { trigger, execute } = makeDoors({ target: OTHER_FLOW }); + + expect((await trigger(route, ACCOUNT_EC)).status).toBe(200); + expect(execute).toHaveBeenCalledTimes(1); + }); + } + + it('the action door\'s own gate still answers its 428 to the account, with and without confirm, and nothing runs', async () => { + for (const body of [{}, { confirm: true }]) { + const { actionDoor, execute } = makeDoors(); + + const answer = await actionDoor(ACCOUNT_EC, body); + + expect(answer.status).toBe(428); + expect(answer.code).toBe('ACTION_CONFIRMATION_REQUIRED'); + expect(answer.details).toMatchObject({ actionName: GATED_ACTION, confirmationMember: 'confirm' }); + expect(execute).not.toHaveBeenCalled(); + } + }); +}); + +describe('confirmationGatedStarterOf — which declaration gates a start', () => { + const row = (name: string, action: Record, objectName = OBJECT) => ({ action: { name, ...action }, objectName }); + + it('reads the declared flag alone: an action of type flow whose target is the flow and that declares ai.requiresConfirmation: true', () => { + const gated = row('a', { type: 'flow', target: FLOW, ai: { requiresConfirmation: true } }); + expect(confirmationGatedStarterOf([gated], FLOW)).toBe(gated); + // Controls: the same row with each of the three facts changed gates nothing. + expect(confirmationGatedStarterOf([row('a', { type: 'flow', target: FLOW, ai: { requiresConfirmation: false } })], FLOW)).toBeUndefined(); + expect(confirmationGatedStarterOf([row('a', { type: 'flow', target: FLOW, ai: { requiresConfirmation: 'true' } })], FLOW)).toBeUndefined(); + expect(confirmationGatedStarterOf([row('a', { type: 'script', target: FLOW, ai: { requiresConfirmation: true } })], FLOW)).toBeUndefined(); + expect(confirmationGatedStarterOf([row('a', { type: 'flow', target: OTHER_FLOW, ai: { requiresConfirmation: true } })], FLOW)).toBeUndefined(); + }); + + it('names the same action on every call when several gate the flow', () => { + const b = row('b_action', { type: 'flow', target: FLOW, ai: { requiresConfirmation: true } }); + const a = row('a_action', { type: 'flow', target: FLOW, ai: { requiresConfirmation: true } }); + expect(confirmationGatedStarterOf([b, a], FLOW)).toBe(a); + expect(confirmationGatedStarterOf([a, b], FLOW)).toBe(a); + }); +}); From 3b8efa32f0efd606e1a5334c24e1f01ee7f26b45 Mon Sep 17 00:00:00 2001 From: Claude Date: Sun, 15 Nov 2026 06:09:36 +0000 Subject: [PATCH 2/9] fix(runtime): a failed action-declaration read refuses the account's start 503 Claude-Session: https://claude.ai/code/session_017xRBcT1w3zpekijraHJE4f Co-authored-by: Claude --- packages/runtime/src/domains/automation.ts | 16 ++++++++++++---- .../flow-start-confirmation-gated-target.test.ts | 5 +++-- 2 files changed, 15 insertions(+), 6 deletions(-) diff --git a/packages/runtime/src/domains/automation.ts b/packages/runtime/src/domains/automation.ts index fee8ac0d1f7..e7e6b996e1c 100644 --- a/packages/runtime/src/domains/automation.ts +++ b/packages/runtime/src/domains/automation.ts @@ -3175,10 +3175,18 @@ async function respondToFlowTrigger( // declarations, read as the `/actions` door reads them, so an account's // start of a flow that a confirmation-gated action targets is refused with // that door's own `428`, whatever the request carries. - const startRefusal = await flowStartRefusal(automationService, flowName, context?.executionContext, { - aiExposed: false, - actionDeclarations: () => servedActionDeclarations(deps, context), - }); + // + // A declaration read that fails is the metadata plane failing to answer + // (ADR-0110 D3): `503`, and nothing runs — never an admitted start. + let startRefusal: Awaited>; + try { + startRefusal = await flowStartRefusal(automationService, flowName, context?.executionContext, { + aiExposed: false, + actionDeclarations: () => servedActionDeclarations(deps, context), + }); + } catch (err) { + return { handled: true, response: deps.errorFromThrown(err, 503) }; + } if (startRefusal) { const details = 'details' in startRefusal ? startRefusal.details : undefined; return { diff --git a/packages/runtime/src/flow-start-confirmation-gated-target.test.ts b/packages/runtime/src/flow-start-confirmation-gated-target.test.ts index 34e03758f83..920a80dfca2 100644 --- a/packages/runtime/src/flow-start-confirmation-gated-target.test.ts +++ b/packages/runtime/src/flow-start-confirmation-gated-target.test.ts @@ -180,12 +180,13 @@ describe('an AI service account does not start, by name, a flow that a confirmat }); } - it(`${route}: an action-declaration read that fails refuses the account's start, and nothing runs`, async () => { + it(`${route}: an action-declaration read that fails refuses the account's start 503, and nothing runs`, async () => { const { trigger, execute } = makeDoors({ listingFails: true }); const answer = await trigger(route, ACCOUNT_EC); - expect(answer.status).toBeGreaterThanOrEqual(400); + expect(answer.status).toBe(503); + expect(answer.code).toBe('SERVICE_UNAVAILABLE'); expect(execute).not.toHaveBeenCalled(); }); } From 14697389524965e9a4be667bfd695fcb50c9208f Mon Sep 17 00:00:00 2001 From: Claude Date: Sun, 15 Nov 2026 07:00:19 +0000 Subject: [PATCH 3/9] test(runtime): the endpoint auth pin pays the metadata load during collection Claude-Session: https://claude.ai/code/session_017xRBcT1w3zpekijraHJE4f Co-authored-by: Claude --- packages/runtime/src/endpoint-policy.auth-gate.pin.test.ts | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/packages/runtime/src/endpoint-policy.auth-gate.pin.test.ts b/packages/runtime/src/endpoint-policy.auth-gate.pin.test.ts index ff9a5a509e2..968598945d3 100644 --- a/packages/runtime/src/endpoint-policy.auth-gate.pin.test.ts +++ b/packages/runtime/src/endpoint-policy.auth-gate.pin.test.ts @@ -41,6 +41,10 @@ */ import { describe, it, expect, beforeAll, afterAll, beforeEach, vi } from 'vitest'; +// The dispatcher's reach loads `@objectstack/metadata` inside a function body +// (`standalone-stack.ts`); paid here, during collection, so no case's clocked +// window pays that first load (`check:test-source-alias`). +import '@objectstack/metadata'; import { LiteKernel, Plugin, PluginContext, isAuthGateAllowlisted, hashApiKey } from '@objectstack/core'; import { HonoServerPlugin } from '@objectstack/plugin-hono-server'; import { ApiEndpointSchema, type ApiEndpoint } from '@objectstack/spec/api'; From 42c1c3c79561d2718adddedee6b53f2e0f122d4d Mon Sep 17 00:00:00 2001 From: Claude Date: Sun, 15 Nov 2026 07:50:38 +0000 Subject: [PATCH 4/9] fix(runtime): rule 2b tells a failed listing service from an absent one, reads every bare-door source, and is asked without the flow probe A listing service that is wired and fails to resolve refuses an AI service account's start as a throwing listing does, with one flat 503 owned by the predicate and confined to the declaration read. On a host with neither merged listing the rule reads the ObjectQL registry and the metadata service, as the bare actions door does. The rule reads the flow's name and the declarations only, so it is asked without the definition probe. The docs state that the declared-endpoint door is not judged by it yet. Claude-Session: https://claude.ai/code/session_017xRBcT1w3zpekijraHJE4f Co-authored-by: Claude --- .../flow-start-carries-action-confirmation.md | 6 +- packages/runtime/src/domains/automation.ts | 74 ++++++------ packages/runtime/src/flow-start-admission.ts | 103 +++++++++++------ ...ow-start-confirmation-gated-target.test.ts | 106 ++++++++++++++++-- 4 files changed, 210 insertions(+), 79 deletions(-) diff --git a/.changeset/flow-start-carries-action-confirmation.md b/.changeset/flow-start-carries-action-confirmation.md index 407e675746e..c57e6b5fa49 100644 --- a/.changeset/flow-start-carries-action-confirmation.md +++ b/.changeset/flow-start-carries-action-confirmation.md @@ -9,8 +9,8 @@ Metadata-protocol: none -**BREAKING** for an AI service account (an agent principal acting for itself, with no person it acts for) that starts a flow by name. An AI service account does not confirm an action for itself, and the action door already refuses it an action declaring `ai.requiresConfirmation: true` whatever the call sends. The same confirmation now travels with the flow such an action starts: when an action of `type: 'flow'` whose `target` is the flow declares `ai.requiresConfirmation: true`, `POST /api/v1/automation/:name/trigger` and the legacy `POST /api/v1/automation/trigger/:name` refuse the account with the action door's own refusal, `428 ACTION_CONFIRMATION_REQUIRED`, its `details` naming the action and the confirmation member, before any run exists and whatever the request carries (`confirm: true` included). Every declaration of such an action counts, whichever package holds it and whether it is embedded on an object or a standalone item; a read of the declarations that fails refuses the start rather than admitting it. +**BREAKING** for an AI service account (an agent principal acting for itself, with no person it acts for) that starts a flow by name. An AI service account does not confirm an action for itself, and the action door already refuses it an action declaring `ai.requiresConfirmation: true` whatever the call sends. The same confirmation now travels with the flow such an action starts: when an action of `type: 'flow'` whose `target` is the flow declares `ai.requiresConfirmation: true`, `POST /api/v1/automation/:name/trigger` and the legacy `POST /api/v1/automation/trigger/:name` refuse the account with the action door's own refusal, `428 ACTION_CONFIRMATION_REQUIRED`, its `details` naming the action and the confirmation member, before any run exists and whatever the request carries (`confirm: true` included). Every declaration of such an action counts, whichever package holds it and whether it is embedded on an object or a standalone item. A read of the declarations that fails, or a metadata service that is wired and fails to resolve, refuses the start `503 SERVICE_UNAVAILABLE` rather than admitting it. The rule reads the flow's name and the declarations, not the flow's definition. It is asked at the two trigger routes; the declared `type: 'flow'` endpoint door is not judged by it yet. -**Not moved.** A person, an OAuth-delegated agent and the system principal start the flow as before, and the action declarations are not read for them. An AI service account starts a flow no confirmation-gated action targets as before. The action door's own gate (`POST /api/v1/actions/...` and MCP `run_action`) answers as before. A declared `type: 'flow'` endpoint on its default `authRequired` admits a session only, so an API key is refused there before the flow, as before. +**Not moved.** A person, an OAuth-delegated agent and the system principal start the flow as before, and the action declarations are not read for them. An AI service account starts a flow no confirmation-gated action targets as before. The action door's own gate (`POST /api/v1/actions/...` and MCP `run_action`) answers as before. A declared `type: 'flow'` endpoint answers as before; on its default `authRequired` it admits a session only, so an API key is refused there before the flow. -**Who moves:** an integration that starts such a flow through the trigger routes under an AI service account's own key. A person starts it now (through the trigger route, or through the action, confirming it), as the action door already requires; or the action's author declares `ai.requiresConfirmation: false` when the flow is safe to start unattended. +**Who moves:** an integration that starts such a flow through the trigger routes under an AI service account's own key. The rule refuses on the safe side in three cases, each an account start only: every holder of the flow's name counts, so an account starting one package's flow is refused when another package's confirmation-gated action targets a flow of the same name; a confirmation-gated action the action door would refuse for another reason (an action switched off) still gates the flow; and on a host whose merged metadata listing is not served at all, every start by an account is refused `503`, a flow no gated action targets included. A person starts it now (through the trigger route, or through the action, confirming it), as the action door already requires; or the action's author declares `ai.requiresConfirmation: false` when the flow is safe to start unattended. diff --git a/packages/runtime/src/domains/automation.ts b/packages/runtime/src/domains/automation.ts index e7e6b996e1c..ddca1e87751 100644 --- a/packages/runtime/src/domains/automation.ts +++ b/packages/runtime/src/domains/automation.ts @@ -3008,33 +3008,50 @@ async function unregisterAndDeleteFlow( /** * [ADR-0151 D3 rule 3] The action declarations the request's environment - * serves, read the way the `/actions` door reads them - * (`collectActionDeclarations` over the protocol's merged object and action - * listings, else the metadata service's): what flow start admission's rule 2b - * reads, for an AI service account only, to find an action that targets the - * flow and declares `ai.requiresConfirmation: true` - * (`../flow-start-admission.ts`). A host with neither listing serves no action - * declaration, so none is found; a listing that throws travels to the caller, - * which refuses the start rather than admitting it. + * serves: what flow start admission's rule 2b reads, for an AI service + * account only, to find an action that targets the flow and declares + * `ai.requiresConfirmation: true` (`../flow-start-admission.ts`). Every row is + * a `collectActionDeclarations` row, from these sources: + * + * - where the `protocol` slot serves the merged listings (`getMetaItems`), its + * merged object and action listings alone — the reading the addressed + * `/actions` door, the bare door's holder rule and the MCP bridge make; + * - otherwise every source the bare `/actions` door resolves a declaration + * from on such a host: the ObjectQL registry's objects (their embedded + * actions) and standalone `action` items, and the metadata service's + * object and action listings. + * + * Absence and failure are told apart, as at every gate that reads an + * authorization fact (`resolveServiceOrLoud`): a slot nothing registered is + * absent and contributes nothing, while a slot that is wired and fails to + * resolve throws, as a listing that throws does, and the predicate refuses + * the start `503`. So a host that serves no declaration from any of these + * sources finds none, and a read that did not happen admits nothing. */ async function servedActionDeclarations( deps: DomainHandlerDeps, context: HttpProtocolContext, ): Promise> { - const resolved = async (name: string): Promise => { - try { - return await deps.resolveService(context, name, context?.environmentId); - } catch { - return undefined; - } - }; - const protocol = await resolved('protocol'); + const envId = context?.environmentId; + const protocol = await deps.resolveServiceOrLoud(context, 'protocol', envId); if (typeof protocol?.getMetaItems === 'function') { const objects = await readMergedItems(protocol, 'object'); const actions = await readMergedItems(protocol, 'action'); return collectActionDeclarations(deps, undefined, objects, actions); } - return collectActionDeclarations(deps, await resolved('metadata')); + const rows: Array<{ action: unknown; objectName: string }> = []; + const engine = (await deps.getObjectQL(context, envId)) as + | { registry?: { listItems?: (type: string) => unknown[] } } + | null; + const registry = engine?.registry; + if (typeof registry?.listItems === 'function') { + rows.push(...await collectActionDeclarations(deps, undefined, registry.listItems('object'), registry.listItems('action'))); + } + const metadata = await deps.resolveServiceOrLoud(context, 'metadata', envId); + if (typeof metadata?.listObjects === 'function' || typeof metadata?.loadMany === 'function') { + rows.push(...await collectActionDeclarations(deps, metadata)); + } + return rows; } /** @@ -3172,21 +3189,14 @@ async function respondToFlowTrigger( // // [ADR-0151 D3 rule 3] And the confirmation an action declares travels // with what it starts: this door states the environment's action - // declarations, read as the `/actions` door reads them, so an account's - // start of a flow that a confirmation-gated action targets is refused with - // that door's own `428`, whatever the request carries. - // - // A declaration read that fails is the metadata plane failing to answer - // (ADR-0110 D3): `503`, and nothing runs — never an admitted start. - let startRefusal: Awaited>; - try { - startRefusal = await flowStartRefusal(automationService, flowName, context?.executionContext, { - aiExposed: false, - actionDeclarations: () => servedActionDeclarations(deps, context), - }); - } catch (err) { - return { handled: true, response: deps.errorFromThrown(err, 503) }; - } + // declarations (`servedActionDeclarations`), so an account's start of a + // flow that a confirmation-gated action targets is refused with the action + // door's own `428`, whatever the request carries. A declaration read that + // fails is refused by the predicate itself, a flat `503`, and nothing runs. + const startRefusal = await flowStartRefusal(automationService, flowName, context?.executionContext, { + aiExposed: false, + actionDeclarations: () => servedActionDeclarations(deps, context), + }); if (startRefusal) { const details = 'details' in startRefusal ? startRefusal.details : undefined; return { diff --git a/packages/runtime/src/flow-start-admission.ts b/packages/runtime/src/flow-start-admission.ts index a9d744d3e8f..6e062859d09 100644 --- a/packages/runtime/src/flow-start-admission.ts +++ b/packages/runtime/src/flow-start-admission.ts @@ -46,15 +46,19 @@ * `ai.requiresConfirmation: true` whatever the request carries * (`actionConfirmationRefusal`, `action-execution.ts`). A door that starts * by NAME a flow such an action targets would start the same run with no - * confirmation asked, so at the doors that state the environment's action - * declarations ({@link FlowStartDoor.actionDeclarations}: the trigger - * routes) an account's start of that flow is refused with the action - * door's own refusal, `428 ACTION_CONFIRMATION_REQUIRED`, naming the - * action, whatever the request carries — no confirmation member is read - * for an account. A person, an OAuth-delegated agent and the system - * principal are not judged by it, and a flow no confirmation-gated action - * targets is admitted as before. No capability opens it, so it answers - * before rule 3. + * confirmation asked, so at a door that states the environment's action + * declarations ({@link FlowStartDoor.actionDeclarations}) an account's + * start of that flow is refused with the action door's own refusal, `428 + * ACTION_CONFIRMATION_REQUIRED`, naming the action, whatever the request + * carries — no confirmation member is read for an account — and a + * declaration read that fails refuses it `503`. The rule is asked at the + * two trigger routes; the declared-endpoint door is not judged by it yet, + * and the action door keeps its own confirmation gate. It reads the flow's + * name and the declarations only, never the definition, so a service + * that cannot serve the definition is judged by it too. A person, an + * OAuth-delegated agent and the system principal are not judged by it, + * and a flow no confirmation-gated action targets is admitted as before. + * No capability opens it, so it answers before rule 3. * 3. **The flow's own `requiredPermissions`** (ruling record 6377848497, * letter A): `screen` and `api` flows stay the doors their author designed, * elevated or not, and the flow says who may walk through them. A caller @@ -235,8 +239,27 @@ export interface FlowStartPermissionRefusal { */ export type FlowStartConfirmationRefusal = ActionConfirmationRefusal; +/** + * The refusal rule 2b answers when the door's action declarations could not be + * read (ADR-0110 D3: the metadata plane failing to answer): a flat `503 + * SERVICE_UNAVAILABLE`, whatever the failure declared, so a start an account + * could not be judged for is refused and never admitted. The standard-catalog + * code (ADR-0112); ⛔ no new code. The message names no flow, no action and + * nothing of the failure. + */ +export const DECLARATION_READ_FAILED_REFUSAL = Object.freeze({ + code: 'SERVICE_UNAVAILABLE', + status: 503, + message: + 'The action declarations this start is judged against could not be read — nothing was run. ' + + 'Retry once the metadata service answers.', +} as const); + +/** The ADR-0112 `503` rule 2b answers when it could not read the declarations it judges. */ +export type FlowStartUnavailableRefusal = typeof DECLARATION_READ_FAILED_REFUSAL; + /** The ADR-0112 refusal a door answers for a start it does not admit. */ -export type FlowStartRefusal = FlowStartPermissionRefusal | FlowStartConfirmationRefusal; +export type FlowStartRefusal = FlowStartPermissionRefusal | FlowStartConfirmationRefusal | FlowStartUnavailableRefusal; /** * One action declaration a door's environment serves, as the door reads it @@ -333,17 +356,18 @@ export interface FlowStartDoor { aiExposed: boolean; /** * [ADR-0151 D3 rule 3] Rule 2b's input: the action declarations this - * door's environment serves, read the way the `/actions` door reads them, - * and read ONLY when the caller is an AI service account. Stated by the - * trigger routes, which start a flow by name with no action in hand. A - * read that throws refuses the start (the door answers the failure, and - * nothing runs), never admits it. + * door's environment serves, read ONLY when the caller is an AI service + * account. A door that states none is not judged by rule 2b. A read that + * throws (a listing, or the service it is read from failing to resolve) + * refuses the start with {@link DECLARATION_READ_FAILED_REFUSAL}, a flat + * `503`, and nothing runs; it never admits it. * + * Rule 2b is asked at the two trigger routes, which state the + * declarations (`servedActionDeclarations`, `domains/automation.ts`). The + * declared-endpoint door states none, so it is not judged by rule 2b yet. * The action door states none: the action it runs is asked its own * confirmation gate first (`actionConfirmationRefusal`), which this rule - * leaves exactly as it is. A declared endpoint states none either: it - * admits a session caller only (an API key is refused before its - * executor), and an AI service account authenticates by key. + * leaves exactly as it is. */ actionDeclarations?: () => Promise; } @@ -659,9 +683,10 @@ async function declaredReadsOf( * Reads the flow through the automation service's own `getFlow` — the probe * `flowIsUnknown` (`flow-dispatch-status.ts`) uses, which serves the same * definition `execute` runs — so there is no second loader. `getFlow` is - * optional on `IAutomationService`; an implementation that omits it cannot be - * asked, and the door dispatches as before, exactly as the existence check - * does. + * optional on `IAutomationService`; an implementation that omits it, or a + * definition the probe does not return, cannot be asked rules 1, 2 and 3, and + * the door dispatches as before, exactly as the existence check does. Rule 2b + * reads no definition and is asked either way. */ export async function flowStartRefusal( automation: unknown, @@ -674,26 +699,38 @@ export async function flowStartRefusal( ): Promise { if (executionContext?.isSystem === true) return null; const svc = automation as { getFlow?: (name: string) => Promise } | null | undefined; - if (typeof svc?.getFlow !== 'function') return null; - const flow = (await svc.getFlow(flowName)) as - | { type?: FlowParsed['type']; runAs?: unknown; requiredPermissions?: unknown } - | null - | undefined; - if (!flow) return null; - if (isElevatedSelfTriggered(flow)) return ELEVATED_START_REFUSAL; + // Rules 1, 2 and 3 read the definition; a service without `getFlow`, or a + // definition the probe does not return, cannot be asked them. + const flow = typeof svc?.getFlow === 'function' + ? (await svc.getFlow(flowName)) as + | { type?: FlowParsed['type']; runAs?: unknown; requiredPermissions?: unknown } + | null + | undefined + : undefined; + if (flow && isElevatedSelfTriggered(flow)) return ELEVATED_START_REFUSAL; // [ADR-0151 Non-goals; ruling record 6812617393, letter C] Rule 2: the // account starts an elevated flow only where the author's AI opt-in stands. - if (flow.runAs === 'system' && isAiServiceAccount(executionContext) && door.aiExposed !== true) { + if (flow && flow.runAs === 'system' && isAiServiceAccount(executionContext) && door.aiExposed !== true) { return AI_ACCOUNT_ELEVATED_START_REFUSAL; } // [ADR-0151 D3 rule 3] Rule 2b: the confirmation an action declares - // travels with what it starts. Asked of an account alone, so the - // declarations are read for no other caller; nothing the request carries - // is read here, so no confirmation member admits an account. + // travels with what it starts. It reads the flow's NAME and the door's + // declarations only, so it is asked whether or not the definition could + // be read. Asked of an account alone, so the declarations are read for no + // other caller; nothing the request carries is read here, so no + // confirmation member admits an account. if (isAiServiceAccount(executionContext) && door.actionDeclarations) { - const gated = confirmationGatedStarterOf(await door.actionDeclarations(), flowName); + let declarations: readonly FlowStartActionDeclaration[]; + try { + declarations = await door.actionDeclarations(); + } catch { + // The read did not happen: refused, never admitted on a guess. + return DECLARATION_READ_FAILED_REFUSAL; + } + const gated = confirmationGatedStarterOf(declarations, flowName); if (gated) return confirmationGatedStartRefusal(gated); } + if (!flow) return null; const missing = missingCapabilities(flow.requiredPermissions, executionContext); if (missing.length > 0) return requiredPermissionsRefusal(flow.requiredPermissions as string[], missing); return null; diff --git a/packages/runtime/src/flow-start-confirmation-gated-target.test.ts b/packages/runtime/src/flow-start-confirmation-gated-target.test.ts index 920a80dfca2..9f5cad25ed3 100644 --- a/packages/runtime/src/flow-start-confirmation-gated-target.test.ts +++ b/packages/runtime/src/flow-start-confirmation-gated-target.test.ts @@ -32,7 +32,7 @@ import { describe, it, expect, vi } from 'vitest'; import '@objectstack/metadata'; import { HttpDispatcher } from './http-dispatcher.js'; -import { confirmationGatedStarterOf } from './flow-start-admission.js'; +import { confirmationGatedStarterOf, flowStartRefusal } from './flow-start-admission.js'; const OBJECT = 'fcg_invoice'; const FLOW = 'fcg_void_invoice'; @@ -67,26 +67,34 @@ const BODIES = { interface Answer { status: number; code?: string; details?: Record } -type Source = 'object' | 'standalone' | 'merged'; +type Source = 'object' | 'standalone' | 'merged' | 'registry'; interface Harness { /** Whether the action that targets {@link FLOW} declares `ai.requiresConfirmation: true`. */ gated?: boolean; - /** Where the action is declared: embedded on the object, a standalone item, or the protocol's merged listing. */ + /** + * Where the action is declared: embedded on the object or a standalone item + * of the metadata service, the protocol's merged listing, or (`registry`) a + * host with neither listing, whose ObjectQL registry alone serves it. + */ source?: Source; /** The gated action targets this flow instead of {@link FLOW}. */ target?: string; - /** The listing read throws. */ - listingFails?: boolean; + /** The listing read throws; `declared` throws an error that declares its own status and code. */ + listingFails?: boolean | 'declared'; + /** This service slot is wired and fails to resolve (its factory throws). */ + resolveFails?: 'protocol' | 'metadata'; + /** The automation service serves no `getFlow`. */ + noGetFlow?: boolean; } /** One user-run screen flow, the action that targets it, and the trigger routes and action door over them. */ function makeDoors(opts: Harness = {}) { - const { gated = true, source = 'object', target = FLOW, listingFails = false } = opts; + const { gated = true, source = 'object', target = FLOW, listingFails = false, resolveFails, noGetFlow = false } = opts; const execute = vi.fn(async (_name: string, _context?: unknown) => ({ success: true, output: {} })); const getFlow = vi.fn(async (name: string) => name === FLOW || name === OTHER_FLOW ? { name, type: 'screen', runAs: 'user' } : null); - const automation: Record = { execute, getFlow }; + const automation: Record = noGetFlow ? { execute } : { execute, getFlow }; const action = { name: GATED_ACTION, @@ -102,15 +110,22 @@ function makeDoors(opts: Harness = {}) { }; const objectDef = { name: OBJECT, actions: source === 'object' ? [action] : [] }; const standalone = source === 'standalone' ? [action] : []; + const registryItems = (type: string): unknown[] => + type === 'object' ? [{ name: OBJECT, actions: [] }] : type === 'action' ? [action] : []; const schemaOf = (n: string) => (n === OBJECT ? objectDef : undefined); const ql: any = { executeAction: vi.fn(async () => ({ ran: 'script' })), getSchema: schemaOf, - registry: { getObject: schemaOf, getItem: () => undefined }, + registry: { + getObject: schemaOf, + getItem: () => undefined, + ...(source === 'registry' ? { listItems: registryItems } : {}), + }, find: vi.fn(async () => []), insert: vi.fn(), update: vi.fn(), delete: vi.fn(), }; const listObjects = vi.fn(async () => { + if (listingFails === 'declared') throw Object.assign(new Error('not here'), { status: 404, code: 'RESOURCE_NOT_FOUND' }); if (listingFails) throw new Error('metadata listing unavailable'); return [objectDef]; }); @@ -128,11 +143,15 @@ function makeDoors(opts: Harness = {}) { const protocol = source === 'merged' ? { getMetaItems } : null; const resolve = (n: string) => n === 'objectql' || n === 'data' ? ql - : n === 'metadata' ? metadata + : n === 'metadata' ? (source === 'registry' ? null : metadata) : n === 'automation' ? automation : n === 'protocol' ? protocol : null; - const kernel: any = { getService: resolve, getServiceAsync: async (n: string) => resolve(n), context: { getService: resolve } }; + const resolveAsync = async (n: string) => { + if (n === resolveFails) throw new Error(`service '${n}' factory failed`); + return resolve(n); + }; + const kernel: any = { getService: resolve, getServiceAsync: resolveAsync, context: { getService: resolve } }; const dispatcher = new HttpDispatcher(kernel); const trigger = async (route: Route, ec: unknown, body: unknown = {}): Promise => { @@ -172,7 +191,7 @@ describe('an AI service account does not start, by name, a flow that a confirmat }); } - for (const source of ['standalone', 'merged'] as const) { + for (const source of ['standalone', 'merged', 'registry'] as const) { it(`${route}: the gated action counts wherever it is declared (${source} listing)`, async () => { const { trigger, execute } = makeDoors({ source }); @@ -189,6 +208,34 @@ describe('an AI service account does not start, by name, a flow that a confirmat expect(answer.code).toBe('SERVICE_UNAVAILABLE'); expect(execute).not.toHaveBeenCalled(); }); + + it(`${route}: the failed read is a flat 503 whatever the failure declares, and nothing runs`, async () => { + const { trigger, execute } = makeDoors({ listingFails: 'declared' }); + + const answer = await trigger(route, ACCOUNT_EC); + + expect(answer.status).toBe(503); + expect(answer.code).toBe('SERVICE_UNAVAILABLE'); + expect(execute).not.toHaveBeenCalled(); + }); + + for (const slot of ['protocol', 'metadata'] as const) { + it(`${route}: a '${slot}' slot that fails to resolve refuses the account's start 503 (failure is not absence), and nothing runs`, async () => { + const { trigger, execute } = makeDoors({ resolveFails: slot }); + + const answer = await trigger(route, ACCOUNT_EC); + + expect(answer.status).toBe(503); + expect(answer.code).toBe('SERVICE_UNAVAILABLE'); + expect(execute).not.toHaveBeenCalled(); + }); + } + + it(`${route}: the rule is asked without the flow-definition probe (a service with no getFlow)`, async () => { + const { trigger, execute } = makeDoors({ noGetFlow: true }); + + expectConfirmationRefusal(await trigger(route, ACCOUNT_EC, { confirm: true }), execute); + }); } }); @@ -205,6 +252,15 @@ describe('CONTROLS — what the confirmation-gated start rule leaves exactly as expect(listObjects).not.toHaveBeenCalled(); }); + it(`${route}: a person is unchanged on a service with no getFlow, and under a failing listing slot`, async () => { + for (const opts of [{ noGetFlow: true }, { resolveFails: 'metadata' as const }, { listingFails: true }]) { + const { trigger, execute } = makeDoors(opts); + + expect((await trigger(route, PERSON_EC)).status, JSON.stringify(opts)).toBe(200); + expect(execute).toHaveBeenCalledTimes(1); + } + }); + it(`${route}: an OAuth-delegated agent is unchanged — it starts the flow`, async () => { const { trigger, execute } = makeDoors(); @@ -261,3 +317,31 @@ describe('confirmationGatedStarterOf — which declaration gates a start', () => expect(confirmationGatedStarterOf([a, b], FLOW)).toBe(a); }); }); + +describe('flowStartRefusal — rule 2b reads the name and the declarations, never the definition', () => { + const gatedRows = async () => [{ + action: { name: GATED_ACTION, type: 'flow', target: FLOW, ai: { requiresConfirmation: true } }, + objectName: OBJECT, + }]; + const door = { aiExposed: false, actionDeclarations: gatedRows }; + const services = { + 'a service with no getFlow': {}, + 'a definition the probe does not return': { getFlow: async () => null }, + } as const; + + for (const [label, automation] of Object.entries(services)) { + it(`${label}: the account is refused 428; a person and an ungated flow are admitted`, async () => { + const refused = await flowStartRefusal(automation, FLOW, ACCOUNT_EC, door); + expect(refused).toMatchObject({ code: 'ACTION_CONFIRMATION_REQUIRED', status: 428 }); + // Controls on the same service: nothing else is judged without the definition. + expect(await flowStartRefusal(automation, FLOW, PERSON_EC, door)).toBeNull(); + expect(await flowStartRefusal(automation, OTHER_FLOW, ACCOUNT_EC, door)).toBeNull(); + }); + } + + it('a failure of the flow read itself is not answered by the declaration-read 503: it travels as before', async () => { + const failing = { getFlow: async () => { throw new Error('flow read failed'); } }; + await expect(flowStartRefusal(failing, FLOW, PERSON_EC, door)).rejects.toThrow('flow read failed'); + await expect(flowStartRefusal(failing, FLOW, ACCOUNT_EC, door)).rejects.toThrow('flow read failed'); + }); +}); From f9b12d5f59229ff8439e0fd5dc6a565be8c07f2f Mon Sep 17 00:00:00 2001 From: Claude Date: Sun, 15 Nov 2026 08:17:37 +0000 Subject: [PATCH 5/9] fix(runtime): every source rule 2b reads tells a failed read from an absent one The ObjectQL engine slot is resolved loud, as the two listing slots are, and the metadata service's object and standalone action listings are read where their throw travels, so a wired slot that fails to resolve and a listing that throws each refuse an AI service account's start with the 503. Claude-Session: https://claude.ai/code/session_017xRBcT1w3zpekijraHJE4f Co-authored-by: Claude --- .../flow-start-carries-action-confirmation.md | 2 +- packages/runtime/src/domains/automation.ts | 29 +++++++++++------ ...ow-start-confirmation-gated-target.test.ts | 31 ++++++++++++++++--- 3 files changed, 47 insertions(+), 15 deletions(-) diff --git a/.changeset/flow-start-carries-action-confirmation.md b/.changeset/flow-start-carries-action-confirmation.md index c57e6b5fa49..f50fecf3f16 100644 --- a/.changeset/flow-start-carries-action-confirmation.md +++ b/.changeset/flow-start-carries-action-confirmation.md @@ -9,7 +9,7 @@ Metadata-protocol: none -**BREAKING** for an AI service account (an agent principal acting for itself, with no person it acts for) that starts a flow by name. An AI service account does not confirm an action for itself, and the action door already refuses it an action declaring `ai.requiresConfirmation: true` whatever the call sends. The same confirmation now travels with the flow such an action starts: when an action of `type: 'flow'` whose `target` is the flow declares `ai.requiresConfirmation: true`, `POST /api/v1/automation/:name/trigger` and the legacy `POST /api/v1/automation/trigger/:name` refuse the account with the action door's own refusal, `428 ACTION_CONFIRMATION_REQUIRED`, its `details` naming the action and the confirmation member, before any run exists and whatever the request carries (`confirm: true` included). Every declaration of such an action counts, whichever package holds it and whether it is embedded on an object or a standalone item. A read of the declarations that fails, or a metadata service that is wired and fails to resolve, refuses the start `503 SERVICE_UNAVAILABLE` rather than admitting it. The rule reads the flow's name and the declarations, not the flow's definition. It is asked at the two trigger routes; the declared `type: 'flow'` endpoint door is not judged by it yet. +**BREAKING** for an AI service account (an agent principal acting for itself, with no person it acts for) that starts a flow by name. An AI service account does not confirm an action for itself, and the action door already refuses it an action declaring `ai.requiresConfirmation: true` whatever the call sends. The same confirmation now travels with the flow such an action starts: when an action of `type: 'flow'` whose `target` is the flow declares `ai.requiresConfirmation: true`, `POST /api/v1/automation/:name/trigger` and the legacy `POST /api/v1/automation/trigger/:name` refuse the account with the action door's own refusal, `428 ACTION_CONFIRMATION_REQUIRED`, its `details` naming the action and the confirmation member, before any run exists and whatever the request carries (`confirm: true` included). Every declaration of such an action counts, whichever package holds it and whether it is embedded on an object or a standalone item. A read of the declarations that fails on any of its sources, or a service it reads them from (the metadata protocol, the ObjectQL engine or the metadata service) that is wired and fails to resolve, refuses the start `503 SERVICE_UNAVAILABLE` rather than admitting it; only a service nothing registered reads as absent. The rule reads the flow's name and the declarations, not the flow's definition. It is asked at the two trigger routes; the declared `type: 'flow'` endpoint door is not judged by it yet. **Not moved.** A person, an OAuth-delegated agent and the system principal start the flow as before, and the action declarations are not read for them. An AI service account starts a flow no confirmation-gated action targets as before. The action door's own gate (`POST /api/v1/actions/...` and MCP `run_action`) answers as before. A declared `type: 'flow'` endpoint answers as before; on its default `authRequired` it admits a session only, so an API key is refused there before the flow. diff --git a/packages/runtime/src/domains/automation.ts b/packages/runtime/src/domains/automation.ts index ddca1e87751..6946675e8b1 100644 --- a/packages/runtime/src/domains/automation.ts +++ b/packages/runtime/src/domains/automation.ts @@ -3021,12 +3021,16 @@ async function unregisterAndDeleteFlow( * actions) and standalone `action` items, and the metadata service's * object and action listings. * - * Absence and failure are told apart, as at every gate that reads an - * authorization fact (`resolveServiceOrLoud`): a slot nothing registered is - * absent and contributes nothing, while a slot that is wired and fails to - * resolve throws, as a listing that throws does, and the predicate refuses - * the start `503`. So a host that serves no declaration from any of these - * sources finds none, and a read that did not happen admits nothing. + * Absence and failure are told apart on every arm, as at every gate that + * reads an authorization fact (`resolveServiceOrLoud`): each of the three + * slots (`protocol`, `objectql`, `metadata`) is resolved loud, so a slot + * nothing registered is absent and contributes nothing, while a slot that is + * wired and fails to resolve throws; and each listing (the two merged ones, + * the registry's two, the metadata service's objects and its standalone + * `action` items) is read where its throw travels. Any such throw makes the + * predicate refuse the start `503`. So a host that serves no declaration from + * any of these sources finds none, and a read that did not happen admits + * nothing. */ async function servedActionDeclarations( deps: DomainHandlerDeps, @@ -3040,16 +3044,23 @@ async function servedActionDeclarations( return collectActionDeclarations(deps, undefined, objects, actions); } const rows: Array<{ action: unknown; objectName: string }> = []; - const engine = (await deps.getObjectQL(context, envId)) as + // The engine slot resolved loud, as the two listing slots are: the quiet + // `getObjectQL` probe reads a wired slot that fails to resolve as no engine. + const engine = (await deps.resolveServiceOrLoud(context, 'objectql', envId)) as | { registry?: { listItems?: (type: string) => unknown[] } } - | null; + | undefined; const registry = engine?.registry; if (typeof registry?.listItems === 'function') { rows.push(...await collectActionDeclarations(deps, undefined, registry.listItems('object'), registry.listItems('action'))); } const metadata = await deps.resolveServiceOrLoud(context, 'metadata', envId); if (typeof metadata?.listObjects === 'function' || typeof metadata?.loadMany === 'function') { - rows.push(...await collectActionDeclarations(deps, metadata)); + // Both listings read HERE and handed over, so a throw of either one + // travels: `collectActionDeclarations` reads a throwing standalone + // listing it is left to read as no standalone item, by design. + const objects: unknown[] = typeof metadata.listObjects === 'function' ? (await metadata.listObjects()) ?? [] : []; + const actions: unknown[] = typeof metadata.loadMany === 'function' ? (await metadata.loadMany('action')) ?? [] : []; + rows.push(...await collectActionDeclarations(deps, undefined, objects, actions)); } return rows; } diff --git a/packages/runtime/src/flow-start-confirmation-gated-target.test.ts b/packages/runtime/src/flow-start-confirmation-gated-target.test.ts index 9f5cad25ed3..1923ed35990 100644 --- a/packages/runtime/src/flow-start-confirmation-gated-target.test.ts +++ b/packages/runtime/src/flow-start-confirmation-gated-target.test.ts @@ -82,15 +82,17 @@ interface Harness { target?: string; /** The listing read throws; `declared` throws an error that declares its own status and code. */ listingFails?: boolean | 'declared'; + /** The metadata service's standalone `action` listing throws. */ + actionListingFails?: boolean; /** This service slot is wired and fails to resolve (its factory throws). */ - resolveFails?: 'protocol' | 'metadata'; + resolveFails?: 'protocol' | 'metadata' | 'objectql'; /** The automation service serves no `getFlow`. */ noGetFlow?: boolean; } /** One user-run screen flow, the action that targets it, and the trigger routes and action door over them. */ function makeDoors(opts: Harness = {}) { - const { gated = true, source = 'object', target = FLOW, listingFails = false, resolveFails, noGetFlow = false } = opts; + const { gated = true, source = 'object', target = FLOW, listingFails = false, actionListingFails = false, resolveFails, noGetFlow = false } = opts; const execute = vi.fn(async (_name: string, _context?: unknown) => ({ success: true, output: {} })); const getFlow = vi.fn(async (name: string) => name === FLOW || name === OTHER_FLOW ? { name, type: 'screen', runAs: 'user' } : null); @@ -133,7 +135,10 @@ function makeDoors(opts: Harness = {}) { load: vi.fn(async () => null), loadDiagnosed: vi.fn(async () => ({ data: null, degraded: false, errors: [] })), listObjects, - loadMany: vi.fn(async (type: string) => (type === 'action' ? standalone : [])), + loadMany: vi.fn(async (type: string) => { + if (type === 'action' && actionListingFails) throw new Error('standalone action listing unavailable'); + return type === 'action' ? standalone : []; + }), getObject: vi.fn(async (n: string) => schemaOf(n)), }; const getMetaItems = vi.fn(async ({ type }: { type: string }) => ({ @@ -219,7 +224,7 @@ describe('an AI service account does not start, by name, a flow that a confirmat expect(execute).not.toHaveBeenCalled(); }); - for (const slot of ['protocol', 'metadata'] as const) { + for (const slot of ['protocol', 'objectql', 'metadata'] as const) { it(`${route}: a '${slot}' slot that fails to resolve refuses the account's start 503 (failure is not absence), and nothing runs`, async () => { const { trigger, execute } = makeDoors({ resolveFails: slot }); @@ -231,6 +236,16 @@ describe('an AI service account does not start, by name, a flow that a confirmat }); } + it(`${route}: a standalone action listing that fails refuses the account's start 503 (failure is not absence), and nothing runs`, async () => { + const { trigger, execute } = makeDoors({ actionListingFails: true }); + + const answer = await trigger(route, ACCOUNT_EC); + + expect(answer.status).toBe(503); + expect(answer.code).toBe('SERVICE_UNAVAILABLE'); + expect(execute).not.toHaveBeenCalled(); + }); + it(`${route}: the rule is asked without the flow-definition probe (a service with no getFlow)`, async () => { const { trigger, execute } = makeDoors({ noGetFlow: true }); @@ -253,7 +268,13 @@ describe('CONTROLS — what the confirmation-gated start rule leaves exactly as }); it(`${route}: a person is unchanged on a service with no getFlow, and under a failing listing slot`, async () => { - for (const opts of [{ noGetFlow: true }, { resolveFails: 'metadata' as const }, { listingFails: true }]) { + for (const opts of [ + { noGetFlow: true }, + { resolveFails: 'metadata' as const }, + { resolveFails: 'objectql' as const }, + { listingFails: true }, + { actionListingFails: true }, + ]) { const { trigger, execute } = makeDoors(opts); expect((await trigger(route, PERSON_EC)).status, JSON.stringify(opts)).toBe(200); From ea8ee499b6ba11b0aa47d60dd5b612e614a6ad32 Mon Sep 17 00:00:00 2001 From: Claude Date: Sun, 15 Nov 2026 09:18:11 +0000 Subject: [PATCH 6/9] fix(runtime): rule 2b reads the services the request's own actions door reads, loud on failure Each slot is resolved in resolveService's order (the request's own kernel first), and only a miss is classified by resolveServiceOrLoud, so the declarations are the ones the same request's /actions door reads in every host shape and a wired slot that fails to resolve still refuses. The jsdoc and changeset now say a read failure that arrives as a throw admits nothing. Claude-Session: https://claude.ai/code/session_017xRBcT1w3zpekijraHJE4f Co-authored-by: Claude --- .../flow-start-carries-action-confirmation.md | 2 +- packages/runtime/src/domains/automation.ts | 66 ++++++++++---- ...ow-start-confirmation-gated-target.test.ts | 89 +++++++++++++++++++ 3 files changed, 140 insertions(+), 17 deletions(-) diff --git a/.changeset/flow-start-carries-action-confirmation.md b/.changeset/flow-start-carries-action-confirmation.md index f50fecf3f16..e717c26d850 100644 --- a/.changeset/flow-start-carries-action-confirmation.md +++ b/.changeset/flow-start-carries-action-confirmation.md @@ -9,7 +9,7 @@ Metadata-protocol: none -**BREAKING** for an AI service account (an agent principal acting for itself, with no person it acts for) that starts a flow by name. An AI service account does not confirm an action for itself, and the action door already refuses it an action declaring `ai.requiresConfirmation: true` whatever the call sends. The same confirmation now travels with the flow such an action starts: when an action of `type: 'flow'` whose `target` is the flow declares `ai.requiresConfirmation: true`, `POST /api/v1/automation/:name/trigger` and the legacy `POST /api/v1/automation/trigger/:name` refuse the account with the action door's own refusal, `428 ACTION_CONFIRMATION_REQUIRED`, its `details` naming the action and the confirmation member, before any run exists and whatever the request carries (`confirm: true` included). Every declaration of such an action counts, whichever package holds it and whether it is embedded on an object or a standalone item. A read of the declarations that fails on any of its sources, or a service it reads them from (the metadata protocol, the ObjectQL engine or the metadata service) that is wired and fails to resolve, refuses the start `503 SERVICE_UNAVAILABLE` rather than admitting it; only a service nothing registered reads as absent. The rule reads the flow's name and the declarations, not the flow's definition. It is asked at the two trigger routes; the declared `type: 'flow'` endpoint door is not judged by it yet. +**BREAKING** for an AI service account (an agent principal acting for itself, with no person it acts for) that starts a flow by name. An AI service account does not confirm an action for itself, and the action door already refuses it an action declaring `ai.requiresConfirmation: true` whatever the call sends. The same confirmation now travels with the flow such an action starts: when an action of `type: 'flow'` whose `target` is the flow declares `ai.requiresConfirmation: true`, `POST /api/v1/automation/:name/trigger` and the legacy `POST /api/v1/automation/trigger/:name` refuse the account with the action door's own refusal, `428 ACTION_CONFIRMATION_REQUIRED`, its `details` naming the action and the confirmation member, before any run exists and whatever the request carries (`confirm: true` included). Every declaration of such an action counts, whichever package holds it and whether it is embedded on an object or a standalone item. The declarations are read from the same services the request's own `/actions` door reads. A read of the declarations that throws on any of its sources, or a service it reads them from (the metadata protocol, the ObjectQL engine or the metadata service) that is wired and fails to resolve, refuses the start `503 SERVICE_UNAVAILABLE` rather than admitting it; only a service nothing registered reads as absent. A source that answers a failed read of its own without throwing (the metadata service's plural listing, which reports a failed loader and answers the others' rows) is judged on the rows it answers. The rule reads the flow's name and the declarations, not the flow's definition. It is asked at the two trigger routes; the declared `type: 'flow'` endpoint door is not judged by it yet. **Not moved.** A person, an OAuth-delegated agent and the system principal start the flow as before, and the action declarations are not read for them. An AI service account starts a flow no confirmation-gated action targets as before. The action door's own gate (`POST /api/v1/actions/...` and MCP `run_action`) answers as before. A declared `type: 'flow'` endpoint answers as before; on its default `authRequired` it admits a session only, so an API key is refused there before the flow. diff --git a/packages/runtime/src/domains/automation.ts b/packages/runtime/src/domains/automation.ts index 6946675e8b1..40ec7d470cd 100644 --- a/packages/runtime/src/domains/automation.ts +++ b/packages/runtime/src/domains/automation.ts @@ -3006,6 +3006,37 @@ async function unregisterAndDeleteFlow( return undefined; } +/** + * [ADR-0151 D3 rule 3] One service slot rule 2b reads its declarations from, + * resolved to the instance the same request's `/actions` door reads, and loud + * on failure. No one helper gives both, so this is the smallest composition of + * the two that exist: + * + * 1. `resolveService`, the order every `/actions` read uses (`getObjectQL` + * included): the request's own kernel first on a host that routes a + * request to a kernel of its own, then the host kernel's scoped factory, + * then its singletons. An instance it answers is the door's instance. + * 2. Only on a miss, `resolveServiceOrLoud` classifies it: a name nothing + * registered (or a scoped registration with no instance in this scope) is + * absent, `undefined`; any other rejection is re-raised. The quiet probe + * absorbs every rejection, so a miss there is absence or a failure it + * swallowed, and this step is what tells the two apart. Its own order + * (the host's scoped leg first) never decides WHICH instance is read: it + * is asked only when step 1 found none. + * + * Scoped by the request's environment, as the door's reads are: unscoped, a + * scoped registration is a fault to the classifier. + */ +async function resolveSlotAsActionsDoorReads( + deps: DomainHandlerDeps, + context: HttpProtocolContext, + name: 'protocol' | 'objectql' | 'metadata', +): Promise { + const served = await deps.resolveService(context, name, context?.environmentId); + if (served != null) return served; + return deps.resolveServiceOrLoud(context, name, context?.environmentId); +} + /** * [ADR-0151 D3 rule 3] The action declarations the request's environment * serves: what flow start admission's rule 2b reads, for an AI service @@ -3021,39 +3052,42 @@ async function unregisterAndDeleteFlow( * actions) and standalone `action` items, and the metadata service's * object and action listings. * - * Absence and failure are told apart on every arm, as at every gate that - * reads an authorization fact (`resolveServiceOrLoud`): each of the three - * slots (`protocol`, `objectql`, `metadata`) is resolved loud, so a slot - * nothing registered is absent and contributes nothing, while a slot that is - * wired and fails to resolve throws; and each listing (the two merged ones, - * the registry's two, the metadata service's objects and its standalone - * `action` items) is read where its throw travels. Any such throw makes the - * predicate refuse the start `503`. So a host that serves no declaration from - * any of these sources finds none, and a read that did not happen admits - * nothing. + * Each of the three slots (`protocol`, `objectql`, `metadata`) is the + * instance the same request's `/actions` door reads, in every host shape + * ({@link resolveSlotAsActionsDoorReads}: the request's own kernel first), + * and absence and failure are told apart on every arm: a slot nothing + * registered is absent and contributes nothing, while a slot that is wired + * and fails to resolve throws; and each listing (the two merged ones, the + * registry's two, the metadata service's objects and its standalone `action` + * items) is read where its throw travels. Any such throw makes the predicate + * refuse the start `503`. So a host that serves no declaration from any of + * these sources finds none, and a read failure that reaches this function as + * a throw admits nothing. A source that answers a failed read of its own + * without throwing is not told apart here: the metadata service's plural + * listing reports a loader that failed and answers the other loaders' rows, + * and those rows are what is judged. */ async function servedActionDeclarations( deps: DomainHandlerDeps, context: HttpProtocolContext, ): Promise> { - const envId = context?.environmentId; - const protocol = await deps.resolveServiceOrLoud(context, 'protocol', envId); + const protocol = await resolveSlotAsActionsDoorReads(deps, context, 'protocol'); if (typeof protocol?.getMetaItems === 'function') { const objects = await readMergedItems(protocol, 'object'); const actions = await readMergedItems(protocol, 'action'); return collectActionDeclarations(deps, undefined, objects, actions); } const rows: Array<{ action: unknown; objectName: string }> = []; - // The engine slot resolved loud, as the two listing slots are: the quiet - // `getObjectQL` probe reads a wired slot that fails to resolve as no engine. - const engine = (await deps.resolveServiceOrLoud(context, 'objectql', envId)) as + // The engine the `/actions` door's `getObjectQL` reads, resolved so that a + // wired slot that fails to resolve is loud, which that probe is not. + const engine = (await resolveSlotAsActionsDoorReads(deps, context, 'objectql')) as | { registry?: { listItems?: (type: string) => unknown[] } } | undefined; const registry = engine?.registry; if (typeof registry?.listItems === 'function') { rows.push(...await collectActionDeclarations(deps, undefined, registry.listItems('object'), registry.listItems('action'))); } - const metadata = await deps.resolveServiceOrLoud(context, 'metadata', envId); + const metadata = await resolveSlotAsActionsDoorReads(deps, context, 'metadata'); if (typeof metadata?.listObjects === 'function' || typeof metadata?.loadMany === 'function') { // Both listings read HERE and handed over, so a throw of either one // travels: `collectActionDeclarations` reads a throwing standalone diff --git a/packages/runtime/src/flow-start-confirmation-gated-target.test.ts b/packages/runtime/src/flow-start-confirmation-gated-target.test.ts index 1923ed35990..758e2c0d394 100644 --- a/packages/runtime/src/flow-start-confirmation-gated-target.test.ts +++ b/packages/runtime/src/flow-start-confirmation-gated-target.test.ts @@ -31,6 +31,8 @@ import { describe, it, expect, vi } from 'vitest'; // window pays that first load (`check:test-source-alias`). import '@objectstack/metadata'; +import { ObjectKernel, ServiceLifecycle } from '@objectstack/core'; + import { HttpDispatcher } from './http-dispatcher.js'; import { confirmationGatedStarterOf, flowStartRefusal } from './flow-start-admission.js'; @@ -366,3 +368,90 @@ describe('flowStartRefusal — rule 2b reads the name and the declarations, neve await expect(flowStartRefusal(failing, FLOW, ACCOUNT_EC, door)).rejects.toThrow('flow read failed'); }); }); + +describe('the declarations are read from the services the request\'s own /actions door reads, in every host shape', () => { + const ENV_ID = 'env-fcg'; + /** No graceful-shutdown handlers: one kernel per case would otherwise pile up process listeners. */ + const bareKernel = (): ObjectKernel => new ObjectKernel({ gracefulShutdown: false, skipSystemValidation: true }); + const gatedAction = { + name: GATED_ACTION, objectName: OBJECT, type: 'flow', target: FLOW, + ai: { exposed: true, description: 'Voids the invoice through its flow, for this test.', requiresConfirmation: true }, + }; + /** A protocol whose merged listings serve the gated action, or (`gated: false`) none. */ + const protocolServing = (gated: boolean) => ({ + getMetaItems: async ({ type }: { type: string }) => ({ + type, + items: type === 'object' ? [{ name: OBJECT, actions: [] }] : type === 'action' && gated ? [gatedAction] : [], + }), + }); + const automationService = () => { + const execute = vi.fn(async () => ({ success: true, output: {} })); + const getFlow = async (name: string) => (name === FLOW ? { name, type: 'screen', runAs: 'user' } : null); + return { execute, getFlow }; + }; + const start = async (dispatcher: HttpDispatcher, context: Record): Promise => { + const res: any = await dispatcher.handleAutomation(`/${FLOW}/trigger`, 'POST', {}, { + request: {}, executionContext: ACCOUNT_EC, ...context, + } as any); + const error = res.response?.body?.error; + return { status: res.response?.status, code: error?.code, details: error?.details }; + }; + + it('kernel-resolver host: the gated action declared on the request\'s own kernel refuses the account\'s start', async () => { + const host = bareKernel(); + host.registerService('protocol', protocolServing(false)); + const env = bareKernel(); + env.registerService('protocol', protocolServing(true)); + const automation = automationService(); + env.registerService('automation', automation); + + expectConfirmationRefusal(await start(new HttpDispatcher(host as never), { kernel: env, environmentId: ENV_ID }), automation.execute); + }); + + it('kernel-resolver host: a shape that merely lacks every source gains no 503 — the account starts the flow', async () => { + const host = bareKernel(); + const env = bareKernel(); + const automation = automationService(); + env.registerService('automation', automation); + + expect((await start(new HttpDispatcher(host as never), { kernel: env, environmentId: ENV_ID })).status).toBe(200); + expect(automation.execute).toHaveBeenCalledTimes(1); + }); + + it('single-environment host: the gated action declared on the default kernel refuses the account\'s start', async () => { + const host = bareKernel(); + host.registerService('protocol', protocolServing(true)); + const automation = automationService(); + host.registerService('automation', automation); + + expectConfirmationRefusal(await start(new HttpDispatcher(host as never), {}), automation.execute); + }); + + it('single-environment host: a shape that merely lacks every source gains no 503 — the account starts the flow', async () => { + const host = bareKernel(); + const automation = automationService(); + host.registerService('automation', automation); + + expect((await start(new HttpDispatcher(host as never), {})).status).toBe(200); + expect(automation.execute).toHaveBeenCalledTimes(1); + }); + + it('SharedProjectPlugin: the gated action the scoped factory serves for the request\'s scope refuses the account\'s start', async () => { + const host = bareKernel(); + host.registerServiceFactory('protocol', (_ctx: unknown, scopeId?: string) => protocolServing(scopeId === ENV_ID), ServiceLifecycle.SCOPED); + const automation = automationService(); + host.registerService('automation', automation); + + expectConfirmationRefusal(await start(new HttpDispatcher(host as never), { environmentId: ENV_ID }), automation.execute); + }); + + it('SharedProjectPlugin: a scoped factory with no instance in this scope is absence, not a 503 — the account starts the flow', async () => { + const host = bareKernel(); + host.registerServiceFactory('protocol', () => undefined, ServiceLifecycle.SCOPED); + const automation = automationService(); + host.registerService('automation', automation); + + expect((await start(new HttpDispatcher(host as never), { environmentId: ENV_ID })).status).toBe(200); + expect(automation.execute).toHaveBeenCalledTimes(1); + }); +}); From 97141221bddabb1a0db32cd5d215ab6a32b9473a Mon Sep 17 00:00:00 2001 From: Claude Date: Sun, 15 Nov 2026 09:22:35 +0000 Subject: [PATCH 7/9] test(runtime): a failing slot fails on every kernel accessor in the rule harness Claude-Session: https://claude.ai/code/session_017xRBcT1w3zpekijraHJE4f Co-authored-by: Claude --- .../src/flow-start-confirmation-gated-target.test.ts | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/packages/runtime/src/flow-start-confirmation-gated-target.test.ts b/packages/runtime/src/flow-start-confirmation-gated-target.test.ts index 758e2c0d394..27364943418 100644 --- a/packages/runtime/src/flow-start-confirmation-gated-target.test.ts +++ b/packages/runtime/src/flow-start-confirmation-gated-target.test.ts @@ -154,11 +154,13 @@ function makeDoors(opts: Harness = {}) { : n === 'automation' ? automation : n === 'protocol' ? protocol : null; - const resolveAsync = async (n: string) => { + // A wired slot that fails to resolve fails on every accessor the kernel has. + const resolveOrFail = (n: string) => { if (n === resolveFails) throw new Error(`service '${n}' factory failed`); return resolve(n); }; - const kernel: any = { getService: resolve, getServiceAsync: resolveAsync, context: { getService: resolve } }; + const resolveAsync = async (n: string) => resolveOrFail(n); + const kernel: any = { getService: resolveOrFail, getServiceAsync: resolveAsync, context: { getService: resolveOrFail } }; const dispatcher = new HttpDispatcher(kernel); const trigger = async (route: Route, ec: unknown, body: unknown = {}): Promise => { From f7941c77799d5499e5bbfca7723e94af182035ca Mon Sep 17 00:00:00 2001 From: Claude Date: Sun, 15 Nov 2026 10:33:12 +0000 Subject: [PATCH 8/9] docs(runtime): rule 2b's declarations are the instance the actions door serves, whichever step of its order answers The jsdoc and changeset state the rule as the tree holds it: a read failure refuses the start when no step of the /actions door's order answers the name; where a later step answers, the start is judged on that instance, as the door would serve it. One pin records it on the kernel-resolver shape. Claude-Session: https://claude.ai/code/session_017xRBcT1w3zpekijraHJE4f Co-authored-by: Claude --- .../flow-start-carries-action-confirmation.md | 2 +- packages/runtime/src/domains/automation.ts | 20 +++++++++++-------- ...ow-start-confirmation-gated-target.test.ts | 13 ++++++++++++ 3 files changed, 26 insertions(+), 9 deletions(-) diff --git a/.changeset/flow-start-carries-action-confirmation.md b/.changeset/flow-start-carries-action-confirmation.md index e717c26d850..04404dac86a 100644 --- a/.changeset/flow-start-carries-action-confirmation.md +++ b/.changeset/flow-start-carries-action-confirmation.md @@ -9,7 +9,7 @@ Metadata-protocol: none -**BREAKING** for an AI service account (an agent principal acting for itself, with no person it acts for) that starts a flow by name. An AI service account does not confirm an action for itself, and the action door already refuses it an action declaring `ai.requiresConfirmation: true` whatever the call sends. The same confirmation now travels with the flow such an action starts: when an action of `type: 'flow'` whose `target` is the flow declares `ai.requiresConfirmation: true`, `POST /api/v1/automation/:name/trigger` and the legacy `POST /api/v1/automation/trigger/:name` refuse the account with the action door's own refusal, `428 ACTION_CONFIRMATION_REQUIRED`, its `details` naming the action and the confirmation member, before any run exists and whatever the request carries (`confirm: true` included). Every declaration of such an action counts, whichever package holds it and whether it is embedded on an object or a standalone item. The declarations are read from the same services the request's own `/actions` door reads. A read of the declarations that throws on any of its sources, or a service it reads them from (the metadata protocol, the ObjectQL engine or the metadata service) that is wired and fails to resolve, refuses the start `503 SERVICE_UNAVAILABLE` rather than admitting it; only a service nothing registered reads as absent. A source that answers a failed read of its own without throwing (the metadata service's plural listing, which reports a failed loader and answers the others' rows) is judged on the rows it answers. The rule reads the flow's name and the declarations, not the flow's definition. It is asked at the two trigger routes; the declared `type: 'flow'` endpoint door is not judged by it yet. +**BREAKING** for an AI service account (an agent principal acting for itself, with no person it acts for) that starts a flow by name. An AI service account does not confirm an action for itself, and the action door already refuses it an action declaring `ai.requiresConfirmation: true` whatever the call sends. The same confirmation now travels with the flow such an action starts: when an action of `type: 'flow'` whose `target` is the flow declares `ai.requiresConfirmation: true`, `POST /api/v1/automation/:name/trigger` and the legacy `POST /api/v1/automation/trigger/:name` refuse the account with the action door's own refusal, `428 ACTION_CONFIRMATION_REQUIRED`, its `details` naming the action and the confirmation member, before any run exists and whatever the request carries (`confirm: true` included). Every declaration of such an action counts, whichever package holds it and whether it is embedded on an object or a standalone item. The declarations are read from the instance the request's own `/actions` door reads, in every host shape. A read of the declarations that throws on any of its sources, or a service it reads them from (the metadata protocol, the ObjectQL engine or the metadata service) that no step of that door's resolution order answers because one failed to resolve it, refuses the start `503 SERVICE_UNAVAILABLE` rather than admitting it; where a later step answers the name, the start is judged on that instance, as the `/actions` door would serve it; only a service nothing registered reads as absent. A source that answers a failed read of its own without throwing (the metadata service's plural listing, which reports a failed loader and answers the others' rows) is judged on the rows it answers. The rule reads the flow's name and the declarations, not the flow's definition. It is asked at the two trigger routes; the declared `type: 'flow'` endpoint door is not judged by it yet. **Not moved.** A person, an OAuth-delegated agent and the system principal start the flow as before, and the action declarations are not read for them. An AI service account starts a flow no confirmation-gated action targets as before. The action door's own gate (`POST /api/v1/actions/...` and MCP `run_action`) answers as before. A declared `type: 'flow'` endpoint answers as before; on its default `authRequired` it admits a session only, so an API key is refused there before the flow. diff --git a/packages/runtime/src/domains/automation.ts b/packages/runtime/src/domains/automation.ts index 40ec7d470cd..768efea93e5 100644 --- a/packages/runtime/src/domains/automation.ts +++ b/packages/runtime/src/domains/automation.ts @@ -3008,14 +3008,17 @@ async function unregisterAndDeleteFlow( /** * [ADR-0151 D3 rule 3] One service slot rule 2b reads its declarations from, - * resolved to the instance the same request's `/actions` door reads, and loud - * on failure. No one helper gives both, so this is the smallest composition of - * the two that exist: + * resolved to the instance the same request's `/actions` door reads, in every + * host shape. The rule, as this function holds it: a read failure refuses the + * start when no leg of that door's order answers the name; where a later leg + * answers, the start is judged on that instance, as the `/actions` door would + * serve it. The smallest composition of the two resolvers that exist: * * 1. `resolveService`, the order every `/actions` read uses (`getObjectQL` * included): the request's own kernel first on a host that routes a * request to a kernel of its own, then the host kernel's scoped factory, - * then its singletons. An instance it answers is the door's instance. + * then its singletons. An instance it answers is the door's instance, + * whichever leg answers it, a leg that did not resolve before it included. * 2. Only on a miss, `resolveServiceOrLoud` classifies it: a name nothing * registered (or a scoped registration with no instance in this scope) is * absent, `undefined`; any other rejection is re-raised. The quiet probe @@ -3054,10 +3057,11 @@ async function resolveSlotAsActionsDoorReads( * * Each of the three slots (`protocol`, `objectql`, `metadata`) is the * instance the same request's `/actions` door reads, in every host shape - * ({@link resolveSlotAsActionsDoorReads}: the request's own kernel first), - * and absence and failure are told apart on every arm: a slot nothing - * registered is absent and contributes nothing, while a slot that is wired - * and fails to resolve throws; and each listing (the two merged ones, the + * ({@link resolveSlotAsActionsDoorReads}: the request's own kernel first). A + * slot nothing registered is absent and contributes nothing; a slot that no + * leg of that door's order answers, because a leg failed to resolve it, + * throws; and where a later leg answers the name, that instance is read, as + * the `/actions` door would serve it. Each listing (the two merged ones, the * registry's two, the metadata service's objects and its standalone `action` * items) is read where its throw travels. Any such throw makes the predicate * refuse the start `503`. So a host that serves no declaration from any of diff --git a/packages/runtime/src/flow-start-confirmation-gated-target.test.ts b/packages/runtime/src/flow-start-confirmation-gated-target.test.ts index 27364943418..9bf0b4ad044 100644 --- a/packages/runtime/src/flow-start-confirmation-gated-target.test.ts +++ b/packages/runtime/src/flow-start-confirmation-gated-target.test.ts @@ -410,6 +410,19 @@ describe('the declarations are read from the services the request\'s own /action expectConfirmationRefusal(await start(new HttpDispatcher(host as never), { kernel: env, environmentId: ENV_ID }), automation.execute); }); + it('kernel-resolver host: where the request\'s own kernel fails to resolve the slot and the host kernel answers it, the start is judged on the host instance, as the /actions door would serve it', async () => { + const host = bareKernel(); + host.registerService('protocol', protocolServing(true)); + const env = bareKernel(); + const automation = automationService(); + env.registerService('automation', automation); + env.registerServiceFactory('protocol', () => { throw new Error('environment protocol factory failed'); }); + // The request's own slot is wired and fails, not absent: the case is not vacuous. + await expect(env.getServiceAsync('protocol')).rejects.toThrow('environment protocol factory failed'); + + expectConfirmationRefusal(await start(new HttpDispatcher(host as never), { kernel: env, environmentId: ENV_ID }), automation.execute); + }); + it('kernel-resolver host: a shape that merely lacks every source gains no 503 — the account starts the flow', async () => { const host = bareKernel(); const env = bareKernel(); From d27cc149b3c2fc645da139f35f346aac750c93c4 Mon Sep 17 00:00:00 2001 From: Claude Date: Sun, 15 Nov 2026 11:00:48 +0000 Subject: [PATCH 9/9] docs(runtime): the engine-slot comment states rule 2b's resolution rule, and per-leg loud resolution is named as a shared follow-up Claude-Session: https://claude.ai/code/session_017xRBcT1w3zpekijraHJE4f Co-authored-by: Claude --- packages/runtime/src/domains/automation.ts | 9 +++++++-- .../src/flow-start-confirmation-gated-target.test.ts | 3 ++- 2 files changed, 9 insertions(+), 3 deletions(-) diff --git a/packages/runtime/src/domains/automation.ts b/packages/runtime/src/domains/automation.ts index 768efea93e5..7b15079f6eb 100644 --- a/packages/runtime/src/domains/automation.ts +++ b/packages/runtime/src/domains/automation.ts @@ -3029,6 +3029,10 @@ async function unregisterAndDeleteFlow( * * Scoped by the request's environment, as the door's reads are: unscoped, a * scoped registration is a fault to the classifier. + * + * Per-leg loud resolution (a wired slot that fails on an earlier step refuses + * even when a later step answers) is a shared resolver change for every + * dispatcher door, tracked by the security lane; it is not in this function. */ async function resolveSlotAsActionsDoorReads( deps: DomainHandlerDeps, @@ -3082,8 +3086,9 @@ async function servedActionDeclarations( return collectActionDeclarations(deps, undefined, objects, actions); } const rows: Array<{ action: unknown; objectName: string }> = []; - // The engine the `/actions` door's `getObjectQL` reads, resolved so that a - // wired slot that fails to resolve is loud, which that probe is not. + // The engine the `/actions` door's `getObjectQL` reads. A slot that no step + // of that door's order answers, because a step failed to resolve it, throws, + // which that probe does not; where a later step answers, that engine is read. const engine = (await resolveSlotAsActionsDoorReads(deps, context, 'objectql')) as | { registry?: { listItems?: (type: string) => unknown[] } } | undefined; diff --git a/packages/runtime/src/flow-start-confirmation-gated-target.test.ts b/packages/runtime/src/flow-start-confirmation-gated-target.test.ts index 9bf0b4ad044..4dca5dbfe81 100644 --- a/packages/runtime/src/flow-start-confirmation-gated-target.test.ts +++ b/packages/runtime/src/flow-start-confirmation-gated-target.test.ts @@ -410,7 +410,8 @@ describe('the declarations are read from the services the request\'s own /action expectConfirmationRefusal(await start(new HttpDispatcher(host as never), { kernel: env, environmentId: ENV_ID }), automation.execute); }); - it('kernel-resolver host: where the request\'s own kernel fails to resolve the slot and the host kernel answers it, the start is judged on the host instance, as the /actions door would serve it', async () => { + // Records today's limitation: this answer changes when per-leg loud resolution lands for every dispatcher door. + it('kernel-resolver host (records today\'s limitation, changes when per-leg loud resolution lands): where the request\'s own kernel fails to resolve the slot and the host kernel answers it, the start is judged on the host instance, as the /actions door would serve it', async () => { const host = bareKernel(); host.registerService('protocol', protocolServing(true)); const env = bareKernel();