Repository navigation
feat(codex): give each managed account a self-contained CODEX_HOME; retire shared mirror (PR-E) - #9179
Closed
brennanb2025 wants to merge 2 commits into
Conversation
…etire shared mirror (PR-E) With the real-home flag ON, a host managed account now launches directly against its own codex-accounts/<id>/home instead of the shared runtime mirror + auth.json hot-swap: - codex-home-paths: syncSystemCodexResourcesIntoManagedHome links system resources into any managed home (ownership-marker discipline; never symlinks into / mutates ~/.codex). - runtime-home-service: prepareForCodexLaunch / prepareForRateLimitFetch / syncForCurrentSelection route the per-account home directly and skip the shared-home hot-swap + token read-back; each home keeps its own auth in place (fixes GAP-5 concurrent auth race). Session discovery scans every per-account home. - hook-service / hook-trust-promotion: install/getStatus/refresh accept a runtimeHomePath so hooks + RPC-granted trust land in the per-account home. - service: config mirror into a self-contained home uses the trust- preserving merge so granted hook/project trust survives account switches. - codex-session-root-dedup: rank codex-accounts/<id>/home as canonical managed alongside the shared runtime home. Flag-OFF and the system-default real-home (null) lane are unchanged; the nested-Orca CODEX_HOME===ORCA_CODEX_HOME daemon strip (#5370) is preserved. Sandboxed tests only; ~/.codex is never mutated.
brennanb2025
force-pushed
the
brennanb2025/codex-ma-e-per-account-home
branch
from
July 17, 2026 10:19
189fd46 to
433356a
Compare
8 of 10 tasks
This was referenced Jul 19, 2026
Contributor
Author
|
Closing as superseded: #9501 (real-home routing + self-contained multi-account homes) explicitly lists this draft as superseded in its description, and that consolidation merged and shipped in v1.4.149 stable. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
What & why
Today real-home routing fires only for the system-default (
host === null) account. Every managed account still injects the single shared runtime home (codex-runtime-home/home) asCODEX_HOMEand hot-swapsauth.jsoninto it on select. Two consequences:auth.json, so concurrent panes for different managed accounts race that file (token refresh from one clobbers the other).This PR makes each
codex-accounts/<id>/homea complete, directly-injectedCODEX_HOMEwhen the real-home flag is ON. The account's home is both the launch home and the credential store, so codex reads/refreshesauth.jsonin place — no hot-swap, no read-back reconciliation, no shared file to race.Changes
codex/codex-home-paths.ts—syncSystemCodexResourcesIntoManagedHome(managedHomePath?)links the system resources (skills/hooks/plugins/plugin-state/profile-v2/themes/prompts/AGENTS.md) into any managed home, reusing the existing ownership-marker + owned-fallback-copy discipline. It only ever reads~/.codexand writes symlinks/owned copies into the target home — never symlinks into or mutates~/.codex.codex-accounts/runtime-home-service.ts—prepareForCodexLaunch/prepareForRateLimitFetch/syncForCurrentSelectionroute a host managed account to its own home and skip the shared-home snapshot/hot-swap/read-back machinery. Resources + config are materialized into the per-account home at launch. A vanishedauth.jsondrops the selection and falls back to the system default.getHostCodexHomePathsForSessionDiscoveryscans every per-account home so account-scoped rollouts still surface in the AI Vault.codex/hook-service.ts+codex/hook-trust-promotion.ts—install/getStatus/refreshRuntimeUserHooks(and the promotion/provenance helpers) accept aruntimeHomePath, so hooks.json + config.toml + RPC-granted trust land in the per-account home. Default stays the shared mirror (flag-OFF/WSL/SSH unchanged).main/index.ts— the launch prep passes the resolved per-account home into the hook install.codex-accounts/service.ts— config mirroring into a self-contained host home uses the trust-preserving merge (syncSystemConfigIntoManagedCodexHome) instead of the sanitize-overwrite, so hook/project trust codex granted in that home survives account switches (no re-approval / app-server re-grant churn). WSL homes and the flag-OFF path keep the existing sanitize path.ai-vault/codex-session-root-dedup.ts—codex-accounts/<id>/homeranks as canonical managed (tier 1) alongside the shared runtime home, so hardlinked aliases collapse onto the per-account home over WSL/remote/custom roots (real homenullstill wins).Routing matrix
CODEX_HOMEnull→ real~/.codexcodex-accounts/<id>/homeauth.json→ no raceRows 3–5 are new/pinned by this PR; unblocks Phase-2 mirror deletion (no lane injects the shared
homewhen the flag is ON).Guardrails
~/.codexis never mutated: resources link/copy from it into the per-account home; auth stays per-account; the only write-back to~/.codexis the pre-existing whitelisted config-settings promotion (model/approvals), identical to what the shared home already does.rmSync) of a per-account home removes symlinks as links, never following into~/.codex.null) lane are byte-identical to today.CODEX_HOMEcauses a Codex auth-revocation war with the user's~/.codex#5370 preserved: the nested-OrcaCODEX_HOME === ORCA_CODEX_HOMEdaemon strip is value-agnostic and still fires for per-account home values.Test evidence (sandboxed temp homes only)
npx vitest run --config config/vitest.config.ts(affected suites) +pnpm run typecheck:node— all green. New/updated coverage:auth.json(each home keeps its own auth; sharedauth.jsonnever written).~/.codexuntouched.~/.codex.CODEX_HOMEstrip ([Bug]: Orca's privateCODEX_HOMEcauses a Codex auth-revocation war with the user's~/.codex#5370).codex+codex-accountssuites: 622 passed.Notes
CODEX_HOME).Do not merge — draft for review.