Skip to content

feat(spec, i18n): list the ask agent's dataset pair (list_datasets, query_dataset) in the platform tool registry and label its chat steps - #33801

Merged
objectstack-fleet[bot] merged 2 commits into
mainfrom
claude/project-thread-2vlfbw
Nov 15, 2026
Merged

objectstack-fleet[bot] merged 2 commits into
mainfrom
claude/project-thread-2vlfbw

Conversation

@objectstack-fleet

Copy link
Copy Markdown
Contributor

Requested by Leehom · project thread

domain:spec#1 · os-project-manager · session_01FEkQ5ksYSwxvhGVTdi3SS4

Fixes #33733

Clause-②: yes (widening)
Metadata-protocol: added
Skills-docs: none — skills/objectstack-ai/SKILL.md teaches the registry by name (PLATFORM_PROVIDED_TOOL_NAMES) and lists no service-ai member it would now miss.

维护者速读

  • 改了什么:平台工具注册表 PLATFORM_TOOLS_BY_PACKAGE['service-ai'] 加入 list_datasets 和 query_dataset;十一个内置语言包各加两条 chatbot.tool.* 步骤名(简体为「查看指标」「按指标查询」)。
  • 为什么改:cloud 的 service-ai 已为问数 agent 注册这两个工具(cloud#4551),注册表没列它们,技能引用它们会被 lint 报成不存在的工具,聊天里的步骤名也显示成英文工具 id。
  • 风险与回滚:只加名字和文案,不删不改任何已有项;MCP 侧这两个工具的注解在其注册处自带,不受影响。回滚即还原本 PR。
  • 先看:packages/spec/src/system/constants/platform-tool-names.ts L41–L56(新名字和说明);ui/packages/i18n/src/locales/zh-Hans.ts L4253、L4255。
  • 两分钟验证:在 ui/ 下跑 pnpm exec vitest run packages/plugin-chatbot/src/__tests__/toolLabels-locale-parity-7481.test.ts,预期全绿(需先 build @objectstack/spec)。
  • 需要你做的:无,席位落地。

What changes

  • Registry, packages/spec/src/system/constants/platform-tool-names.ts. list_datasets (L54) and query_dataset (L56) join the service-ai group, in sort order. The group's docblock (L41–L50) now says what the pair does: list_datasets reads the installed datasets and the metrics each defines, and query_dataset answers a question through one governed metric (cloud#4551), and points at ../../ai/dataset-tools.zod, where ADR-0149 D2 declares both names and shapes.

  • Labels, ui/packages/i18n/src/locales/*.ts, chatbot.tool block only. Both keys in all eleven built-in packs, each a sentence in the pack's language:

    Pack list_datasets query_dataset
    en Check the available metrics Query by a metric
    zh-Hans 查看指标 按指标查询
    zh-Hant (generated by gen:zh-hant) 檢視指標 按指標查詢
    ja 利用できる指標を確認する 指標で照会する
    ko 사용 가능한 지표 확인하기 지표로 조회하기
    de Die verfügbaren Kennzahlen ansehen Über eine Kennzahl abfragen
    es Ver las métricas disponibles Consultar por métrica
    fr Consulter les indicateurs disponibles Interroger un indicateur
    pt-BR Ver as métricas disponíveis Consultar por métrica
    ru Посмотреть доступные метрики Запросить данные по метрике
    ar عرض المؤشرات المتاحة الاستعلام حسب المؤشر
  • Changeset .changeset/33733-dataset-tool-labels.md: @objectstack/spec minor (Metadata-protocol: added), @object-ui/i18n patch (its files[] ships dist, which carries the packs).

Tests

  • New pin, platform-tool-names.test.ts L53. The service-ai group contains LIST_DATASETS_TOOL_NAME and QUERY_DATASET_TOOL_NAME (imported from ../../ai/dataset-tools.zod, so the registry spelling is held to the ADR-0149 D2 constants), both answer isPlatformProvidedToolName true, and the control query_datasets answers false.
  • Existing pins that read the registry now cover the pair: toolLabels-locale-parity-7481.test.ts (every registry name has a non-empty label in every pack) and toolLabels-sentences-12724.test.ts (same key set in every pack, no value equals the tool id or the title-caser's output).

Ablations (head 13eaec9e, scripts/ablation-replace.mjs, both restored to blob == HEAD with git diff HEAD empty):

Registry: the two names removed → the new spec pin red (1 failed | 5 passed)
ablation-replace: ok mutation landed: anchor 1 -> 0, blob 6c627c5e2a02 -> a6a19345c1fd
FAIL src/system/constants/platform-tool-names.test.ts > lists the service-ai dataset pair the ask agent registers (cloud#4551)
AssertionError: expected [ Array(8) ] to deeply equal ArrayContaining{…}
Tests  1 failed | 5 passed (6)
ablation-replace: ok restored: blob == HEAD (6c627c5e2a02) and `git diff HEAD` is empty

The spec test imports src/ by relative path, so no dist is in the path.

Labels: en list_datasets removed → both ui label pins red (2 failed | 28 passed)
ablation-replace: ok mutation landed: anchor 1 -> 0, blob df8f06a8ca30 -> 093ac78fe5e5
FAIL toolLabels-locale-parity-7481.test.ts > en defines a non-empty label for every covered tool
AssertionError: en is missing chatbot.tool entries: expected [ 'list_datasets' ] to deeply equal []
FAIL toolLabels-sentences-12724.test.ts > reads every shipped pack, each with the same non-empty key set
Tests  2 failed | 28 passed (30)
ablation-replace: ok restored: blob == HEAD (df8f06a8ca30) and `git diff HEAD` is empty

The ui suite reads @objectstack/spec/system from dist/, rebuilt with the new names before the run.

Acceptance notes

  • Other registry readers, measured; none needs an edit. packages/mcp/src/mcp-server-runtime.ts: PLATFORM_READ_ONLY_TOOL_NAMES / PLATFORM_DESTRUCTIVE_TOOL_NAMES are deliberately partial (its docblock: they carry only the names whose safety class the bridge knows; query_data and search_knowledge are not in them either), and their pin checks only that each listed name is in the registry. The world-hint pin enumerates the registry, so the pair now gets openWorldHint: false on the runtime bridge, which matches what MCP's own registration of the pair asserts (registerDatasetTools, packages/mcp/src/mcp-http-tools.ts: readOnlyHint: true, destructiveHint: false, openWorldHint: false). packages/lint/src/validate-ai-tool-references.ts reads the registry as its platform universe: a probe on this head resolves list_datasets and query_dataset and still reports query_datasets ("Did you mean query_dataset?"). packages/spec/src/ai/build-progress.zod.ts, packages/objectql/src/bare-name-one-holder.ts, ui/packages/plugin-chatbot/src/toolResultParsers.ts and ui/scripts/check-i18n-call-site-keys.mjs mention the registry in prose only.
  • zh-Hant is generated. The pack is written by pnpm --filter @object-ui/i18n gen:zh-hant from zh-Hans (a ui test reds a stale one), so its list_datasets reads 檢視指標, the generator's conversion of 查看指标.
  • No overlap with Chat answer source block: render dataset provenance (metric and dataset) from query_dataset, not only ObjectQuerySource #33734. That PR's files (AnswerSource.tsx, ChatbotEnhanced.tsx, plugin-chatbot.mdx) are not touched; the only locale edits are the two keys inside each pack's chatbot.tool block.
  • Spec artifacts. pnpm --filter @objectstack/spec check:generated after a spec build: all 14 artifacts up to date, nothing to regenerate (the registry's values are not in api-surface/ or the reference docs).
  • Observed, not changed. skills/objectstack-ai/SKILL.md's MCP tool table does not list the dataset pair MCP registers (registerDatasetTools); that predates this card and is about MCP, not this registry. class: observation · reach: none · carrier: none.

Verification

On head 13eaec9e (branch claude/project-thread-2vlfbw, merge base origin/main a557fa38), each exit code captured before any pipe:

  • pnpm --filter @objectstack/spec test: exit 0, Test Files 842 passed (842), Tests 26943 passed, 1 todo.
  • pnpm --filter @objectstack/spec typecheck (incl. check:test-typecheck): exit 0.
  • From ui/: pnpm exec vitest run packages/plugin-chatbot/ packages/i18n/: exit 0, Test Files 201 passed (201), Tests 2852 passed, 13 skipped. pnpm --filter @object-ui/i18n type-check: exit 0.
  • pnpm --filter @objectstack/mcp exec vitest run src/mcp-tool-bridge-safety-annotations.test.ts src/mcp-dataset-tools.test.ts: exit 0, 34 passed. pnpm --filter @objectstack/lint exec vitest run src/validate-ai-tool-references.test.ts: exit 0, 23 passed.
  • Derived gates (node scripts/pm/dispatch-gates.mjs --commands --repo objectstack-ai/objectstack, 86 families, same list re-derived on the final head): all 86 exit 0. Five first answered exit 3/1 for a missing prerequisite (check:dual-build-cjs-loads, check:lean-entry-closure, lint check:doc-formula-expressions, ui vitest run scripts/ (unbuilt @objectstack/client), teardown self-test (shallow fixture)) and were rerun green after a full turbo run build and the fixture fetch. --ran: "86 derived famil(ies) accounted for — 86 run, 0 NOT-MEASURED".
  • dispatch-gates --tier: no path-derived mandate; 62 changed lines, under the 3000 threshold. packages/spec/src/** is the Clause-② surface: the seat's contract review applies.
  • CI families are read from this PR's check-runs, not re-run here.

🤖 Generated with Claude Code

https://claude.ai/code/session_01FEkQ5ksYSwxvhGVTdi3SS4

…ool registry and label its chat steps

`list_datasets` and `query_dataset` join `PLATFORM_TOOLS_BY_PACKAGE['service-ai']`
(cloud service-ai registers them for the ask agent), and every built-in
locale pack gains a `chatbot.tool.*` sentence for each.

Co-Authored-By: Claude <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01FEkQ5ksYSwxvhGVTdi3SS4
@github-actions github-actions Bot added documentation Improvements or additions to documentation protocol:system tests tooling Fix lands in tooling, not a product package — enters pm:queue only with Unblocks: or a named surface labels Nov 15, 2026
@github-actions

Copy link
Copy Markdown
Contributor

📓 Docs Drift Check

This PR changes 1 package(s): @objectstack/spec, touching 3 documentable anchor(s).

⛔ 2 release-owned page(s) name something this change touched. These are read-only:

  • content/docs/releases/v18/18-3.mdx (via PLATFORM_TOOLS_BY_PACKAGE (symbol, a top-level const object))
  • content/docs/releases/v18/18-4.mdx (via PLATFORM_TOOLS_BY_PACKAGE (symbol, a top-level const object), list_datasets (literal, a string literal in PLATFORM_TOOLS_BY_PACKAGE), query_dataset (literal, a string literal in PLATFORM_TOOLS_BY_PACKAGE))

content/docs/releases/ is RELEASE-OWNED (AGENTS.md "Documentation Guardrails"): release
notes are written centrally at release time, and a code PR that edits them is the exact PR
that guardrail exists to stop. They are still audited — read-only. If one of them is actually
wrong, file an issue or open a dedicated docs-only PR; do not edit it here.

What this run could not see

Coarse fallback — 172 page(s) merely mention a changed package (the pre-#9192 predicate, kept for the deliberately-wide backstop): node scripts/docs-audit/affected-docs.mjs --json 1e65a389e12e7c07e2121378d1d0755226c2ad60 → packageMentionDocs.

Which tree this was computed on

This run read content/docs from 98753142b1efa0b55309a42243f4afcd3c1731de — the merge of head 13eaec9ec63d27db69ea42ce4ada9555019a8cc9 into base 1e65a389e12e7c07e2121378d1d0755226c2ad60, which is what actions/checkout gives a pull_request run. Not the PR head.

A worktree cut from an older main holds a different content/docs, so re-deriving there can legitimately return a different list — that is a different tree, not a wrong row. To answer on the same tree:

# while this PR is open — GitHub drops the merge commit once it closes
git fetch origin 98753142b1efa0b55309a42243f4afcd3c1731de && git checkout 98753142b1efa0b55309a42243f4afcd3c1731de
# afterwards, rebuild it from the two parents, which stay fetchable
git fetch origin 1e65a389e12e7c07e2121378d1d0755226c2ad60 13eaec9ec63d27db69ea42ce4ada9555019a8cc9 && git checkout -B drift-repro 1e65a389e12e7c07e2121378d1d0755226c2ad60 && git merge --no-ff 13eaec9ec63d27db69ea42ce4ada9555019a8cc9

node scripts/docs-audit/affected-docs.mjs --json 1e65a389e12e7c07e2121378d1d0755226c2ad60

⚠️ That checkout carried uncommitted changes, so the commit above does not fully identify what was read.

Advisory only, and a precision-first one (#9192): a page is listed because it names a
symbol, wire route or SDK method this diff touched — not because it mentions a changed
package. Each row says which anchor put it there, so a wrong row is reportable rather than
merely annoying. To re-verify, run the docs-accuracy-audit workflow scoped to these files:
node scripts/docs-audit/affected-docs.mjs 1e65a389e12e7c07e2121378d1d0755226c2ad60 → pass the list as
args.docs, on the commit named under Which tree this was computed on.

@objectstack-fleet

Copy link
Copy Markdown
Contributor Author

domain:spec#1 · os-project-manager · session_01FEkQ5mswnWm181XgYcCUag

Contract review

Served-tier: CONTRACT_REVIEW_TIER
Head-sha: 13eaec9ec63d27db69ea42ce4ada9555019a8cc9
Local-runs: none
Scope: packages/spec/src/system/constants/platform-tool-names.ts + packages/spec/src/system/constants/platform-tool-names.test.ts

Read for this record: card #33733 (body and all four comments: triage 6891883794, re-lane 6892365476, claim 6892496349, dev report 6893391372), the PR body, the 14-file list, the net diff against merge base a557fa38, and the check-runs on this head. The seat also had me read the Rulings section of its order; no judgment below rests on it. The 11 ui/packages/i18n/src/locales/*.ts hunks and the changeset are the lane seat's ACCEPT; they are read here for ② and for the registry header's own label rule.

Check-runs at review time: 13 success, 10 skipped, 21 in progress, 0 failed. Build Core, Test Core 1-8, the Type Check and Lint families and Live E2E UI had not answered. The gate verdicts are therefore not in; this PASS is the contract reading only, and landing waits on those runs.

① Derived judgments

  • Registry. Two members join PLATFORM_TOOLS_BY_PACKAGE['service-ai'], in sorted position (get_record · list_datasets · query_data · query_dataset · query_records). PLATFORM_PROVIDED_TOOL_NAMES and isPlatformProvidedToolName derive from the map, so nothing else in the file owes an edit. Both names are snake_case, sit in no second group and do not start with action_. Right.
  • Spelling. The names equal LIST_DATASETS_TOOL_NAME / QUERY_DATASET_TOOL_NAME in packages/spec/src/ai/dataset-tools.zod.ts, and the new pin imports those constants, so the registry cannot drift from the ADR-0149 D2 spelling. Right.
  • Readers, each read on this head:
    • packages/lint/src/validate-ai-tool-references.ts:145 builds its universe from the registry: a skill naming either tool stops drawing the warning-severity ai-skill-tool-unresolved. Intended.
    • packages/mcp/src/mcp-server-runtime.ts:503 (worldAnnotation): a bridged tool of either name now gets openWorldHint: false. That is true of both (they read this environment's own datasets) and equals what MCP's native registration asserts.
    • PLATFORM_READ_ONLY_TOOL_NAMES / PLATFORM_DESTRUCTIVE_TOOL_NAMES (mcp-server-runtime.ts:311, :323): the dev's reading is verified. The docblock calls the sets deliberately partial. Both pins are subset-only: one bridges the registry and asserts every annotated name is in it, the other iterates the two sets and asserts each name is in the registry. Neither asserts that a registry reader is in the read-only set, so no pin reds. A bridged pair gets no readOnlyHint, which reads as the protocol's cautious default. query_data, search_knowledge and visualize_data are in the same position on main.
    • Name collision: where the native MCP dataset tools are registered, bridgeTools skips the bridged namesake (nativeToolNames, mcp stdio: a host whose AI tool registry already carries list_objects / the data tools cannot boot the stdio transport ("Tool list_objects is already registered") #31836), so the pair is never registered twice.
    • ChatbotEnhanced.answerSource-31868.test.tsx:225 and mapMessages.persistedChart-25908.test.ts:112 assert containment of other names only. build-progress.zod.ts, skill.zod.ts, stack.zod.ts, bare-name-one-holder.ts, rule-explanations.ts, toolResultParsers.ts and check-i18n-call-site-keys.mjs name the registry in prose only.
  • Generated artifacts needed no change: verified by reading. packages/spec/api-surface/system.json and export-origins/system.json list the export names, not the values. A grep for sibling members (search_package_docs, remove_sample_data) finds no generated file, reference doc or second hand copy of the list.
  • Labels. All 11 built-in packs (ar, de, en, es, fr, ja, ko, pt-BR, ru, zh-Hans, zh-Hant) gain both keys inside the chatbot.tool block, in sorted position. Each value is a sentence in the pack's language; none equals the tool id or the title-caser's output; no English is copied into another pack. zh-Hant is in Traditional characters (檢視指標 / 按指標查詢). The header's second duty is met.
  • Not verifiable from here: that cloud service-ai registers the pair (cloud PR feat(spec)!: converge the dual-source MetadataFormat and CacheStrategy enum declarations (#4537) #4557). It is carried from the card. ADR-0149 D2 and its D7 row 5 say the same in this repo, and a wrong group fails cloud's conformance test at the pin bump.

② Semver level

  • Clause-②: yes (widening) holds. The declared type does not move; the published runtime value widens, and two published consumers change their answer on it (the lint universe and the MCP world hint). Nothing is removed.
  • @object-ui/i18n: patch holds: its packs ship and gain keys only.
  • Metadata-protocol: added and @objectstack/spec: minor — nit N1, see ④. The same kind of edit landed three days ago as Metadata-protocol: none and patch (feat(spec, i18n): register the ask agent tool get_record_history and label it in every locale pack #32668, contract review 6836202589, which rejected added on the code: skill.tools[] parses any string before and after, and the registry feeds only a warning-severity lint finding). By AGENTS.md checklist step 3, none takes patch, and a non-protocol widening ships patch. The declaration here is internally consistent (added takes at least minor) and over-declares; it does not under-declare. It changes nothing that ships: 26 pending changesets already take @objectstack/spec to minor in its fixed group, and the release notes place the entry under 新增能力 on either reading.

③ Boundary flags

④ Design judgment

platform-tool-names.ts holds against the code it cites: ../../ai/dataset-tools.zod resolves, declares both names and shapes, and registerDatasetTools in packages/mcp/src/mcp-http-tools.ts registers the pair. platform-tool-names.test.ts agrees with the contract: the pin reads the group, both membership answers and a query_datasets control, and the dev's ablation showed it red without the names.

  • N1 — nit. Metadata-protocol: added / spec minor against the none / patch reading of feat(spec, i18n): register the ask agent tool get_record_history and label it in every locale pack #32668 (②). No effect on what ships. Accept as a deviation, or correct the line in a later prose-only edit; a changeset edit now would move the head.
  • N2 — nit. The service-ai docblock is looser than the schema it points at. (a) list_datasets returns the datasets the caller may query, with their dimensions and measures and the term matches, not "the installed datasets and the metrics each defines": a dataset the caller is not admitted to is absent, and dimensions are listed too. (b) query_dataset runs a selection against ONE saved dataset and may name several measures, so "through one governed metric" understates it. (c) In "declared once in ../../ai/dataset-tools.zod (ADR-0149 D2), which MCP registers too", MCP registers the tools, not the file. None of this misleads a reader about the registry's contract; the wording follows the card.
  • N3 — nit. The changeset names the lint effect but not the MCP effect (openWorldHint: false for a bridged tool of either name). The PR body names it.
  • Observation, outside ④ (lane seat's ACCEPT): the de label Über eine Kennzahl abfragen has no object and reads less naturally than its neighbours (Die benötigten Daten abfragen). It is still a German sentence and passes the rule.

0 must-fix, 0 should-fix, 3 nits.

Implemented-by: claude/project-thread-2vlfbw
Reviewed-by: session_01FEkQ5mswnWm181XgYcCUag

VERDICT: PASS

@objectstack-fleet

Copy link
Copy Markdown
Contributor Author

domain:spec#1 · os-project-manager · session_01FEkQ5mswnWm181XgYcCUag

ACCEPT · PR #33801 (#33733) · head 13eaec9ec63d27db69ea42ce4ada9555019a8cc9 · 2026-11-15T11:41Z

席位核对

  • 形态: 14 files from the PR's file list, +60 −2, base 1e65a389.
    • packages/spec/src/system/constants/platform-tool-names.ts: list_datasets and query_dataset join PLATFORM_TOOLS_BY_PACKAGE['service-ai'] in sorted position, and the docblock is updated.
    • platform-tool-names.test.ts: a new pin imports LIST_DATASETS_TOOL_NAME / QUERY_DATASET_TOOL_NAME, so the registry cannot drift from the ADR-0149 D2 spelling.
    • The 11 built-in packs under ui/packages/i18n/src/locales/: both chatbot.tool.* keys, inside the block only.
    • One changeset: @objectstack/spec minor, @object-ui/i18n patch.
    • No governed path, under 3000 lines: Tier S, seat lands.
  • 前提实测: one PR for both halves, as the order ruled, because the ui label-parity test reads the registry. No packages/mcp edit: PLATFORM_READ_ONLY_TOOL_NAMES is documented as partial and both of its pins are subset-only, which the review verified. Spec generated artifacts are unchanged: they list export names, not values. Dev report 6893391372: 86/86 derived gates, nothing unmeasured; two ablations went red, then were restored.
  • 门禁 check-runs: latest attempt on this head: 67 runs, 57 success, 10 skipped, 0 failed. mergeable_state clean.
  • 契约复审: CONTRACT_REVIEW_TIER PASS, record 6893453882 on this head: no must-fix, no should-fix, three nits. Isolated reviewer; Ruling-ref 「你有 fable ,车道契约复审可以自己做」 2026-11-07. This review ran before the maintainer's 「review#1 正在入座,你这个账户后续的契约复审找他」 (2026-11-15T11:16Z); later reviews go to review#1.
  • 接受的偏差:
  • 范围外去向: none. ui seat 2's Chat answer source block: render dataset provenance (metric and dataset) from query_dataset, not only ObjectQuerySource #33734 (the dataset provenance block) shares no file.
  • 落地条款: ready + auto-merge now, under the maintainer's standing orders 「按照 pm-dispatch 规则复核过的都授权」 (2026-10-25T11:35Z) and 「你应该使用 pm-dispatch 技能审核和落地pr」 (2026-11-07T16:59Z). This is work in hand under 「当前任务处理完,合并后就下班」 (2026-11-15T11:07Z). K = 0 commits on main past this head's affected-set base 1e65a389 (< 15).

@objectstack-fleet
objectstack-fleet Bot marked this pull request as ready for review November 15, 2026 11:41
@objectstack-fleet
objectstack-fleet Bot added this pull request to the merge queue Nov 15, 2026
Merged via the queue into main with commit b005638 Nov 15, 2026
68 checks passed
@objectstack-fleet
objectstack-fleet Bot deleted the claude/project-thread-2vlfbw branch November 15, 2026 12:11
scbdzhwl pushed a commit to scbdzhwl/objectstack-analysis that referenced this pull request Nov 16, 2026
… which dataset and metrics it used (objectstack-ai#33870)

<!-- claude-projects-attribution: {"github_login":"os-project-manager"}
-->
_Requested by **Leehom** · [project
thread](https://claude.ai/code/project/chan_01TenzsRopZj4jMbvjX8uz1X?thread=cmsg_01TenzsRopZj4jMbvjX8uz1XTfnpANDWSRVQfEQTS9xCwV)_

Fixes objectstack-ai#33734

Clause-②: yes (widening)
Metadata-protocol: none

Seat `domain:ui#2` · os-project-manager · card thread
`session_01FEkQ5kWtEXh64E1jg6WPCD` · claim 6892143272

## 维护者速读

- 改了什么:AI 对话里答案下方折叠的「计算方式」块,过去只认对象查询(`query_records` 等)的 `source`;现在 AI
通过 `query_dataset`
按指标回答时,同一位置显示所用的数据集、每个指标(名称旁附机器名与口径说明)、分组维度和问题追加的筛选条件。对象查询的显示完全不变。
- 为什么改:ADR-0149 D3 规定指标答案的来源从工具返回的 `provenance` 块渲染,规格
`DatasetProvenanceSchema` 也写明「An answer renders its source from this
block」,但界面一直只读 `source`,指标答案没有结构化来源块(cloud PR objectstack-ai#4557 的发现)。
- 风险与回滚:纯前端读取与显示;`detectAnswerSource` 的返回类型与导出类型 `AnswerSource`
放宽为两种来源的联合类型(Clause-② 放宽,见下)。浏览器缓存重载时数据集来源写回 `provenance` 键。回滚即还原本 PR。
- 先看:ui/packages/plugin-chatbot/src/AnswerSource.tsx(新增
`DatasetSourceSection`;对象查询的筛选渲染抽成共用的
`AnswerSourceFilter`,输出不变)、ui/packages/plugin-chatbot/src/mapMessages.ts(`detectAnswerSource`
先读
`provenance`)、ui/packages/app-shell/src/hooks/useChatConversation.ts(缓存写回键)。
- 两分钟验证:在已接入 `query_dataset`
的环境问一个指标问题(如「本月营收多少」),展开答案下的「计算方式」:应看到「数据集」「指标」「分组依据」「筛选条件」四行;问一个普通记录问题,块内容与今天相同。
- 需要你做的:无,席位落地(Clause-② 放宽,席位先补契约复审记录)。

## What changes

- **Lift.** `detectAnswerSource` (`mapMessages.ts`) reads a tool
result's top-level `provenance` through `DatasetProvenanceSchema` first,
then the object-query `source` through `ObjectQuerySourceSchema`, as
before. Each is the schema's parse: an undeclared key is stripped, and a
block the schema refuses is no block. `query_dataset` answers only
`provenance`; the object-query tools answer only `source`.
- **Draw.** `AnswerSource.tsx` gains `DatasetSourceSection`, chosen by
the block's `kind: 'dataset'`:
- **Dataset**: the dataset's label (its name where the label is empty);
- **Metrics**: each measure's label, with its name beside it when the
two differ, and its `description` (the business definition ADR-0149 D1
asks for) under it when declared; the name alone where the label is
empty;
  - **Grouped by**: the dimensions' labels, when any were selected;
- **Filter**: `runtimeFilter` lowered to rows exactly as the
object-query filter is (now one shared `AnswerSourceFilter`), or drawn
as served when it does not lower; with no `runtimeFilter`, "No filter
added to the dataset definition", because the dataset's own `filter`
still applies and is never served (the schema says so), so "All records"
would be false.
- No "Only records visible to you" line: the provenance block carries no
scope member, and the block states only what the producer sent.
- **Object-query rendering is unchanged.** `AnswerSourceSection` draws
the same rows, test ids and words; the filter markup moved into
`AnswerSourceFilter` byte for byte. The 31868 pin file passes unchanged.
- **Cache.** `sanitizeChatMessagesForCache` (`useChatConversation.ts`)
writes a dataset lift back under `provenance` (the producer's key), an
object-query lift under `source` as before, so both hydration paths lift
it again on reload.
- **Types.** `AnswerSource` is now declared in `mapMessages.ts` as
`ObjectQuerySource | DatasetProvenance` and re-exported from `index.tsx`
under the same name.
- **Strings.** `chatbot.answerSource.dataset`, `metrics`,
`noAddedFilter` in all 11 packs (`all-locales-key-parity`); zh-Hant
generated from zh-Hans (`gen:zh-hant`). "Grouped by" and "Filter" reuse
the existing keys.
- **Docs.** One sentence in
`content/docs/frontend/plugins/plugin-chatbot.mdx` beside the paragraph
that describes the block (seat amendment 2).
- **Published surface, each a `Clause-②: yes (widening)` on
`@object-ui/plugin-chatbot`:**
- `detectAnswerSource`'s return type: `ObjectQuerySource | undefined` →
`AnswerSource | undefined`;
- the exported type `AnswerSource`: was `ObjectQuerySource`, now
`ObjectQuerySource | DatasetProvenance`;
- `ChatbotEnhancedToolInvocation.answerSource` (in
`ChatbotEnhanced.tsx`, the one type line the seat approved):
`ObjectQuerySource` → `ObjectQuerySource | DatasetProvenance`;
- `AnswerSourceBlockProps.sources[].source` (package-internal, not
exported from the entry): the same union.
- A consumer that reads `object` / `filter` / `scope` off an
`AnswerSource` narrows on `kind` first. In this repository the only
consumer outside the package, `useChatConversation.ts`, does.
- Changeset `.changeset/33734-answer-source-dataset-provenance.md`:
`@object-ui/plugin-chatbot`, `@object-ui/i18n`, `@object-ui/app-shell`,
`@object-ui/console` patch (a widening with `Metadata-protocol: none`
ships `patch`; app-shell is private and console's `dist` ships it).

## Tests

-
`ui/packages/plugin-chatbot/src/__tests__/ChatbotEnhanced.answerSource-dataset-33734.test.tsx`
(turns built from wire parts through `uiMessageToChatMessage` and drawn
by the real `ChatbotEnhanced`, the block opened by clicking its rendered
trigger). The fixture is a `query_dataset` answer
`QueryDatasetOutputSchema` accepts (asserted):
- the lift returns the provenance alone, an undeclared key and the rows
stripped; a provenance the schema refuses (wrong `kind`, string
`measures`, string `dataset`) lifts nothing;
- a `query_dataset` answer shows the dataset, each metric (label, name
beside it, description), the grouping and the filter rows; no
object-query section, no scope line, nothing of the rows or args;
- no `runtimeFilter` and no dimensions: the "no filter added" line, no
grouping row, never "All records";
  - a nested filter is drawn as served;
- a turn with a dataset answer and an object-query answer: one block,
both sections, in call order;
- CONTROL: an object-query answer draws as today (object, filter row,
records, scope) with no dataset section;
  - CONTROL: a `query_dataset` refusal (no provenance) draws no block;
  - the shipped zh pack (数据集 / 指标).
-
`ui/packages/app-shell/src/hooks/__tests__/useChatConversation.test.tsx`:
a `query_dataset` provenance survives sanitize, JSON round-trip and both
hydration paths (`hydratedMessagesToChatMessages`,
`uiMessageToChatMessage`), and the cached part's `output` is `{
provenance }`.
- **Red first** on base bd96ec9 (production files restored to base,
tests at head): 7 failed / 84 passed; every positive pin red (the
rendered ones: "Unable to find ... button ... How this was computed";
the lift: "expected undefined to deeply equal { kind: 'dataset', ...
}"); the controls and the refused-provenance pin green, as they must be.
Head: 91/91 over the new file, the 31868 file and
`useChatConversation.test.tsx`.
- **Ablations** through `scripts/ablation-replace.mjs` (ui vitest
aliases `@object-ui/plugin-chatbot` to `src`, no rebuild), each mutation
landing on disk, each restored with the blob equal to HEAD and `git diff
HEAD` empty, running the same three files (91 tests):
- the lift ignores `provenance`: 7 failed — every dataset pin and the
reload pin;
- no dataset section (the branch ANDed with an always-false term): 5
failed — every rendered dataset pin;
- cache writes a dataset lift under `source`: 1 failed — the reload pin;
- metric name beside the label dropped: 1 failed — the "shows the
dataset, each metric" pin;
- CONTROL leg, every block routed to the dataset section: 8 failed — the
new object-query CONTROL, the mixed-turn pin and six 31868 object-query
pins;
- CONTROL leg, the empty-turn guard removed: 6 failed — the
no-provenance CONTROL, the 31868 "no source draws no block" pin and the
off-contract pins.

## Acceptance notes

- **Not delivered: the "non-metric reading" label on a fallback.**
`DatasetProvenanceSchema` has no member that marks a fallback (`kind` is
only `'dataset'`). Per ADR-0149 D3 rule 4 a fallback answer is an
object-query answer (`query_records` / `aggregate_records`), and its
「非指标口径」 words are the producer's, inside `source.line`, which today's
block does not draw. Labelling every `ObjectQuerySource` block would
mislabel plain record reads and change the object-query rendering this
order froze. The seat ruled the leg out of this PR and files the
follow-up (it needs a producer or spec marker first).
- The metric's `description` is drawn because it is the sentence
ADR-0149 D3 says explains what the number includes; the order listed
label, dataset and filters.
- No scope line on a dataset section: the provenance carries none. The
dataset query runs under the caller's context, but the block does not
state what the producer did not send.
- `ChatbotEnhanced.tsx`: two lines only (the type import and the
`answerSource` member type), approved by the seat; this branch is
rebased onto main after objectstack-ai#33746 merged, as the seat ordered.

## Verification

<details><summary>Local gates, type-check, lint and suites</summary>

- Head ee612b4 (rebased onto 4b5024d after objectstack-ai#33746 merged; the rebase
was clean). `node scripts/pm/dispatch-gates.mjs --commands --repo
objectstack-ai/objectstack` derives 71 families for this diff. All 71
exit 0 on ee612b4, run sequentially after rebuilding the spec, formula,
client, lint, sdui-parser and client-react closures and the
`@object-ui/app-shell^...` closure (lock VERDICT command-exit 0).
`--ran`: 71 derived, 71 run, 0 NOT-MEASURED.
- Suites under the lock, from `ui/` with `--maxWorkers=2`:
`packages/plugin-chatbot/` + `packages/i18n/` 203 files, 2878 passed, 13
skipped; `packages/app-shell/src/hooks/` +
`packages/app-shell/src/console/ai/` 153 files, 1255 passed.
- `pnpm run type-check` in `ui/packages/plugin-chatbot`,
`ui/packages/i18n` and `ui/packages/app-shell`: exit 0 each.
- ESLint on the changed source, test and locale files: 0 errors; the 58
warnings are all on lines this diff does not touch
(`react-refresh/only-export-components` and friends in `index.tsx`,
`ChatbotEnhanced.tsx`, `useChatConversation.ts`). `pnpm
check:new-line-citations` (from `ui/`): exit 0.
- The same union was green on the pre-rebase heads (90a3f1ea for the 40
code families, ac1ae487 for the 31 docs families).
- `origin/main` moved 8 commits after 4b5024d (to c87e2ad), among them
objectstack-ai#33801, which adds `chatbot.tool.list_datasets` / `query_dataset` labels
to the same eleven packs in another block, and the 18.5.0
version-packages commit. `git merge-tree` of HEAD with c87e2ad is
clean; the full app-shell suite and the rest of the farm are CI's.

</details>

🤖 Generated with [Claude Code](https://claude.com/claude-code)

https://claude.ai/code/session_01FEkQ5kWtEXh64E1jg6WPCD

---
_Generated by [Claude
Code](https://claude.ai/code/session_01FEkQ5kWtEXh64E1jg6WPCD)_

---------

Co-authored-by: Claude <noreply@anthropic.com>
Co-authored-by: objectstack-fleet[bot] <332303061+objectstack-fleet[bot]@users.noreply.github.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

documentation Improvements or additions to documentation protocol:system size/s tests tooling Fix lands in tooling, not a product package — enters pm:queue only with Unblocks: or a named surface

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Platform tool registry and chatbot labels: add list_datasets / query_dataset under service-ai (cloud registers them for the ask agent)

1 participant