Skip to content

fix(tests): isolate Codex home from user state#1150

Open
aaiyer wants to merge 1 commit into
DeusData:mainfrom
aaiyer:fix/cli-test-codex-home-isolation
Open

fix(tests): isolate Codex home from user state#1150
aaiyer wants to merge 1 commit into
DeusData:mainfrom
aaiyer:fix/cli-test-codex-home-isolation

Conversation

@aaiyer

@aaiyer aaiyer commented Jul 17, 2026

Copy link
Copy Markdown
Contributor

What does this PR do?

Completes the test-state isolation added in #1067. The runner replaced HOME and cleared CBM_CACHE_DIR, but it still inherited the invoking process's CODEX_HOME. When that directory existed, CLI fixtures detected the developer's real Codex installation and repeatedly installed and uninstalled MCP config, AGENTS.md content, skills, and Scout/Verify/Auditor profiles there.

A sentinel run on exact upstream/main e678b2b reproduced thousands of accesses and explicit write syscalls under the inherited CODEX_HOME, left an extra skills directory, and failed the install-plan no-mutation fixture because the inherited override shadowed its temporary .codex directory.

Fix

  • set CODEX_HOME to the private test HOME's .codex path before normal suites run;
  • fail test-home setup instead of continuing if the environment isolation cannot be established;
  • add a regression that binds CODEX_HOME to the private test HOME;
  • explicitly unset and restore CODEX_HOME in the two tests that intentionally exercise the home-directory fallback.

Worker and socket-probe modes still exit before normal suite setup, as before.

Validation

  • ASan + UBSan test runner build with warnings as errors: passed;
  • make -f Makefile.cbm test-focused TEST_SUITES=cli: 223 passed;
  • inherited fresh CODEX_HOME sentinel under strace: 0 sentinel-path syscalls after the fix, identical file hashes and directory inventory;
  • bash scripts/check-no-test-skips.sh: passed;
  • bash scripts/security-audit.sh: passed with existing review notices only;
  • bash scripts/security-vendored.sh: passed (75 files);
  • git diff --check: passed;
  • DCO check: passed.

Local CI lint was attempted but cppcheck was unavailable; clang-format and clang-tidy are also not installed in this environment. GitHub CI remains the lint authority.

Coordination

#1149 overlaps the same install-plan fallback test for a separate fixture-lifetime issue. Whichever PR lands second will need to rebase and preserve both intents: free the receipt JSON on every validation-failure path, and explicitly isolate CODEX_HOME while exercising the fallback path.

Scope

Only tests/test_main.c and tests/test_cli.c change. There is no production behavior or dependency change.

Signed-off-by: Anand Aiyer <anand@aiyer.com>
@aaiyer
aaiyer requested a review from DeusData as a code owner July 17, 2026 15:15
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.

1 participant