[bug] Windows: hermetic test fixture is a no-op — the suite rewrites the operator's real crypto key and makes existing records undecryptable
Summary
tests/conftest.py's _hermetic_default_paths fixture patches only HOME. On Windows that does not redirect Path.home(), so the fixture is a no-op there and the test suite reads and writes the operator's real store.
On my machine, running pytest rewrote ~/.iai-mcp/.crypto.key. The 297 existing records had been encrypted with the previous key, no .pre-rotate copy is retained, and .crypto-key-watcher.json stores only mtime+size — so those records became permanently undecryptable. memory_recall now returns InvalidTag for all of them.
Why
os.path.expanduser on Windows resolves USERPROFILE first, then HOMEDRIVE+HOMEPATH, and falls back to HOME only when none of them is set:
HOME = C:\...\Temp\fake-home
USERPROFILE = C:\Users\cmartin
Path.home() = C:\Users\cmartin <-- HOME ignored
Every test resolving Path.home() / ".iai-mcp" therefore reached the live store.
Reproduce
On Windows, with an existing store that holds records:
pytest -q tests/test_cli_crypto.py tests/test_crypto.py tests/test_hippo_crypto.py
The mtime of ~/.iai-mcp/.crypto.key advances. Recall then fails with InvalidTag.
Suggested fix
Patch the Windows variables alongside HOME:
monkeypatch.setenv("HOME", str(base))
monkeypatch.setenv("USERPROFILE", str(base))
drive, tail = os.path.splitdrive(str(base))
monkeypatch.setenv("HOMEDRIVE", drive)
monkeypatch.setenv("HOMEPATH", tail or "\\")
Because the failure mode is silent, a regression guard seems worthwhile too — a test asserting the hermetic marker appears in str(Path.home()) fails loudly if isolation ever breaks again, on any platform.
Environment
Windows 11, Python 3.11.15, iai-pme 3.0.2 (cp311 win_amd64 wheel from PyPI).
Verified fixed on my side. Happy to open a PR with the fixture change plus the guard.
Distinct from #109 and #113: those cover POSIX-only APIs outside their platform guards at daemon boot. This one is the test fixture, and its consequence is destroyed user data rather than a failed start.
Fixed in v3.0.3 — the hermetic fixture now redirects USERPROFILE/HOMEDRIVE/HOMEPATH as well as HOME, so the suite can't touch a real store on Windows. Thanks for the precise diagnosis.