You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
Test suite is not hermetic: config, cache and home dirs leak into tests #1103
Where:internal/config/paths.go:49-62 (UserConfigDir has no override seam); internal/tui/model.go:891-892 (newModel reads the real config.UserConfigDir()/zero/commands/*.md); internal/cli/app.go:754, internal/cli/observability.go:43 (call config.DefaultResolveOptions directly, bypassing the deps.userConfigPath seam at app.go:141).
Problem: 551 newModel( calls in TUI tests, only one TUI test file sets APPDATA/XDG_CONFIG_HOME/HOME. Repo-wide only 5 test files set APPDATA/LOCALAPPDATA, while 22 non-test files call os.User{Config,Home,Cache}Dir directly (e.g. skills/skills.go x3, sandbox/profile.go x3, sessions/store.go, cron/store.go, hooks/hooks.go). This violates the "Hermetic tests" rule in AGENTS.md: developer config leaks into tests and tests can write to real state directories.
Suggested fix: add a ZERO_CONFIG_DIR (or package-level) override in config, route the 22 callers through it, and add a per-package TestMain pointing HOME, USERPROFILE, APPDATA, LOCALAPPDATA, XDG_CONFIG_HOME, XDG_CACHE_HOME at a temp dir.
Confirmed, and it's worse than reading: on main, go test ./internal/tui/ writes into the user's real directories. With HOME, USERPROFILE, APPDATA, LOCALAPPDATA, XDG_CONFIG_HOME and XDG_CACHE_HOME pointed at an empty temp dir, one run left two sessions under .local/share/zero/sessions/ and a windows-cap-sids.json under .config/zero/ there. On a developer's machine those land in the real session list.
Approving, but in slices rather than one change across 22 callers. First slice: a TestMain in internal/tui that points every root the package resolves (HOME, USERPROFILE, APPDATA, LOCALAPPDATA, XDG_CONFIG_HOME, XDG_DATA_HOME, XDG_CACHE_HOME) at a temp dir, the way isolateCLIUserState does for internal/cli, plus a test that a model built with default options keeps its session store inside that dir. The config override seam and the other packages can follow as their own PRs, each with the same before-and-after check.
Activity
Vasanthdev2004 commentedon Oct 12, 2026
Confirmed, and it's worse than reading: on main,
go test ./internal/tui/writes into the user's real directories. WithHOME,USERPROFILE,APPDATA,LOCALAPPDATA,XDG_CONFIG_HOMEandXDG_CACHE_HOMEpointed at an empty temp dir, one run left two sessions under.local/share/zero/sessions/and awindows-cap-sids.jsonunder.config/zero/there. On a developer's machine those land in the real session list.Approving, but in slices rather than one change across 22 callers. First slice: a
TestMainininternal/tuithat points every root the package resolves (HOME,USERPROFILE,APPDATA,LOCALAPPDATA,XDG_CONFIG_HOME,XDG_DATA_HOME,XDG_CACHE_HOME) at a temp dir, the wayisolateCLIUserStatedoes forinternal/cli, plus a test that a model built with default options keeps its session store inside that dir. Theconfigoverride seam and the other packages can follow as their own PRs, each with the same before-and-after check.test(tui): isolate user home, config and cache dirs for the TUI tests
test(tui): isolate user home, config and cache dirs for the TUI tests (…
test(agent): isolate user home, config and cache dirs for the agent t…