Skip to content

test(dedup-finder): 把 keep_rank 的深度契约钉在所有 runner 上(#54 遗留的搁浅 commit) - #57

Merged
skyzhao1223 merged 1 commit into
mainfrom
test/pin-keep-rank-sep-contract
Oct 9, 2026
Merged

skyzhao1223 merged 1 commit into
mainfrom
test/pin-keep-rank-sep-contract

Conversation

@skyzhao1223

Copy link
Copy Markdown
Owner

#54 的分支被压缩时,子代理有一个 commit 55c588e 落在了分支上但没进 main。它只改测试,价值在于补上 #54 那个分隔符修复的回归护栏。

为什么需要它

#54 让 dedup-finder 输出正斜杠相对路径,好让 keep_rank() 的深度这一级(item["path"].count("/"))在 Windows 上生效。但这个修复只在 windows-latest 上可观测:POSIX 上 os.sep 本就是 /,把 .replace(os.sep, "/") 删掉不会产生任何本地信号。

实测:删掉那一行后,本 skill 的 smoke 套件在 macOS 上仍然全过。

这些断言用间接方式补上:它们把路径直接喂给纯函数,所以在任何 runner 上行为一致;并且让 fixture 的深度这一级变成载荷性的——年龄刻意与深度打架(临时/2024 深度 2 却比 临时 深度 1 更旧;工作/终稿/深层 深度 3 是全局最新),所以手推的 EXPECT_C 只有在深度这一级真的生效时才成立。

变异测试(在 macOS 上跑,即对这些断言最不利的情况)

变异 结果
keep_rank 去掉 depth 这一级 ✅ 被抓到
depth 改成数两种分隔符 ✅ 被抓到
depth 恒为 0(= Windows 上的实际症状) ✅ 被抓到
prefer 这一级失效 ✅ 被抓到
删掉 _walk 里的 .replace(os.sep, "/") ❌ 存活

最后一条是固有的、不是缺口:那个调用在 POSIX 上按定义就是空操作,所以任何「只在 POSIX 上跑」的断言都看不到它。套件能抓到的是它的后果——depth 变成恒 0——而那正是缺失归一在 Windows 上造成的结果。护栏守的是后果,不是那一行。

顺带更正一处说过头的话

原 commit 的 fixture 注释把这些断言称作「那个分隔符修复的唯一非 Windows 护栏」,这话不准确(见上:删掉归一那一行在本机抓不到)。已改写成「实际钉住的是什么、钉不住的是什么」。

验证

检查 结果
两份 smoke.sh 镜像 ✅ 逐字节一致;全部 skill 副本同步
ruff check skills src tests ✅ All checks passed
9 个 smoke.sh ✅ 全过
pytest -q ✅ 201 passed (3.12) / 179 passed + 1 skipped (3.9)
pyright ✅ 0 errors
变异跑完后 scanner 本体 ✅ 零差异(没留下扰动)

纯测试改动,dedup_finder.py 未动。

Cherry-picks 55c588e, which was left stranded on feat/config-overrides-
scanners3 when that branch was squashed for #54, and corrects one overstated
claim in its comments.

The separator fix in #54 made dedup-finder emit forward-slash relative paths so
that keep_rank()'s depth tier — `item["path"].count("/")` — works on Windows.
But that fix is only *observable* on windows-latest: on POSIX `os.sep` is
already "/", so deleting `.replace(os.sep, "/")` produces no local signal at
all. Measured here: with that line removed, this skill's smoke suite still
passes on macOS.

These assertions close the gap indirectly. They feed paths straight to the pure
function, so they run identically on every runner, and they make the fixture's
depth tier load-bearing: the ages deliberately contradict the depths
(临时/2024 at depth 2 is older than 临时 at depth 1; 工作/终稿/深层 at depth 3 is
the newest file overall), so the hand-derived EXPECT_C is only correct while the
depth tier actually fires.

Mutation-tested on macOS, i.e. the hardest case for these assertions:

  remove the depth tier from keep_rank        -> caught
  make depth count both separators            -> caught
  make depth identically 0 (the Windows bug)  -> caught
  break the prefer tier                       -> caught
  delete `.replace(os.sep, "/")` in _walk     -> NOT caught (survives)

The last one is inherent rather than a gap: on POSIX that call is a no-op by
definition, so no POSIX-only assertion can see it. What the suite does catch is
its *consequence* — depth becoming identically 0 — which is exactly what the
missing normalisation causes on Windows. The guard covers the effect, not the
line. The fixture comment previously described these assertions as "the only
non-Windows guard for the separator fix", which overstated it; rewritten to say
what is actually pinned and what is not.

Test-only. Verified: both mirrored smoke.sh byte-identical and every skill copy
in sync; ruff clean; all 9 smoke.sh pass; pytest 201 (3.12) and 179+1 skipped
(3.9); pyright 0 errors; the scanner itself has zero diff after the mutation
runs, so nothing was left perturbed.
@skyzhao1223
skyzhao1223 merged commit d3665bc into main Oct 9, 2026
10 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant