spec: view union identity precondition (#5599) - #6280
Merged
qq9340100 merged 2 commits intoAug 7, 2026
Conversation
#5599) `ViewMetadataSchema` accepted any object at all. Its fourth union member (`FormViewSchema.extend(…).strip()`) both strips unknown keys and declares no required key — `type` even carries a `'simple'` default — so it matched every object and handed the whole union a wildcard. Measured on origin/main: getMetadataTypeSchema('view').safeParse({ nope: 1 }) -> success, data = { type: 'simple' } saveMetaItem({ type: 'view', name: 'garbage_view', item: { nope: 1 } }) -> { success: true, state: 'active', seq: 1 } persisted body = {"nope":1,"name":"garbage_view"} `saveMetaItem` persists the ORIGINAL body, so a wrong-shaped view became an active overlay that renders nothing, and the read path re-parsed it through the same schema and badged it `_diagnostics.valid: true` (#5598). `view` was the one common overlay type whose declared write-path validation (ADR-0005 §Validation) could be bypassed outright — declared != enforced at union MEMBER SELECTION, one level above the object schemas #4001 closed. Direction B of the ruling: a minimal identity precondition ahead of all four arms. A body must carry at least one key some member declares, discounting the keys the write path stamps itself (`name` always; `viewKind`/`object`/ `label` inherited from a shadowed registry entry, #2555) — those are present on every body reaching the gate and so carry no evidence. The bar is shape, not completeness: `{ isPinned: true }` still saves. No arm's `.strip()` changed — the #5074 round-trip capability is untouched, and direction A (a required floor on member 4) stays deferred. The check reports through the existing `z.preprocess` stage's `ctx` rather than as an extra pipe stage. An added stage satisfies the output-direction `anyOf` pin and silently degrades the INPUT direction to `{}`, which would leave Studio's SchemaForm rendering nothing. Verified byte-identical `/api/v1/meta/types/view` emission in both directions. - vocabulary derived from the members, never hand-listed, so a new arm key widens it in the same edit - `VIEW_WRITE_PATH_IDENTITY_KEYS` exported so the producer side is pinned: `normalizeViewMetadata` may not stamp a key outside it without going red - `{}` pin in view-metadata-schema.test.ts reversed, with the reasoning it used to carry and why the measurement contradicted it Co-Authored-By: Claude Opus 5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01Gn96jhbN7TGSPzjBDsZfXx
…w-union-identity-precondition
|
The latest updates on your projects. Learn more about Vercel for GitHub. 1 Skipped Deployment
|
Contributor
📓 Docs Drift CheckThis PR changes 1 package(s): 112 hand-written doc(s) reference the affected code and may need an implementation-accuracy re-verification:
|
qq9340100
marked this pull request as ready for review
August 7, 2026 13:56
qq9340100
deleted the
claude/issue-5599-view-union-identity-precondition
branch
August 7, 2026 14:24
os-zhuang
pushed a commit
that referenced
this pull request
Aug 7, 2026
main 上有 8 个参考页在本分支开出后被重生成(#6243、#6280、#6281、#6333 等), 其中 `ui/bulk-action.mdx` 与 `automation/state-machine.mdx` 与本分支相交。 两棵独立重生成的树会零冲突合并却落地陈旧组合,故按 os-regen 钩子的要求从合并后的 树重新 `gen:schema && gen:docs`,并在合并结果上重跑全部验证: - 参考语料 216 页 / 8548 个单元格,check:docs 232 个生成文件 in sync - MDX 编译 216/216 - @objectstack/spec: 337 个测试文件 / 8614 个测试通过,typecheck 干净 Co-Authored-By: Claude Opus 5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_014wsZeReNTqiceBfLb5Pyf5
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 #5599
View union 判别身份前置条件收紧(#5599 验收面)。
Generated by Claude Code