Skip to content

feat(hygiene): detect orphan config files by reachability (#155) - #156

Merged
Jammy2211 merged 1 commit into
mainfrom
feature/hygiene-orphan-config-files
Jul 23, 2026
Merged

feat(hygiene): detect orphan config files by reachability (#155)#156
Jammy2211 merged 1 commit into
mainfrom
feature/hygiene-orphan-config-files

Conversation

@Jammy2211

Copy link
Copy Markdown
Contributor

Part 1 of PyAutoBrain#155 — the detector

/hygiene config could not see orphan config files. _hygiene_config.py iterated only library yamls and skipped any without a workspace counterpart, so a workspace file the libraries never shipped was structurally invisible — how a dead config/grids.yaml survived in 10 repos for ~a year (autolens_workspace#317).

What this adds

An orphan-file pass beside the existing key-mirror diff. A workspace config/**/*.yaml with no library counterpart at the same relative path is an orphan.

The signal is reachability, not filename similarity — a pure filename check is ~120 hits, nearly all legitimate, because whole subtrees are owned by something other than the libraries. Those owners are named in an explicit ORPHAN_OWNERS map and suppressed:

  • build/* → PyAutoHands release tooling
  • priors/*JSONPriorConfig class-path resolution

Deliberately an in-checker map, not a per-repo .hygieneignore — 20 new files and a config surface that can itself go stale is the exact failure mode being fixed.

The library's own shipped set encodes the verdict: it ships non_linear/GridSearch.yaml (live) but not non_linear/{nest,mle,mcmc}.yaml (dead), so the pass keeps the first and surfaces the rest with no per-file rule. Only repos whose config/ mirrors the library tree (share ≥1 file) are scanned, self-scoping to workspace/test/assistant repos and excluding organ repos — no hardcoded list.

Acceptance (all verified)

Case Expected Result
real pre-#317 grids.yaml blob flag
non_linear/{nest,mle,mcmc}.yaml today flag
build/* silent
priors/* silent

A check that cannot re-find the bug that motivated it is not validated — the grids.yaml retrospective runs against the real blob at ce99ca12b^.

What it found

Running it surfaced 26 dead non_linear files across 9 repos and a third cluster the ticket did not name — visualize/include.yaml in 2 test repos (no library ships it, nothing reads conf.instance["visualize"]["include"], no Include2D class, user-facing workspaces already dropped it). Both are removed in the Part-2 PRs below.

Tests

tests/test_hygiene_conductor.py: a suppressed-vs-flagged orphan fixture (the owner map is the part most likely to rot) and a non-mirror-repo skip. 16 passed. Stdlib+PyYAML only; the PyYAML-absent sys.exit(1) fallback preserved; folded into the same count|summary prescan line.

Part 2 — cleanup PRs (the dead config this found)

autocti_assistant, autocti_workspace, autocti_workspace_test, autofit_workspace_developer, autofit_workspace_test, autogalaxy_workspace_test, autolens_assistant, autolens_workspace_test, euclid_strong_lens_modeling_pipeline — all on feature/hygiene-orphan-config-files.

Closes #155.

`/hygiene config` could not see orphan config FILES: `_hygiene_config.py`
iterated only LIBRARY yamls and skipped any without a workspace counterpart, so
a workspace file the libraries never shipped was structurally invisible. That
blind spot let a dead `config/grids.yaml` survive in 10 repos for ~a year
(autolens_workspace#317).

Add an orphan-file pass beside the existing key-mirror diff. A workspace
`config/**/*.yaml` with no library counterpart at the same relative path is an
orphan. The right test of a config file is REACHABILITY (does anything read
it), not filename similarity — a pure filename check is ~120 hits, nearly all
legitimate, because whole subtrees are owned by something other than the
libraries. Those owners are named in an explicit ORPHAN_OWNERS map and
suppressed: `build/*` (PyAutoHands release tooling) and `priors/*`
(JSONPriorConfig class-path resolution). Deliberately an in-checker map, NOT a
per-repo `.hygieneignore` — 20 new files and a config surface that can itself
go stale is the exact failure mode being fixed.

The library's own shipped set encodes the verdict: it ships
`non_linear/GridSearch.yaml` (live) but not `non_linear/{nest,mle,mcmc}.yaml`
(dead), so the pass keeps the first and surfaces the rest with no per-file rule.
Only repos whose config/ MIRRORS the library tree (share >=1 file) are scanned,
which self-scopes to the workspace/test/assistant repos and excludes organ
repos without a hardcoded list.

Acceptance (all verified): flags the real pre-#317 `grids.yaml` blob, flags
`non_linear/*` on today's tree, stays silent on `build/*` and `priors/*`. A
check that cannot re-find the bug that motivated it is not validated.

Folded into the same `count|summary` prescan line; stdlib+PyYAML only; the
PyYAML-absent `sys.exit(1)` fallback is preserved.

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
@Jammy2211
Jammy2211 merged commit 2102169 into main Jul 23, 2026
@Jammy2211
Jammy2211 deleted the feature/hygiene-orphan-config-files branch July 23, 2026 18:49
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.

feat: give /hygiene sight of orphan config files (reachability-based)

1 participant