Repository navigation
feat(spec)!: converge the dual-source MetadataFormat and CacheStrategy enum declarations (#4537) - #4557
Merged
Conversation
…y enum declarations (#4537) Two enum vocabularies were declared on both ./shared and ./system and had diverged on their VALUES — which accepted value set you got depended on nothing but the import path (the #4411 trap; #4535 A2, #4506 baseline). Value-level divergence is the silent kind: a mismatched value never fails to compile. MetadataFormat / MetadataFormatSchema — shared declaration is the single source: - system/metadata-persistence.zod.ts no longer declares its own 7-member copy; it re-exports shared/metadata-types.zod (the MetadataManagerConfig pattern, in reverse). The extension-style aliases yml/ts/js it carried had zero producers in this repo, objectui and cloud: FilesystemLoader.detectFormat normalizes at the boundary (.yml -> 'yaml', .ts -> 'typescript', .js -> 'javascript') and the database/remote/memory loaders always emit 'json'. - Direction: shared, not system — kernel/metadata-loader.zod has imported the shared schema since #4411 (MetadataManagerConfig.formats needs no change), and system already re-exports MetadataManagerConfigSchema FROM kernel, so a system-side source would close a module cycle (shared -> system -> kernel -> shared). CacheStrategy — system/cache.zod.ts (CacheStrategySchema) is the single declaration: - shared/enums.zod.ts CacheStrategyEnum (+ its CacheStrategy type export) removed: zero importers in all three repos, while the system schema is the one CacheTier.strategy gates on. Same disposition as AggregationFunctionEnum in the same file (objectui#2945): removed rather than reconciled. - 'adaptive', declared only on the system side with zero producers, is dropped — the enum carries the four values both declarations agreed on (lru | lfu | fifo | ttl). Bookkeeping: - dual-source-exports.baseline.json: the three converged rows deleted (shrink-only ratchet). - json-schema.manifest.json: shared/CacheStrategyEnum key deleted (deliberate retirement, #2978 flow). - Pin tests: yml/ts/js rejected on the system entry; 'adaptive' rejected on CacheStrategySchema. - api-surface.json, references docs, skill refs regenerated via check:generated --fix. - Changeset (major) carries the FROM -> TO migration lines. - No ADR-0087 conversion / tombstone: loader envelope + config vocabulary with no authorable-metadata producers (the #4411/#4536 route). Co-Authored-By: Claude Opus 5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01M9uWvoEp9CoLzYjNExj9sL
|
The latest updates on your projects. Learn more about Vercel for GitHub. 1 Skipped Deployment
|
Contributor
📓 Docs Drift CheckThis PR changes 1 package(s): 107 hand-written doc(s) reference the affected code and may need an implementation-accuracy re-verification:
|
os-zhuang
marked this pull request as ready for review
August 2, 2026 04:07
This was referenced Aug 2, 2026
This was referenced Nov 15, 2026
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>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Fixes #4537
#4535 A2 项:
MetadataFormat/MetadataFormatSchema/CacheStrategy在./shared与./system各有一份声明,且分歧在枚举值上——值不匹配不会编译错,是比形状分歧更易出静默 bug 的一类(#4411 陷阱)。三条基线行全部收敛并删除。前置核查结论(三仓扫描:本仓 + cloud + objectui)
yml/ts/js三个别名:零生产者 ⇒ A1 同款收窄。packages/metadata/src/loaders/filesystem-loader.ts的detectFormat在边界处归一化:.yml→'yaml'、.ts→'typescript'、.js→'javascript'——扩展名别名从不进入format字段;'json';--format旗标是输出格式(json/yaml/table),不同域。CacheStrategy分歧 ='adaptive'(仅 system 侧声明,零生产者)。shared/enums.zod.ts的CacheStrategyEnum(4 值)三仓零 importer;system/cache.zod.ts的CacheStrategySchema(5 值)是CacheTier.strategy实际引用的一份。真源侧判定(import 语句级)
MetadataFormat:shared 为真源,system 收敛为 re-export(MetadataManagerConfig模式、反向)。运行时消费者(packages/metadata 的 4 个 serializer + filesystem-loader)从@objectstack/spec/system导入——re-export 后符号同一,零改动;kernel/metadata-loader.zod自 spec 同名双源:两个MetadataWatchEvent形状不同、分挂两个子路径入口,其中 kernel 版零消费方(ADR-0049 enforce-or-remove) #4411 起从 shared 导入,无需回改。方向不能选 system:system 已从 kernel re-exportMetadataManagerConfigSchema(system → kernel → shared 依赖链),真源放 system 会闭环成模块循环。CacheStrategy:system/cache.zod成为唯一声明。shared 侧零 importer,按同文件AggregationFunctionEnum先例(objectui#2945)删除而非调和——为一个概念保留第二个名字正是词汇当初漂移的成因;'adaptive'一并收窄,枚举保留两份声明曾共同认可的 4 值(lru | lfu | fifo | ttl)。变更清单
system/metadata-persistence.zod.ts:删除本地 7 值MetadataFormatSchema,re-export shared 声明(4 值);类型同步 re-export;单一来源注释更新。shared/enums.zod.ts:删除CacheStrategyEnum+CacheStrategy类型(附与AggregationFunctionEnum同款的处置注释)。system/cache.zod.ts:CacheStrategySchema收窄掉'adaptive'。yml/ts/js拒绝 pin;cache 侧'adaptive'拒绝 pin;shared enums 测试删除对应块。dual-source-exports.baseline.json:删除 3 条基线行(shrink-only ratchet 点名的正是这 3 条,无额外 stale 行)。json-schema.manifest.json:删除shared/CacheStrategyEnum(deliberate retirement,gen:schema silently drops PageTabsProps since #2967 — references regen would delete real docs #2978 流程)。api-surface.json(./shared 少 2 个导出)、references 文档、skill refs 均由check:generated --fix再生。'yml'→'yaml'、'ts'→'typescript'、'js'→'javascript';CacheStrategyEnum→@objectstack/spec/system的CacheStrategySchema;'adaptive'→ 4 值之一)。无 ADR-0087 conversion / tombstone:loader envelope + 无 authorable 生产者的配置词汇,同 #4536/#4411 路线(
authorable-surface.json无涉及;存量sys_metadata行不携带别名值——DB loader 恒写'json')。验证
check:dual-source-exports:✅ 无新增,49 条 accepted(3 条已删)check:generated:✅ 8/8 artifacts up to datepnpm --filter @objectstack/spec test:285 files / 7246 tests 全绿pnpm --filter @objectstack/spec typecheck(tsc --noEmit):✅pnpm build:71/71 ✅pnpm test:132/132 turbo tasks ✅(exit 0)关联:#4535(主单)、#4506(基线)、#4411、#4536(同款处置先例)
Generated by Claude Code