Skip to content
This repository was archived by the owner on Nov 4, 2026. It is now read-only.
This repository was archived by the owner on Nov 4, 2026. It is now read-only.

两处生成器锚规则逐名 expect、首个不匹配即抛:一批 dependabot 同时漂多个区间时只报第一个,要一轮修一个(#4098 已观察未落地) #4974

Closed

Description

@yinlianghui

Filed unassigned while implementing #4968 (PR #4969). 不在那个 PR 范围内(它是区间跟进,这是门自身的报告完整性)。

现象

全仓有两个「生成器模板区间 = 仓内区间」的 ratchet 测试:

  • packages/cli/src/__tests__/app-generator.test.ts — sources every range from this repo instead of inventing one,13 个名字(DEPENDENCY_ANCHORS)
  • packages/create-plugin/src/__tests__/templates.test.ts:356 — sources every devDependency range from this repo instead of inventing them,8 个名字(DEV_DEPENDENCY_ANCHORS)

两者都是在 for 循环里逐名 expect,而 expect 失败即抛,所以一次只报第一个不匹配的名字。表是插入序遍历的,于是「谁先漂」还取决于名字在表里的位置,而不是严重性。

代价(今天实测到的)

#4968 处理时,lucide-react 在 cli 表里排在 postcss / react / tailwindcss / typescript / vite 之前,所以它遮住了后面 6 个名字的判定 —— 门给不出「这一批 dependabot 到底漂了几个区间」这个信息。我只能另写脚本把两张表全量算一遍才敢说「各只漂一处」(结果见 PR #4969 的两张表)。

更实际的代价是跨包的:create-plugin 那处当时在 main 上也是红的(@testing-library/jest-dom ^7.0.0 vs 根 ^7.0.1,来自 #4948),但因为它在另一个包、另一个测试文件,packages/cli/ 绿之前根本没有任何东西报它。如果我只按 issue 的包边界扫,#4968 落地后全仓仍然是红的,需要第二轮。

这条一周前已被写下

#4098 的 "Suggested first step" 结尾就写了:

then re-read both test files for any other range they pin that this morning's other five bumps have already moved — shiki, maplibre-gl, react-hook-form and next all landed in the same window and only the first mismatch in each file is reported.

当时靠人工「再读一遍两个文件」补上,机制没改;七天后同一个盲区又让第二处模板藏了一轮。

建议修法

把逐名 expect 改成累积后一次断言,保留现有的信息量。cli 侧大意:

const drifted: string[] = [];
for (const [name, anchor] of Object.entries(DEPENDENCY_ANCHORS)) {
  // ... 前置断言(根里必须存在 / 仓内必须一致)保持立即抛,它们是仓库事实而非漂移
  if (generated !== expected) {
    drifted.push(`${generator} manifest's ${name}: ${generated} should be ${expected}`);
  }
}
expect(drifted).toEqual([]);

要点两条:

  1. 前置断言与漂移断言要分开。 「name must exist in the root manifest」「in-repo manifests disagree on name … settle on one range first」是关于仓库状态的前提,立即抛是对的;只有值不匹配这一类该累积。
  2. 两个文件都要改,否则跨包盲区还在 —— 这正是今天那处的成因。

顺带:两处的 anchor 表都值得在同一次里加一句注释,说明「门只判本表内的名字」,以及新增模板依赖必须同时进表(完整性门已经在管这个,但两条规则分居两个 it 里,读的时候不明显)。

分类说明

这条没有用户面影响,只影响门的报告质量与修复轮数,PM 若判为 observation-class 可加 finding 标签;我按「今天确实兑现了代价、且是第二次」当作具体缺陷提交,不自行降级。

Activity

  1. yinlianghui commented on Aug 17, 2026

    @yinlianghui
    ContributorAuthor

    这一族今天又活了一次:main 现在(@ 590dd6356)在两个 shard 上红。 不另立卡(#4098 是同一缺陷的上一轮,已关;本卡持有这一族的「逐名 expect、一轮修一个」观察),把实测记在这里。

    在 #3832 的 PR(#4975)分支上把 origin/main merge 进来后本地复现,与该 PR 的改动无关(它只动 ComponentInput.type 与五处声明,不碰任何 package.json / 模板):

    packages/cli/src/__tests__/app-generator.test.ts
      × sources every range from this repo instead of inventing one
        routed manifest's lucide-react must match its in-repo range:
        expected '^1.29.0' to be '^1.31.0'
      × writes a manifest whose @object-ui ranges name this CLI version
        expected '^1.29.0' to be '^1.31.0'
    
    packages/create-plugin/src/__tests__/templates.test.ts
      × sources every devDependency range from this repo instead of inventing them
        @testing-library/jest-dom range must match the repo root:
        expected '^7.0.0' to be '^7.0.1'
    

    来源:今天两轮 dependabot —— #4946(patch-updates,lucide-react 1.29→1.31)与 #4948(dev-dependencies,@testing-library/jest-dom 7.0.0→7.0.1)。两轮都只移了仓内区间,没移生成器模板里的那份副本。

    同一次 merge 里第三条红是 #4911(spec 17.0.0 GA 的 $like / $ilike,packages/fields 的 FilterConditionField.operators.test.ts)—— 那张卡已经开着,main 把 @objectstack/spec 从 ^17.0.0-rc.6 推到 ^17.0.0 之后它就是活的。

    也就是说 main 今天有 三条 红、跨三个包,全部由「pin 前移、跟随面没跟」造成 —— 正好是本卡说的「一轮修一个」在同一天里撞了三次。对本卡的判据没有新增,只是又一个实测样本;顺带给后面所有基于今天 main 的 PR 一个归因,免得每个 agent 都当成自己的红重查一遍(#4975 就查了一轮)。


    Generated by Claude Code

  2. self-assigned this
    on Aug 17, 2026
  3. yinlianghui commented on Aug 17, 2026

    @yinlianghui
    ContributorAuthor

    认领(objectui 车道分片 PM,会话 session_01GTRjn8xBqp75dk7kFupVRt,批次 20 补席,替换前提证伪关卡的 #4017):branch claude/issue-4974-anchor-cumulative-report。按卡面建议实施:两处生成器锚规则(app-generator.test.ts / templates.test.ts)从「逐名 expect 首败即抛」改累积断言(一轮报全部漂移),前置断言与漂移断言分开;#4098/#4968 两次事故的「一轮修一个」形状即验收反例。


    Generated by Claude Code

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Type

No type

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions