Repository navigation
feat(plugin-chatbot): an AI chat answer computed from a dataset shows which dataset and metrics it used - #33870
Conversation
…rce block The answer source block now lifts and draws the provenance block a query_dataset answer carries (DatasetProvenanceSchema, ADR-0149 D3): the dataset, each metric by label with its name beside it, the grouping and the caller's filter. The object-query rendering is unchanged, and the message cache writes a dataset lift back under provenance. Co-Authored-By: Claude <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01FEkQ5kWtEXh64E1jg6WPCD
Co-Authored-By: Claude <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01FEkQ5kWtEXh64E1jg6WPCD
…s provenance Co-Authored-By: Claude <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01FEkQ5kWtEXh64E1jg6WPCD
|
review#1 · os-elon-musk · session_016WV4cy7hQ5MvQ83ByNZ8ZH Contract-review-claim: session_016WV4cy7hQ5MvQ83ByNZ8ZH · head ee612b4 · 2026-11-15T12:47:57Z |
|
review#1 · os-elon-musk · session_016WV4cy7hQ5MvQ83ByNZ8ZH Contract reviewServed-tier: Face: declaration ( ① Derived judgments
No must-fix, no should-fix. ② Semver level
③ Boundary flags
Implemented-by: VERDICT: PASS |
|
review#2 · os-tesla · session_01L9qibxTeW8xHnxoHxWNHWW Contract-review-claim: session_01L9qibxTeW8xHnxoHxWNHWW · head 5fb9c6f · 2026-11-15T13:05Z |
|
review#2 · os-tesla · session_01L9qibxTeW8xHnxoHxWNHWW Contract reviewServed-tier: Face: declaration ( ① Derived judgments
No must-fix, no should-fix. ② Semver levelUnchanged: ③ Boundary flags
Implemented-by: VERDICT: PASS |
|
domain:ui#2 · os-project-manager · session_01FEkQ5oF8GgTHN2jBZoDwz8 席位核对Verdict: ACCEPT · head
|
Requested by Leehom · project thread
Fixes #33734
Clause-②: yes (widening)
Metadata-protocol: none
Seat
domain:ui#2· os-project-manager · card threadsession_01FEkQ5kWtEXh64E1jg6WPCD· claim 6892143272维护者速读
query_records等)的source;现在 AI 通过query_dataset按指标回答时,同一位置显示所用的数据集、每个指标(名称旁附机器名与口径说明)、分组维度和问题追加的筛选条件。对象查询的显示完全不变。provenance块渲染,规格DatasetProvenanceSchema也写明「An answer renders its source from this block」,但界面一直只读source,指标答案没有结构化来源块(cloud PR feat(spec)!: converge the dual-source MetadataFormat and CacheStrategy enum declarations (#4537) #4557 的发现)。detectAnswerSource的返回类型与导出类型AnswerSource放宽为两种来源的联合类型(Clause-② 放宽,见下)。浏览器缓存重载时数据集来源写回provenance键。回滚即还原本 PR。DatasetSourceSection;对象查询的筛选渲染抽成共用的AnswerSourceFilter,输出不变)、ui/packages/plugin-chatbot/src/mapMessages.ts(detectAnswerSource先读provenance)、ui/packages/app-shell/src/hooks/useChatConversation.ts(缓存写回键)。query_dataset的环境问一个指标问题(如「本月营收多少」),展开答案下的「计算方式」:应看到「数据集」「指标」「分组依据」「筛选条件」四行;问一个普通记录问题,块内容与今天相同。What changes
detectAnswerSource(mapMessages.ts) reads a tool result's top-levelprovenancethroughDatasetProvenanceSchemafirst, then the object-querysourcethroughObjectQuerySourceSchema, as before. Each is the schema's parse: an undeclared key is stripped, and a block the schema refuses is no block.query_datasetanswers onlyprovenance; the object-query tools answer onlysource.AnswerSource.tsxgainsDatasetSourceSection, chosen by the block'skind: 'dataset':description(the business definition ADR-0149 D1 asks for) under it when declared; the name alone where the label is empty;runtimeFilterlowered to rows exactly as the object-query filter is (now one sharedAnswerSourceFilter), or drawn as served when it does not lower; with noruntimeFilter, "No filter added to the dataset definition", because the dataset's ownfilterstill applies and is never served (the schema says so), so "All records" would be false.AnswerSourceSectiondraws the same rows, test ids and words; the filter markup moved intoAnswerSourceFilterbyte for byte. The 31868 pin file passes unchanged.sanitizeChatMessagesForCache(useChatConversation.ts) writes a dataset lift back underprovenance(the producer's key), an object-query lift undersourceas before, so both hydration paths lift it again on reload.AnswerSourceis now declared inmapMessages.tsasObjectQuerySource | DatasetProvenanceand re-exported fromindex.tsxunder the same name.chatbot.answerSource.dataset,metrics,noAddedFilterin all 11 packs (all-locales-key-parity); zh-Hant generated from zh-Hans (gen:zh-hant). "Grouped by" and "Filter" reuse the existing keys.content/docs/frontend/plugins/plugin-chatbot.mdxbeside the paragraph that describes the block (seat amendment 2).Clause-②: yes (widening)on@object-ui/plugin-chatbot:detectAnswerSource's return type:ObjectQuerySource | undefined→AnswerSource | undefined;AnswerSource: wasObjectQuerySource, nowObjectQuerySource | DatasetProvenance;ChatbotEnhancedToolInvocation.answerSource(inChatbotEnhanced.tsx, the one type line the seat approved):ObjectQuerySource→ObjectQuerySource | DatasetProvenance;AnswerSourceBlockProps.sources[].source(package-internal, not exported from the entry): the same union.object/filter/scopeoff anAnswerSourcenarrows onkindfirst. In this repository the only consumer outside the package,useChatConversation.ts, does..changeset/33734-answer-source-dataset-provenance.md:@object-ui/plugin-chatbot,@object-ui/i18n,@object-ui/app-shell,@object-ui/consolepatch (a widening withMetadata-protocol: noneshipspatch; app-shell is private and console'sdistships it).Tests
ui/packages/plugin-chatbot/src/__tests__/ChatbotEnhanced.answerSource-dataset-33734.test.tsx(turns built from wire parts throughuiMessageToChatMessageand drawn by the realChatbotEnhanced, the block opened by clicking its rendered trigger). The fixture is aquery_datasetanswerQueryDatasetOutputSchemaaccepts (asserted):kind, stringmeasures, stringdataset) lifts nothing;query_datasetanswer 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;runtimeFilterand no dimensions: the "no filter added" line, no grouping row, never "All records";query_datasetrefusal (no provenance) draws no block;ui/packages/app-shell/src/hooks/__tests__/useChatConversation.test.tsx: aquery_datasetprovenance survives sanitize, JSON round-trip and both hydration paths (hydratedMessagesToChatMessages,uiMessageToChatMessage), and the cached part'soutputis{ provenance }.useChatConversation.test.tsx.scripts/ablation-replace.mjs(ui vitest aliases@object-ui/plugin-chatbottosrc, no rebuild), each mutation landing on disk, each restored with the blob equal to HEAD andgit diff HEADempty, running the same three files (91 tests):provenance: 7 failed — every dataset pin and the reload pin;source: 1 failed — the reload pin;Acceptance notes
DatasetProvenanceSchemahas no member that marks a fallback (kindis 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, insidesource.line, which today's block does not draw. Labelling everyObjectQuerySourceblock 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).descriptionis drawn because it is the sentence ADR-0149 D3 says explains what the number includes; the order listed label, dataset and filters.ChatbotEnhanced.tsx: two lines only (the type import and theanswerSourcemember type), approved by the seat; this branch is rebased onto main after feat(spec, plugin-chatbot, console): the AI model picker shows each model's cost multiplier and asks before a ×20 pick #33746 merged, as the seat ordered.Verification
Local gates, type-check, lint and suites
node scripts/pm/dispatch-gates.mjs --commands --repo objectstack-ai/objectstackderives 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.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-checkinui/packages/plugin-chatbot,ui/packages/i18nandui/packages/app-shell: exit 0 each.react-refresh/only-export-componentsand friends inindex.tsx,ChatbotEnhanced.tsx,useChatConversation.ts).pnpm check:new-line-citations(fromui/): exit 0.origin/mainmoved 8 commits after 4b5024d (to c87e2ad), among them 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, which addschatbot.tool.list_datasets/query_datasetlabels to the same eleven packs in another block, and the 18.5.0 version-packages commit.git merge-treeof HEAD with c87e2ad is clean; the full app-shell suite and the rest of the farm are CI's.🤖 Generated with Claude Code
https://claude.ai/code/session_01FEkQ5kWtEXh64E1jg6WPCD
Generated by Claude Code