fix(codex): honor CODEX_HOME during migration - #65261
Conversation
|
Thanks for the focused regression fix. Current The proposed precedence aligns migration, plugin discovery, and the app-server's active Codex home. The added cases in Automated hermes-sweeper review. |
SummaryFour PRs are associated with this issue complex: #27764 addresses the permission downgrade during re-migration, #25857 fixes the earlier top-level TOML placement bug, #65261 selects the correct migration target via CODEX_HOME, and #66170 forwards dynamic Hermes MCP context. Only #27764 changes permission preservation; the other three address distinct migration defects. Related pull requests
Suggested consolidationKeep #27764 open with the concrete salvage path from its contributor review because it is the recorded best fix for #27616 but its current diff can duplicate a user-owned root key and does not fully preserve the three reported permission keys. Keep #65261 separate and open for its CODEX_HOME fix; #25857 should remain closed because its implementation landed through #26260, and #66170 should remain closed rather than being reopened through this unrelated permission issue. No listed PRs are duplicates. Cross-PR triage: Reviewed 4 pull requests and 1 issue in this complex. Each diff was read against this issue; Assessment working set: 25 kB of PR diffs, 12 kB of issue/PR text, 4 kB of discussion (5 comments), 2 verify verdicts. verdicts reflect diff content, not PR titles. Part of an automated triage batch. |
|
I refreshed this fix against current The current-main refresh keeps this PR's owner-compatible precedence:
I also added two focused regressions that cover adjacent paths not currently exercised here or in #71452:
Current-main verification: The implementation is still only three files: the migration helper plus its unit tests and the runtime-switch integration test. I am not opening a successor because #65261 is already the canonical high-salvageability owner surface. @ericfadden, I have the current-main test refresh ready if you want it folded into this branch. |
What does this PR do?
Honor
CODEX_HOMEwhen the Codex runtime migration is called without an explicitcodex_homeargument.The migration helper previously fell straight back to
~/.codex, while the slash-command path callsmigrate(config)without passing a home. That could write the managed configuration block to the wrongconfig.tomleven though the spawned Codex runtime usedCODEX_HOME.The resolution order is now:
codex_homeargumentCODEX_HOMEenvironment variable~/.codexThis is separate from #57792, which changes profile-specific app-server worker routing rather than migration target selection.
Related Issue
N/A — this is a narrow migration bug with a direct regression test.
Type of Change
Changes Made
hermes_cli/codex_runtime_plugin_migration.pyto resolve the migration target from the explicit argument, thenCODEX_HOME, then the existing home-directory fallback.tests/hermes_cli/test_codex_runtime_plugin_migration.pyfor environment selection, explicit-argument precedence, and blank-environment fallback.How to Test
main, setCODEX_HOMEto an isolated directory and callmigrate(config)withoutcodex_home; the migration uses the fallback home instead of the environment-selected home.CODEX_HOME. An explicit argument still wins, and a blank environment value still falls back to~/.codex.scripts/run_tests.sh tests/hermes_cli/test_codex_runtime_plugin_migration.py tests/hermes_cli/test_codex_runtime_switch.py -q— 101 passed.ruff check hermes_cli/codex_runtime_plugin_migration.py tests/hermes_cli/test_codex_runtime_plugin_migration.py— passed.origin/main— 0 findings. Redacted Gitleaks scan oforigin/main..HEAD— no leaks.The full repository runner was also executed: 41,911 tests passed and 36 failed in 15 unrelated files. The failures were outside this PR's files and involved macOS/Linux platform assumptions, live local provider/catalog state, active approval-mode state, and one timing threshold.
Checklist
Code
fix(scope):,feat(scope):, etc.)pytest tests/ -qand all tests passDocumentation & Housekeeping
docs/, docstrings) — N/A; the change aligns behavior with the existingCODEX_HOMEdocumentationcli-config.yaml.exampleif I added/changed config keys — N/ACONTRIBUTING.mdorAGENTS.mdif I changed architecture or workflows — N/AScreenshots / Logs
N/A — automated regression coverage exercises the path-selection behavior.