Skip to content

test(arch-lint): never walk the Hypothesis cache in the repository inventory - #4388

Merged
Daniel Meppiel (danielmeppiel) merged 1 commit into
mainfrom
danielmeppiel-inventory-vanish-winerror
Nov 20, 2026
Merged

Daniel Meppiel (danielmeppiel) merged 1 commit into
mainfrom
danielmeppiel-inventory-vanish-winerror

Conversation

@danielmeppiel

Copy link
Copy Markdown
Collaborator

Description

Fix-forward for red main. Main push b9ba827, Windows units 3/3: tests/unit/scripts/test_architecture_skills_root_guard.py::test_open_coded_skills_root_is_flagged[...] failed with cannot inventory repository: [WinError 3] The system cannot find the path specified: '...\.hypothesis\tmp'. Hypothesis deleted its temp dir while the architecture inventory was walking the checkout.

Fix (scripts/architecture_linter/inventory.py): .hypothesis joins the generated tool caches (.pytest_cache, .ruff_cache, .mypy_cache, which were already excluded) as an anywhere-excluded name, so the walk never descends into it.

Walk errors on real source directories stay fail-closed, unchanged from accb621's Copilot-review fold: a vanished source subtree is never silently dropped from the architecture linter. I deliberately did not add a blanket ENOENT/WinError 3 tolerance, since that would reopen that hole. Excluding the cache removes the race at its source.

Tests (tests/unit/scripts/test_architecture_inventory.py):

  • test_tool_cache_vanishing_mid_walk_is_never_walked: mocks os.scandir to raise the Windows path-not-found OSError (errno ENOENT, winerror=3) for .hypothesis at the root and nested. The inventory succeeds and lists nothing under it. Mutation break: without the exclusion, this test fails.
  • test_windows_path_not_found_in_source_still_fails_closed: the same OSError on src/ still aborts the inventory.
  • The frozen EXCLUDED_ROOTS tuple is updated.

Issue and approved scope

Issue: Refs #3983

Human scope-approval comment: delivery-manager-directed fix-forward for red main (0.37 release mechanics); test tooling only.

Does this PR complete the issue, or what remains? It clears this Windows inventory race only.

Type of change

  • Bug fix
  • New feature
  • Documentation
  • Maintenance / refactor

Testing

  • Tested locally

  • All existing tests pass

  • Added tests for new functionality (if applicable)

  • Via the host guard local-test.sh: pytest -p no:xdist tests/unit/scripts/test_architecture_inventory.py passed (24 passed).

  • Mutation: with .hypothesis removed from the exclusion, -k tool_cache gives 1 failed.

  • ruff check / ruff format --check (0.15.12) on scripts/architecture_linter/, scripts/lint_architecture_boundaries.py and the changed test: clean.

Changelog

  • One line in one section under ## [Unreleased] in CHANGELOG.md.
  • N/A -- internal-only change (CI, tests, refactor).

Spec conformance (OpenAPM v0.1)

  • N/A -- this PR does not change OpenAPM-observable behaviour.

…ventory

Windows units 3/3 on main (b9ba827) failed
test_architecture_skills_root_guard with "cannot inventory repository:
[WinError 3] ... .hypothesis\tmp": Hypothesis removed its temp dir while
the architecture inventory walked the checkout.

.hypothesis is a generated test-tool cache like .pytest_cache, so it joins
the anywhere-excluded names and is never descended into. Walk errors on
source directories stay fail-closed (accb621): a new test pins that a
WinError 3 on src/ still aborts the inventory, and another proves a
vanishing .hypothesis cache no longer can.

Co-authored-by: Copilot App <[email protected]>

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🟡 Changes recommended

Both new Windows regression tests lack pytest.mark.windows_compat, so the PR-time Windows Compatibility Gate skips their cache-exclusion and source-error checks.

1 open issue
What changed in this PR

This PR fixes a Windows race in the architecture linter's repository inventory by preventing traversal of Hypothesis caches, while preserving failures for missing source directories.

Changes:

  • Exclude .hypothesis directories at any depth.
  • Add regression tests for cache traversal and source-directory errors.
  • Update the frozen exclusion-list assertion.
File Description
tests/​unit/​scripts/​test_architecture_inventory.py Adds regression coverage and updates the expected exclusions.
scripts/​architecture_linter/​inventory.py Excludes Hypothesis caches from repository traversal.

Review effort: Balanced

return error


def test_tool_cache_vanishing_mid_walk_is_never_walked(tmp_path, monkeypatch) -> None:
@danielmeppiel
Daniel Meppiel (danielmeppiel) merged commit fe7617f into main Nov 20, 2026
30 checks passed
@danielmeppiel
Daniel Meppiel (danielmeppiel) deleted the danielmeppiel-inventory-vanish-winerror branch November 20, 2026 16:10
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.

2 participants