Summary
The three CspMcpServer tests in crates/csp/src/bin/csp/mcp_server.rs (search_tool_call_returns_json_payload, find_related_tool_call_reports_missing_chunk, and search_tool_call_honors_per_call_content) build real indexes for a random tempfile directory through the production DiskLoadOrBuild seam. load_or_build_index runs with LoadOrBuildOptions { base_dir: None, .. }, so every run writes into the developer's real ~/.csp/index/.
The cache key is hashed from the random temp path, so the entries can never be reused and are never removed. Measured with an isolated HOME: one cargo test run leaves 5 orphan index directories (~100 KB) — 2 from the pre-existing tests, 3 more since #99 added the per-call content test (one per content variant). Repeated local or CI runs accumulate them indefinitely; csp clear index is currently the only remedy, and it wipes the whole cache.
The tests already apply the module's one existing isolation hook (server.stats_file = None keeps telemetry out of ~/.csp/savings.jsonl); there is no equivalent hook for the index cache because CspMcpServer.cache is the monomorphic IndexCache<DiskLoadOrBuild> and DiskLoadOrBuild exposes no base_dir.
Surfaced by the gpt review engine on #99; the validator classified it as pre-existing on main rather than introduced by that PR, so it was deferred here.
Proposed fix
Give DiskLoadOrBuild an optional cache home (e.g. a base_dir: Option<PathBuf> field threaded into LoadOrBuildOptions.base_dir and source_fingerprint), and expose a #[cfg(test)]-gated constructor or field on CspMcpServer so all three tests point the cache at a second tempdir() that is deleted with the fixture. This matches the crate's existing seams (IndexCache::with_seam(Stub) in the lib tests, run_clear_at(&CacheLocation, ..) in the CLI) rather than adding a public production constructor that exists only for tests.
Acceptance
Refs
Summary
The three
CspMcpServertests incrates/csp/src/bin/csp/mcp_server.rs(search_tool_call_returns_json_payload,find_related_tool_call_reports_missing_chunk, andsearch_tool_call_honors_per_call_content) build real indexes for a randomtempfiledirectory through the productionDiskLoadOrBuildseam.load_or_build_indexruns withLoadOrBuildOptions { base_dir: None, .. }, so every run writes into the developer's real~/.csp/index/.The cache key is hashed from the random temp path, so the entries can never be reused and are never removed. Measured with an isolated
HOME: onecargo testrun leaves 5 orphan index directories (~100 KB) — 2 from the pre-existing tests, 3 more since #99 added the per-callcontenttest (one per content variant). Repeated local or CI runs accumulate them indefinitely;csp clear indexis currently the only remedy, and it wipes the whole cache.The tests already apply the module's one existing isolation hook (
server.stats_file = Nonekeeps telemetry out of~/.csp/savings.jsonl); there is no equivalent hook for the index cache becauseCspMcpServer.cacheis the monomorphicIndexCache<DiskLoadOrBuild>andDiskLoadOrBuildexposes nobase_dir.Surfaced by the
gptreview engine on #99; the validator classified it as pre-existing onmainrather than introduced by that PR, so it was deferred here.Proposed fix
Give
DiskLoadOrBuildan optional cache home (e.g. abase_dir: Option<PathBuf>field threaded intoLoadOrBuildOptions.base_dirandsource_fingerprint), and expose a#[cfg(test)]-gated constructor or field onCspMcpServerso all three tests point the cache at a secondtempdir()that is deleted with the fixture. This matches the crate's existing seams (IndexCache::with_seam(Stub)in the lib tests,run_clear_at(&CacheLocation, ..)in the CLI) rather than adding a public production constructor that exists only for tests.Acceptance
CspMcpServertests run withHOME/~/.cspuntouched (verify by running the test binary with an isolatedHOMEand asserting~/.csp/index/stays absent).CspMcpServeroutside#[cfg(test)].cargo fmt --all && cargo clippy --all-targets --all-features -- -D warnings && cargo test --workspacepass.Refs
contentparameter to search/find_related (semble#247) #99 (review discussion), parity(#247): add per-callcontentparameter to MCP search/find_related and key the session cache on it #85crates/csp/src/mcp.rs::DiskLoadOrBuild,crates/csp/src/indexing/cache_orchestrator.rs(CacheLocationresolution)