fix(validate): unify GenUI runtime schema validation - #106
Merged
Conversation
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.
Summary
修复 #102 中
validate_dsh_ui与实际 GenUI 渲染语义不一致的问题,并进一步统一 GenUI 的 runtime schema、字段归一化、校验与 renderability 判断,避免字段名或字段类型错误在 repair 阶段被静默丢弃后仍通过校验或渲染空壳组件。Closes #102
问题
此前 GenUI 的协议规则分散在 validator、repair、renderer 和 tool 中,导致部分输入存在以下情况:
card.label/content、table.headers/data、callout.kind、steps.items等字段无法被统一识别;validate_dsh_ui可能返回 ✅,但 renderer repair 后静默删除字段;render_ui、fence renderer、presentation meta 对同一 spec 的 renderability 判断可能不完全一致。改动
1. 引入统一的 GenUI runtime schema
新增并扩展 component schema registry,集中描述:
同时从 schema registry 派生 native component type 集合,减少协议定义漂移。
2. 统一字段 alias normalization
将常见模型输出兼容字段归一化为 canonical schema,包括:
card.label -> titlecard.content -> itemstable.headers -> columnstable.data -> rowscallout.kind -> tonesteps.items -> stepstext.text、badge.text/value、tabs[].content等兼容行为。canonical 字段与 alias 同时存在时优先保留 canonical,并输出明确 warning。
3. 补齐 runtime validation
runtime schema 现在会参与实际校验,包括:
例如此前可能被 repair 静默删除的:
card.title = 123callout.tonesteps[].title类型错误plot.series[].kind非法值现在会在 render 前直接报告错误。
4. 统一 chart semantic validation
将 chart renderability 规则收口到 guard 的共享实现中,
chart-contract.ts仅保留兼容 API,避免 plugin 与 renderer 分别维护 chart 协议。5. 统一 renderability 判断
新增共享
isRenderableProcess(),并用于:render_ui.executerender_ui.presentationMeta避免同一个 spec 在不同入口出现“一个认为合法、另一个仍然渲染”的情况。
6. 修复 native node drop detection
拆分:
declaredNativeCountrenderedNativeCountrenderedTotalCountnative drop detection 仅比较 native/native,避免 opaque custom node 或 file-tree data 掩盖被 repair 删除的 native component。
7. 增强字段诊断
对 native component、root spec 以及部分 nested records 增加 unknown-field diagnostics,同时继续保持 custom renderer payload opaque,不检查或重写插件自定义数据。
测试
新增/更新测试覆盖:
render_ui/validate_dsh_ui/ fence renderability 一致性;