Skip to content

test: keep tests and the guide tool out of the developer's real KMP home (#910) - #913

Draft
tgarciai wants to merge 2 commits into
integration/909-910-900-901from
fix/910-test-data-home
Draft

tgarciai wants to merge 2 commits into
integration/909-910-900-901from
fix/910-test-data-home

Conversation

@tgarciai

@tgarciai tgarciai commented Oct 4, 2026

Copy link
Copy Markdown
Member

Part of #910.

What leaked

Run on a developer machine, the kmp-mcp and kmp-release test suites wrote into the real home:

  • known-stores.jsonl: spawned kmp-mcp binaries remembered their temporary stores in the real $XDG_DATA_HOME/kmp/known-stores.jsonl. This is the case the issue describes.
  • Host configuration: spawned binaries also reached the real host files, creating ~/.claude.json, ~/.claude/backups and ~/.hermes/ in the home they inherited.
  • agent-users/: in-process gRPC servers kept each endpoint's agent directory and telemetry salt under $XDG_DATA_HOME/agent-users/. Every test uses a fresh random port, so every run added new <hash>.sqlite3 and .telemetry-salt files. On the maintainer's machine there were 162 of them, 44 from today alone.
  • kmp-release guide assets write: set KMP_MCP_DATA_DIR but not XDG_DATA_HOME.

Fix

  • Spawned binaries: a new helper, tests/support/isolated_home.rs, gives every spawned kmp-mcp a HOME, XDG_DATA_HOME and XDG_CONFIG_HOME private to the test process, under CARGO_TARGET_TMPDIR. About 80 spawn sites now use it. A test that sets these variables itself still wins, because its value is applied later.
  • In-process gRPC servers: the new KernelMcpServer::with_remote_state_home moves a remote store's agent directory and salt. The gRPC tests use it to point at the isolated home.
  • kmp-release: the guide engine now sets XDG_DATA_HOME beside KMP_MCP_DATA_DIR for scratch-store runs. A regression test with a fake engine checks this for both the CLI path and the MCP path.

Evidence

cargo test -p kmp-mcp, run with HOME and XDG_* pointing at a fake developer home:

tree left in the fake home
integration base (5da095e) kmp/known-stores.jsonl (temp store /tmp/.tmp…), agent-users/*.sqlite3 and salts, .claude.json, .claude/backups, .hermes/
this branch (kmp-mcp + kmp-release) nothing (no file)

cargo test -p kmp-mcp -p kmp-release also ran against the maintainer's real home: 108 suites ok, and the real known-stores.jsonl was byte-identical before and after. fmt, clippy -D warnings and the kmp-mcp architecture gate all pass.

CI is unaffected because its home is throwaway. The dev-loop now also covers kmp-release (499f82b on the integration branch).

codex added 2 commits October 4, 2026 22:43
Every kmp-mcp test that spawns the binary now goes through one helper,
tests/support/isolated_home.rs, which points HOME, XDG_DATA_HOME and
XDG_CONFIG_HOME at a home private to the test process under
CARGO_TARGET_TMPDIR. A test that needs its own layout still sets the
variables afterwards and wins.

kmp-release's guide engine now sets XDG_DATA_HOME beside KMP_MCP_DATA_DIR
for scratch-store runs, so `kmp-release guide assets write` no longer
remembers its temp store in the real known-stores index.
…910)

In-process gRPC servers kept each endpoint's agent directory and telemetry
salt in the user data home, and every test endpoint is a fresh random port:
each run left new agent-users/<hash>.sqlite3 and salt files beside the
developer's real ones. KernelMcpServer::with_remote_state_home relocates
both, and the gRPC tests use the isolated test home.

This branch has not been deployed

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

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants