Skip to content

fix(tests): isolate integration caches from user state#1067

Open
tmonestudio wants to merge 1 commit into
DeusData:mainfrom
tmonestudio:codex/test-isolate-cache
Open

fix(tests): isolate integration caches from user state#1067
tmonestudio wants to merge 1 commit into
DeusData:mainfrom
tmonestudio:codex/test-isolate-cache

Conversation

@tmonestudio

Copy link
Copy Markdown

What does this PR do?

Prevents the C test runner from reading or writing a user's real codebase-memory cache.

Several integration fixtures exercise the production index_repository flow. The production cache resolver prefers CBM_CACHE_DIR, while older fixtures derive the expected database path from HOME/.cache/codebase-memory-mcp. When the runner inherited a real cache, early assertion returns could leave fixture databases behind. Setting only CBM_CACHE_DIR was also insufficient because those legacy paths diverged.

Fix

  • create a private temporary HOME for every normal test-runner process;
  • clear inherited CBM_CACHE_DIR, so production code and legacy fixtures converge on the private HOME cache;
  • delete the sentinel tree with atexit, including after early test returns;
  • make the lang-contract helper honor an explicit CBM_CACHE_DIR when a test intentionally sets one.

Worker/probe subprocess modes still exit before the sentinel setup.

Validation

Windows GCC build after rebasing onto current main:

  • full C runner: 5831 passed, 22 skipped;
  • production-cache sentinel: 501 DB files before, 501 after;
  • added files: 0;
  • removed files: 0.

The same run previously left cbm_seq898_*, cbm_lc_*, and cbm_fcw_* fixture databases in the inherited cache.

Checklist

  • Every commit is signed off (git commit -s)
  • Full C test runner passes locally
  • Full lint (left to CI)
  • Behavior validated with a before/after cache sentinel

Run the test process under a private temporary HOME and clear inherited CBM_CACHE_DIR so production index paths and legacy fixtures resolve to the same isolated cache.

Make lang-contract fixtures honor an explicit cache override and remove the sentinel tree at process exit, including after early assertion returns.

Validated on Windows with the full runner: 5828 passed, 22 skipped; a 500-project user cache had zero files added or removed.

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
Signed-off-by: tmonestudio <tmonestudio@users.noreply.github.com>
@tmonestudio tmonestudio requested a review from DeusData as a code owner July 12, 2026 23:34
@DeusData DeusData added bug Something isn't working security Security vulnerabilities, hardening priority/high Needs near-term maintainer attention; high-impact bug, regression, safety issue, or release blocker. labels Jul 14, 2026
@DeusData DeusData added this to the 0.9.1-rc milestone Jul 14, 2026
@DeusData

Copy link
Copy Markdown
Owner

Thanks for isolating integration-test caches from real user state. This is a high-priority 0.9.1-rc safety fix. Review will verify that every relevant test redirects both cache and configuration roots, restores environment state on all exits, and cannot read or mutate a developer installation.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

bug Something isn't working priority/high Needs near-term maintainer attention; high-impact bug, regression, safety issue, or release blocker. security Security vulnerabilities, hardening

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants