Repository navigation
fix(scanner): repair SD022 compile error breaking estate-wide Hypatia scan - #553
Merged
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 <[email protected]> Claude-Session: https://claude.ai/code/session_012JvDqQCW4CHxkEBAoJV5FU
hyperpolymath
marked this pull request as ready for review
June 27, 2026 10:05
hyperpolymath
added a commit
to hyperpolymath/JuliaPackageSpitter.jl
that referenced
this pull request
Oct 31, 2026
… Python-ban violation and a dead exemption (#74) Five pre-existing defects, each fixed at the detection predicate and each verified by **executing the shipped command** — not by reasoning about it. Two of my own earlier diagnoses were falsified while doing this and are corrected below rather than left standing. ## 1. The Justfile could not be parsed, so no conformance predicate ever ran `Contractile Checks` has been red at `Run must checks` on `main` (run `39701731564`) with `Run trust verifications` skipped. The cause is not any predicate. `just` reported, once installed locally: ``` error: unknown start of token '-' ——▶ Justfile:712:16 712 │ if command -v panic-attack >/dev/null 2>&1; then ``` `doctor:` is a shebang recipe, so its body belongs to bash — but the comment `# Optional tools` sat at **column 0** on line 711, which ends a recipe body. Everything after it was lexed as justfile syntax. The file could not be loaded at all, so *every* recipe in it and in the imported `contractile.just` exited 1 without evaluating anything. **Fix: one character of indentation.** A second, independent error was hiding behind it. `guix-shell` was defined twice (lines 573 and 581); `just` reports lexer errors before it checks redefinitions, so it was invisible until line 711 was fixed: ``` error: recipe `guix-shell` first defined on line 573 is redefined on line 581 ``` Fixed by renaming the fallback to `guix-shell-fallback` — **byte-identical to the rename already in PR #72**, so whichever merges first, the other applies cleanly. > **Correction withdrawn from commit `434680b`.** That message claimed the duplicate recipe was "the actual reason" Contractile was red. It was not — the lexer error was, and the duplicate was merely masked by it. Both repairs are required; only the ordering claim was wrong. ## 2. `must-spdx-headers` examined zero files and reported success The predicate searched for `*.rs`, `*.res`, `*.gleam`. This checkout contains **zero** such files, so `xargs -r` never ran, `wc -l` returned `0`, and the check passed without reading a single file. Retargeted at the extensions actually present — `.jl` (6), `.agda` (17), `.sh` (10), `.ncl` (7): **40 files, all of which already carry an SPDX header** — so this is a real check that passes today rather than a new source of red. The old `head -20` truncation is gone. A leading `test "$(find … | wc -l)" -gt 0` guard makes it **fail-closed** rather than merely non-vacuous today: without it, deleting every source file would make the predicate vacuously true again — reintroducing the exact defect being fixed. ## 3. `trust-container-images-pinned` passed if *any* line contained a digest Its description has always said "base images", plural; the command was `grep -q '@sha256:' Containerfile`. A Containerfile with a pinned build stage and an unpinned `:latest` **runtime** stage — the stage that ships — satisfied it, and it printed nothing on failure. Replaced with a walk over every `FROM` line that names each offender. The build stage is now pinned using a digest **copied programmatically** from `hyperpolymath/echidna`'s Containerfile (which pins this exact image on three `FROM` lines) and verified byte-identical afterwards: `sha256:9c2092b053779e14c82fb50f77b37bcc38b7d2c83972352d5813280f9d035b03`. It was **not** resolved against the registry — `cgr.dev` is unreachable from this environment — and inventing a digest would be a fabricated pin, worse than an honest `:latest`. Provenance and a re-resolve command are recorded in the file. `cgr.dev/chainguard/static:latest` is **left unpinned**, because no digest for it could be sourced from anywhere reachable. ## 4. `dogfood-gate.yml` enforced a Python ban using Python The `eclexiaiser-validate` step ran `python3 -c "import tomllib …"` in a repository whose own `label-triage.yml` states **"Python is fully banned estate-wide"** and **"THE CLASSIFIER IS jq, NOT PYTHON"**. A gate that breaks the rule it enforces teaches readers the ban is decorative. `jq` cannot parse TOML, so the validation is now `awk` over exactly the subset of TOML that `eclexiaiser init` emits. No interpreter, no new dependency. The old validator also only tested that `source` was a **non-empty string**. It now tests the path **exists**. That is the difference between a measurement and a claim: `eclexiaiser.toml` declared `name = "audit"`, `source = "src/main.rs"` — a Rust path that has never existed in this Julia package — and the validator printed `Valid`. The manifest now declares the real entry point, `generate_package` in `src/generator.jl`. ## 5. `.hypatia-ignore` claimed an exemption for a file that does not exist Its only entry was `cicd_rules/banned_language_file:examples/SafeDOMExample.res`. That file is gone; `examples/` holds only `quickstart.jl`, and no `.res` file exists anywhere here. A ledger claiming an exemption for absent material asserts this repo contains banned content and has been permitted to keep it, and hides the fact that the ReScript migration is **complete**. The ledger now claims zero exemptions — the intended end state of one that "can only shrink as work is done". The file is kept because it is the location the governance gate names in its failure message. ## Verification `just` 1.59.0 was installed from `rust-just-linux-x64` on `registry.npmjs.org` (reachable here, unlike the release-asset host serving the GitHub extension and the `just.systems` installer), and the shipped commands were executed: | check | result | |---|---| | `just --list` | loads; ~60 recipes enumerated (was: lexer error) | | `just must-check` | **exit 0** — "All must checks passed"; first time these four predicates have ever executed | | `just trust-verify` | exit 1, failing **only** at `unpinned base image: FROM cgr.dev/chainguard/static:latest` | | same, from a clean clone of HEAD | `must-check` PASS | | declaration vs generated `contractile.just` (both predicates) | byte-identical | | SPDX predicate + header-less `src/noheader.jl` fixture | exit 1, names the file | | SPDX predicate + tree with no source files | exit 1 — guard holds | | container predicate + both stages pinned | exit 0 | | container predicate + no Containerfile | exit 0 | | container predicate + build pinned, runtime unpinned | exit 1 (**old predicate: PASS** — the hole) | | eclexiaiser validator: real manifest | exit 0 | | …with `source = "src/main.rs"` | exit 1, names the missing path | | …with no `[[functions]]` / empty `project.name` / missing `source` | exit 1 each, distinct diagnostics | The `run:` block was extracted from the YAML itself rather than paraphrased, and executed under `bash -e` as the runner does. `grep -c .` calls carry `|| true` because `grep` exits 1 on a zero count, which under `bash -e` would abort the step before any diagnostic printed. ## Interaction with PR #72 * The `guix-shell-fallback` rename is **identical** to #72's, so merge order does not matter for it. * #72's `Justfile` hunks are naming-only. **It does not fix line 711**, so if #72 merges alone, `just` still cannot load the file and `Contractile Checks` stays red at `Run must checks` with the predicates still unreachable. * `Trustfile.a2ml` / `Mustfile.a2ml`: #72 edits only the `@abstract:` line (hunk `@@ -2,7 +2,7 @@`); this PR edits the predicate blocks. Disjoint. * `contractile.just` is not in #72 at all. * `eclexiaiser.toml`: #72 renames the retired repo name on lines 2 and 5; this PR changes only the `[[functions]]` block. Disjoint. The naming sweep is deliberately left to #72 — until it merges, the validator's success line still prints the retired name. ## What this PR does not fix * **`Contractile Checks` stays red, deliberately.** It could have been made green by pinning one image and keeping the weak `grep -q` predicate — the runtime stage would have stayed `:latest` behind a green check. The remaining failure is one line and one decision: supply a real digest for `cgr.dev/chainguard/static`, or drop the runtime stage. Deleting the Containerfile would also pass it, via the predicate's own `test ! -f` branch — that is the check ceasing to apply, not being satisfied. * **On this PR the job currently fails earlier, at `Install just`** — a `curl https://just.systems/install.sh | bash` step that succeeded on run `41090111140` and failed on `41090784666` with identical content. An external pipe-to-shell install is unreliable; #72 replaces it with a pinned, checksummed `cargo install just --version 1.36.0 --locked`, which matches `.tool-versions`. That is a good change and this PR does not duplicate it. * **`🔴 GATE: Package identity` is red here and on `main`.** It needs the naming sweep carried by #72; that work is not duplicated here. * **`governance / *`, `mirror / *`, Secret Scanner** — cross-repo reusable-workflow callers cannot satisfy lockfile enforcement in any of the three possible `actions.lock` states. Measured in closed PR #73, which carries the evidence table. Not fixable from a calling repository (`gh-actions-lock#179`). * **`Hypatia Neurosymbolic Analysis` red on `main` is stale, not live.** The failing run died in `Build Hypatia scanner` on 2026-10-25; **every run since — including this PR's, at 54s — is `success`**, and hypatia's default branch moved on 2026-10-30. `main` has not re-run the workflow because nothing has been pushed to it, and a check-run stays attached to its commit indefinitely. `workflow_dispatch` returns 403 for this token, so re-running it on `main` needs the owner. (An earlier draft of this body attributed the fix to `hyperpolymath/hypatia#553`, merged 2026-06-27 — which predates the October failure and so cannot explain it. Withdrawn.) * **The four checks named `Dependabot`.** No workflow here emits that name (`dependabot-automerge.yml`'s job is `automerge`, and its recent runs are all `skipped` by its actor guard), so these are platform-generated check-runs, most likely open Dependabot alerts. The alerts API returns 403 for this token, so that is a hypothesis and is not acted on. --------- Co-authored-by: arena-agent <[email protected]>
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