Repository navigation
fix(mcp): the objectstack://objects resources serve labels in the locale the object tools speak - #35072
Conversation
…bject tools speak Co-Authored-By: Claude <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01WGufzfR33NbV51QQU6R6bm
…tools under a default locale Co-Authored-By: Claude <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01WGufzfR33NbV51QQU6R6bm
Co-Authored-By: Claude <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01WGufzfR33NbV51QQU6R6bm
…he stdio principal reads Co-Authored-By: Claude <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01WGufzfR33NbV51QQU6R6bm
…ject-resources-caller-locale
📓 Docs Drift CheckThis PR changes 1 package(s): 1 hand-written doc(s) NAME something this change touched and may need an implementation-accuracy re-verification:
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 391e25be331a53aee1b8a168e1e75f757a40296e && git checkout 391e25be331a53aee1b8a168e1e75f757a40296e
# afterwards, rebuild it from the two parents, which stay fetchable
git fetch origin 1282a464e9d27c2f8b86e69026087d1a1ff9b2df 689463fd78db407702ca6113b4b9b05984557811 && git checkout -B drift-repro 1282a464e9d27c2f8b86e69026087d1a1ff9b2df && git merge --no-ff 689463fd78db407702ca6113b4b9b05984557811
node scripts/docs-audit/affected-docs.mjs --json 1282a464e9d27c2f8b86e69026087d1a1ff9b2df
|
|
repo:objectstack#3 · os-support-ai · session_01WGufzfWpJ96QY9T7d8DvFg L1: ACCEPT · 2026-11-18T01:34ZHead-sha: 689463f 席位核对PR shape.
Not governed. Clause-②: CI. It was still running when I read it (21 pending, nothing failed). This verdict holds on the condition that One routine, moved as is. The new wrapper.
The mask holds. The translator rewrites text on the fields it is given and adds none. It is applied to the served object, never the declaration, so a masked field stays absent along with its translated text. The pins drive the real wiring. The #34995 block boots
The #34872 block still holds over the moved routine. The ablation turns the resource pin red. HTTP. Streamable HTTP registers no resources, so it is out of scope by construction, as the changeset says. Must-fixNone. Should-fixNone. Notes
Next: o3-E lands once the three aggregates are green. No seat L2 is owed. A later push owes an L1-c delta read. |
|
repo:objectstack#3 · os-support-ai · session_01WGufzfR33NbV51QQU6R6bm Landing · 2026-11-18T01:55Z
State: ready + auto-merge armed. Fixes #34995. |
Requested by Yibo Wang · project thread
Fixes #34995
Clause-②: no
Metadata-protocol: none
维护者速读
objectstack://objects与objectstack://objects/{name}现在和list_objects/describe_object工具一样,按工作区默认语言返回对象名、字段名、说明和选项名。packages/mcp/src/stdio-data-bridge.ts的servedLocaleObjectView(工具与资源共用的唯一翻译入口);packages/mcp/src/plugin.ts中交给资源的视图套上这层;测试文件stdio-data-bridge.object-locale-34872.test.ts末尾的[#34995]三条用例。pnpm --filter @objectstack/mcp exec vitest run --maxWorkers=2 src/stdio-data-bridge.object-locale-34872.test.ts,预期 8/8 通过。What changes
stdio-data-bridge.ts: the mcp: list_objects and describe_object serve labels and descriptions in the caller's locale, as the REST metadata door does #34872 translation (inServedLocaleovertranslateMetaList, withdefaultLocaleSources) moves out ofcreateStdioDataBridgeto module scope, unchanged, and is wrapped asservedLocaleObjectView(view, { i18n, protocol }): anMcpObjectViewwhoselistObjects/getObjectanswer the wrapped view's objects in the transport's locale, and whose declared-object read hands on the untranslated declaration (onlyreadonlyis read off it).list_objectsanddescribe_objectnow read through this wrapper; the dataset path calls the same module-scopedefaultLocaleSources. No second translation routine.plugin.ts: the view handed to the object resources (setRuntimeObjectView, the call site right beforebridgeResources) is wrapped inservedLocaleObjectViewover the same served view (callerObjectViewunder a stdio principal), with the samei18nservice andprotocolreads. The served view is what is translated, never the declaration, so a masked field stays absent (ADR-0106 D3/D5).mcp-server-runtime.ts: doc comment only.buildObjectListResource/buildObjectSchemaResourcetranslate nothing themselves; they serve labels as the view serves them.servedLocaleObjectViewis not exported from the package entry (index.ts); no published surface changes.@objectstack/mcppatch.Why
The object tools were localized in #34872 (PR #34922); the two resources still served authored text, so a resource read and a tool call for one object could name it in two languages.
Tests
New
[#34995]block inpackages/mcp/src/stdio-data-bridge.object-locale-34872.test.ts, booting the realMCPServerPluginand reading over an in-memory MCP client:describe_object's answer byte-for-byte, and the list resource's labels equallist_objects's (the card's done-when).fieldCountcounts only served fields.endefault with no entry, and no i18n service on the host: authored labels on the resources and the tools alike.Acceptance notes
bridgeResources,this.mcpServer.registerResource,mcp-server-runtime.ts);handleHttpRequestbuilds a per-request server that registers tools and prompts and no resources, so there is no HTTP resource to localize.mcp-server-runtime.ts"and where the resources are registered". The resources' view is handed over andbridgeResourcesis called inplugin.ts(setRuntimeObjectViewat the resource registration call site), so the wrap lands there. It is the only place the resources' view is set.findandgetSchemaonly (the verbs the stdio principal resolution reads); a first draft carried an unusedupdatethatcheck:engine-double-contractflagged.Verification
All readings on head
689463fd78(after mergingorigin/mainateb7b09d4d2) unless noted.@objectstack/mcp tests and typecheck
pnpm --filter '@objectstack/mcp^...' buildthenpnpm --filter @objectstack/mcp exec vitest run --maxWorkers=2andpnpm --filter @objectstack/mcp typecheck, under the verify lock:VERDICT command-exit 0;Test Files 71 passed (71),Tests 1261 passed (1261);check:test-typecheck: OK(53 errors / 8 pinned signatures held, unchanged).Ablation (one-shot, not kept)
Committed fix first, then
node scripts/ablation-replace.mjsonpackages/mcp/src/plugin.ts, anchor{ i18n: () => optionalService('i18n'), protocol: protocolReads },replaced by{},(the resources' view keeps the wrapper but loses its locale source; the tools are untouched). Anchor x1 to x0, blob 9169554f98 to 85772e895f. Test file run:Tests 2 failed | 6 passed (8), the zh-CN case (expected { name: 'deal', label: 'Deal', … } to match … label: '交易') and the masked-field case (expected 'Deal' to be '交易'); the authored-label case stays green, as expected. Restored: blob equals HEAD (9169554f98),git diff HEADempty. The test imports./plugin.jsfrom source, so no rebuild leg applies.Targeted gates
node scripts/pm/dispatch-gates.mjs --repo objectstack-ai/objectstack --commands(no paths): 69 commands, all run;--ranwith recorded exit codes:69 derived famil(ies) accounted for — 68 run, 1 NOT-MEASURED.pnpm check:dual-build-cjs-loads, exit 3PREREQUISITE NOT MET(reads every package'sdist/; only the mcp closure is built here). CI runs it.pnpm check:engine-double-contractwas red (exit 1) on the first run against the test's unusedupdatedouble; green (exit 0) after it was dropped, and again on the merged head.check:engine-double-contract,check:type-check-debt,check:type-check-coverage,check:test-source-alias,check:nul-bytes,check-empty-changeset,check-changeset-no-major,check-adr-0087-registration.check-governed-merges --branch: NOT governed; 304 changed lines, under 3000.dispatch-gates --tier: no path-derived mandate.overlap-check: clean against origin/main, feat(analytics): list_datasets answers nextStep and query_dataset answers sourceLine, in the caller's language #35043 and feat(cli): os skills install, update and status at the server's version, with or without a project #35060.Human Minimum
packages/specholds no runtime logic.pnpm lintpasses. (Repo-wide lint is CI's run; not run locally.)main, one pull request.packages/spectouched: its generated artifacts are regenerated and committed. (Not touched.)content/docs/references/,packages/*/CHANGELOG.mdorcontent/docs/releases/.Generated by Claude Code