diff --git a/.changeset/34209-retire-mcp-action-confirm-member.md b/.changeset/34209-retire-mcp-action-confirm-member.md new file mode 100644 index 00000000000..10f477bdbcd --- /dev/null +++ b/.changeset/34209-retire-mcp-action-confirm-member.md @@ -0,0 +1,24 @@ +--- +'@objectstack/mcp': patch +'@objectstack/spec': patch +'@object-ui/console': patch +--- + +feat(mcp,spec)!: `run_action` and `resume_run` refuse the `confirm` member — confirmation happens in the app, by the person + +Clause-②: yes (narrowing) +Metadata-protocol: none (the retired member belongs to an MCP tool's input, not to a key a metadata author writes; `ai.requiresConfirmation` keeps its meaning. The dev confirms against the diff.) + + + +**BREAKING** for an MCP client, an agent or a script that sends `confirm` to the `run_action` or `resume_run` tool. Ruled by the maintainer: the member is retired, so a stale client is refused loudly instead of silently ignored. Since the hand-off to the person in the app, the caller's `confirm: true` confirmed nothing on these two tools; now a call that carries the member at all is refused. + +- `run_action` and `resume_run` no longer declare `confirm`. A call that carries it, `true` or `false`, is refused by the tool's closed input, the same refusal any undeclared argument gets. This applies on every action, whether or not it declares `ai.requiresConfirmation`. The refusal names the member and says that confirmation happens in the app, by the person, or in the client when it supports elicitation and the connection can carry the question. Nothing is resolved or run. +- Unchanged: a call without the member on a declared-gated action is confirmed by the person. A client that advertised `elicitation` on a connection that can carry the question (stdio) has the person asked in the client, and `accept` runs the call. Otherwise the call is handed to the person (`status: 'pending_confirmation'`), or refused `428 ACTION_CONFIRMATION_REQUIRED` with `details.reason: 'no_confirmation_service'` on a host with no pending-confirmation service. The MCP `delete_record` and `delete_records` tools still require `confirm: true`. A host's own door (`dispatchAction`) under the `ai` posture still reads `confirm`. +- The served MCP skill (and the console's downloadable copy of it), the `tool.requiresConfirmation` retirement guidance in `@objectstack/spec`, and the contract prose in `@objectstack/spec/contracts` stop teaching `confirm: true` on these two tools. The upgrade-guide entry `action-requires-confirmation-elicited` now keys its switch on the hand-off rather than on elicitation, and names the refusal of the member. + +What changes for a caller: + +- FROM `run_action({ actionName, recordId, confirm: true })` (accepted, not read) TO `run_action({ actionName, recordId })`. Relay a `pending_confirmation` answer to the person and let them approve it in the app (or let them answer the question in their client, where it is asked there); do not retry. +- FROM `resume_run({ runId, values, confirm: true })` TO `resume_run({ runId, values })`. +- To fix a client: stop sending `confirm` to `run_action` and `resume_run`. Keep sending it to `delete_record` and `delete_records`. diff --git a/content/docs/ai/actions-as-tools.mdx b/content/docs/ai/actions-as-tools.mdx index b2c2bf5dae7..57ea5cc8034 100644 --- a/content/docs/ai/actions-as-tools.mdx +++ b/content/docs/ai/actions-as-tools.mdx @@ -128,6 +128,15 @@ through the API. Destructive actions (`confirmText`, `mode: 'delete'`, `requiresConfirmation: true` so the client can ask the human before calling. To assert that a destructive-looking action is safe for autonomous execution, set `ai.requiresConfirmation: false`. +An action whose author declared `ai.requiresConfirmation: true` runs on an +agent's `run_action` call only once the person the agent acts for confirms it: +in the client, when the client supports elicitation and the connection can carry +the question (accept runs the call once; decline, dismissal or no answer in time +refuses it `ACTION_CONFIRMATION_REQUIRED`), and in the app otherwise: the call +does not run, it is handed to the person, who approves or rejects it there +(`status: "pending_confirmation"`), or it is refused `428` +`ACTION_CONFIRMATION_REQUIRED` on a server with no pending-confirmation service. The agent cannot confirm for the person: `run_action` +and `resume_run` refuse a call that carries `confirm`, on every action. An AI service account does not confirm an action for itself: an action declaring `ai.requiresConfirmation: true` refuses it at every door, REST `/actions` included, whatever the request carries, and a person runs that action. @@ -205,9 +214,14 @@ on the same record for this caller: answer the same `404`, so a run id says nothing about runs you did not start. - **The same gates as `run_action`.** A flow action exposed to AI (`ai.exposed`) must target the run's flow on the run's object, and the caller - must pass its `requiredPermissions` and its activation switch. An action - flagged `ai.requiresConfirmation` needs `confirm: true` on the resume as well, - because the flow's writes happen after the screen. + must pass its `requiredPermissions` and its activation switch. When the + action's author declared `ai.requiresConfirmation: true`, the resume needs + the person as well, because the flow's writes happen after the screen: they + are asked in the client when it supports elicitation and the connection can + carry the question (accept continues the run; any other answer refuses the + call and the run stays paused), and otherwise the run stays paused until they + approve it in the app. `resume_run` + takes no `confirm`; a call that carries it is refused. - **The record is read again as you.** A subject record you can no longer read is refused `RECORD_NOT_FOUND` (`404`), as `run_action` refuses it. - **Screens only.** A run waiting on anything other than a screen (a timer diff --git a/content/docs/ai/connect-mcp.mdx b/content/docs/ai/connect-mcp.mdx index 562b1883b1e..4b58bba2870 100644 --- a/content/docs/ai/connect-mcp.mdx +++ b/content/docs/ai/connect-mcp.mdx @@ -418,8 +418,11 @@ can reach is the **default exposure policy (v1)**: an organization, re-enabling an OAuth application) are exposed. Destructive lifecycle acts (banning a user, revoking a session or an API key, removing a member, deleting a team, leaving an organization) are exposed with - `ai.requiresConfirmation: true`, so `run_action` refuses them until the call - carries `confirm: true`. Acts that mint a credential or a session, change + `ai.requiresConfirmation: true`, so `run_action` runs them only once the + person confirms: in the client when it supports elicitation and the + connection can carry the question, and otherwise it hands each one to the + person in the app, or refuses it (`428`) on a server with no + pending-confirmation service. Acts that mint a credential or a session, change ownership or a sign-in factor, or destroy an account or an organization (impersonating a user, setting a password, creating an API key, transferring ownership, deleting an organization) declare nothing and are not listed. The @@ -430,7 +433,10 @@ can reach is the **default exposure policy (v1)**: - **An approver's decisions are exposed to the approver's agent.** The four decisions on an approval request (`sys_approval_request`): approve, reject, reassign and send back, are exposed with `ai.requiresConfirmation: true`, so - `run_action` decides only once the call carries `confirm: true`. Each forwards + `run_action` decides only once the approver confirms: in the client when it + supports elicitation and the connection can carry the question, and + otherwise in the app, or the call is refused (`428`) on a server with no + pending-confirmation service. Once confirmed, each forwards to its approvals route as the caller, and the approval service admits the same people the console's buttons admit: a current approver of the request, and, for approve, reject and reassign, the administrator who may override it. @@ -597,7 +603,24 @@ drive this MCP server. Same word, different layer. gate and `requiredPermissions` are checked at *invoke* time). Treat writing an action as a code-review-worthy act — that's the real security boundary. - An action can also declare `ai.requiresConfirmation`; destructive-looking - actions (`confirmText`, danger variants) default to requiring it. + actions (`confirmText`, danger variants) are listed with + `requiresConfirmation: true` by default, so a client asks its human first. +- **A person confirms a declared-gated action, in the client or in the app.** + When the author declared `ai.requiresConfirmation: true`, the agent's call + on `run_action` or `resume_run` runs only once the person the agent acts for + confirms it. When the client supports elicitation and the connection can + carry the question (a stdio connection, today), the person is asked in the + client: accept runs the call once; decline, dismissal or no answer in time + refuses it (`ACTION_CONFIRMATION_REQUIRED`, `details.reason` `declined`, + `cancelled` or `timed_out`). Otherwise the tools do not run the action on + the call: they hand it to the person and answer + `status: "pending_confirmation"` with a `pendingId`, and the person approves + or rejects it in the app. A server with no + pending-confirmation service refuses the call (`428` + `ACTION_CONFIRMATION_REQUIRED`, `details.reason: "no_confirmation_service"`), + and the person performs the action in the app. Neither tool takes `confirm`: + a call that carries it is refused, on every action, and the agent resends + without it. - **An AI service account does not confirm an action for itself.** An action declaring `ai.requiresConfirmation: true` refuses an AI service account's key (`428` `ACTION_CONFIRMATION_REQUIRED`) at `run_action`, `resume_run` and REST diff --git a/examples/app-todo/test/mcp-actions.test.ts b/examples/app-todo/test/mcp-actions.test.ts index 5aed6e4aa9d..8c313863212 100644 --- a/examples/app-todo/test/mcp-actions.test.ts +++ b/examples/app-todo/test/mcp-actions.test.ts @@ -241,19 +241,29 @@ describe('app-todo business actions over MCP (CE runtime, no service-ai)', () => const gatedId = await seedTask('Needs a human'); - // 7a/7b — [#33690] WITH the member and WITHOUT it alike: this app registers - // no pending-confirmation service, so the call is refused with the - // declared code and `details.reason: 'no_confirmation_service'`, and - // NOTHING ran. Before the amended contract 7b (with `confirm: true`) ran - // the handler; the member now travels the whole path and confers nothing. - for (const [id, extra] of [[12, {}], [13, { confirm: true }]] as const) { - const refused = await callMcp(confirmBridge, toolsCall(id, 'run_action', { actionName: 'todo_complete_task', recordId: gatedId, ...extra })); - expect(refused.result?.isError).toBe(true); - const refusedEnvelope = JSON.parse(refused.result?.content?.[0]?.text ?? '{}'); - expect(refusedEnvelope?.error?.code).toBe('ACTION_CONFIRMATION_REQUIRED'); - expect(refusedEnvelope?.error?.status).toBe(428); - expect(refusedEnvelope?.error?.details?.actionName).toBe('todo_complete_task'); - expect(refusedEnvelope?.error?.details?.reason).toBe('no_confirmation_service'); + // 7a — [#33690] Without the member: this app registers no + // pending-confirmation service, so the call is refused with the declared + // code and `details.reason: 'no_confirmation_service'`, and NOTHING ran. + const refused = await callMcp(confirmBridge, toolsCall(12, 'run_action', { actionName: 'todo_complete_task', recordId: gatedId })); + expect(refused.result?.isError).toBe(true); + const refusedEnvelope = JSON.parse(refused.result?.content?.[0]?.text ?? '{}'); + expect(refusedEnvelope?.error?.code).toBe('ACTION_CONFIRMATION_REQUIRED'); + expect(refusedEnvelope?.error?.status).toBe(428); + expect(refusedEnvelope?.error?.details?.actionName).toBe('todo_complete_task'); + expect(refusedEnvelope?.error?.details?.reason).toBe('no_confirmation_service'); + expect(await statusOf(gatedId)).toBe('not_started'); + + // 7b — [#34209] WITH the member: the member is retired, so the tool's + // closed input refuses the call before the runtime is reached — on the + // gated action and on an ungated one alike — and NOTHING ran. Before the + // amended contract this call ran the handler; under #33690 it reached the + // gate and conferred nothing; now it never gets past the input. + for (const [id, actionName] of [[13, 'todo_complete_task'], [15, 'todo_delete_completed']] as const) { + const withMember = await callMcp(confirmBridge, toolsCall(id, 'run_action', { actionName, recordId: gatedId, confirm: true })); + expect(withMember.result?.isError, actionName).toBe(true); + const text = withMember.result?.content?.[0]?.text ?? ''; + expect(text, actionName).toContain('`confirm`'); + expect(text, actionName).not.toContain('"ACTION_CONFIRMATION_REQUIRED"'); expect(await statusOf(gatedId)).toBe('not_started'); } diff --git a/packages/mcp/src/mcp-action-confirmation-handoff-33690.test.ts b/packages/mcp/src/mcp-action-confirmation-handoff-33690.test.ts index d5578b94d1b..54e43da4e61 100644 --- a/packages/mcp/src/mcp-action-confirmation-handoff-33690.test.ts +++ b/packages/mcp/src/mcp-action-confirmation-handoff-33690.test.ts @@ -9,7 +9,12 @@ * is the call's SUCCESSFUL answer: not an error result, the pending id and * message intact, so an agent tells its person where to approve; * - the `no_confirmation_service` refusal keeps the registered envelope - * (`428 ACTION_CONFIRMATION_REQUIRED`) with `details.reason`. + * (`428 ACTION_CONFIRMATION_REQUIRED`) with `details.reason`; + * - [#34209] the `confirm` member is RETIRED from both tools (maintainer + * ruling 6909355256): a call carrying it, `true` or `false`, on any action, + * gated or not, is refused by the tool's closed input with the same + * unknown-key refusal any undeclared key gets, and the bridge is never + * called. The pins that accepted it (#33690) are flipped below. * * The bridge is a double standing in for the runtime door, whose hand-off is * pinned in `packages/runtime/src/action-confirmation-handoff-33690.test.ts`; @@ -108,27 +113,30 @@ async function call(bridge: McpDataBridge & McpActionBridge, body: unknown): Pro } describe('[#33690] run_action and resume_run relay a hand-off as the call\'s successful answer', () => { - it('run_action: each confirm: true call answers pending_confirmation with its own pending id, never an error', async () => { + it('run_action: each call answers pending_confirmation with its own pending id, never an error', async () => { const bridge = makeBridge('service'); for (let i = 1; i <= 3; i++) { - const json = await call(bridge, toolsCall(i, 'run_action', { actionName: GATED, recordId: 'a1', [AI_ACTION_CONFIRMATION_MEMBER]: true })); + const json = await call(bridge, toolsCall(i, 'run_action', { actionName: GATED, recordId: 'a1' })); expect(json.result.isError).toBeFalsy(); expect(JSON.parse(json.result.content[0].text)).toEqual(pendingOf(i)); } + // [#34209] The tool forwards no confirmation member at all. + for (const [, , input] of bridge.calls) expect(input).not.toHaveProperty(AI_ACTION_CONFIRMATION_MEMBER); }); it('resume_run: the hand-off is relayed the same way', async () => { const bridge = makeBridge('service'); - const json = await call(bridge, toolsCall(1, 'resume_run', { runId: 'run_1', values: { reason: 'x' }, [AI_ACTION_CONFIRMATION_MEMBER]: true })); + const json = await call(bridge, toolsCall(1, 'resume_run', { runId: 'run_1', values: { reason: 'x' } })); expect(json.result.isError).toBeFalsy(); expect(JSON.parse(json.result.content[0].text)).toEqual(pendingOf(1)); - expect(bridge.calls[0]).toEqual(['resumeRun', 'run_1', { values: { reason: 'x' }, [AI_ACTION_CONFIRMATION_MEMBER]: true }]); + // Exactly the values: no confirmation member, not even an `undefined` one. + expect(bridge.calls[0]).toStrictEqual(['resumeRun', 'run_1', { values: { reason: 'x' } }]); }); it('no service: the refusal keeps the registered envelope and carries details.reason', async () => { for (const [tool, args] of [ - ['run_action', { actionName: GATED, recordId: 'a1', [AI_ACTION_CONFIRMATION_MEMBER]: true }], - ['resume_run', { runId: 'run_1', [AI_ACTION_CONFIRMATION_MEMBER]: true }], + ['run_action', { actionName: GATED, recordId: 'a1' }], + ['resume_run', { runId: 'run_1' }], ] as const) { const json = await call(makeBridge('none'), toolsCall(1, tool, args)); expect(json.result.isError, tool).toBe(true); @@ -139,14 +147,73 @@ describe('[#33690] run_action and resume_run relay a hand-off as the call\'s suc }); } }); +}); + +/** + * [#34209] The retired member. Both tools answer a call that carries it with + * the closed input's unknown-key refusal: the SAME shape an undeclared key such + * as `bogus` gets (a tool error naming the key, no ADR-0112 code of its own), + * before the bridge is reached. The ruling: refused outright, on every action, + * including one that declares no confirmation, whatever value it carries. + */ +describe('[#34209] run_action and resume_run refuse the retired confirm member outright', () => { + /** The refusal's leading statement: everything before the key list. */ + const statementOf = (text: string) => text.slice(0, text.indexOf('`')); + + const CASES = [ + ['run_action', { actionName: GATED, recordId: 'a1' }], + // An action that declares no confirmation: refused all the same. + ['run_action', { actionName: 'touch_account', recordId: 'a1' }], + ['resume_run', { runId: 'run_1', values: { reason: 'x' } }], + ] as const; + + it('refuses the member with true and with false, on a gated and an ungated action, and never calls the bridge', async () => { + for (const [tool, args] of CASES) { + for (const value of [true, false]) { + const bridge = makeBridge('service'); + const json = await call(bridge, toolsCall(1, tool, { ...args, [AI_ACTION_CONFIRMATION_MEMBER]: value })); + const label = `${tool} ${JSON.stringify(args)} confirm=${value}`; + expect(json.result?.isError, label).toBe(true); + const text: string = json.result.content.map((c: any) => c.text).join('\n'); + expect(text, label).toContain(`\`${AI_ACTION_CONFIRMATION_MEMBER}\``); + // The prescription rides the refusal: the person confirms, in the app. + expect(text, label).toContain('in the app'); + expect(bridge.calls, label).toEqual([]); + } + } + }); - it('the member stays accepted on both tools, so a call carrying it is not refused for it', async () => { + it('is the unknown-key refusal every undeclared key gets: same statement, no code of its own', async () => { + for (const [tool, args] of CASES) { + const member = await call(makeBridge('service'), toolsCall(1, tool, { ...args, [AI_ACTION_CONFIRMATION_MEMBER]: true })); + const unknown = await call(makeBridge('service'), toolsCall(1, tool, { ...args, bogus: true })); + const memberText: string = member.result.content[0].text; + const unknownText: string = unknown.result.content[0].text; + expect(unknown.result.isError, tool).toBe(true); + expect(statementOf(memberText), tool).toBe(statementOf(unknownText)); + expect(statementOf(memberText).length, `${tool}: the statement read empty`).toBeGreaterThan(10); + // Not an ADR-0112 envelope: no second code is minted for the member. + expect(memberText, tool).not.toContain('ACTION_CONFIRMATION_REQUIRED","status"'); + expect(() => JSON.parse(memberText), tool).toThrow(); + } + }); + + it('neither tool advertises the member, and both stay closed against it', async () => { const json = await call(makeBridge('service'), { jsonrpc: '2.0', id: 1, method: 'tools/list' }); for (const name of ['run_action', 'resume_run']) { const tool = json.result.tools.find((t: any) => t.name === name); - expect(tool?.inputSchema.properties[AI_ACTION_CONFIRMATION_MEMBER]?.type, name).toBe('boolean'); + // Control: the tool is listed with its real members, so the absence below is real. + expect(Object.keys(tool?.inputSchema.properties ?? {}).length, name).toBeGreaterThan(0); + expect(tool.inputSchema.properties, name).not.toHaveProperty(AI_ACTION_CONFIRMATION_MEMBER); + expect(tool.inputSchema.additionalProperties, name).toBe(false); } }); + + it('CONTROL: the delete tools keep the member, so the retirement is these two tools only', async () => { + const json = await call(makeBridge('service'), { jsonrpc: '2.0', id: 1, method: 'tools/list' }); + const del = json.result.tools.find((t: any) => t.name === 'delete_record'); + expect(del?.inputSchema.properties?.[AI_ACTION_CONFIRMATION_MEMBER]?.type).toBe('boolean'); + }); }); // --------------------------------------------------------------------------- diff --git a/packages/mcp/src/mcp-action-confirmation-member.test.ts b/packages/mcp/src/mcp-action-confirmation-member.test.ts index 058202d0dd8..4b4aee747ef 100644 --- a/packages/mcp/src/mcp-action-confirmation-member.test.ts +++ b/packages/mcp/src/mcp-action-confirmation-member.test.ts @@ -1,8 +1,15 @@ // Copyright (c) 2026 ObjectStack. Licensed under the Apache-2.0 license. /** - * [#15942 / #16293] The `run_action` door carries the confirmation member — - * and the ADR-0112 refusal that member exists to satisfy. + * [#15942 / #16293] The `run_action` door carried the confirmation member — + * and the ADR-0112 refusal that member existed to satisfy. + * + * [#34209] RETIRED (maintainer ruling 6909355256). Since the hand-off (#33690) + * the member confirmed nothing, so it is no longer declared: the closed input + * refuses a call that carries it, and the tool forwards no member to the + * bridge. The pins below that asserted the member was advertised, forwarded + * and satisfied the gate are FLIPPED to assert the opposite; the strip story + * that follows is why the closed shape, and not a silent drop, is the answer. * * ## Why this file drives the REAL door * @@ -49,10 +56,10 @@ import type { McpDataBridge, McpActionBridge } from './mcp-http-tools.js'; const GATED = 'archive_account'; /** - * A bridge that reproduces the runtime gate's OBSERVABLE contract: it refuses - * the gated action unless the request carries the member as boolean `true`, - * throwing the same `code` / `status` / `details` envelope - * `actionConfirmationRefusal` produces. + * A bridge that reproduces the runtime door's OBSERVABLE answer for a gated + * action on a host with no pending-confirmation service: it refuses the gated + * action whatever the request carries, throwing the `code` / `status` / + * `details` envelope the runtime produces (#33690). */ function makeBridge(): McpDataBridge & McpActionBridge & { calls: any[] } { const calls: any[] = []; @@ -86,7 +93,7 @@ function makeBridge(): McpDataBridge & McpActionBridge & { calls: any[] } { }, async runAction(name: string, input: any) { calls.push([name, input]); - if (name === GATED && input?.[AI_ACTION_CONFIRMATION_MEMBER] !== true) { + if (name === GATED) { throw Object.assign( new Error( `Action '${GATED}' on 'account' declares ai.requiresConfirmation: true — nothing was run.`, @@ -98,6 +105,7 @@ function makeBridge(): McpDataBridge & McpActionBridge & { calls: any[] } { actionName: GATED, objectName: 'account', confirmationMember: AI_ACTION_CONFIRMATION_MEMBER, + reason: 'no_confirmation_service', }, }, ); @@ -133,73 +141,68 @@ describe('run_action carries the confirmation member through the real MCP door ( bridge = makeBridge(); }); - it('advertises the member on the tool schema, so a model can DISCOVER the retry', async () => { + it('[#34209] no longer advertises the member on the tool schema, and the shape is closed', async () => { const json = await call({ jsonrpc: '2.0', id: 1, method: 'tools/list' }); const runAction = json.result.tools.find((t: any) => t.name === 'run_action'); const props = runAction.inputSchema.properties; - // Control: the pre-existing members are still advertised, so a missing - // `confirm` below would be a real absence and not an empty read. + // Control: the pre-existing members are still advertised, so the missing + // `confirm` below is a real absence and not an empty read. expect(Object.keys(props)).toEqual( expect.arrayContaining(['actionName', 'objectName', 'recordId', 'params']), ); - expect(Object.keys(props)).toContain(AI_ACTION_CONFIRMATION_MEMBER); - expect(props[AI_ACTION_CONFIRMATION_MEMBER].type).toBe('boolean'); + expect(Object.keys(props)).not.toContain(AI_ACTION_CONFIRMATION_MEMBER); + expect(runAction.inputSchema.additionalProperties).toBe(false); }); - it('REFUSES a gated action with no member — code, status and the retry details', async () => { + it('relays a gated refusal with its code, status and details, and forwards no member', async () => { const json = await call(toolsCall(2, 'run_action', { actionName: GATED, recordId: 'a1' })); expect(json.result.isError).toBe(true); const envelope = JSON.parse(json.result.content[0].text); expect(envelope.error.code).toBe('ACTION_CONFIRMATION_REQUIRED'); expect(envelope.error.status).toBe(428); - // The machine-readable half: a refused agent rebuilds the retry from this - // WITHOUT re-parsing the message prose. + // The machine-readable half survives the tool unflattened. expect(envelope.error.details).toEqual({ actionName: GATED, objectName: 'account', confirmationMember: AI_ACTION_CONFIRMATION_MEMBER, + reason: 'no_confirmation_service', }); - // …and the door really did forward a request with no confirmation. expect(bridge.calls).toHaveLength(1); - expect(bridge.calls[0][1][AI_ACTION_CONFIRMATION_MEMBER]).toBeUndefined(); + expect(bridge.calls[0][1]).not.toHaveProperty(AI_ACTION_CONFIRMATION_MEMBER); }); - it('SUCCEEDS on the retry — the member survives both strip layers', async () => { + it('[#34209] REFUSES a retry carrying `confirm: true` at the input: the bridge never sees it', async () => { const json = await call( toolsCall(3, 'run_action', { actionName: GATED, recordId: 'a1', [AI_ACTION_CONFIRMATION_MEMBER]: true }), ); - // The assertion the whole card turns on: before this change the member was - // dropped here and this call was refused exactly like the one above. - expect(bridge.calls[0][1][AI_ACTION_CONFIRMATION_MEMBER]).toBe(true); - expect(json.result.isError).toBeFalsy(); - expect(JSON.parse(json.result.content[0].text)).toMatchObject({ ok: true, result: { archived: true } }); + // Flipped: before the retirement this call reached the bridge with the + // member set. Now the closed shape refuses it before dispatch. + expect(json.result.isError).toBe(true); + expect(json.result.content[0].text).toContain(`\`${AI_ACTION_CONFIRMATION_MEMBER}\``); + expect(bridge.calls).toHaveLength(0); }); - it('forwards `recordId` and `params` unchanged beside the member', async () => { + it('forwards exactly `objectName`, `recordId` and `params`, and no member', async () => { await call( toolsCall(4, 'run_action', { - actionName: GATED, + actionName: 'other_action', objectName: 'account', recordId: 'a1', params: { reason: 'dupe' }, - [AI_ACTION_CONFIRMATION_MEMBER]: true, }), ); - expect(bridge.calls[0][1]).toEqual({ + expect(bridge.calls[0][1]).toStrictEqual({ objectName: 'account', recordId: 'a1', params: { reason: 'dupe' }, - [AI_ACTION_CONFIRMATION_MEMBER]: true, }); }); - it('is a CLOSED boolean — a truthy string is refused by the door, not passed on', async () => { + it('a truthy string is refused at the input too, never passed on', async () => { const json = await call( toolsCall(5, 'run_action', { actionName: GATED, recordId: 'a1', [AI_ACTION_CONFIRMATION_MEMBER]: 'true' }), ); expect(json.result.isError).toBe(true); - // A transport artefact must never read as an attestation, and the wrong - // failure here would be it reaching the bridge as a truthy value. expect(bridge.calls).toHaveLength(0); }); diff --git a/packages/mcp/src/mcp-http-tools.ts b/packages/mcp/src/mcp-http-tools.ts index 45388c68eee..13dced8027f 100644 --- a/packages/mcp/src/mcp-http-tools.ts +++ b/packages/mcp/src/mcp-http-tools.ts @@ -76,10 +76,10 @@ import { type QueryDatasetInput, type QueryDatasetOutput, } from '@objectstack/spec/ai'; -// [#15942 / #16293] The confirmation member the `run_action` door accepts and -// forwards. Imported, never hand-spelled: the door that refuses (the runtime's -// `actionConfirmationRefusal`) and the client that retries have to agree on the -// spelling, and this door is the one that has to advertise it. +// [#15942 / #16293] The confirmation member the delete tools require. Imported, +// never hand-spelled: the gate that refuses and the client that retries have to +// agree on the spelling. [#34209] `run_action` and `resume_run` REFUSE the same +// spelling at their input, so they key the refusal off this constant too. import { AI_ACTION_CONFIRMATION_MEMBER, type AIActionConfirmation, @@ -2044,8 +2044,9 @@ function withoutHistorySentence(map: z.core.$ZodErrorMap): z.core.$ZodErrorMap { * payload the undeclared keys have already been deleted from. The handler * cannot report what it never received — this is not a handler bug, and no * amount of care inside one can fix it. `run_action`'s confirmation member - * carries the same finding from the other side ("Under zod an undeclared key is - * DROPPED, not rejected"), and had to be *declared* for exactly this reason. + * carried the same finding from the other side ("Under zod an undeclared key is + * DROPPED, not rejected"), and had to be *declared* for exactly this reason + * until its retirement (#34209) made the closed shape refuse it instead. * * Handing `registerTool` a built `.strict()` object instead moves the decision * one frame up, to the only place that can still see the key: the SDK refuses @@ -2097,7 +2098,17 @@ function withoutHistorySentence(map: z.core.$ZodErrorMap): z.core.$ZodErrorMap { * factory rather than a second implementation of it. */ function strictToolInput( - options: { surface: string; aliases?: Readonly> }, + options: { + surface: string; + aliases?: Readonly>; + /** + * [#34209] Exact-key prescriptions for a member this tool RETIRED: the + * factory's `guidance` channel, so a retired member is refused by the same + * unknown-key refusal as any other undeclared key, with the prescription + * in place of a rename guess. No code of its own is minted. + */ + retired?: Readonly>; + }, shape: T, ) { return z @@ -2106,18 +2117,40 @@ function strictToolInput( surface: options.surface, knownKeys: Object.keys(shape), aliases: options.aliases, + guidance: options.retired, history: '', // These argument shapes are not protocol metadata and never carried a - // retirement kit, so no unknown key here is a retired key: the - // upgrade-guide pointer would send an agent to a page unrelated to - // its mistake. Only the tools closed HERE opt out; the dataset pair - // takes spec `strictObject` schemas and keeps the spec refusal. + // retirement kit, so the upgrade-guide pointer would send an agent to + // a page unrelated to its mistake. A member a tool retires carries its + // prescription inline instead (`retired` above). Only the tools closed + // HERE opt out; the dataset pair takes spec `strictObject` schemas and + // keeps the spec refusal. retiredKeyUpgradeGuide: false, })), }) .strict(); } +/** + * [#34209] The prescription `run_action` and `resume_run` refuse the retired + * confirmation member with (maintainer ruling 6909355256): the caller's + * `confirm` never confirmed a declared-gated action after the hand-off, so a + * stale client is refused loudly rather than silently ignored, on EVERY action, + * gated or not. The refusal is the closed input's unknown-key refusal, so it + * arrives before the bridge is called and nothing runs. The delete tools are + * outside the ruling and keep the member. + */ +const RETIRED_CONFIRMATION_MEMBER: Readonly> = { + [AI_ACTION_CONFIRMATION_MEMBER]: + `\`${AI_ACTION_CONFIRMATION_MEMBER}\` is not accepted here: you cannot confirm an action for the person. ` + + 'Confirmation happens in the app, by the person you act for, or in your client when it supports ' + + 'elicitation and this connection can carry the question: an action its author declared ' + + 'ai.requiresConfirmation: true is asked of them there, or handed to them and answered status ' + + '"pending_confirmation" (or, where the server cannot hand it off, refused ACTION_CONFIRMATION_REQUIRED and ' + + 'performed in the app), and every other ' + + `action runs without it. Resend this call without \`${AI_ACTION_CONFIRMATION_MEMBER}\`.`, +}; + /** * The spellings every object-scoped tool shares, split out because they are the * same guess wherever an object name is taken. @@ -3383,8 +3416,9 @@ export function registerActionTools( // [#33690] The amended confirmation contract: the caller's `confirm` // never counts on an action whose author declared // `ai.requiresConfirmation: true`; the person is asked in the app. - 'An action its author declared ai.requiresConfirmation: true never runs on this call, and confirm: true ' + - 'does not change that: the call is handed to the person you act for, who approves or rejects it in ' + + // [#34209] The member is retired: a call carrying it is refused. + 'An action its author declared ai.requiresConfirmation: true never runs on this call: the call is ' + + 'handed to the person you act for, who approves or rejects it in ' + 'the app, and you are answered status "pending_confirmation" with a pendingId and a message to pass on. ' + 'Nothing has run then; do not retry, tell the user to approve it. Where the server cannot hand it off, ' + 'the call is refused ACTION_CONFIRMATION_REQUIRED (details.reason "no_confirmation_service"): the user ' + @@ -3413,6 +3447,7 @@ export function registerActionTools( inputSchema: strictToolInput( { surface: 'this run_action call', + retired: RETIRED_CONFIRMATION_MEMBER, aliases: { ...OBJECT_NAME_ALIASES, ...RECORD_ID_ALIASES, @@ -3453,30 +3488,12 @@ export function registerActionTools( .record(z.string(), z.unknown()) .optional() .describe('Input parameters declared by the action.'), - // [#15942 / #16293] The confirmation member — a CLOSED boolean at the - // TOP LEVEL of the request, keyed off the contract's own constant so - // this door cannot spell it differently from the door that refuses. - // - // WHY IT IS DECLARED HERE AND NOT ONLY ENFORCED IN THE RUNTIME. Under - // zod an undeclared key is DROPPED, not rejected: before this member - // existed a client that sent `confirm: true` had it silently stripped - // by the SDK's shape wrap and then again by this handler's forward, so - // enforcing the gate alone would have made every action declaring - // `ai.requiresConfirmation: true` permanently un-invokable over MCP — - // refused, retried with the member, stripped, refused again. The door - // grows the member in the same change that enforces it. - // - // It is also how the model DISCOVERS the retry: an agent reads the tool - // schema, so a member that lives only in the refusal prose (or in a - // transport header) is one it cannot see. - [AI_ACTION_CONFIRMATION_MEMBER]: z - .boolean() - .optional() - .describe( - 'Not read by this tool: an action its author declared ai.requiresConfirmation: true is handed ' - + 'to the person to approve in the app whatever this member says, and any other action runs ' - + 'without it. Accepted so that a call carrying it is not refused for it.', - ), + // [#34209] No confirmation member. It was declared here (#15942) while + // the caller's `confirm: true` was the confirmation; since the + // hand-off (#33690) it confirmed nothing, and the maintainer retired + // it (ruling 6909355256). Undeclared, the closed shape refuses it with + // `RETIRED_CONFIRMATION_MEMBER`'s prescription, before the bridge is + // called, on every action — `tools/list` shows it absent. }, ), // Actions execute app-defined business logic with side effects (writes, @@ -3488,9 +3505,6 @@ export function registerActionTools( async (args, extra) => { const { recordId, params } = args; let { actionName, objectName, namespace } = args; - // Read off the constant, so the member's spelling has exactly one - // authority in this package (the schema key above is the same constant). - const confirm = args[AI_ACTION_CONFIRMATION_MEMBER]; if (!actionName || typeof actionName !== 'string') { return errorResult('actionName is required'); } @@ -3531,10 +3545,9 @@ export function registerActionTools( ...(namespace !== undefined ? { namespace } : {}), recordId, params, - // [#15942] Forwarded, not rebuilt-without. This line and the schema - // key above are the two halves of one change: dropping either one - // restores the strip that made the gate unsatisfiable. - [AI_ACTION_CONFIRMATION_MEMBER]: confirm, + // [#34209] No confirmation member: the closed input refuses it, so + // none reaches here to forward. Elicitation asks the person through + // the door below and never read the caller's member. }; // [#33712] Step 1 of the amended confirmation contract: a client that // advertised `elicitation` on a server that read its `initialize` (the @@ -3579,8 +3592,8 @@ export function registerActionTools( 'the user whose call started the run can resume it, and it is gated exactly as run_action is ' + '(author AI opt-in, your capabilities, your read access to the record). The rest of the flow runs ' + 'the app\'s business logic and can mutate data. When the action that started the run was declared ' + - 'ai.requiresConfirmation: true, the run does not continue on this call and confirm: true does not ' + - 'change that: it is handed to the person you act for, who approves or rejects it in the app, and you ' + + 'ai.requiresConfirmation: true, the run does not continue on this call: ' + + 'it is handed to the person you act for, who approves or rejects it in the app, and you ' + 'are answered status "pending_confirmation" with a pendingId; the run stays paused until they ' + 'approve. Where the server cannot hand it off, the call is refused ACTION_CONFIRMATION_REQUIRED and ' + 'the run stays paused. When your client supports elicitation and this connection can carry it, the ' + @@ -3592,6 +3605,7 @@ export function registerActionTools( inputSchema: strictToolInput( { surface: 'this resume_run call', + retired: RETIRED_CONFIRMATION_MEMBER, // The spellings a caller who knows the REST resume door (`inputs` // / `variables`) or the other tools (`params`, `data`) reaches // for. Each is named in the refusal so the caller can resend with @@ -3619,18 +3633,8 @@ export function registerActionTools( 'The screen\'s field values, keyed by field name (the names in screen.fields). Omit only when ' + 'every field on the screen is optional.', ), - // The confirmation member, keyed off the contract's constant exactly - // as `run_action` declares it, for the same reason: a member this - // shape did not declare would be refused, and the gate that asks - // for it could never be satisfied. - [AI_ACTION_CONFIRMATION_MEMBER]: z - .boolean() - .optional() - .describe( - 'Not read by this tool: a resume of a run whose action was declared ai.requiresConfirmation: ' - + 'true is handed to the person to approve in the app whatever this member says. Accepted so ' - + 'that a call carrying it is not refused for it.', - ), + // [#34209] No confirmation member, as on `run_action`: a call + // carrying it is refused with the same prescription. }, ), // The rest of the flow runs here, so this carries the same annotations @@ -3639,16 +3643,13 @@ export function registerActionTools( }, async (args, extra) => { const { runId, values } = args; - const confirm = args[AI_ACTION_CONFIRMATION_MEMBER]; if (!runId || typeof runId !== 'string') { return errorResult('runId is required'); } try { - const request = { - values, - // Forwarded, never rebuilt without it: see `run_action` above. - [AI_ACTION_CONFIRMATION_MEMBER]: confirm, - }; + // [#34209] `values` only: the retired confirmation member is refused + // at the closed input, as on `run_action`. + const request = { values }; // [#33712] As `run_action`: asked in place where the client can be. const elicitConfirmation = actionConfirmationElicitorFor(server, extra); const result = elicitConfirmation diff --git a/packages/mcp/src/mcp-resume-run-tool.test.ts b/packages/mcp/src/mcp-resume-run-tool.test.ts index 07caae9e20c..68f4f66d290 100644 --- a/packages/mcp/src/mcp-resume-run-tool.test.ts +++ b/packages/mcp/src/mcp-resume-run-tool.test.ts @@ -14,7 +14,8 @@ * when the bridge implements `resumeRun`, under the `actions:execute` scope; * - `tools/list` declares its closed input schema, and `run_action`'s * description names it only where it is registered; - * - the call reaches the bridge with exactly `{ values, confirm }`; + * - the call reaches the bridge with exactly `{ values }` (#34209: the + * `confirm` member is retired and refused at the input); * - a coded refusal keeps its ADR-0112 envelope on the way back. * * The unknown-key refusal is swept with every other tool in @@ -93,12 +94,13 @@ describe('MCP resume_run — where it is registered', () => { const tools = await listTools(makeBridge(vi.fn())); for (const name of ['run_action', 'resume_run']) { const tool = tools[name]; - expect(tool.description, name).toContain('confirm: true'); expect(tool.description, name).toContain("Under an AI service account's own key"); expect(tool.description, name).toContain('refused whatever it sends'); - // [#33690] The member is not read by either tool for anyone now: a - // declared-gated call is handed to the person, whatever it says. - expect(tool.inputSchema.properties.confirm.description, name).toContain('Not read by this tool'); + // [#34209] The member is retired from both tools: neither declares it, + // and neither description teaches it; a declared-gated call is handed + // to the person. + expect(tool.inputSchema.properties, name).not.toHaveProperty('confirm'); + expect(tool.description, name).not.toContain('confirm: true'); expect(tool.description, name).toContain('pending_confirmation'); } expect(tools.run_action.description).toContain('ai.requiresConfirmation: false when it is safe unattended'); @@ -106,12 +108,11 @@ describe('MCP resume_run — where it is registered', () => { }); describe('MCP resume_run — its declared shape', () => { - it('declares runId (required), values and confirm, closed against anything else', async () => { + it('declares runId (required) and values, closed against anything else (no confirm: #34209)', async () => { const tool = (await listTools(makeBridge(vi.fn()))).resume_run; expect(tool.inputSchema.required).toEqual(['runId']); - expect(Object.keys(tool.inputSchema.properties).sort()).toEqual(['confirm', 'runId', 'values']); + expect(Object.keys(tool.inputSchema.properties).sort()).toEqual(['runId', 'values']); expect(tool.inputSchema.properties.values.type).toBe('object'); - expect(tool.inputSchema.properties.confirm.type).toBe('boolean'); expect(tool.inputSchema.additionalProperties).toBe(false); }); @@ -122,20 +123,30 @@ describe('MCP resume_run — its declared shape', () => { }); describe('MCP resume_run — the call', () => { - it('reaches the bridge with exactly the runId, the values and the confirmation', async () => { + it('reaches the bridge with exactly the runId and the values', async () => { const resumeRun = vi.fn(async () => ({ ok: true, result: { status: 'completed' } })); const json = await rpc(makeBridge(resumeRun), 'tools/call', { name: 'resume_run', - arguments: { runId: 'run_1', values: { subject: 'Call back', dueDate: '2026-10-01' }, confirm: true }, + arguments: { runId: 'run_1', values: { subject: 'Call back', dueDate: '2026-10-01' } }, }); expect(json.result.isError).toBeFalsy(); expect(resumeRun).toHaveBeenCalledTimes(1); - expect(resumeRun).toHaveBeenCalledWith('run_1', { + expect((resumeRun.mock.calls[0] as unknown[])[1]).toStrictEqual({ values: { subject: 'Call back', dueDate: '2026-10-01' }, - confirm: true, }); }); + it('[#34209] refuses a call carrying the retired confirm member before the bridge is reached', async () => { + const resumeRun = vi.fn(); + const json = await rpc(makeBridge(resumeRun), 'tools/call', { + name: 'resume_run', + arguments: { runId: 'run_1', values: {}, confirm: true }, + }); + expect(json.result.isError).toBe(true); + expect(json.result.content[0].text).toContain('`confirm`'); + expect(resumeRun).not.toHaveBeenCalled(); + }); + it('returns the bridge\'s answer unchanged, so a run paused on its next screen reads as paused', async () => { const answer = { ok: true, diff --git a/packages/mcp/src/mcp-stdio-tools.test.ts b/packages/mcp/src/mcp-stdio-tools.test.ts index e5ef1eb9b7e..5ffd0b91651 100644 --- a/packages/mcp/src/mcp-stdio-tools.test.ts +++ b/packages/mcp/src/mcp-stdio-tools.test.ts @@ -280,7 +280,8 @@ describe('#8034 stdio transport: tools/list', () => { const tool = (listed.result.tools as Array<{ name: string; inputSchema: any }>).find((t) => t.name === 'resume_run'); expect(tool).toBeDefined(); expect(tool!.inputSchema.required).toEqual(['runId']); - expect(Object.keys(tool!.inputSchema.properties).sort()).toEqual(['confirm', 'runId', 'values']); + // [#34209] No `confirm`: the member is retired from resume_run. + expect(Object.keys(tool!.inputSchema.properties).sort()).toEqual(['runId', 'values']); expect(tool!.inputSchema.additionalProperties).toBe(false); const called = await session.rpc('tools/call', { @@ -288,7 +289,7 @@ describe('#8034 stdio transport: tools/list', () => { arguments: { runId: 'run_7', values: { subject: 'Call back' } }, }); expect(called.result.isError).toBeFalsy(); - expect(resumeRun).toHaveBeenCalledWith('run_7', { values: { subject: 'Call back' }, confirm: undefined }); + expect((resumeRun.mock.calls[0] as unknown[])[1]).toStrictEqual({ values: { subject: 'Call back' } }); }); it('serves NO tools and advertises none when no bridge was given', async () => { diff --git a/packages/mcp/src/skill-md.test.ts b/packages/mcp/src/skill-md.test.ts index adaee949a88..0ee2bf325a3 100644 --- a/packages/mcp/src/skill-md.test.ts +++ b/packages/mcp/src/skill-md.test.ts @@ -94,12 +94,21 @@ describe('renderSkillMarkdown', () => { it('teaches action preference — run a matching business action instead of hand-editing records', () => { const md = renderSkillMarkdown(); expect(md).toContain('Prefer actions over hand-edits'); - expect(md).toContain('run_action({ actionName, objectName?, recordId?, params?, confirm? })'); - // [#15942] The signature owes `confirm`, and the skill owes the sentence - // that makes it usable: an agent that learns the member exists but not that - // the server REFUSES without it has learned nothing it can act on. - expect(md).toContain('ACTION_CONFIRMATION_REQUIRED'); - expect(md).toContain('requiresConfirmation'); + // [#34209] The member is retired from both action tools: the signatures + // carry no `confirm`, the skill teaches no `confirm: true` retry on them, + // and it says what does happen instead: the hand-off and the refusal. + expect(md).toContain('run_action({ actionName, objectName?, recordId?, params? })'); + expect(md).toContain('resume_run({ runId, values? })'); + const start = md.indexOf('- **run_action('); + const end = md.indexOf('whatever the call sends).', md.indexOf('- **resume_run(')); + expect(start > -1 && end > start, 'the run_action / resume_run lines moved: re-anchor this pin').toBe(true); + const actionTools = md.slice(start, end); + expect(actionTools, 'the skill teaches a confirm: true retry on an action tool again').not.toContain('confirm: true'); + expect(actionTools).toContain('pending_confirmation'); + expect(actionTools).toContain('ACTION_CONFIRMATION_REQUIRED'); + expect(actionTools).toContain('requiresConfirmation'); + // Control: the delete tools keep the member, and the skill still teaches it there. + expect(md).toContain('delete_record({ objectName, recordId, confirm })'); // [ADR-0151 D3 rule 3] The retry is a person's or a delegated agent's; an // AI service account is refused whatever it sends, and is told so. expect(md).toContain("Under an AI service\n account's own key"); diff --git a/packages/mcp/src/skill-md.ts b/packages/mcp/src/skill-md.ts index 1a450e45d97..a011104ef6f 100644 --- a/packages/mcp/src/skill-md.ts +++ b/packages/mcp/src/skill-md.ts @@ -484,27 +484,37 @@ create/update payload. but \`run_action\` would refuse it for you (your credential, or your role in this organization): \`unavailable.reason\` says why and what would let it run, so tell your human instead of calling it. -- **run_action({ actionName, objectName?, recordId?, params?, confirm? })** — +- **run_action({ actionName, objectName?, recordId?, params? })** — invoke a business action by name. Invocation is permission-gated, but the action body executes the app's registered logic as trusted code (it can mutate data or trigger flows with the app's own authority). Pass \`recordId\` for record-scoped actions and \`params\` for declared inputs; - \`objectName\` only disambiguates a name shared by multiple objects. Pass - \`confirm: true\` on an action \`list_actions\` reports as - \`requiresConfirmation\` — the server REFUSES such a call without it - (\`ACTION_CONFIRMATION_REQUIRED\`) and nothing runs. Ask your human first; - the flag asserts an approval, it does not obtain one. Under an AI service + \`objectName\` only disambiguates a name shared by multiple objects. An + action \`list_actions\` reports as \`requiresConfirmation\` may need a + person's approval, which you cannot give: when its author declared it and + your client supports elicitation on a connection that can carry it, the + person is asked in your client — accept runs the call once, and any other + answer refuses it (\`ACTION_CONFIRMATION_REQUIRED\`); do not retry unless + they ask. Otherwise the call does not run, and you are answered + \`status: "pending_confirmation"\` with a \`pendingId\` — the person + approves or rejects it in the app, so relay the message and do not retry. + A server that cannot hand it off + refuses it (\`ACTION_CONFIRMATION_REQUIRED\`, \`details.reason\` + \`no_confirmation_service\`) and nothing runs: the person performs it in the + app. Never send \`confirm\`: the tool refuses a call that carries it, on + every action. Under an AI service account's own key (an agent acting for itself, for no person) the call is refused whatever it sends and nothing runs: hand the action to a person, or its author declares \`ai.requiresConfirmation: false\` when it is safe unattended. -- **resume_run({ runId, values?, confirm? })** — continue a flow run that +- **resume_run({ runId, values? })** — continue a flow run that \`run_action\` answered with \`status: "paused"\` and a \`screen\` (a form the flow needs filled in). Send the screen's field values in \`values\`, keyed by the names in \`screen.fields\`. The run completes, or pauses again on its next screen, which you fill with another \`resume_run\`. Only the user whose call started the run can resume it, under the same gates as \`run_action\` - (including \`confirm: true\` for an action flagged \`requiresConfirmation\`, + (the person's confirmation, in your client or in the app, for an action its + author declared \`requiresConfirmation\`, the refusal of a call that sends \`confirm\`, and its refusal under an AI service account's own key whatever the call sends). ${renderFileToolLines(options)}${renderDatasetToolLines(options)}${options.federationTools === true && grantsAuthoringTools(options.grantedScopes) ? FEDERATION_TOOL_LINES : ''}${authoringTools ? renderAuthoringSection(authoringTools, describeObjectRegistered) : ''}${dataOnlyBlock} ## Conventions & gotchas diff --git a/packages/qa/dogfood/test/action-confirmation-handoff-33690.dogfood.test.ts b/packages/qa/dogfood/test/action-confirmation-handoff-33690.dogfood.test.ts index f01fda14bdc..301a65439dd 100644 --- a/packages/qa/dogfood/test/action-confirmation-handoff-33690.dogfood.test.ts +++ b/packages/qa/dogfood/test/action-confirmation-handoff-33690.dogfood.test.ts @@ -15,9 +15,12 @@ // `approval-decide-over-mcp.dogfood.test.ts` and // `mcp-system-object-action-exposure.dogfood.test.ts`). // -// ⭐ the same `run_action` call carrying `confirm: true`, sent N times, -// writes the record 0 times and is held N times, each with its own -// pending id, each hand-off recorded for the person the call ran as; +// ⭐ the same `run_action` call, sent N times, writes the record 0 times +// and is held N times, each with its own pending id, each hand-off +// recorded for the person the call ran as; +// ⭐ [#34209] a call carrying the retired `confirm` member is refused at +// the tool's input, on the gated action and on an ungated one: nothing +// is written and nobody is asked; // ⭐ CONTROL: the same update through an action that declares no // confirmation runs at once, and nobody is asked. @@ -143,12 +146,12 @@ describe('[#33690] a confirmation-gated action over MCP is handed to the person, await stack?.stop?.(); }); - it(`⭐ the same call with confirm: true, sent ${N} times, writes 0 times and is held ${N} times with a pending id`, async () => { + it(`⭐ the same call, sent ${N} times, writes 0 times and is held ${N} times with a pending id`, async () => { const id = await openTicket('gated'); const before = handOffs.length; for (let i = 1; i <= N; i++) { const answer = await tool('run_action', { - actionName: GATED, objectName: OBJECT, recordId: id, [AI_ACTION_CONFIRMATION_MEMBER]: true, + actionName: GATED, objectName: OBJECT, recordId: id, }); expect(answer.isError, answer.text).toBe(false); expect(answer.payload).toMatchObject({ @@ -165,6 +168,22 @@ describe('[#33690] a confirmation-gated action over MCP is handed to the person, } }, 120_000); + it('⭐ [#34209] a call carrying confirm is refused at the input, gated or not: nothing written, nobody asked', async () => { + for (const [actionName, value] of [[GATED, true], [PLAIN, true], [GATED, false]] as const) { + const id = await openTicket(`with-member-${actionName}-${value}`); + const before = handOffs.length; + const answer = await tool('run_action', { + actionName, objectName: OBJECT, recordId: id, [AI_ACTION_CONFIRMATION_MEMBER]: value, + }); + const label = `${actionName} confirm=${value}`; + expect(answer.isError, label).toBe(true); + expect(answer.text, label).toContain(`\`${AI_ACTION_CONFIRMATION_MEMBER}\``); + expect(answer.text, label).toContain('in the app'); + expect(await statusOf(id), label).toBe('open'); + expect(handOffs.length, label).toBe(before); + } + }, 120_000); + it('CONTROL: an action that declares no confirmation runs at once, and nobody is asked', async () => { const id = await openTicket('plain'); const before = handOffs.length; diff --git a/packages/qa/dogfood/test/approval-decide-over-mcp.dogfood.test.ts b/packages/qa/dogfood/test/approval-decide-over-mcp.dogfood.test.ts index f1ad7ad3e27..cf6d570c8f8 100644 --- a/packages/qa/dogfood/test/approval-decide-over-mcp.dogfood.test.ts +++ b/packages/qa/dogfood/test/approval-decide-over-mcp.dogfood.test.ts @@ -29,7 +29,7 @@ // no slate) is refused, and the request stays pending: the account // confirmation rule (ADR-0151 D3 rule 3) answers first, `428` // `ACTION_CONFIRMATION_REQUIRED` with `details.reason: 'service_account'` -// whatever the call sends, `confirm: true` included; +// whatever the call sends; // ⭐ [#33690] every other caller's decision, recall, send-back and resubmit // runs nothing over MCP, confirmed or not: the actions declare // `ai.requiresConfirmation: true`, so the caller's own `confirm: true` @@ -38,6 +38,8 @@ // 'no_confirmation_service'`, and the request stays pending. Before the // amended contract a confirmed call decided here; a person now decides in // the app (a host's pending-confirmation service hands the call to them). +// [#34209] A call that carries `confirm` at all is refused earlier, at +// `run_action`'s closed input, and the request stays pending as well. // The read half of the card (an approver listing their pending requests over // MCP) is not here: the MCP object tools refuse every `sys_*` object, so this @@ -247,9 +249,19 @@ describe('an approver\'s agent decides a pending approval request over MCP (#324 * true`, so the caller's own `confirm: true` never runs them; this stack * registers no pending-confirmation service, so the call is refused at * confirmation, after the request row is read and before it is forwarded. + * [#34209] A call that carries the retired `confirm` member is refused + * earlier still, at the tool's closed input, and never reaches the action: + * with `confirm` set, that refusal is what is asserted. */ - const expectRefusedAtConfirmation = (answer: { isError: boolean; payload: any; text: string }, reason: string) => { + const expectRefusedAtConfirmation = ( + answer: { isError: boolean; payload: any; text: string }, reason: string, confirm = false, + ) => { expect(answer.isError, answer.text).toBe(true); + if (confirm) { + expect(answer.text).toContain(`\`${AI_ACTION_CONFIRMATION_MEMBER}\``); + expect(answer.payload?.error?.code, answer.text).toBeUndefined(); + return; + } expect(answer.payload?.error?.code, answer.text).toBe('ACTION_CONFIRMATION_REQUIRED'); expect(answer.payload?.error?.status, answer.text).toBe(428); expect(answer.payload?.error?.details?.reason, answer.text).toBe(reason); @@ -260,14 +272,14 @@ describe('an approver\'s agent decides a pending approval request over MCP (#324 for (const confirm of [true, false]) { // [#33690] Refused at confirmation now, never forwarded: the service's // own `REQUEST_NOT_FOUND` is no longer reached over MCP. - expectRefusedAtConfirmation(await approve({ bearer: stranger }, requestId, confirm), 'no_confirmation_service'); + expectRefusedAtConfirmation(await approve({ bearer: stranger }, requestId, confirm), 'no_confirmation_service', confirm); } await expectUndecided(requestId, 'a member on no slate'); }); it('⭐ the submitter is refused, and the request stays pending', async () => { const requestId = await openRequest('submitter'); - expectRefusedAtConfirmation(await approve({ bearer: submitter }, requestId, true), 'no_confirmation_service'); + expectRefusedAtConfirmation(await approve({ bearer: submitter }, requestId, false), 'no_confirmation_service'); await expectUndecided(requestId, 'the submitter'); }); @@ -278,14 +290,14 @@ describe('an approver\'s agent decides a pending approval request over MCP (#324 // action, which declares `ai.requiresConfirmation`, is refused at admission // whatever the call carries, before the request is looked up; [#33690] // the refusal names `reason: 'service_account'`. - expectRefusedAtConfirmation(await approve({ key: accountKey }, requestId, true), 'service_account'); + expectRefusedAtConfirmation(await approve({ key: accountKey }, requestId, false), 'service_account'); await expectUndecided(requestId, 'an AI service account'); }); it('⭐ [#33690] the approver\'s call decides nothing, confirmed or not: refused at confirmation, the request stays pending', async () => { const requestId = await openRequest('approver'); for (const confirm of [false, true]) { - expectRefusedAtConfirmation(await approve({ bearer: approver }, requestId, confirm), 'no_confirmation_service'); + expectRefusedAtConfirmation(await approve({ bearer: approver }, requestId, confirm), 'no_confirmation_service', confirm); await expectUndecided(requestId, `an approver's call (confirm: ${confirm})`); } }); @@ -294,13 +306,13 @@ describe('an approver\'s agent decides a pending approval request over MCP (#324 const requestId = await openRequest('recall'); for (const confirm of [false, true]) { expectRefusedAtConfirmation( - await act({ bearer: submitter }, 'approval_recall', requestId, confirm, 'fixing the lines'), 'no_confirmation_service', + await act({ bearer: submitter }, 'approval_recall', requestId, confirm, 'fixing the lines'), 'no_confirmation_service', confirm, ); expectRefusedAtConfirmation( - await act({ bearer: approver }, 'approval_send_back', requestId, confirm, 'fix the dates'), 'no_confirmation_service', + await act({ bearer: approver }, 'approval_send_back', requestId, confirm, 'fix the dates'), 'no_confirmation_service', confirm, ); expectRefusedAtConfirmation( - await act({ bearer: submitter }, 'approval_resubmit', requestId, confirm, 'dates fixed'), 'no_confirmation_service', + await act({ bearer: submitter }, 'approval_resubmit', requestId, confirm, 'dates fixed'), 'no_confirmation_service', confirm, ); } await expectUndecided(requestId, 'recall, send-back and resubmit over MCP'); diff --git a/packages/qa/dogfood/test/approval-read-over-mcp.dogfood.test.ts b/packages/qa/dogfood/test/approval-read-over-mcp.dogfood.test.ts index 7a12213dc75..96c8a630e58 100644 --- a/packages/qa/dogfood/test/approval-read-over-mcp.dogfood.test.ts +++ b/packages/qa/dogfood/test/approval-read-over-mcp.dogfood.test.ts @@ -38,9 +38,10 @@ // `sys_approval_action` stays refused; // ⭐ the query tool's text names the "pending for me" filter shape; // ⭐ end to end: the submitter files over MCP, the approver lists; [#33690] -// the approver's approve carrying `confirm: true` decides nothing (the -// caller's own confirm never counts on a declared-gated action, and this -// stack has no pending-confirmation service), so the request stays pending. +// the approver's approve decides nothing (a person confirms a +// declared-gated action, and this stack has no pending-confirmation +// service), and [#34209] the same approve carrying `confirm` is refused +// at the tool's input, so the request stays pending. import { describe, it, expect, beforeAll, afterAll } from 'vitest'; import { type VerifyStack } from '@objectstack/verify'; @@ -446,7 +447,7 @@ describe('an approver\'s agent lists the approvals waiting on them over MCP (#32 expect(query?.description).toContain('pending_approvers'); }); - it('⭐ end to end: the approver lists what waits on them; [#33690] a confirmed approve over MCP decides nothing, and the request stays waiting', async () => { + it('⭐ end to end: the approver lists what waits on them; [#33690] an approve over MCP decides nothing, and the request stays waiting', async () => { const before = rowsOf((await pendingForMe({ bearer: approver })).payload); const target = before.find((r) => String(r.record_id) === first.recordId); expect(target, 'the approver sees the request in their pending list').toBeTruthy(); @@ -456,17 +457,31 @@ describe('an approver\'s agent lists the approvals waiting on them over MCP (#32 objectName: REQUEST, recordId: String(target.id), params: { comment: 'approved over MCP' }, - [AI_ACTION_CONFIRMATION_MEMBER]: true, }); // [#33690] `approval_approve` declares `ai.requiresConfirmation: true`, so - // the caller's own `confirm: true` never runs it; this stack registers no + // a person confirms it, never the caller; this stack registers no // pending-confirmation service, so the call is refused at confirmation. - // Before the amended contract it approved and the flow resumed. + // Before the amended contract a `confirm: true` call approved and the flow + // resumed. expect(decided.isError, decided.text).toBe(true); expect(decided.payload?.error?.code, decided.text).toBe('ACTION_CONFIRMATION_REQUIRED'); expect(decided.payload?.error?.details?.reason, decided.text).toBe('no_confirmation_service'); expect((await requestRow(first.requestId)).status).toBe('pending'); + // [#34209] The same approve carrying the retired `confirm` member is + // refused at `run_action`'s closed input, before the action is reached. + const withMember = await tool({ bearer: approver }, 'run_action', { + actionName: 'approval_approve', + objectName: REQUEST, + recordId: String(target.id), + params: { comment: 'approved over MCP' }, + [AI_ACTION_CONFIRMATION_MEMBER]: true, + }); + expect(withMember.isError, withMember.text).toBe(true); + expect(withMember.text).toContain(`\`${AI_ACTION_CONFIRMATION_MEMBER}\``); + expect(withMember.payload?.error?.code, withMember.text).toBeUndefined(); + expect((await requestRow(first.requestId)).status).toBe('pending'); + expect((await pendingIds({ bearer: approver })).sort()).toEqual([first.requestId, second.requestId].sort()); }); }); diff --git a/packages/qa/dogfood/test/mcp-system-object-action-exposure.dogfood.test.ts b/packages/qa/dogfood/test/mcp-system-object-action-exposure.dogfood.test.ts index a8ba1e57a3f..7ef4c80b1c1 100644 --- a/packages/qa/dogfood/test/mcp-system-object-action-exposure.dogfood.test.ts +++ b/packages/qa/dogfood/test/mcp-system-object-action-exposure.dogfood.test.ts @@ -258,11 +258,13 @@ describe('[#27681, #27900] sys_user identity actions over MCP: what each bucket\ expect(await isBanned(targetUserId), 'an unconfirmed agent call banned the user').toBe(false); }, 120_000); - it('the packaged-action switch holds over MCP: ban_user OFF answers 409 ACTION_DISABLED even confirmed', async () => { + it('the packaged-action switch holds over MCP: ban_user OFF answers 409 ACTION_DISABLED', async () => { await flip(false); try { + // [#34209] No `confirm`: the member is retired from run_action, and the + // switch answers before the confirmation step anyway. const refused = await tool(admin, 'run_action', { - actionName: 'ban_user', objectName: 'sys_user', recordId: targetUserId, confirm: true, + actionName: 'ban_user', objectName: 'sys_user', recordId: targetUserId, }); expect(refused.isError).toBe(true); expect(refused.payload?.error).toMatchObject({ code: 'ACTION_DISABLED', status: 409 }); @@ -272,25 +274,36 @@ describe('[#27681, #27900] sys_user identity actions over MCP: what each bucket\ } }, 120_000); - it('the target still authorizes: a plain member\'s confirmed call is refused and the user is NOT banned', async () => { + it('the target still authorizes: a plain member\'s call is refused and the user is NOT banned', async () => { const refused = await tool(member, 'run_action', { - actionName: 'ban_user', objectName: 'sys_user', recordId: targetUserId, confirm: true, + actionName: 'ban_user', objectName: 'sys_user', recordId: targetUserId, }); expect(refused.isError).toBe(true); expect(await isBanned(targetUserId)).toBe(false); }, 120_000); - it('[#33690] the administrator\'s call carrying confirm: true clears every gate and still bans nobody: the caller\'s confirm never counts', async () => { - // Before the amended confirmation contract this call banned the user. The - // stack registers no pending-confirmation service, so the call is refused - // at confirmation, after every other gate, and nothing is forwarded. + it('[#33690] the administrator\'s call clears every gate and still bans nobody: a person confirms, never the caller', async () => { + // Before the amended confirmation contract a `confirm: true` call banned + // the user. The stack registers no pending-confirmation service, so the + // call is refused at confirmation, after every other gate, and nothing is + // forwarded. const refused = await tool(admin, 'run_action', { - actionName: 'ban_user', objectName: 'sys_user', recordId: targetUserId, params: { banReason: 'dogfood' }, confirm: true, + actionName: 'ban_user', objectName: 'sys_user', recordId: targetUserId, params: { banReason: 'dogfood' }, }); expect(refused.isError, refused.text).toBe(true); expect(refused.payload?.error).toMatchObject({ code: 'ACTION_CONFIRMATION_REQUIRED', status: 428 }); expect(refused.payload?.error?.details?.reason, refused.text).toBe('no_confirmation_service'); expect(await isBanned(targetUserId)).toBe(false); + + // [#34209] The same call carrying the retired `confirm` member is refused + // at the tool's closed input, before any gate. + const withMember = await tool(admin, 'run_action', { + actionName: 'ban_user', objectName: 'sys_user', recordId: targetUserId, params: { banReason: 'dogfood' }, confirm: true, + }); + expect(withMember.isError, withMember.text).toBe(true); + expect(withMember.text).toContain('`confirm`'); + expect(withMember.payload?.error?.code, withMember.text).toBeUndefined(); + expect(await isBanned(targetUserId)).toBe(false); }, 120_000); // ── The OAuth-connected agent: one case per bucket ─────────────────────── @@ -332,10 +345,10 @@ describe('[#27681, #27900] sys_user identity actions over MCP: what each bucket\ // gate's sentence with the REST door's 403. The scoped call is not told the // action is unexposed, because it is exposed; the caller's grant is why. const scoped = await tool(memberAgent, 'run_action', { - actionName: 'ban_user', objectName: 'sys_user', recordId: agentTargetUserId, params: { banReason: 'member agent' }, confirm: true, + actionName: 'ban_user', objectName: 'sys_user', recordId: agentTargetUserId, params: { banReason: 'member agent' }, }); const byName = await tool(memberAgent, 'run_action', { - actionName: 'ban_user', recordId: agentTargetUserId, params: { banReason: 'member agent' }, confirm: true, + actionName: 'ban_user', recordId: agentTargetUserId, params: { banReason: 'member agent' }, }); for (const refused of [scoped, byName]) { expect(refused.isError, refused.text).toBe(true); @@ -355,19 +368,26 @@ describe('[#27681, #27900] sys_user identity actions over MCP: what each bucket\ expect(messageOf(scoped)).toContain('system object "sys_user" is not exposed via MCP'); }, 120_000); - it('C: [#33690] the agent\'s ban_user is refused 428 before any forward, with confirm: true and without it, and bans nobody', async () => { + it('C: [#33690] the agent\'s ban_user is refused 428 before any forward, and bans nobody; [#34209] with confirm it is refused at the input', async () => { // Before the amended confirmation contract the confirmed call was served as - // the agent (#28367) and banned the user. The agent's own `confirm: true` - // never counts now, and the stack registers no pending-confirmation service. - for (const extra of [{}, { confirm: true }]) { - const refused = await tool(agent, 'run_action', { - actionName: 'ban_user', objectName: 'sys_user', recordId: agentTargetUserId, params: { banReason: 'agent' }, ...extra, - }); - expect(refused.isError, refused.text).toBe(true); - expect(refused.payload?.error).toMatchObject({ code: 'ACTION_CONFIRMATION_REQUIRED', status: 428 }); - expect(refused.payload?.error?.details?.reason, refused.text).toBe('no_confirmation_service'); - expect(await isBanned(agentTargetUserId)).toBe(false); - } + // the agent (#28367) and banned the user. A person confirms now, never the + // agent, and the stack registers no pending-confirmation service. + const refused = await tool(agent, 'run_action', { + actionName: 'ban_user', objectName: 'sys_user', recordId: agentTargetUserId, params: { banReason: 'agent' }, + }); + expect(refused.isError, refused.text).toBe(true); + expect(refused.payload?.error).toMatchObject({ code: 'ACTION_CONFIRMATION_REQUIRED', status: 428 }); + expect(refused.payload?.error?.details?.reason, refused.text).toBe('no_confirmation_service'); + expect(await isBanned(agentTargetUserId)).toBe(false); + + // [#34209] The agent's `confirm: true` is refused at the tool's closed input. + const withMember = await tool(agent, 'run_action', { + actionName: 'ban_user', objectName: 'sys_user', recordId: agentTargetUserId, params: { banReason: 'agent' }, confirm: true, + }); + expect(withMember.isError, withMember.text).toBe(true); + expect(withMember.text).toContain('`confirm`'); + expect(withMember.payload?.error?.code, withMember.text).toBeUndefined(); + expect(await isBanned(agentTargetUserId)).toBe(false); }, 120_000); it('H: impersonate_user is absent from the agent\'s listing and refused by name', async () => { diff --git a/packages/runtime/src/action-confirmation-handoff-33690.test.ts b/packages/runtime/src/action-confirmation-handoff-33690.test.ts index d1ed2bb0476..3c7493c7873 100644 --- a/packages/runtime/src/action-confirmation-handoff-33690.test.ts +++ b/packages/runtime/src/action-confirmation-handoff-33690.test.ts @@ -18,8 +18,17 @@ * The real bridge (`buildMcpBridge`, through `HttpDispatcher`) is driven * against a kernel double, so every pin reads what the door made the engine * and the service double do, not only what it answered. The acceptance is - * the card's: the same request sent with `confirm: true` N times executes 0 - * times, and every attempt is held with a pending id. + * the card's: the same request sent N times executes 0 times, and every + * attempt is held with a pending id. + * + * [#34209] The MCP tools no longer forward a `confirm` member: `run_action` + * and `resume_run` REFUSE a call that carries it at their closed input + * (maintainer ruling 6909355256), pinned in `@objectstack/mcp`'s + * `mcp-action-confirmation-handoff-33690.test.ts`, which this package does not + * depend on. So the primary pins here send the request the tool now forwards, + * with no member. The bridge's input type still admits the member, and the + * loops marked "below the tool" keep sending it: a bridge caller that is not + * the tool still gets nothing for it (defense in depth). */ // Paid at collection, not inside a case's clock (check:test-source-alias). @@ -155,7 +164,7 @@ async function refusalOf(p: Promise): Promise<{ code: unknown; status: const N = 5; describe('[#33690] run_action: a declared-gated action is handed to the person, never run on the caller\'s confirm', () => { - it(`the same request with confirm: true, sent ${N} times, executes 0 times and is held ${N} times with a pending id`, async () => { + it(`the same request, sent ${N} times, executes 0 times and is held ${N} times with a pending id`, async () => { const service = makeConfirmationService(); const h = makeHarness({ service }); const bridge = h.bridgeAs(PERSON); @@ -163,7 +172,7 @@ describe('[#33690] run_action: a declared-gated action is handed to the person, const answers: any[] = []; for (let i = 0; i < N; i++) { answers.push(await bridge.runAction(GATED.name, { - recordId: 'lead_1', params: { note: 'stale' }, [AI_ACTION_CONFIRMATION_MEMBER]: true, + recordId: 'lead_1', params: { note: 'stale' }, })); } @@ -186,7 +195,7 @@ describe('[#33690] run_action: a declared-gated action is handed to the person, expect(ec.userId).toBe('u1'); }); - it('holds the call with the member and without it alike: the member is not read', async () => { + it('below the tool: a bridge caller passing the member is held all the same: the member is not read', async () => { for (const extra of [{}, { [AI_ACTION_CONFIRMATION_MEMBER]: false }, { [AI_ACTION_CONFIRMATION_MEMBER]: true }]) { const service = makeConfirmationService(); const h = makeHarness({ service }); @@ -199,7 +208,7 @@ describe('[#33690] run_action: a declared-gated action is handed to the person, it('a delegated agent (acting for a person) is handed off too, for that person', async () => { const service = makeConfirmationService(); const h = makeHarness({ service }); - const answer = await h.bridgeAs(DELEGATED).runAction(GATED.name, { recordId: 'lead_1', [AI_ACTION_CONFIRMATION_MEMBER]: true }); + const answer = await h.bridgeAs(DELEGATED).runAction(GATED.name, { recordId: 'lead_1' }); expect(answer).toMatchObject({ status: 'pending_confirmation' }); expect(h.ql.executeAction).not.toHaveBeenCalled(); expect((service.submit.mock.calls[0] as any[])[1].onBehalfOf.userId).toBe('u1'); @@ -210,11 +219,11 @@ describe('[#33690] run_action: a declared-gated action is handed to the person, const h = makeHarness({ service }); const bridge = h.bridgeAs(PERSON); - const flow = await bridge.runAction(GATED_FLOW.name, { recordId: 'lead_1', [AI_ACTION_CONFIRMATION_MEMBER]: true }); + const flow = await bridge.runAction(GATED_FLOW.name, { recordId: 'lead_1' }); expect(flow).toMatchObject({ status: 'pending_confirmation', actionName: GATED_FLOW.name }); expect(h.automation.execute).not.toHaveBeenCalled(); - const update = await bridge.runAction(GATED_UPDATE.name, { recordId: 'lead_1', [AI_ACTION_CONFIRMATION_MEMBER]: true }); + const update = await bridge.runAction(GATED_UPDATE.name, { recordId: 'lead_1' }); expect(update).toMatchObject({ status: 'pending_confirmation', actionName: GATED_UPDATE.name }); }); @@ -222,15 +231,15 @@ describe('[#33690] run_action: a declared-gated action is handed to the person, const service = makeConfirmationService(); const h = makeHarness({ service }); - const refused = await refusalOf(h.bridgeAs(PERSON).runAction(GATED.name, { recordId: 'lead_2', [AI_ACTION_CONFIRMATION_MEMBER]: true })); + const refused = await refusalOf(h.bridgeAs(PERSON).runAction(GATED.name, { recordId: 'lead_2' })); expect({ code: refused.code, status: refused.status }).toEqual({ code: 'RECORD_NOT_FOUND', status: 404 }); expect(service.submit).not.toHaveBeenCalled(); expect(h.ql.executeAction).not.toHaveBeenCalled(); }); - it('no service registered: refused 428 ACTION_CONFIRMATION_REQUIRED, reason no_confirmation_service, with the member and without it', async () => { - for (const extra of [{ [AI_ACTION_CONFIRMATION_MEMBER]: true }, {}]) { + it('no service registered: refused 428 ACTION_CONFIRMATION_REQUIRED, reason no_confirmation_service (below the tool: with the member too)', async () => { + for (const extra of [{}, { [AI_ACTION_CONFIRMATION_MEMBER]: true }]) { const h = makeHarness(); const refused = await refusalOf(h.bridgeAs(PERSON).runAction(GATED.name, { recordId: 'lead_1', ...extra })); expect({ code: refused.code, status: refused.status }, JSON.stringify(extra)).toEqual({ @@ -250,14 +259,14 @@ describe('[#33690] run_action: a declared-gated action is handed to the person, it('a service that answers no pending id is a fault, never a hand-off: thrown, and nothing run', async () => { const service = { submit: vi.fn(async () => ({})) }; const h = makeHarness({ service }); - const thrown: any = await h.bridgeAs(PERSON).runAction(GATED.name, { recordId: 'lead_1', [AI_ACTION_CONFIRMATION_MEMBER]: true }).catch((e: unknown) => e); + const thrown: any = await h.bridgeAs(PERSON).runAction(GATED.name, { recordId: 'lead_1' }).catch((e: unknown) => e); expect(thrown).toBeInstanceOf(Error); expect(String(thrown.message)).toContain('pendingId'); expect(h.ql.executeAction).not.toHaveBeenCalled(); }); - it('[ADR-0151 D3 rule 3] an AI service account is refused, never handed off: reason service_account, with the member and without it', async () => { - for (const extra of [{ [AI_ACTION_CONFIRMATION_MEMBER]: true }, {}]) { + it('[ADR-0151 D3 rule 3] an AI service account is refused, never handed off: reason service_account (below the tool: with the member too)', async () => { + for (const extra of [{}, { [AI_ACTION_CONFIRMATION_MEMBER]: true }]) { const service = makeConfirmationService(); const h = makeHarness({ service }); const refused = await refusalOf(h.bridgeAs(ACCOUNT).runAction(GATED.name, { recordId: 'lead_1', ...extra })); @@ -293,13 +302,13 @@ describe('[#33690] resume_run: a resume of a gated action is handed off carrying return started.runId; } - it(`confirm: true sent ${N} times resumes 0 times; each call is held with a pending id carrying its run and values`, async () => { + it(`a resume sent ${N} times resumes 0 times; each call is held with a pending id carrying its run and values`, async () => { const service = makeConfirmationService(); const h = makeHarness({ service }); const runId = await pausedRun(h); for (let i = 0; i < N; i++) { - const answer = await h.bridgeAs(PERSON).resumeRun(runId, { values: { reason: 'dup' }, [AI_ACTION_CONFIRMATION_MEMBER]: true }); + const answer = await h.bridgeAs(PERSON).resumeRun(runId, { values: { reason: 'dup' } }); expect(answer).toMatchObject({ status: 'pending_confirmation', pendingId: `pa_${i + 1}`, actionName: GATED_FLOW.name, objectName: OBJECT }); } @@ -316,7 +325,7 @@ describe('[#33690] resume_run: a resume of a gated action is handed off carrying it('no service registered: refused 428, reason no_confirmation_service, and the run stays paused', async () => { const h = makeHarness(); const runId = await pausedRun(h); - const refused = await refusalOf(h.bridgeAs(PERSON).resumeRun(runId, { values: { reason: 'x' }, [AI_ACTION_CONFIRMATION_MEMBER]: true })); + const refused = await refusalOf(h.bridgeAs(PERSON).resumeRun(runId, { values: { reason: 'x' } })); expect({ code: refused.code, status: refused.status }).toEqual({ code: 'ACTION_CONFIRMATION_REQUIRED', status: 428 }); expect(refused.details).toMatchObject({ actionName: GATED_FLOW.name, objectName: OBJECT, reason: 'no_confirmation_service' }); expect(h.automation.resume).not.toHaveBeenCalled(); @@ -327,7 +336,7 @@ describe('[#33690] resume_run: a resume of a gated action is handed off carrying const service = makeConfirmationService(); const h = makeHarness({ service }); const started: any = await h.automation.execute(GATED_FLOW.target, { userId: 'bot_1', object: OBJECT, record: { id: 'lead_1' } }); - const refused = await refusalOf(h.bridgeAs(ACCOUNT).resumeRun(started.runId, { values: { reason: 'x' }, [AI_ACTION_CONFIRMATION_MEMBER]: true })); + const refused = await refusalOf(h.bridgeAs(ACCOUNT).resumeRun(started.runId, { values: { reason: 'x' } })); expect({ code: refused.code, status: refused.status }).toEqual({ code: 'ACTION_CONFIRMATION_REQUIRED', status: 428 }); expect(refused.details).toMatchObject({ reason: 'service_account' }); expect(service.submit).not.toHaveBeenCalled(); diff --git a/packages/spec/src/ai/tool.zod.ts b/packages/spec/src/ai/tool.zod.ts index 990f723d2c0..b9345c13902 100644 --- a/packages/spec/src/ai/tool.zod.ts +++ b/packages/spec/src/ai/tool.zod.ts @@ -83,6 +83,12 @@ const TOOL_RETIRED_KEY_GUIDANCE: Record = { // never a confirmation, so the bound names that pair and keeps REST outside // this gate for every other caller. // + // [#33690 / #34209] The member half follows the amended contract: a person + // confirms through the hand-off, and `run_action` / `resume_run` refuse the + // caller's `confirm` at their input (maintainer ruling 6909355256), so this + // prescription teaches no `confirm: true` retry. It names the member only to + // say it is refused. + // // The ids stay in this comment and out of the string: `check:doc-authoring` // reds on an internal tracker id inside a customer-facing prescription. requiresConfirmation: @@ -95,31 +101,34 @@ const TOOL_RETIRED_KEY_GUIDANCE: Record = { '(which derives `destructiveHint` from a hardcoded name list). Delete the key. For a ' + 'REAL gate on a destructive operation, put it behind an action and set ' + '`action.ai.requiresConfirmation: true` — the flag the platform\'s confirmation ' + - 'CONTRACT is written against (`AIActionConfirmation`, `@objectstack/spec/contracts`), ' + - 'and that contract is ENFORCED. An AI-facing call on an action declaring the flag ' + - 'must carry the confirmation member `confirm: true` on the request; without it the ' + - 'call is REFUSED with `ACTION_CONFIRMATION_REQUIRED` (428), the refusal naming the ' + - 'action and the exact member to set so the caller confirms and retries. A GATE, not ' + - 'a queue: nothing is parked, nothing is held for an operator to find later, and a ' + - 'refused call did not run — no record was read and none was written. Two BOUNDS to ' + - 'read before you rely on it. (1) The enforced set is the doors that ask every action ' + - 'for the author\'s `ai.exposed` opt-in — today the action door reached from the MCP ' + - '`run_action` tool. REST `/actions` reads `ai.exposed` in one case only (an AI ' + - 'service account starting a `type: \'flow\'` action whose flow declares ' + - '`runAs: \'system\'` needs the opt-in there), and that check asks for the opt-in ' + - 'alone, not a confirmation; for a person\'s call REST `/actions` sits OUTSIDE this ' + - 'gate, so a human in front of that route is still yours to ' + - 'arrange. An AI service account (an agent acting for itself, not on a person\'s ' + - 'behalf) does not confirm an action for itself: it is refused at every action door, ' + - 'REST `/actions` included, whatever its request carries, and a person runs the ' + - 'action. (2) Only the ' + - 'author\'s declared `ai.requiresConfirmation: true` refuses, and only the boolean ' + - '`true` confirms: the wider listing heuristic that reports `requiresConfirmation` ' + - 'for a destructive-looking action ADVISES a client to ask and never refuses, and an ' + - 'explicit `false` never refuses. `confirm: true` is an unverifiable caller claim — ' + - 'the gate makes FORGETTING loud, it does not prove a human. For AI metadata ' + - 'mutations the ADR-0033 draft/publish workspace is the gate: nothing is live until a ' + - 'human publishes.', + 'CONTRACT is written against (`AI_ACTION_CONFIRMATION_CAPABILITY`, ' + + '`@objectstack/spec/contracts`), and that contract is ENFORCED: a person confirms, ' + + 'never the agent. On the MCP `run_action` and `resume_run` tools a call on an action ' + + 'declaring the flag runs only once the person the caller acts for confirms it: in ' + + 'the client, when the client supports elicitation and the connection can carry the ' + + 'question (accept runs the call; decline, dismissal or no answer in time refuses it ' + + 'with `ACTION_CONFIRMATION_REQUIRED`), and in the app otherwise: the call does not ' + + 'run, it is handed to the person, who approves or rejects it there, and the tool ' + + 'answers `status: "pending_confirmation"` with a pending id; a server with no ' + + 'pending-confirmation service refuses it with `ACTION_CONFIRMATION_REQUIRED` (428), ' + + 'and the person performs the action in the app. The agent cannot confirm for the ' + + 'person: `confirm: true` is an unverifiable caller claim, and those two tools refuse ' + + 'any call that carries the member, on every action, so a client resends without it. ' + + 'Two BOUNDS to read before you rely on it. (1) The enforced set is the doors that ask ' + + 'every action for the author\'s `ai.exposed` opt-in — today the action door reached ' + + 'from the MCP `run_action` and `resume_run` tools. REST `/actions` reads `ai.exposed` ' + + 'in one case only (an AI service account starting a `type: \'flow\'` action whose ' + + 'flow declares `runAs: \'system\'` needs the opt-in there), and that check asks for ' + + 'the opt-in alone, not a confirmation; for a person\'s call REST `/actions` sits ' + + 'OUTSIDE this gate, so a human in front of that route is still yours to arrange. An ' + + 'AI service account (an agent acting for itself, not on a person\'s behalf) does not ' + + 'confirm an action for itself: it is refused at every action door, REST `/actions` ' + + 'included, whatever its request carries, and a person runs the action. (2) Only the ' + + 'author\'s declared `ai.requiresConfirmation: true` asks the person: the wider listing ' + + 'heuristic that reports `requiresConfirmation` for a destructive-looking action ' + + 'ADVISES a client to ask and never gates, and an explicit `false` never gates. For AI ' + + 'metadata mutations the ADR-0033 draft/publish workspace is the gate: nothing is live ' + + 'until a human publishes.', }; /** diff --git a/packages/spec/src/contracts/ai-service.ts b/packages/spec/src/contracts/ai-service.ts index 3f1c8285307..f687c1cf2ce 100644 --- a/packages/spec/src/contracts/ai-service.ts +++ b/packages/spec/src/contracts/ai-service.ts @@ -204,7 +204,9 @@ export interface AIToolDefinition { * ONE exported constant, because the member's SPELLING is the whole contract: * the door that refuses and the client that retries have to agree on it, and a * door hand-spelling its own `'confirm'` is precisely how two doors drift into - * two dialects (Prime Directive #12). Every AI-facing action door reads this. + * two dialects (Prime Directive #12). Every door that gates on the member reads + * this, and the MCP `run_action` and `resume_run` tools key their REFUSAL of it + * off this constant (below). * * It rides as a TOP-LEVEL member of the action request. The two request * shapes it is destined for are the MCP `run_action` tool input (`actionName` @@ -212,8 +214,13 @@ export interface AIToolDefinition { * and the runtime action door's own request object — the `input` argument of * `invokeBusinessAction` (`objectName` / `recordId` / `params`, * `packages/runtime/src/action-execution.ts`), which the MCP bridge builds - * that object from. Each grows the member in the change that enforces it, so - * neither ever accepts-and-ignores it. A third door carries the same member + * that object from. Each grew the member in the change that enforced it. The + * MCP tool input has since retired it (below). The runtime request keeps it + * for the host door, which reads it; on the MCP bridge path the same request + * type still accepts it but nothing reads it there (the amended contract asks + * the person instead), and no MCP call can supply it, because the tool refuses + * the member before the bridge is called. A third door + * carries the same member * at the top level of its input: the MCP `delete_record` tool (see * {@link AIActionConfirmation}, "The second gate"). Two placements were * rejected, and the reasons are the contract: @@ -244,10 +251,15 @@ export interface AIToolDefinition { * The amended contract ({@link AI_ACTION_CONFIRMATION_CAPABILITY}) has a * person confirm an action declaring `ai.requiresConfirmation: true`, through * an elicitation or a hand-off to the app, and the member never counts on such - * a call. That is what the doors enforce from the change that implements the - * amendment; until it ships they still gate on the member as described above - * and in {@link AIActionConfirmation}. The MCP `delete_record` and - * `delete_records` gates are outside the amendment and keep reading it. + * a call. The MCP `run_action` and `resume_run` tools implement it, and with + * it the member is RETIRED from both tools' input: a call that carries it is + * refused by the tool's closed input, before the call is resolved, on every + * action, declared-gated or not. The refusal says that confirmation happens in + * the app, by the person, and the caller resends without the member. A door + * that has not implemented the amendment (a host door under the `ai` posture) + * still gates on the member as described above and in + * {@link AIActionConfirmation}. The MCP `delete_record` and `delete_records` + * gates are outside the amendment and keep reading it. */ export const AI_ACTION_CONFIRMATION_MEMBER = 'confirm'; @@ -262,8 +274,12 @@ export const AI_ACTION_CONFIRMATION_MEMBER = 'confirm'; * now a person's confirmation ({@link AI_ACTION_CONFIRMATION_CAPABILITY}): * the server elicits it through the client, or hands the call to the host's * pending-confirmation service for the person to decide in the app, and the - * caller's own `confirm` never counts. What follows describes the member contract the - * doors enforce until the change that implements the amendment; the + * caller's own `confirm` never counts. The MCP `run_action` and `resume_run` + * tools implement the amendment and no longer accept the member at all: a call + * that carries it is refused at the tool's input, on every action, and the + * caller resends without it. What follows describes the member contract a + * door enforces until it implements the amendment (a host door under the `ai` + * posture), and the FROM half of the MCP tools' breaking note; the * predicate section (the DECLARED flag, never the listing heuristic) and the * AI service account rule carry over unchanged. The MCP `delete_record` and * `delete_records` gates are outside the amendment and keep reading the @@ -391,17 +407,23 @@ export interface ActionConfirmationRequiredDetails { /** The object the action operates on; omitted for object-less actions. */ objectName?: string; /** - * The request member a caller acting for a person sets to `true` and - * retries with, once its human approves — always the value of - * {@link AI_ACTION_CONFIRMATION_MEMBER}, echoed so the caller reads it off - * the refusal instead of restating it. An AI service account's refusal - * carries it too, but no retry of that account's succeeds: a person runs - * the action (ADR-0151 D3 rule 3). + * Always the value of {@link AI_ACTION_CONFIRMATION_MEMBER}, echoed so the + * caller reads the member's spelling off the refusal instead of restating + * it. What the caller does with it depends on the gate that refused: * - * Under the amended contract ({@link AI_ACTION_CONFIRMATION_CAPABILITY}), - * once the doors implement it, no retry with the member runs a - * declared-gated action: the member confers nothing there, and `reason` - * says what the caller can do. + * - A member gate (no `reason`: the MCP `delete_record` / `delete_records` + * gate, or a door before the amendment): a caller acting for a person + * sets it to `true` and retries, once its human approves. + * - A refusal under the amended contract ({@link AI_ACTION_CONFIRMATION_CAPABILITY}, + * `reason` set): the member confers nothing, and no retry with it runs + * the action; `reason` says what the caller can do. At the MCP + * `run_action` and `resume_run` tools the echo names the member those + * tools REFUSE at their input: the caller never sends it there, since + * the person confirms, in the client when it can be asked there and in + * the app otherwise. + * + * An AI service account's refusal carries it too, but no retry of that + * account's succeeds: a person runs the action (ADR-0151 D3 rule 3). */ confirmationMember: typeof AI_ACTION_CONFIRMATION_MEMBER; /** @@ -524,7 +546,11 @@ export interface ActionConfirmationRequiredDetails { * 5. **The caller's `confirm` never counts.** On a declared-gated call the * member ({@link AI_ACTION_CONFIRMATION_MEMBER}) confers nothing: not with * an elicitation, not in place of one, not in place of a hand-off, and not - * when the host has no service. + * when the host has no service. The MCP `run_action` and `resume_run` + * tools do not accept it at all: a call carrying it is refused at the + * tool's input, on every action, gated or not, because the person + * confirms (elicited in the client where it can be asked, in the app + * otherwise); the caller resends without it. * 6. **An AI service account: unchanged** (ADR-0151 D3 rule 3). An agent * principal acting for itself, with no `onBehalfOf`, is refused whatever it * sends, reason `service_account`. It is neither elicited (no person stands @@ -614,11 +640,13 @@ export interface ActionConfirmationRequiredDetails { * * This text is the contract from the release that carries it. The doors * implement it in the change that enforces it, which also moves the shipped - * prescriptions that describe the member. Until that change ships, every door - * still gates on the member as {@link AIActionConfirmation} describes: the - * MCP `run_action` and `resume_run` tools run a declared-gated action on - * `confirm: true`, over stdio and over Streamable HTTP alike, and that reading - * is the FROM half of the breaking note. The in-app door likewise runs + * prescriptions that describe the member. Until a door's change ships, it + * still gates on the member as {@link AIActionConfirmation} describes. The + * MCP `run_action` and `resume_run` tools ran a declared-gated action on + * `confirm: true` until theirs, over stdio and over Streamable HTTP alike, and + * that reading is the FROM half of their breaking note; the release that + * ships their hand-off also retires the member from their input, so a call + * that carries it is refused there. The in-app door likewise runs * ADR-0011's queue as documented until its implementing change ships: any * holder of `ai:approve` may decide an item, the approve and reject doors take * whatever credential they authenticate, and an approved item is re-dispatched diff --git a/packages/spec/src/migrations/entries/semantic/18.action-requires-confirmation-elicited.ts b/packages/spec/src/migrations/entries/semantic/18.action-requires-confirmation-elicited.ts index d8061a43dd9..b5f2094a135 100644 --- a/packages/spec/src/migrations/entries/semantic/18.action-requires-confirmation-elicited.ts +++ b/packages/spec/src/migrations/entries/semantic/18.action-requires-confirmation-elicited.ts @@ -8,38 +8,47 @@ import type { SemanticMigration } from '../../types.js'; // caller's own `confirm: true` stops counting once the doors implement it. A // structured TODO, not a D2 conversion: nothing an author wrote is rewritten // or refused, and whether a gated action still needs a person is the author's -// judgement. Written conditionally on purpose: in the release that first -// carries this entry the doors still gate on `confirm: true`. +// judgement. Written conditionally on purpose: the release that first carried +// this entry (spec 18.5.0) still gated on `confirm: true`. The switch is keyed +// on the hand-off, the step every MCP door takes (#33690), never on +// elicitation (review nit 2 on PR #34202), which only a door that can carry +// the question takes (#33712: stdio first, ahead of the hand-off); the same +// switch retires the member from both tools' input (#34209, ruling 6909355256). export const entry: SemanticMigration = { id: 'action-requires-confirmation-elicited', surface: 'objects[].actions[].ai.requiresConfirmation and actions[].ai.requiresConfirmation set to `true` — ' + 'what the declaration asks of a caller on the MCP `run_action` and `resume_run` tools', replacement: - 'Read this against your runtime first. Until the release whose changelog says the AI doors confirm by ' - + 'elicitation, `run_action` and `resume_run` still run a declared-gated action on the caller\'s ' - + '`confirm: true`, and a call without it is refused with `ACTION_CONFIRMATION_REQUIRED` (428): keep sending ' - + 'it there. From that release, keep the declaration where a person must approve the call; what changes is ' - + 'who confirms. The server asks the person in the MCP client with an elicitation (`elicitation/create`, ' - + 'form mode) when the client advertised the `elicitation` capability at `initialize`; otherwise it hands ' - + 'the call to the host\'s pending-confirmation service, answers `status: \'pending_confirmation\'` with a ' + 'Read this against your runtime first. The switch is the release whose changelog says `run_action` and ' + + '`resume_run` hand a declared-gated call to the person (`status: \'pending_confirmation\'`). Before it, ' + + 'those tools still run a declared-gated action on the caller\'s `confirm: true`, and a call without it is ' + + 'refused with `ACTION_CONFIRMATION_REQUIRED` (428): keep sending it there. From that release, keep the ' + + 'declaration where a person must approve the call; what changes is who confirms. The server hands the ' + + 'call to the host\'s pending-confirmation service, answers `status: \'pending_confirmation\'` with a ' + 'pending id, and the person approves or rejects it in the app, where it runs as them with every ' + 'permission re-checked. Only a host with no such service refuses, with `details.reason` ' - + '`no_confirmation_service`. From then on the caller\'s own `confirm: true` confirms nothing.', + + '`no_confirmation_service`. The same release stops accepting `confirm` on `run_action` and ' + + '`resume_run` at all: a call that carries it is refused at the tool, on every action, so the caller ' + + 'resends without it. A runtime whose changelog also says the MCP doors confirm by elicitation asks the ' + + 'person in the MCP client instead (`elicitation/create`, form mode) when the client advertised the ' + + '`elicitation` capability at `initialize` and the connection can carry the question: accept runs the ' + + 'call, and decline, dismissal or no answer in time refuses it.', reason: '`confirm: true` was the caller\'s own claim that a person approved, and nothing could check it: an agent ' + 'could send it for an irreversible action on reading the person\'s instruction as consent, and measured ' + 'runs did exactly that. The gate made forgetting loud and did not prove a person. The server asking the ' - + 'person, in the client or in the app, with the caller unable to answer for them, is what makes the ' + + 'person, in the app or in the client, with the caller unable to answer for them, is what makes the ' + 'declaration mean what an author who wrote it meant. No mechanical move applies: the metadata is ' + 'unchanged, and the work is on the client side and in the author\'s decision about each gated action. ' + 'ADR-0011 / ADR-0151 / ADR-0087.', acceptanceCriteria: 'Now: for every action declaring `ai.requiresConfirmation: true`, decide again that a person must approve ' - + 'each AI call; if not, declare `false` knowingly. Once your runtime confirms by elicitation (its changelog ' - + 'says so; a refusal then carries `details.reason`): an MCP client that supports elicitation asks the ' - + 'person in place; any other caller gets a pending answer and the person decides in the app, provided the ' - + 'host runs a pending-confirmation service; a script or agent that ran such an action unattended on its ' - + 'own `confirm: true` no longer runs it, and a person does. Done when no caller relies on its own ' - + '`confirm: true` for a declared-gated action on a runtime that has switched.', + + 'each AI call; if not, declare `false` knowingly. Once your runtime hands such a call to the person (its ' + + 'changelog says so; a refusal then carries `details.reason`): an MCP client that supports elicitation, on ' + + 'a connection that can carry it, has the person asked in place; any other caller gets a pending answer and ' + + 'the person decides in the app, provided the host runs a pending-confirmation service; a script or agent that ' + + 'ran such an action unattended on its own `confirm: true` no longer runs it, and a person does; and no ' + + 'client sends `confirm` to `run_action` or `resume_run`, which refuse it. Done when no caller sends ' + + '`confirm` to those two tools on a runtime that has switched.', }; diff --git a/ui/apps/console/src/pages/developer/objectstack-skill.ts b/ui/apps/console/src/pages/developer/objectstack-skill.ts index b56f4c45607..4a2e8866baf 100644 --- a/ui/apps/console/src/pages/developer/objectstack-skill.ts +++ b/ui/apps/console/src/pages/developer/objectstack-skill.ts @@ -201,27 +201,37 @@ create/update payload. but \`run_action\` would refuse it for you (your credential, or your role in this organization): \`unavailable.reason\` says why and what would let it run, so tell your human instead of calling it. -- **run_action({ actionName, objectName?, recordId?, params?, confirm? })** — +- **run_action({ actionName, objectName?, recordId?, params? })** — invoke a business action by name. Invocation is permission-gated, but the action body executes the app's registered logic as trusted code (it can mutate data or trigger flows with the app's own authority). Pass \`recordId\` for record-scoped actions and \`params\` for declared inputs; - \`objectName\` only disambiguates a name shared by multiple objects. Pass - \`confirm: true\` on an action \`list_actions\` reports as - \`requiresConfirmation\` — the server REFUSES such a call without it - (\`ACTION_CONFIRMATION_REQUIRED\`) and nothing runs. Ask your human first; - the flag asserts an approval, it does not obtain one. Under an AI service + \`objectName\` only disambiguates a name shared by multiple objects. An + action \`list_actions\` reports as \`requiresConfirmation\` may need a + person's approval, which you cannot give: when its author declared it and + your client supports elicitation on a connection that can carry it, the + person is asked in your client — accept runs the call once, and any other + answer refuses it (\`ACTION_CONFIRMATION_REQUIRED\`); do not retry unless + they ask. Otherwise the call does not run, and you are answered + \`status: "pending_confirmation"\` with a \`pendingId\` — the person + approves or rejects it in the app, so relay the message and do not retry. + A server that cannot hand it off + refuses it (\`ACTION_CONFIRMATION_REQUIRED\`, \`details.reason\` + \`no_confirmation_service\`) and nothing runs: the person performs it in the + app. Never send \`confirm\`: the tool refuses a call that carries it, on + every action. Under an AI service account's own key (an agent acting for itself, for no person) the call is refused whatever it sends and nothing runs: hand the action to a person, or its author declares \`ai.requiresConfirmation: false\` when it is safe unattended. -- **resume_run({ runId, values?, confirm? })** — continue a flow run that +- **resume_run({ runId, values? })** — continue a flow run that \`run_action\` answered with \`status: "paused"\` and a \`screen\` (a form the flow needs filled in). Send the screen's field values in \`values\`, keyed by the names in \`screen.fields\`. The run completes, or pauses again on its next screen, which you fill with another \`resume_run\`. Only the user whose call started the run can resume it, under the same gates as \`run_action\` - (including \`confirm: true\` for an action flagged \`requiresConfirmation\`, + (the person's confirmation, in your client or in the app, for an action its + author declared \`requiresConfirmation\`, the refusal of a call that sends \`confirm\`, and its refusal under an AI service account's own key whatever the call sends). ## Conventions & gotchas