Repository navigation
feat(runtime,mcp): ask the person in their MCP client before a confirmation-gated action runs - #34318
Conversation
Co-Authored-By: Claude <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01QsR2jTEivi2wogPpeo3xd5
Co-Authored-By: Claude <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01QsR2jTEivi2wogPpeo3xd5
Co-Authored-By: Claude <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01QsR2jTEivi2wogPpeo3xd5
Co-Authored-By: Claude <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01QsR2jTEivi2wogPpeo3xd5
Co-Authored-By: Claude <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01QsR2jTEivi2wogPpeo3xd5
📓 Docs Drift CheckThis PR changes 2 package(s): 31 hand-written doc(s) name something this change touched — list omitted above 15 rows. Re-derive on the tree named below: ⛔ 7 release-owned page(s) also affected — read-only, see AGENTS.md Documentation Guardrails. What this run could not see
Coarse fallback — 37 page(s) merely mention a changed package (the pre-#9192 predicate, kept for the deliberately-wide backstop): Which tree this was computed onThis run read A worktree cut from an older # while this PR is open — GitHub drops the merge commit once it closes
git fetch origin 8b09292f6340d8ba3af48d6a2800c56a8c2b8d7e && git checkout 8b09292f6340d8ba3af48d6a2800c56a8c2b8d7e
# afterwards, rebuild it from the two parents, which stay fetchable
git fetch origin 4c0cf65f79a7db985edc349d3615d3bb52d6362e c3019504e02664d6e96c940a28dfdaebb28d0198 && git checkout -B drift-repro 4c0cf65f79a7db985edc349d3615d3bb52d6362e && git merge --no-ff c3019504e02664d6e96c940a28dfdaebb28d0198
node scripts/docs-audit/affected-docs.mjs --json 4c0cf65f79a7db985edc349d3615d3bb52d6362e
|
|
domain:server#5 · zhuangjianguo · session_01QsR2jTjrNnh6b2BkCXFugM |
|
domain:server#5 · zhuangjianguo · session_01QsR2jTjrNnh6b2BkCXFugM Contract reviewServed-tier: The face is semantic, not a narrowing ( ① Derived judgments
② Semver level
③ Boundary flags
④ Design judgmentThe change makes the spec's own declared step real at the one door that can carry it, and takes nothing away at any other. It follows the contract's order and its answer table. Findings:
Spoof, replay and race: the answer is read from the SDK's pending-request table for the one request the server sent on the connection it was sent on; a second or late answer finds no pending request. ADR-0011 already states what an No must-fix. Findings 1 and 2 earn a delta review of their fix. Implemented-by: |
|
domain:server#5 · zhuangjianguo · session_01QsR2jTjrNnh6b2BkCXFugM Review — PASSHead-sha: What holds
MustNone. ShouldThese are the contract record's findings 1 and 2, which I verified against the diff. Each earns a delta review of its fix, and I'd fix both in this PR before landing.
Nits
Board items for the area, not this diff: the no-service message still omits "use a client that supports confirmation" (contract step 3.3) and needs a carrier card before #33712 closes; #33712's close note owes "hosted HTTP users keep the email path until #34321"; Gates51 check runs at this head: 35 success, 16 skipped (the ui, docs, dogfood and temporal jobs the path filter leaves out, the opt-in jobs, and the queue-only and schedule-only verdicts), 0 failed or pending. Test Core 8/8, Build Core, TypeScript Type Check, Lint & Repo Gates, Check Changeset and the PR-body guards are green. The PR body records 70/70 derived dispatch gates run, all exit 0, and a clean The contract-review record for the |
… answer Co-Authored-By: Claude <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01QsR2jTEivi2wogPpeo3xd5
…s, the record id on a line of its own Co-Authored-By: Claude <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01QsR2jTEivi2wogPpeo3xd5
…stion Co-Authored-By: Claude <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01QsR2jTEivi2wogPpeo3xd5
|
domain:server#5 · zhuangjianguo · session_01QsR2jTjrNnh6b2BkCXFugM Contract reviewServed-tier: Delta review of the record on head ① Derived judgments
② Semver levelUnchanged and still matching: ③ Boundary flags
④ Design judgment
Nothing new of should-fix grade was introduced. The second admission pass is reads only and cannot run or hand off anything. No must-fix, no should-fix. Nits alone end the round. Implemented-by: |
|
domain:server#5 · zhuangjianguo · session_01QsR2jTjrNnh6b2BkCXFugM Review — PASS (delta)Head-sha: The head is the merge of the dev's What holds
Must / ShouldNone. Nits
GatesAt |
|
domain:server#5 · zhuangjianguo · session_01QsR2jTEivi2wogPpeo3xd5 席位核对ACCEPT and landing · area S3 · 2026-11-16T08:40Z · head
Ready + auto-merge under the area S3 landing line (maintainer, project thread, 2026-11-15T11:06Z) and the pm-dispatch landing procedure (maintainer, 2026-11-15T15:56Z); in-flight work under the wind-down order (2026-11-16T07:43Z). Generated by Claude Code |
Stacks #34318's in-client elicitation onto the retired confirm member: run_action and resume_run pass the elicitor door as main does, and their bridge request no longer forwards the caller's confirm (the closed input refuses it first; elicitation never read it). Claude-Session: https://claude.ai/code/session_01FEkQ5kgF3mo9f7LXuv5hac Co-Authored-By: Claude <noreply@anthropic.com>
… that works on the door that asked (objectstack-ai#37367) Fixes objectstack-ai#34325 Clause-②: yes (widening) Metadata-protocol: none ## 维护者速读 - 用户能看到什么变化:AI 客户端调用需要人工确认的业务动作、而服务器没有挂起审批服务时,拒绝提示会按入口说清楚该怎么办:本地(stdio)连接且客户端不支持弹框确认时,提示换用支持确认的客户端;所有入口都提示由人在应用里完成,并且不要改用别的工具做同样的修改。 - 为什么做:属于「MCP 写数」主线;此前有 AI 读到「去应用里做」后改用直接改记录的工具绕过了确认,维护者已同意在提示里明确禁止。 - 出错会怎样:只改拒绝提示的文字,错误码、状态和返回字段都不变,不会改数据;对外接口只新增可选项,已有接入方不受影响;可直接撤回。 - 要你做什么:无。 ## What changes The `no_confirmation_service` refusal (`428 ACTION_CONFIRMATION_REQUIRED`) that the MCP `run_action` and `resume_run` doors answer when a declared-gated action meets a host with no pending-confirmation service now names the route that works on the door that asked. The code, the status, `details` (including `reason`) and the hand-off handed to a host's service are unchanged. No spec file is touched. Messages, measured through the real runtime bridge (`buildMcpBridge`) at this head, for `archive_lead` on `crm_lead`: - Before, every door (main 80da086): `Action 'archive_lead' on 'crm_lead' declares ai.requiresConfirmation: true, so a person confirms it — nothing was run. This server has no pending-confirmation service to ask them through, and a confirmation sent on the request does not count. Perform the action in the app instead.` - After, stdio door, client without `elicitation`: `... does not count. A client that supports confirmation (MCP elicitation) is asked in place on this server: use one to confirm it here. Otherwise a person performs it in the app: do not make the same change with another tool.` - After, Streamable HTTP door (and any caller that passes no door): `... does not count. A person performs it in the app: do not make the same change with another tool.` The first sentence is the step-3 sentence of `AI_ACTION_CONFIRMATION_CAPABILITY`. It is left out on Streamable HTTP, which asks no client until objectstack-ai#34321, as ruling 6909391261 on objectstack-ai#33712 says. The in-app clause on every door is the wording of comment 6966146204 on this card. It matches the `run_action` description clause that objectstack-ai#37355 added. How the refusal site knows the door: the MCP tools already decide per call whether the client can be elicited (`actionConfirmationElicitorFor`, from objectstack-ai#34318). A new `actionCallDoorFor` in `packages/mcp/src/action-confirmation-elicitation.ts` returns one of three things: - `door`, main's `McpActionCallDoor` (the elicitor), when the client can be asked. The bridge is called with three arguments, as on main; - `facts`, `{ elicitsCapableClients: true }`, when this server read the client's `initialize` and can carry a request to it, but the client did not advertise form-mode `elicitation` (the long-lived stdio server today). The bridge is called as `(name, request, undefined, facts)`; - nothing, when the server never read `initialize` (the per-request Streamable HTTP server). The bridge is then called with two arguments, as before. The check is made on what the server can do, not on a transport name. If the HTTP door starts to read `initialize` (objectstack-ai#34321), it gets the sentence at the same time as the elicitation that makes it true. The runtime bridge (`packages/runtime/src/domains/mcp.ts`) forwards the flag through `invokeBusinessAction` / `confirmAdmittedAction` (`action-dispatch.ts`) and `resumeActionRun` to `handOffActionConfirmation(..., door)` (`action-execution.ts`). It arrives as a separate argument, not on `ActionConfirmationHandOff`, so the host's service never sees it. Public surface of `@objectstack/mcp`, additive only (hence `Clause-②: yes (widening)`): - `McpActionCallDoor` is unchanged, and it is still passed only when the client can be elicited; - there is a new exported type `McpActionCallDoorFacts` (`{ elicitsCapableClients?: true }`); - `McpActionBridge.runAction` and `resumeRun` gain an optional fourth parameter `facts`. A bridge written against main compiles unchanged. It ignores the fourth argument and hands the call off as before, so only the refusal wording differs on such a bridge. ## Tests - `packages/runtime/src/action-confirmation-handoff-33690.test.ts`, new describe `[objectstack-ai#34325]` (7 cases), run through the real bridge for both tools. With the stdio door, the message carries the client sentence followed by the in-app clause. With no door (HTTP), it carries the in-app clause and never the client sentence. `details` are equal on both doors. The flag never reaches the service's hand-off. - `packages/mcp/src/mcp-action-confirmation-handoff-33690.test.ts`, new describe `[objectstack-ai#34325]` (6 cases), for both tools: - stdio with a client without `elicitation`: the bridge gets no door and exactly `{ elicitsCapableClients: true }` as the fourth argument; - stdio with a client that has the capability: main's door (the elicitor alone), three arguments, no facts; - Streamable HTTP after an `initialize` that advertised `elicitation`: no door, two arguments. - One existing objectstack-ai#33712 pin, "a client WITHOUT the capability", pinned `door: undefined, argCount: 2` on stdio. The door is still `undefined`; the pin now also reads `facts: { elicitsCapableClients: true }` and `argCount: 4`. The intent is the same: the client is never asked and the call is handed off. The Streamable HTTP pin is unchanged. - Ablations, one-off, via `scripts/ablation-replace.mjs`: each anchor went from 1 hit to 0, and each restore left the blob equal to HEAD with an empty `git diff HEAD`. The tests import source through relative paths, so no dist rebuild is on the path. All 7 went red: - A1, the client sentence switched off: runtime stdio x2 red. - A2, the in-app clause reverted to today's wording: runtime stdio x2 and HTTP x2 red. - A3, the bridge's forwarding of the flag deleted: runtime stdio x2 red. - A4, `confirmAdmittedAction` stops passing it: runtime stdio `run_action` red. - A5, the resume path stops passing it: runtime stdio `resume_run` red. - A6, `actionCallDoorFor` never returns the facts: mcp stdio x3 red (one existing pin and two new ones). - A7, the facts are set without a read `initialize`: mcp HTTP x3 red (the existing objectstack-ai#33712 HTTP pin and two new ones). - All seven re-run on head fa794d0 after the rework: same red sets, every restore equal to HEAD. ## Acceptance notes - An out-of-repo bridge built against main keeps compiling and behaving as today. On a stdio client without `elicitation` its refusal keeps the old wording until it reads `facts`. carrier: cloud (if cloud implements that bridge). - The spec's step-3 prose (`packages/spec/src/contracts/ai-service.ts`) still describes one message with both routes. The HTTP door's omission of the client route follows ruling 6909391261. The prose is left as it is. ## Verification Two-minute check: `pnpm --filter @objectstack/runtime exec vitest run src/action-confirmation-handoff-33690.test.ts -t 34325`. Expect 7 passing, including `stdio, a client without elicitation (run_action)` and `Streamable HTTP, no door (run_action)`. Readings at fa794d0: <details><summary>build, typecheck, vitest (under os-verify-lock)</summary> - `pnpm --filter '@objectstack/runtime^...' --filter '@objectstack/mcp^...' build && mcp typecheck && runtime typecheck && both pin files`: VERDICT command-exit 0 (pins 53/53 and 34/34). - `pnpm --filter @objectstack/mcp test`: MCP_EXIT=0, Test Files 85 passed (85), Tests 1515 passed (1515). - `pnpm --filter @objectstack/runtime test`: RUNTIME_EXIT=0, Test Files 649 passed (649), Tests 12034 passed, 25 skipped (12059). </details> <details><summary>derived gate families</summary> - `dispatch-gates --commands --repo objectstack-ai/objectstack`: 69 families. - 68 exit 0, including `check-adr-0087-registration` and `check-changeset-no-major` on the `yes (widening)` changeset. `check:dual-build-cjs-loads` exit 3 (PREREQUISITE NOT MET: no whole-repo dist), so it is NOT MEASURED locally and left to CI. - `--ran` with exit codes: 69 derived, 68 run, 1 NOT-MEASURED, 0 UNRUN (exit 0). - `overlap-check`: clean against origin/main 98bda0a. No merge of main was needed: main's 4 new commits do not touch `packages/mcp` or `packages/runtime`. </details> --- _Generated by [Claude Code](https://claude.ai/code/session_01QSeKYo86w1wqy2z2fMrryr)_ 🤖 Generated with [Claude Code](https://claude.com/claude-code) https://claude.ai/code/session_01QSeKYo86w1wqy2z2fMrryr <!-- signed: repo:objectstack#4 · os-justin · session_01QSeKYo86w1wqy2z2fMrryr --> --------- Co-authored-by: Claude <noreply@anthropic.com>
domain:server#5 · zhuangjianguo · session_01QsR2jTEivi2wogPpeo3xd5
Requested by Steedos · project thread
Part of #33712
Clause-②: no
Metadata-protocol: semantic (at the MCP door, an author's
ai.requiresConfirmation: trueis confirmed in place for a client that advertiseselicitation. The dev confirms the level against the diff and, if it holds, adds the PR body'sSkills-docs:line.)Skills-docs: follow-up #34210 (widened to cover the in-client question and the
declined/cancelled/timed_outrefusals)维护者速读
ai.requiresConfirmation: true且客户端声明了征询能力的 stdio 调用;远程 HTTP 接口行为与字节均未变。回滚即还原本 PR。packages/runtime/src/action-dispatch.ts(confirmAdmittedAction的征询分支)、packages/mcp/src/action-confirmation-elicitation.ts(超时与取消的判读)、packages/runtime/src/domains/mcp.ts(resume_run分支)。pnpm --filter @objectstack/mcp exec vitest run src/mcp-action-confirmation-handoff-33690.test.ts,应见 18 个用例全绿,其中 stdio 同意/拒绝/取消与 HTTP 仍挂起各有专用例。What changes
Step 1 of the amended confirmation contract (
AI_ACTION_CONFIRMATION_CAPABILITY,packages/spec/src/contracts/ai-service.ts) at the MCPrun_actionandresume_rundoors, on the server that can carry it.@objectstack/mcp, newaction-confirmation-elicitation.ts:actionConfirmationElicitorFor(server, extra)answers an elicitor for the open tool call, orundefinedwhen the client did not advertise form-modeelicitationon this server'sinitialize(the SDK reads an emptyelicitation: {}as form mode). The elicitor sends ONEelicitation/create(form mode, emptyrequestedSchema) throughextra.sendRequest, related to the tool call, bounded byACTION_CONFIRMATION_ELICITATION_TIMEOUT_MS(five minutes, the door's bound the contract asks the door to name; a door constant, no authorable key), abandoned on the call's abort signal. It reads the result'sactiononly (a loose schema, so a form payload the SDK's ownElicitResultSchemawould reject cannot turn anacceptinto a failure). A timeout reads astimed_out; an error answer, an aborted call and a closed connection read ascancel(the abort check comes first because the SDK rejects an aborted request with aRequestTimeouterror too).mcp-http-tools.ts: both tools pass{ elicitConfirmation }as a third bridge argument only when the elicitor exists; otherwise the bridge is called with exactly the two arguments it got before.McpActionBridge.runAction/resumeRungain the optionaldoor?: McpActionCallDoor. Both tool descriptions gain one sentence on the in-client question.@objectstack/runtime:action-dispatch.tsconfirmAdmittedAction(washandOffAdmittedAction) asks the elicitor after the same caller-scope subject verdict the hand-off asks, so the contract's step order holds (every admission gate, the subject load and its verdict, then the person).acceptreturns torunResolvedAction, which dispatches as any admitted call (theaction_invocationrow is written as for any run).decline/cancel/timed_outare refused428 ACTION_CONFIRMATION_REQUIREDwithreasondeclined/cancelled/timed_out, through the existingconfirmationRefusalOf. An elicitor that throws reads ascancelled. Nothing is handed off on any answer.action-execution.tsgainselicitActionConfirmationandactionConfirmationElicitSubject(the action, its label, the object, the record id, and the record's title viaresolveRecordTitle, left out rather than replaced by the id).domains/mcp.tsforwards the door from the bridge and givesresumeActionRunthe same branch:acceptresumes the parked run, any other answer refuses and the run stays paused.Tests
packages/runtime/src/action-confirmation-handoff-33690.test.ts, two new top-leveldescribes on the existing harness (the realbuildMcpBridgeover a kernel double;nameField: 'name'added to its object so the question can carry a title): run_action accept runs once and hands nothing off, the elicitor gets{ actionName, actionLabel, objectName, recordId, recordTitle: 'Ada' }; an accept covers one call; decline / cancel / timed_out refused with their reasons, nothing runs, nothing submitted; a failing elicitor readscancelled; an account and an unreadable record are refused before the elicitor is called; an ungated action is never asked; resume_run accept resumes with the call's values, decline keeps the run paused, an account is refused before asking.packages/mcp/src/mcp-action-confirmation-handoff-33690.test.ts, three new top-leveldescribes: a real SDKClienton the long-lived server'sStdioServerTransport(newline framing over two pipes) advertisingelicitation: {}: accept (one form-mode request naming action, object, record title and id), accept with an unread payload, decline, cancel, an error answer, and resume_run accept / decline; a client without the capability is never asked and the bridge gets two arguments. Streamable HTTP: a client that advertisedelicitationatinitializeis handed off on the next POST, answeredapplication/json; a non-gated call answers plain JSON.actionConfirmationElicitorForagainst a realClientover the SDK's in-memory pair: accept / decline / cancel,timed_outat a 50 ms bound,cancelwhen the client closes the connection mid-question,cancelon an error answer.Acceptance notes
Part of. Measured on@modelcontextprotocol/sdk1.32.1 (LATEST_PROTOCOL_VERSION2025-11-25): the door builds a freshServerper POST (handleHttpRequest, stateless, no session id), so the server that answerstools/callnever ran_oninitializeand holds no client capabilities; and a client's answer to a server request arrives as a separate POST, which in stateless mode reaches another fresh server with no pending request (server request ids are per-instance counters, so they cannot even be routed by id). Streaming thetools/callresponse alone carries the question out but nothing can carry the answer back. Eliciting there needs Streamable HTTP sessions (Mcp-Session-Id), which is an architecture decision; the options are in the report on the card. Until then the contract's own rule holds there: a door that cannot elicit hands off and is never refused for that alone.main(step 4, andACTION_CONFIRMATION_REFUSAL_REASONS) refuses them withcancelled/timed_out. This PR follows the spec text and does not editpackages/spec; the conflict is raised for a ruling on the card. Flipping it is two branches inelicitActionConfirmation.skill-md.ts) is untouched; it stays with mcp: the served MCP skill and TOOL_RETIRED_KEY_GUIDANCE still teach run_action confirm: true, which the MCP door no longer reads since the confirmation hand-off #34209.scripts/ablation-replace.mjs, restore verifiedgit diff HEADempty): elicit branch inconfirmAdmittedActionremoved: 6 run_action pins red; elicit branch inresumeActionRunremoved: resume accept / decline red; the tool's elicitor forcedundefined: 5 stdio pins red ("expected [] to have a length of 1 but got +0"); the account refusal inaiDoorConfirmationremoved: both account-before-asking pins red; the capability check inactionConfirmationElicitorForremoved: the non-capable stdio pin and the HTTP pin red.Verification
Readings at head
3557594b65unless named (merge oforigin/mainat0f74af49d5; the only commit after it drops two inert lint comments in a test file).Package tests (each under the shared verify lock, exit captured per part)
@objectstack/mcptest: 66 files / 1204 tests passed (exit 0).@objectstack/runtimetest (full): 607 files passed, 11101 tests passed / 19 skipped (exit 0), atc09b8aa557, before theorigin/mainmerge, which moved no runtime source (two unrelated runtime test files). At the final head, the five confirmation files (action-confirmation-handoff-33690,mcp-resume-run,action-confirmation-gate,action-dispatch,mcp-system-object-action-exposure): 149 tests passed.@objectstack/mcp(its public exports grew):@objectstack/verify52 files / 439 passed;@objectstack/http-conformance20 / 292;@objectstack/example-todo9 / 249;@objectstack/cliunit layer 423 / 6010 (integration layer declared to CI).@objectstack/dogfoodis the battery: not run (no!, no(narrowing)arm). The runtime's dependents are not re-run: its package exports did not move.pnpm --filter @objectstack/mcp typecheckandpnpm --filter @objectstack/runtime typecheck: exit 0, test layers within their ledgers.--no-inline-config) on the eight touched source and test files: exit 0. The repo-widepnpm lintis left to CI.Derived gates
node scripts/pm/dispatch-gates.mjs --commands --repo objectstack-ai/objectstack: 70 commands. 68 ran in one loop, each with its exit captured before any pipe: all exit 0.check:type-check-debt(re-measure, 0 entries, OK) andcheck:dual-build-cjs-loads(123 entries load) ran afterwards under the lock: exit 0.--ran: 70 derived, 70 run, 0 NOT-MEASURED, 0 UNRUN.git merge-tree --write-treeagainst PR #34236's headc53ea9d147and againstorigin/main: both clean.Session: https://claude.ai/code/session_01QsR2jTEivi2wogPpeo3xd5
🤖 Generated with Claude Code