fix(skills): stabilize content_hash ordering for shared-prefix paths - #53877
fix(skills): stabilize content_hash ordering for shared-prefix paths#53877lucifer0114 wants to merge 1 commit into
Conversation
|
Boundary note for reviewers: This PR is intentionally scoped only to the What it includes:
What it intentionally does not include:
I split those concerns on purpose so this PR can stay narrowly reviewable as the hash-ordering fix, while #41199 / follow-up work can handle the lock-state side separately. I also validated this split on a live downstream checkout after updating to current
Result: |
Duplicate of #53448 -- both Fix #53404 by rewriting |
tonydwb
left a comment
There was a problem hiding this comment.
Code Review Summary
Verdict: Approved
Content hash ordering fix for shared-prefix paths (2 files). Regression test + implementation:
- Test
test_bundle_content_hash_matches_on_disk_when_file_and_dir_share_prefixcatches the exact bug scenario (file vs dir prefix collision) - Fix uses deterministic
sorted()ordering forrglobresults - Clean, minimal change to the hash computation
Good regression coverage for a subtle ordering bug.
tonydwb
left a comment
There was a problem hiding this comment.
Code Review Summary
Verdict: Approved
Content hash ordering fix for shared-prefix paths (2 files). Regression test + implementation:
- Test
test_bundle_content_hash_matches_on_disk_when_file_and_dir_share_prefixcatches the exact bug scenario (file vs dir prefix collision) - Fix uses deterministic
sorted()ordering forrglobresults by relative POSIX path strings - Clean, minimal change to the hash computation
The key insight: sorting Path objects directly can disagree with pure string ordering when a file and nested directory share a prefix (e.g. references/styles.md vs references/styles/blueprint.md). Sorting by the .as_posix() string ensures consistency with bundle_content_hash().
Good regression coverage for a subtle ordering bug.
Reviewed by Hermes Agent
|
Closing as a duplicate of #53448. I compared both PRs directly: they implement the same This does not affect #53881, which is a separate stale-lock self-heal fix. |
Summary
content_hash()sort on the same relative POSIX path string that it hashesbundle_content_hash()Why
content_hash()currently sortsPathobjects but hashes the relative POSIX string. Those two orderings are not guaranteed to match. When a skill contains both a file and a nested directory sharing a prefix (for examplereferences/styles.mdandreferences/styles/blueprint.md), unchanged content can hash in a different byte order and trigger false update reports.Test plan
scripts/run_tests.sh tests/tools/test_skills_hub.pytest_bundle_content_hash_matches_on_disk_when_file_and_dir_share_prefixFixes #53404
Related to #41176