Skip to content

Test suite is not hermetic: config, cache and home dirs leak into tests #1103

Description

@PierrunoYT

Found in the 2026-09-28 code audit (finding N-8).

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.

Activity

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

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions