Skip to content

fix: #480 Detector 1 of the #467 home-path guard enumerated tests/fixtures/ non-recursively - #485

Merged
fdaviddpt merged 2 commits into
mainfrom
fix/480
Sep 1, 2026
Merged

fdaviddpt merged 2 commits into
mainfrom
fix/480

Conversation

@fdaviddpt

@fdaviddpt fdaviddpt commented Sep 1, 2026 •

Copy link
Copy Markdown
Contributor

Closes #480.

Detector 1 of the #467 home-path guard (tests/test_no_real_home_paths_467.py) enumerated tests/fixtures/ with FIXTURES_DIR.iterdir(), which only ever sees the immediate children of that directory. A real /Users/<x>/ or /home/<x>/ segment committed inside a subdirectory of tests/fixtures/ would be invisible to the detector at any depth, and its own positive control (test_scanned_at_least_one_fixture_file, asserting len(files) >= 2) could not have noticed -- it is satisfied by the 4 top-level files alone, which is exactly why the issue's own MUST-FIRE fixture had to sit at the top level to pass.

Fix: _fixture_files() now walks with FIXTURES_DIR.rglob("*") filtered by is_file().

New tests, all pointing the scan at a synthetic tree via monkeypatch.setattr(f"{__name__}.FIXTURES_DIR", tmp_path) since the real tests/fixtures/ has no subdirectories today and cannot exercise depth on its own:

  • test_fixture_scan_descends_into_subdirectories -- MUST FIRE, the enumeration alone
  • test_detector_fires_on_a_home_path_nested_in_a_fixture_subdirectory -- MUST FIRE, the full detector end to end, at depth
  • test_detector_does_not_fire_on_a_sanitised_path_in_a_fixture_subdirectory -- MUST NOT FIRE, the paired negative control at the same depth
  • test_fixture_scan_reports_how_many_files_it_examined -- the receipt half of the issue's own fix note ("recursion plus a receipt naming how many files were actually examined, so an empty walk cannot read as a clean one")

Red before the fix (2 failed, 1 passed, 9 deselected), green after (12 passed).

Review round 1 finding, fixed in a second commit. Both the spawned reviewer and the spawned auditor independently caught the same issue in the first commit: the receipt test compared len(files) == len(git ls-files tests/fixtures) for exact equality. rglob("*") walks the filesystem, not the git index, so a file that physically exists under tests/fixtures/ but isn't tracked -- a stray .DS_Store, .gitignored in this repo but created by Finder just from browsing the folder -- would make the walk's count disagree with git's count for a reason unrelated to any missed subtree. Reproduced (touch tests/fixtures/.DS_Store -> AssertionError: fixture scan examined 5 file(s) but git tracks 4), then fixed by switching to a subset check: every git-tracked file under tests/fixtures/ must be present in what the walk found, without demanding the walk find nothing else -- still catches a dropped subtree, no longer trips on an untracked stray file. Re-verified both directions.

BELOW-BAR NOTE: none raised in this round; both review findings were fixed in-scope.

Docs: README.md (this repo's only docs_targets entry) opened; it describes tests/fixtures/codex-rollout.jsonl only in an unrelated paragraph about #443 and says nothing about the guard's own internals -- no-change-needed. Changelog fragment added at changelog.d/480.fixed.md, checked with .oss/assemble_changelog.py --check (ok).

Scope: tests/test_no_real_home_paths_467.py and changelog.d/480.fixed.md only, per the brief -- no touch to pipeline/, scripts/user-prompt-hook.sh, scripts/save-session.sh or scripts/session-end-hook.sh, which other concurrent lanes hold.

Verified by the maintainer

Independent of the lane, at review of this pull request. The report's platform field is null and the body says nothing about the cross-platform dimension the brief asked for, so I read the file rather than leave that unanswered.

The platform question does not bite, and the reason is worth stating. _HOME_PATH = re.compile(r"(?:/Users/|/home/)([A-Za-z0-9_.-]+)") is matched against file contents, not against filesystem paths -- the detector scans the committed bytes of each fixture, which carry whatever separators they were captured with, independent of the host reading them. rglob("*") plus is_file() is separator-neutral, and relative_to(REPO_ROOT) appears only in offender messages. So the widened walk behaves identically on a backslash-separated host. That claim is reasoned from reading the code, not observed on Windows -- and this detector cannot be observed there, per the next point.

The thing a reviewer should actually know about this guard: it does not run on CI at all. The file's own argued correction (lines 78-100) records why -- windows-latest runs as runneradmin, which appears legitimately in tests/test_stale_config_sweep_362.py as a realistic Windows home-path fixture, and #472 turned the CI pass into a live false positive. A per-image skiplist was rejected as wrong-by-construction on the next image. That is a deliberate, well-argued scope decision, not an oversight -- but it means this fix widens a detector whose only execution is local. The matrix will not exercise the recursion this pull request adds; a maintainer running pytest will.

Accepted as reported: the red run (2 failed, 1 passed), the depth-paired MUST-FIRE / MUST-NOT-FIRE, and the review round that caught the receipt test's exact-count comparison against git ls-files and moved it to a subset check. I did not re-run the suite; the lane's own module run is green and CI is the gate for the rest.

…-recursively

`_fixture_files()` used `FIXTURES_DIR.iterdir()`, which only ever sees the
immediate children of tests/fixtures/, so a real /Users/<x>/ or /home/<x>/
segment committed inside a subdirectory would be invisible to the detector
at any depth. The detector's own positive control (`>= 2` file count)
could not have caught this: it is satisfied by the top-level files alone,
which is exactly why the issue's own MUST-FIRE case had to be planted at
the top level to pass.

Switched to `FIXTURES_DIR.rglob("*")`, and added:
- a MUST-FIRE case proving the enumeration itself now descends into a
  synthetic subdirectory (the real tests/fixtures/ has none today, so a
  synthetic tree is the only way to exercise depth at all)
- a MUST-FIRE case driving a nested #467-shaped home path through the
  real detector logic end to end, not just the bare regex
- a MUST-NOT-FIRE case proving the widened walk does not start firing on
  the sanitised placeholder segment at that same depth
- a receipt test that cross-checks the number of files the scan examined
  against `git ls-files tests/fixtures`, so a walk that silently drops a
  subtree disagrees with a number instead of passing quietly (the fix
  note in #480 asked for recursion plus this)

Scope: tests/test_no_real_home_paths_467.py only.

Co-Authored-By: Max <noreply>
…sts/fixtures/

Review of the prior commit (e77b27d) caught it: the receipt test added
for #480 compared `len(_fixture_files())` against `len(git ls-files
tests/fixtures)` for exact equality. `rglob("*")` walks the filesystem,
not the git index, so a file that exists on disk but is not tracked --
reproduced with a stray `.DS_Store`, which is `.gitignore`d in this
repo but still visible to the walk -- makes the counts disagree for a
reason that has nothing to do with a missed subtree. A contributor who
has ever opened tests/fixtures/ in Finder on macOS could hit this
locally.

Switched to a subset check: every git-tracked file under
tests/fixtures/ must be present in what the walk found, without
demanding the walk find nothing else. That still catches the #480
regression (a dropped subtree drops tracked files from the walk's
result) and stops asserting against files nobody tracks. Reproduced
both directions: `touch tests/fixtures/.DS_Store` no longer fails the
suite; the file still fails if a tracked fixture goes missing from the
walk's output.

Co-Authored-By: Max <noreply>
@fdaviddpt
fdaviddpt merged commit 99f8f87 into main Sep 1, 2026
13 checks passed
@fdaviddpt
fdaviddpt deleted the fix/480 branch September 1, 2026 19:40
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.

Detector 1 of the #467 home-path guard enumerates tests/fixtures non-recursively, and its positive control cannot notice a missed subtree

1 participant