Repository navigation
fix(codex): heal WSL hooks before typed launches - #16535
Conversation
|
Note Reviews pausedIt looks like this branch is under active development. To avoid overwhelming you with review comments due to an influx of new commits, CodeRabbit has automatically paused this review. You can configure this behavior by changing the Use the following commands to manage reviews:
Use the checkboxes below for quick actions:
No actionable comments were generated in the recent review. 🎉 ℹ️ Recent review info⚙️ Run configurationConfiguration used: Repository UI Review profile: CHILL Plan: Pro Plus Run ID: 📒 Files selected for processing (28)
🚧 Files skipped from review as they are similar to previous changes (22)
Included review availability: Your plan provides up to 10 included reviews per hour; 3 remain after this review. 📝 WalkthroughWalkthroughWSL Codex preparation now validates managed homes, distro names, and POSIX paths before installing hooks through the WSL runtime. A new runtime RPC exposes this preparation to the CLI and restricts calls to local clients. WSL hook relay installation delegates Codex to the runtime-home installer. WSL launcher resolution converts packaged Windows paths to guest paths. Shell wrappers require an executable preflight path. WSL environment forwarding carries the preflight variable without translation. Tests cover routing, validation, installation behavior, launcher handling, and shell wrapper conditions. 🚥 Pre-merge checks | ✅ 3 | ❌ 2❌ Failed checks (2 warnings)
✅ Passed checks (3 passed)
Full details: Description checkExplanation The description explains the change, rationale, scope, WSL behavior, reproduction, and verification results. However, it omits several required template sections and leaves the mandatory linked issue field empty. Resolution Add the required ELI5, What Changed, Why, Linked Issue with a valid issue number, Visual Proof with N/A and a reason if applicable, Testing, AI Disclosure, Review, Agent skill upstream boundary, Notes, and Checklist sections. Mark completed checklist items and document any exceptions. Full details: Docstring CoverageExplanation Docstring coverage is 18.75% which is insufficient. The required threshold is 80.00%. Docstring coverage is scoped to functions touched by this diff. Analyzed 16 functions across 21 files. (7 skipped: 7 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: 1
ℹ️ Review info
⚙️ Run configuration
Configuration used: Repository UI
Review profile: CHILL
Plan: Pro Plus
Run ID: 90089436-88a0-44cc-b452-f9c3835545eb
📒 Files selected for processing (17)
src/cli/handlers/agent-hooks.test.tssrc/cli/handlers/agent-hooks.tssrc/main/__fixtures__/shell-wrapper-snapshots/daemon-bash-rcfile.txtsrc/main/__fixtures__/shell-wrapper-snapshots/daemon-fish-init.txtsrc/main/__fixtures__/shell-wrapper-snapshots/daemon-zsh-zshenv.txtsrc/main/__fixtures__/shell-wrapper-snapshots/local-bash-rcfile.txtsrc/main/__fixtures__/shell-wrapper-snapshots/local-fish-init.txtsrc/main/__fixtures__/shell-wrapper-snapshots/local-zsh-zshenv.txtsrc/main/codex/managed-home-shell-preflight.test.tssrc/main/codex/managed-home-shell-preflight.tssrc/main/pty/codex-shell-launch-preflight.test.tssrc/main/pty/codex-shell-launch-preflight.tssrc/main/pty/wsl-orca-env.test.tssrc/main/pty/wsl-orca-env.tssrc/main/runtime/rpc/methods/agent-hooks.test.tssrc/main/runtime/rpc/methods/agent-hooks.tssrc/main/runtime/rpc/methods/index.ts
Included review availability: Your plan provides up to 10 included reviews per hour; 9 remain after this review.
| import type { AgentHookInstallStatus } from '../../shared/agent-hook-types' | ||
| import { normalizeRuntimePathForComparison } from '../../shared/cross-platform-path' | ||
| import { toWindowsWslPath } from '../../shared/wsl-paths' | ||
| import { wslCodexRuntimeHomeForGuestHome } from '../pty/codex-home-wsl-env' |
There was a problem hiding this comment.
🎯 Functional Correctness | 🟠 Major | ⚡ Quick win
Restore the CLI typecheck boundary.
Line 6 imports a file excluded from config/tsconfig.tc.cli.json. The declared CLI typecheck fails with TS6307. Move the helper to an included module or include its source in that project.
🧰 Tools
🪛 GitHub Check: typecheck
[failure] 6-6:
File '/home/runner/work/orca/orca/src/main/pty/codex-home-wsl-env.ts' is not listed within the file list of project '/home/runner/work/orca/orca/config/tsconfig.tc.cli.json'. Projects must list all files or use an 'include' pattern.
Source: Linters/SAST tools
ddfe391 to
307ca37
Compare
|
Note GitHub couldn't provide a complete incremental comparison for this pull request, so CodeRabbit is performing a full review instead. This review may take a little longer. |
There was a problem hiding this comment.
Actionable comments posted: 1
ℹ️ Review info
⚙️ Run configuration
Configuration used: Repository UI
Review profile: CHILL
Plan: Pro Plus
Run ID: 73710eb0-c35a-4a3a-acc0-c8303db5b16c
📥 Commits
Reviewing files that changed from the base of the PR and between 307ca37 and bc560dbd10d68b8191f45cd589079cea6e785547.
📒 Files selected for processing (12)
src/main/agent-hooks/remote-hook-service-installers.test.tssrc/main/agent-hooks/wsl-hook-fs-adapter.tssrc/main/agent-hooks/wsl-hook-relay-deps.tssrc/main/agent-hooks/wsl-hook-relay-guest-install.tssrc/main/agent-hooks/wsl-hook-relay-live.integration.test.tssrc/main/agent-hooks/wsl-hook-relay-manager.test.tssrc/main/codex/hook-service-wsl-runtime.test.tssrc/main/codex/hook-service.tssrc/main/codex/managed-home-shell-preflight.tssrc/main/pty/codex-preflight-profile-path-rewrite.test.tssrc/main/runtime/rpc/methods/agent-hooks.test.tssrc/main/runtime/rpc/methods/agent-hooks.ts
Included review availability: Your plan provides up to 10 included reviews per hour; 5 remain after this review.
bc560db to
2817a7f
Compare
|
Note GitHub couldn't provide a complete incremental comparison for this pull request, so CodeRabbit is performing a full review instead. This review may take a little longer. |
e526add to
04cbb2c
Compare
`managed-home-shell-preflight.ts` is already in the CLI project's include list and now imports `wslCodexRuntimeHomeForGuestHome` from `src/main/pty/codex-home-wsl-env.ts`, which the list did not cover — TS6307, so the CLI typecheck failed on every push. Added the single module rather than a `src/main/pty/**` glob: it is a 31-line leaf with no imports of its own, so it does not widen what the CLI bundle can reach.
Two independent readiness reviews agreed the Orca-terminal boundary holds, but Codex Sol found a P1 the other rated P2: the new just-in-time repair raced the existing relay installer and the two produced DIFFERENT hook and trust representations for the same managed home. Two unserialized writers emitting different formats is worse than the bug this PR fixes, because it fails intermittently rather than cleanly — a pane works or does not depending on which lane won. - Relay Codex installs now delegate to the runtime-home writer, so there is one canonical representation instead of two. Redirected scripts use the runtime path, the readable wrapper, and the prepended group. - `installForRuntimeHomeSerialized` puts every asynchronous WSL caller for a given home on one queue (`wslInstallQueues`), so concurrent panes cannot interleave writes. Also rewrites the stale pin test the new `-x` guard broke. It asserted the defect — "would run the impostor if the preflight carried an unqualified command name", expecting the hijack marker to exist. The guard is a security improvement, so the test now asserts the contract: an unqualified preflight is skipped and the marker is never written. Rewritten to the new behavior, not loosened or deleted. 818 tests pass across the affected suites; typecheck clean. The changed-file quality gate could not run locally — its pnpm engine-warning JSON parser fails under Node 26 — so CI covers it. The boundary both reviews verified is untouched: paired/relay/mobile clients stay hard-blocked from the RPC, params remain shape-locked to the managed home suffix with traversal rejection, nothing is written outside the managed home, and macOS/Linux stay inert.
e341dd2 to
99a687d
Compare
Codex review loop — statusREADY at head 99a687d. The branch was rebased onto current main, then a same-model gpt-5.6-sol/high adversarial review loop ran to clean. It fixed the bounded typed-launch preparation budget, restart reconstruction of managed WSL homes, symlink-containment enforcement, duplicate repair coalescing while preserving the real per-config mutation queue, and packaged WSL path transport. Guardrails were re-verified at this head: paired/relay/mobile callers are blocked from the repair RPC; the managed-home parameter shape rejects traversal; canonical containment prevents symlink write escape; writes stay within the resolved managed runtime home; macOS/Linux remain inert; and the user command remains unchanged as codex. Outside-Orca WSL validation had empty CODEX_HOME and ORCA_PANE_KEY, created no Orca panes, and did not trigger the managed hook flow. Verification includes 174 focused tests with 2 platform skips, end-readiness coverage of 25 files / 285 tests with 2 skips, node and CLI typechecks, changed-code quality, mutation checks for changed assertions, and green PR CI across Node 24/26, package, Windows package, wire compatibility, shell contracts, and E2E checks. Local and remote branch heads match with no unpushed commits. Windows/WSL Electron QA used Playwright CDP at this exact SHA: an Orca-created WSL terminal received the unchanged typed codex command, granted all 8 managed hook trusts, and rendered Working/Codex gpt-5.6-terra from hook-origin status instead of remaining an anonymous WSL pane. The host process table still reports wsl.exe at the WSL boundary, and a live hostile-symlink race was not exercised; the final readiness audit treated those as residual evidence gaps rather than blockers because containment is directly covered and the rendered hook-origin identity converged. Final readiness checklist: CLEAN/READY. |
Merge-risk answersThree questions came up before merging: cross-platform regression risk, whether this depends on Orca's agent launcher, and whether it survives the upcoming Does typing
|
* fix(codex): heal WSL hooks before typed launches * test(codex): keep launcher fixture type-safe on Windows * fix(build): list codex-home-wsl-env in the CLI typecheck project `managed-home-shell-preflight.ts` is already in the CLI project's include list and now imports `wslCodexRuntimeHomeForGuestHome` from `src/main/pty/codex-home-wsl-env.ts`, which the list did not cover — TS6307, so the CLI typecheck failed on every push. Added the single module rather than a `src/main/pty/**` glob: it is a 31-line leaf with no imports of its own, so it does not widen what the CLI bundle can reach. * fix(codex): converge the two WSL hook install lanes onto one writer Two independent readiness reviews agreed the Orca-terminal boundary holds, but Codex Sol found a P1 the other rated P2: the new just-in-time repair raced the existing relay installer and the two produced DIFFERENT hook and trust representations for the same managed home. Two unserialized writers emitting different formats is worse than the bug this PR fixes, because it fails intermittently rather than cleanly — a pane works or does not depending on which lane won. - Relay Codex installs now delegate to the runtime-home writer, so there is one canonical representation instead of two. Redirected scripts use the runtime path, the readable wrapper, and the prepended group. - `installForRuntimeHomeSerialized` puts every asynchronous WSL caller for a given home on one queue (`wslInstallQueues`), so concurrent panes cannot interleave writes. Also rewrites the stale pin test the new `-x` guard broke. It asserted the defect — "would run the impostor if the preflight carried an unqualified command name", expecting the hijack marker to exist. The guard is a security improvement, so the test now asserts the contract: an unqualified preflight is skipped and the marker is never written. Rewritten to the new behavior, not loosened or deleted. 818 tests pass across the affected suites; typecheck clean. The changed-file quality gate could not run locally — its pnpm engine-warning JSON parser fails under Node 26 — so CI covers it. The boundary both reviews verified is untouched: paired/relay/mobile clients stay hard-blocked from the RPC, params remain shape-locked to the managed home suffix with traversal rejection, nothing is written outside the managed home, and macOS/Linux stay inert. * fix(codex): serialize resolved WSL hook homes * fix(codex): recover managed WSL homes after restart * fix(wsl): translate Codex preflight through WSLENV * fix(cli): cover bounded WSL Codex repair * fix(codex): coalesce duplicate WSL hook repairs * fix(codex): verify reconstructed WSL homes (cherry picked from commit 3558cf9)
* fix(codex): heal WSL hooks before typed launches * test(codex): keep launcher fixture type-safe on Windows * fix(build): list codex-home-wsl-env in the CLI typecheck project `managed-home-shell-preflight.ts` is already in the CLI project's include list and now imports `wslCodexRuntimeHomeForGuestHome` from `src/main/pty/codex-home-wsl-env.ts`, which the list did not cover — TS6307, so the CLI typecheck failed on every push. Added the single module rather than a `src/main/pty/**` glob: it is a 31-line leaf with no imports of its own, so it does not widen what the CLI bundle can reach. * fix(codex): converge the two WSL hook install lanes onto one writer Two independent readiness reviews agreed the Orca-terminal boundary holds, but Codex Sol found a P1 the other rated P2: the new just-in-time repair raced the existing relay installer and the two produced DIFFERENT hook and trust representations for the same managed home. Two unserialized writers emitting different formats is worse than the bug this PR fixes, because it fails intermittently rather than cleanly — a pane works or does not depending on which lane won. - Relay Codex installs now delegate to the runtime-home writer, so there is one canonical representation instead of two. Redirected scripts use the runtime path, the readable wrapper, and the prepended group. - `installForRuntimeHomeSerialized` puts every asynchronous WSL caller for a given home on one queue (`wslInstallQueues`), so concurrent panes cannot interleave writes. Also rewrites the stale pin test the new `-x` guard broke. It asserted the defect — "would run the impostor if the preflight carried an unqualified command name", expecting the hijack marker to exist. The guard is a security improvement, so the test now asserts the contract: an unqualified preflight is skipped and the marker is never written. Rewritten to the new behavior, not loosened or deleted. 818 tests pass across the affected suites; typecheck clean. The changed-file quality gate could not run locally — its pnpm engine-warning JSON parser fails under Node 26 — so CI covers it. The boundary both reviews verified is untouched: paired/relay/mobile clients stay hard-blocked from the RPC, params remain shape-locked to the managed home suffix with traversal rejection, nothing is written outside the managed home, and macOS/Linux stay inert. * fix(codex): serialize resolved WSL hook homes * fix(codex): recover managed WSL homes after restart * fix(wsl): translate Codex preflight through WSLENV * fix(cli): cover bounded WSL Codex repair * fix(codex): coalesce duplicate WSL hook repairs * fix(codex): verify reconstructed WSL homes

Summary
CODEX_HOMEand matching distro./mnt/.../orca.exepath and carry it throughWSLENVwithout changing native behavior.Orca terminal boundary
Hooks remain scoped to Orca terminals: the PTY-scoped
CODEX_HOMEoverride is unchanged, and this does not install hooks into the user default home. If a mixed-version runtime does not expose the new optional RPC, or if repair otherwise fails, the wrapper fails open so Codex still launches.Claude does not share this reattach gap: relay re-ensure reinstalls its hook configuration, while Codex needed an explicit trust-repair lane before every typed launch.
Windows / WSL reproduction
Reproduced on the Windows high-spec host with Ubuntu 24.04. Before the fix, the pane used
/home/neil/.local/share/orca/codex-runtime-home/home; the managed hook files were present, but trust was absent and the in-guest CLI prepare path could not repair the WSL home.With this branch, the runtime-host repair returned
installedagainst the corresponding \wsl.localhost UNC config path, wrote all eight managed hook trust entries, and resolved the packaged launcher to/mnt/c/Users/neil/AppData/Local/Programs/orca/resources/bin/orca.exe. A direct WSL launch still completed successfully withcodex-cli 0.148.0in 18 ms.The regression tests reproduce the reattached typed-launch path, validate pane-home and distro matching, cover local-CLI-only RPC authorization and mixed-version failure-open behavior, and assert guest launcher propagation.
Verification
--config config/vitest.config.ts.pnpm tc:nodepassed on macOS and Windows.PATH=/opt/homebrew/opt/node@24/bin:$PATH pnpm run check:code-quality:changedpassed with zero findings.oxfmt, andgit diff --checkpassed.