Repository navigation
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
Conversation
…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
Co-Authored-By: Claude <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01FEkQ5ksYSwxvhGVTdi3SS4
📓 Docs Drift CheckThis PR changes 1 package(s): ⛔ 2 release-owned page(s) name something this change touched. These are read-only:
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): Which tree this was computed onThis run read A worktree cut from an older # 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
|
|
domain:spec#1 · os-project-manager · session_01FEkQ5mswnWm181XgYcCUag Contract reviewServed-tier: 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 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
② Semver level
③ Boundary flags
④ Design judgment
0 must-fix, 0 should-fix, 3 nits. Implemented-by: VERDICT: PASS |
|
domain:spec#1 · os-project-manager · session_01FEkQ5mswnWm181XgYcCUag ACCEPT · PR #33801 (#33733) · head
|
… 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>
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.mdteaches the registry by name (PLATFORM_PROVIDED_TOOL_NAMES) and lists noservice-aimember it would now miss.维护者速读
PLATFORM_TOOLS_BY_PACKAGE['service-ai']加入list_datasets和query_dataset;十一个内置语言包各加两条chatbot.tool.*步骤名(简体为「查看指标」「按指标查询」)。packages/spec/src/system/constants/platform-tool-names.tsL41–L56(新名字和说明);ui/packages/i18n/src/locales/zh-Hans.tsL4253、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) andquery_dataset(L56) join theservice-aigroup, in sort order. The group's docblock (L41–L50) now says what the pair does:list_datasetsreads the installed datasets and the metrics each defines, andquery_datasetanswers 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.toolblock only. Both keys in all eleven built-in packs, each a sentence in the pack's language:list_datasetsquery_datasetgen:zh-hant)Changeset
.changeset/33733-dataset-tool-labels.md:@objectstack/specminor (Metadata-protocol: added),@object-ui/i18npatch (itsfiles[]shipsdist, which carries the packs).Tests
platform-tool-names.test.tsL53. Theservice-aigroup containsLIST_DATASETS_TOOL_NAMEandQUERY_DATASET_TOOL_NAME(imported from../../ai/dataset-tools.zod, so the registry spelling is held to the ADR-0149 D2 constants), both answerisPlatformProvidedToolNametrue, and the controlquery_datasetsanswers false.toolLabels-locale-parity-7481.test.ts(every registry name has a non-empty label in every pack) andtoolLabels-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 withgit diff HEADempty):Registry: the two names removed → the new spec pin red (1 failed | 5 passed)
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)
The ui suite reads
@objectstack/spec/systemfromdist/, rebuilt with the new names before the run.Acceptance notes
packages/mcp/src/mcp-server-runtime.ts:PLATFORM_READ_ONLY_TOOL_NAMES/PLATFORM_DESTRUCTIVE_TOOL_NAMESare deliberately partial (its docblock: they carry only the names whose safety class the bridge knows;query_dataandsearch_knowledgeare 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 getsopenWorldHint: falseon 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.tsreads the registry as its platform universe: a probe on this head resolveslist_datasetsandquery_datasetand still reportsquery_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.tsandui/scripts/check-i18n-call-site-keys.mjsmention the registry in prose only.pnpm --filter @object-ui/i18n gen:zh-hantfrom zh-Hans (a ui test reds a stale one), so itslist_datasetsreads 檢視指標, the generator's conversion of 查看指标.AnswerSource.tsx,ChatbotEnhanced.tsx,plugin-chatbot.mdx) are not touched; the only locale edits are the two keys inside each pack'schatbot.toolblock.pnpm --filter @objectstack/spec check:generatedafter a spec build: all 14 artifacts up to date, nothing to regenerate (the registry's values are not inapi-surface/or the reference docs).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(branchclaude/project-thread-2vlfbw, merge baseorigin/maina557fa38), 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.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.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, lintcheck:doc-formula-expressions, uivitest run scripts/(unbuilt@objectstack/client), teardown self-test (shallow fixture)) and were rerun green after a fullturbo run buildand 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.🤖 Generated with Claude Code
https://claude.ai/code/session_01FEkQ5ksYSwxvhGVTdi3SS4