Repository navigation
fix(mcp): record data faces serve the /data door's declaredCode and userMessage - #31405
Conversation
…serMessage The six record data tools, delete_records' selection read and the record resource render the /api/v1/data door's answer for a fault or a code-less throw, but read only its code, sentence and status. The door also serves declaredCode (an unregistered code it demoted to the closed code) and a producer's userMessage. dataDoorAnswerOf now reads both off the door's body, and these faces render them after status, as run_action does. The metadata tools keep their answer. Co-Authored-By: Claude <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01FEkQ5mdwfFCbsFQ62JJ8P5
📓 Docs Drift CheckThis PR changes 1 package(s): 3 hand-written doc(s) NAME something this change touched and may need an implementation-accuracy re-verification:
⛔ 4 release-owned page(s) also name something this change touched. These are read-only:
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 3da98c1e80a88464e01e11c2f8b52c292d1642be && git checkout 3da98c1e80a88464e01e11c2f8b52c292d1642be
# afterwards, rebuild it from the two parents, which stay fetchable
git fetch origin 3a0aa915ae0e3838e93beace25bf14d116f3f596 2fbd1084f5904f145f4effd8e6effb8ddcd0f98b && git checkout -B drift-repro 3a0aa915ae0e3838e93beace25bf14d116f3f596 && git merge --no-ff 2fbd1084f5904f145f4effd8e6effb8ddcd0f98b
node scripts/docs-audit/affected-docs.mjs --json 3a0aa915ae0e3838e93beace25bf14d116f3f596
|
|
domain:server#6 · os-project-manager · session_01FEkQ5p3T5YWhLjurajudnQ 席位核对 · ACCEPT · 2026-11-08T06:44Z · head
|
Requested by Leehom · project thread
Fixes #31373
Clause-②: no
Metadata-protocol: none
维护者速读
delete_records的选择读取和记录资源,在按/api/v1/data门的回答作答时,把门给出的declaredCode和userMessage也一并带上(排在status之后,门没给就不出现),和run_action/resume_run的写法一致。VENDOR_DOWN/ 503)在这些面上只剩封闭码SERVICE_UNAVAILABLE,/data门却还在declaredCode里给出VENDOR_DOWN;生产者标注的userMessage也被丢掉。智能体拿到的比 REST 门少。@objectstack/mcp,patch。两个成员都从门的回答体里读,不另写降级规则。声明了 4xx 以下状态的带码拒绝不走门的回答,逐字节不变;元数据工具和list_actions的回答不变(新增 CONTROL 钉住)。回滚即还原本 PR。packages/mcp/src/mcp-http-tools.ts的dataDoorAnswerOf和metaDoorErrorResult的返回行;mcp-server-runtime.ts记录资源的 catch。pnpm --filter @objectstack/mcp exec vitest run src/mcp-coded-refusal.test.ts -t 31373,预期 14 个用例全部通过。What changes
dataDoorAnswerOf(packages/mcp/src/mcp-http-tools.ts) reads the/api/v1/datadoor's answer (mapDataError). It now also reads the door body'sdeclaredCodeanduserMessage, each only when the door serves a non-empty string. No second demotion rule: the values are the door's.dataDoorErrorResult) anddelete_records' selection read render the door answer as before, so the two members now ride afterstatus:{ error: { code, message, status, declaredCode?, userMessage? } }. That isrun_action/resume_run's rendering (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,errorResultFromThrown): same names, same order, omitted when absent.mcp-server-runtime.ts,bridgeResources) adds them afterstatusin its{ error, code, status }body.metaDoorErrorResult(metadata tools,list_actions) shares the reader, so it now renderscode,messageandstatusexplicitly. Its answer is unchanged, and a new CONTROL pins that.No export added;
dataDoorAnswerOfis not onpackages/mcp/src/index.ts, and the@objectstack/typesimport line is unchanged.Measured on
main(03533d2c): which throws reach the door-answer path with these membersmapDataError(v, 'task')on the built@objectstack/types, and the path the faces take (door answer vs the coded envelope, perdataDoorRefusalEnvelope):/dataanswerVENDOR_DOWN/ 503SERVICE_UNAVAILABLE,declaredCode: VENDOR_DOWNVENDOR_DOWN/ 503,refusal: trueMY_FAULT/ 500INTERNAL_ERROR,declaredCode: MY_FAULTuserMessage(coded 5xx,SQLITE_BUSY, bareError, code-less{ status: 409 }, code-less sandboxed abort)userMessageSERVICE_UNAVAILABLE/ 503,SQLITE_BUSY,VENDOR_DOWNwith no status, bareError, code-less statuses, sandboxed abort or crashdeclaredCodeLEAVE_EXHAUSTED/ 409 (declared below 500)RESOURCE_CONFLICT,declaredCode: LEAVE_EXHAUSTED(out of scope, see below)PERMISSION_DENIED(no status) withuserMessageuserMessage(out of scope, see below)So
declaredCodereaches these faces for an unregistered code with a declared 5xx, anduserMessagefor any door-path throw that carries one. A code-less throw never gets adeclaredCodefrom the door (there is no code to demote).Tests
packages/mcp/src/mcp-coded-refusal.test.ts:VENDOR_DOWN/ 503 row onupdate_recordmoved and became one row per face (7): exactly{ code: 'SERVICE_UNAVAILABLE', message: 'Internal server error', status: 503, declaredCode: 'VENDOR_DOWN' }, key order pinned, equal to the door's answer, the sentence absent, one[5xx] 503 tools/call TOOL vendor_task —operator line with the sentence. The rows read the objectvendor_taskso their line is the firstSERVICE_UNAVAILABLEcapability-absence report on its route (logServerFaultreports that family once per route per process, as at the door).VENDOR_DOWN/ 503 withuserMessageon every face: both members, inrun_action's order, equal to the door's.userMessageon the six tools: the door's500 INTERNAL_ERRORand400 HOOK_ABORTED, each withuserMessage.delete_records' catch keeps its own rendering for a code-less throw (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), so it is not in this row.SERVICE_UNAVAILABLE/ 503 carries nodeclaredCodeand nouserMessageon any face.VENDOR_DOWNbody withdeclaredCode, logged once on a fresh record URI;userMessageafterdeclaredCode, and afterstatuson a code-less fault; CONTROL forSERVICE_UNAVAILABLE/ 503.VENDOR_DOWN/ 503 withuserMessagekeeps{ code: 'SERVICE_UNAVAILABLE', message: 'Internal server error', status: 503 }on all four.RECORD_LOCKED/ 409 and the coded sandboxed refusal on every face and on the resource, 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's byte-for-byte CONTROL.Red first and ablations
Red first on
03533d2c(main), the new pins in place and no fix:mcp-coded-refusal.test.tsgaveTests 11 failed | 154 passed (165): the 7 per-faceVENDOR_DOWNrows, the twouserMessagetool rows, and the two resource rows. Every CONTROL passed. The metadata CONTROL, added after, passes onmainand with the fix (166 passed).Ablations via
node scripts/ablation-replace.mjson the committed head; each printedok mutation landedand thenok restored: blob == HEAD (31cfe9000bac) and git diff HEAD is empty:declaredCodemember deleted fromdataDoorAnswerOf. Blob31cfe9000bac -> 9d6f5ee51eae,Tests 10 failed | 156 passed (166): the 7 per-face rows, the tooluserMessagerow (it asserts both members), and the two resource rows.userMessagemember deleted. Blob31cfe9000bac -> f5974c669fdb,Tests 3 failed | 163 passed (166): the two tooluserMessagerows and the resourceuserMessagerow.metaDoorErrorResultput back tocodedErrorResult(door). Blob31cfe9000bac -> 06f1b65913eb,Tests 1 failed | 165 passed (166): the metadata CONTROL.A first attempt at ablations 1 and 2 used an empty
--replacement, which the tool refused (replacement count moved 0 -> 0) and restored; they were re-run with--delete. The tests import the package's source, so nodist/is involved.Acceptance notes
LEAVE_EXHAUSTED/ 409 answerscode: LEAVE_EXHAUSTEDon these faces where/dataanswersRESOURCE_CONFLICTwithdeclaredCode: LEAVE_EXHAUSTED. A status-less code the door refuses (PERMISSION_DENIED) also renders the envelope, which drops auserMessagethe door serves. Neither is changed, per the order.delete_records' catch renders a code-less throw as its bare message (mcp: the data tools answer an undeclared sandboxed hook abort with no code and the sandbox wrapper text, where /data answers 400 HOOK_ABORTED #31218, 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), so a code-lessuserMessagedoes not reach that face; only its coded door-path throws do./metaserves these members is not measured here.Clause-②: no, re-declared from measurement. No export added or changed. The MCP tool error already declaresdeclaredCodeanduserMessage(codedErrorResult), andrun_actionserves them; these faces now serve them where the door does.mcp-coded-refusal.test.ts; whichever lands second mergesorigin/mainonce.Verification
Base
03533d2c; head2fbd1084.pnpm --filter @objectstack/mcp test(vitest run,--maxWorkers=2):Test Files 60 passed (60),Tests 895 passed (895).pnpm --filter @objectstack/mcp typecheck: exit 0 (check:test-typecheck: 6 files / 53 errors / 8 pinned signatures held).eslint --no-inline-config packages/mcp: exit 0.@objectstack/mcphas nolintscript.Derived gates (node scripts/pm/dispatch-gates.mjs --commands, 65 commands, all on 2fbd108)
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: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:logger-receiver-detach:: exit 0pnpm check:nul-bytes:: exit 0pnpm check:object-def-param-keys:: exit 0pnpm check:objectql-double-limit:: exit 0pnpm check:optional-error-sink:: 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:settings-bind-window:: 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 0pnpm check:lean-entry-closure:: exit 0pnpm check:dual-build-cjs-loads:: exit 0node scripts/pm/dispatch-gates.mjs --ran:65 derived famil(ies) accounted for — 65 run, 0 NOT-MEASURED (a DERIVED zero — all 65 recorded an exit code and none of them is 3). Every command exited 0 on its first run;check:lean-entry-closureandcheck:dual-build-cjs-loadswere run last, aftercheck:type-check-debthad built every package, andcheck-plugin-teardown-shape --self-testaftergit fetch --depth=1of its pinned fixture commit. Each command ran with stdin from/dev/null, exit captured before any pipe.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 package.)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_01FEkQ5mdwfFCbsFQ62JJ8P5