Uh oh!
There was an error while loading. Please reload this page.
test(layout): pin the README Registration key list to registerLayout() (#4860) - #4893
Merged
Merged
Conversation
#4860) The same component-key list is published in three places. Two were held to source -- the guide's sentence by guide-layout-sidebar-nav-doc.test.ts (#4840) and the keys' existence by app-shell-not-a-component-key.test.tsx (#4841) -- and packages/layout/README.md's `## Registration` paragraph was not. Measured asymmetry: #4841 deregistered `app-shell`, the guide's list went red and forced the page to change, the README's list named the same retired key and nothing noticed. Both directions, each with its own diagnostic: a key the README names but the barrel does not register (a reader authors it and gets the OBJUI-001 `Unknown component type` panel), and a key the barrel registers that the README does not name (a live authoring surface nobody can discover). Both lists are parsed on every run -- hardcoding them here would reproduce #3899's own defect, whose prose listed a `sidebar-nav` key this package has never registered. A third test asserts the floors as a visible fact: two set differences are both trivially green on two empty lists, so a regex that stops matching would silently turn the pin into a no-op. README.md itself is unchanged -- its list has been correct since PR #4859. Co-authored-by: Claude <noreply@anthropic.com>
Empty frontmatter: test-only, no published source and no behaviour change. The gate guards `src/**`, and a new pin under `src/__tests__/` lands there, so the declaration is what answers it. Co-authored-by: Claude <noreply@anthropic.com>
Contributor
✅ Console Performance Budget
📦 Bundle Size Report
Size Limits
|
yinlianghui
commented
Aug 17, 2026
CollaboratorAuthor
PM 验收:ACCEPT(#4860,批次 15,PM 会话 实物核验(已过)
测试设计
反向验证
CI(亲读终态):19 项 check runs 全 completed,17 success + 2 skipped(path-filter 计绿),零失败。 附带产出:新 finding #4894 已立卡入池。 → undraft + auto-merge (SQUASH)。 Generated by Claude Code |
yinlianghui
marked this pull request as ready for review
August 17, 2026 02:41
Uh oh!
There was an error while loading. Please reload this page.
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 freeto 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#4860
背景:三处同源键表,只有这一处没有钉子
@object-ui/layout的组件键表在仓内发布在三个地方,其中两处早已机械钉到源码:content/docs/guide/layout.md的 "registers five keys …" 句guide-layout-sidebar-nav-doc.test.ts(#4840)packages/layout/src/index.ts键的存废app-shell-not-a-component-key.test.tsx(#4841)+side-effects-manifest.test.ts(只有数量下限)packages/layout/README.md的## Registration段这个不对称是实测出来的,不是推断:#4841 撤销
app-shell注册时,guide 的键表被钉子打红、逼出了文档修改;README 的键表列着同一个已撤销的键,没有任何测试发现,最后是 PR #4859 里人工改对的。「有人读到了」不是机制。README 是本包的 npm 首屏 —— 列一个没人注册的键,等于读者照着写那个节点、拿到渲染器的红框Unknown component type(OBJUI-001)。改动
只加两个文件,README.md 本体零修改(自 PR #4859 起它就是对的):
packages/layout/src/__tests__/readme-registration-keys.test.ts— 新钉子.changeset/layout-readme-registration-keys-pin.md— 空 frontmatter(纯测试,不发布任何包)钉子形态:双向
照 #4840 钉 guide 的形态,但拆成两个方向、两条独立诊断,因为它们是两种不同的缺陷:
app-shell注册后在 schema 路径上不可用:四个 ReactNode 插槽 JSON 一个都填不了,inputs 又为空,节点解析得到却永远渲染不出壳 #4841 的形状;更早是 packages/layout:sideEffects: falsecontradicts the load-timeregisterLayout()— a side-effect-only import can be tree-shaken away #3899 的幽灵sidebar-nav)。第三条测试把下限断言成显式事实:两个集合差在两个空列表上都是平凡绿,所以正则一旦不再匹配(README 改写、注册调用改用双引号),上面两条会静默变成空操作。这条同时挡住重复项 —— 重复项能让两个集合差都为空,而两份列表其实并不相同。
顺序不比较:列表恰好按注册顺序排列是好习惯、不是契约;一个因重排就变红的钉子,读者会学会绕开它。
期望值一律从源码读出,绝不写死
在测试里硬编码这五个键,正是这个钉子要防的缺陷本身:#3899 自己的散文就自信地列了一个本包从未注册过的
sidebar-nav。所以两侧每次运行都重新解析 —— 红了永远是「改 README(或改 barrel)」,绝不是「更新测试」。这个解析有一个值得写下来的依赖:源码侧读的是
ComponentRegistry+.register(的正则,因此src/index.ts注释里逐字引用一个 register 调用会被当成活注册。index.ts用散文描述那个已撤销的app-shell调用正是为此(#4841 留下的注释),本钉子是第三个受益者,文件头注释里也记了这条。为什么是新文件,而不是扩
readme-app-shell-example.test.ts那个文件(#4817)自述的扫描面是 AppShell 开标签与
AppShellProps表格,且只读 README 与AppShell.tsx。Registration 键表是关于src/index.ts的事实 —— 本包已有的 README 钉子从不打开这个源。按包内既有惯例(readme-sidebar-nav-example.test.ts/readme-app-shell-example.test.ts),一个被记录的关注点配一个钉子文件。两处与派单预判不同的形态,记录在案
sidebar-navJSON 节点,键表也与 SidebarNavProps/NavItem 全面不符 #4840 的 guide 句子做(锚点词之间用\s+,列表体用[^)]*),而不是照表格行做 —— guide 那条钉子正是被一次纯重排打红过,才留下这个教训。packages/layout/README.md的注册键表是三处同源键表里唯一没有钉子的一处 —— #4841 撤app-shell时它是唯一没被打红的 #4860 把它列为选项 A 的附带项。这条正则在仓内已有三份副本(guide-layout-sidebar-nav-doc.test.ts、app-shell-not-a-component-key.test.tsx、side-effects-manifest.test.ts),本 PR 是第四份。刻意不提取:为服务一个钉子去改三个钉子文件,而这些文件是故意自包含的 —— 一个从共享模块导入自己读取器的钉子,可以在它所守护的文件之外被静默架空。理由写在新文件的头注释里。反向验证(两个方向,先预判后跑)
预判写在跑之前:方向 A 只让第 1 条红、方向 B 只让第 2 条红,且两次
packages/layout其余 16 个测试文件全绿 —— 后者才是本单前提的实测证据。方向 A —— README 键表加一个假键
fake-key:方向 B —— README 键表删掉活键
app-schema-renderer:两次都与预判逐字相符,而且两次其余 16 个文件全绿 —— 即在本 PR 之前,README 键表向任一方向漂移,仓内没有任何东西会发现。这正是 #4860 立单所依据的事实,现在被测量下来了。
还原用
git checkout -- packages/layout/README.md,未用git stash(stash 栈跨 worktree 共享,AGENTS.md 明令禁止)。验证
还原后全绿:
type-check 用的是包级脚本而非仓根
turbo run type-check全量:改动是packages/layout内一个新增测试文件,不被任何包导入,能编译它的正是该包的tsconfig.test.json(已跑,干净);容器内多 agent 并行,全量 type-check 属于无谓的重扫。Generated by Claude Code