Skip to content

fix(mcp): a coded sandboxed hook refusal answers the body's sentence, not the wrapper naming the hook - #31268

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

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

Conversation

@objectstack-fleet

Copy link
Copy Markdown
Contributor

Requested by Leehom · project thread

Fixes #31246

Clause-②: no
Metadata-protocol: none

维护者速读

  • 改了什么:沙箱 hook(或 action 主体)抛出带错误码的拒绝时,MCP 的所有工具和记录资源现在只回 hook 作者写的那句话(Locked.),错误码和状态码不变;读法用 /api/v1/data 同一个函数 sandboxBusinessMessage,没有复制逻辑。
  • 为什么改:之前 MCP 回的是沙箱调试包装 hook 'NAME' threw: Error: Locked.,把 hook 内部名字暴露给 agent;REST 对同一个拒绝只回那句话。
  • 风险与回滚:只改 @objectstack/mcp 的两处读法,patch;非沙箱的带码拒绝逐字不变,沙箱里崩溃的主体也保持原样。回滚即还原这两处。
  • 先看:packages/mcp/src/mcp-http-tools.ts 的 thrownRefusalEnvelope;packages/mcp/src/mcp-server-runtime.ts 记录资源的 catch;packages/mcp/src/mcp-coded-refusal.test.ts 的 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 块。
  • 两分钟验证:pnpm --filter @objectstack/mcp exec vitest run src/mcp-coded-refusal.test.ts -t 31246,预期 16 个用例全部通过。
  • 需要你做的:无,席位落地。

What changes

A QuickJS hook or action body that runs throw Object.assign(new Error('Locked.'), { code: 'RECORD_LOCKED', status: 409 }) leaves the runner as a SandboxError with message = hook 'NAME' threw: Error: Locked., innerMessage = Locked., code and status as declared (measured on the real QuickJSScriptRunner at main 169ff7e). MCP rendered message, so the agent read the hook's internal name; /api/v1/data answers 409 RECORD_LOCKED with Locked. (mapDataError → armSentence → sandboxBusinessMessage).

  • thrownRefusalEnvelope (packages/mcp/src/mcp-http-tools.ts) reads message as sandboxBusinessMessage(err) ?? messageOf(err). sandboxBusinessMessage is the one reader in @objectstack/types that the /data door uses; there is no second copy of its logic in packages/mcp. The code and status are unchanged.
  • The record resource's catch (MCPServerRuntime.bridgeResources, packages/mcp/src/mcp-server-runtime.ts) answered a coded refusal with its own err.message. It now uses the envelope's message, so it gives the same sentence as the tools. The code-less { error } answer is unchanged.

The envelope is the one reader, so every face that renders a coded refusal moves together: the 13 tools (list_objects, describe_object, validate_expression, the six record data tools, delete_records, list_actions, run_action, resume_run), the per-row grouping of delete_records (rowRefusalOf), the record resource, and the object resources' coded refusal (objectResourceRefusal).

Throw Before (MCP) Now (MCP) /api/v1/data
coded sandboxed refusal (RECORD_LOCKED/409, inner Locked.) RECORD_LOCKED · hook 'demo_guard' threw: Error: Locked. · 409 RECORD_LOCKED · Locked. · 409 RECORD_LOCKED · Locked. · 409
CONTROL: coded non-sandbox refusal, including one whose own text reads like the wrapper its message its message, byte for byte (not this card)

Tests

  • packages/mcp/src/mcp-coded-refusal.test.ts: a new #31246 describe on the shared /mcp HTTP harness. Each of the 13 tools (the SITES table, which is held equal to the registered tool list) answers the coded sandboxed refusal with { code: 'RECORD_LOCKED', message: INNER_SENTENCE, status: 409 }. Each case also checks that this equals mapDataError's answer to the same throw, and that the hook name and threw are absent. CONTROL: three coded non-sandbox throws (a plain sentence, a sentence that reads like the wrapper, and a SandboxError with an empty innerMessage) render byte for byte as JSON.stringify({ error: { code, message, status } }, null, 2). In the record-resource describe: the coded sandboxed refusal answers { error: INNER_SENTENCE, code, status }, and a CONTROL keeps a coded non-sandbox wrapper-like sentence.
  • packages/mcp/src/mcp-delete-records.test.ts: a coded sandboxed row refusal is grouped as { code: 'RECORD_LOCKED', status: 409, reason: INNER_SENTENCE }, and the call goes on.
Red first and ablations

Red first on bdefd49f (after PR #31245 merged, before the fix): the two files answered Tests 15 failed | 91 passed (106). The 13 tool rows, the resource row and the delete_records row failed; the CONTROLs passed. After the fix: Tests 106 passed (106).

Ablation 1 (node scripts/ablation-replace.mjs, mcp-http-tools.ts): message: sandboxBusinessMessage(err) ?? messageOf(err), replaced by message: messageOf(err) as string,. Output: ok mutation landed: anchor 1 -> 0, blob 9cca1c033a19 -> 58b6b2bf2013, then Tests 15 failed | 91 passed (106), then ok restored: blob == HEAD (9cca1c033a19) and git diff HEAD is empty.

Ablation 2 (mcp-server-runtime.ts): error: envelope.message, replaced by error: message as string,. Output: ok mutation landed: anchor 1 -> 0, blob 38c17f5605e4 -> c385c405c4f1, then Tests 1 failed | 105 passed (106) (the resource row only), then ok restored: blob == HEAD (38c17f5605e4).

The tests import the package's source, so no dist/ is involved.

Acceptance notes

Item 2 of the card: each listed face was measured against the REST door that serves the same verb, using five throws: V1 coded sandboxed refusal, V2 code-less sandboxed abort, V3 bare Error, V4 driver string code SQLITE_BUSY, V5 coded sandboxed crash (inner TypeError: boom, code RECORD_LOCKED, status 409; the real runner's shape). MCP was measured over /mcp on this branch with a bridge member throwing each value. REST was measured with the door's own responder: mapDataError for /data, handleRouteError for /meta, and the runtime HttpDispatcher.handleActions for /actions.

Face Throw MCP answers REST answers Reading
every face V1 inner sentence (this PR) inner sentence fixed here
every face V5 coded crash RECORD_LOCKED · hook 'demo_guard' threw: TypeError: boom · 409 /data, /meta: 500 INTERNAL_ERROR Internal server error; /actions: 500 INTERNAL_ERROR divergence, not fixed by the shared reader (sandboxBusinessMessage declines a crash by contract); finding
metadata tools, list_actions V3 bare text socket hang up /meta: 500 INTERNAL_ERROR Internal server error divergence; finding
metadata tools, list_actions V4 SQLITE_BUSY · driver text /meta: 500 DATABASE_ERROR Internal data error divergence; finding
record resource V2 { error: "hook 'demo_guard' threw: Error: Not enough leave" } /data: 400 HOOK_ABORTED Not enough leave divergence (the #31218 code-less half on this face); finding
record resource V3 / V4 { error: 'socket hang up' } / { error, code: 'SQLITE_BUSY' } 500 INTERNAL_ERROR / 500 DATABASE_ERROR divergence; same finding
run_action / resume_run V2 bare wrapper text naming the body /actions: 400 HOOK_ABORTED inner sentence divergence; finding
run_action / resume_run V3 bare text, no code /actions: 400 VALIDATION_ERROR same text divergence (code only); same finding
run_action / resume_run V4 SQLITE_BUSY · text, no status /actions: 400 VALIDATION_ERROR · text · declaredCode: SQLITE_BUSY divergence; same finding
record data tools V4 SQLITE_BUSY · driver text, no status (coded path is read first) /data: 500 DATABASE_ERROR Internal data error divergence; finding
record data tools V2 / V3 HOOK_ABORTED 400 / INTERNAL_ERROR 500 same converged by #31218
delete_records outer catch V2 / V3 bare message n/a kept as intended, see below

Kept as intended: delete_records' outer catch stays on errorResultWithCode. It also renders this file's own code-less sentences (delete_records could not read the records the query on 'OBJ' answered), which mapDataError's unknown-object heuristic would misread as 404 OBJECT_NOT_FOUND (the PR #31245 note). Its fault answer still quotes the faulting row's thrown message, as mcp-delete-records.test.ts pins on purpose. Each divergence above is listed for the seat to file, one card per face.

Verification

Base: bdefd49f (main, with PR #31245 merged); head: a8855476.

  • pnpm --filter @objectstack/mcp test: Test Files 60 passed (60), Tests 806 passed (806), lock VERDICT command-exit 0.
  • pnpm --filter @objectstack/mcp typecheck: exit 0 (includes check:test-typecheck: 53 errors / 8 pinned signatures held).
  • pnpm exec eslint --no-inline-config on the four touched .ts files: exit 0 (@objectstack/mcp has no lint script).
Derived gates (node scripts/pm/dispatch-gates.mjs --commands, 60 commands, all on a885547)
  • 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 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:dual-build-cjs-loads :: 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:objectql-double-limit :: 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: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

node scripts/pm/dispatch-gates.mjs --ran: 60 derived famil(ies) accounted for — 60 run, 0 NOT-MEASURED. Two gates first exited 3 on a prerequisite and were re-run after it was met: check-plugin-teardown-shape --self-test (shallow clone; fetched its pinned fixture commit) and check:dual-build-cjs-loads (needed every package's dist, built by check:type-check-debt). Both then exited 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_01FEkQ5oWCPWH6i2Lsts9cdP

…the wrapper naming the hook

thrownRefusalEnvelope reads the caller-addressed sentence through
sandboxBusinessMessage (@objectstack/types), the read the /api/v1/data door
makes, and the record resource renders the envelope's message. Code and
status are unchanged; a coded non-sandbox refusal keeps its message.

Co-Authored-By: Claude <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01FEkQ5oWCPWH6i2Lsts9cdP
@github-actions github-actions Bot added size/m 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 7, 2026
@github-actions

github-actions Bot commented Nov 7, 2026

Copy link
Copy Markdown
Contributor

📓 Docs Drift Check

2 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
  • 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 63 of 226 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 8f4e8fb9def634d62d9f7d418a9707f4bc400f25 → packageMentionDocs.

Which tree this was computed on

This run read content/docs from acedf75f1cb1d39de836767d31bf64b403282dd7 — the merge of head a8855476e91d945fefd9f5b2d6f1365e84a78be1 into base 8f4e8fb9def634d62d9f7d418a9707f4bc400f25, 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 acedf75f1cb1d39de836767d31bf64b403282dd7 && git checkout acedf75f1cb1d39de836767d31bf64b403282dd7
# afterwards, rebuild it from the two parents, which stay fetchable
git fetch origin 8f4e8fb9def634d62d9f7d418a9707f4bc400f25 a8855476e91d945fefd9f5b2d6f1365e84a78be1 && git checkout -B drift-repro 8f4e8fb9def634d62d9f7d418a9707f4bc400f25 && git merge --no-ff a8855476e91d945fefd9f5b2d6f1365e84a78be1

node scripts/docs-audit/affected-docs.mjs --json 8f4e8fb9def634d62d9f7d418a9707f4bc400f25

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

@objectstack-fleet

Copy link
Copy Markdown
Contributor Author

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

席位核对 · ACCEPT · 2026-11-07T21:37Z · head a8855476e91d945fefd9f5b2d6f1365e84a78be1

Seat domain:server#6 reviewed the diff of its own dispatch (claim and amendment 6712491439 on #31246, card thread session_01FEkQ5oWCPWH6i2Lsts9cdP, report 6713074631). Read against GitHub, not the report.

  1. Shape: 5 files, +137 / -3. thrownRefusalEnvelope (packages/mcp/src/mcp-http-tools.ts) now sets message to sandboxBusinessMessage(err) ?? messageOf(err), the same @objectstack/types reader the /api/v1/data door uses, with no copy of its logic; the bridgeResources catch in mcp-server-runtime.ts (amendment) renders envelope.message instead of its own err.message. Code and status unchanged; a coded non-sandbox refusal keeps its message byte for byte; a crashed body keeps today's text (the reader declines it). Body says Fixes #31246; no other closing keyword.
  2. Premise: re-measured red by the dev after PR fix(mcp): the record data tools answer a code-less throw as the /data door does, so an undeclared hook abort is HOOK_ABORTED #31245 merged (base bdefd49f): a real QuickJS hook throwing { code: 'RECORD_LOCKED', status: 409 } answered hook 'demo_guard' threw: Error: Locked. on every MCP tool and the record resource, where /api/v1/data answers 409 Locked.. New pins 15 red without the fix, 106/106 with it; two ablations (one per file) each red on their own pins, restored to HEAD.
  3. Gates / check-runs: 48 runs on a8855476, 35 success, 13 skipped, 0 red. mergeable_state clean, and the head merges cleanly with main 07559ce5 (git merge-tree no conflict). Dev: mcp 60/60 files (806 tests), typecheck exit 0, eslint on the 4 touched files exit 0, 60/60 derived gates exit 0 with --ran clean, 0 NOT MEASURED.
  4. Contract review: Clause-②: no (the envelope's type and members are unchanged; only the sentence a sandboxed refusal carries changes, to the one /data already answers), no packages/spec/src path: none owed.
  5. Out of scope / Skills-docs: item 2's measured divergences are filed as 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–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 (coded crash, resource code-less, run_action/resume_run, metadata tools, driver string code); delete_records' outer catch is kept by ruling with its reason pinned. The changeset names the one superseded sentence of the unreleased 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 note. Metadata-protocol: none; Skills-docs: not owed.
  6. Landing: check-governed-merges --pr 31268: not governed, 140 changed lines. Changeset patch for @objectstack/mcp. 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 7, 2026 21:38
@objectstack-fleet
objectstack-fleet Bot enabled auto-merge November 7, 2026 21:38
@objectstack-fleet
objectstack-fleet Bot added this pull request to the merge queue Nov 7, 2026
Merged via the queue into main with commit b3bd75d Nov 7, 2026
49 checks passed
@objectstack-fleet
objectstack-fleet Bot deleted the claude/project-thread-bkz0jj branch November 7, 2026 22:07
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

documentation Improvements or additions to documentation 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

1 participant