Skip to content

fix(service-i18n): a missing translation's fallback is reported once through the plugin logger - #28539

Merged
objectstack-fleet[bot] merged 3 commits into
mainfrom
claude/project-thread-98grvb
Nov 1, 2026
Merged

objectstack-fleet[bot] merged 3 commits into
mainfrom
claude/project-thread-98grvb

Conversation

@objectstack-fleet

Copy link
Copy Markdown
Contributor

Requested by Leehom · project thread

Fixes #28109

Clause-②: no (the returned strings are unchanged; a log signal only)
Metadata-protocol: none

维护者速读

  • 改了什么:服务端翻译适配器 FileI18nAdapter.t() 在缺翻译回退时,经插件 logger 说一次:请求语言缺某个键、由回退语言补上时,每个「键 + 语言」说一次;请求语言整包都没有时,每个语言只说一次;所有包都没有这个键时记一条 debug。返回给用户的字符串一个字节都不变。
  • 为什么改:卡 service-i18n: a missing translation falls back to the fallback locale, then to the key, with no signal #28109(分诊 6524808565):以前缺翻译时用户看到英文或原始键,运维、作者、CI 谁都不知道。分诊把信号形式交给开发选,并排除新增门禁;本 PR 选「每键一次的运行时警告」。
  • 风险与回滚:只加日志,不改回退顺序和返回值;去重集合上限 1000 条,满了说一句就停,热路径不会刷屏也不会无限占内存。只有应用「提供」的语言(声明的 supportedLocales,未声明时即已加载的语言)才是 warn,其余是 debug,所以客户端乱发 Accept-Language 推不高 warn 量。回滚即 revert。
  • 先看:packages/services/service-i18n/src/file-i18n-adapter.ts(t() 的回退分支与新的 reportMiss);src/file-i18n-adapter.test.ts 末尾的新 describe;src/i18n-service-plugin.ts(把 ctx.logger 传给适配器的一行)。
  • 两分钟验证:pnpm --filter @objectstack/service-i18n exec vitest run --maxWorkers=2 → 4 个文件 71/71 通过。
  • 需要你做的:无,席位落地。

What changes

The signal: a once-per-key runtime warning (the dev's choice the triage left open). An author diagnostic was not chosen: most t() keys are computed at run time (objects.X.fields.Y.label, validation.field.required), so no static check can list them, and the triage excludes a new gate.

FileI18nAdapter takes an optional logger (the warn and debug members of Logger from @objectstack/spec/contracts). Without one it is silent, exactly as before, so a library user constructing the adapter by hand sees no change. I18nServicePlugin.init passes ctx.logger.

On a miss in the requested locale, t() calls reportMiss after the fallback leg. The fallback order and the returned value are untouched (the reporting reads only what t() already computed). Each report is said once:

Case Said Level
The requested locale lacks the key and the fallback locale serves it once per key and locale, naming both warn if the stack offers the locale, else debug
The requested locale has no bundle at all (static or authored) once per locale, not once per key warn if the stack offers the locale, else debug
No bundle holds the key; the key itself is returned once per key and locale debug, always
1000 distinct reports reached once warn, then silence until restart

"Offers" is getLocales(): the declared i18n.supportedLocales, else every loaded locale. For any other locale the client asked for something the app never offered (often straight from Accept-Language), the fallback is the designed answer, and a client cannot drive the warn volume by sending locales.

Why the key-missed-everywhere case is debug, not the louder warning the order leaned toward. At least ten t() callers probe on purpose and read the echoed key as "not overridden": the field/object label ladders in objectql (record-validator.ts, engine-validation-messages.ts, rule-validator.ts), the approvals reader labels and refusal override address, the audit activity summary, messaging's notification text, the sandbox hook refusal catalogue and automation's node text. Measured live (below), every both-missed line on a plain boot and page load is one of these probes (objects.showcase_account.fields.__search.label, validation.field.required, flows.*.label in en, where the source label lives in metadata, not in a bundle). A warn there would report misses nobody has to fix. Messaging already warns once per key for its own catalog misses.

The bound. FileI18nAdapter.MISSING_TRANSLATION_REPORT_LIMIT = 1000, shared by per-key and per-locale entries. The largest per-page report count measured below is 12 distinct entries per locale, so 1000 leaves room for a whole partial locale while costing at most some tens of KB of short strings.

Tests

  • Red first, on the base implementation with the new tests (src/file-i18n-adapter.test.ts, src/i18n-service-plugin.test.ts): Tests 6 failed | 44 passed (50). The failures were exactly the reporting cases; the controls ("a hit in the requested locale logs nothing", "returns exactly what an adapter without a logger returns") passed on base.
  • Green at head: pnpm --filter @objectstack/service-i18n exec vitest run --maxWorkers=2 → Test Files 4 passed (4) · Tests 71 passed (71); pnpm typecheck exit 0.
  • New cases: fallback-served warns once naming locale, key and fallback, and a second call logs nothing; a hit logs nothing; both-missed is one debug per key and locale and still returns the key; an offered locale with no bundle is one warn for any number of keys; an unoffered locale with no bundle is one debug; a fallback in an unoffered locale is debug while an offered one is warn; an authored translation counts as the locale's bundle and as a hit; the bound stops after 1000 with one closing line; the returned strings (with and without interpolation, every case) equal those of an adapter with no logger; the plugin passes its logger through.
  • Ablation (node scripts/ablation-replace.mjs --delete of the this.reportMiss(...) call in t(); tests import src/ relatively, so no build leg): anchor 1 → 0, blob bbf3e2c1 → 07a841a0; Tests 8 failed | 44 passed (52) in the two files, every reporting case red and every control green; restored, blob == HEAD, git diff HEAD empty.

Acceptance notes

  • Noise, measured live on objectstack dev --seed-admin --fresh at OS_LOG_LEVEL=debug, after a full pnpm build and the console build, loading the real Console home (/_console/home, 20 to 21 API requests) once per locale in Chromium with that Accept-Language. Report lines added by each load:

    Stack Boot en zh-CN fr ja-JP es-ES
    showcase (offers en, zh-CN) 1 debug 8 debug 2 debug 1 debug 12 debug 12 debug
    todo (offers en, zh-CN, ja-JP) 0 0 0 1 debug 0 not measured

    Zero warn lines on either stack at the head. Base logged nothing of any kind. At the default info level a plain boot and page load therefore print nothing new.

  • An intermediate head that warned on every locale with a bundle measured 3 warn lines per Console home load in ja-JP and in es-ES on the showcase (objects.showcase_invoice.label, objects.showcase_contact.label, objects.showcase_account.label: the platform plugins ship ja-JP/es-ES bundles, the showcase translates its objects only in zh-CN). That is the case the "offered" rule turns into debug: the showcase never offered those locales.

  • The first measured fr load (i18n: French is not a platform locale, so a user whose locale is fr reads English sys_user labels (Home feed field labels) #28107: fr is not a platform locale) gave one line for the whole page, not one per key.

  • A locale requested before its bundles are pushed (platform bundles load at kernel:ready) would be reported as having no bundle once; none of the measured boots produced such a line.

Verification

Derived gate list at head (60 commands), each exit captured before any pipe, reconciled with --ran

Run at head 0be93784 (each line is COMMAND :: exit N):

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/check-tenant-audit-census.mjs :: exit 0
node scripts/check-tenant-audit-census.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/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: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: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:pm-changeset-deadline-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:route-envelope :: 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:watch-hint-literal :: exit 0
pnpm check:where-matcher :: exit 0

node scripts/pm/dispatch-gates.mjs --repo objectstack-ai/objectstack --ran FILE → exit 0: 60 derived famil(ies) accounted for — 60 run, 0 NOT-MEASURED. check-plugin-teardown-shape.mjs --self-test needed git fetch --depth=1 origin 621a4876… on this shallow clone first (exit 3 before, 0 after). Families CI runs outside the derived list (artifact roster, wide-population, type-check lanes, Test Core) are read from the PR's check-runs, not re-run here.

Scoped lint

node --stack-size=4000 node_modules/eslint/bin/eslint.js packages/services/service-i18n --no-inline-config → exit 0. Control-byte self-scan of the touched files: no hit.

test:repo (vitest repo project) is not run locally: the diff edits no repo-project test and the derived list does not name it; CI's Test Core runs it.


Generated by Claude Code

…e plugin logger

What t() returns is unchanged; the fallback-served case warns once per key
and locale, a locale with no bundle warns once, a key no bundle holds is a
debug line, and reports stop after a bounded count.

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

github-actions Bot commented Nov 1, 2026

Copy link
Copy Markdown
Contributor

📓 Docs Drift Check

This PR changes 1 package(s): @objectstack/service-i18n, touching 6 documentable anchor(s).

2 hand-written doc(s) NAME something this change touched and may need an implementation-accuracy re-verification:

  • content/docs/kernel/services-checklist.mdx (via FileI18nAdapter (symbol, a top-level class), I18nServicePlugin (symbol, a top-level class))
  • content/docs/protocol/kernel/i18n-standard.mdx (via I18nServicePlugin (symbol, a top-level class))

⛔ 1 release-owned page(s) also name something this change touched. These are read-only:

  • content/docs/releases/v18/18-0.mdx (via I18nServicePlugin (symbol, a top-level class))

content/docs/releases/ is RELEASE-OWNED (AGENTS.md "Documentation Guardrails"): release
notes are written centrally at release time, and a code PR that edits them is the exact PR
that guardrail exists to stop. They are still audited — read-only. If one of them is actually
wrong, file an issue or open a dedicated docs-only PR; do not edit it here.

What this run could not see
  • 2 name(s) were too generic to anchor anything (single lowercase words)
  • the SDK route bridge reached 60 of 212 client-bound route-ledger rows — the other 152 have no registrar path: tail to select them, so pages documenting THEIR client methods cannot appear above, on this or any run. Of those 152: 0 are remediable by widening that discovery convention (an in-repo file declares the path; the convention did not scan it); 55 are structural — on a ledger where NOT ONE row is declared in-repo, so no discovery change reaches them at any price; 97 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 — 5 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 37184244b82b9e4234581b653cdc7554e74e6136 → packageMentionDocs.

Which tree this was computed on

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

node scripts/docs-audit/affected-docs.mjs --json 37184244b82b9e4234581b653cdc7554e74e6136

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

Advisory only, and a precision-first one (#9192): a page is listed because it names a
symbol, wire route or SDK method this diff touched — not because it mentions a changed
package. Each row says which anchor put it there, so a wrong row is reportable rather than
merely annoying. To re-verify, run the docs-accuracy-audit workflow scoped to these files:
node scripts/docs-audit/affected-docs.mjs 37184244b82b9e4234581b653cdc7554e74e6136 → pass the list as
args.docs, on the commit named under Which tree this was computed on.

@objectstack-fleet

Copy link
Copy Markdown
Contributor Author

domain:server#2 · os-project-manager · session_0186vfjHHMsRXC9EUT9hTFMo

席位核对

ACCEPT · domain:server seat 2 · os-project-manager · session_0186vfjHHMsRXC9EUT9hTFMo · 2026-11-01T05:46Z · head 0be93784 · #28109

The maintainer's standing authorisation for landing reviewed PRs, verbatim: 「按照 pm-dispatch 规则复核过的都授权」.

  1. Shape:
    • A draft against main with no assignees, Fixes #28109, and a patch changeset for @objectstack/service-i18n.
    • check-governed-merges --pr 28539 reads NOT governed, 254 changed lines. Landing tier S.
    • The claim (6553476218) names this PR's branch, claude/project-thread-98grvb.
  2. Against the order:
    • What t() returns is unchanged: the same fallback order and the same string. A miss is now reported once per (locale, key), or once per locale when the locale has no bundle at all, through the plugin's logger. The adapter defaults to no logger, so library users see no change.
    • The dedupe set is bounded at 1000 entries, with one final line when the bound is reached. That bounds both memory and log volume.
    • Two deviations from the seat's lean, both measured and accepted:
      • A key missing everywhere is logged at debug, not as a louder warning. At least ten callers probe t() on purpose, and every live both-missed line was such a probe.
      • A warn is emitted only for a locale the stack offers (getLocales()). Other locales log at debug, since an intermediate head gave 3 warnings per page in ja-JP and es-ES on a stack that never offered them.
    • Live result: showcase plus todo boot, and the real Console home in en, zh-CN, fr, ja-JP and es-ES, produced 0 warn lines.
    • No new gate (triage: 「新增门禁默认否」).
  3. Contract review: not owed. The PR declares Clause-②: no (a log signal only) and touches no packages/spec/src/**, governed path or narrowing. The Logger type is imported from the existing contract.
  4. Gates: CI on head 0be93784 shows 35 success, 13 skipped and 0 red. The state is clean. The dev report (6553906673) shows red-first, ablation and 60 of 60 derived gates.
  5. Overlap: no other open PR touches packages/services/service-i18n/src/. git merge-tree reports no conflict against main 258fb1e9.
  6. Landing: pr_ready + automerge_enable through the relay.

Generated by Claude Code

@objectstack-fleet
objectstack-fleet Bot marked this pull request as ready for review November 1, 2026 05:47
@objectstack-fleet
objectstack-fleet Bot enabled auto-merge November 1, 2026 05:47
@objectstack-fleet
objectstack-fleet Bot added this pull request to the merge queue Nov 1, 2026
Merged via the queue into main with commit 071bda6 Nov 1, 2026
49 checks passed
@objectstack-fleet
objectstack-fleet Bot deleted the claude/project-thread-98grvb branch November 1, 2026 06: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

Development

Successfully merging this pull request may close these issues.

service-i18n: a missing translation falls back to the fallback locale, then to the key, with no signal

1 participant