Repository navigation
feat(i18n): serve labels by i18n.sourceLocale as the authored language - #34025
Conversation
II18nService gains an optional getSourceLocale/setSourceLocale pair, shaped like the fallback pair. AppPlugin threads the declared i18n.sourceLocale into the service; FileI18nAdapter and the kernel's in-memory fallback implement both. Every document-translator option builder (rest metaTranslateOptions, objectql formula labels, email option holes, analytics select options, storage upload-link labels) passes getSourceLocale, else getDefaultLocale, as ResolveOptions.defaultLocale. The spec prose that said the serving layer does not read the key is corrected. Claude-Session: https://claude.ai/code/session_01ADHkmRFB7DnbZ57susY8Uv Co-authored-by: Claude <noreply@anthropic.com>
…uilder Claude-Session: https://claude.ai/code/session_01ADHkmRFB7DnbZ57susY8Uv Co-authored-by: Claude <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01ADHkmRFB7DnbZ57susY8Uv Co-authored-by: Claude <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01ADHkmRFB7DnbZ57susY8Uv Co-authored-by: Claude <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01ADHkmRFB7DnbZ57susY8Uv Co-authored-by: Claude <noreply@anthropic.com>
… pins Claude-Session: https://claude.ai/code/session_01ADHkmRFB7DnbZ57susY8Uv Co-authored-by: Claude <noreply@anthropic.com>
|
domain:spec#2 · os-steve · session_01ADHkmQjrEpxMVxEiDUJHqC Contract-review-claim: session_01ADHkmQjrEpxMVxEiDUJHqC · head 5156e55 · 2026-11-15T16:33Z |
📓 Docs Drift CheckThis PR changes 9 package(s): 7 hand-written doc(s) NAME something this change touched and may need an implementation-accuracy re-verification:
⛔ 8 release-owned page(s) also name something this change touched. These are read-only:
What this run could not see
Coarse fallback — 190 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 c5f423f6a5ac6604e1f79efe2bcfba74fe2be72b && git checkout c5f423f6a5ac6604e1f79efe2bcfba74fe2be72b
# afterwards, rebuild it from the two parents, which stay fetchable
git fetch origin e71ecc1b32cca6a8c56ae1d949c0b9100465475e b63efd08913228c8b7b3ba3368e7e28a0512eaa6 && git checkout -B drift-repro e71ecc1b32cca6a8c56ae1d949c0b9100465475e && git merge --no-ff b63efd08913228c8b7b3ba3368e7e28a0512eaa6
node scripts/docs-audit/affected-docs.mjs --json e71ecc1b32cca6a8c56ae1d949c0b9100465475e
|
|
domain:spec#2 · os-steve · session_01ADHkmQjrEpxMVxEiDUJHqC Contract reviewServed-tier: Read: card #33634 (body and all 7 comments, incl. 6894743586, 6894767686, 6895278811, both claims, 6897697194), PR #34025 body and file list (28 files, +562/-70), the net diff against the merge base, and the head tree for the census. The remaining 14 files (tests, changeset, four Check-runs on this head at review time: 14 completed ① Derived judgments
② Semver level
③ Boundary flags
④ Design judgmentNo must-fix, no should-fix. Scenario traced on the head ( Per
Census re-run on the head tree (every non-test reader of
Implementing files against the contract: Nits (no effect on this diff's correctness or the contract; none is to be fixed in code on this head):
Implemented-by: VERDICT: PASS |
|
domain:spec#2 · os-steve · session_01ADHkmQjrEpxMVxEiDUJHqC Contract-review-claim: session_01ADHkmQjrEpxMVxEiDUJHqC · head 74a2954 · 2026-11-15T17:21Z |
|
domain:spec#2 · os-steve · session_01ADHkmQjrEpxMVxEiDUJHqC Contract reviewServed-tier: Read: round 1's record in full; PR #34025 body, labels and comment list at this head; the commit range Commits between the two heads. One commit is on the branch's first-parent line; the other 41 are main's and arrive through it.
Check-runs on this head ( ① Derived judgments
② Semver level
③ Boundary flags
④ Design judgmentNo must-fix on the diff. One should-fix, on the PR body and a follow-up card; it needs no push and does not move the head.
Census re-run on this head's tree, against round 1's:
Scenario from round 1 ( Nits (none is to be fixed in code on this head):
Implemented-by: VERDICT: PASS |
|
domain:spec#2 · os-steve · session_01ADHkmQjrEpxMVxEiDUJHqC Contract-review-claim: session_01ADHkmQjrEpxMVxEiDUJHqC · head b63efd0 · 2026-11-15T17:31Z |
|
domain:spec#2 · os-steve · session_01ADHkmQjrEpxMVxEiDUJHqC Contract reviewServed-tier: Read: round 2's record in full; the commit range ① Derived judgments
② Semver level
③ Boundary flags
④ Design judgmentNo must-fix on the diff; the diff is the one round 2 passed. Nothing new from main.
Check-runs on this head ( CI is still running. This PASS is the design verdict only; landing waits for a green run on Implemented-by: VERDICT: PASS |
|
domain:spec#2 · os-steve · session_01ADHkmQjrEpxMVxEiDUJHqC ACCEPT · PR #34025 (#33634) · head
|
⛔ merge queue 构建失败 — 先分诊,再决定要不要重排队列构建 43744925702 红了。队列跑的是全量套件(PR 侧 CI 只跑 affected 子集), 分类: 失败的 job(日志抽取,best effort):
跨 PR 相同签名(24h,按失败测试文件聚合):
历史信号:
分诊清单:
Generated by Claude Code · merge-queue-triage workflow (#4859) |
⛔ merge queue 构建失败 — 先分诊,再决定要不要重排队列构建 43754687299 红了。队列跑的是全量套件(PR 侧 CI 只跑 affected 子集), 分类: 失败的 job(日志抽取,best effort):
跨 PR 相同签名(24h,按失败测试文件聚合):
历史信号:
分诊清单:
Generated by Claude Code · merge-queue-triage workflow (#4859) |
⛔ merge queue 构建失败 — 先分诊,再决定要不要重排队列构建 43757525680 红了。队列跑的是全量套件(PR 侧 CI 只跑 affected 子集), 分类: 失败的 job(日志抽取,best effort):
跨 PR 相同签名(24h,按失败测试文件聚合):
历史信号:
分诊清单:
Generated by Claude Code · merge-queue-triage workflow (#4859) |
|
domain:spec#2 · os-steve · session_01ADHkmQjrEpxMVxEiDUJHqC Requeue · PR #34025 · head
|
…ender adds, so /meta translates a dependent package's added fields (objectstack-ai#34156) <!-- claude-projects-attribution: {"github_login":"zhuangjianguo"} --> _Requested by **Steedos** · [project thread](https://claude.ai/code/project/chan_018ETKaNwMZCNRYD7D8Q9Ubb?thread=cmsg_018ETKaNwMZCNRYD7D8Q9UbbSUQWB2j9eHYsRcrCiq1X1C)_ ## 维护者速读 - **改了什么**:依赖包通过 `objectExtensions` 给基础包对象新增的字段(如 carbon 包给 `crm_account` 加的 `cb_market`),在中文等非默认语言下读 `/api/v1/meta/object` 时,字段名和选项名现在按该依赖包自己的翻译包显示,不再是英文。 - **为什么改**:此前对象的"出厂基准"只算基础包自己声明的字段,依赖包加的字段被当成"后来手工改过",于是翻译一律不套用;新建记录表单读的就是这个接口,所以中文界面里出现英文选项。 - **风险与回滚**:只扩了基准里"基础包没声明、由代码依赖包新增"的字段;基础包自己的字段、对象名称、`fieldPatches` 改的文字、租户和 `.custom` 加的字段都按原样不动。回滚即 revert 本 PR。 - **先看**:`packages/objectql/src/registry.ts`(`packagedAddedFields` 与 `getPackagedObjectBase`,重写后的 ⛔ 段)、`packages/objectql/src/protocol-packaged-object-base.test.ts`(边界钉子)、`packages/objectql/src/protocol-meta-effective-schema.test.ts`(中文读回再保存仍存英文原文)。 - **两分钟验证**:`pnpm --filter @objectstack/rest exec vitest run --maxWorkers=2 src/meta-object-field-patch-i18n.test.ts`,预期 12 passed,其中新增组断言 zh-CN 下 `cb_market` 为「市场」、选项为「内销 / 出口」,基础包自己被改名的字段仍保持原文。 - **需要你做的**:无,席位落地。 Fixes objectstack-ai#33800 Half 2 of the card (a dependent package's `fieldPatches` label/description getting its own translation) is out of this PR by maintainer ruling 6896340775: D stands and it has its own card. Until that card lands, patched text shows as written in every language. Clause-②: no Metadata-protocol: none ## What changes **The defect, measured on `origin/main` 45dee17.** A select field `cb_market` added by a dependent code package through `objectExtensions`, with the zh-CN rows in that package's pack, was served under zh-CN as `Market` / `Domestic` / `Export`. That held on the item read and on the list read (`translateMetaDocument` / `translateMetaList`, over a real `SchemaRegistry`). `translateObject` worked as designed. Its input was the problem: `SchemaRegistry.getPackagedObjectBase` returned the owner's declaration alone, so the field had no packaged counterpart and every slot of it counted as authored after the fact. **Origin.** The label and option-label divergence checks came in with objectstack-ai#29624 (59775a0, shipped in 18.3.0). It was not objectstack-ai#29948, and not 18.4.0: the path is identical from 18.3.0 to 18.4.0 (measured: `translateObject`, `packagedObjectField`, `valueOverridesPackagedBase`, `getPackagedObjectBase` and `translateMetaDocument` agree at the 18.3.0 and 18.4.0 tags). **The fix (seat ruling 6895879286, option A).** `getPackagedObjectBase` now also carries every field that a CODE `extend` contributor adds under a name the owner does not declare (`packagedAddedFields`). It uses the same filter as `packagedRules` (`ownership === 'extend' && isCodeArtifactBody`). This extends objectstack-ai#27559's rule-name principle to field names: the catalog rows for such a field can only translate what its extender ships. Boundaries, each one pinned: - An owner-declared field stays the owner's, even when an extender redeclares it (objectstack-ai#8037). - Same-name extenders resolve to the fold's winner (ascending priority). - `fieldPatches` are not merged, and the scalars are untouched. - Fields from a tenant overlay or a stored (`_provenance: 'org'`) extension, the `.custom` pair's included, stay diverged. - The ⛔ at the former registry.ts:8140 is rewritten and keeps the objectstack-ai#8037 reason. - The base is returned BY REFERENCE only when no code extender ships a rule or adds a field. No caller relies on reference equality: the callers are `metadata-protocol`'s echo restore and base accessor, the REST read gate, and objectql's `engine-validation-messages`, which reads `.validations` only. **The save door agrees with the read.** `restoreTranslatedObjectEchoes` (objectstack-ai#29673) reads the same accessor. A zh-CN read of the added field, echoed back by a PUT, is stored as the extender's source text (`Market`, `Domestic`, `Export`), both over a stored row and with none. **Extender-added `listViews`: not applicable, no card.** `ObjectExtensionSchema` refuses `listViews` on an extension (`packages/spec/src/data/object.zod.ts`, its guidance: "`listViews` cannot be contributed through an object extension"). So `translateObjectListViews` never sees a view an extender added. **Stale comments rewritten:** the `TranslateDocumentOptions.packagedBase` doc, the `packagedObjectField` doc, the `translateObject` docblock sentence on undeclared fields, and the `i18n-resolver.test.ts` comment on the undeclared-field pin. These are comment-only changes in `@objectstack/spec`. **Contract declaration.** `Clause-②: no`. No accept set, export, schema or response shape changes, and nothing previously served is refused. What changes is the label text that non-default-locale `/api/v1/meta/object` reads serve for fields a code extender adds; the changeset says so. Default-locale reads are unchanged. Not breaking, so no `!`, banner or ADR-0087 marker, and the dogfood battery is not owed. ## Tests - `packages/objectql/src/protocol-packaged-object-base.test.ts` (the existing harness for `getPackagedObjectBase`, per ruling 6583487846): a new top-level describe with 7 cases. The BY REFERENCE pin is flipped: with the shared fixture's `loyalty_tier` extension the base is now a copy that carries the field, and a label-only extension still returns the owner by reference. - `packages/rest/src/meta-object-field-patch-i18n.test.ts` (the existing harness for the meta-object extension i18n exit): a new top-level describe with 5 cases (item read, list read, base fields, owner field redeclared, tenant-added field). - `packages/objectql/src/protocol-meta-effective-schema.test.ts` (the existing objectstack-ai#29673 door harness): a new top-level describe with 2 cases (with and without a stored row). Red before the fix (45dee17 + pins): objectql 4 failed / 9 passed; rest 4 failed / 8 passed (`expected 'Market' to be '市场'`). ## Acceptance notes - **The reporter's package shape (seat item 2) was not measured directly**: `steedos-labs/os-project-blackcat-crm` is not readable from this session. The card's own facts point to a code package rather than a stored `object_extension` row. The fields come in "through `objectExtensions`" (the manifest key of a code package), they carry no `__c` suffix, and the package "passes validate". - Extender-added `listViews`: none can exist (the extension schema refuses the key), so there is nothing to translate and no card to file. - The seat ruling asks the reporter to confirm which page and version their 18.3.0 Chinese reading came from. On this path 18.3.0 and 18.4.0 behave the same (objectstack-ai#29624 shipped in 18.3.0). ## Verification All on head `ecffbe8d0` (origin/main `86350e125` merged), unless a line names another head. <details><summary>Pins, typecheck, generated artifacts (locked, final head)</summary> ``` os-verify-lock: VERDICT command-exit 0 · held the lock 904s closure :: exit 0 :: pnpm --workspace-concurrency=2 --filter @objectstack/rest... build pins-oql :: exit 0 :: Test Files 2 passed (2) :: Tests 38 passed (38) pins-rest :: exit 0 :: Test Files 1 passed (1) :: Tests 12 passed (12) oql-tc :: exit 0 :: pnpm --filter @objectstack/objectql typecheck rest-tc :: exit 0 :: pnpm --filter @objectstack/rest typecheck spec-gen :: exit 0 :: pnpm --filter @objectstack/spec check:generated dts-closure / published-files / sourcemap-no-sources-content / lean-entry-closure / test-source-alias / nul-bytes / type-check-debt :: exit 0 ``` </details> <details><summary>Package suites (head c856cd3: the fix merged with origin/main fb79d47; the final head adds only a test import and a main merge that touches no package of this diff's behaviour)</summary> ``` oql-test :: exit 0 :: Test Files 598 passed (598) :: Tests 13250 passed (13250) mp-test :: exit 0 :: Test Files 342 passed | 9 skipped (351) :: Tests 22923 passed | 43 skipped rest-test :: exit 0 :: Test Files 413 passed (413) :: Tests 8459 passed | 332 skipped spec-test :: exit 0 :: Test Files 843 passed (843) :: Tests 26966 passed | 1 todo ``` </details> <details><summary>Ablations (each leg: ablation-replace, objectql build, ablation-dist-preflight, pins, restore with blob == HEAD)</summary> ``` A1 drop the owner-declared guard -> 3 red: BY REFERENCE (label-only/redeclare), owner's redeclared field (objectql), owner field redeclared (rest) A2 drop the code-artifact filter -> 1 red: carries nothing from a stored (tenant-provenance) extension A3 fold code fieldPatches into base -> 7 red: does not fold fieldPatches (objectql) + 6 of the published fieldPatches cases (rest) final build exit 0 · absent-preflight exit 0 · every leg "restored == HEAD blob" ``` A3's first run was a no-op: the anchor sat inside its own replacement, and ablation-replace refused it with a drop of 0. It was rerun with a different anchor, and the line above is that rerun. A1's first run failed the dts build (an unused binding) and was rerun clean. </details> <details><summary>Gate sweep and PR-body gates</summary> `dispatch-gates --commands` derived 93 families. 92 were run locally with exit codes recorded and exit 0, after one fix: `check:test-source-alias` asked for a module-top `@objectstack/spec/ui` import in the rest pin file, which is added. `check:dual-build-cjs-loads` is left to CI. `pnpm lint` exit 0. Run with this body: `check-changeset-no-major`, `check-adr-0087-registration`, `check-closing-keyword-parity`, `check-partof-closing-keyword`, all exit 0. `git merge-tree --write-tree` is clean against origin/main, objectstack-ai#33821 (already merged) and objectstack-ai#34025 (the one open PR touching `i18n-resolver.ts`). </details> --- 🤖 Generated with [Claude Code](https://claude.com/claude-code) --------- Co-authored-by: Claude <noreply@anthropic.com>
Requested by Steve · project thread
Fixes #33634
Clause-②: yes
Metadata-protocol: semantic
Skills-docs: follow-up #34053
维护者速读
i18n.sourceLocale,把它当作元数据内联标签的原文语言;i18n 服务契约新增可选的getSourceLocale/setSourceLocale。fallbackLocale时,英文请求拿到的是中文标签;工具已把en报成 100% 覆盖,运行时却不这么服务。sourceLocale的应用;没声明的应用答案逐字不变(每个入口都有对照测试)。回滚即 revert 本 PR。packages/spec/src/contracts/i18n-service.ts(新契约方法的语义)、packages/rest/src/meta-item-read-gate.ts(元数据读取的取值顺序)、packages/runtime/src/app-plugin.ts(声明如何注入服务)。pnpm --filter @objectstack/rest exec vitest run src/meta-i18n-declared-fallback-chain.test.ts,预期 25 个测试全绿,其中 §6 六个是本卡的钉子。What changes
An app authored in English that defaults its users to
zh-CN(defaultLocale: 'zh-CN',sourceLocale: 'en', nofallbackLocale, azh-CNpack) used to serve anenrequest the Chinese row: every caller that builds the label resolver's options passedgetDefaultLocale()asResolveOptions.defaultLocale(the authored language), soenwas not "the authored one" and walked the fallback chain (zh-CN, the boot paths' collapse) ahead of the inline text. Route A of the census report (issuecomment 6894743586), chosen by the seat:packages/spec/src/contracts/i18n-service.ts): optionalgetSourceLocale(): string | undefinedandsetSourceLocale(locale): void. Same stance as the fallback pair: implementing one does not oblige the other (per-value); the getter answers only what was declared and never derivesdefaultLocale— that collapse is the caller's. ThegetDefaultLocalejsdoc no longer claims it is always the authored language.AppPlugin.loadTranslationsthreadsi18n.sourceLocalebesidesetDefaultLocale/setFallbackLocale, guarded on "declared something" (a sibling app on the same kernel keeps its value).FileI18nAdapterand the kernel's in-memory fallback implement both halves. Measured:os serveand plugin-dev constructI18nServicePluginwithdefaultLocale/fallbackLocaleonly, andAppPluginthen calls the setters on the adapter it built, so neither boot path needed a new option (serve.ts,dev-i18n.tsuntouched).getSourceLocale()(non-empty) elsegetDefaultLocale()asResolveOptions.defaultLocale, fallback chain untouched: restmetaTranslateOptions(also behindRestServer.translateOptionsFor,form-routes.tsand the runtime dispatcher's list translation), objectqlformula-option-labels.ts, plugin-emailoption-label-table.ts, service-analyticstranslateSelectOptions, service-storagerecord-file-access.tslabelsIn. The census re-run on895783a1(every non-testfallbackChain/getDefaultLocalereader underpackages/) found no sixth builder; the only otherfallbackChainsite isui/packages/i18n/src/utils/spec-formatters.ts, a client formatter fed from its own config, not fromII18nService(noted below).domains/i18n.ts, discovery, AppPlugin seed locale,extractLocale(a header-less request still falls todefaultLocale), plugin-auth (not touched).TranslationConfigSchema.sourceLocalejsdoc and.describe("Not yet read by the serving layer"),ResolveOptions.defaultLocalejsdoc and the resolver header, theRestServer.translateOptionsFordocblock, the regeneratedcontent/docs/references/system/translation.mdx, and three hand-written doc pages that described the old rule or told authors to addfallbackLocale: 'en'as a workaround. Shared read helper: inline (five 3-line copies); no new@objectstack/spec/systemexport.Tests
Each builder has a pin with
defaultLocale: 'zh-CN',sourceLocale: 'en', nofallbackLocale(collapsed tozh-CN): anenrequest answers the inline English label, azh-CNrequest thezh-CNrow, and a CONTROL with nosourceLocalekeeps today's answer (zh-CNrow foren).meta-i18n-declared-fallback-chain.test.ts§6: single read, list read, header-less request (falls tozh-CN), a third locale (ja-JPwalks the chain tozh-CN), controls with the accessor absent and answeringundefined.engine-formula-option-label.test.ts, plugin-emailtemplate-option-labels.integration.test.ts(booted kernel), service-analyticspicklist-dimension-label-i18n.test.ts(both strategies), service-storagerecord-file-access.integration.test.ts(the upload-link page, English and Chinese).fallbacks.test.ts(memory provider),file-i18n-adapter.test.ts,app-plugin.test.ts(threads, does not call when undeclared, skips a provider without the setter), speci18n-service.test.ts.protocol()/makeRest()take an optional document map, and the plugin-emailAppFixturetakes accessor overrides; every existing case runs with the defaults it had.Readings (local, shared container; packages built at the head the suites ran on)
driver-turso, a devDependency outside the first build closure).scripts/ablation-replace.mjs, mutation proven on disk, file restored to its HEAD blob each time): rest source read removed → 2 of 25 red (§6 single and list read); objectql → 1 of 9 red; plugin-email → 1 of 4 red; service-analytics → 2 of 30 red (one per strategy); service-storage → 1 of 90 red;AppPluginsetSourceLocalecall removed → 1 of 39 red. Each test file imports the source under test, so no rebuild was needed for the legs.pnpm --filter @objectstack/spec check:generated: one stale artifact (content/docs/references/system/translation.mdx), regenerated;api-surfaceunchanged (an optional interface member).Acceptance notes
ui/packages/i18n/src/utils/spec-formatters.tsbuilds afallbackChainfrom its own client config, not fromII18nService; it is outside this route (the Console's own locale config). Not filed.en-USagainstsourceLocale: 'en') is not recognised as the authored one:isDefaultLocalecompares tags exactly (case-insensitive), the same as it always did fordefaultLocale. Unchanged by this PR; noted, not filed.Verification
Verification head:
b63efd08, a merge-only commit oforigin/main(e71ecc1b, 15 commits past the previous merge) made under the seat's K ≥ 15 landing rule; CI on this head is the landing verdict. No file this PR changes moved on main's side. The local readings below were taken at5156e558(suites, ablations, derived gates, HTTP door) and74a2954d(the first merge ofmain: full rebuild,check:generatedgreen with nothing to regenerate).HTTP door, booted
The todo example in a side worktree at this head, set to
defaultLocale: 'zh-CN',sourceLocale: 'en', nofallbackLocale, and itsenbundle dropped (so English can only come from the inline labels);pnpm dev --fresh, signed in as the dev admin,GET /api/v1/meta/object/todo_task:Accept-Language: en→Task/Tasks/ fieldSubject(inline English)Accept-Language: zh-CN→任务/任务/主题Accept-Language: ja-JP→タスク/タスク/件名任务(the users' default)sourceLocale:en→任务/任务/主题(the card's defect, unchanged for a stack that declares nothing).The example edits lived only in that throwaway worktree; it was removed after both servers were stopped.
Derived gates (head 5156e55)
node scripts/pm/dispatch-gates.mjs --commands --repo objectstack-ai/objectstackon head5156e558: 130 commands, all run, all exit 0;--ranreconciliation: 130 derived, 130 run, 0 NOT-MEASURED, 0 UNRUN. The first round (head75656a8b) found one real red,check:test-source-aliason the edited rest test (the routes reach@objectstack/objectqlthrough a dynamic import inside a case's clock); fixed in5156e558with a module-topimport '@objectstack/objectql', the shape the package's other door tests use. Its other two non-zero exits were environment:check-plugin-teardown-shape --self-testexit 3 until its pinned commit was fetched into the shallow clone, andcheck:generated's embeddedcheck:test-typechecktsc run failing without diagnostics at the default heap (green at the CI heap, 4096 MB).