Repository navigation
test(dedup-finder): 把 keep_rank 的深度契约钉在所有 runner 上(#54 遗留的搁浅 commit) - #57
Merged
Merged
Conversation
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.
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.
#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 这一级_walk里的.replace(os.sep, "/")最后一条是固有的、不是缺口:那个调用在 POSIX 上按定义就是空操作,所以任何「只在 POSIX 上跑」的断言都看不到它。套件能抓到的是它的后果——depth 变成恒 0——而那正是缺失归一在 Windows 上造成的结果。护栏守的是后果,不是那一行。
顺带更正一处说过头的话
原 commit 的 fixture 注释把这些断言称作「那个分隔符修复的唯一非 Windows 护栏」,这话不准确(见上:删掉归一那一行在本机抓不到)。已改写成「实际钉住的是什么、钉不住的是什么」。
验证
smoke.sh镜像ruff check skills src testssmoke.shpytest -qpyright纯测试改动,
dedup_finder.py未动。