Skip to content

Fix bless_scope leaf-key '/' mangling and unattributed '?' bucket (#3143) - #3147

Merged
squid-protocol merged 2 commits into
mainfrom
fix/bless-scope-3143
Sep 17, 2026
Merged

squid-protocol merged 2 commits into
mainfrom
fix/bless-scope-3143

Conversation

@squid-protocol

Copy link
Copy Markdown
Owner

Closes #3143.

Problem

bless_scope.py is the documented review path for golden-master blesses (#3141), so its bucketing being lossy matters. Two defects:

  1. Unattributed ? bucket (~51 diffs). golden_diff.deep_compare emits three line shapes — ⚠️ MISMATCH at …, ➕ EXTRA KEY FOUND: …, ➖ MISSING KEY: … — but bless_scope parsed 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.
  2. Leaf keys containing / were mangled. deep_compare joined paths as f"{path}/{key}" and bless_scope split on every /, so an archetype bucket like I/O & Config Routines Files was cut at the wrong boundary (rendered as O & Config Routines Files), and distinct keys could collide.

Fix

  • tests/golden_diff.py: deep_compare now threads the path as a tuple of segments and returns a DiffLine(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 _AT regex. 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, and str/join compatibility for the other callers.

Verification

  • New + existing tests: pytest tests/tools/test_bless_scope.py tests/test_golden_crucible.py → pass.
  • mypy tests/golden_diff.py clean; ruff rule-code set identical to origin/main (no new violations).
  • No golden-master fixtures touched; deep_compare's displayed output is unchanged.

)

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>
Comment thread tests/tools/test_bless_scope.py Fixed
@github-actions

Copy link
Copy Markdown
Contributor

🐦‍⬛ Muninn Security Scan

✅ No security issues found.

🐦‍⬛ Powered by Muninn · Skald Lab

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>
@squid-protocol
squid-protocol merged commit bab58c0 into main Sep 17, 2026
28 checks passed
@squid-protocol
squid-protocol deleted the fix/bless-scope-3143 branch September 17, 2026 21:26
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.

bless_scope: leaf keys containing '/' are mangled, and 51 differences land in an unattributed '?' bucket

2 participants