Skip to content

fix(mcp): record data faces withhold a declared 5xx's sentence as /data does - #31371

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

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

Conversation

@objectstack-fleet

Copy link
Copy Markdown
Contributor

Requested by Leehom · project thread

Fixes #31341

Clause-②: no
Metadata-protocol: none

维护者速读

What changes

dataDoorRefusalEnvelope (packages/mcp/src/mcp-http-tools.ts, #31273) decides whether a coded throw on a /data face 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 (serverFaultProvenance answers 'declared' or 'undeclared'), and keeps the coded answer only for a declared refusal status below 500 (serverFaultProvenance answers undefined). The predicate change is one token: !== 'undeclared' became === undefined.

When the door (mapDataError, read through dataDoorAnswerOf) answers a 5xx, the face renders the door's code, sentence and status and logs the thrown text once through logServerFault, the path #31273 already built. No copy of the withhold rule: mapDataError applies declaredRefusalMessage itself. 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 in mcp-server-runtime.ts). Only comments change in mcp-server-runtime.ts.

Throw Before (tools / resource) Now /api/v1/data (mapDataError)
SERVICE_UNAVAILABLE / 503, 'The ledger is closing.' code, 503, the producer's sentence SERVICE_UNAVAILABLE, 503, Internal server error; the sentence logged once same
same, with refusal: true code, 503, the sentence unchanged 503 SERVICE_UNAVAILABLE, the sentence
unregistered VENDOR_DOWN / 503 VENDOR_DOWN, 503, the sentence SERVICE_UNAVAILABLE, 503, Internal server error same, plus declaredCode: VENDOR_DOWN
CONTROL RECORD_LOCKED / 409 coded unchanged 409 RECORD_LOCKED
CONTROL coded sandboxed refusal (RECORD_LOCKED / 409) coded, the body's sentence unchanged 409 RECORD_LOCKED
CONTROL PERMISSION_DENIED, no status { code, message } unchanged 403 PERMISSION_DENIED
CONTROL SQLITE_BUSY, no status (#31273) the door's 500 DATABASE_ERROR unchanged same

On the resource, the same answers use its { error, code, status } members.

Tests

packages/mcp/src/mcp-coded-refusal.test.ts:

The operator line is read from console.error and console.warn together because logServerFault reports a declared SERVICE_UNAVAILABLE as a capability absence: one warn per 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.ts gave Tests 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 two refusal: true rows passed on base, as expected (they pin the sentence kept). With the fix: 136 passed.

Ablations, each via node scripts/ablation-replace.mjs on the committed head 5c91f46f; each printed ok mutation landed and then ok restored: blob == HEAD (ebb31a2794c5) and git diff HEAD is empty:

  1. The predicate put back to !== '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). Blob ebb31a2794c5 -> c9344e7ebdf1, Tests 9 failed | 127 passed (136): the same nine rows as red first.
  2. The declared-refusal guard deleted, so every door 5xx is declined. Blob 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 (a SandboxError with an empty innerMessage declaring RECORD_LOCKED / 409) is answered 500 INTERNAL_ERROR by 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

Verification

Base d0512c2f; head 5c91f46f.

  • 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-config on the three touched .ts files: exit 0. @objectstack/mcp has no lint script.
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 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: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:object-def-param-keys :: exit 0
  • pnpm check:objectql-double-limit :: exit 0
  • pnpm check:optional-error-sink :: 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:settings-bind-window :: 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
  • pnpm check:dual-build-cjs-loads :: exit 0

node 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-closure first exited 3 (PREREQUISITE NOT MET: @objectstack/objectql dist missing) and exited 0 when re-run after check:type-check-debt had built every package; check:dual-build-cjs-loads was run last for the same reason and exited 0. check-plugin-teardown-shape --self-test ran after git fetch --depth=1 of 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

  • 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_01FEkQ5mdwfFCbsFQ62JJ8P5

…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
@github-actions github-actions Bot added the size/m label Nov 8, 2026
@github-actions

github-actions Bot commented Nov 8, 2026

Copy link
Copy Markdown
Contributor

📓 Docs Drift Check

This PR changes 1 package(s): @objectstack/mcp, touching 5 documentable anchor(s).

12 hand-written doc(s) NAME something this change touched and may need an implementation-accuracy re-verification:

  • content/docs/api/client-sdk.mdx (via SERVICE_UNAVAILABLE (literal, a string literal in a comment on a changed line))
  • content/docs/api/error-catalog.mdx (via SERVICE_UNAVAILABLE (literal, a string literal in a comment on a changed line))
  • content/docs/api/index.mdx (via SERVICE_UNAVAILABLE (literal, a string literal in a comment on a changed line))
  • content/docs/automation/webhooks.mdx (via SERVICE_UNAVAILABLE (literal, a string literal in a comment on a changed line))
  • content/docs/data-modeling/drivers.mdx (via SQLITE_BUSY (literal, a string literal in a comment on a changed line))
  • content/docs/deployment/cli.mdx (via SQLITE_BUSY (literal, a string literal in a comment on a changed line))
  • content/docs/deployment/self-hosting.mdx (via SERVICE_UNAVAILABLE (literal, a string literal in a comment on a changed line))
  • content/docs/permissions/authentication.mdx (via SERVICE_UNAVAILABLE (literal, a string literal in a comment on a changed line))
  • content/docs/permissions/authorization.mdx (via SERVICE_UNAVAILABLE (literal, a string literal in a comment on a changed line))
  • content/docs/permissions/sharing-rules.mdx (via SERVICE_UNAVAILABLE (literal, a string literal in a comment on a changed line))
  • content/docs/protocol/kernel/error-handling.mdx (via SERVICE_UNAVAILABLE (literal, a string literal in a comment on a changed line))
  • content/docs/ui/print-pages.mdx (via SERVICE_UNAVAILABLE (literal, a string literal in a comment on a changed line))

⛔ 5 release-owned page(s) also name something this change touched. These are read-only:

  • content/docs/releases/v17/17-0.mdx (via SERVICE_UNAVAILABLE (literal, a string literal in a comment on a changed line))
  • content/docs/releases/v17/17-3.mdx (via SERVICE_UNAVAILABLE (literal, a string literal in a comment on a changed line))
  • content/docs/releases/v17/17-4.mdx (via SERVICE_UNAVAILABLE (literal, a string literal in a comment on a changed line))
  • content/docs/releases/v17/17-7.mdx (via SERVICE_UNAVAILABLE (literal, a string literal in a comment on a changed line))
  • content/docs/releases/v18/18-2.mdx (via SERVICE_UNAVAILABLE (literal, a string literal in a comment on a changed line))

content/docs/releases/ is RELEASE-OWNED (AGENTS.md "Documentation Guardrails"): release
notes are written centrally at release time, and a code PR that edits them is the exact PR
that guardrail exists to stop. They are still audited — read-only. If one of them is actually
wrong, file an issue or open a dedicated docs-only PR; do not edit it here.

What this run could not see
  • 1 anchor(s) matched too much of the corpus to be a work list: /api/v1/data (route, 50 pages)
  • the SDK route bridge reached 64 of 227 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 da7fce5903a6d0237eb1b3c3ba675c228a13ea6d → packageMentionDocs.

Which tree this was computed on

This run read content/docs from 7d2701711ef3898d878866061f13978eeecea9b1 — the merge of head 5c91f46fb809d59bbc6a984986a07e5f4dbcc84a into base da7fce5903a6d0237eb1b3c3ba675c228a13ea6d, 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 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

⚠️ That checkout carried uncommitted changes, so the commit above does not fully identify what was read.

Advisory only, and a precision-first one (#9192): a page is listed because it names a
symbol, wire route or SDK method this diff touched — not because it mentions a changed
package. Each row says which anchor put it there, so a wrong row is reportable rather than
merely annoying. To re-verify, run the docs-accuracy-audit workflow scoped to these files:
node scripts/docs-audit/affected-docs.mjs da7fce5903a6d0237eb1b3c3ba675c228a13ea6d → pass the list as
args.docs, on the commit named under Which tree this was computed on.

@github-actions github-actions Bot added 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 8, 2026
@objectstack-fleet objectstack-fleet Bot added area:ai AI-native — agent / tool / skill metadata, and the MCP surface an agent drives domain:server Domain lane — seat card indexed by label:pm:seat labels Nov 8, 2026
@objectstack-fleet

Copy link
Copy Markdown
Contributor Author

domain:server#6 · os-project-manager · session_01FEkQ5p3T5YWhLjurajudnQ

席位核对 · ACCEPT · 2026-11-08T05:08Z · head 5c91f46fb809d59bbc6a984986a07e5f4dbcc84a

Seat domain:server#6 reviewed the diff of its own dispatch (claim 6717051976 on #31341, card thread session_01FEkQ5mdwfFCbsFQ62JJ8P5, report 6717377210). Read against GitHub, not the report.

  1. Shape: 4 files, +145 / -34. One predicate in dataDoorRefusalEnvelope (mcp-http-tools.ts) changes. The /data door's reader (dataDoorAnswerOf → mapDataError, then isServerFault) is now asked for every coded throw whose status is a 5xx or undeclared (serverFaultProvenance is not undefined), not only the undeclared ones. A declared status below 500 keeps the coded answer. Nothing is copied from the door, and nothing new is exported. The six record data tools, delete_records' selection read and the record resource read it. Body says Fixes #31341; no other closing keyword.
  2. Premise: red first on main d0512c2f: 9 failed / 127 passed with the new pins and no fix (the resource and 7 per-face declared-503 rows, the unregistered VENDOR_DOWN / 503 row); the refusal: true rows were green on the base, as expected; 136 passed with it. Ablation 1 (predicate back to !== 'undeclared') red 9; ablation 2 (the declared-refusal guard removed) red 1 on 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; both restored to HEAD.
  3. Accepted scope line: a declared 4xx keeps its coded answer even where /data answers 500. The example is a SandboxError with an empty inner message declaring RECORD_LOCKED / 409. Asking the door for every status would move 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, and the card scopes declared 5xx. Ablation 2 pins the guard.
  4. Accepted consequence, carried: an unregistered code with a declared 5xx (VENDOR_DOWN / 503) now answers the status's closed code (SERVICE_UNAVAILABLE), as the door does. The door keeps the producer's spelling in declaredCode, which no MCP record face serves. That gap is filed as mcp: the record data tools and the record resource drop declaredCode, where /data serves an unregistered code's spelling there (VENDOR_DOWN / 503) #31373. 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 declared-503 CONTROL rows moved, as the order said.
  5. Gates / check-runs: dev: mcp 60/60 files (865 tests), typecheck exit 0, eslint exit 0, 65/65 derived gates exit 0. CI on 5c91f46f: 36 success, 21 skipped, 0 failure. The one cancelled Check Changeset run was superseded by a later success on the same head after a label edit. mergeable_state clean, and the head merges cleanly with current main (it was dispatched alongside fix(mcp): run_action and resume_run answer a throw through the /actions door's one reader #31315, which has since merged).
  6. Contract review: Clause-②: no (re-declared from measurement: no type, member or package export changes; a declared 5xx's answer becomes the one /data already gives, in members the tool error already declares), no packages/spec/src path, and check-owed-reviews lists no owed review for this PR: none owed.
  7. Out of scope: mcp: the record data tools and the record resource drop declaredCode, where /data serves an unregistered code's spelling there (VENDOR_DOWN / 503) #31373 above. Metadata-protocol: none; Skills-docs: not owed. Changeset patch for @objectstack/mcp.
  8. Landing: check-governed-merges --pr 31371: not governed, 179 changed lines. 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.

@objectstack-fleet
objectstack-fleet Bot marked this pull request as ready for review November 8, 2026 05:09
@objectstack-fleet
objectstack-fleet Bot enabled auto-merge November 8, 2026 05:09
@objectstack-fleet
objectstack-fleet Bot added this pull request to the merge queue Nov 8, 2026
Merged via the queue into main with commit 03533d2 Nov 8, 2026
58 of 59 checks passed
@objectstack-fleet
objectstack-fleet Bot deleted the claude/project-thread-mtu202 branch November 8, 2026 05:38
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

area:ai AI-native — agent / tool / skill metadata, and the MCP surface an agent drives documentation Improvements or additions to documentation domain:server Domain lane — seat card indexed by label:pm:seat 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: the record data tools and the record resource serve a declared 5xx refusal's own sentence, where /data withholds it ('Internal server error')

1 participant