Repository navigation
Commit 8dbb4a1
feat(example-crm): business vocabulary on crm_opportunity_metrics (ADR-0149 D1) (#31771)
<!-- claude-projects-attribution: {"github_login":"os-steve"} -->
_Requested by **Steve** · [project
thread](https://claude.ai/code/project/chan_01FdL1XeUyvVNxLreh3F4Qi9?thread=cmsg_01FdL1XeUyvVNxLreh3F4Qi94CosmCy4wibc3rRg4ppMsN)_
Fixes #31591
Clause-②: no
Metadata-protocol: none
## 维护者速读
- 改了什么:给示例 CRM 的商机指标数据集(crm_opportunity_metrics)的 3 个维度和 3
个指标都写上业务定义(description)和用户常用说法(synonyms,中英混排,29 个),并补了中文翻译;hotcrm
的九个数据集另立了卡 objectstack-ai/hotcrm#2425。
- 为什么改:ADR-0149 要求 AI 通过数据集语义层回答业务问题,这是第一份真实词汇数据,也是 D5
问数准确率评测的「改前/改后」基线。
- 风险与回滚:只改示例元数据与它的测试,不发布任何包;回滚即还原这三个文件。
-
先看:`examples/app-crm/src/datasets/opportunity.dataset.ts`(总金额的定义:含在途、赢单、输单,既不是在途漏斗也不是已确认收入)、`examples/app-crm/src/translations/crm.translation.ts`、`examples/app-crm/test/smoke.test.ts`。
- 两分钟验证:`pnpm --filter @objectstack/example-crm exec vitest run
test/smoke.test.ts`,预期 24 个用例全绿。
- 需要你做的:无,席位落地。
## What changes
- `crm_opportunity_metrics`: every member (dimensions `stage`,
`account`, `close_date`; measures `opp_count`, `total_amount`,
`avg_amount`) gains a `description` written as a plain business
definition (what it counts, what it excludes; ADR-0149 M1 ruled A, no
model instructions) and `synonyms` a business user would type, English
and Chinese in the one list (D1: synonyms are match input, never
locale-keyed). Near-duplicates of the label were left out (no "total
amount", "average deal size", "opportunities").
- Deliberate choice: a synonym that names a narrower meaning than the
measure is a defect, not a style point (these are D5's first data).
`total_amount` sums open, won and lost deals alike, so it carries no
"revenue" / 「营收」 synonym and no "pipeline value" / 「漏斗金额」 synonym (in
sales usage both mean a subset: won deals, open deals). Its description
says it is neither the open pipeline nor booked revenue, and how to
narrow it to each. `avg_amount` averages every stage, so it carries no
「平均成交额」 (成交 reads as won deals).
- zh-CN bundle: the spec card (#31587) made member `description`
translatable at `datasets.NAME.{dimensions,measures}.MEMBER.description`
(display text, like `label`) and gave `synonyms` no bundle key.
Following that rule, each member description has its zh-CN translation;
no synonym key was invented. The `en` block of this bundle has no
`datasets` section today (the source metadata is English), so none was
added.
- hotcrm half: filed as objectstack-ai/hotcrm#2425 through the relay
(`issue-create.mjs`) with the same rules. Code search on hotcrm's
default branch finds **nine** dataset files, not the eight the card
names (`account_metrics`, `contact_metrics`, `event_metrics`,
`forecast_metrics`, `lead_metrics`, `opportunity_metrics`,
`task_metrics`, `case_metrics`, `product_metrics`); the card asks
hotcrm's lane to confirm scope.
### D5 baseline (before / after, this dataset)
| | members | members with description | synonyms |
|---|---|---|---|
| before (`0105a687`) | 6 (3 dimensions, 3 measures) | 0 | 0 |
| after | 6 | 6 (+ 6 zh-CN translations) | 29 (stage 6, account 6,
close_date 5, opp_count 5, total_amount 4, avg_amount 3) |
No member is left without synonyms.
## Tests
New top-level `describe` in `examples/app-crm/test/smoke.test.ts` (the
example's shared harness file), read on the composed stack:
- the dataset passes `DatasetSchema.safeParse`, vocabulary `superRefine`
included;
- every dimension and measure has a non-empty `description` and at least
one synonym (member roster pinned);
- every member description has a non-empty zh-CN translation that is not
the English text echoed.
No existing test was edited.
Ablation (`scripts/ablation-replace.mjs`, each leg restored to blob ==
HEAD, `git diff HEAD` empty; example source runs under vitest directly,
no dist leg):
- `stage` synonym `'sales stage'` → `'customer'` (collides with
`account`'s synonym): the stack's own load refuses — file collection
fails with `datasets.0.dimensions.1.synonyms.0: synonym "customer" of
dimension "account" is also a synonym of dimension "stage" in this
dataset …` (the composed stack parses before any `it` runs, so the
refusal arrives one layer earlier than the new parse pin).
- delete `avg_amount`'s zh-CN `description`: `× translates every member
description into zh-CN` — `AssertionError: avg_amount: expected false to
be true`.
- delete `avg_amount`'s `synonyms`: `× gives every dimension and measure
a description and at least one synonym` — `AssertionError: avg_amount:
expected 0 to be greater than 0`.
## Acceptance notes
- Changeset: none, `skip-changeset`. `@objectstack/example-crm` is
`private: true`; `.changeset/config.json` versions private packages
(`privatePackages.version: true`) but the package publishes nothing, and
its CHANGELOG has only ever carried dependency bumps. AGENTS.md reserves
a changeset for a diff that publishes.
- Note for a later card, not changed here: `avg_amount`'s existing zh-CN
label 「平均成交额」 reads as "average won-deal amount" while the measure
averages every stage (open, won, lost). The label is out of this card's
scope; a later card could relabel it 「平均商机金额」.
- The term matcher that reads `synonyms` (ADR-0149 D7 card 2,
service-analytics) has not landed; until it does these keys are declared
data with ledger rows `planned`, as D6 states.
## Verification
Head `2d04c9f8` (seat fix round 1 on top of `f17fabe3`: dropped three
synonyms, reworded `total_amount`'s description in en and zh-CN;
`f17fabe3` merged `origin/main`, touching no `examples/` or
`packages/spec` file).
<details><summary>example-crm test + typecheck (lock VERDICT
command-exit 0)</summary>
`pnpm --filter @objectstack/example-crm test && pnpm --filter
@objectstack/example-crm typecheck` on `2d04c9f8` (closure built on
`f17fabe3`; the fix round touched only example source): Test Files 7
passed (7), Tests 51 passed (51), typecheck no errors.
</details>
<details><summary>derived gates</summary>
On `2d04c9f8`, `node scripts/pm/dispatch-gates.mjs --commands --repo
objectstack-ai/objectstack` derived 40 families; all 40 run, every one
exit 0 (`--ran` reconciliation: 40 run, 0 NOT-MEASURED, 0 UNRUN).
```
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/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
pnpm --filter @objectstack/spec run check:duration-unit-keys :: exit 0
pnpm check:ci-filter-parity :: exit 0
pnpm check:cross-package-test-inputs :: 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:examples-live-imports :: exit 0
pnpm check:gitlink-declared :: exit 0
pnpm check:i18n-coverage :: 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:org-identifier :: exit 0
pnpm check:page-declaration-shape :: 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: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:vouch-for-reference-callers :: exit 0
pnpm check:watch-hint-literal :: exit 0
pnpm check:where-matcher :: exit 0
```
</details>
<details><summary>lint</summary>
`pnpm exec eslint --no-inline-config` on the three changed files: exit
0.
</details>
🤖 Generated with [Claude Code](https://claude.com/claude-code)
https://claude.ai/code/session_01ADHkmQaUC9ShR9MNZLdNV4
<!-- signed: domain:server#2 · os-steve ·
session_01ADHkmQaUC9ShR9MNZLdNV4 -->
---------
Co-authored-by: Claude <noreply@anthropic.com>1 parent 7931f81 commit 8dbb4a1
3 files changed
Lines changed: 136 additions & 12 deletions
File tree
- examples/app-crm
- src
- datasets
- translations
- test
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
16 | 16 | | |
17 | 17 | | |
18 | 18 | | |
| 19 | + | |
| 20 | + | |
| 21 | + | |
| 22 | + | |
| 23 | + | |
19 | 24 | | |
20 | | - | |
| 25 | + | |
| 26 | + | |
| 27 | + | |
| 28 | + | |
| 29 | + | |
| 30 | + | |
| 31 | + | |
| 32 | + | |
| 33 | + | |
| 34 | + | |
21 | 35 | | |
22 | 36 | | |
23 | 37 | | |
24 | | - | |
| 38 | + | |
| 39 | + | |
| 40 | + | |
| 41 | + | |
| 42 | + | |
| 43 | + | |
| 44 | + | |
| 45 | + | |
| 46 | + | |
| 47 | + | |
25 | 48 | | |
26 | 49 | | |
27 | | - | |
| 50 | + | |
| 51 | + | |
| 52 | + | |
| 53 | + | |
| 54 | + | |
| 55 | + | |
| 56 | + | |
| 57 | + | |
| 58 | + | |
| 59 | + | |
| 60 | + | |
28 | 61 | | |
29 | 62 | | |
30 | 63 | | |
31 | 64 | | |
32 | 65 | | |
33 | 66 | | |
34 | | - | |
35 | | - | |
36 | | - | |
| 67 | + | |
| 68 | + | |
| 69 | + | |
| 70 | + | |
| 71 | + | |
| 72 | + | |
| 73 | + | |
| 74 | + | |
| 75 | + | |
| 76 | + | |
| 77 | + | |
| 78 | + | |
| 79 | + | |
| 80 | + | |
| 81 | + | |
| 82 | + | |
| 83 | + | |
| 84 | + | |
| 85 | + | |
| 86 | + | |
| 87 | + | |
| 88 | + | |
| 89 | + | |
| 90 | + | |
| 91 | + | |
| 92 | + | |
| 93 | + | |
| 94 | + | |
| 95 | + | |
| 96 | + | |
| 97 | + | |
| 98 | + | |
37 | 99 | | |
38 | 100 | | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
370 | 370 | | |
371 | 371 | | |
372 | 372 | | |
373 | | - | |
374 | | - | |
375 | | - | |
| 373 | + | |
| 374 | + | |
| 375 | + | |
| 376 | + | |
| 377 | + | |
| 378 | + | |
| 379 | + | |
| 380 | + | |
| 381 | + | |
| 382 | + | |
| 383 | + | |
| 384 | + | |
376 | 385 | | |
377 | 386 | | |
378 | | - | |
379 | | - | |
380 | | - | |
| 387 | + | |
| 388 | + | |
| 389 | + | |
| 390 | + | |
| 391 | + | |
| 392 | + | |
| 393 | + | |
| 394 | + | |
| 395 | + | |
| 396 | + | |
| 397 | + | |
| 398 | + | |
381 | 399 | | |
382 | 400 | | |
383 | 401 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
257 | 257 | | |
258 | 258 | | |
259 | 259 | | |
| 260 | + | |
| 261 | + | |
| 262 | + | |
| 263 | + | |
| 264 | + | |
| 265 | + | |
| 266 | + | |
| 267 | + | |
| 268 | + | |
| 269 | + | |
| 270 | + | |
| 271 | + | |
| 272 | + | |
| 273 | + | |
| 274 | + | |
| 275 | + | |
| 276 | + | |
| 277 | + | |
| 278 | + | |
| 279 | + | |
| 280 | + | |
| 281 | + | |
| 282 | + | |
| 283 | + | |
| 284 | + | |
| 285 | + | |
| 286 | + | |
| 287 | + | |
| 288 | + | |
| 289 | + | |
| 290 | + | |
| 291 | + | |
| 292 | + | |
| 293 | + | |
| 294 | + | |
| 295 | + | |
| 296 | + | |
| 297 | + | |
| 298 | + | |
| 299 | + | |
| 300 | + | |
| 301 | + | |
| 302 | + | |
| 303 | + | |
0 commit comments