Repository navigation
Commit 2f656af
feat(platform-objects): the System Overview datasets carry synonyms and a description on their seven members (#34992)
🤖 Generated with [Claude Code](https://claude.com/claude-code)
https://claude.ai/code/session_01WGufzi3ezPzTysQPDEjmVz
Fixes #34921
repo:objectstack#3 · os-support-ai · session_01WGufzi3ezPzTysQPDEjmVz
Clause-②: no
Metadata-protocol: none
## 维护者速读
-
**改了什么**:平台自带的“系统概览”五个数据集(用户、组织、会话、安装包、审计日志)里的七个指标/维度,现在都有了中英文同义词和一句业务定义;业务定义在
11 种语言包里都有翻译。
- **为什么改**:管理员问“有多少用户”/ "how many users"
时,问数工具只能靠指标名或当前语言的标签去匹配,平台自己的指标反而查不到;现在这些问法能直接命中 `user_count`。
- **风险与回滚**:只改元数据和语言包,不动 spec、规则和运行时代码;最坏情况是某个同义词选得不准,回滚就是还原
`system.datasets.ts` 和语言包这一个 PR。
- **先看**:①
`packages/platform-objects/src/apps/dashboards/system.datasets.ts`(七组同义词,看措辞准不准、有没有两个指标抢同一个词);②
`packages/rest/src/system-overview-dataset-vocabulary.test.ts`(真实数据集走真实
`list_datasets` 的钉子);③
`packages/platform-objects/src/apps/translations/zh-CN.ts` 的 `datasets`
段。
- **两分钟验证**:`pnpm --filter @objectstack/rest exec vitest run
src/system-overview-dataset-vocabulary.test.ts`(需先构建
platform-objects),预期 8 个用例全绿。
- **需要你做的**:无,席位落地。
## What changes
The five System Overview datasets
(`packages/platform-objects/src/apps/dashboards/system.datasets.ts`)
gain ADR-0149 D1 vocabulary on all seven members:
| Dataset | Member | Synonyms (one authored array, never bundled) |
|---|---|---|
| `sys_user_metrics` | measure `user_count` | 用户, 用户数, 用户数量, 用户总数,
有多少用户, users, user count, number of users, total users, how many users |
| `sys_organization_metrics` | measure `org_count` | 组织, 组织数, 组织数量,
组织总数, 有多少组织, organizations, orgs, organization count, number of
organizations, how many organizations |
| `sys_session_metrics` | measure `session_count` | 会话, 会话数, 会话数量, 登录会话,
有多少会话, sessions, session count, number of sessions, login sessions, how
many sessions |
| `sys_package_installation_metrics` | measure `package_count` | 已安装的包,
安装的包数, 包安装数, 装了多少包, installations, installed packages, package
installations, package count, number of installed packages, how many
packages are installed |
| `sys_audit_log_metrics` | dimension `action` | 操作类型, 动作, 审计动作, action
type, operation, audit action |
| `sys_audit_log_metrics` | dimension `user_id` | 操作人, 操作者, 执行人, 操作用户,
actor, performed by, acting user |
| `sys_audit_log_metrics` | measure `event_count` | 事件, 事件数, 审计事件,
审计事件数, 审计日志条数, 有多少审计事件, events, event count, audit events, audit log
entries, how many audit events |
Each member also gets a one-sentence `description`. That text is display
copy, so it has a bundle entry at
`datasets.NAME.{measures,dimensions}.MEMBER.description` in all eleven
Setup bundle locales (en mirrors the source verbatim; zh-CN, zh-Hant,
ja-JP, ko, es-ES, fr, pt-BR, de, ru and ar are hand-translated, as the
existing `datasets.*.label` rows are). Each translated locale records
the new paths' source digests in its hand-maintained
`LOCALE.source-hashes.ts`, written the same way the label rows were
(`collectSourceHashes(en)`; the existing label digests reproduce
byte-for-byte). No `*.generated.ts` file changes, and no generator
output moves.
**How the matcher treats these words.** `matchDatasetTerms`
(service-analytics) compares a term with a member's name, label and
synonyms by EQUALITY after `normalizeDatasetTerm`. It never matches a
substring or a single word inside a phrase. So a multi-word term such as
"how many users" resolves only where a member writes that exact phrase
as one synonym. I chose to write the administrator's phrasing (`how many
users`, `有多少用户`) as synonyms, plus the term forms a model lifts from a
question (`user count`, `用户数`). A longer question with no exact hit,
such as "how many users do we have", still gets only near `candidates`
(containment, two code points or more), which means a clarifying
question. That behaviour is unchanged.
**Collisions.** Within one dataset, the schema's vocabulary refinement
judges collisions (full `DatasetSchema.safeParse` is green for all
five). Across the five datasets, no synonym is a word of another
*measure* in any locale, and a new test pins that. The one cross-member
equality is 「用户」: it is a `user_count` synonym and also the existing
zh-CN label of the `user_id` dimension. In zh-CN the two labels already
met before this PR. A dimension match picks no number, so the word still
answers with `user_count`. In other locales the synonym adds the only
match.
The other language's bare label is listed on purpose (`users` beside
「用户」). The label a caller is matched against is the one served in the
caller's locale, so under zh-CN the English label `Users` is not a match
target.
No spec, schema, protocol or vocabulary-rule change. The rule's module
note ("It answers to no synonym unless its source writes one") stays
true; the source now writes them.
## Tests
- `packages/rest/src/system-overview-dataset-vocabulary.test.ts` (new)
puts the pin where these datasets meet the dataset tools without new
wiring: `@objectstack/rest` already depends on both
`@objectstack/platform-objects` and `@objectstack/service-analytics`. It
feeds the REAL datasets, localized by the REAL Setup bundle through
`translateDataset`, to the REAL `list_datasets` of an
`AnalyticsServicePlugin`-booted service. The objects behind the datasets
are declaration doubles. Under `en` and `zh-CN`:
- `terms: ['用户数']` matches exactly
`sys_user_metrics.measures.user_count`, on `synonym`, and has no
`candidates`;
- `terms: ['how many users']` matches the same member the same way;
- the control `terms: ['营收', 'revenue']` matches nothing and has no
`candidates`;
- under zh-CN, the catalogue lists `user_count`'s description from the
bundle.
- `system-overview-dataset-translations.test.ts` gains a top-level
`describe` in the existing harness file:
- all seven members declare a Chinese and an English synonym and a
description;
- each dataset survives a full parse;
- no synonym is another measure's word in any locale;
- the en bundle copies each description verbatim;
- no translated locale serves the English description.
<details><summary>Test runs (head 82b53be)</summary>
```
pnpm --filter @objectstack/rest exec vitest run --maxWorkers=2 src/system-overview-dataset-vocabulary.test.ts
Test Files 1 passed (1)
Tests 8 passed (8)
pnpm --filter @objectstack/platform-objects test
Test Files 123 passed (123)
Tests 2060 passed (2060)
pnpm --filter @objectstack/platform-objects typecheck -> exit 0
pnpm --filter @objectstack/rest typecheck -> exit 0 (test layer: 0 files / 0 errors held)
```
</details>
<details><summary>Ablation: drop user_count's synonyms, the pin goes
red</summary>
The ablation ran through `scripts/ablation-replace.mjs`, which deleted
the `user_count` `synonyms` array. Then `pnpm --filter
@objectstack/platform-objects build`, then `node
scripts/ablation-dist-preflight.mjs @objectstack/platform-objects "total
users" --absent` (exit 0: the marker is gone from `dist/`).
```
MUTANT test exit=1
× en: 「用户数」 resolves to user_count alone, by its declared synonym
× en: "how many users" resolves to user_count alone, by its declared synonym
× zh-CN: 「用户数」 resolves to user_count alone, by its declared synonym
× zh-CN: "how many users" resolves to user_count alone, by its declared synonym
Tests 4 failed | 4 passed (8)
```
The 4 that stayed green are the listing, the two controls and the
description case, which is what you would expect.
Restore: `ablation-replace: ok restored: blob == HEAD (b3d4784) and
git diff HEAD is empty`. After a rebuild the preflight found the marker
present in 4 built files with a clean tree, and the suite went back to
`Tests 8 passed (8)`.
</details>
## Acceptance notes
- **i18n baseline moved by 0.** `scripts/i18n-coverage-baseline.json`
holds `packages/platform-objects/scripts/i18n-extract.config.ts: 0`
before and after, and `node scripts/check-i18n-coverage.mjs` reports `OK
(14 config(s), 423 baselined untranslated string(s), none new)`. The
extract config declares no `datasets`, so the ratchet's population does
not include these rows in either direction. The new strings are held
instead by the translation test above (every locale translated, en
verbatim).
- The synonyms are Simplified Chinese and English only.
`normalizeDatasetTerm` does not fold Traditional to Simplified, so a
zh-Hant administrator typing 「使用者數」 matches only the zh-Hant label
「使用者」, and only in that locale. This is noted here, not filed.
- `sys_package_installation` is cloud-only. Where the object is absent,
its dataset is left out of `list_datasets`, and the synonyms are
harmless there.
## Verification
<details><summary>Derived gate families (63) and
reconciliation</summary>
`node scripts/pm/dispatch-gates.mjs --commands --repo
objectstack-ai/objectstack` derived 63 families from merge base
fb5c42d, tree 82b53be. All 63 ran locally.
Three exited 3 (PREREQUISITE NOT MET) on the first pass and were re-run
once the prerequisite held, each exit 0:
- `pnpm check:i18n`, after the CLI and extract-closure build: `OK (10
package(s) — all bundles in sync, no undeclared authoring keys)`;
- `pnpm check:dual-build-cjs-loads`, after a full workspace build: `124
published require entry point(s) across 72 package(s) load`;
- `node scripts/check-plugin-teardown-shape.mjs --self-test`, after
fetching its pinned fixture commit into the shallow clone: `48 cases
pass`.
The dist-reading gates were re-run after the full build, all exit 0:
`check:dts-closure`, `check:published-files`,
`check:lean-entry-closure`, `check:sourcemap-no-sources-content`,
`check-dts-emitted --self-test`.
```
Run reconciliation — 63 derived, 63 run, 0 NOT-MEASURED, 0 UNRUN.
✓ dispatch-gates --ran: 63 derived famil(ies) accounted for — 63 run, 0 NOT-MEASURED
```
`overlap-check` before each push: `VERDICT clean exit 0` against
origin/main and #34799, which shares the locale bundles and merges
cleanly.
</details>
The rest of the `@objectstack/rest` suite was not re-run locally: this
PR adds one test file there and changes no rest source. CI's `Test Core`
runs it.
<!-- signed: repo:objectstack#3 · os-support-ai ·
session_01WGufzi3ezPzTysQPDEjmVz -->
---------
Co-authored-by: Claude <noreply@anthropic.com>1 parent 38a1433 commit 2f656af
25 files changed
Lines changed: 907 additions & 78 deletions
File tree
- .changeset
- packages
- platform-objects/src/apps
- dashboards
- translations
- rest/src
| 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 | + | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
16 | 16 | | |
17 | 17 | | |
18 | 18 | | |
| 19 | + | |
19 | 20 | | |
20 | 21 | | |
21 | 22 | | |
22 | 23 | | |
23 | 24 | | |
24 | | - | |
| 25 | + | |
25 | 26 | | |
26 | 27 | | |
27 | 28 | | |
| |||
107 | 108 | | |
108 | 109 | | |
109 | 110 | | |
| 111 | + | |
| 112 | + | |
| 113 | + | |
| 114 | + | |
| 115 | + | |
| 116 | + | |
| 117 | + | |
| 118 | + | |
| 119 | + | |
| 120 | + | |
| 121 | + | |
| 122 | + | |
| 123 | + | |
| 124 | + | |
| 125 | + | |
| 126 | + | |
| 127 | + | |
| 128 | + | |
| 129 | + | |
| 130 | + | |
| 131 | + | |
| 132 | + | |
| 133 | + | |
| 134 | + | |
| 135 | + | |
| 136 | + | |
| 137 | + | |
| 138 | + | |
| 139 | + | |
| 140 | + | |
| 141 | + | |
| 142 | + | |
| 143 | + | |
| 144 | + | |
| 145 | + | |
| 146 | + | |
| 147 | + | |
| 148 | + | |
| 149 | + | |
| 150 | + | |
| 151 | + | |
| 152 | + | |
| 153 | + | |
| 154 | + | |
| 155 | + | |
| 156 | + | |
| 157 | + | |
| 158 | + | |
| 159 | + | |
| 160 | + | |
| 161 | + | |
| 162 | + | |
| 163 | + | |
| 164 | + | |
| 165 | + | |
| 166 | + | |
| 167 | + | |
| 168 | + | |
| 169 | + | |
| 170 | + | |
| 171 | + | |
| 172 | + | |
| 173 | + | |
| 174 | + | |
| 175 | + | |
| 176 | + | |
| 177 | + | |
| 178 | + | |
| 179 | + | |
| 180 | + | |
| 181 | + | |
| 182 | + | |
| 183 | + | |
| 184 | + | |
| 185 | + | |
| 186 | + | |
| 187 | + | |
| 188 | + | |
| 189 | + | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
9 | 9 | | |
10 | 10 | | |
11 | 11 | | |
| 12 | + | |
| 13 | + | |
| 14 | + | |
| 15 | + | |
| 16 | + | |
| 17 | + | |
| 18 | + | |
| 19 | + | |
| 20 | + | |
| 21 | + | |
| 22 | + | |
| 23 | + | |
| 24 | + | |
| 25 | + | |
| 26 | + | |
| 27 | + | |
| 28 | + | |
| 29 | + | |
| 30 | + | |
12 | 31 | | |
13 | 32 | | |
14 | 33 | | |
15 | 34 | | |
16 | 35 | | |
17 | 36 | | |
18 | 37 | | |
19 | | - | |
| 38 | + | |
| 39 | + | |
| 40 | + | |
| 41 | + | |
| 42 | + | |
| 43 | + | |
| 44 | + | |
| 45 | + | |
| 46 | + | |
| 47 | + | |
20 | 48 | | |
21 | 49 | | |
22 | 50 | | |
23 | 51 | | |
24 | 52 | | |
25 | 53 | | |
26 | 54 | | |
27 | | - | |
| 55 | + | |
| 56 | + | |
| 57 | + | |
| 58 | + | |
| 59 | + | |
| 60 | + | |
| 61 | + | |
| 62 | + | |
| 63 | + | |
| 64 | + | |
28 | 65 | | |
29 | 66 | | |
30 | 67 | | |
31 | 68 | | |
32 | 69 | | |
33 | 70 | | |
34 | 71 | | |
35 | | - | |
| 72 | + | |
| 73 | + | |
| 74 | + | |
| 75 | + | |
| 76 | + | |
| 77 | + | |
| 78 | + | |
| 79 | + | |
| 80 | + | |
| 81 | + | |
36 | 82 | | |
37 | 83 | | |
38 | 84 | | |
39 | 85 | | |
40 | 86 | | |
41 | 87 | | |
42 | 88 | | |
43 | | - | |
| 89 | + | |
| 90 | + | |
| 91 | + | |
| 92 | + | |
| 93 | + | |
| 94 | + | |
| 95 | + | |
| 96 | + | |
| 97 | + | |
| 98 | + | |
| 99 | + | |
44 | 100 | | |
45 | 101 | | |
46 | 102 | | |
47 | 103 | | |
48 | 104 | | |
49 | 105 | | |
50 | 106 | | |
51 | | - | |
| 107 | + | |
| 108 | + | |
| 109 | + | |
| 110 | + | |
| 111 | + | |
| 112 | + | |
| 113 | + | |
| 114 | + | |
| 115 | + | |
52 | 116 | | |
53 | 117 | | |
54 | 118 | | |
| |||
57 | 121 | | |
58 | 122 | | |
59 | 123 | | |
| 124 | + | |
| 125 | + | |
| 126 | + | |
60 | 127 | | |
61 | 128 | | |
62 | 129 | | |
63 | | - | |
| 130 | + | |
| 131 | + | |
| 132 | + | |
| 133 | + | |
| 134 | + | |
| 135 | + | |
| 136 | + | |
| 137 | + | |
| 138 | + | |
| 139 | + | |
| 140 | + | |
64 | 141 | | |
65 | 142 | | |
66 | 143 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
182 | 182 | | |
183 | 183 | | |
184 | 184 | | |
| 185 | + | |
185 | 186 | | |
| 187 | + | |
186 | 188 | | |
| 189 | + | |
187 | 190 | | |
| 191 | + | |
188 | 192 | | |
| 193 | + | |
189 | 194 | | |
| 195 | + | |
190 | 196 | | |
| 197 | + | |
191 | 198 | | |
192 | 199 | | |
193 | 200 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
187 | 187 | | |
188 | 188 | | |
189 | 189 | | |
190 | | - | |
191 | | - | |
192 | | - | |
193 | | - | |
| 190 | + | |
| 191 | + | |
| 192 | + | |
| 193 | + | |
| 194 | + | |
| 195 | + | |
| 196 | + | |
| 197 | + | |
| 198 | + | |
| 199 | + | |
| 200 | + | |
| 201 | + | |
| 202 | + | |
| 203 | + | |
| 204 | + | |
| 205 | + | |
| 206 | + | |
| 207 | + | |
| 208 | + | |
| 209 | + | |
| 210 | + | |
| 211 | + | |
| 212 | + | |
| 213 | + | |
| 214 | + | |
| 215 | + | |
| 216 | + | |
| 217 | + | |
| 218 | + | |
| 219 | + | |
| 220 | + | |
| 221 | + | |
194 | 222 | | |
195 | | - | |
196 | | - | |
| 223 | + | |
| 224 | + | |
| 225 | + | |
| 226 | + | |
| 227 | + | |
| 228 | + | |
| 229 | + | |
| 230 | + | |
| 231 | + | |
| 232 | + | |
| 233 | + | |
| 234 | + | |
| 235 | + | |
| 236 | + | |
| 237 | + | |
| 238 | + | |
197 | 239 | | |
198 | 240 | | |
199 | 241 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
183 | 183 | | |
184 | 184 | | |
185 | 185 | | |
| 186 | + | |
186 | 187 | | |
| 188 | + | |
187 | 189 | | |
| 190 | + | |
188 | 191 | | |
| 192 | + | |
189 | 193 | | |
| 194 | + | |
190 | 195 | | |
| 196 | + | |
191 | 197 | | |
| 198 | + | |
192 | 199 | | |
193 | 200 | | |
194 | 201 | | |
| |||
0 commit comments