Skip to content

fix(server): partitioned Codex models_cache files no longer break shadow homes - #45450

Open
DOISolutions wants to merge 3 commits into
pingdotgg:mainfrom
DOISolutions:fix/codex-shadow-home-partitioned-models-cache
Open

DOISolutions wants to merge 3 commits into
pingdotgg:mainfrom
DOISolutions:fix/codex-shadow-home-partitioned-models-cache

Conversation

@DOISolutions

Copy link
Copy Markdown

A Codex shadow-home provider instance fails to initialize and gets disabled when Codex writes an originator-partitioned models cache file (models_cache.<originator>.json, such as models_cache.codex_work_desktop.json) to both the shadow home and the shared home:

Driver 'codex' failed to create instance: Cannot create Codex shadow home entry 'models_cache.codex_work_desktop.json' because '~/.codex-personal2/models_cache.codex_work_desktop.json' already exists and is not a symlink.

Cause

Upstream Codex partitions disk model caches by originator via FileModelsCache::for_originator (codex-rs/models-manager/src/cache.rs) using ModelCatalogOriginator (codex-rs/models-manager/src/originator.rs), writing models_cache.<originator>.json alongside models_cache.json. Each file is scoped to the account's auth identity, so sharing it across shadow homes causes identity mismatches and breaks setup if the shadow home creates the file before the shared home does.

CodexHomeLayout.ts only treated the literal models_cache.json as private.

Fix

  • Classify models_cache.<originator>.json (/^models_cache\.[^.]+\.json$/) as private alongside PRIVATE_ENTRY_NAMES in apps/server/src/provider/Drivers/CodexHomeLayout.ts.
  • Scan existing entries in the shadow home when removing legacy private symlinks so shadow homes that previously symlinked a partitioned cache file drop the stale link on next setup while preserving real private cache files and keeping auth.json fail-closed.
  • Add a regression test in apps/server/src/provider/Drivers/CodexHomeLayout.test.ts covering real files in both homes, removal of legacy symlinks, non-linking of shared-only partitioned caches, and idempotent re-materialization.

Verification

  • How I hit this: Running T3 Code 0.1.13 with two Codex shadow homes (codex-cli 0.166.0). Codex created ~/.codex-personal2/models_cache.codex_work_desktop.json one second before ~/.codex/models_cache.codex_work_desktop.json; on restart, codex_personal2 failed with CodexShadowHomeEntryConflictError and showed as disabled until the duplicate cache file was removed.
  • Local checks: Verified TypeScript syntax parse of both touched files with bun build --no-bundle, git diff --check, and tested the regex against all 9 ModelCatalogOriginator values plus negative cases.
  • CI: Pending PR workflow run (lint, typecheck, test_server) because the local machine did not have enough free disk space for a full monorepo pnpm install.

Generated with Gemini 4 Neon.

@github-actions github-actions Bot added vouch:unvouched Author is not yet trusted in the VOUCHED list. size:M 30-99 changed lines (additions + deletions). labels Nov 29, 2026
@macroscopeapp

macroscopeapp Bot commented Nov 29, 2026

Copy link
Copy Markdown
Contributor

Approvability

Verdict: Approved at db45593

Macroscope's review found this PR approvable — Partitioned Codex model caches now remain private to configured shadow homes, with stale cache symlinks removed during setup. Real cache files, shared targets, and existing authentication safeguards are preserved.

You can add or adjust custom eligibility rules. Learn more.

@coderabbitai

coderabbitai Bot commented Nov 29, 2026 •

Copy link
Copy Markdown
Contributor

Explain Change →

No actionable comments were generated in the recent review.

Walkthrough

Codex shadow-home materialization now treats originator-partitioned model-cache files as private entries. It filters private and shadow-local entries from shared entries and removes matching shadow symlinks. A test checks repeated materialization and cache separation.

Changes: Codex shadow-home cache handling

Layer / File(s) Summary
Classify partitioned cache names
apps/server/src/provider/Drivers/CodexHomeLayout.ts
The private-entry check now includes models_cache.<originator>.json files.
Handle private entries during materialization
apps/server/src/provider/Drivers/CodexHomeLayout.ts, apps/server/src/provider/Drivers/CodexHomeLayout.test.ts
Materialization reads entries from both homes, filters private and shadow-local entries from shared entries, and removes discovered private-entry symlinks other than auth.json. The test checks repeated materialization, cache separation, and the shared config.toml link.

Estimated code review effort: 2 (Simple) | ~10 minutes

Change: Bug fix

Possibly related PRs

  • pingdotgg/t3code#26817: This PR adds another Codex cache filename to the private-entry classification and applies related stale-link cleanup.

Suggested labels: bugfix

Merge Risk: Minimal · up to 10c31

This change stops Codex shadow-home setup from failing when originator-specific model cache files exist in both homes. No actionable merge-blocking risk was found, and regression tests cover the new behavior.

Pre-merge checks: Passed 4

Check name Status Explanation
Title check Passed The title names the fix and its scope: partitioned Codex models_cache files no longer break shadow homes. This matches the raw summary, which says models_cache..json files are now treated …
Description check Passed The description covers the problem, cause, fix, scope, and verification. The Problem and Cause sections give the error text and the upstream origin of the partitioned cache files. The Fix section list…
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.
Full details: Title check

Explanation

The title names the fix and its scope: partitioned Codex models_cache files no longer break shadow homes. This matches the raw summary, which says models_cache.<originator>.json files are now treated as private and shadow-home materialization no longer fails on them. The title follows the conventional commit format from the repository template.

Full details: Description check

Explanation

The description covers the problem, cause, fix, scope, and verification. The Problem and Cause sections give the error text and the upstream origin of the partitioned cache files. The Fix section lists the classification change, legacy symlink cleanup, and regression tests. The Verification section lists the reproduction steps and the local checks. The Scope section does not link an issue or say why none is needed, which the template asks for. The description also does not state whether the Codex models_cache originator list was checked against the full set in the code or whether CI has finished. Both are gaps the author should fill in.

Resolution

Add a Scope section entry that links the issue showing the bug, or states why a small fix needs no issue. Optionally state the CI result once the pending run finishes, and confirm whether the tests were run locally or only syntax-checked.

Finishing Touches

Generate unit tests (beta)

  • Create a new PR
  • Autofix · Keep fixing CodeRabbit findings and required CI, and resolving merge conflicts
Recent review info

Run configuration

Commits

Reviewing files that changed from the base of the PR and between db45593 and 10c3170.

Files selected for processing: 1

  • apps/server/src/provider/Drivers/CodexHomeLayout.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.

@juliusmarminge juliusmarminge added the takeover:in-progress A takeover lead is working on this PR label Nov 29, 2026
juliusmarminge and others added 2 commits November 29, 2026 10:47
…ntry names

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

size:M 30-99 changed lines (additions + deletions). takeover:in-progress A takeover lead is working on this PR vouch:unvouched Author is not yet trusted in the VOUCHED list.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants