Repository navigation
feat(mcp): list_objects and describe_object serve labels and descriptions in the caller's locale - #34922
Conversation
…ions in the caller's locale Co-Authored-By: Claude <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01WGufzgNCAXyGfBQFZBwixH
Co-Authored-By: Claude <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01WGufzgNCAXyGfBQFZBwixH
📓 Docs Drift CheckThis PR changes 2 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 — 37 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 8c27b9038262817dd09ec47b3d6c9c68f6bca452 && git checkout 8c27b9038262817dd09ec47b3d6c9c68f6bca452
# afterwards, rebuild it from the two parents, which stay fetchable
git fetch origin 13e0305c3391db13c75b39762f4cdd8ec8f4a28f 2ba60e904c6efa353c0d4ffb34eeea82a25ae6d3 && git checkout -B drift-repro 13e0305c3391db13c75b39762f4cdd8ec8f4a28f && git merge --no-ff 2ba60e904c6efa353c0d4ffb34eeea82a25ae6d3
node scripts/docs-audit/affected-docs.mjs --json 13e0305c3391db13c75b39762f4cdd8ec8f4a28f
|
|
repo:objectstack#3 · os-support-ai · session_01WGufzfWpJ96QY9T7d8DvFg L1: ACCEPT · 2026-11-17T16:45ZHead-sha: 2ba60e9 席位核对PR shape.
Declaration. Governed / size. Check-runs at 2ba60e9. 57 runs, every one One routine, not two.
After the mask. Both doors translate the object as the caller is served it: What the translation does not touch.
Tests. 5 HTTP cases and 5 stdio cases cover:
The report also has a live zh-CN reading on app-crm that matches REST Docs made false? None. Neither Must-fixNone. Should-fixNone. Notes
Next: o3-G lands. No seat L2 is owed. A later push owes an L1-c delta read. |
|
repo:objectstack#3 · os-support-ai · session_01WGufzgNCAXyGfBQFZBwixH Landing · 2026-11-17T16:48Z
Ready + auto-merge into the queue. Area o3-G (repo:objectstack#3) watches it to MERGED and closes out #34872. |
Requested by Yibo Wang · project thread
Fixes #34872
Clause-②: no
Metadata-protocol: none
repo:objectstack#3 · os-support-ai · session_01WGufzgNCAXyGfBQFZBwixH
维护者速读
list_objects和describe_object现在按调用者的语言返回对象标签、对象描述、字段标签、字段描述和选项标签。HTTP 读请求的Accept-Language,stdio 用 i18n 服务的默认语言。两者调用的都是 REST/meta对象接口用的同一个翻译函数(translateMetaList),没有另写一套翻译。Accept-Language时,现在会取 i18n 默认语言(en)包里的值,和 REST 一致(app-crm 的amount因此显示为 "Deal Value")。回滚就是撤销这两个源文件的改动。packages/runtime/src/domains/mcp.ts里的inCallerLocale,以及它在listObjectSummaries/describeObject的两处调用(风险点:翻译必须作用在servedToCaller返回的对象上);②packages/mcp/src/stdio-data-bridge.ts里的inServedLocale,以及describeObject;③ 两个*-34872.test.ts测试里关于字段掩码的用例。pnpm --filter @objectstack/runtime exec vitest run --maxWorkers=2 src/domains/mcp-object-locale-34872.test.ts,预期Tests 5 passed (5)。What changes
packages/runtime/src/domains/mcp.ts): newinCallerLocaletranslates the objects as the caller is served them (servedToCaller, the ADR-0106 mask) withtranslateMetaList, the routineGET /meta/objectand the dataset tools already run. The locale is this request's, read bymetaRequestLocale(Accept-Language, then?locale=, then the i18n default).list_objectstranslates the whole page in one call.describe_objecttranslates the one served object, then projects it withdescribeServedObject.declaredis still read only for thereadonlyverdict. A new module helper,metaTranslationSources, holds the i18n, protocol and locale reading.loadDatasetsnow calls it too, so the dataset tools and the object tools answer one caller in one locale. The dataset behaviour is byte-for-byte the same.packages/mcp/src/stdio-data-bridge.ts): newinServedLocaledoes the same overcallerObjectView. The locale is the i18n service's default, the reading the stdiolist_datasetsalready uses: the transport carries no request.defaultLocaleSourcesis shared withloadDatasets.labelanddescription, fieldlabel, fielddescriptionfrom the bundle'shelpkey, option labels (field-level, then the bound picklist's), and validation messages. Names, option values and the answer's shape are unchanged. Clause-② stays no.@objectstack/runtimeand@objectstack/mcp.Tests
New pins: HTTP 5/5, stdio 5/5, plus the sibling #34721 and dataset-locale suites
packages/runtime/src/domains/mcp-object-locale-34872.test.ts: realSecurityPluginon a realObjectQLoverSqlDriver, through the real/mcpentry, with an i18n double carrying a zh-CN bundle. Cases: zh-CN translates the label, description and option label, and names stay;list_objectsunder zh-CN; a masked field stays absent and its zh-CN label and help text never appear, and the member'sfieldCountis the staff count minus 1; no header (defaulten, no entry) serves the authored text;fr-FR, or no i18n service, serves the authored text.packages/mcp/src/stdio-data-bridge.object-locale-34872.test.ts: the real tools (registerObjectTools) over the stdio bridge withsecurityDoubleFor. The same five cases at the default locale, including an i18n resolver that throws.mcp3 files / 13 tests passed (34872, 34721 and dataset-locale);runtime2 files / 9 tests passed (34872 and 34721).pnpm --filter @objectstack/mcp testgaveTest Files 70 passed (70),Tests 1246 passed (1246).pnpm --filter @objectstack/runtime testgaveTest Files 615 passed (615),Tests 11415 passed | 23 skipped (11438). Both lock verdicts werecommand-exit 0.pnpm --filter @objectstack/mcp --filter @objectstack/runtime typecheck: exit 0, includingcheck:test-typecheck.Ablation: four legs, each red, each restored to the HEAD blob
The subjects are imported by relative path from
src, so nodistwas involved. Each mutation went throughscripts/ablation-replace.mjs: the anchor went from 1 hit to 0, and the blob was restored equal to HEAD with an emptygit diff HEAD.served.length >= 0). Blob b4a8eb66b4e3 became 7199ebfa2457. Result:Tests 3 failed | 2 passed (5)(describe zh-CN, list zh-CN, masked case). Restored.Tests 1 failed | 4 passed (5), atexpect(field(described, DENIED)).toBeUndefined(). Restored.Tests 3 failed | 2 passed (5). Restored.Tests 1 failed | 4 passed (5)(masked case). Restored.Acceptance notes
Accept-Language: zh-CN,describe_object crm_opportunity). Before, at fc5913e:Opportunity/A potential sale tied to an account., stage optionsProspecting, Qualification, Proposal, Closed Won. After, at 5334bf9:商机/与客户关联的潜在销售机会。, fields商机名称,阶段(options初步接洽, 需求确认, 方案报价, 赢单),金额,预计成交日期,创建时间. This matches the REST/meta/object/crm_opportunitydoor's zh-CN answer.list_objectsunder zh-CN now lists客户,活动,联系人,线索,商机,产品明细, each with its zh-CN description.en) bundle entries, becausemetaRequestLocalefalls back to that default. The REST door does the same:/meta/object/crm_opportunitywith no header answersamount: Deal Value,close_date: Expected Close. app-crm'senbundle relabels both away from the authoredAmount/Close Date. The MCP answer follows REST here. This is an observation about the example's bundle, not a defect of this change.inlineHelpText: the translator serves the bundle'shelpentry oninlineHelpTextand keepsdescriptionin the source language (its documented slot rule). MCP servesdescriptiononly, so such a field's description stays in the authored language. This is the shared translator's rule, left unchanged.objectstack://objectsandobjectstack://objects/{name}(mcp-server-runtime.ts) still serve the authored text. The card names the two tools only, so the resources were not changed. carrier: Decision: open-source MCP — the client thinks locally, the server keeps a thin door (a metadata draft write entry for building; the data door for 问数), plus policy, version skew and the 问数 eval #34659.describe_object/list_objectstool descriptions (mcp-http-tools.ts) do not mention the locale. The answer's shape is unchanged, so they were left as they are (outside the claim surface).mainmoved 15 commits after fc5913e. None touches this diff's files.overlap-checkagainst origin/main 13e0305 and fix(mcp): render the /mcp/skill data loop from the published objectstack-ask skill #34881 reportsVERDICT clean exit 0.Verification
Derived gate families (`dispatch-gates --commands`, 68) at 2ba60e9
check:nul-bytes,check:test-source-alias,check:cross-package-test-inputs,check:doc-authoring,check:issue-citations,check:empty-changeset,check:adr-0087-registrationandcheck:changeset-no-major.check:dual-build-cjs-loads(PREREQUISITE NOT MET— only the example-crm closure is built here, 14 packages have no dist), andcheck-plugin-teardown-shape.mjs --self-test(a shallow clone cannot reach the pinned positive-control commit; it grades the checker, not this diff). CI runs both.dispatch-gates --ran:68 derived, 68 run, 0 NOT-MEASURED, 0 UNRUN.test:repo, dogfood (no!, no narrowing arm) and the type-check lanes run in CI.Generated by Claude Code