fix(console): un-invert the validation sample's condition and drop 4 silently-stripped keys - #3282
Merged
xuyushun441-sys merged 1 commit intoAug 3, 2026
Conversation
…stripped keys (#3276) `ScriptValidationSchema.condition` is the FAILURE predicate — "Predicate (CEL). If TRUE, validation fails." The `amount_positive` sample declared `condition: 'amount > 0'`, i.e. it failed every order with a positive amount and passed every non-positive one: the exact opposite of its own name and message. Corrected to `amount <= 0`, matching the direction of the spec's own examples (`record.amount < 0`, `discount_percent > 0.40`). The spec guard added in #3257 structurally cannot catch this — it asks whether a draft parses, never whether it means what its author intended — and an inverted sample is worse than a broken one: the broken one gets fixed, the inverted one gets copied, usually by a model. Also removes four keys that parsed and were then silently dropped, since neither the validation branches nor SkillSchema are `.strict()`: - validation.object a rule's scope IS its host object's validations[] - validation.field exists on state_machine/format/json_schema, not script - validation.expression not a key on any validation branch - skill.type SkillSchema classifies by `surface`, not `type` `field` was found by auditing every sample for input keys missing from the parse result; the same audit's other findings are out of scope here and filed as #3280 (view/job/email_template) and #3281 (ValidationPreview). No changeset: `preview-samples.ts` is dev-only. It is reached only from `preview-gallery.tsx` via `preview-gallery.html`, and `vite.config.ts` declares no `rollupOptions.input`, so the build's sole entry stays `index.html` — the samples never reach `dist/`, which is what the published package ships. 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 10:26
xuyushun441-sys
deleted the
claude/issue-3276-validation-sample-semantics
branch
August 3, 2026 10:27
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 #3276
1.
condition的方向(主要问题)先按 dispatch 的要求核了契约再动手。
node_modules/@objectstack/spec/src/data/validation.zod.ts:119:确认无误:
condition是失败谓词,不是不变式。同文件顶部的 Salesforce 对照也是同一方向 ——condition: 'discount_percent > 0.40'配 message「Discount cannot exceed 40%」,写的都是非法的情形。样例原本是
condition: 'amount > 0',配name: 'amount_positive'和 message「Order amount must be greater than zero.」—— 按契约,它会在金额为正时判定失败,把每一条合法订单拦下、把每一条非法订单放行,和自己的名字与消息正好相反。改为'amount <= 0'。这类错误 #3257 的守卫结构上抓不到(它只问「能不能 parse」),而危害恰恰更大:parse 不过的样例会被修,语义反了的样例会被照抄 —— 抄的人通常是模型。
2. 四个会被静默剥掉的键
validation各分支与SkillSchema都不是.strict(),所以这些键 parse 能过、解析结果里却不存在:validation.objectvalidations[]上,宿主就是它的作用域validation.fieldstate_machine/format/json_schema三支,script没有validation.expressionskill.typeSkillSchema用surface(ask/build/both)分类,没有type,更没有'prompt'field是 issue 正文没列的第三个 —— 它是我按 dispatch 第 3 条机械审计所有样例时找出来的(见下)。它今天已经被剥掉,所以删除它在运行时零变化;只是不再教作者写一个没用的键。要把错误指到某个字段,spec 的正解是type: 'cross_field'+fields: ['amount'](同一条求值路径,fields[0]决定违规挂在哪个字段上)—— 这一点已写进文件注释。按⚠️ 提示,这四个键没有加进
RETIRED_KEYS:它们不是被退役的键,是在这些 schema 上从来没存在过的键,两件事不能混。3. 全样例审计(dispatch 第 3 条)
把每个样例按守卫测试的方式嵌进
ObjectStackSchema,safeParse后逐层比对输入/输出的 key 集合,输入有、输出没有的即为被剥掉的键。修完之后validation与skill归零;其余发现不在本 PR 修,已按 Prime Directive #10 立为未指派 issue:timeoutMs是拼错的timeout#3280 ——view(name/label/object/list.object,ViewSchema是个没有身份键的容器)、job(concurrency,以及拼错的timeoutMs,真键是timeout)、email_template(from应为fromOverride;to是发送期入参,不是授权期元数据)。另附「静默剥键」机械检查的建议 —— 并说明它是结构性检查,不是本 issue 拒掉的那种语义断言。ValidationPreview读expression、scope ?? where,还有个 spec 里不存在的unique分支 —— #3275 漏掉的那个 preview #3281 ——ValidationPreview.tsx读celText(d.condition) ?? celText(d.expression)(给一个从来不存在的键做别名回退,AGENTS.md #0.1),还有个 spec 里已被明确裁掉的case 'unique'分支。这是 metadata-admin previews 仍在读取 spec 已拒收的键(AgentPreview/SkillPreview/AppPreview/DatasourcePreview),预览会为一份存不下去的草稿画出「正常」界面 #3275 那张表漏掉的第五个 preview,同在packages/app-shell,不在本 PR 的 scope fence 内。按 issue 第 3 条与 dispatch 的 ⛔,没有往
preview-samples-spec-valid.test.ts里加任何语义断言。验证
validation与skill都留在SPEC_CLEAN里,守卫全绿。type-check:本 worktree 里pnpm --filter @object-ui/console type-check报TS2307: Cannot find module '@object-ui/types'等 —— 工作区包未构建所致,与本改动无关:git stash后在干净树上重跑,报错完全相同(CI 会先构建)。改动文件单独过 tsc 干净:预览渲染的实际影响(已读
ValidationPreview.tsx确认,无崩溃):object芯片不再显示(规则本来就没有object);field只在非script分支被读,本样例零变化;condition照常渲染。不加 changeset(已复核)
preview-samples.ts仅被preview-gallery.tsx引用,后者仅由preview-gallery.html引入;apps/console/vite.config.ts里没有rollupOptions.input(grepinput:命中 0 次),因此 Vite 的构建入口只有默认的index.html,preview-gallery.html不是构建输入。发布物files: ["dist", …]中的dist由该构建产出,样例不会进入 —— 对用户不可见。#3269 / #3277 的判断成立。Generated by Claude Code