Skip to content

Revert "fix(codex): launch WSL accounts from direct homes" and "refactor(codex): remove WSL runtime mirror machinery" (#16504, #16505) - #16722

Merged
brennanb2025 merged 1 commit into
mainfrom
revert-pr-16504
Aug 27, 2026
Merged

brennanb2025 merged 1 commit into
mainfrom
revert-pr-16504

Conversation

@AmethystLiang

@AmethystLiang AmethystLiang commented Aug 27, 2026 •

Copy link
Copy Markdown
Contributor
Files Added Deleted Net
Test 10 $\color{#1a7f37}{\Huge{\mathbf{+}}}$​382 $\color{#cf222e}{\Huge{\mathbf{−}}}$​559 $\color{#cf222e}{\Huge{\mathbf{−}}}$​177
Prod 7 $\color{#1a7f37}{\Huge{\mathbf{+}}}$​393 $\color{#cf222e}{\Huge{\mathbf{−}}}$​594 $\color{#cf222e}{\Huge{\mathbf{−}}}$​201

Reverts #16504 and dependent #16505.

Launch Blocker Rationale (Continuous Readiness Counsel Validated)

  • F06-1 (P0 Blocker): Destination auth.json can be truncated by a concurrent in-place rewrite during WSL legacy auth drain. When promoteAuth=0 and deleteSource=1, the apply script deletes the intact source auth without revalidating destination integrity, permanently destroying user authentication credentials on upgrade.
  • FC-01 (P1 Blocker): Pre-upgrade WSL sessions under ~/.local/share/orca/codex-runtime-home/home are 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

…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.
@coderabbitai

coderabbitai Bot commented Aug 27, 2026

Copy link
Copy Markdown
Contributor

Review Change Stack

📝 Walkthrough

Walkthrough

The 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 f4be7

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)

Check name Status Explanation Resolution
Description check ⚠️ Warning 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, Vi… 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 s…
Docstring Coverage ⚠️ Warning 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… Write docstrings for the functions missing them to satisfy the coverage threshold.
✅ Passed checks (3 passed)
Check name Status Explanation
Title check ✅ Passed 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 understand…
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 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 check

Explanation

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 Coverage

Explanation

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.)

  • Fix all pre-merge checks with AI
✨ Finishing Touches 💡 1
📝 Generate docstrings 💡
  • Create stacked PR
  • Commit on current branch

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.

@coderabbitai coderabbitai 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.

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

📥 Commits

Reviewing files that changed from the base of the PR and between 673842d and f4be7fa.

📒 Files selected for processing (17)
  • src/main/agent-auth-restart-preservation.test.ts
  • src/main/agent-auth-restart-preservation.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-accounts/legacy-wsl-runtime-auth-drain.ts
  • src/main/codex-accounts/runtime-home-service.ts
  • src/main/codex-accounts/runtime-home-wsl-managed-accounts.test.ts
  • src/main/codex-accounts/runtime-home-wsl-session-bridge.test.ts
  • src/main/codex-accounts/runtime-home-wsl-system-default.test.ts
  • src/main/codex-accounts/wsl-codex-auth-batch-reader.ts
  • src/main/codex/codex-pane-account-registry.ts
  • src/main/codex/codex-pane-launch-account.test.ts
  • src/main/codex/codex-pane-launch-account.ts
  • src/main/codex/codex-stale-pane-accounts.test.ts
  • src/main/pty/codex-home-wsl-env.ts
  • src/main/wsl/__fixtures__/wsl-invocation-allowlist.txt
  • src/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.

Comment on lines +45 to +48
if (codexRuntimeHome && Date.now() - startedAt < AUTH_PRESERVATION_TIMEOUT_MS) {
runWslCodexPreservationStep(codexRuntimeHome)
} else if (codexRuntimeHome) {
logStepTimeout('Codex auth preservation', 0)

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.

🩺 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' src

Repository: 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-accounts

Repository: 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/main

Repository: 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/shared

Repository: 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.ts

Repository: 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 240

Repository: 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.

Comment on lines +1097 to +1099
mkdirSync(runtimeHomePath, { recursive: true })
this.safeMigrateLegacyWslActiveHomePointer(distro, runtimeHomePath)
this.seedWslRuntimeHome(runtimeHomePath, activeAccount, distro)

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.

🩺 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)
     }
   }

Comment on lines +1132 to 1144
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
)
})
}

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.

🎯 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.

Suggested change
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

@brennanb2025
brennanb2025 merged commit 9c01e09 into main Aug 27, 2026
49 checks passed
paidaxingyo666 pushed a commit to paidaxingyo666/Manta that referenced this pull request Aug 30, 2026
…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)
enrick-dev pushed a commit to enrick-dev/orca that referenced this pull request Oct 15, 2026
…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.
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.

2 participants