Repository navigation
fix(mcp): stdio list_datasets localizes the dataset catalogue for the workspace default locale - #34833
Conversation
… workspace default locale The stdio bridge's dataset loader now runs the HTTP door's /meta list translation (translateMetaList from @objectstack/rest) for the i18n service's default locale, so a zh-CN workspace serves zh-CN member labels and a bundle-label term matches as label over stdio, as over HTTP with no Accept-Language (ADR-0149 D2). An unresolvable i18n service leaves the list untranslated. Co-Authored-By: Claude <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01WGufzgwLiKcfujYUug7sPs
Co-Authored-By: Claude <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01WGufzgwLiKcfujYUug7sPs
📓 Docs Drift Check2 anchor(s) derived from 1 changed package(s); no hand-written page names any of them. 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 77ddeec7dd6e8c114e1f1bfa3b880a4387b96a11 && git checkout 77ddeec7dd6e8c114e1f1bfa3b880a4387b96a11
# afterwards, rebuild it from the two parents, which stay fetchable
git fetch origin c513d62acdd342745bbfe29786ba4b644cd934fc f12cb94021cd6382dc1147883b82183b74373587 && git checkout -B drift-repro c513d62acdd342745bbfe29786ba4b644cd934fc && git merge --no-ff f12cb94021cd6382dc1147883b82183b74373587
node scripts/docs-audit/affected-docs.mjs --json c513d62acdd342745bbfe29786ba4b644cd934fc |
|
repo:objectstack#3 · os-support-ai · session_01WGufzhshTXCAmv9KJXRZkB L1 review · 2026-11-17T12:55ZL1: ACCEPT Read at this exact head: the 7 files (+221/−7), the body, card #34787, claim 6946458372, amendment 6948225307 and os-dev-report 6948178219. Must-fixNone. Should-fixNone. Checklist
Notes
Under the "only nit-level findings open at landing" standard, nothing here blocks landing. |
|
repo:objectstack#3 · os-support-ai · session_01WGufzgwLiKcfujYUug7sPs Landing · area o3-B · 2026-11-17T12:56Z
State change: ready for review + auto-merge (merge queue). Card #34787 closes on merge via |
Requested by Yibo Wang · project thread
repo:objectstack#3 · os-support-ai · session_01WGufzgwLiKcfujYUug7sPs
Closes #34787
Clause-②: no
Metadata-protocol: none
维护者速读
list_datasets/query_dataset读到的数据集,现在先用 HTTP 通道同一个翻译函数(@objectstack/rest的translateMetaList)按工作区默认语言翻译,再交给执行器展示和匹配。label命中。@objectstack/mcp新增对@objectstack/rest的运行时依赖(实测osCLI 入口本来就加载它);i18n 服务取不到时保持原来的未翻译列表。回滚即 revert 本 PR。packages/mcp/src/stdio-data-bridge.ts(loadDatasets的翻译步骤)、packages/mcp/package.json(新依赖)、packages/mcp/vitest.config.ts(两条源码 alias)。pnpm --filter @objectstack/mcp exec vitest run src/stdio-data-bridge.dataset-locale.test.ts,预期 4 个用例全部通过。What changes
packages/mcp/src/stdio-data-bridge.ts: the stdio bridge'sloadDatasets(the one source bothlist_datasetsandquery_datasetread) now runstranslateMetaList(sources, 'dataset', items)from@objectstack/rest, the callpackages/runtime/src/domains/mcp.tsmakes on the HTTP door. Its three sources mirror the HTTP door's: the i18n service (a resolver that throws or answers nothing means none), the merged protocol read for the packaged base (or none on a host without one), andmetaRequestLocale(undefined, i18n)for the locale. With no request, that answers the i18n service's default, which is what the HTTP door answers for a call with noAccept-Language. No new locale source and no per-call locale.StdioDataBridgeDepsgains an optionali18n?: () => unknown, andpackages/mcp/src/plugin.tspasses() => optionalService('i18n'), resolved at each use like the protocol and security services.@objectstack/mcpexports nothing new.packages/mcp/package.json:@objectstack/restadded todependencies,@objectstack/service-analyticsadded todevDependencies(the test's stand-in executor matches terms with the platform'smatchDatasetTerms).pnpm-lock.yamladds the two importer links.packages/mcp/vitest.config.ts: anchored source aliases for@objectstack/restand@objectstack/service-analytics. Without them,check:test-source-aliaswould need two new rows in its shrink-only ledger..changeset/34787-stdio-list-datasets-locale.md: a patch for@objectstack/mcp.Not touched:
dataset-term-matcher.ts, matching other locales' bundle values (#34720's open fork),candidates, the HTTP door, and a per-call stdio locale.Translator route: import from
@objectstack/restI measured two routes. Importing from
@objectstack/restwas chosen over a thin wrapper aroundtranslateMetadataDocument:translateMetaListdoes more than calltranslateMetadataDocument. It also resolves the packaged base (packagedObjectBaseOf) and a declared override's pair bundle (pairTranslationBundleOf), and it applies the translate options (metaTranslateOptions: fallback chain and source locale). A wrapper would have to copy those or drop them. Either way the two transports would stop agreeing.packages/plugins/plugin-auth/src/invitation-role-label.tsalready importstranslateMetaListfrom@objectstack/rest.@objectstack/restdoes not depend on@objectstack/mcp(check:workspace-manifest-cyclesexit 0).packages/mcp/dist/index.js(ESM, module-init set collected throughmodule.registerHooks), at 3bbda33 and at this head:@objectstack/rest,@objectstack/metadata,@objectstack/observability,@objectstack/platform-objects,chokidar,glob,js-yamlandreaddirp.packages/cli/dist/index.js(theoshost that runs the stdio transport) already loads all 8.@objectstack/runtimeimports@objectstack/reststatically. So the cost falls only on a host that embeds@objectstack/mcpwithout the runtime.check:lean-entry-closureguards only@objectstack/objectql/coreand stays green.Why
ADR-0149 D2 says the
list_datasetssource is "localized at the metadata boundary for the caller's locale the way the REST door localizes a saved dataset". It names no transport exception. On #34720, live readings on a copy of app-crm withi18n.defaultLocale: 'zh-CN'showed the gap (comment 6945257866). The stdio door showed English labels and matched none of 总金额 / 平均成交额 / 阶段. HTTP with no header matched all three aslabel.Tests
packages/mcp/src/stdio-data-bridge.dataset-locale.test.ts(new). The bridge runs over a dataset with zh-CN bundle labels. A stand-in executor lists what the bridge loaded and runs the platform'smatchDatasetTermsover it:measures.total_amount · label; 阶段 →dimensions.stage · label.endefault: authored labels, and the zh-CN term does not hit (today's result).Ablation (one-time proof, committed fix first,
scripts/ablation-replace.mjs):return Array.isArray(translated) ? translated : items;was replaced byreturn items; /* ABLATED-34787 */. Landing was confirmed (anchor 1 → 0, blob5dad1618→721eb27b).expected 'Opportunity Metrics' to be '商机指标', 1 failed and 3 passed.5dad1618equals the HEAD blob, andgit diff HEADis empty.dist/sits on its path.Acceptance notes
getDefaultLocale(), as on the HTTP door with no header. TheEntryLocalizationthatplugin.tsassembles for the stdio principal'sExecutionContextis not read here. On the readings below the two agreed.getLocales/getTranslationsthrows reachesloadDatasetsas a throw on both transports. The executor answers that as a degraded read. That case is not pinned here.query_datasetresolves its dataset through the same loader, the provenance labels it prints over stdio are localized too. The HTTP door already behaves this way.stdio-data-bridge.ts, in a different region.overlap-checkreports it merges cleanly.Verification
All readings at head
f12cb94021unless stated.Unit tests and typecheck
pnpm --filter @objectstack/mcp exec vitest run --maxWorkers=2(whole package, under the verify lock): Test Files 67 passed (67), Tests 1230 passed (1230), lock VERDICT command-exit 0.pnpm --filter @objectstack/mcp typecheck: exit 0, withcheck:test-typecheck: OK.eslint --no-inline-configon the four changed TypeScript files: exit 0. The repo-widepnpm lintis CI's.Live re-read: examples/app-crm copies, both transports, one boot each
Method: the worktree's own build,
os dev -p PORTin a throwaway copy ofexamples/app-crm(deleted afterwards, never committed), and a persistentOS_HOME.POST /api/v1/keysas the seeded admin.OS_MCP_STDIO_ENABLED=trueandOS_MCP_STDIO_API_KEY. Over stdio it sentinitializeand thentools/call list_datasets. Over HTTP,POST /api/v1/mcpwithx-api-key.Avg Deal Sizeis the authored label ofmeasures.avg_amountand is not a member name.Copy with
i18n.defaultLocale: 'zh-CN':matches(crm_opportunity_metrics)Accept-LanguageAccept-Language: enAccept-Language: zh-CNCopy with
i18n.defaultLocale: 'en'(unchanged app-crm config):matchesenzh-CNAvg Deal Sizemisses on both transports under the zh-CN default and hits aslabelunder the en default.Gates: dispatch-gates --commands, reconciled with --ran
node scripts/pm/dispatch-gates.mjs --commands --repo objectstack-ai/objectstackderived 84 commands. All 84 were run locally, each with its exit code captured before any pipe.check:test-source-alias("OK — 122 packages with tests scanned"),check:undeclared-dep-imports,check:workspace-manifest-cycles,check:lean-entry-closure,check:dts-closure,check:published-filesandcheck:engine-double-contract.pnpm check:dual-build-cjs-loads, exit 3, PREREQUISITE NOT MET: 14 packages outside this change have nodist/in this worktree. A directrequire('./packages/mcp/dist/index.cjs')loads, exit 0. CI'sLint & Repo Gatesruns the gate over a full build.dispatch-gates --ranwith exit-annotated records: "84 derived famil(ies) accounted for — 83 run, 1 NOT-MEASURED (1 DERIVED from a recorded exit 3)", exit 0.node scripts/check-nul-bytes.mjs: exit 0.overlap-checkagainst origin/main and the PRs that share paths (feat(mcp): list_objects and describe_object return the authored object and field description #34814, fix(settings)!: offer the knowledge settings only where the knowledge service is mounted #34223, chore: version packages #33849): clean, exit 0.Human Minimum
packages/specholds no runtime logic.pnpm lintis CI's).main, one pull request.packages/spectouched: not touched.content/docs/references/,packages/*/CHANGELOG.mdorcontent/docs/releases/.Generated by Claude Code