Skip to content

fix(mcp): a coded sandboxed hook crash is a fault on MCP, not a refusal at its declared status - #31290

Merged
objectstack-fleet[bot] merged 1 commit into
mainfrom
claude/project-thread-bkz0jj
Nov 7, 2026
Merged

objectstack-fleet[bot] merged 1 commit into
mainfrom
claude/project-thread-bkz0jj

Conversation

@objectstack-fleet

Copy link
Copy Markdown
Contributor

Requested by Leehom · project thread

Fixes #31269

Clause-②: no
Metadata-protocol: none

维护者速读

  • 改了什么:沙箱 hook 主体在声明了错误码的情况下崩溃(如 TypeError),MCP 不再把它当成业务拒绝(声明的码 + 409 + 带 hook 名的包装文本)。现在它和不带码的同一个崩溃答得一样:六个记录数据工具答 500 INTERNAL_ERROR / Internal server error,并在服务端记一行日志,与 /api/v1/data 一致。
  • 为什么改:REST 各入口先判断"是不是崩溃"(isSandboxCrash),崩溃一律按服务端故障答 500;MCP 只看错误码,于是把 hook 内部名和原生错误文字以业务状态码交给 agent。
  • 风险与回滚:只在 @objectstack/mcp 的 thrownRefusalEnvelope 加一行,直接调用 @objectstack/types 已导出的同一个判断函数;不带崩溃的带码拒绝不变。回滚即删这一行。patch。
  • 先看:packages/mcp/src/mcp-http-tools.ts 的 thrownRefusalEnvelope;packages/mcp/src/mcp-coded-refusal.test.ts 末尾的 mcp: a CODED sandboxed hook CRASH answers the sandbox wrapper (hook name and native error text) at a business status, where /data answers 500 #31269 块。
  • 两分钟验证:pnpm --filter @objectstack/mcp exec vitest run src/mcp-coded-refusal.test.ts -t 31269,预期 15 个用例全部通过。
  • 需要你做的:无,席位落地。

What changes

thrownRefusalEnvelope (packages/mcp/src/mcp-http-tools.ts), the one reader every MCP face uses to tell a coded refusal, now returns undefined when isSandboxCrash(err). isSandboxCrash is the predicate classifyDataError and resolveErrorResponse ask before any code-gated arm. @objectstack/types already exports it (rest's error-response.ts imports it), so no export is added and there is no copy of the crash read in packages/mcp.

A sandboxed body that crashed while declaring a code is therefore no coded refusal, and each face renders it as it renders the same crash with no code. That is the fault answer each face already gives an uncoded crash today, not a new shape. Measured on /mcp over a bridge member throwing the real runner's SandboxError (message hook 'demo_guard' threw: TypeError: boom, innerMessage TypeError: boom, code RECORD_LOCKED, status 409):

Face Before Now (= that face's answer to the same crash with no code) REST door
query_records, aggregate_records, get_record, create_record, update_record, delete_record RECORD_LOCKED · wrapper · 409 INTERNAL_ERROR · Internal server error · 500, one [5xx] 500 tools/call TOOL task — … log line /data: 500 INTERNAL_ERROR Internal server error
delete_records (a row that crashes) fault with code: RECORD_LOCKED, status: 409, the wrapper quoted the uncoded fault answer: no code, no status, the thrown message quoted (kept on purpose, PR #31245 note) n/a
list_objects, describe_object, validate_expression, list_actions, delete_records outer catch RECORD_LOCKED · wrapper · 409 the bare thrown text (today's uncoded rendering) /meta: 500 INTERNAL_ERROR
run_action, resume_run RECORD_LOCKED · wrapper · 409 the bare thrown text (today's uncoded rendering) /actions: 500 INTERNAL_ERROR
record resource { error: wrapper, code: RECORD_LOCKED, status: 409 } { error: wrapper } (today's uncoded rendering) /data: 500 INTERNAL_ERROR

No face serves the declared code or its business status for a crash any more. The record data tools now give the doors' full fault answer. On the other faces, the crash's text is still the face's uncoded rendering, which carries the wrapper. Those renderings are the next cards in this chain, which the order fences out of this PR: #31270 (record resource), #31271 (run_action / resume_run), #31272 (metadata tools and list_actions). When they land, the coded crash follows them, because the pins hold each such face equal to its code-less answer. delete_records' outer catch and its fault quote are kept as intended (PR #31245 and #31268).

Unchanged, measured before and after on the same probe: a coded sandboxed refusal (Locked. 409, #31246), a code-less sandboxed abort, a bare Error, and a driver string code (SQLITE_BUSY, #31273's face) answer byte for byte as before on every face.

Tests

packages/mcp/src/mcp-coded-refusal.test.ts, a new #31269 describe on the shared /mcp harness:

  • each of the six record data tools: { code: 'INTERNAL_ERROR', message: 'Internal server error', status: 500 }, equal to mapDataError's answer to the same throw; the text carries no hook name and no TypeError; one [5xx] 500 tools/call TOOL task — log line;
  • every other tool (the SITES table, which is held equal to the registered tool list): the coded crash's answer equals the same crash's answer with no code, and RECORD_LOCKED / 409 are absent;
  • CONTROL: a coded sandboxed refusal keeps { code: 'RECORD_LOCKED', message: 'Locked.', status: 409 } on every tool.

In the record-resource describe: the coded crash answers byte for byte what the same crash with no code answers, and RECORD_LOCKED is absent. packages/mcp/src/mcp-delete-records.test.ts: a row that crashes with a declared code stops the call as a fault with no code and no status, and the whole answer equals the one for the same crash with no code.

Red first and ablation

Red first on b3bd75d8 (main, with PR #31268), new pins and no fix: Tests 15 failed | 107 passed (122) across the two files. The CONTROL passed. The real runner probe (QuickJSScriptRunner, hook body throw Object.assign(new TypeError('boom'), { code: 'RECORD_LOCKED', status: 409 })) gave message hook 'demo_guard' threw: TypeError: boom, innerMessage TypeError: boom, code RECORD_LOCKED, status 409. mapDataError answered 500 INTERNAL_ERROR Internal server error, while every MCP tool and the record resource answered RECORD_LOCKED / wrapper / 409. With the fix: Tests 122 passed (122).

Ablation (node scripts/ablation-replace.mjs, mcp-http-tools.ts): if (isSandboxCrash(err)) return undefined; replaced by if (isSandboxCrash(err) && String("ABL").length < 0) return undefined;. Output: ok mutation landed: anchor 1 -> 0, blob eca0c12b6dd3 -> c7b949836b5f, then Tests 15 failed | 107 passed (122), then ok restored: blob == HEAD (eca0c12b6dd3) and git diff HEAD is empty. The tests import the package's source, so no dist/ is involved.

Acceptance notes

Verification

Base: b3bd75d8; head: f7517feb.

  • pnpm --filter @objectstack/mcp test: Test Files 60 passed (60), Tests 822 passed (822), lock VERDICT command-exit 0.
  • pnpm --filter @objectstack/mcp typecheck: exit 0 (check:test-typecheck: 53 errors / 8 pinned signatures held).
  • pnpm exec eslint --no-inline-config on the three touched .ts files: exit 0 (@objectstack/mcp has no lint script).
Derived gates (node scripts/pm/dispatch-gates.mjs --commands, 62 commands, all on f7517fe)
  • node scripts/check-adr-0087-registration.mjs --base origin/main :: exit 0
  • node scripts/check-adr-0087-registration.mjs --self-test :: exit 0
  • node scripts/check-changeset-no-major.mjs --base origin/main :: exit 0
  • node scripts/check-closing-keyword-parity.mjs :: exit 0
  • node scripts/check-closing-keyword-parity.mjs --self-test :: exit 0
  • node scripts/check-comment-mask-adoption.mjs :: exit 0
  • node scripts/check-comment-mask-adoption.mjs --self-test :: exit 0
  • node scripts/check-comment-mask-corpus.mjs :: exit 0
  • node scripts/check-dts-emitted.mjs --self-test :: exit 0
  • node scripts/check-empty-changeset.mjs --base origin/main :: exit 0
  • node scripts/check-empty-changeset.mjs --self-test :: exit 0
  • node scripts/check-issue-citations.mjs :: exit 0
  • node scripts/check-plugin-teardown-shape.mjs :: exit 0
  • node scripts/check-plugin-teardown-shape.mjs --self-test :: exit 0
  • node scripts/ci/assert-turbo-remote-cache.mjs --self-test :: exit 0
  • node scripts/ci/plan-test-core-shards.mjs --self-test :: exit 0
  • node scripts/ci/prune-turbo-cache.mjs --self-test :: exit 0
  • node scripts/ci/snapshot-next.mjs --self-test :: exit 0
  • node scripts/docs-audit/check-affected-docs.mjs :: exit 0
  • node scripts/docs-audit/check-drift-comment.mjs :: exit 0
  • node scripts/pm/release-rehearsal-clone.mjs --self-test :: exit 0
  • node scripts/release-pending-publish.mjs --self-test :: exit 0
  • pnpm --filter @objectstack/spec run check:duration-unit-keys :: exit 0
  • pnpm --filter @objectstack/spec run check:error-code-provenance :: exit 0
  • pnpm check:adr-symbol-anchors :: exit 0
  • pnpm check:changeset-gate-self-tests :: exit 0
  • pnpm check:ci-filter-parity :: exit 0
  • pnpm check:closed-ceremony-text :: exit 0
  • pnpm check:cross-package-test-inputs :: exit 0
  • pnpm check:dispatcher-error-vocabulary :: exit 0
  • pnpm check:doc-authoring :: exit 0
  • pnpm check:driver-memory-census :: exit 0
  • pnpm check:dts-closure :: exit 0
  • pnpm check:dual-build-cjs-loads :: exit 0
  • pnpm check:engine-double-contract :: exit 0
  • pnpm check:error-status-conformance :: exit 0
  • pnpm check:gitlink-declared :: exit 0
  • pnpm check:issue-citations :: exit 0
  • pnpm check:keyed-text-bounds :: exit 0
  • pnpm check:lean-entry-closure :: exit 0
  • pnpm check:logger-receiver-detach :: exit 0
  • pnpm check:nul-bytes :: exit 0
  • pnpm check:objectql-double-limit :: exit 0
  • pnpm check:org-identifier :: exit 0
  • pnpm check:page-declaration-shape :: exit 0
  • pnpm check:platform-object-tenancy-census :: exit 0
  • pnpm check:published-files :: exit 0
  • pnpm check:query-options-erasure :: exit 0
  • pnpm check:refd-timer-probe :: exit 0
  • pnpm check:registry-log-declared :: exit 0
  • pnpm check:rest-log-spy-declared :: exit 0
  • pnpm check:slot-lookup :: exit 0
  • pnpm check:sourcemap-no-sources-content :: exit 0
  • pnpm check:system-context-census :: exit 0
  • pnpm check:test-source-alias :: exit 0
  • pnpm check:tier-file-adoption :: exit 0
  • pnpm check:type-check-coverage :: exit 0
  • pnpm check:type-check-debt :: exit 0
  • pnpm check:undeclared-dep-imports :: exit 0
  • pnpm check:vouch-for-reference-callers :: exit 0
  • pnpm check:watch-hint-literal :: exit 0
  • pnpm check:where-matcher :: exit 0

node scripts/pm/dispatch-gates.mjs --ran: 62 derived famil(ies) accounted for — 62 run, 0 NOT-MEASURED. check:dual-build-cjs-loads first exited 3 (PREREQUISITE NOT MET: not every package had a dist). It exited 0 when re-run after check:type-check-debt had built every package.

Not run locally (CI's): test:repo, the dogfood shards, the type-check lanes.

Human Minimum

  • 1. Schemas start as Zod; packages/spec holds no runtime logic. (Not touched.)
  • 2. Every name I added uses the casing for its kind.
  • 3. No formatter ran; pnpm lint passes. (eslint on the touched files.)
  • 4. One issue, one branch off an up-to-date main, one pull request.
  • 5. A change that publishes carries a changeset, and both declaration lines are filled in here and in the changeset.
  • 6. packages/spec touched: its generated artifacts are regenerated and committed. (Not touched.)
  • 7. No hand edits to content/docs/references/, packages/*/CHANGELOG.md or content/docs/releases/.
  • 8. Title, body and comments are in English.

🤖 Generated with Claude Code

https://claude.ai/code/session_01FEkQ5oWCPWH6i2Lsts9cdP

…clared status

thrownRefusalEnvelope asks isSandboxCrash (@objectstack/types), the predicate
the REST doors ask first, and declines a crash, so each MCP face renders a
crash that declared a code as it renders the same crash with no code: the
record data tools answer the /data door's 500 INTERNAL_ERROR, logged once.

Co-Authored-By: Claude <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01FEkQ5oWCPWH6i2Lsts9cdP
@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 7, 2026
@github-actions

github-actions Bot commented Nov 7, 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 63 of 226 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 — 12 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 b3bd75d813ad57b9829b5ff63e84cb2524570fc7 → packageMentionDocs.

Which tree this was computed on

This run read content/docs from 2d98e30ac7070d9db2b61bc22c52b3d5a40b2b75 — the merge of head f7517febcedd135a8216f9ff91780b8658865594 into base b3bd75d813ad57b9829b5ff63e84cb2524570fc7, 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 2d98e30ac7070d9db2b61bc22c52b3d5a40b2b75 && git checkout 2d98e30ac7070d9db2b61bc22c52b3d5a40b2b75
# afterwards, rebuild it from the two parents, which stay fetchable
git fetch origin b3bd75d813ad57b9829b5ff63e84cb2524570fc7 f7517febcedd135a8216f9ff91780b8658865594 && git checkout -B drift-repro b3bd75d813ad57b9829b5ff63e84cb2524570fc7 && git merge --no-ff f7517febcedd135a8216f9ff91780b8658865594

node scripts/docs-audit/affected-docs.mjs --json b3bd75d813ad57b9829b5ff63e84cb2524570fc7

⚠️ 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-07T23:10Z · head f7517febcedd135a8216f9ff91780b8658865594

Seat domain:server#6 reviewed the diff of its own dispatch (claim on #31269, card thread session_01FEkQ5oWCPWH6i2Lsts9cdP, report 6714087551). Read against GitHub, not the report.

  1. Shape: 4 files, +127 / -1. thrownRefusalEnvelope (packages/mcp/src/mcp-http-tools.ts) now answers undefined when isSandboxCrash(err), the predicate the REST doors ask first in classifyDataError, imported from @objectstack/types, which already exports it (data-error-classification.ts export block, the import rest uses): no copy, no new export. A sandboxed body that crashed while declaring a code is rendered on every MCP face exactly as the same crash with no code: the six record data tools answer the /data door's 500 INTERNAL_ERROR 'Internal server error' with one server-side fault line; delete_records rows answer the uncoded fault. A coded sandbox refusal keeps the mcp: a CODED sandboxed hook refusal still answers the sandbox wrapper text with the hook's name, where /data answers the body's sentence — and the other MCP tools still render a throw unlike REST #31246 answer (CONTROL). mcp-server-runtime.ts untouched. Body says Fixes #31269; no other closing keyword.
  2. Premise: red first on main b3bd75d8 (after PR fix(mcp): a coded sandboxed hook refusal answers the body's sentence, not the wrapper naming the hook #31268): 15 failed with the new pins and no fix (6 data tools, 7 other tools, record resource, delete_records row), 122 passed with it; one ablation of the crash read turned the same 15 red, restored.
  3. Gates / check-runs: 48 runs on f7517feb, 35 success, 13 skipped, 0 red. mergeable_state clean; the head merges cleanly with main c0f88b9a. Dev: mcp 60/60 files (822 tests), typecheck exit 0, eslint on the 3 touched files exit 0, 62/62 derived gates exit 0, --ran clean.
  4. Contract review: Clause-②: no (no type, member or export changes; a crash on MCP now gets the fault answer the doors already give and the record data tools already give an uncoded crash), no packages/spec/src path: none owed.
  5. Deviation, accepted: on the record resource, run_action / resume_run, the metadata tools and list_actions, the declared code and business status are gone, but the text is each face's code-less rendering, which still carries the runner's wrapper. Those faces are mcp: the record resource answers a code-less sandboxed hook abort with the wrapper naming the hook, where GET /data answers 400 HOOK_ABORTED with the sentence #31270, 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 and mcp: the metadata tools and list_actions answer a fault with its raw text (or a driver code), where the /meta door answers 500 INTERNAL_ERROR #31272, next in this lane; their orders add a crash case (with and without a code), and these pins hold each face equal to its code-less answer, so the wrapper goes when they land. Metadata-protocol: none; Skills-docs: not owed. Nothing filed.
  6. Landing: check-governed-merges --pr 31290: not governed, 128 changed lines. Changeset patch for @objectstack/mcp. 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.

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.

mcp: a CODED sandboxed hook CRASH answers the sandbox wrapper (hook name and native error text) at a business status, where /data answers 500

1 participant