Repository navigation
fix(codex): a transcript lookup miss creates no Codex directories - #29557
Conversation
|
Warning Review limit reachedYou've used all free OSS reviews for now. Wait for the free limit to reset to keep reviewing this public repository. Next included review available in 12 minutes. View limit details
No actionable comments were generated in the recent review. 🎉 ℹ️ Recent review info
📝 Walkthrough
Priority: ⬇️ Low Merge Risk: ⚪ Minimal · up to
|
The per-account tier of the session-file resolver listed homes through getHostCodexHomePathsForSessionDiscovery, which reached the mkdir-ing getOrcaManagedCodexHomePath. The transcript poll runs every 5 s on a miss, so users who never used Codex got userData/codex-runtime-home/home created. Use the path-only resolver for discovery, and skip the per-account ownership checks while the managed accounts root does not exist. Follow-up to #28469.
1c03dd7 to
320b74b
Compare
ELI5
When Orca is waiting for a chat transcript file to appear, it checks every 5 seconds. One of those checks asked a helper for "the Codex folders to look in", and that helper also created Orca's private Codex folder as a side effect. So people who had never used Codex ended up with an empty
codex-runtime-home/homefolder in Orca's data directory. Looking for a file should never create folders. Now the lookup only computes the folder paths and creates nothing.What Changed
Before: on a lookup miss, the session-file resolver's per-account tier (
codexAccountSessionsDirs→hostAdditionalCodexHomePaths) calledgetHostCodexHomePathsForSessionDiscovery(). Its first entry came fromthis.getRuntimeHomePath(), which isgetOrcaManagedCodexHomePath(), and that runsmkdirSync. The resolver's own comment already says this poll must not create that folder, and its first tier already used the path-only resolver; the per-account tier added in #28469 went around it. Every miss also ran the per-account ownership checks (synchronous stat, realpath and marker reads, plus a warning) even when the managed accounts folder didn't exist at all.After:
getHostCodexHomePathsForSessionDiscovery()uses the existing path-onlyresolveOrcaManagedCodexHomePath(). It is the same path string, minus themkdirSync. Launch, hooks, the config mirror and the session bridge still create the folder through the original getter, exactly when they need it.getManagedAccountHomesForSessionDiscovery()checks the managed accounts root once per call. If it is definitively absent (ENOENT/ENOTDIR), it skips the host-account ownership checks. No host account home can be "owned" without that root, so the result is the same, just without the disk reads and the per-poll warning. Any other error (EPERM, EBUSY, ...) still goes to the ownership check, which reports it as "indeterminate" (#STA-4422). WSL account homes are still listed.Why
The audit asked for a non-creating resolver, reusing one if it existed.
resolveOrcaManagedCodexHomePath()already exists and is what the resolver's first tier and the launch-route prediction already use, so no new read-only variant was needed. All callers ofgetHostCodexHomePathsForSessionDiscovery()were checked: AI Vault listing, orcad'slistCodexSessionHomes, and Codex resume's trusted-home list. They only list or compare paths, and a missing home just lists as empty. None depended on the folder being created.Linked Issue
Follow-up to #28469 (which added the per-account lookup tier). Found in a post-merge audit.
Visual Proof
N/A: no UI change. The only visible difference is that no stray folder appears in Orca's data directory.
Testing
New
src/main/codex-accounts/runtime-home-session-discovery-read-only.test.tswires the realCodexRuntimeHomeServiceinto the realresolveSessionFilePath. It starts from a userData with no Codex mirror and no accounts folder (but one persisted host account), and runs two lookup misses. It asserts that:codex-runtime-home/homedoes not exist;I confirmed it fails with the old code. The existing codex-accounts, session-file-resolver, AI Vault resume and Codex resume/startup tests pass (69 files, 530 tests), and so do
pnpm tcandcheck:code-quality:changed.AI Disclosure
Review
An adversarial review found nothing blocking. It checked every caller for reliance on the mkdir: none, and the path string is identical. It also checked that skipping the account checks when the root is missing can never drop a home that would have been "owned", because ownership requires
realpath(root)to succeed. It noted, and I left unchanged: when the root exists but one account's home was deleted, each poll still logs the existing "untrusted" warning, as before.Agent skill upstream boundary
Notes
Ensure no issues in: Security, Cross-platoform support (Linux, Windows, Mac), Remote SSH, Mobile, general backwards compatibility, performance
Host-local only. SSH transcripts are read from the path the remote hook reports and never use this tier. WSL account homes are listed exactly as before.
Checklist
N/Awith reasonpnpm lint,pnpm typecheck,pnpm test, andpnpm buildpass (or CI will cover; local preferred)