Skip to content

hotclm's own notifications reach a zh-CN user in English — "Contract approved: …", "Renewal decision due: …", "Expired: …" — though the platform's notify template path is per-recipient localized - #174

Merged
zhuangjianguo merged 1 commit into
mainfrom
claude/issue-160-notify-templates
Oct 27, 2026

Conversation

@objectstack-fleet

Copy link
Copy Markdown
Contributor

Fixes #160

Clause-②: no
Metadata-protocol: none

Every notification hotclm sends itself wrote its words inline in a notify node's title / message. NotifyConfigSchema defines those as one text for every recipient ("not localizable — use template for per-locale content"), so a zh-CN user's bell and mail read English. Each listed node now names an email_template bundle in template and fills its holes from templateData. The platform picks the member per recipient, from sys_user.locale or else the deployment default, on the inbox and the email channel alike.

What changed

  • src/email-templates/: ten bundles, one file per flow, built by noticeBundle() in _bundle.ts. Each bundle has an English member carrying the unchanged sentence and a zh-CN member written in the tone of the existing zh-CN bundle (你, 「」, 请…). They are registered through defineStack({ emailTemplates }).
    • approval (F5): clm.contract_approved, clm.contract_rejected
    • signature round (F7): clm.execution_copy_missing, clm.execution_formalities_missing
    • renewal notice (F12): clm.renewal_notice_due
    • expiry (F13): clm.contract_expired, clm.contract_auto_renewed
    • legal-review SLA (F3): clm.legal_review_over_30_days, clm.legal_review_over_60_days
    • stalled turn (F4): clm.turn_stalled
  • The English member is en-US, not en. At 18.2.0 the resolver matches (name, locale) exactly. For a call that names a locale, it retries one rung only, the literal en-US (EMAIL_TEMPLATE_FLOOR_LOCALE), with no subtag folding. The stack's default is en, and the Console's English choice writes en. Both miss and land on the en-US floor, and so does any tag nobody authored. A member written as en would have no floor: an unknown locale would dead-letter with TEMPLATE_NOT_FOUND. The measurement below shows the en → en-US hop live.
  • Flows: the ten notify nodes swap title / message for template + templateData (CEL value envelopes, ref() as before). In _daily-sweep.ts, RowNotice takes either form, so rowBody() can build a template notice. The two sweeps outside this card still pass inline copy (see Acceptance notes).
  • The missing-formalities list goes over in both languages. signatureExecution already mapped each missing formality to its English option label. It now also maps it to the zh-CN bundle's label (missingTextZhCN, joined with 、, read from src/translations/zh-CN/objects.lifecycle.ts). The zh-CN member reads that list and the English member reads missingText. Without this, the zh-CN sentence would name the formality in English.
  • RenewalStartFlow is untouched. In renewal-notice.flow.ts only the sweep's notify node changed.

Measured on 18.2.0 (pnpm demo:zh, port 3152, throwaway DB, Chromium at /opt/pw-browsers/chromium in zh-CN)

The personas are the declared demo staff, signed in through the Console's login form with admin123. Each requester's line manager was set to Executive with POST /api/v1/auth/admin/set-user-manager. Each persona's language was chosen in the Console (account menu → 语言). That control writes PATCH /api/v1/data/sys_user/ID {"locale":"zh-CN"} (or {"locale":"en"}), so a user who picks 中文 in the Console becomes a zh-CN recipient.

Before (origin/main 0159171). NDA-2026-0016 (owner requester1, sys_user.locale zh-CN) went through approval: counsel2 decided the open deviation and the review and sent it for approval, and executive approved rung 1. requester1's bell read Contract approved: 双向保密协议 — 铜田商旅 / Your contract … has cleared every approval rung …. sys_email.subject was the same English. This confirms the card's premise.

After (this branch):

Triggered Recipient · sys_user.locale Bell (browser, signed in as the recipient) sys_email.subject
Approval end to end, MSA-2026-0004: manager → finance → executive rungs, approved requester1 · zh-CN 合同已批准:主服务协议 — 索伦特制造 / 你的合同「…」已通过全部审批层级,现在可以发起签署。 合同已批准:主服务协议 — 索伦特制造
Approval rejected at rung 1, ICA-2026-0004 requester1 · zh-CN 合同已驳回:独立承包人协议 — 卡米尔·博尚 / 你的合同「…」在审批中被驳回… 合同已驳回:…
Approval rejected at rung 1, MSA-2026-0002 requester2 · en Contract rejected: 主服务协议 — 北风物流 / Your contract … was rejected in approval. … Contract rejected: …
Approval rejected at rung 1, MSA-2026-0006 requester3 · unset (deployment default en) Contract rejected: 主服务协议 — 玄武能源 / … Contract rejected: …
Signing round completed with the required countersigned copy unrecorded, MSA-2026-0007 counsel1 · zh-CN 执行形式未完成:主服务协议 — 静谧传媒 / …这份合同不能生效:回签副本已收到。 执行形式未完成:…
Signing round completed, nothing required, no executed copy, NDA-2026-0007 counsel1 · zh-CN 缺少执行副本:双向保密协议 — 静谧传媒 / 这一签署轮次已经完成… 缺少执行副本:…
Signing round completed with the countersigned copy unrecorded, SUP-2026-0004 counsel2 · en Execution formalities outstanding: 供应商协议 — 渡鸦安保 / … : Countersigned copy returned. Execution formalities outstanding: …

No delivery failed (sys_notification_delivery with status other than success: 0 rows). The metadata API serves all 20 members (GET /api/v1/meta/email_template: 10 names × en-US + zh-CN). The boot banner shows no degraded capability. Two console errors in the browser, 404 and 401 on resource loads, show identically on origin/main (before run) and are not from this change.

NOT MEASURED in the browser: the four daily sweeps (renewal decision due, expired, renewal drafted, 30/60 days in review, waiting on the counterparty). They have no on-demand door. POST /api/v1/automation/expiration_sweep/trigger (and …/turn_stalled/trigger) as the dev admin (tried on the before boot; the refusal is the platform's flow-start rule, not this change) answers 403 PERMISSION_DENIED: "This caller may not start this flow. A flow that runs on its own trigger starts there…". The cron is 0 6/7 * * * UTC. Per the round's rule, no alternate route was taken.

What covers them instead is a render proof through the platform's own code. All 10 bundles were rendered by plugin-email 18.2.0's EmailService.renderTemplate, the call the inbox channel makes, over createRegistryEmailTemplateLoader fed allEmailTemplates. Each bundle ran for recipient locales zh-CN, en and fr-FR. Result: bundles=10 members=20 failures=0. zh-CN rendered the Chinese member, en and fr-FR fell to the en-US member, and no {{ hole was left unfilled.

Gates (head c4423f7)

  • pnpm install: exit 0
  • pnpm validate: exit 0. The 7 diagnostics are byte-identical to origin/main's (diffed against a git archive 0159171 snapshot).
  • pnpm lint: exit 0, 0 warnings, 6 suggestions, identical to origin/main.
  • pnpm typecheck: exit 0
  • pnpm lint:i18n-gate: exit 0 (✓ i18n gate … COVERAGE : 0 missing keys across 2 locale(s))
  • CLM_DEMO_SEED=1 pnpm validate: exit 0

Acceptance notes

  • Same defect, outside this card's file surface: src/flows/obligation-due.flow.ts (due in 7 days / due today / overdue) and src/flows/payment-overdue.flow.ts (instalment overdue) still send inline English. The card did not list them and the claim did not include them. With this PR the move for each is three lines: a bundle plus template / templateData on the rowBody notice.
  • review_started_at and turn_since are datetimes and render as raw ISO (2026-09-12T00:00:00.000Z) in both members, exactly as the inline English did. Formatting them (for example | date:iso) would change the English text, so it is left out of this card.
  • File surface: besides the notify nodes and the new src/email-templates/, this PR edits objectstack.config.ts (one emailTemplates: registration, which the platform requires for an app to declare templates), _daily-sweep.ts (the builder that emits four of the ten notify nodes), and signatureExecution (the zh-CN formality list).

🤖 Generated with Claude Code

https://claude.ai/code/session_017nzWFRUo2U7evMkPdVniAn

…emplates

Every notify node in the approval, signature, renewal-notice, expiry,
legal-review SLA and stalled-turn flows wrote its words inline in `title` /
`message`, which NotifyConfigSchema defines as one text for every
recipient. A zh-CN user's bell and mail read English.

Each node now names an `email_template` bundle (`template`) and fills its
holes from `templateData`. Each bundle has an en-US member (the resolver's
fallback floor, carrying the unchanged English sentence) and a zh-CN member.
The delivery path picks the member per recipient, from sys_user.locale or
else the deployment default, for the inbox and the email channel alike.

The missing-formalities notice passes the formality list in both
languages, because the words are option labels computed in the flow.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_017nzWFRUo2U7evMkPdVniAn
@objectstack-fleet

Copy link
Copy Markdown
Contributor Author

席位核对 — ACCEPT · head c4423f7 · 2026-10-27T11:11Z

check reading
shape draft → main, Fixes #160; mergeable clean
CI on the head both Validate check-runs success on c4423f7 = PR head.sha
scope 16 files (+409/−27): ten notify nodes move to template + templateData, with new bundles in src/email-templates/ (en-US + zh-CN members)
surface three places sit beyond the claim's letter, and the seat accepts them: the one emailTemplates registration line in objectstack.config.ts (the platform requires it); _daily-sweep.ts rowBody, which builds four of the ten nodes; and signatureExecution's zh-CN formality list. RenewalStartFlow is untouched, as the seat asked. Nothing governed; lint 0 warnings
the defect measured live with the declared staff. Before: a zh-CN requester's bell read 'Contract approved: …' in English. After: approved, rejected, executed-copy-missing and formalities-outstanding each arrive in the recipient's own language, zh-CN or en. A recipient with no locale gets the deployment default. All 7 emails had a subject in the bell's language, status sent, with 0 failed
not measured live the daily sweeps (renewal due, expired, renewal drafted, review 30/60, turn stalled): an admin cannot start a system-run schedule flow on demand on 18.2.0 (403). All ten bundles were rendered through plugin-email's own renderTemplate for zh-CN, en and fr-FR: 20 members, 0 failures, no unfilled hole
en-US member the 18.2.0 resolver's only fallback is the literal en-US, so an en member would leave other locales with no floor. Accepted
follow-up obligation-due.flow.ts and payment-overdue.flow.ts still send inline English. The card did not list them; the seat files a follow-up card

Landing: under the maintainer's merge authorization (project thread: 「你可以自己审核的就自己合并」).


Generated by Claude Code

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

2 participants