fix(scanner): repair SD022 compile error breaking estate-wide Hypatia scan - #553
Merged
Conversation
#545's rewrite of sd022_stale_path_after_rename/1 left a dangling `real_subdirs` after the binding was renamed to `real_basenames` (src_dir_index/1). `mix escript.build` fails with "undefined function real_subdirs/0", which breaks the Hypatia scan job estate-wide — the reusable workflow clones hypatia and builds the escript before scanning, so every consumer repo's scan dies at build. Fixes: - real_subdirs -> real_basenames in the final reject. - The lookbehind regex has one capture group, so the 2-group `[_, prefix, dir]` destructure could never match (FunctionClauseError after the compile error was resolved); reduced to `[_, dir]` and removed the now-unused real_path_reference?/4 + foreign_prefix?/2 (the negative lookbehind already excludes prefixed/foreign refs). - Guard also checks File.dir?(repo/src) so an empty `src/<dir>` directory still counts (git ls-files cannot see empty dirs). Verified locally: mix test test/structural_drift_test.exs -> 32 tests, 0 failures; module compiles via elixirc. Co-authored-by: Claude <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_012JvDqQCW4CHxkEBAoJV5FU
hyperpolymath
marked this pull request as ready for review
June 27, 2026 10:05
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.
Problem —
maindoes not compile, so every repo'sscanis redThe Hypatia reusable workflow
git clones this repo and runsmix escript.buildbefore scanning. As of #545 (7df53b1b),mainfails to build:So
scan / Hypatia Neurosymbolic Analysisdies at "Build Hypatia scanner" on every consumer repo in the estate (surfaced while verifying #464 — the cache pin is fine, this is the real blocker).Root cause
#545 rewrote
sd022_stale_path_after_rename/1and renamed the bindingreal_subdirs→real_basenames(now produced bysrc_dir_index/1), but left a danglingreal_subdirsreference in the finalEnum.reject. Two further latent defects from the same half-finished refactor:[_, prefix, dir](two groups) and calledreal_path_reference?/4— aFunctionClauseErrorwaiting to fire once the compile error was cleared.src_dir_index/1switched togit ls-files, which cannot see an emptysrc/<dir>directory — so the early-return guard would wrongly short-circuit (this is exactly what the existing test"flags docs referencing src/<dir>/…"sets up).Fix (minimal, behaviour-preserving)
real_subdirs→real_basenamesin the final reject.[_, dir]and remove the now-unusedreal_path_reference?/4+foreign_prefix?/2(the lookbehind already excludes prefixed/foreign refs, so they were dead).File.dir?(repo/src)so an emptysrc/<dir>still counts.Net diff: +4 / −25 in one file.
Verification
Ran the real suite locally (Elixir 1.14 / OTP 25):
(All four
sd022_*tests pass, pluselixirccompiles the module clean — reproduced the originalCompileErrorfirst, confirmed it's gone after.)Once
maincompiles again, the estate-widescanlane unblocks. Closes the scan-side of #464.Drafted by Claude Code; please run
mix test/mix escript.buildin CI before merge.Generated by Claude Code