Repository navigation
fix(mcp): record data faces withhold a declared 5xx's sentence as /data does - #31371
Conversation
…ta does The six record data tools, delete_records' selection read and the record resource read the coded path first, so a throw declaring a 5xx (for example SERVICE_UNAVAILABLE / 503) reached the agent with the producer's own sentence, where /api/v1/data keeps the code and status and withholds the sentence unless the throw marks itself refusal: true. dataDoorRefusalEnvelope now asks the door's own reader for every throw whose status is a 5xx or undeclared, not only for the undeclared one; a declared refusal status below 500 keeps its coded answer. Co-Authored-By: Claude <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01FEkQ5mdwfFCbsFQ62JJ8P5
📓 Docs Drift CheckThis PR changes 1 package(s): 12 hand-written doc(s) NAME something this change touched and may need an implementation-accuracy re-verification:
⛔ 5 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 7d2701711ef3898d878866061f13978eeecea9b1 && git checkout 7d2701711ef3898d878866061f13978eeecea9b1
# afterwards, rebuild it from the two parents, which stay fetchable
git fetch origin da7fce5903a6d0237eb1b3c3ba675c228a13ea6d 5c91f46fb809d59bbc6a984986a07e5f4dbcc84a && git checkout -B drift-repro da7fce5903a6d0237eb1b3c3ba675c228a13ea6d && git merge --no-ff 5c91f46fb809d59bbc6a984986a07e5f4dbcc84a
node scripts/docs-audit/affected-docs.mjs --json da7fce5903a6d0237eb1b3c3ba675c228a13ea6d
|
|
domain:server#6 · os-project-manager · session_01FEkQ5p3T5YWhLjurajudnQ 席位核对 · ACCEPT · 2026-11-08T05:08Z · head
|
Requested by Leehom · project thread
Fixes #31341
Clause-②: no
Metadata-protocol: none
维护者速读
query_records、aggregate_records、get_record、create_record、update_record、delete_record)、delete_records的选择读取和记录资源,遇到声明了 5xx 状态码的带码异常(例如SERVICE_UNAVAILABLE/ 503)时,改按/api/v1/data的回答作答:码和状态码保留,生产者原句隐去成Internal server error,除非异常自己标了refusal: true;原句只在服务端记一次日志。/data门对同一异常会隐去原句。@objectstack/mcp一处判定(dataDoorRefusalEnvelope里一个条件),patch。声明了 4xx 的拒绝照旧逐字节不变(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 的 CONTROL 钉着);未注册的码配 5xx 会像门一样落成该状态的封闭码(门把原码放在declaredCode,MCP 各面都不发这个成员)。回滚即还原本 PR。packages/mcp/src/mcp-http-tools.ts的dataDoorRefusalEnvelope;packages/mcp/src/mcp-coded-refusal.test.ts里两个 mcp: the record data tools and the record resource serve a declared 5xx refusal's own sentence, where /data withholds it ('Internal server error') #31341 块。pnpm --filter @objectstack/mcp exec vitest run src/mcp-coded-refusal.test.ts -t 31341,预期 11 个用例全部通过。What changes
dataDoorRefusalEnvelope(packages/mcp/src/mcp-http-tools.ts, #31273) decides whether a coded throw on a/dataface renders as a coded refusal or as the door's fault answer. It used to ask the door only when the throw declared no status (serverFaultProvenance'undeclared'). It now asks the door for every throw whose status is a 5xx or undeclared (serverFaultProvenanceanswers'declared'or'undeclared'), and keeps the coded answer only for a declared refusal status below 500 (serverFaultProvenanceanswersundefined). The predicate change is one token:!== 'undeclared'became=== undefined.When the door (
mapDataError, read throughdataDoorAnswerOf) answers a 5xx, the face renders the door'scode, sentence andstatusand logs the thrown text once throughlogServerFault, the path #31273 already built. No copy of the withhold rule:mapDataErrorappliesdeclaredRefusalMessageitself. No new export from@objectstack/types; every reader was already imported.All eight faces already read this one function (the six tools through
dataDoorErrorResult,delete_records' outer catch, the record resource catch inmcp-server-runtime.ts). Only comments change inmcp-server-runtime.ts./api/v1/data(mapDataError)SERVICE_UNAVAILABLE/ 503,'The ledger is closing.'SERVICE_UNAVAILABLE, 503,Internal server error; the sentence logged oncerefusal: true503 SERVICE_UNAVAILABLE, the sentenceVENDOR_DOWN/ 503VENDOR_DOWN, 503, the sentenceSERVICE_UNAVAILABLE, 503,Internal server errordeclaredCode: VENDOR_DOWNRECORD_LOCKED/ 409409 RECORD_LOCKEDRECORD_LOCKED/ 409)409 RECORD_LOCKEDPERMISSION_DENIED, no status{ code, message }403 PERMISSION_DENIEDSQLITE_BUSY, no status (#31273)500 DATABASE_ERROROn the resource, the same answers use its
{ error, code, status }members.Tests
packages/mcp/src/mcp-coded-refusal.test.ts:delete_records): exactly{ code: 'SERVICE_UNAVAILABLE', message: 'Internal server error', status: 503 }, equal tomapDataError's answer, the sentence absent from the text, and exactly one[5xx] 503 tools/call TOOL task —operator line (onconsole.errororconsole.warn) carrying the sentence;refusal: trueon every face: the sentence kept, equal to the door's answer;VENDOR_DOWN/ 503 row: the door's closed code, sentence withheld.{"error":"Internal server error","code":"SERVICE_UNAVAILABLE","status":503}, equal to the door's, one[5xx] 503 resources/read objectstack://objects/task/records/t1 —line with the sentence; therefusal: truebody keeps the sentence. mcp: the record data tools answer a driver string code (SQLITE_BUSY) with the driver's text and no status, where /data answers 500 DATABASE_ERROR #31273's resource CONTROL kept only its status-lessPERMISSION_DENIEDhalf; the declared-503 half moved here.RECORD_LOCKED/ 409 and the coded sandboxed refusal on every face (mcp: the record data tools answer a driver string code (SQLITE_BUSY) with the driver's text and no status, where /data answers 500 DATABASE_ERROR #31273 block) and on the resource (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 block),PERMISSION_DENIEDwith no status, and 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 "a coded non-sandbox refusal renders its own message byte for byte".The operator line is read from
console.errorandconsole.warntogether becauselogServerFaultreports a declaredSERVICE_UNAVAILABLEas a capability absence: onewarnper route per process, as at the door.Red first and ablations
Red first on
d0512c2f(main), the new pins in place and no fix:mcp-coded-refusal.test.tsgaveTests 9 failed | 127 passed (136). The failures: the resource declared-503 row, the seven per-face declared-503 rows and the unregistered-code row. The tworefusal: truerows passed on base, as expected (they pin the sentence kept). With the fix:136 passed.Ablations, each via
node scripts/ablation-replace.mjson the committed head5c91f46f; each printedok mutation landedand thenok restored: blob == HEAD (ebb31a2794c5) and git diff HEAD is empty:!== 'undeclared'(the mcp: the record data tools answer a driver string code (SQLITE_BUSY) with the driver's text and no status, where /data answers 500 DATABASE_ERROR #31273 line). Blobebb31a2794c5 -> c9344e7ebdf1,Tests 9 failed | 127 passed (136): the same nine rows as red first.ebb31a2794c5 -> c5b7abf4be16,Tests 1 failed | 135 passed (136): 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 CONTROL "a coded non-sandbox refusal renders its own message byte for byte". Its third throw (aSandboxErrorwith an emptyinnerMessagedeclaringRECORD_LOCKED/ 409) is answered500 INTERNAL_ERRORby the door, so the guard is what keeps a declared 4xx out of this card.The tests import the package's source, so no
dist/is involved.Acceptance notes
mapDataError(v, 'task')on the built@objectstack/types): declaredSERVICE_UNAVAILABLE/ 503 answers503 { error: 'Internal server error', code: 'SERVICE_UNAVAILABLE' }; withrefusal: true, the sentence; unregisteredVENDOR_DOWN/ 503 answersSERVICE_UNAVAILABLEplusdeclaredCode: 'VENDOR_DOWN'; declaredINTERNAL_ERROR/ 500 answersInternal server error.declaredCode, which no MCP data or metadata face serves (dataDoorAnswerOfreadscode,errorand status only, as 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's metadata faces do). Today that spelling reached the agent ascode. ServingdeclaredCodehere would add a member to these faces' tool error; it is not done. A producer keeps its own code on the wire by registering it.SandboxErrorwith an emptyinnerMessage, which the door reads as the sandbox's own fault). That is a 4xx declaration, outside this card's 5xx scope; 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 CONTROL keeps pinning the current answer.Clause-②: no, re-declared from measurement. No export added or changed:dataDoorRefusalEnvelopeis not onpackages/mcp/src/index.ts, and the import line of@objectstack/typesnames the same symbols. The tool error keeps its keys (code,message,status); only the values for a declared 5xx move to the door's.run_action/resume_run(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, PR fix(mcp): run_action and resume_run answer a throw through the /actions door's one reader #31315) and the metadata tools andlist_actions(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). They never calldataDoorRefusalEnvelope;thrownRefusalEnvelope,errorResultFromThrownandmetaDoorErrorResultare byte-identical. PR fix(mcp): run_action and resume_run answer a throw through the /actions door's one reader #31315 is still open on the same two files; whichever lands second mergesorigin/mainonce.Verification
Base
d0512c2f; head5c91f46f.pnpm --filter @objectstack/mcp test(vitest run,--maxWorkers=2):Test Files 60 passed (60),Tests 865 passed (865).pnpm --filter @objectstack/mcp typecheck: exit 0 (check:test-typecheck: 6 files / 53 errors / 8 pinned signatures held).eslint --no-inline-configon the three touched.tsfiles: exit 0.@objectstack/mcphas nolintscript.Derived gates (node scripts/pm/dispatch-gates.mjs --commands, 65 commands, all on 5c91f46)
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:lean-entry-closure:: 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: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).check:lean-entry-closurefirst exited 3 (PREREQUISITE NOT MET:@objectstack/objectqldist missing) and exited 0 when re-run aftercheck:type-check-debthad built every package;check:dual-build-cjs-loadswas run last for the same reason and exited 0.check-plugin-teardown-shape --self-testran aftergit fetch --depth=1of its pinned fixture commit. Each command ran with stdin from/dev/null, exit captured before any pipe.eslint --no-inline-config packages/mcp: exit 0.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_01FEkQ5mdwfFCbsFQ62JJ8P5