Repository navigation
Revert "fix(codex): launch WSL accounts from direct homes" and "refactor(codex): remove WSL runtime mirror machinery" (#16504, #16505) - #16722
Conversation
…tor(codex): remove WSL runtime mirror machinery" This reverts commit ebcd637 (#16504) and dependent commit 673842d (#16505). Launch-blocker rationale (findings-counsel validated): - P0 Data Loss (F06-1): The WSL legacy auth drain deleteSource=1 path deletes intact source auth without re-validating the destination after concurrent destination rewrites, permanently corrupting auth credentials on upgrade. - P1 Workflow Regression (FC-01): Pre-upgrade sessions under ~/.local/share/orca/codex-runtime-home/home are not linked into direct homes, breaking /resume in the Codex CLI for upgrading WSL users.
📝 WalkthroughWalkthroughThe change replaces legacy WSL authentication draining with stable per-distro runtime homes. WSL launches now seed runtime auth, configuration, and instructions, then start session bridging from the materialized home. Auth read-back validates identity and freshness and synchronizes refreshed credentials. Restart preservation uses a shared timeout budget. WSL pane routing, legacy active-home migration, system-default handling, and related tests and allowlists now use the runtime-home model. Merge Risk: 🟡 Moderate · up to The change can unexpectedly switch WSL accounts during transient credential rotation, repeatedly freeze the application while preparing launches, and allow restart operations to exceed their lifecycle deadline. Merge should wait for these bounded correctness and responsiveness risks to be fixed or explicitly accepted. 🚥 Pre-merge checks | ✅ 3 | ❌ 2❌ Failed checks (2 warnings)
✅ Passed checks (3 passed)
Full details: Title checkExplanation The title clearly identifies that the pull request reverts the two WSL-related changes and matches the main changes in the pull request. It is longer than preferred but remains specific and understandable. Full details: Description checkExplanation The description explains the revert and documents two launch blockers, but it does not follow most required template sections. It omits ELI5, What Changed, Why, Linked Issue in the required format, Visual Proof or N/A, Testing, AI Disclosure, Review, boundary confirmation, Notes, and the checklist. Resolution Complete the required pull request template. Add concise ELI5, What Changed, and Why sections; provide a Linked Issue entry using “Fixes #” or explain the applicable issue; add Visual Proof or write N/A with a reason; document testing and supported platforms; complete AI Disclosure, Review, Agent skill upstream boundary, Notes, and the Checklist. Full details: Docstring CoverageExplanation Docstring coverage is 16.67% which is insufficient. The required threshold is 80.00%. Docstring coverage is scoped to functions touched by this diff. Analyzed 6 functions across 9 files. (2 skipped: 2 unsupported.)
✨ Finishing Touches 💡 1📝 Generate docstrings 💡
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: 3
ℹ️ Review info
⚙️ Run configuration
Configuration used: Repository UI
Review profile: CHILL
Plan: Pro Plus
Run ID: 8a426579-3e97-4fda-995e-b07198c9449a
📒 Files selected for processing (17)
src/main/agent-auth-restart-preservation.test.tssrc/main/agent-auth-restart-preservation.tssrc/main/codex-accounts/legacy-wsl-runtime-auth-drain-apply-script.test.tssrc/main/codex-accounts/legacy-wsl-runtime-auth-drain.test.tssrc/main/codex-accounts/legacy-wsl-runtime-auth-drain.tssrc/main/codex-accounts/runtime-home-service.tssrc/main/codex-accounts/runtime-home-wsl-managed-accounts.test.tssrc/main/codex-accounts/runtime-home-wsl-session-bridge.test.tssrc/main/codex-accounts/runtime-home-wsl-system-default.test.tssrc/main/codex-accounts/wsl-codex-auth-batch-reader.tssrc/main/codex/codex-pane-account-registry.tssrc/main/codex/codex-pane-launch-account.test.tssrc/main/codex/codex-pane-launch-account.tssrc/main/codex/codex-stale-pane-accounts.test.tssrc/main/pty/codex-home-wsl-env.tssrc/main/wsl/__fixtures__/wsl-invocation-allowlist.txtsrc/shared/child-process/__fixtures__/child-process-import-allowlist.txt
💤 Files with no reviewable changes (6)
- src/main/codex/codex-pane-account-registry.ts
- src/main/codex-accounts/legacy-wsl-runtime-auth-drain.ts
- src/main/codex-accounts/legacy-wsl-runtime-auth-drain-apply-script.test.ts
- src/main/codex-accounts/legacy-wsl-runtime-auth-drain.test.ts
- src/main/codex/codex-stale-pane-accounts.test.ts
- src/main/codex-accounts/wsl-codex-auth-batch-reader.ts
Included review availability: Your plan provides up to 10 included reviews per hour; 3 remain after this review.
| if (codexRuntimeHome && Date.now() - startedAt < AUTH_PRESERVATION_TIMEOUT_MS) { | ||
| runWslCodexPreservationStep(codexRuntimeHome) | ||
| } else if (codexRuntimeHome) { | ||
| logStepTimeout('Codex auth preservation', 0) |
There was a problem hiding this comment.
🩺 Stability & Availability | 🟠 Major | 🏗️ Heavy lift
🔎 Supported by static analysis
🏁 Script executed:
#!/bin/bash
set -e
printf '%s\n' '--- applicable repository conventions ---'
find /tmp/coderabbit-repo-knowledge/stablyai-orca-89dc44e4 -type f -name '*.md' -print | sort
printf '%s\n' '--- target outline ---'
ast-grep outline src/main/agent-auth-restart-preservation.ts --lang typescript
printf '%s\n' '--- target source ---'
cat -n src/main/agent-auth-restart-preservation.ts
printf '%s\n' '--- directly bound symbols and callers ---'
rg -n -C 4 'runWithinLifecycleTimeout|runWslCodexPreservationStep|syncActiveWslSelectionsBeforeRestart|AUTH_PRESERVATION_TIMEOUT_MS|agent-auth-restart-preservation' srcRepository: stablyai/orca
Length of output: 21276
🏁 Script executed:
#!/bin/bash
set -e
printf '%s\n' '--- conventions for src/main and src ---'
cat /tmp/coderabbit-repo-knowledge/stablyai-orca-89dc44e4/conventions/src-main-daemon.md
cat /tmp/coderabbit-repo-knowledge/stablyai-orca-89dc44e4/conventions/src.md
printf '%s\n' '--- relevant runtime-home implementation ---'
cat -n src/main/codex-accounts/runtime-home-service.ts | sed -n '680,770p'
printf '%s\n' '--- methods called by WSL read-back ---'
rg -n -C 5 'syncActiveWslSelectionsBeforeRestart|syncActiveWsl|wsl|execFileSync|spawnSync|execSync' src/main/codex-accounts/runtime-home-service.ts src/main/codex-accountsRepository: stablyai/orca
Length of output: 50370
🏁 Script executed:
#!/bin/bash
set -e
printf '%s\n' '--- runtime-home service method ---'
cat -n src/main/codex-accounts/runtime-home-service.ts | sed -n '700,755p'
printf '%s\n' '--- exact callees in the preservation path ---'
python3 - <<'PY'
from pathlib import Path
p = Path('src/main/codex-accounts/runtime-home-service.ts')
lines = p.read_text().splitlines()
terms = ('syncActiveWslSelectionsBeforeRestart', 'syncWsl', 'execFileSync', 'copyFileSync', 'readFileSync', 'writeFileSync')
for i, line in enumerate(lines, 1):
if 'syncActiveWslSelectionsBeforeRestart' in line:
print(f'--- method at {i} ---')
for n in range(max(1, i-8), min(len(lines), i+45)+1):
print(f'{n:5}: {lines[n-1]}')
PY
printf '%s\n' '--- WSL process helper definitions ---'
rg -n -C 8 'function (runWslProcess|runWslCommand)|const (runWslProcess|runWslCommand)|export .*runWslProcess|WSL_.*TIMEOUT' src/mainRepository: stablyai/orca
Length of output: 50370
🏁 Script executed:
#!/bin/bash
set -e
printf '%s\n' '--- safe read-back implementation ---'
rg -n -C 12 'safeReadBackActiveWslAccountBeforeRestart' src/main/codex-accounts/runtime-home-service.ts
printf '%s\n' '--- bounded WSL and synchronous process contracts used by runtime-home-service.ts ---'
rg -n -C 10 'execFileSync\(' src/main/codex-accounts/runtime-home-service.ts
rg -n -C 10 'function runWslProcess|const runWslProcess|export .*runWslProcess|runWslProcess\s*=' src/main/codex-accounts src/main/shared src/sharedRepository: stablyai/orca
Length of output: 13579
🏁 Script executed:
#!/bin/bash
set -e
cat -n src/main/codex-accounts/runtime-home-service.ts | sed -n '1180,1315p'Repository: stablyai/orca
Length of output: 5990
🏁 Script executed:
#!/bin/bash
set -e
rg -n -C 18 'readBackRefreshedTokensFromPath' src/main/codex-accounts/runtime-home-service.tsRepository: stablyai/orca
Length of output: 4770
🏁 Script executed:
#!/bin/bash
set -e
cat -n src/main/codex-accounts/runtime-home-service.ts | sed -n '935,1015p'
printf '%s\n' '--- repository WSL boundary references ---'
rg -n -C 5 'readFileSync|existsSync|WSL.*timeout|filesystem.*timeout|stalls|stall' docs src/main/codex-accounts src/main | head -n 240Repository: stablyai/orca
Length of output: 27655
Enforce the deadline for WSL read-back. If syncActiveWslSelectionsBeforeRestart() stalls, its synchronous existsSync() and readFileSync() calls cannot be released by runWithinLifecycleTimeout, so restart can exceed the shared 2,000 ms deadline. Make this read-back asynchronous and bound the filesystem operation.
| mkdirSync(runtimeHomePath, { recursive: true }) | ||
| this.safeMigrateLegacyWslActiveHomePointer(distro, runtimeHomePath) | ||
| this.seedWslRuntimeHome(runtimeHomePath, activeAccount, distro) |
There was a problem hiding this comment.
🩺 Stability & Availability | 🟠 Major | 🏗️ Heavy lift
Run the legacy WSL pointer migration once per distro, not on every sync.
safeMigrateLegacyWslActiveHomePointer spawns wsl.exe with execFileSync on every call to syncWslRuntimeForCurrentSelection. That method runs on each Codex launch preparation, on each syncForCurrentSelection({ runtime: 'wsl' }), and on every rate-limit cache miss in getPreparedWslRateLimitHomePath. execFileSync blocks the Electron main process for up to the 5000 ms timeout at Line 1264, so a cold or busy WSL distro freezes the UI repeatedly. The shell-side existence check does not avoid the process spawn.
Gate the migration behind per-distro process state (or a durable marker) so it runs at most once per distro.
♻️ Proposed guard
+ private readonly migratedLegacyWslActiveHomeDistros = new Set<string>()
+
private safeMigrateLegacyWslActiveHomePointer(distro: string, runtimeHomePath: string): void {
+ if (this.migratedLegacyWslActiveHomeDistros.has(distro)) {
+ return
+ }
+ this.migratedLegacyWslActiveHomeDistros.add(distro)
try {
this.migrateLegacyWslActiveHomePointer(distro, runtimeHomePath)
} catch (error) {
console.warn('[codex-runtime-home] Failed to migrate legacy WSL active Codex home:', error)
}
}| if (activeAccount && activeAuthPath) { | ||
| console.warn( | ||
| '[codex-runtime-home] Active WSL managed account is missing auth.json, restoring system default' | ||
| ) | ||
| this.store.updateSettings({ | ||
| activeCodexManagedAccountId: settings.activeCodexManagedAccountId, | ||
| activeCodexManagedAccountIdsByRuntime: setSelectedCodexAccountIdForTarget( | ||
| normalizeCodexRuntimeSelection(settings), | ||
| null, | ||
| wslTarget | ||
| ) | ||
| }) | ||
| } |
There was a problem hiding this comment.
🎯 Functional Correctness | 🟠 Major | ⚡ Quick win
A transient missing auth.json now deselects the WSL account.
When the managed home exists but auth.json cannot be found, this branch clears the WSL selection immediately and the flow below mirrors system-default credentials into the runtime home. Codex replaces auth.json atomically, and on Windows antivirus or indexing can make the file briefly absent to existsSync. The user then loses the selected account and launches under different credentials.
The host lane already solves this with this.credentialAbsenceGrace (see Lines 404-411 and the #STA-4422 rationale). Reuse it here so only a durable absence clears the selection.
🛡️ Proposed fix
if (activeAccount && activeAuthPath) {
+ const absence = this.credentialAbsenceGrace.assess(activeAuthPath)
+ if (!absence.durable) {
+ // Why: Codex rotates auth.json atomically; a transient absence must not
+ // deselect the account and swap in system-default credentials.
+ return runtimeHomePath
+ }
console.warn(
'[codex-runtime-home] Active WSL managed account is missing auth.json, restoring system default'
)As per coding guidelines: "check whether an existing implementation already does the job (or nearly does). Extend or generalize it instead of building a parallel version".
📝 Committable suggestion
‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.
| if (activeAccount && activeAuthPath) { | |
| console.warn( | |
| '[codex-runtime-home] Active WSL managed account is missing auth.json, restoring system default' | |
| ) | |
| this.store.updateSettings({ | |
| activeCodexManagedAccountId: settings.activeCodexManagedAccountId, | |
| activeCodexManagedAccountIdsByRuntime: setSelectedCodexAccountIdForTarget( | |
| normalizeCodexRuntimeSelection(settings), | |
| null, | |
| wslTarget | |
| ) | |
| }) | |
| } | |
| if (activeAccount && activeAuthPath) { | |
| const absence = this.credentialAbsenceGrace.assess(activeAuthPath) | |
| if (!absence.durable) { | |
| // Why: Codex rotates auth.json atomically; a transient absence must not | |
| // deselect the account and swap in system-default credentials. | |
| return runtimeHomePath | |
| } | |
| console.warn( | |
| '[codex-runtime-home] Active WSL managed account is missing auth.json, restoring system default' | |
| ) | |
| this.store.updateSettings({ | |
| activeCodexManagedAccountId: settings.activeCodexManagedAccountId, | |
| activeCodexManagedAccountIdsByRuntime: setSelectedCodexAccountIdForTarget( | |
| normalizeCodexRuntimeSelection(settings), | |
| null, | |
| wslTarget | |
| ) | |
| }) | |
| } |
Source: Coding guidelines
…tor(codex): remove WSL runtime mirror machinery" (stablyai#16722) This reverts commit ebcd637 (stablyai#16504) and dependent commit 673842d (stablyai#16505). Launch-blocker rationale (findings-counsel validated): - P0 Data Loss (F06-1): The WSL legacy auth drain deleteSource=1 path deletes intact source auth without re-validating the destination after concurrent destination rewrites, permanently corrupting auth credentials on upgrade. - P1 Workflow Regression (FC-01): Pre-upgrade sessions under ~/.local/share/orca/codex-runtime-home/home are not linked into direct homes, breaking /resume in the Codex CLI for upgrading WSL users. (cherry picked from commit 9c01e09)
…tor(codex): remove WSL runtime mirror machinery" (stablyai#16722) This reverts commit 35c6098 (stablyai#16504) and dependent commit bf956ae (stablyai#16505). Launch-blocker rationale (findings-counsel validated): - P0 Data Loss (F06-1): The WSL legacy auth drain deleteSource=1 path deletes intact source auth without re-validating the destination after concurrent destination rewrites, permanently corrupting auth credentials on upgrade. - P1 Workflow Regression (FC-01): Pre-upgrade sessions under ~/.local/share/orca/codex-runtime-home/home are not linked into direct homes, breaking /resume in the Codex CLI for upgrading WSL users.
Reverts #16504 and dependent #16505.
Launch Blocker Rationale (Continuous Readiness Counsel Validated)
auth.jsoncan be truncated by a concurrent in-place rewrite during WSL legacy auth drain. WhenpromoteAuth=0anddeleteSource=1, the apply script deletes the intact source auth without revalidating destination integrity, permanently destroying user authentication credentials on upgrade.~/.local/share/orca/codex-runtime-home/homeare not linked into direct homes, making existing conversation history invisible to Codex/resume.Validated by 4-seat findings counsel (Grok, Codex gpt-5.6-sol, Claude Opus, Claude Sonnet).
cc @brennanb2025