Repository navigation
fix(mcp): a coded sandboxed hook crash is a fault on MCP, not a refusal at its declared status - #31290
Conversation
…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
📓 Docs Drift Check1 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
Coarse fallback — 12 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 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 |
|
domain:server#6 · os-project-manager · session_01FEkQ5p3T5YWhLjurajudnQ 席位核对 · ACCEPT · 2026-11-07T23:10Z · head
|
Requested by Leehom · project thread
Fixes #31269
Clause-②: no
Metadata-protocol: none
维护者速读
TypeError),MCP 不再把它当成业务拒绝(声明的码 + 409 + 带 hook 名的包装文本)。现在它和不带码的同一个崩溃答得一样:六个记录数据工具答500 INTERNAL_ERROR/Internal server error,并在服务端记一行日志,与/api/v1/data一致。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 returnsundefinedwhenisSandboxCrash(err).isSandboxCrashis the predicateclassifyDataErrorandresolveErrorResponseask before any code-gated arm.@objectstack/typesalready exports it (rest'serror-response.tsimports it), so no export is added and there is no copy of the crash read inpackages/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
/mcpover a bridge member throwing the real runner'sSandboxError(messagehook 'demo_guard' threw: TypeError: boom,innerMessageTypeError: boom,codeRECORD_LOCKED,status409):query_records,aggregate_records,get_record,create_record,update_record,delete_recordRECORD_LOCKED· wrapper · 409INTERNAL_ERROR·Internal server error· 500, one[5xx] 500 tools/call TOOL task — …log line/data:500 INTERNAL_ERRORInternal server errordelete_records(a row that crashes)code: RECORD_LOCKED,status: 409, the wrapper quotedlist_objects,describe_object,validate_expression,list_actions,delete_recordsouter catchRECORD_LOCKED· wrapper · 409/meta:500 INTERNAL_ERRORrun_action,resume_runRECORD_LOCKED· wrapper · 409/actions:500 INTERNAL_ERROR{ error: wrapper, code: RECORD_LOCKED, status: 409 }{ error: wrapper }(today's uncoded rendering)/data:500 INTERNAL_ERRORNo 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 andlist_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 bareError, 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#31269describe on the shared/mcpharness:{ code: 'INTERNAL_ERROR', message: 'Internal server error', status: 500 }, equal tomapDataError's answer to the same throw; the text carries no hook name and noTypeError; one[5xx] 500 tools/call TOOL task —log line;SITEStable, which is held equal to the registered tool list): the coded crash's answer equals the same crash's answer with no code, andRECORD_LOCKED/409are absent;{ 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_LOCKEDis 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 bodythrow Object.assign(new TypeError('boom'), { code: 'RECORD_LOCKED', status: 409 })) gavemessagehook 'demo_guard' threw: TypeError: boom,innerMessageTypeError: boom,codeRECORD_LOCKED,status409.mapDataErroranswered500 INTERNAL_ERRORInternal server error, while every MCP tool and the record resource answeredRECORD_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 byif (isSandboxCrash(err) && String("ABL").length < 0) return undefined;. Output:ok mutation landed: anchor 1 -> 0, blob eca0c12b6dd3 -> c7b949836b5f, thenTests 15 failed | 107 passed (122), thenok restored: blob == HEAD (eca0c12b6dd3) and git diff HEAD is empty. The tests import the package's source, so nodist/is involved.Acceptance notes
Clause-②: no: no export is added (isSandboxCrashwas already on@objectstack/types' entry), and no published type changes. The answer that moves is a crash's text and status on MCP, which become the fault answer each face already gives.run_action/resume_run, and the metadata tools andlist_actions, through their code-less renderings. Their carriers 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, as the order rules.Verification
Base:
b3bd75d8; head:f7517feb.pnpm --filter @objectstack/mcp test:Test Files 60 passed (60),Tests 822 passed (822), lockVERDICT command-exit 0.pnpm --filter @objectstack/mcp typecheck: exit 0 (check:test-typecheck: 53 errors / 8 pinned signatures held).pnpm exec eslint --no-inline-configon the three touched.tsfiles: exit 0 (@objectstack/mcphas nolintscript).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 0node scripts/check-adr-0087-registration.mjs --self-test:: exit 0node scripts/check-changeset-no-major.mjs --base origin/main:: exit 0node scripts/check-closing-keyword-parity.mjs:: exit 0node scripts/check-closing-keyword-parity.mjs --self-test:: exit 0node scripts/check-comment-mask-adoption.mjs:: exit 0node scripts/check-comment-mask-adoption.mjs --self-test:: exit 0node scripts/check-comment-mask-corpus.mjs:: exit 0node scripts/check-dts-emitted.mjs --self-test:: exit 0node scripts/check-empty-changeset.mjs --base origin/main:: exit 0node scripts/check-empty-changeset.mjs --self-test:: exit 0node scripts/check-issue-citations.mjs:: exit 0node scripts/check-plugin-teardown-shape.mjs:: exit 0node scripts/check-plugin-teardown-shape.mjs --self-test:: exit 0node scripts/ci/assert-turbo-remote-cache.mjs --self-test:: exit 0node scripts/ci/plan-test-core-shards.mjs --self-test:: exit 0node scripts/ci/prune-turbo-cache.mjs --self-test:: exit 0node scripts/ci/snapshot-next.mjs --self-test:: exit 0node scripts/docs-audit/check-affected-docs.mjs:: exit 0node scripts/docs-audit/check-drift-comment.mjs:: exit 0node scripts/pm/release-rehearsal-clone.mjs --self-test:: exit 0node scripts/release-pending-publish.mjs --self-test:: exit 0pnpm --filter @objectstack/spec run check:duration-unit-keys:: exit 0pnpm --filter @objectstack/spec run check:error-code-provenance:: exit 0pnpm check:adr-symbol-anchors:: exit 0pnpm check:changeset-gate-self-tests:: exit 0pnpm check:ci-filter-parity:: exit 0pnpm check:closed-ceremony-text:: exit 0pnpm check:cross-package-test-inputs:: exit 0pnpm check:dispatcher-error-vocabulary:: exit 0pnpm check:doc-authoring:: exit 0pnpm check:driver-memory-census:: exit 0pnpm check:dts-closure:: exit 0pnpm check:dual-build-cjs-loads:: exit 0pnpm check:engine-double-contract:: exit 0pnpm check:error-status-conformance:: exit 0pnpm check:gitlink-declared:: exit 0pnpm check:issue-citations:: exit 0pnpm check:keyed-text-bounds:: exit 0pnpm check:lean-entry-closure:: exit 0pnpm check:logger-receiver-detach:: exit 0pnpm check:nul-bytes:: exit 0pnpm check:objectql-double-limit:: exit 0pnpm check:org-identifier:: exit 0pnpm check:page-declaration-shape:: exit 0pnpm check:platform-object-tenancy-census:: exit 0pnpm check:published-files:: exit 0pnpm check:query-options-erasure:: exit 0pnpm check:refd-timer-probe:: exit 0pnpm check:registry-log-declared:: exit 0pnpm check:rest-log-spy-declared:: exit 0pnpm check:slot-lookup:: exit 0pnpm check:sourcemap-no-sources-content:: exit 0pnpm check:system-context-census:: exit 0pnpm check:test-source-alias:: exit 0pnpm check:tier-file-adoption:: exit 0pnpm check:type-check-coverage:: exit 0pnpm check:type-check-debt:: exit 0pnpm check:undeclared-dep-imports:: exit 0pnpm check:vouch-for-reference-callers:: exit 0pnpm check:watch-hint-literal:: exit 0pnpm check:where-matcher:: exit 0node scripts/pm/dispatch-gates.mjs --ran:62 derived famil(ies) accounted for — 62 run, 0 NOT-MEASURED.check:dual-build-cjs-loadsfirst exited 3 (PREREQUISITE NOT MET: not every package had a dist). It exited 0 when re-run aftercheck:type-check-debthad built every package.Not run locally (CI's):
test:repo, the dogfood shards, the type-check lanes.Human Minimum
packages/specholds no runtime logic. (Not touched.)pnpm lintpasses. (eslint on the touched files.)main, one pull request.packages/spectouched: its generated artifacts are regenerated and committed. (Not touched.)content/docs/references/,packages/*/CHANGELOG.mdorcontent/docs/releases/.🤖 Generated with Claude Code
https://claude.ai/code/session_01FEkQ5oWCPWH6i2Lsts9cdP