Skip to content

fix(codex): keep Orca-only MCP servers when refreshing the retained shared home - #24983

Merged
OrcaWin merged 2 commits into
mainfrom
sta-9109-keep-orca-only-mcp-on-retained-refresh
Oct 4, 2026
Merged

OrcaWin merged 2 commits into
mainfrom
sta-9109-keep-orca-only-mcp-on-retained-refresh

Conversation

@OrcaWin

@OrcaWin OrcaWin commented Oct 3, 2026 •

Copy link
Copy Markdown
Collaborator
Files Added Deleted Net
Test 2 $\color{#1a7f37}{\Huge{\mathbf{+}}}$​111 0 $\color{#1a7f37}{\Huge{\mathbf{+}}}$​111
Prod 1 $\color{#1a7f37}{\Huge{\mathbf{+}}}$​20 $\color{#cf222e}{\Huge{\mathbf{−}}}$​4 $\color{#1a7f37}{\Huge{\mathbf{+}}}$​16

ELI5

Before Orca started running Codex directly on your own ~/.codex folder, it ran Codex on a private copy of that folder. Codex terminals that were already open before an update keep using that old copy, so Orca keeps refreshing it with your latest ~/.codex settings. That refresh was deleting MCP servers you had added from inside an Orca terminal, and the old copy was the only place those existed. Now the refresh keeps them.

What Changed

Before: updating Orca on Windows while Codex terminals were open deleted MCP servers you'd added from an Orca terminal from Orca's old Codex folder (%APPDATA%\orca\codex-runtime-home\home), the only place they existed.
After: they're kept. Servers that came from ~/.codex and that you've since removed there are still removed from the old copy, and ordinary settings and project/hook trust refresh exactly as before.

Mechanism: the refresh for those surviving terminals (syncSystemConfigIntoLegacySharedCodexHome) merged with "every [mcp_servers.*] table belongs to ~/.codex", so any table not in ~/.codex was dropped. The old copy already holds the record the normal mirror keeps of which MCP servers it copied from ~/.codex (.orca-config-settings-baseline.json). The refresh now reads that record and passes it to the same merge the normal mirror uses, so only servers that came from ~/.codex can be removed:

  • Record present: uses its server list. An Orca-only server is kept; a server copied from ~/.codex and later removed there is dropped.
  • Older record without the MCP list: already reads as "the whole MCP section belongs to ~/.codex", so behaviour is unchanged.
  • No record: unchanged (the whole MCP section belongs to ~/.codex).
  • Record exists but can't be read: the refresh is skipped for that pass instead of guessing. This matches how the function already treats a config file it can't read, and the caller logs and carries on.

The refresh stays one-way: it reads the record but never updates it.

Why

Found by an end-to-end run of #24356: start with a build from before #24356 that has a [mcp_servers.demo-mcp] table only in Orca's copy and a live terminal daemon, then upgrade. demo-mcp was gone from the old copy's config.toml.

The refresh function predates #24356, and macOS/Linux terminals that survived the switch to the real ~/.codex had the same behaviour. #24356 is what made it run on Windows, where the terminal daemon is built to outlive auto-updates. The fix applies to every platform; the record has the same meaning everywhere.

Reusing the normal mirror's ownership record was the smallest correct option. Keeping every MCP table would bring back servers you deleted from ~/.codex. Recording ownership separately for the old copy would mean a second source of truth. The cost of not updating the record: a server added to ~/.codex after the last full mirror and then removed from ~/.codex stays in the old copy. That leaves an extra entry; nothing is lost.

Linked Issue

Linear: STA-9109

Visual Proof

N/A. This only changes what is written to a config file; there's nothing new on screen.

Testing

  • New tests in src/main/codex/codex-config-mirror-mcp-ownership.test.ts and src/main/codex-accounts/legacy-shared-config-compatibility.test.ts: an Orca-only server is kept, a server removed from ~/.codex is dropped, an older record without the MCP list and a missing record behave as before, an unreadable record leaves the config untouched, and settings and project/hook trust still refresh while the record stays unchanged. The three tests for the new behaviour fail on main.

  • pnpm tc:node, oxlint, oxfmt --check, pnpm run check:code-quality:changed: pass.

  • src/main/codex + src/main/codex-accounts on Windows: the same tests fail with and without this change (WSL, session-resume, structured-session, and app-server suites that already fail on this machine). This change adds no new failures.

  • I manually tested these changes locally

  • Automated tests added/updated, or explained why not below

Review

Agent skill upstream boundary

  • Not applicable, or this change follows docs/reference/agent-skill-sharing-upstream-boundary.md and copies or mechanically translates no upstream skill-installer source, tests, fixtures, registry entries, path tables, comments, or documentation.

Notes

Cross-platform: same behaviour on macOS, Linux, and Windows. SSH/WSL: not affected; this only touches the local host's old Orca copy. Backwards compatibility: older records keep their existing meaning.

Checklist

  • This PR is small and focused
  • I explained what changed and why (ELI5, the user-facing before/after, the mechanism, and why over the alternatives)
  • Before/after screenshots or videos attached for UI changes, or N/A with reason
  • Self-reviewed for correctness, security, and performance
  • Cross-platform, SSH/remote, and path/shortcut impact considered (or N/A)
  • pnpm lint, pnpm typecheck, pnpm test, and pnpm build pass (or CI will cover; local preferred)

…hared home

The refresh for panes that outlive an update treated the old shared
home's whole MCP root as owned by ~/.codex, so it deleted servers the
user had added from an Orca terminal, which existed only there. Read the
home's settings baseline instead, as the normal mirror does: drop only
servers the last mirror copied from ~/.codex. No baseline keeps the old
behaviour; an unreadable one skips the refresh. The baseline is not
advanced, keeping the refresh one-way.

STA-9109

@pullfrog pullfrog Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

✅ No new issues found.

Reviewed changes

  • Legacy refresh reads MCP ownership from the retained baseline — syncSystemConfigIntoLegacySharedCodexHome now passes the retained home's own .orca-config-settings-baseline.json mcpServers/mcpServerRoot into mergeSystemCodexConfigIntoRuntime instead of always forcing new Set(), true. Orca-only servers (absent from the baseline and from ~/.codex) survive, while servers the baseline recorded from ~/.codex and since removed there are still dropped.
  • No-record and pre-ownership baselines keep prior behavior — absent or v1/v2 baselines map to [∅, true]; an indeterminate baseline read now throws so the caller skips that pass rather than guessing. The refresh stays one-way (never advances the baseline).
  • Tests — new cases in codex-config-mirror-mcp-ownership.test.ts and legacy-shared-config-compatibility.test.ts pin each branch: keep Orca-only / drop ~/.codex-removed, pre-ownership guard, unreadable baseline leaves the config untouched, and settings + project/hook trust still refresh with the baseline unchanged.

The new ownership arguments mirror exactly what the managed mirror already feeds the merge (promotionPlan.mirroredMcpServers / mirroredMcpServerRoot), so the two paths stay consistent; the merge still consults the current ~/.codex ownership for the inline-root and same-name cases. I ran the affected suites (82 tests, all pass), oxlint on the changed files, and pnpm tc:node — all clean.

Pullfrog  | View workflow run | Using deepseek-v4.1-flash (free via Pullfrog for OSS) | 𝕏

@coderabbitai

coderabbitai Bot commented Oct 3, 2026 •

Copy link
Copy Markdown
Contributor

Review in Change Stack →

Navigate logical layers of code changes, visualize relationships, and explore their blast radius.

🧰 Additional context used
📚 Code guidelines (1)
AGENTS.md — auto-discovered

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration
  • Configuration used: Repository UI
  • Review profile: CHILL
  • Plan: Advanced
  • Run ID: 65fde722-6f35-4fd1-833c-09b2b054da65
📥 Commits

Reviewing files that changed from the base of the PR and between d5e03aa and 7ee6877.

📒 Files selected for processing (1)
  • src/main/codex/codex-config-mirror-mcp-ownership.test.ts

Included review availability: This review used your included allowance. Your plan provides up to 10 included reviews per hour; 8 remain after this review.


📝 Walkthrough

Walkthrough

Legacy shared-home refresh uses MCP ownership recorded in the runtime settings baseline when merging system configuration. If no baseline exists, it keeps the previous whole-root ownership behavior. If the baseline cannot be read, the refresh throws. Tests cover MCP server retention and removal, unchanged baseline contents, unreadable baselines, and retained-pane settings.

Priority: ⬇️ Low

Merge Risk: ⚪ Minimal · up to 7ee68

Orca-only MCP servers are retained while mirrored servers continue to track system settings. If the ownership baseline cannot be read, that refresh is skipped and logged without blocking real-home startup or launch; no actionable merge risk remains.

Security Architecture Review

Security architecture risk: 🔵 Low · up to 7ee68

The refresh preserves terminal-only servers, but servers newly copied from the main configuration are not added to the ownership record. Removing one later may leave its command configuration behind in older terminals. The demonstrated scope is the user's retained configuration, not a new remote access path.

Retained concerns

  • Low · security · inferred: Ownership history does not advance when the legacy refresh copies a new MCP server. With a name-based baseline that omits server X, one refresh can copy X from the system configuration; a later refresh that removes X while retaining other system settings preserves X as runtime-only. Unlike the previous whole-root policy, removal can therefore leave executable server configuration in the retained home. Actual subsequent execution is not established.
Security review details

Security Blast Radius

  • inferred — The demonstrated exposure is the user's retained shared Codex home and panes consuming it. The inspected path reads local configuration and ownership files and writes retained configuration; downstream MCP privileges, credentials, and execution reach were not established.

Security Findings and Attack Paths

  • inferred — A server supplied through the system configuration can persist after later removal if legacy refreshes copied it without recording its ownership. This is a removal-propagation concern, not a verified unauthorized-execution finding. The strongest counterevidence is that servers already named in the baseline are correctly removed.

Trust Boundaries and Controls

  • observed — The refresh remains one-way into the retained home and does not promote its configuration into the live system home. Indeterminate ownership refuses the merge instead of guessing which server entries may be deleted.

Resilience and Maintainability Implications

  • observed — Compatibility refresh errors are logged and contained rather than propagated by the wrapper. Guarded-file recovery runs before baseline readability is checked, so refusal should not be interpreted as guaranteeing no recovery-related filesystem changes.

Hardening Proposals

  • proposed — Consider recording provenance for servers first copied by legacy refreshes, separately from the deliberately unchanged settings baseline, with publication tied to successful configuration replacement. This could preserve terminal-only servers while allowing later system removal to propagate.
🚥 Pre-merge checks | ✅ 4 | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 66.67% which is insufficient. The required threshold is 80.00%. Docstring coverage is scoped to functions touched by this diff. Analyzed 3 functions across 3 files. Write docstrings for the functions missing them to satisfy the coverage threshold.
✅ Passed checks (4 passed)
Check name Status Explanation
Title check ✅ Passed The title clearly identifies the main change: preserving Orca-only MCP servers during refresh of the retained shared Codex home.
Description check ✅ Passed The description covers the required ELI5, change, rationale, issue, visual proof, testing, review, boundary, notes, and checklist sections. It explains the behavior and testing in detail. The linked i…
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.
  • Fix all pre-merge checks with AI
✨ Finishing Touches 💡 1
📝 Generate docstrings 💡
  • Commit to this branch
  • Create a new PR
  • Autopilot · Keep fixing CodeRabbit findings and required CI, and resolving merge conflicts

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.

❤️ Share

Comment @coderabbitai help to get the list of available commands.

@OrcaWin
OrcaWin merged commit 0f9bc5a into main Oct 4, 2026
31 checks passed
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