Repository navigation
fix(mcp): record data faces serve the /data door's members beside a coded refusal - #31431
Conversation
…oded refusal A coded refusal on the record data faces kept the thrown envelope, so an app's own unregistered code with a declared 4xx reached the agent outside the registered vocabulary and a producer's userMessage was dropped, where /api/v1/data answers the closed code with declaredCode and serves the userMessage. The envelope is now read against the door's answer: a code the door demoted answers the door's refusal, and the door's userMessage joins any other coded refusal. delete_records' selection read routes every coded throw through the same renderer; its code-less rendering is unchanged. Co-Authored-By: Claude <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01FEkQ5mdwfFCbsFQ62JJ8P5
…r read 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 06b611ec4187e4cccbb9fdb444e5e89ba2dae171 && git checkout 06b611ec4187e4cccbb9fdb444e5e89ba2dae171
# afterwards, rebuild it from the two parents, which stay fetchable
git fetch origin 0e13561b4a99082c0ce4344e52050625a822d41f d6d1ff92bd73f5ee107d32bf3ea5e69524b22bac && git checkout -B drift-repro 0e13561b4a99082c0ce4344e52050625a822d41f && git merge --no-ff d6d1ff92bd73f5ee107d32bf3ea5e69524b22bac
node scripts/docs-audit/affected-docs.mjs --json 0e13561b4a99082c0ce4344e52050625a822d41f
|
|
domain:server#6 · os-project-manager · session_01FEkQ5p3T5YWhLjurajudnQ 席位核对 · ACCEPT · 2026-11-08T08:08Z · head
|
Requested by Leehom · project thread
Fixes #31407
Clause-②: no
Metadata-protocol: none
维护者速读
delete_records的选择读取和记录资源,在回答"拒绝"类带码异常(门答 4xx)时,对照/api/v1/data门的回答补齐两样东西:应用自己未注册的码(如LEAVE_EXHAUSTED/ 409)改答门的封闭码RESOURCE_CONFLICT加declaredCode: 'LEAVE_EXHAUSTED',原句和状态码保留;生产者写的userMessage不再被丢掉。userMessage;/data和run_action都已经这样回答。@objectstack/mcp,patch。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 钉住的回答逐字节不变(注册码RECORD_LOCKED/ 409、沙箱带码拒绝、唯一约束的UNIQUE_VIOLATION拼写);没有status的拒绝码仍旧没有status。delete_records外层 catch 只改了带码那一支的去向,无码异常的裸消息不变。回滚即还原本 PR。packages/mcp/src/mcp-http-tools.ts的refusalAsTheDoorServesIt和dataDoorRefusalEnvelope;delete_records外层 catch 的条件;mcp-server-runtime.ts记录资源 catch。pnpm --filter @objectstack/mcp exec vitest run src/mcp-coded-refusal.test.ts -t 31407,预期 12 个用例全部通过。What changes
dataDoorRefusalEnvelope(packages/mcp/src/mcp-http-tools.ts) still returns the coded envelope for a refusal andundefinedfor a door fault, decided exactly as before. The envelope it returns is now read against the door's answer to the same throw (dataDoorAnswerOf,mapDataError) by a new module-privaterefusalAsTheDoorServesIt:declaredCode), the face answers the door's refusal: closed code, sentence, status,declaredCode, anduserMessagewhen served.userMessagejoins it when the door serves one.Whether a code is demoted is the door's
declaredCode; there is no vocabulary check here. Members render inrun_action's order (#31271) and #31373's:code,message,status,declaredCode,userMessage, each omitted when absent. The return type is a module-localDataDoorRefusalEnvelope(ThrownRefusalEnvelopeplus the two optional members); neither is onpackages/mcp/src/index.ts.Faces:
dataDoorErrorResult, unchanged.mcp-server-runtime.ts) adds the two members afterstatusin its{ error, code, status }body.delete_records' outer catch sent a coded throw todataDoorErrorResultonly when the door answered a fault; it now sends every coded throw there, so its selection read gets the same members. Its code-less rendering (the 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) is untouched.Measured on
main(e6a0b72a): coded envelope-path throws, today's envelope vs the doorProbe (not committed):
dataDoorRefusalEnvelopeanddataDoorAnswerOfon 19 throws./data)LEAVE_EXHAUSTED/ 409LEAVE_EXHAUSTED, 409RESOURCE_CONFLICT, 409,declaredCodeLEAVE_EXHAUSTED/ 422LEAVE_EXHAUSTED, 422VALIDATION_ERROR, 422,declaredCodeLEAVE_EXHAUSTED,statusCode: 409LEAVE_EXHAUSTED, no statusRESOURCE_CONFLICT, 409,declaredCodeLEAVE_EXHAUSTED/ 409LEAVE_EXHAUSTED, inner sentence, 409RESOURCE_CONFLICT, inner sentence, 409,declaredCodeuserMessageuserMessagePERMISSION_DENIED, no status, +userMessage{ code, message }userMessageuserMessageRECORD_LOCKED/ 409 +userMessageuserMessagePERMISSION_DENIED, no status{ code, message }UNIQUE_VIOLATION, no status{ code, 'dup' }DuplicateRecordErrorUNIQUE_VIOLATION, engine sentence, 409RECORD_LOCKED/ 409 with emptyinnerMessageRECORD_LOCKED, wrapper, 409INTERNAL_ERRORRECORD_LOCKED/ 409, sandboxedRECORD_LOCKED/ 409,MFA_REQUIRED/ 403,RECORD_NOT_FOUND/ 404,PERMISSION_DENIED/ 403,INVALID_FIELD/ 400Only the rows the order names move (a demoted code, and a
userMessagethe door serves). The other differences are listed under Acceptance notes and left alone.Tests
packages/mcp/src/mcp-coded-refusal.test.ts, red first:LEAVE_EXHAUSTED/ 409 on each face (7): exactly{ code: 'RESOURCE_CONFLICT', message: 'No leave days left this year.', status: 409, declaredCode: 'LEAVE_EXHAUSTED' }, key order pinned, equal to the door's answer, nothing logged (console.errorandconsole.warnuntouched).LEAVE_EXHAUSTED/ 409 +userMessageon every face: both members, equal to the door's.PERMISSION_DENIEDwith no status +userMessageon every face:{ code, message, userMessage }in that order, unlogged; the door is asserted to serve thatuserMessage.RECORD_LOCKED/ 409 and the coded sandboxed refusal answer exactly the keyscode,message,statuson every face.LEAVE_EXHAUSTEDbody withdeclaredCode(equal to the door's, unlogged), and thePERMISSION_DENIED+userMessagebody.PERMISSION_DENIEDCONTROL, mcp: the data tools and the record resource render a coded refusal as its message alone, so a stdio client never reads MFA_REQUIRED (ruling C′ item 1's "same code") or any other refusal's code #23509's "carries no status", the unique-violation wire-code pins.Red first and ablations
Red first on
e6a0b72a(main), the new pins in place and no fix:mcp-coded-refusal.test.tsgaveTests 11 failed | 167 passed (178): the 7 per-faceLEAVE_EXHAUSTEDrows, the twouserMessagetool rows and the two resource rows. The CONTROL passed. With the fix:178 passed.Ablations via
node scripts/ablation-replace.mjson the committed head; each printedok mutation landedand thenok restored: blob == HEAD … git diff HEAD is empty:&& String('ABL').length < 0).mcp-http-tools.tsblobab9af56d548b -> 8f8fa89e73bd,Tests 9 failed | 169 passed (178): the 7 per-face rows, theLEAVE_EXHAUSTED+userMessagerow, the resourceLEAVE_EXHAUSTEDrow.userMessagejoin replaced byreturn envelope. Blobab9af56d548b -> 84eff1187f7b,Tests 2 failed | 176 passed (178): the twoPERMISSION_DENIED+userMessagerows.delete_records' catch condition put back (&& dataDoorRefusalEnvelope(err, objectName) === undefined). Blobab9af56d548b -> 06e8ff7ed57b,Tests 3 failed | 175 passed (178): the threedelete_recordsrows.declaredCodemember deleted.mcp-server-runtime.tsblobfe0b732b1547 -> e9ec35a89689,Tests 1 failed | 177 passed (178).The tests import the package's source, so no
dist/is involved.Acceptance notes
delete_records' outer catch. The order puts that catch's code-less rendering out of scope; its coded branch now routes every coded throw todataDoorErrorResult(it already routed the fault ones), so the selection read, one of the eight faces, answers like the other seven. For a coded throw the door does not demote and that carries nouserMessage, the rendering is the oneerrorResultWithCodegave, byte for byte.status. The door answers a status-lessPERMISSION_DENIED403 and a status-lessUNIQUE_VIOLATION409 with its own sentence; these faces keep the thrown envelope (nostatus), as mcp: the data tools and the record resource render a coded refusal as its message alone, so a stdio client never reads MFA_REQUIRED (ruling C′ item 1's "same code") or any other refusal's code #23509 and 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 pin it. Only the door'suserMessagejoins it. Not changed here.A record with this value already existsvs the engine's own); mcp: a tool call that repeats a unique value answers the engine's in-processDUPLICATE_RECORDin its error result, not the ruled wire spellingUNIQUE_VIOLATION(create_record,run_action,resume_run) #23701 keeps the engine's sentence on MCP. Not changed.userMessageon a registered declared-4xx code (RECORD_LOCKED/ 409 +userMessage) is now served too: the door serves it, and the order's rule is the door'suserMessage. Without auserMessagethat answer is byte-identical.Clause-②: no, re-declared from measurement. No export added to a package entry; the@objectstack/typesimport line is unchanged. The tool error already declaresdeclaredCodeanduserMessage(codedErrorResult), andrun_actionand the door-answer path already serve them.run_action/resume_run, the metadata tools andlist_actions(the mcp: the record data tools and the record resource drop declaredCode, where /data serves an unregistered code's spelling there (VENDOR_DOWN / 503) #31373 CONTROL for them stays green).Verification
Base
e6a0b72a; headd6d1ff92.pnpm --filter @objectstack/mcp test(vitest run,--maxWorkers=2):Test Files 60 passed (60),Tests 907 passed (907).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 d6d1ff9)
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