Repository navigation
Commit 9b99640
feat(spec,plugin-audit): an activity milestone's timeline row reads in the reader's language (#37582)
<!-- claude-projects-attribution: {"github_login":"os-sales"} -->
_Requested by **Sales** · [project
thread](https://claude.ai/code/project/chan_01D5bWFY3rFzgJcytD5gD4Uu?thread=cmsg_01D5bWFY3rFzgJcytD5gD4UuPE7uyDAJyqjwwMzomWv5ff)_
Fixes #37524
Clause-②: yes (widening)
Metadata-protocol: added
Skills-docs: follow-up #37585
## 维护者速读
-
用户能看到什么变化:应用声明的「活动里程碑」(例如工单关闭、商机赢单)写在记录时间线上的那一行,现在按读者的语言显示:应用在翻译包里给这条里程碑写了中文模板,中文用户看到的就是中文句子,句子里的下拉值也显示成中文选项名;没写译文的语言照旧显示作者原文。
- 为什么做:以前这一行永远是作者写的语言,翻译包里没有放它的位置,应用自己没法改(HotCRM 的工单、商机时间线就是这样)。
-
出错会怎样:存下来的行文字不变,只在读的时候换成译文;译文缺失、读请求不带语言、或者是这次改动之前写的旧行,都显示原文。字段权限的遮蔽规则照旧:读者看不到的字段参与拼出的句子,任何语言下都不给。
- 要你做什么:无。技能文档 `skills/objectstack-i18n` 补一句的后续卡是 #37585。
## What changes
**The reading** (at `4116465625`): the timeline already serves most rows
in the reader's language — the CRUD mirror stores a summary CODE beside
the sentence and the `sys_activity` read middleware re-composes it per
reader
(`packages/plugins/plugin-audit/src/activity-summary-message.ts`). A
fired milestone was the one row left out, by an implementation note in
that file ("its template is the author's sentence and is never
translated"), and `ObjectTranslationDataSchema` had no key the template
could be translated under. ADR-0052 §5b.2 defines the milestone and says
nothing about its language.
- **Spec, translation slot**
(`packages/spec/src/system/translation.zod.ts`). An object translation
accepts `_milestones: { <field>: { <value>: { summary } } }`. A
milestone declares no name; the watched `field` and the `value` it fires
on are what fire it (the writer fires the first declared match), so the
pair is its address and no new authorable key is added to
`activityMilestones`. `milestones` and `activityMilestones` are refused,
and the refusal names `_milestones` as the key to write (as
`validations` names `_validations`).
- **Spec, resolver** (`packages/spec/src/system/i18n-resolver.ts`).
`resolveObjectMilestoneSummary(bundle, object, field, value, opts)`
reads the template along the locale chain; a dotted value is one key. It
is deliberately NOT overlaid by `translateObject`: an object served by
`/meta` with the translated template on it would round-trip into the
authored declaration on the next Studio save. A pin holds that
`translateObject` leaves `activityMilestones[].summary` as authored.
- **Writer** (`packages/plugins/plugin-audit/src/audit-writers.ts`). A
fired milestone's row now carries `metadata.summary_message` = `{ key:
'activityMilestone', object, field, value, tokens }`, each token stored
as the field-change code stores a value: the text the writer rendered,
plus the select option it matched. The stored `summary` is unchanged
(the authored sentence, rendered as before), and so are `type`,
`metadata.kind` and the text sources the redaction reads.
- **Reader** (`activity-summary-message.ts`). `readerSummaryLocale`
gains `milestoneSummary`, which reads the template from the same bundle
and `ResolveOptions` the labels are translated with.
`composeActivitySummary` interpolates it: a select token is named by the
option label on the reader-language object definition, any other token
by its stored text, and a token with no stored value (a token the
translation adds, or an empty value) renders empty, as an empty value
does in the authored sentence. No template for the reader's language ⇒
nothing is composed and the stored sentence stands. A tenant that
reworded a packaged milestone's `summary` keeps its words (ADR-0029
D9.2a, judged as a reworded validation message is: the served milestone
against the packaged one of the same pair, through the resolver's one
predicate `scalarOverridesPackagedBase`, whose key union gains
`'summary'`; an empty served summary is no rewording, so the catalog
still applies). The code is stripped from `metadata` for every
non-system reader, as the other non-field-change codes are.
- **Redaction, unchanged.** The milestone's token fields were already
the summary's declared text sources, so a reader not served one has the
`summary` dropped before this middleware runs; the middleware only
overlays a `summary` still present, so it never re-adds a dropped one.
Pinned below.
- **Lint.** The extractor (`i18n-walk.ts`) scaffolds
`objects.<o>._milestones.<field>.<value>.summary` for each pair, the
first entry of a repeated pair only. The translation-reference rule
(`validate-translation-references.ts`) flags a `_milestones` key over a
pair no milestone of the object declares, suggesting the near value.
- **Example.** `examples/app-showcase` translates its one milestone
(`showcase_task`, `status` → `done`) in zh-CN, so the extractor's new
key is translated where the coverage gate measures it.
- **Docs.** `content/docs/ui/translations.mdx` (the key table) and
`content/docs/protocol/kernel/i18n-standard.mdx` (the reference rule's
table) name the key. `content/docs/references/system/translation.mdx`,
`api-surface/system.json`, `export-origins/system.json` and the
strictness-ledger count (`system/` 409 → 410, the new strict object)
regenerated by `check:generated --fix`.
Small calls made here (no card): the `field` + `value` address rather
than a new `name` on a milestone; a boolean token keeps rendering its
stored value (as the authored sentence does today) rather than a
per-locale yes/no word; token texts are not length-bounded in the code
(the authored sentence they come from is not bounded either).
Left as they are after contract review (optional, noted here): N3, the
`{token}` pattern is spelled twice (writer and reader); N4, the reader
asks `getPackagedObjectBase` twice per row with no cache. Neither
changes an answer.
## Why
An app that is otherwise fully translated still wrote authoring-language
rows ("Case escalated — …") on the record timeline, with no key it could
fill in.
## Verification
-
`packages/plugins/plugin-audit/src/activity-milestone-summary-locale.integration.test.ts`
(new; real kernel, real audit writer, SQLite, the engine middleware
chain): a zh-CN reader reads `商机赢单:Acme(赢单)` from the zh-CN template
with the `{stage}` token named by its zh-CN option label; the system, an
en reader, a read with no locale and a ja-JP reader (no entry) read the
stored `Deal won: Acme (Won)`; the code is stored for the system and
served to no other caller; a reader not served a token's field (`note`)
gets the row with no `summary`. Red first: with the composer's template
lookup stubbed out, the zh-CN pin and the redaction pin's served half
fail (2 of 4).
- `activity-summary-message.test.ts`, new describe: composes the
translated template, an unstored token empty; nothing composed for a
locale with no entry or on a locale with no `milestoneSummary`; a
tenant's rewording of the packaged milestone keeps its words while the
untouched one translates, and an emptied one still translates (fails
with the earlier local copy of the comparison); the stored code reads
back and a malformed one is refused.
- `packages/spec/src/system/i18n-milestone-summary.test.ts` (new): the
key is read by pair, a dotted value as one key, along the fallback
chain, `undefined` on misses; the schema accepts the group and refuses a
key it does not declare; `translateObject` leaves the authored summary.
- `packages/lint/src/i18n-milestones-37524.test.ts` (new): the extractor
emits one key per fired pair seeded with the authored template; the
reference rule resolves declared pairs and flags an undeclared value
(with the suggestion) and an unwatched field.
- `validate-translation-references.test.ts`: the #13835 object-branch
coverage ledger classifies `_milestones` as reference-checked, backed by
a ghost that reports, and the all-groups control bundle names the real
pair.
- Local runs at `92e8e1bcf`: `@objectstack/plugin-audit` vitest 110
files / 1,840 tests pass; `@objectstack/lint` vitest 237 files / 9,683
tests pass (the one red, the coverage ledger, fixed in the tip commit
and re-run: 268/268); `@objectstack/spec` vitest `src/system` pass;
`node scripts/check-i18n-bundles.mjs` exit 0; eslint on the touched
files exit 0; `tsc --noEmit` for plugin-audit exit 0; `pnpm --filter
@objectstack/spec check:generated` exit 0; `node
scripts/pm/overlap-check.mjs` exit 0. `check:i18n-coverage` needs the
built examples and is left to CI.
Contract review (L2) is owed before landing: the diff changes
`packages/spec/src/**` and declares `Clause-②: yes (widening)`.
## Human Minimum
- [x] 1. Schemas start as Zod; `packages/spec` holds no runtime logic.
- [x] 2. Every name I added uses the casing for its kind.
- [x] 3. No formatter ran; `pnpm lint` passes.
- [x] 4. One issue, one branch off an up-to-date `main`, one pull
request.
- [x] 5. A change that publishes carries a changeset, and both
declaration lines are filled in here and in the changeset.
- [x] 6. `packages/spec` touched: its generated artifacts are
regenerated and committed.
- [x] 7. No hand edits to `content/docs/references/`,
`packages/*/CHANGELOG.md` or `content/docs/releases/`.
- [x] 8. Title, body and comments are in English.
- [x] The *Before Submitting* list in CONTRIBUTING.md is done.
🤖 Generated with [Claude Code](https://claude.com/claude-code)
https://claude.ai/code/session_01L6bhgUpnvPnJ1hR74pUrVj
---
_Generated by [Claude
Code](https://claude.ai/code/session_01L6bhgUpnvPnJ1hR74pUrVj)_
<!-- signed: repo:objectstack#2 · os-sales ·
session_01L6bhgUpnvPnJ1hR74pUrVj -->
---------
Co-authored-by: Claude <noreply@anthropic.com>1 parent f4978d9 commit 9b99640
20 files changed
Lines changed: 640 additions & 19 deletions
File tree
- .changeset
- content/docs
- protocol/kernel
- references/system
- ui
- docs/audits/2026-07-unknown-key-strictness-ledger.counts
- examples/app-showcase/src/system/translations
- packages
- lint/src
- plugins/plugin-audit/src
- spec
- api-surface
- authorable-surface
- export-origins
- src/system
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
| 1 | + | |
| 2 | + | |
| 3 | + | |
| 4 | + | |
| 5 | + | |
| 6 | + | |
| 7 | + | |
| 8 | + | |
| 9 | + | |
| 10 | + | |
| 11 | + | |
| 12 | + | |
| 13 | + | |
| 14 | + | |
| 15 | + | |
| 16 | + | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
1176 | 1176 | | |
1177 | 1177 | | |
1178 | 1178 | | |
| 1179 | + | |
1179 | 1180 | | |
1180 | 1181 | | |
1181 | 1182 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
100 | 100 | | |
101 | 101 | | |
102 | 102 | | |
| 103 | + | |
103 | 104 | | |
104 | 105 | | |
105 | 106 | | |
| |||
169 | 170 | | |
170 | 171 | | |
171 | 172 | | |
| 173 | + | |
| 174 | + | |
| 175 | + | |
| 176 | + | |
| 177 | + | |
| 178 | + | |
172 | 179 | | |
173 | 180 | | |
174 | 181 | | |
| |||
224 | 231 | | |
225 | 232 | | |
226 | 233 | | |
| 234 | + | |
227 | 235 | | |
228 | 236 | | |
229 | 237 | | |
| |||
415 | 423 | | |
416 | 424 | | |
417 | 425 | | |
| 426 | + | |
418 | 427 | | |
419 | 428 | | |
420 | 429 | | |
| |||
669 | 678 | | |
670 | 679 | | |
671 | 680 | | |
| 681 | + | |
672 | 682 | | |
673 | 683 | | |
674 | 684 | | |
| |||
892 | 902 | | |
893 | 903 | | |
894 | 904 | | |
| 905 | + | |
895 | 906 | | |
896 | 907 | | |
897 | 908 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
79 | 79 | | |
80 | 80 | | |
81 | 81 | | |
| 82 | + | |
82 | 83 | | |
83 | 84 | | |
84 | 85 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
19 | 19 | | |
20 | 20 | | |
21 | 21 | | |
22 | | - | |
| 22 | + | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
501 | 501 | | |
502 | 502 | | |
503 | 503 | | |
| 504 | + | |
| 505 | + | |
| 506 | + | |
| 507 | + | |
| 508 | + | |
| 509 | + | |
| 510 | + | |
504 | 511 | | |
505 | 512 | | |
506 | 513 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
| 1 | + | |
| 2 | + | |
| 3 | + | |
| 4 | + | |
| 5 | + | |
| 6 | + | |
| 7 | + | |
| 8 | + | |
| 9 | + | |
| 10 | + | |
| 11 | + | |
| 12 | + | |
| 13 | + | |
| 14 | + | |
| 15 | + | |
| 16 | + | |
| 17 | + | |
| 18 | + | |
| 19 | + | |
| 20 | + | |
| 21 | + | |
| 22 | + | |
| 23 | + | |
| 24 | + | |
| 25 | + | |
| 26 | + | |
| 27 | + | |
| 28 | + | |
| 29 | + | |
| 30 | + | |
| 31 | + | |
| 32 | + | |
| 33 | + | |
| 34 | + | |
| 35 | + | |
| 36 | + | |
| 37 | + | |
| 38 | + | |
| 39 | + | |
| 40 | + | |
| 41 | + | |
| 42 | + | |
| 43 | + | |
| 44 | + | |
| 45 | + | |
| 46 | + | |
| 47 | + | |
| 48 | + | |
| 49 | + | |
| 50 | + | |
| 51 | + | |
| 52 | + | |
| 53 | + | |
| 54 | + | |
| 55 | + | |
| 56 | + | |
| 57 | + | |
| 58 | + | |
| 59 | + | |
| 60 | + | |
| 61 | + | |
| 62 | + | |
| 63 | + | |
| 64 | + | |
| 65 | + | |
| 66 | + | |
| 67 | + | |
| 68 | + | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
85 | 85 | | |
86 | 86 | | |
87 | 87 | | |
| 88 | + | |
| 89 | + | |
88 | 90 | | |
89 | 91 | | |
90 | 92 | | |
| |||
1002 | 1004 | | |
1003 | 1005 | | |
1004 | 1006 | | |
| 1007 | + | |
| 1008 | + | |
| 1009 | + | |
| 1010 | + | |
| 1011 | + | |
| 1012 | + | |
| 1013 | + | |
| 1014 | + | |
| 1015 | + | |
| 1016 | + | |
| 1017 | + | |
| 1018 | + | |
| 1019 | + | |
| 1020 | + | |
| 1021 | + | |
| 1022 | + | |
| 1023 | + | |
| 1024 | + | |
| 1025 | + | |
| 1026 | + | |
| 1027 | + | |
| 1028 | + | |
1005 | 1029 | | |
1006 | 1030 | | |
1007 | 1031 | | |
| |||
1653 | 1677 | | |
1654 | 1678 | | |
1655 | 1679 | | |
| 1680 | + | |
| 1681 | + | |
| 1682 | + | |
| 1683 | + | |
| 1684 | + | |
| 1685 | + | |
1656 | 1686 | | |
1657 | 1687 | | |
1658 | 1688 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
3855 | 3855 | | |
3856 | 3856 | | |
3857 | 3857 | | |
| 3858 | + | |
3858 | 3859 | | |
3859 | 3860 | | |
3860 | 3861 | | |
| |||
3920 | 3921 | | |
3921 | 3922 | | |
3922 | 3923 | | |
| 3924 | + | |
| 3925 | + | |
| 3926 | + | |
| 3927 | + | |
| 3928 | + | |
3923 | 3929 | | |
3924 | 3930 | | |
3925 | 3931 | | |
| |||
3955 | 3961 | | |
3956 | 3962 | | |
3957 | 3963 | | |
| 3964 | + | |
3958 | 3965 | | |
3959 | 3966 | | |
3960 | 3967 | | |
| |||
0 commit comments