Skip to content

fix(runtime): MCP run_action answers a declared action with no handler as /actions does, 404 RESOURCE_NOT_FOUND - #31408

Merged
objectstack-fleet[bot] merged 2 commits into
mainfrom
claude/project-thread-oiz4q5
Nov 8, 2026
Merged

objectstack-fleet[bot] merged 2 commits into
mainfrom
claude/project-thread-oiz4q5

Conversation

@objectstack-fleet

Copy link
Copy Markdown
Contributor

Requested by Leehom · project thread

domain:server#6 · os-project-manager · session_01FEkQ5pVLKxR5eAhTYetnwR

Fixes #31330

Clause-②: no
Metadata-protocol: none

维护者速读

  • 改了什么:一个声明了但没有 handler 的动作("ghost" 动作),MCP bridge 以前抛一个不带 code 的 Error('No handler registered …')。现在改为抛出 /api/v1/actions 自己回答的那个路由未命中:同一句 Action 'X' on object 'Y' not found,404,RESOURCE_NOT_FOUND。
  • 为什么改:自 mcp: run_action and resume_run answer a code-less sandboxed action-body throw with the wrapper naming the body, where /actions answers 400 HOOK_ABORTED with the sentence #31271 起,run_action 通过 /actions 的同一个 reader(actionsDoorAnswerOf)作答,不带 code 的抛错被当成 400 VALIDATION_ERROR,等于告诉 agent 它的输入有错。而 REST 对同一个动作回 404。
  • 风险与回滚:只改 runtime 里一处抛错(action-execution.ts)。只有 MCP 的 bridge 能走到这里,REST 及其它门的回答不变(runtime 全量绿,/actions 的 pin 都没改)。MCP 为这个未命中写的 action_invocation 行也随之变成 404 / RESOURCE_NOT_FOUND,与 REST 写的那行一致。回滚即 revert。patch。
  • 先看:packages/runtime/src/action-execution.ts 中 !dispatch.dispatched 那段;新测试 packages/runtime/src/mcp-run-action-ghost-routing-miss.test.ts。
  • 两分钟验证:pnpm --filter @objectstack/runtime exec vitest run src/mcp-run-action-ghost-routing-miss.test.ts,预期 6 条全绿。
  • 需要你做的:无,由席位落地。

What changes

  • @objectstack/runtime action-execution.ts. When the MCP bridge (invokeBusinessAction → dispatchAdmittedBusinessAction) finds no handler for a declared script action, it now throws the routing miss as REST /actions answers it from its routing-miss branch (domains/actions.ts). The sentence is Action 'X' on object 'Y' not found, the status is 404, and the code is standardErrorCodeForHttpStatus(404), which is RESOURCE_NOT_FOUND. It used to throw Error('No handler registered for action 'X' on 'Y'') with no code.
  • Sentence. The order said to keep the producer's sentence unless /actions serves a different one. /actions does serve a different one, so the throw now uses the door's sentence, and the two doors answer the same bytes. No code reads the old sentence; the only readers were three test pins, which move here.
Ghost action (declared, no handler) Before (main f4b4c8a) After
MCP run_action 400 VALIDATION_ERROR, No handler registered for action 'X' on 'Y' 404 RESOURCE_NOT_FOUND, Action 'X' on object 'Y' not found
MCP action_invocation row failed, 500, INTERNAL_ERROR failed, 404, RESOURCE_NOT_FOUND
REST POST /api/v1/actions (the measured target) 404 RESOURCE_NOT_FOUND, same sentence unchanged
CONTROL: action with a handler runs on both doors unchanged
CONTROL: handler's coded refusal RECORD_LOCKED / 409 code and status kept on both doors unchanged

Tests

  • New packages/runtime/src/mcp-run-action-ghost-routing-miss.test.ts, 6 rows. One kernel serves both doors (handleActions and buildMcpBridge().runAction), so each pin is the agreement between them:
    • REST answers 404 / RESOURCE_NOT_FOUND / the routed-object sentence (the measured target).
    • The bridge's throw has the same code, status and sentence as the REST body.
    • actionsDoorAnswerOf(thrown) equals the REST body (code, status, message, no declaredCode).
    • Each door writes one failed invocation row with 404 / RESOURCE_NOT_FOUND.
    • CONTROL: with a handler bound, the action runs on both doors.
    • CONTROL: a handler's coded refusal keeps its code and status on both doors.
  • mcp-list-actions-handler-probe.test.ts: the two rejects.toThrow(/No handler registered/) pins now assert { code: 'RESOURCE_NOT_FOUND', status: 404 }.
  • packages/cli/test/package-install-local-handlers.integration.test.ts: the ghost run_action pin moves from VALIDATION_ERROR / 400 to the exact envelope { code: 'RESOURCE_NOT_FOUND', status: 404, message: "Action 'ghost_task' on object 'tasks_app_task' not found" }, measured over a real os start stack.
  • resume_run is not pinned: it continues a paused run through automation.resume and never reaches the script dispatch, so it cannot hit the miss.

Acceptance notes

  • Who reads the throw. Only domains/mcp.ts's bridge runAction calls invokeBusinessAction; REST /actions answers its own miss before any throw. No REST or other door's answer moves. service-settings' own "No handler registered … in 'ns'" sentence is a different producer and is unchanged.
  • Past-tense comments left as they are. domains/mcp.ts (~961), app-artifact-handlers.ts (~25) and cloud-connection/src/marketplace-install-local-plugin.ts (~5673) mention the old sentence as a measured history ("was listed … and refused there with …"). They are still true as history, and two of the files are outside this claim's surface.
  • Clause-②: no. A ghost action's run_action answer moves from an uncoded 400 to the coded miss /actions already serves. No new export, type or protocol member.

Verification

All on head f841c43e (base f4b4c8ae).

Red first, fix, suites
  • Red first on base f4b4c8ae, the new runtime file: Tests 3 failed | 3 passed (6). The bridge threw code: undefined, status: undefined; actionsDoorAnswerOf gave VALIDATION_ERROR / 400; the MCP row recorded 500 / INTERNAL_ERROR. The REST pin and both CONTROLs were green.
  • With the fix: the new file and the probe file, Tests 12 passed (12). The runtime suite and the cli file below ran on ce565b30; f841c43e changes only those two runtime test files (a module-top import, one unused fake member), and both were rerun green on it.
  • pnpm --filter @objectstack/runtime test: Test Files 556 passed (556), Tests 8963 passed | 19 skipped; lock VERDICT command-exit 0.
  • packages/cli/test/package-install-local-handlers.integration.test.ts (after --filter '@objectstack/cli...' build): Test Files 1 passed (1), Tests 17 passed (17); lock VERDICT command-exit 0.
  • typecheck for @objectstack/runtime (on f841c43e) and @objectstack/cli: exit 0 (test layers held: runtime 27 / 186 / 66, cli 3 / 28 / 6).
  • Lint, as the root script runs it, scoped to the touched packages (eslint packages/runtime/src packages/cli/test --no-inline-config): exit 0.
Ablation (ablation-replace, restored to HEAD)
  • action-execution.ts: the code / status on the miss throw spread only under a condition that is never true (String('ABL').length < 0), so the throw goes back to uncoded. Mutation landed (anchor 1 to 0, blob bcee193c06b8 to eb08314860a9). The new file plus the probe file: Tests 5 failed | 7 passed (12). The 3 new parity rows and the 2 probe rows went red; the REST pin and the CONTROLs stayed green. Restored: blob == HEAD (bcee193c06b8), git diff HEAD empty.
Derived gates

node scripts/pm/dispatch-gates.mjs --commands --repo objectstack-ai/objectstack at f841c43e: 67 commands, each run with stdin from /dev/null, all exit 0. The first loop, on ce565b30, read two reds from the new test file, both fixed in f841c43e: check:engine-double-contract (an unused findOne on the engine fake, now dropped) and check:test-source-alias (the new file and the edited probe file now pay the @objectstack/metadata load at module top). check:dual-build-cjs-loads exited 3 on that first loop (PREREQUISITE NOT MET) and 0 on the full rerun. dispatch-gates --ran: 67 derived families accounted for, 67 run, 0 NOT-MEASURED. Not run locally (CI): test:repo, dogfood shards, type-check lanes, the rest of the cli integration tier.

🤖 Generated with Claude Code

https://claude.ai/code/session_01FEkQ5pVLKxR5eAhTYetnwR

… answers

The MCP bridge threw a declared action with no handler as an uncoded
"No handler registered" error, which run_action answered as the /actions
reader's 400 VALIDATION_ERROR rejection. It now throws the routing miss
REST /actions answers: its sentence, 404 and RESOURCE_NOT_FOUND.

Co-Authored-By: Claude <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01FEkQ5pVLKxR5eAhTYetnwR
@github-actions github-actions Bot added size/m documentation Improvements or additions to documentation tests tooling Fix lands in tooling, not a product package — enters pm:queue only with Unblocks: or a named surface labels Nov 8, 2026
@github-actions

github-actions Bot commented Nov 8, 2026

Copy link
Copy Markdown
Contributor

📓 Docs Drift Check

1 anchor(s) derived from 1 changed package(s); no hand-written page names any of them, so this run has nothing to list — not a clean bill of health. This check sees only pages that NAME a derived anchor: one that documents this change in prose, or enumerates it in an authoring dialect, names none and stays invisible to it on every run.

What this run could not see
  • the SDK route bridge reached 64 of 227 client-bound route-ledger rows — the other 163 have no registrar path: tail to select them, so pages documenting THEIR client methods cannot appear above, on this or any run. Of those 163: 0 are remediable by widening that discovery convention (an in-repo file declares the path; the convention did not scan it); 59 are structural — on a ledger where NOT ONE row is declared in-repo, so no discovery change reaches them at any price; 104 are undecided (no in-repo declaration, on a ledger that has other in-repo registrars — absence and an unreadable spelling are not distinguishable here). The rows themselves: node scripts/docs-audit/affected-docs.mjs --bridge-coverage
  • a page that states a rule by its inputs shares no identifier with the emitter that implements the rule, so an emitter-only diff cannot list it — not on this run and not on any run. Measured on fix(driver-sql): emit varchar(maxLength) for a text field a declared index keys on #11430: content/docs/protocol/objectql/types.mdx documents the text-family column mapping by the ObjectQL type names it maps FROM (text / textarea / html) while the diff changed createColumn; it went unlisted, and it was the page that diff falsified, in four places. No shared token exists to detect this on, so a rule your change carries has to be re-read by hand in the pages that restate it.
  • a key NAME is not a key, so the hand re-read the line above prescribes can land on the wrong schema. The same spelling is authorable on one governed type and a [REMOVED] tombstone on another for each of active, aria, joins, objects, template, tools and version (censused on [finding] tools is a key on BOTH AgentSchema (tombstoned, dead) and SkillSchema (live, cloud-attested), so a name-based search attributes skill examples to the agent key — it produced a false stop-the-line alarm on PR #19059 #19093 over the liveness ledger's governed types, top-level keys); nothing in a search result distinguishes the two, so a grep hit on a LIVE example reads as evidence about the DEAD key. Measured on fix(spec): the agent.tools liveness row says dead — it claimed live on a key the schema tombstoned #19059: content/docs/ai/agents.mdx was reported as contradicting the agent.tools tombstone over its tools: example at :161, which is inside the defineSkill({ block opened at :155 — the page was already correct. Settle ownership by PARSING the value against both schemas, never by the name: that literal PASSES SkillSchema, and as an AgentSchema it FAILS at tools with the tombstone prescription. ⛔ These names are not the whole class — a key retired through a .strict() guidance map leaves no tombstone in the walked shape and none of them here (tool.category, live as AIToolDefinition.category).

Coarse fallback — 28 page(s) merely mention a changed package (the pre-#9192 predicate, kept for the deliberately-wide backstop): node scripts/docs-audit/affected-docs.mjs --json 3a0aa915ae0e3838e93beace25bf14d116f3f596 → packageMentionDocs.

Which tree this was computed on

This run read content/docs from 87627839733e4f334395ee48ff06244dc21f9d44 — the merge of head f841c43e2d88f4846028f9c18552e9b4c8c80076 into base 3a0aa915ae0e3838e93beace25bf14d116f3f596, which is what actions/checkout gives a pull_request run. Not the PR head.

A worktree cut from an older main holds a different content/docs, so re-deriving there can legitimately return a different list — that is a different tree, not a wrong row. To answer on the same tree:

# while this PR is open — GitHub drops the merge commit once it closes
git fetch origin 87627839733e4f334395ee48ff06244dc21f9d44 && git checkout 87627839733e4f334395ee48ff06244dc21f9d44
# afterwards, rebuild it from the two parents, which stay fetchable
git fetch origin 3a0aa915ae0e3838e93beace25bf14d116f3f596 f841c43e2d88f4846028f9c18552e9b4c8c80076 && git checkout -B drift-repro 3a0aa915ae0e3838e93beace25bf14d116f3f596 && git merge --no-ff f841c43e2d88f4846028f9c18552e9b4c8c80076

node scripts/docs-audit/affected-docs.mjs --json 3a0aa915ae0e3838e93beace25bf14d116f3f596

⚠️ That checkout carried uncommitted changes, so the commit above does not fully identify what was read.

@objectstack-fleet

Copy link
Copy Markdown
Contributor Author

domain:server#6 · os-project-manager · session_01FEkQ5p3T5YWhLjurajudnQ

席位核对 · ACCEPT · 2026-11-08T06:45Z · head f841c43e2d88f4846028f9c18552e9b4c8c80076

Seat domain:server#6 reviewed the diff of its own dispatch (claim 6717468582 on #31330, card thread session_01FEkQ5pVLKxR5eAhTYetnwR, report 6718182762). Read against GitHub, not the report.

  1. Shape: 5 files, +216 / -15 (the report's line_budget gives the earlier ce565b30 figures; the dev corrected it in the hand-back). The fix is at the producer: dispatchAdmittedBusinessAction's !dispatch.dispatched branch (packages/runtime/src/action-execution.ts) throws Action 'X' on object 'Y' not found with status: 404 and code: standardErrorCodeForHttpStatus(404) (RESOURCE_NOT_FOUND), the routing miss POST /api/v1/actions answers from its own branch. run_action reads it through actionsDoorAnswerOf as before; there is no MCP-side text match, no new import (the helper was already imported) and no new export. Body says Fixes #31330; no other closing keyword.
  2. Premise: red first on base f4b4c8ae in the new mcp-run-action-ghost-routing-miss.test.ts: 3 failed / 3 passed (bridge throw had no code or status; actionsDoorAnswerOf answered VALIDATION_ERROR / 400; the MCP invocation row recorded 500 INTERNAL_ERROR); the REST pin and both CONTROLs green. Ablation red 5, restored. The two moved pins (cli package-install-local-handlers ghost row, now toEqual the exact 404 envelope; runtime mcp-list-actions-handler-probe THE DEFECT and stray-key rows) move as the order said.
  3. Accepted deviations: the sentence is the /actions door's, per the order's rule, so both doors answer the same bytes; the MCP action_invocation row for the miss moves from 500 INTERNAL_ERROR to 404 RESOURCE_NOT_FOUND, equal to the REST row, pinned. No REST answer or REST row moves; resume_run cannot reach the miss.
  4. Gates / check-runs: dev: runtime 556/556 files, cli integration 17/17, typecheck runtime + cli exit 0, scoped eslint exit 0, 67/67 derived gates exit 0 at f841c43e (0 NOT-MEASURED; engine-double-contract and test-source-alias were red on the first loop and fixed in f841c43e). CI on f841c43e: 35 success, 13 skipped, 0 failure. mergeable_state clean, and the head merges cleanly with current main.
  5. Contract review: Clause-②: no (re-declared from measurement: no type, member or export changes; the ghost answer becomes the coded miss /actions already serves), no packages/spec/src path, and check-owed-reviews lists no owed review for this PR: none owed.
  6. Out of scope: past-tense comments naming the old sentence in three files stay as history; not carried. Metadata-protocol: none; Skills-docs: not owed. Changeset patch for @objectstack/runtime. No file overlap with PR fix(mcp): record data faces serve the /data door's declaredCode and userMessage #31405 (mcp: the record data tools and the record resource drop declaredCode, where /data serves an unregistered code's spelling there (VENDOR_DOWN / 503) #31373) or seat 3's runtime: /actions answers a driver string code (SQLITE_BUSY) as 400 VALIDATION_ERROR with declaredCode, where /data answers the same throw 500 DATABASE_ERROR #31317 / runtime: fold HttpDispatcher.errorFromThrown onto the @objectstack/types thrown-answer reader so the two compositions of one answer cannot drift #31319 so far; whichever lands second merges main once.
  7. Landing: check-governed-merges --pr 31408: not governed, 231 changed lines. Landing on the maintainer's standing words 「按照 pm-dispatch 规则复核过的都授权」 (2026-10-25T11:35Z) and 「你应该使用 pm-dispatch 技能审核和落地pr」 (2026-11-07T16:59Z). Relay pr_ready, then automerge_enable.

@objectstack-fleet
objectstack-fleet Bot marked this pull request as ready for review November 8, 2026 06:46
@objectstack-fleet
objectstack-fleet Bot enabled auto-merge November 8, 2026 06:46
@objectstack-fleet
objectstack-fleet Bot added this pull request to the merge queue Nov 8, 2026
Merged via the queue into main with commit 1f029a7 Nov 8, 2026
49 checks passed
@objectstack-fleet
objectstack-fleet Bot deleted the claude/project-thread-oiz4q5 branch November 8, 2026 07:10
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

documentation Improvements or additions to documentation size/m tests tooling Fix lands in tooling, not a product package — enters pm:queue only with Unblocks: or a named surface

Projects

None yet

Development

Successfully merging this pull request may close these issues.

runtime: MCP run_action answers an action with no handler 400 VALIDATION_ERROR, where /actions answers 404 — the bridge throws it uncoded

1 participant