Repository navigation
Fix bless_scope leaf-key '/' mangling and unattributed '?' bucket (#3143) - #3147
Merged
Merged
Conversation
) golden_diff.deep_compare built diff-line paths as f"{path}/{key}" strings and emitted three shapes (MISMATCH / EXTRA KEY / MISSING KEY). bless_scope re-parsed those strings with a regex that matched only the MISMATCH shape and then split the path on every '/'. Two defects resulted: 1. Every EXTRA/MISSING KEY diff failed the regex and fell into an unattributed '?' bucket (~51 diffs, ~1.5% of a real bless), invisible to the top-down read the tool's own docstring prescribes. 2. A leaf key that itself contains '/' -- e.g. the archetype bucket "I/O & Config Routines Files" -- was split at the wrong boundary, showing a mangled name and letting distinct keys collide into one bucket. Fix: deep_compare now threads the path as a tuple of segments and returns a DiffLine(str) subclass that renders byte-for-byte identically to before (so the three other callers -- test_golden_crucible, scope_check, update_golden_master, which print/join/regex the strings -- are unaffected) while carrying structured .segments and .kind. bless_scope buckets directly from .segments/.kind, dropping the fragile MISMATCH-only regex; unattributable items get an explicit "(unparsed)" label instead of a silent '?'. Adds tests/tools/test_bless_scope.py covering slash-in-key segment integrity, the '?'-bucket regression, and str/join compatibility for the other callers. Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
Contributor
Co-authored-by: Copilot Autofix powered by AI <62310815+github-advanced-security[bot]@users.noreply.github.com> Signed-off-by: Joe Esquibel <joe.m.esquibel@gmail.com>
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.
Closes #3143.
Problem
bless_scope.pyis the documented review path for golden-master blesses (#3141), so its bucketing being lossy matters. Two defects:?bucket (~51 diffs).golden_diff.deep_compareemits three line shapes —⚠️ MISMATCH at …,➕ EXTRA KEY FOUND: …,➖ MISSING KEY: …— butbless_scopeparsed them with a regex (_AT) that matched only the MISMATCH shape. Every added/removed key therefore fell into a silent?bucket, invisible to the top-down read the tool's own docstring prescribes./were mangled.deep_comparejoined paths asf"{path}/{key}"andbless_scopesplit on every/, so an archetype bucket likeI/O & Config Routines Fileswas cut at the wrong boundary (rendered asO & Config Routines Files), and distinct keys could collide.Fix
tests/golden_diff.py:deep_comparenow threads the path as a tuple of segments and returns aDiffLine(str)subclass. The human-readable text is byte-for-byte unchanged, so the three other consumers —test_golden_crucible.py("\n".join),scope_check.py(regex + print),update_golden_master.py/golden_diff.py __main__(print) — are unaffected. The subclass additionally carries.segments: tuple[str, ...]and.kind(mismatch/extra/missing).tests/tools/bless_scope.py: buckets directly from.segments/.kind, removing the fragile_ATregex. Slash-bearing leaf keys stay intact; EXTRA/MISSING keys are attributed to their section; anything genuinely unparseable gets an explicit(unparsed)label rather than a silent?.tests/tools/test_bless_scope.py(new): slash-in-key segment integrity, the?-bucket regression, andstr/joincompatibility for the other callers.Verification
pytest tests/tools/test_bless_scope.py tests/test_golden_crucible.py→ pass.mypy tests/golden_diff.pyclean;ruffrule-code set identical toorigin/main(no new violations).deep_compare's displayed output is unchanged.