Skip to content

fix(service-messaging): a notification template read for a recipient locale with no row tries the stack's declared fallback before en - #29048

Merged
objectstack-fleet[bot] merged 6 commits into
mainfrom
claude/project-thread-j938he
Nov 2, 2026
Merged

objectstack-fleet[bot] merged 6 commits into
mainfrom
claude/project-thread-j938he

Conversation

@objectstack-fleet

@objectstack-fleet objectstack-fleet Bot commented Nov 2, 2026 •

Copy link
Copy Markdown
Contributor

domain:server#5 · os-project-manager · session_01FEkQ5oc56xChD6Wrc4cGSt

Requested by Leehom · project thread

Fixes #28919

Clause-②: no
Metadata-protocol: none

维护者速读

  • 改了什么:通知模板(sys_notification_template)按收件人 locale 取行时,在 en 之前多试一级:栈声明的 fallback locale(i18n.fallbackLocale,否则 defaultLocale)及其主语言(zh-CN → zh)。
  • 为什么改:Email template resolver ignores i18n.fallbackLocale and does no language-subtag folding: en-GB / zh-TW recipients never reach en / zh-CN rows #28880 已让邮件模板读声明的 fallback,通知模板仍直接落到 en,同一个收件人在同一个栈上两类模板答案不同。
  • 风险与回滚:只多查一到两次精确行;没有 i18n 服务、包外自建的 store、不带 locale 的调用都与原来完全相同;所有示例栈声明的都是 en,结果不变。回滚即 revert 本 PR。
  • 先看:template-renderer.ts(localeCandidates 与 declaredFallbackLocale)、messaging-service-plugin.ts(把 i18n 的 getFallbackLocale 交给 store)、template-declared-fallback.test.ts。
  • 两分钟验证:pnpm --filter @objectstack/service-messaging exec vitest run src/template-declared-fallback.test.ts,预期 12 个用例全绿。
  • 需要你做的:无,席位落地。

What changes

  • NotificationTemplateStore's ladder for a named recipient locale is now: the named tag, its primary subtag, the stack's declared fallback and its primary subtag, then DEFAULT_LOCALE (en). Duplicates are dropped, so a stack declaring en walks exactly the old ladder.
  • The declared fallback is read at each resolve through a reader the plugin hands the store: the i18n service's getFallbackLocale, resolved from the service registry at call time, so an i18n service registered after kernel:ready is seen. Both hops are optional. A missing service, a missing method, an empty or non-tag answer, or a throw leave the rung out, and the store answers as it did before.
  • Placement and the published surface. The reader rides a module-private symbol key (TEMPLATE_DECLARED_FALLBACK_LOCALE, with the NotificationTemplateStoreWiring type), declared in template-renderer.ts and not re-exported from the package entry. This is the same shape fix(plugin-email): a templated email to a named locale folds it against the template's locales and tries the stack's declared fallback before en-US #28917 used on the email side. The published NotificationTemplateStoreOptions and the class declaration are unchanged. The built dist/index.d.ts and dist/index.d.cts differ from main only in the store's docblock text.
  • Ruling 2 reading: no resolveBundleLocale fold. The store reads rows one findOne at a time and holds no locale list, so it cannot fold without a new read. The fallback takes the same two steps as the named tag (tagThenPrimary), and no third copy of the BCP-47 ladder is added.
  • A call that names no locale keeps its single en rung, matching the email side, where a no-locale call is unchanged.
  • The comment at notification-template.object.ts (the locale field) now gives the new two-resolver reading: the declared-fallback rung is shared, and the fold is not. The email-channel comment names the new rung.

Why

After #28917 (#28880), a templated email to a recipient whose locale has no row tries the declared fallback before en-US. A sys_notification_template render for the same recipient went straight to en. The two template families answered the same recipient on the same stack differently.

Measurement (ruling 3). No shipped stack declares a non-en fallback. examples/app-crm, app-showcase and app-todo declare fallbackLocale: 'en', app-multi-package declares no i18n block, and hotcrm's src/sales declares 'en'. So for every shipped stack the ladder is unchanged. A stack that declares defaultLocale: 'zh-CN' and no fallbackLocale gets zh-CN as its fallback through os serve's fallbackLocale || defaultLocale || 'en', and that stack's ladder changes. The plugin already reads the i18n service from its context (getDefaultTemplateLocale), so the store reaches it without a new published member.

Tests

src/template-declared-fallback.test.ts (new, 12 cases):

  • Store: the declared fallback is chosen before en. The fallback folds to its primary subtag. The recipient's primary subtag still wins over the fallback. The ladder lands en when nothing matches. A changed answer is seen on the next resolve. Four ways of having no fallback (no reader, undefined, blank, throws) give today's ladder ['fr-FR','fr','en']. A no-locale call reads en alone.
  • The new file's engine double routes update/delete through assertEngineUpdateDispatch/assertEngineDeleteDispatch, and its three rows are recorded in scripts/engine-double-contract.pinned.json (--write: 0 added or grown elsewhere, 0 lost).
  • Composition: through MessagingServicePlugin, the mounted email channel renders the zh-CN row for a fr-FR recipient when an i18n service with getFallbackLocale: 'zh-CN' is registered AFTER kernel:ready, and renders the en row on a host with no i18n service.
Red first on main (5 red / 7 green)

Test file only, implementation absent: the five fallback cases fail (picks the declared fallback before en…, folds… primary subtag, lands en when neither…, reads… at each resolve, the composition case). The no-fallback, subtag-wins and no-locale cases pass, as today's ladder already answers them.

Ablation, one per rung (each through scripts/ablation-replace.mjs, restored to a byte-identical HEAD)

Tests import the source by relative path, so no dist/ rebuild is in the path.

  • A, delete the fallback rung tagThenPrimary(declaredFallback): 5 failed.
  • B, fallback without its primary subtag (push(declaredFallback)): 3 failed (folds…, lands en…, reads… at each resolve).
  • C, fallback before the named tag: 5 failed, including the recipient's primary subtag still wins.
  • D, drop the throw guard around the reader: 1 failed (a reader that throws). The first attempt was refused by the tool as a no-op (the replacement was a substring of the anchor) and ran nothing. The rerun used a distinct replacement.
  • E, drop the plugin wiring key: 1 failed (the composition case).

Acceptance notes

  • The store does not fold with resolveBundleLocale (see ruling 2 above). A zh-TW fallback over a store holding only zh-CN therefore lands zh or en, not zh-CN. The email side folds that case.
  • Not touched: packages/spec/** and plugin-email.

Verification

All readings are on head 1c8f2f69 (origin/main merged), except the ablation and d.ts readings, which were taken on the implementation commits before the merge.

  • pnpm --filter @objectstack/service-messaging test: exit 0, Test Files 63/63, Tests 771/771.
  • pnpm --filter @objectstack/service-messaging typecheck: exit 0. The new test file is in the package's tsc --listFiles.
  • eslint --no-inline-config packages/services/service-messaging/src: exit 0.
  • Published declarations: dist/index.d.ts and dist/index.d.cts were built at the base and at the fix. They differ only in the NotificationTemplateStore docblock text. No type, member or export changed, and the module-private symbol does not appear.
  • Derived gates (node scripts/pm/dispatch-gates.mjs --commands --repo objectstack-ai/objectstack): 71 derived, 71 run, all exit 0. --ran reconciliation: 0 NOT-MEASURED, 0 UNRUN. Prerequisites cleared before the run: check:i18n and check:dual-build-cjs-loads read built output (closure built), and check-plugin-teardown-shape --self-test needs its pinned fixture commit fetched.
  • CI families outside the derived set: see this PR's check-runs.

… declared fallback locale

NotificationTemplateStore walked the named tag, its primary subtag, then
'en', and never read the stack's i18n.fallbackLocale. The plugin now hands
the store the i18n service's getFallbackLocale under a module-private key,
read at each resolve; the ladder tries the declared fallback and its primary
subtag before DEFAULT_LOCALE. A host with no i18n service answers as before.

Co-Authored-By: Claude <noreply@anthropic.com>
Co-Authored-By: Claude <noreply@anthropic.com>
…te declared fallback

Co-Authored-By: Claude <noreply@anthropic.com>
…delete through the dispatch predicates

Co-Authored-By: Claude <noreply@anthropic.com>
@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 2, 2026
@github-actions

github-actions Bot commented Nov 2, 2026

Copy link
Copy Markdown
Contributor

📓 Docs Drift Check

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

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

  • content/docs/automation/webhooks.mdx (via MessagingServicePlugin (symbol, a top-level class))

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

  • content/docs/releases/v14.mdx (via MessagingServicePlugin (symbol, a top-level class))
  • content/docs/releases/v17/17-5.mdx (via MessagingServicePlugin (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
  • 1 name(s) were too generic to anchor anything (single lowercase words)
  • the SDK route bridge reached 60 of 216 client-bound route-ledger rows — the other 156 have no registrar path: tail to select them, so pages documenting THEIR client methods cannot appear above, on this or any run. Of those 156: 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; 101 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 — 6 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 0be247ce8b91ba3b9a3ce7235491b28a986b039a → packageMentionDocs.

Which tree this was computed on

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

node scripts/docs-audit/affected-docs.mjs --json 0be247ce8b91ba3b9a3ce7235491b28a986b039a

⚠️ 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 0be247ce8b91ba3b9a3ce7235491b28a986b039a → 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#5 · os-project-manager · session_01FEkQ5oc56xChD6Wrc4cGSt

席位核对

ACCEPT · domain:server seat 5 · os-project-manager · session_01FEkQ5oc56xChD6Wrc4cGSt · 2026-11-02T06:28Z · head 1c8f2f69 · #28919

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

席位意见:与 diff 相符。通知模板在收件人语言没有对应行时,先试站点声明的回退语言(及其主语言),再退到 en,与邮件模板一致;没有 i18n 服务、未指定语言或包外构造的调用照旧。

  1. Shape: draft against main, Fixes #28919, patch changeset for @objectstack/service-messaging; Clause-②: no, Metadata-protocol: none. No contract review owed. check-governed-merges --pr 29048: NOT governed, +319 / -17. git merge-tree against main: clean.
  2. Against the order:
    • Ruling 1. The ladder is: the named tag, its primary subtag, the declared fallback (getFallbackLocale, read at each resolve) and its primary subtag, then DEFAULT_LOCALE. With no i18n service, the answer is exactly as today.
    • Ruling 2. The store holds no locale list, so it does not fold with resolveBundleLocale. The fallback takes the same named-then-primary steps, and there is no third copy of the BCP-47 ladder.
    • Ruling 3. No shipped stack declares a non-en fallback (all declare en), and the plugin already reaches the i18n service.
    • Ruling 4. The comment at ~line 130 states the new two-resolver reading. No spec edit.
    • The reader rides a module-private symbol: index.ts re-exports neither it nor NotificationTemplateStoreWiring, and the published NotificationTemplateStoreOptions is unchanged.
  3. Accepted deviations:
    • scripts/engine-double-contract.pinned.json gains the three rows the gate's own --write produces for the new test double.
    • The missing body signature is supplied by this seat.
  4. Gates: red first 5/12, and five ablations (one per rung), each red. 71/71 derived gates exit 0, --ran 0 NOT-MEASURED. Check-runs on this head were still running at ACCEPT, and auto-merge waits on every required one.
  5. Out of scope: none new.
  6. Landing: pr_ready + automerge_enable through the relay.

@objectstack-fleet
objectstack-fleet Bot marked this pull request as ready for review November 2, 2026 06:29
@objectstack-fleet
objectstack-fleet Bot enabled auto-merge November 2, 2026 06:29
@objectstack-fleet
objectstack-fleet Bot added this pull request to the merge queue Nov 2, 2026
@github-merge-queue
github-merge-queue Bot removed this pull request from the merge queue due to failed status checks Nov 2, 2026
@github-actions

github-actions Bot commented Nov 2, 2026

Copy link
Copy Markdown
Contributor

⛔ merge queue 构建失败 — 先分诊,再决定要不要重排

队列构建 41406611368 红了。队列跑的是全量套件(PR 侧 CI 只跑 affected 子集),
所以失败的测试可能在本 PR 没碰过的包里 —— 那不是重排能修的。每次盲目重排都会让排在后面的所有 PR 重建一轮。

分类:failure —— 按下面的日志分诊。

失败的 job(日志抽取,best effort):

  • Test Core (6/8) — 失败步骤: Run this shard's tests

    @objectstack/cli:test:  FAIL   unit  test/validate-build-gate-parity.test.ts > os validate is the read-only superset of os build (#3782, #4409) > the command sources use no call shape this scan cannot
      ↳ 失败原因: @objectstack/cli:test: Error: Test timed out in 5000ms.
    

↳ 失败原因 是判读的关键:超时(Test timed out in … / Hook timed out in …)多半是负载/时序,不是本 PR 的回归;
断言(AssertionError: …)才指向真实的行为改变。两者的 FAIL 行长得一模一样,只有这一行能区分。

⚠️ 断言这一侧有一类例外,判据是断言在测什么,不是它是不是 AssertionError。 断言的对象是产品行为(一个值、一个形状、一次拒收)⇒ 照上面读:真实的行为改变,去查,⛔ 不要重排掉;
断言的对象是这次实验自身的有效性前提(跑完的耗时、负载下的先后、任何只在时间预算内才成立的条件)⇒ 它跟超时是同一类,同样对负载敏感,重排一次是合法的判别手段。
识别是机械的:断言的消息或它比较的值本身点名了一段时长、一个时间戳、一个耗时计数。实测过的一对 —— AssertionError: SecurityPlugin.init() ran: expected false to be true 测的是产品行为(真回归);
AssertionError: this run took over a second, so second-precision stamps could have differed too: expected 1006 to be less than 1000 测的是实验前提:它守护的那条不变式当时是绿的,同一个 head 原样重排一次即成功。
穿着 AssertionError 外衣的时间测量,仍然是时间测量。(⛔ 这只改「怎么读一次红」,不改「哪些测试可以重排」——后者由别处管。)

跨 PR 相同签名(24h,按失败测试文件聚合):

  • test/validate-build-gate-parity.test.ts — 24h 窗口内只有本 PR 撞到过,暂不汇总(再有一个不同 PR 撞到就会自动开汇总 issue)。
  • ⚠️ 24h 评论账本没读完(超过 5 页仍未读到窗口尽头),所以上面的「不同 PR 数」是下界,不是全量。

历史信号:

  • 本 PR 过去 24h 无队列失败记录(首次)。
  • 过去 24h 队列共有 4 个失败构建(不含本次)。

分诊清单:

  1. 失败测试在本 PR 改动的包里 → 真回归,修 PR。
  2. 失败测试与本 PR 无关 → 看上面的「跨 PR 相同签名」;已有汇总 issue ⇒ flaky/环境问题实锤,去那张 issue 上谈,修好前重排只会再烧一轮全队列。
  3. 两者都不是 → 可能与同组 PR 语义冲突;等前面的 PR 落地或失败出队后再重排一次即可,不要连续重排。

Generated by Claude Code · merge-queue-triage workflow (#4859)

@objectstack-fleet

Copy link
Copy Markdown
Contributor Author

domain:server#5 · os-steve · session_01ADHkmQKwKFCp1m6Pb6Q8c1

Queue kick · triage and one re-queue · 2026-11-02T08:14Z

The merge queue removed this PR at 2026-11-02T07:47:34Z (build run 41406611368). Seat 5 holds #28919 now (claim on the card); the ACCEPT 6570671797 stands on head 1c8f2f69, which has not moved.

  • Signature: Test Core (6/8) · @objectstack/cli · test/validate-build-gate-parity.test.ts > os validate is the read-only superset of os build (#3782, #4409) > the command sources use no call shape this scan cannot read · Error: Test timed out in 5000ms. (1 failed of 1714; the shard's import phase took 337 s).
  • Not in the flake ledger as far as this seat can read, so it is a new signature: recorded here and on messaging: NotificationTemplateStore's locale ladder (named tag, primary subtag, en) never reads the stack's declared i18n.fallbackLocale #28919.
  • Three facts for one re-queue: ① the failing file reads the cli command sources only; this diff touches packages/services/service-messaging/** and a changeset, so the import closure is disjoint; ② the same shard is green on a later queue build (run 41408594677, Test Core (6/8) success); ③ the first error is a timeout, not an assertion.
  • Action: re-queued once through the relay (automerge_enable). If the same signature removes it again, the seat stops and files it for a fresh diagnosis.

@objectstack-fleet
objectstack-fleet Bot added this pull request to the merge queue Nov 2, 2026
Merged via the queue into main with commit dedc350 Nov 2, 2026
53 checks passed
@objectstack-fleet
objectstack-fleet Bot deleted the claude/project-thread-j938he branch November 2, 2026 09:23
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.

messaging: NotificationTemplateStore's locale ladder (named tag, primary subtag, en) never reads the stack's declared i18n.fallbackLocale

1 participant