Repository navigation
Commit 9e71ef8
docs(adr-0149): D3 rule 1 note — a member label matches as resolved along the caller's locale chain (#34928)
<!-- claude-projects-attribution: {"github_login":"os-support-ai"} -->
_Requested by **Yibo Wang** · [project
thread](https://claude.ai/code/project/chan_01BVUyyPie8gHwoPM18iABwB?thread=cmsg_01BVUyyPie8gHwoPM18iABwBLW6dHPW6sSheA32XPKZzPV)_
repo:objectstack#3 · os-support-ai · session_01WGufzg1NmbJpZhtiWQkTir
Closes #34870
Clause-②: no
Metadata-protocol: none
Landing: **Tier H** (`docs/adr/**`). This PR stays draft; no seat
readies, queues or arms auto-merge on it.
## 维护者速读
- 改了什么:ADR-0149 D3 第 1
条下加一段只增不改的修订说明,写明「标签在每个语言下都是匹配目标」的准确含义:内联多语言标签的每个语言都算,翻译包里的标签只算为调用方语言解析出的那一个值(沿解析器的语言链:先按平台语言阶梯找请求语言,含变体扩展,再找部署声明的回退语言;请求语言即编写语言时跳过回退);别的语言的词只有写成同义词才命中。`dataset-term-matcher.ts`
的文档注释改成同样的话。没有任何代码行为变化。
- 为什么改:#34720 的裁决「A+C 本语言标签+同义词」(记录 6946563869)已定,但 ADR 原文和匹配器注释仍写「every
locale」,读起来像翻译包的所有语言都能命中,与裁决和 HTTP 入口的实际行为不符。
- 风险与回滚:只改文档与注释,零运行时风险。回滚即 revert 本 PR。
- 先看:① ADR-0149 D3 第 1 条下的修订说明,看是否如实转述裁决;② 其中「按传输层的调用方语言」一条:stdio
入口现在也走翻译(用 i18n 服务的默认语言),不是派发词所说的「不翻译」,见 Acceptance notes;③
`dataset-term-matcher.ts` 顶部注释。
- 两分钟验证:`pnpm check:adr-symbol-anchors`,预期最后一行 `✅
check-adr-symbol-anchors: ... anchors across 158 records
resolve`(修订说明里新增的符号锚都能解析)。
- 需要你做的:席位 L2 复核后,亲手合并本 PR(Tier H:`docs/adr/**`)。
## What changes
-
**`docs/adr/0149-ai-answers-business-questions-through-the-dataset-semantic-layer.md`**
(10 lines added, 0 removed): an add-only amendment note, nested under D3
rule 1 so the numbered list stays intact. It follows the record's
existing amendment-note form (the #34761 note after rule 5) and its
measurement discipline (symbol anchors only; the line positions are
below, not in the record). It states:
- an inline label map: every locale is a target, unless the bundle
answers for that member;
- a bundle label: one value, resolved for the caller's locale along the
resolver's locale chain (option A; fix round 1 spells the chain out),
resolved before matching; where the bundle answers, its value replaces
the authored label (string or inline map), so the authored label is then
no target, the consequence the ruling records;
- a word in another language is an authored synonym (option C);
`candidates` offer, never hit;
- the caller's locale per transport: HTTP reads `Accept-Language`,
falling back to the i18n default; stdio has no request and translates
for the i18n service's default locale; with no resolvable i18n service
the catalogue is untranslated on either;
- the matcher is unchanged.
- **`packages/services/service-analytics/src/dataset-term-matcher.ts`**
(doc comments only, +13 / -3): the module comment and the
`MatchableMember.label` comment say the same words. No statement, type
or export changes.
## Why
The decision text said a member's label matches "in every locale". The
ruling on #34720, verbatim 「A+C 本语言标签+同义词」 (ruling record 6946563869),
and the HTTP door hold it narrower. The note did not ride #34761's ADR
note (PR #34828).
## Code readings behind each claim (base `ab441988`)
<details><summary>File and line positions, measured at the base
commit</summary>
- HTTP door: `packages/runtime/src/domains/mcp.ts:1542` (`loadDatasets`
inside `datasetToolMembers`) runs `translateMetaList` with
`requestLocale` at `:1555` = `metaRequestLocale({ headers:
context.request?.headers }, i18n)`. Headers only, so the locale is
`Accept-Language`, else the i18n service's default.
- `packages/rest/src/meta-item-read-gate.ts:3208` `metaRequestLocale`:
`Accept-Language`, then `?locale=`, then `i18n.getDefaultLocale()`.
`:3538` `translateMetaList` returns the items untranslated when no
locale resolves; `:3286` `metaTranslateOptions` adds the i18n fallback
locale as the lookup chain.
- `packages/spec/src/system/i18n-resolver.ts:1907` maps `dataset` to
`translateDataset` (`:2626`); `translateDatasetMembers` (`:2545`, label
lookup `:2562`) writes the bundle string over `member.label` when the
bundle answers, an inline map included (the doc block's "An inline
locale map is never changed" sentence: the catalog applies to it).
`localeChain` (`:649`) is the caller's locale plus the fallback chain.
- Executor:
`packages/services/service-analytics/src/dataset-tools.ts:365` loads
through the transport's `loadDatasets`; `:439` hands the loaded
(translated) members to `matchDatasetTerms`. The matcher
(`dataset-term-matcher.ts`, `labelTargets`) reads a string or each value
of an inline map and never reads a bundle.
- stdio: `packages/mcp/src/stdio-data-bridge.ts:1431`-`1458` runs the
same `translateMetaList`, with `requestLocale` at `:1453` =
`metaRequestLocale(undefined, i18n)`, the i18n service's default locale.
This landed with #34833 (commit `6320abba`), the change made for card
#34787.
</details>
## Tests
No behaviour change, so no new test and no ablation. At head `233683d6`:
<details><summary>Typecheck and tests, service-analytics</summary>
- `pnpm --filter '@objectstack/service-analytics^...' build && pnpm
--filter @objectstack/service-analytics run typecheck` (under the verify
lock): `VERDICT command-exit 0`, `tsc --noEmit` clean.
- `pnpm --filter @objectstack/service-analytics test` (under the verify
lock): `Test Files 218 passed (218)`, `Tests 5548 passed | 335 skipped
(5883)`, `VERDICT command-exit 0`.
</details>
## Acceptance notes
- **The dispatch's stdio premise did not hold at the base.** The
dispatch said the stdio transport's `loadDatasets` applies no
translation step. At `ab441988` it does: #34833 (`6320abba`) made it run
the HTTP door's `translateMetaList` for the i18n service's default
locale. The note states what the code does: on stdio the bundle label in
the workspace default locale is a target, and an inline map's every
locale is a target.
- **Bundle replaces, it does not add.** The ruling's words are "every
locale of an inline label map, plus the bundle label in the caller's
locale". In the code, a member that has both an inline map and a bundle
entry for the caller's locale is served the bundle string alone. The
note says so instead of implying both are targets for one member. This
is the ruling's own recorded consequence (an English source label stops
matching under a translated locale), stated one step more generally.
- **Overlap.** Open draft PR #34904 (#34763) touches
`dataset-term-matcher.ts` too. `overlap-check` merges it cleanly with
this branch.
- **Changeset: none, with the `skip-changeset` label.** The diff is an
ADR (not published) plus doc comments in a published package. That is
the fast lane's comment-only case, so nothing ships. An empty changeset
was ruled out on purpose: `check-empty-changeset` refuses a new one.
## Verification
At head `233683d6`, change set derived by `node
scripts/pm/dispatch-gates.mjs --commands --repo
objectstack-ai/objectstack` (2 paths vs merge base `ab4419881`): 54
local commands run, 52 exit 0, 2 NOT MEASURED (prerequisites, not red).
`--ran` reconciliation: `54 derived famil(ies) accounted for — 54 run, 0
UNRUN`.
<details><summary>Selected verdict lines</summary>
- `pnpm check:adr-symbol-anchors` exit 0: `✅ check-adr-symbol-anchors:
3740 anchors across 158 records resolve`
- `node scripts/check-adr-links.mjs` exit 0: `✅ check-adr-links: 1150
relative link destination(s) under docs/adr/ resolve`
- `pnpm check:adr-index` exit 0: `adr-index --report: OK —
docs/adr/README.md is current`
- `pnpm check:adr-anchors` exit 0
- `pnpm check:nul-bytes` exit 0: `check-nul-bytes: OK (scanned 25983
text file(s) ... no raw ASCII control bytes)`
- `node scripts/check-issue-citations.mjs` exit 0: `✅
check-issue-citations: no issue citations added against ab44198 (1
file(s) read)`; `pnpm check:issue-citations` (self-test) exit 0
- `pnpm check:doc-authoring` exit 0
- `node scripts/pm/overlap-check.mjs --branch=HEAD` exit 0: `VERDICT
clean exit 0` (origin/main `13e0305c33` and #34904)
- NOT MEASURED: `node scripts/check-plugin-teardown-shape.mjs
--self-test` exit 3, reason: its fixture is pinned to commit `621a4876`,
which this shallow checkout cannot reach (checker health only, cannot
judge this diff). `pnpm check:dual-build-cjs-loads` exit 3, reason:
`PREREQUISITE NOT MET`, no full `pnpm build` in this worktree. CI runs
both.
</details>
The repo-wide runs (`pnpm lint`, the full `check:*` farm, `Test Core`)
are CI's.
## Fix round 1
Head `4b963c98` answers the seat's L2 record (comment 6954921504, S1,
with N1 to N3 folded in) and the L1-c ACCEPT's note N1 (comment
6954336709), which made the same point as S1. Prose only: no statement,
type or export changes. The body's What changes bullet and the 维护者速读
line above were edited to match.
- **S1, the bundle label's locale chain.** The note had said a bundle
label matches in "the caller's locale only" and that "the bundle's
values in other locales are not" targets. The resolver says otherwise.
`lookupDatasetMemberAttr` walks `localeChain`: first the requested
locale, read through `pickData` / `resolveBundleLocale` (exact, case,
platform table language, base language, variant expansion), then the
deployment's declared fallback locale. `metaTranslateOptions` supplies
that fallback from `getFallbackLocale()`, and `localeChain` skips it
when the caller's locale is the authored one (`getSourceLocale()`, else
`getDefaultLocale()`). The note's bundle point now states that chain,
says one value is served per member and only that value is a target, and
replaces the clause with "no other bundle value is". It gives two worked
cases. A `zh-TW` caller against a bundle whose only Chinese locale is
`zh-CN` is served the `zh-CN` label: `resolveLocaleAmong` step 5,
variant expansion. A `fr` caller in a deployment authored in another
language, with declared fallback `en`, is served the `en` label when the
bundle has no French one. The bold lead now reads "the one
translation-bundle label resolved for the caller's locale". New anchors:
`i18n-resolver.ts#lookupDatasetMemberAttr`,
`i18n-resolver.ts#resolveBundleLocale`,
`meta-item-read-gate.ts#metaTranslateOptions`. The matcher's module
comment mirrors the chain in one clause, and its `MatchableMember.label`
comment says "resolved for", not "resolved to".
- **N1, the HTTP pair-translation corner.** When no i18n service
resolves, stdio has no locale (`metaRequestLocale(undefined, undefined)`
is `undefined`), so `translateMetaList` returns the items untranslated.
HTTP is different: `Accept-Language` still yields a locale, and
`pairTranslationBundleOf` reads a declared override's pair bundle from
the protocol. `translateDataset` then applies it through
`labelCatalogs`. The note now names that one exception (anchor
`meta-item-read-gate.ts#pairTranslationBundleOf`).
- **N2, other doors.** The note adds one sentence. Any other door to the
same executor, cloud's service-ai `ToolRegistry` (D2) among them,
supplies the executor's `loadDatasets` itself and owes the same
translation step. The contract it points to is
`dataset-tools.ts#DatasetToolsDeps`, whose `loadDatasets` doc already
says "localized at the metadata boundary for the caller's locale". No
repository beyond those the ADR already names is cited.
- **N3, the PR in the note header.** The header now says "PR #34928"
instead of "this PR". That is ADR-0011's note form, minus the commit,
which does not exist before merge.
<details><summary>Fix round 1 verification, head 4b963c9</summary>
- Named gates, each exit code captured before any pipe: `pnpm
check:adr-symbol-anchors` exit 0, `✅ check-adr-symbol-anchors: 3745
anchors across 158 records resolve` (3740 at round 0, plus the five new
anchors). `pnpm check:adr-links` exit 0, `1150 relative link
destination(s) under docs/adr/ resolve`. `pnpm check:adr-index` exit 0,
`docs/adr/README.md is current`. `pnpm check:adr-anchors` exit 0. `pnpm
check:doc-authoring` exit 0. `pnpm check:nul-bytes` exit 0, `no raw
ASCII control bytes`. `pnpm check:issue-citations` (self-test) exit 0.
`node scripts/check-issue-citations.mjs` exit 0, `no issue citations
added against ab44198 (1 file(s) read)`.
- `pnpm --filter '@objectstack/service-analytics^...' build`, then `pnpm
--filter @objectstack/service-analytics typecheck`, both under the
verify lock: `VERDICT command-exit 0` each, `tsc --noEmit` clean.
- Derived families: `node scripts/pm/dispatch-gates.mjs --commands
--repo objectstack-ai/objectstack` gave 54 commands, all run. 52 exited
0. 2 are NOT MEASURED for the same reasons as round 0, both
prerequisites and not reds. `check-plugin-teardown-shape --self-test`
exited 3: the fixture commit `621a4876` cannot be reached from this
shallow checkout. `check:dual-build-cjs-loads` exited 3 with
`PREREQUISITE NOT MET`: there is no full build here. `--ran` gives `54
derived famil(ies) accounted for — 54 run, 0 UNRUN`. The derivation
warned STALE TREE: this branch is 11 commits behind `origin/main`, and
`dispatch-gates.mjs` and its data file changed in that range. CI derives
on its own tree.
- `node scripts/pm/overlap-check.mjs` exit 0: `VERDICT clean exit 0`,
against origin/main `46991d0e` and #34904.
- No test or ablation: the matcher's code lines are unchanged.
</details>
## Human Minimum
- [x] 1. Schemas start as Zod; `packages/spec` holds no runtime logic.
(Not touched.)
- [x] 2. Every name I added uses the casing for its kind. (No names
added.)
- [x] 3. No formatter ran; `pnpm lint` passes. (Left to CI.)
- [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. (Publishes
nothing: `skip-changeset`.)
- [x] 6. `packages/spec` touched: its generated artifacts are
regenerated and committed. (Not touched.)
- [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 (the 维护者速读 block is
Chinese by the dev agent's rule).
- [x] The *Before Submitting* list in CONTRIBUTING.md is done, with the
repo-wide runs left to CI as stated above.
---
_Generated by [Claude
Code](https://claude.ai/code/session_01WGufzg1NmbJpZhtiWQkTir)_
<!-- signed: repo:objectstack#3 · os-support-ai ·
session_01WGufzg1NmbJpZhtiWQkTir -->
---------
Co-authored-by: Claude <noreply@anthropic.com>
Co-authored-by: objectstack-fleet[bot] <332303061+objectstack-fleet[bot]@users.noreply.github.com>1 parent e556e3a commit 9e71ef8
2 files changed
Lines changed: 27 additions & 3 deletions
File tree
- docs/adr
- packages/services/service-analytics/src
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
149 | 149 | | |
150 | 150 | | |
151 | 151 | | |
| 152 | + | |
| 153 | + | |
| 154 | + | |
| 155 | + | |
| 156 | + | |
| 157 | + | |
| 158 | + | |
| 159 | + | |
| 160 | + | |
| 161 | + | |
152 | 162 | | |
153 | 163 | | |
154 | 164 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
17 | 17 | | |
18 | 18 | | |
19 | 19 | | |
20 | | - | |
21 | | - | |
| 20 | + | |
| 21 | + | |
| 22 | + | |
| 23 | + | |
| 24 | + | |
| 25 | + | |
| 26 | + | |
| 27 | + | |
| 28 | + | |
| 29 | + | |
| 30 | + | |
| 31 | + | |
| 32 | + | |
22 | 33 | | |
23 | 34 | | |
24 | 35 | | |
| |||
33 | 44 | | |
34 | 45 | | |
35 | 46 | | |
36 | | - | |
| 47 | + | |
| 48 | + | |
| 49 | + | |
| 50 | + | |
37 | 51 | | |
38 | 52 | | |
39 | 53 | | |
| |||
0 commit comments