Repository navigation
fix(codex): preserve runtime config when system source is missing - #9127
Conversation
|
No actionable comments were generated in the recent review. 🎉 ℹ️ Recent review info⚙️ Run configurationConfiguration used: Repository UI Review profile: CHILL Plan: Pro Plus Run ID: 📥 CommitsReviewing files that changed from the base of the PR and between 90133526fcd4246fe9029eb2b44905b157555fbb and 0fb5ba1. 📒 Files selected for processing (1)
📝 WalkthroughWalkthroughUpdated Codex configuration mirroring to return early when the system 🚥 Pre-merge checks | ✅ 4 | ❌ 1❌ Failed checks (1 warning)
✅ Passed checks (4 passed)
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
There was a problem hiding this comment.
Actionable comments posted: 1
ℹ️ Review info
⚙️ Run configuration
Configuration used: Repository UI
Review profile: CHILL
Plan: Pro
Run ID: c7aef3ca-a113-4426-99cb-e941840a5639
📥 Commits
Reviewing files that changed from the base of the PR and between cc1ad06 and 2c18dcdd7f31440e38bd7acfc8ae33bedd3e820a.
📒 Files selected for processing (2)
src/main/codex/codex-config-mirror.test.tssrc/main/codex/codex-config-mirror.ts
|
Taking a look! |
9013352 to
a7f4caf
Compare
|
@brennanb2025 please own |
Why: codex-config-mirror.ts sat at the 300-line cap, so the missing-source guard could not land without a max-lines disable.
Why: a runtime home seeded outside the mirror (WSL, per-account) never got a baseline while the source was missing, so promotion stayed inert and silently reverted the in-Codex change once the source returned.
…ings Two routes still reached the stablyai#9073 data loss after the missing-source guard: - Promotion runs before the guard and, with no ~/.codex/config.toml, created one holding only the promoted keys. The next mirror treated that skeleton as authoritative and deleted every other runtime setting. It needs no missing file: `codex mcp add` inside an Orca-launched Codex plus /model was enough to drop the MCP server for good. Promotion now seeds a brand-new system config from the runtime's ordinary settings, so the mirror round-trips them. - A 0-byte source (half-written, or an unhydrated cloud-synced home) still read as an authoritative empty config and advanced the baseline, making the loss unrecoverable. A blank source is now treated like a missing one. Moves the TOML section model out of codex-config-mirror.ts so promotion can share it without a cycle.
a7f4caf to
0fb5ba1
Compare
|
Thanks for this — the root cause is right and the guard is the correct shape. I rebased onto latest main (the branch was well behind and conflicting) and adapted the fix to the promotion-plan signature the mirror uses now. While validating I found the guard alone doesn't fully close #9073, so I extended it in three places:
Each fix has a regression test that fails when that fix alone is reverted. Two small structural changes were needed: Two follow-ups I deliberately left out of scope: the skip is silent (worth transition-gated logging so a downed WSL distro is diagnosable), and it also pauses the runtime config's duplicate- |
brennanb2025
left a comment
There was a problem hiding this comment.
Approving. Root cause is correct; extended to cover the remaining routes to the same data loss, each with a regression test. Validated on latest main.
…ablyai#9127) * fix(codex): preserve runtime config without system source * fix(codex): retain baseline when mirror is skipped * refactor(codex): extract deprecated hook-flag normalization Why: codex-config-mirror.ts sat at the 300-line cap, so the missing-source guard could not land without a max-lines disable. * fix(codex): bootstrap a baseline when the mirror is skipped Why: a runtime home seeded outside the mirror (WSL, per-account) never got a baseline while the source was missing, so promotion stayed inert and silently reverted the in-Codex change once the source returned. * fix(codex): stop a synthesized source config from wiping runtime settings Two routes still reached the stablyai#9073 data loss after the missing-source guard: - Promotion runs before the guard and, with no ~/.codex/config.toml, created one holding only the promoted keys. The next mirror treated that skeleton as authoritative and deleted every other runtime setting. It needs no missing file: `codex mcp add` inside an Orca-launched Codex plus /model was enough to drop the MCP server for good. Promotion now seeds a brand-new system config from the runtime's ordinary settings, so the mirror round-trips them. - A 0-byte source (half-written, or an unhydrated cloud-synced home) still read as an authoritative empty config and advanced the baseline, making the loss unrecoverable. A blank source is now treated like a missing one. Moves the TOML section model out of codex-config-mirror.ts so promotion can share it without a cycle. --------- Co-authored-by: Brennan Benson <[email protected]>
Summary
Stops a temporarily missing system Codex config from wiping an existing managed runtime config and stranding unpromoted changes.
ELI5
If Codex's settings file briefly disappeared, the app used to think you had no settings and erased the ones it was managing. Now it just waits for the file to come back and keeps your settings intact.
Root cause & fix
When
~/.codex/config.tomlwas temporarily absent, the mirror treated it as an authoritative empty config: it merged that emptiness into the existing managed runtime (erasing ordinary settings like model and hooks) and still advanced the baseline snapshot, so the lost runtime changes could never retry once the source returned. The fix makessyncSystemConfigIntoManagedCodexHomeUnsafereturn aCodexConfigMirrorResult; a missing source with an existing runtime yields'skipped-missing-source', and the caller returns early without advancing the baseline. This preserves the runtime config and allows a later retry once the source reappears.Evidence
Validated & rebased onto latest main during a bug-bash triage on 2026-07-23. Rebase was clean onto
origin/main.codex-config-mirror.test.tsandconfig-settings-promotion.test.ts.git checkout origin/main -- codex-config-mirror.ts) fails exactly the two guard tests, proving they exercise the fix:oxlint src/main/codex/codex-config-mirror.ts-> 0 warnings, 0 errors. Typecheck passes.Trade-offs
None — pure fix.
Regression risk
Zero-regression by construction: the new early-return path triggers only when the system config is absent and a runtime config already exists — the exact case that previously destroyed data. Fresh-mirror seeding, empty-baseline init, and normal merge paths are unchanged and remain covered by the other 56 passing tests.
Original fix by @kin001 (fixes #9073). Validated, rebased, and (where applicable) hardened via automated bug-bash review; original fix design preserved.