fix(console): drop retired ToolSchema keys from the tool preview sample (#3257) - #3269
Merged
xuyushun441-sys merged 1 commit intoAug 3, 2026
Merged
Conversation
The `tool` sample in the metadata-designer gallery declared `category`, `active` and `requiresConfirmation` — three keys `ToolSchema` retired and now rejects by name (objectstack#3896; objectstack#3715 / ADR-0033 §2). The sample is not a fixture: it is the worked example an author sees in the designer's preview gallery, so it was teaching authors — and, more often, models generating metadata — to write a tool definition that `ToolSchema.parse()` refuses outright. Since objectui#3236 `ToolPreview` no longer renders these keys either, so they were pure noise. Also adds the guard that makes this class of rot a CI failure instead of a lesson taught to the next author: each sample is embedded in a whole stack and handed to `ObjectStackSchema.safeParse()`, which is the authoring contract itself — no hand-picked schema export (the obvious pick for `email_template` is the runtime send payload, not the authorable record) and no Zod internals. The audit it came from found `tool` was not alone: 12 of 20 samples fail today, 4 of them carrying retired keys of exactly this kind. Those are recorded in the test's `KNOWN_STALE` ledger with a reverse assertion — an entry that starts passing fails the build and demands promotion, so the list can only shrink — and tracked in objectui#3266. No changeset: `preview-samples.ts` is dev-only. `preview-gallery.html` is not a Vite build input, so none of this reaches the published `dist`. Fixes #3257 Co-Authored-By: Claude Opus 5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01NVPjPzmmAJ2Ngtvgg5MSRa
|
The latest updates on your projects. Learn more about Vercel for GitHub. |
Contributor
✅ Console Performance Budget
📦 Bundle Size Report
Size Limits
|
xuyushun441-sys
marked this pull request as ready for review
August 3, 2026 09:24
xuyushun441-sys
deleted the
claude/issue-3257-console-tool-sample-retired-keys
branch
August 3, 2026 09:24
This was referenced Aug 3, 2026
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 #3257
改了什么
apps/console/src/preview-samples.ts的tool样例删掉三行:category/active/requiresConfirmation。样例其余部分(name/label/description/objectName/parameters/outputSchema)全部保留 —— 实测这份删完之后ToolSchema直接 ACCEPT。另外新增一条机器守卫
apps/console/src/__tests__/preview-samples-spec-valid.test.ts,把「样例过期」从静默腐烂变成 CI 报红。为什么这不只是清理
这份样例不是测试夹具,是设计器预览画廊里给作者看的范本。范本的隐含承诺是「照抄就能用」,而它已经违约了:三个键都被
.strict()的ToolSchema逐个具名拒收,谁照抄谁就得到一份ToolSchema.parse()当场拒绝的元数据。这正是 AI 生成元数据最容易照抄并放大的位置 —— 坏范本不是错一次,是持续传播。和 #3236 是同一次三仓扫描的两半,但危害形态不同:#3236 是「UI 宣传了不存在的能力」,本单是「范本在教人写错」。#3236 之后
ToolPreview也不再渲染这三个徽标,这三行成了纯噪音。守卫怎么写的(这是本 PR 的大头)
校验方式是把样例塞进一整个 stack,交给
ObjectStackSchema.safeParse():而不是去 import 一个手挑的
XxxSchema。两个理由,都是写的过程中踩出来的:ObjectStackSchema本身就是作者契约 —— 作者能发布的形态。按名字猜 schema 会猜错:email_template最顺手的那个EmailTemplateSchema其实是运行时发信载荷(id/body/bodyType),真正可编写的记录是EmailTemplateDefinitionSchema(name/label/subject/bodyHtml)。读集合不可能挑错。._def去剥optional > array > …迟早会在 Zod 换版本时静默解错(或者更糟:空过)。让 wrapper 自己剥,这条测试问的就恰好是那个该问的问题 —— 这份样例如果被作者发布进真实 stack,会怎样?守卫分四层:
classifies every sample exactly onceSPEC_CLEAN/KNOWN_STALE/NO_AUTHORING_SCHEMA之一。明天新加的样例逃不掉分类,否则报红%s sample is valid metadata.parse()(含本次修好的tool)%s sample still fails as recordedSPEC_CLEAN—— 台账只会缩短,不会变成垃圾堆tool sample does not resurrect retired key %s破坏性验证(sabotage)
把
category: 'data'和requiresConfirmation: false加回样例后重跑,三层同时报红:已还原,当前 24/24 绿。
顺带核对了同文件其它全部 19 个样例(派发要求第 2 点)
结论:
tool不是唯一一个 —— 20 个样例里 12 个当前过不了.parse(),其中 4 个带的是和本单完全同型的已退役键(action.bulkEnabled、agent.tools/agent.knowledge、skill.triggerPhrases、flow.waitEventConfig.onTimeout)。view、job、tool(本 PR 修完)、permission、position、email_templateobject、page、report、dashboard、app、action、flow、agent、skill、datasource、validation、translationworkflow、approval(spec 只有ApprovalNodeConfigSchema,那是 flow 节点配置)这 12 个本 PR 没修,而是进了测试里的
KNOWN_STALE台账(每条写明具体原因),并立了 objectui#3266 跟踪。没顺手修的理由不是偷懒:object.fields的数组形态是 app-shell 有意支持的,不是笔误 ——previews/object-fields-io.ts的readFields()显式分支shape: 'array' | 'record'并原样保留。把样例改成 record 会让画廊不再覆盖 array 那条分支;真正该先裁决的是这个双形态要不要留(AGENTS.md #0.1 的典型场景),而不是先改样例。dashboard/app/flow样例会改变画廊渲染出来的东西,而预览画廊是本仓共用的浏览器验证台,并行 agent 正拿它验证别的改动。apps/console的tool样例 + 审计 + 守卫;PD#3 要求越界发现另立单。translation那条要特别说明:ObjectStackSchema.translations是Array< Record< locale, TranslationData > >,而 console 这份样例是{ name, label, locale, language, description, data }的元数据记录形态 —— 更可能是映射选错而非样例过期,已在测试注释和 #3266 里如实标注,没有硬套。守卫的强度上限(如实记录,别过度信任)
守卫有多严取决于 spec 有多严:
tools/apps/flows/permissions/positions/datasources的元素 schema 是.strict(),而views/jobs/emailTemplates不是 —— 后者把未知键悄悄剥掉而不报错。也就是说这三类样例即便混进一个已退役的键,守卫照样绿。这一点写在测试文件头部,免得后来者误以为「绿 = 没有退役键」。这是 spec 仓的事(objectstack#4001 / #3896 同一条线),已记在 #3266 备查。为什么没有 changeset
preview-samples.ts文件头就写着 DEV-ONLY;实测apps/console/vite.config.ts没有input:配置,Vite 默认只以index.html为入口,preview-gallery.html不是生产构建入口 —— 这份样例根本进不了发布的dist,对@object-ui/console的消费者不可见。加上 AGENTS.md §9「纯 bug 修复不需要 changeset」,故不加。验证
相关
ToolPreview侧的同型残留)category/active审计关闭)、objectstack#3715 / ADR-0033 §2(requiresConfirmation退役)🤖 Generated with Claude Code
https://claude.ai/code/session_01NVPjPzmmAJ2Ngtvgg5MSRa
Generated by Claude Code