Keep the classifier cache in the test tmpdir so the suite is hermetic#37
Merged
Conversation
Summary Scrub and re-point `XDG_CACHE_HOME` in the hook test harness so the protected-bare classifier cache no longer writes into the developer's real `~/.cache` during a test run. The harness already redirects hook state (`XDG_RUNTIME_DIR`/ `XDG_STATE_HOME`) at the test tmpdir, but `_protected_bare_nested_cache_file` resolves its cache from `XDG_CACHE_HOME` (falling back to `~/.cache`), which the harness left untouched. So running the suite rewrote a real `~/.cache/agentguard/protected-bare-nested-roots-*` file — a pre-existing hermeticity leak surfaced during review of the hook-state change. - add `XDG_CACHE_HOME` to the ambient XDG scrub and export it at `$TEST_TMPDIR` alongside `XDG_RUNTIME_DIR`, matching the same pattern and rationale Testing - before/after check: the real `~/.cache/agentguard` mtime is unchanged across a full suite run (was rewritten at test time before this change) - full suite green (`./test/agentguard-test`: ok, all suites 0 failed); `checkrun lint` and `shellcheck -x` clean - no test asserts the classifier cache path, so redirecting it is safe
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
Scrub and re-point
XDG_CACHE_HOMEin the hook test harness so theprotected-bare classifier cache no longer writes into the developer's
real
~/.cacheduring a test run.The harness already redirects hook state (
XDG_RUNTIME_DIR/XDG_STATE_HOME) at the test tmpdir, but_protected_bare_nested_cache_fileresolves its cache from
XDG_CACHE_HOME(falling back to~/.cache),which the harness left untouched. So running the suite rewrote a real
~/.cache/agentguard/protected-bare-nested-roots-*file — a pre-existinghermeticity leak surfaced during review of the hook-state change.
XDG_CACHE_HOMEto the ambient XDG scrub and export it at$TEST_TMPDIRalongsideXDG_RUNTIME_DIR, matching the same patternand rationale
Testing
~/.cache/agentguardmtime is unchangedacross a full suite run (was rewritten at test time before this change)
./test/agentguard-test: ok, all suites 0 failed);checkrun lintandshellcheck -xclean