fix: honor stat-aware cache lookup contract#1720
Open
fallintoplace wants to merge 2 commits into
Open
Conversation
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.
Summary
Root cause
The identity-hardening cache refactor moved both
get_cached_result_with_stat()helpers onto the identity-bound lookup path, but stopped forwarding the caller-providedstat_result. The API still advertised stat reuse even though the argument was ignored.Impact
Callers that already computed
os.stat_resultcan use the stat-aware lookup helpers without paying for a dead parameter, and the lookup still goes through the hardened identity validation flow.Validation
uv run ruff format modelaudit/cache/cache_manager.py modelaudit/cache/scan_results_cache.py tests/cache/test_cache_correctness.pyuv run ruff check --fix modelaudit/cache/cache_manager.py modelaudit/cache/scan_results_cache.py tests/cache/test_cache_correctness.pyuv run mypy modelaudit/cache/cache_manager.py modelaudit/cache/scan_results_cache.py tests/cache/test_cache_correctness.pyPROMPTFOO_DISABLE_TELEMETRY=1 uv run pytest tests/cache/test_cache_correctness.pyPROMPTFOO_DISABLE_TELEMETRY=1 uv run pytest tests/cache/test_cache_correctness.py -k 'cache_manager_reuses_lookup_identity_for_miss or scan_results_cache_get_cached_result_with_stat_reuses_provided_stat or cache_manager_get_cached_result_with_stat_reuses_provided_stat'Notes
uv run mypy modelaudit/ packages/modelaudit-picklescan/src packages/modelaudit-picklescan/tests tests/still reports existingos.listxattr/os.setxattr/os.getxattrtyping errors inmodelaudit/cli.pyandtests/test_cli.py.PROMPTFOO_DISABLE_TELEMETRY=1 uv run pytest -m 'not slow and not integration' --maxfail=1 -xlane also fails onupstream/mainintests/cache/test_cache_correctness.py::test_scan_cache_revalidates_sources_after_nested_importer_cache_population[changed-namespace].