Skip to content

fix(codex): heal WSL hooks before typed launches - #16535

Merged
brennanb2025 merged 10 commits into
mainfrom
brennanb2025/wsl-codex-hooks
Aug 27, 2026
Merged

brennanb2025 merged 10 commits into
mainfrom
brennanb2025/wsl-codex-hooks

Conversation

@brennanb2025

@brennanb2025 brennanb2025 commented Aug 26, 2026 •

Copy link
Copy Markdown
Contributor
Files Added Deleted Net
Test 18 $\color{#1a7f37}{\Huge{\mathbf{+}}}$​552 $\color{#cf222e}{\Huge{\mathbf{−}}}$​29 $\color{#1a7f37}{\Huge{\mathbf{+}}}$​523
Prod 13 $\color{#1a7f37}{\Huge{\mathbf{+}}}$​365 $\color{#cf222e}{\Huge{\mathbf{−}}}$​25 $\color{#1a7f37}{\Huge{\mathbf{+}}}$​340

Summary

  • Heal managed Codex hooks immediately before typed Codex launches in WSL panes, including reattached panes.
  • Route WSL repair through the authoritative Windows runtime RPC, targeting the pane-scoped CODEX_HOME and matching distro.
  • Translate the verified bundled launcher to a guest-absolute /mnt/.../orca.exe path and carry it through WSLENV without changing native behavior.

Orca terminal boundary

Hooks remain scoped to Orca terminals: the PTY-scoped CODEX_HOME override 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 installed against 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 with codex-cli 0.148.0 in 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

  • Windows focused Vitest: 6 files passed, 70 tests passed, 19 skipped, using --config config/vitest.config.ts.
  • pnpm tc:node passed on macOS and Windows.
  • PATH=/opt/homebrew/opt/node@24/bin:$PATH pnpm run check:code-quality:changed passed with zero findings.
  • Focused local Vitest, oxfmt, and git diff --check passed.

@coderabbitai

coderabbitai Bot commented Aug 26, 2026 •

Copy link
Copy Markdown
Contributor

Review Change Stack

Note

Reviews paused

It 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 reviews.auto_review.auto_pause_after_reviewed_commits setting.

Use the following commands to manage reviews:

  • @coderabbitai resume to resume automatic reviews.
  • @coderabbitai review to trigger a single review.

Use the checkboxes below for quick actions:

  • ▶️ Resume reviews
  • 🔍 Trigger review

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: Repository UI

Review profile: CHILL

Plan: Pro Plus

Run ID: ec77c127-9a2d-4b11-8291-bea6672afe16

📥 Commits

Reviewing files that changed from the base of the PR and between 9062494 and 2817a7f.

📒 Files selected for processing (28)
  • config/tsconfig.cli.json
  • src/cli/handlers/agent-hooks.test.ts
  • src/cli/handlers/agent-hooks.ts
  • src/main/__fixtures__/shell-wrapper-snapshots/daemon-bash-rcfile.txt
  • src/main/__fixtures__/shell-wrapper-snapshots/daemon-fish-init.txt
  • src/main/__fixtures__/shell-wrapper-snapshots/daemon-zsh-zshenv.txt
  • src/main/__fixtures__/shell-wrapper-snapshots/local-bash-rcfile.txt
  • src/main/__fixtures__/shell-wrapper-snapshots/local-fish-init.txt
  • src/main/__fixtures__/shell-wrapper-snapshots/local-zsh-zshenv.txt
  • src/main/agent-hooks/remote-hook-service-installers.test.ts
  • src/main/agent-hooks/wsl-hook-fs-adapter.ts
  • src/main/agent-hooks/wsl-hook-relay-deps.ts
  • src/main/agent-hooks/wsl-hook-relay-guest-install.ts
  • src/main/agent-hooks/wsl-hook-relay-live.integration.test.ts
  • src/main/agent-hooks/wsl-hook-relay-manager.test.ts
  • src/main/codex/codex-trust-config-mutation-queue.test.ts
  • src/main/codex/hook-service-wsl-runtime.test.ts
  • src/main/codex/hook-service.ts
  • src/main/codex/managed-home-shell-preflight.test.ts
  • src/main/codex/managed-home-shell-preflight.ts
  • src/main/pty/codex-preflight-profile-path-rewrite.test.ts
  • src/main/pty/codex-shell-launch-preflight.test.ts
  • src/main/pty/codex-shell-launch-preflight.ts
  • src/main/pty/wsl-orca-env.test.ts
  • src/main/pty/wsl-orca-env.ts
  • src/main/runtime/rpc/methods/agent-hooks.test.ts
  • src/main/runtime/rpc/methods/agent-hooks.ts
  • src/main/runtime/rpc/methods/index.ts
🚧 Files skipped from review as they are similar to previous changes (22)
  • src/main/agent-hooks/wsl-hook-relay-guest-install.ts
  • src/main/fixtures/shell-wrapper-snapshots/local-fish-init.txt
  • src/main/fixtures/shell-wrapper-snapshots/daemon-fish-init.txt
  • src/main/pty/wsl-orca-env.ts
  • src/main/runtime/rpc/methods/agent-hooks.test.ts
  • src/main/fixtures/shell-wrapper-snapshots/local-bash-rcfile.txt
  • src/cli/handlers/agent-hooks.ts
  • src/main/pty/codex-shell-launch-preflight.test.ts
  • src/main/fixtures/shell-wrapper-snapshots/daemon-bash-rcfile.txt
  • src/main/pty/wsl-orca-env.test.ts
  • src/main/fixtures/shell-wrapper-snapshots/daemon-zsh-zshenv.txt
  • src/main/fixtures/shell-wrapper-snapshots/local-zsh-zshenv.txt
  • src/main/runtime/rpc/methods/agent-hooks.ts
  • src/main/runtime/rpc/methods/index.ts
  • config/tsconfig.cli.json
  • src/main/agent-hooks/wsl-hook-relay-deps.ts
  • src/main/pty/codex-shell-launch-preflight.ts
  • src/main/agent-hooks/wsl-hook-relay-live.integration.test.ts
  • src/cli/handlers/agent-hooks.test.ts
  • src/main/agent-hooks/remote-hook-service-installers.test.ts
  • src/main/codex/managed-home-shell-preflight.test.ts
  • src/main/agent-hooks/wsl-hook-relay-manager.test.ts

Included review availability: Your plan provides up to 10 included reviews per hour; 3 remain after this review.


📝 Walkthrough

Walkthrough

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

Check name Status Explanation Resolution
Description check ⚠️ Warning 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 … 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…
Docstring Coverage ⚠️ Warning 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:… 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 summarizes the primary change: repairing Codex hooks before typed launches in WSL.
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: Description check

Explanation

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 Coverage

Explanation

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 💡
  • 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: 1


ℹ️ Review info
⚙️ Run configuration

Configuration used: Repository UI

Review profile: CHILL

Plan: Pro Plus

Run ID: 90089436-88a0-44cc-b452-f9c3835545eb

📥 Commits

Reviewing files that changed from the base of the PR and between 5a8b4af and 448e45f.

📒 Files selected for processing (17)
  • src/cli/handlers/agent-hooks.test.ts
  • src/cli/handlers/agent-hooks.ts
  • src/main/__fixtures__/shell-wrapper-snapshots/daemon-bash-rcfile.txt
  • src/main/__fixtures__/shell-wrapper-snapshots/daemon-fish-init.txt
  • src/main/__fixtures__/shell-wrapper-snapshots/daemon-zsh-zshenv.txt
  • src/main/__fixtures__/shell-wrapper-snapshots/local-bash-rcfile.txt
  • src/main/__fixtures__/shell-wrapper-snapshots/local-fish-init.txt
  • src/main/__fixtures__/shell-wrapper-snapshots/local-zsh-zshenv.txt
  • src/main/codex/managed-home-shell-preflight.test.ts
  • src/main/codex/managed-home-shell-preflight.ts
  • src/main/pty/codex-shell-launch-preflight.test.ts
  • src/main/pty/codex-shell-launch-preflight.ts
  • src/main/pty/wsl-orca-env.test.ts
  • src/main/pty/wsl-orca-env.ts
  • src/main/runtime/rpc/methods/agent-hooks.test.ts
  • src/main/runtime/rpc/methods/agent-hooks.ts
  • src/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'

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

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

@brennanb2025
brennanb2025 force-pushed the brennanb2025/wsl-codex-hooks branch from ddfe391 to 307ca37 Compare August 26, 2026 21:48
@coderabbitai

coderabbitai Bot commented Aug 26, 2026

Copy link
Copy Markdown
Contributor

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.

@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: 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.ts
  • src/main/agent-hooks/wsl-hook-fs-adapter.ts
  • src/main/agent-hooks/wsl-hook-relay-deps.ts
  • src/main/agent-hooks/wsl-hook-relay-guest-install.ts
  • src/main/agent-hooks/wsl-hook-relay-live.integration.test.ts
  • src/main/agent-hooks/wsl-hook-relay-manager.test.ts
  • src/main/codex/hook-service-wsl-runtime.test.ts
  • src/main/codex/hook-service.ts
  • src/main/codex/managed-home-shell-preflight.ts
  • src/main/pty/codex-preflight-profile-path-rewrite.test.ts
  • src/main/runtime/rpc/methods/agent-hooks.test.ts
  • src/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.

@brennanb2025
brennanb2025 force-pushed the brennanb2025/wsl-codex-hooks branch from bc560db to 2817a7f Compare August 27, 2026 07:11
@coderabbitai

coderabbitai Bot commented Aug 27, 2026

Copy link
Copy Markdown
Contributor

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.

@brennanb2025
brennanb2025 force-pushed the brennanb2025/wsl-codex-hooks branch 2 times, most recently from e526add to 04cbb2c Compare August 27, 2026 18:10
`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.
@brennanb2025
brennanb2025 force-pushed the brennanb2025/wsl-codex-hooks branch from e341dd2 to 99a687d Compare August 27, 2026 18:37
@brennanb2025

brennanb2025 commented Aug 27, 2026 •

Copy link
Copy Markdown
Contributor Author

Codex review loop — status

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

Windows WSL typed Codex QA

Final readiness checklist: CLEAN/READY.

@brennanb2025

Copy link
Copy Markdown
Contributor Author

Merge-risk answers

Three questions came up before merging: cross-platform regression risk, whether this depends on Orca's agent launcher, and whether it survives the upcoming codex_home mirror deletion. Answers below, each verified against 99a687d6bd rather than taken from the review summary.

Does typing codex still work, or does this need our launcher?

It works precisely for the typed case, and the launcher is never consulted.

The mechanism is a shell function installed into the pane's own init:

function codex {
  "${ORCA_CODEX_LAUNCH_PREFLIGHT}" agent hooks prepare-codex >/dev/null 2>&1 || :
  command codex "$@"
}

Type codex, the heal runs, then the real binary launches. launchAgent is not read anywhere in the preflight — grepping it for launchAgent, launchToken, and agentLaunch returns nothing.

The gate is "is this an Orca pane" (ORCA_CODEX_LAUNCH_PREFLIGHT is only set on Orca-spawned PTYs), not "did Orca launch the agent." In a terminal outside Orca the variable is absent, the function is never defined, and no hooks fire — which is the boundary this has to keep.

Three details worth noting: unalias codex inside the substitution (an alias would break command -v detection), || : on the assignment (an absent codex would otherwise trip set -e in bash), and command codex "$@" so the function cannot recurse into itself.

Cross-platform regression risk

31 files, but only two changes are reachable outside WSL. Everything else is wsl-*, managed-wsl-*, a new RPC method, or tests.

1. The shell wrapper guard — this does run on every macOS/Linux pane:

- if [[ -n "$ORCA_CODEX_LAUNCH_PREFLIGHT" && -n "$__orca_codex_binary" && -x "$__orca_codex_binary" ]]
+ if [[ -n "$ORCA_CODEX_LAUNCH_PREFLIGHT" && -x "$ORCA_CODEX_LAUNCH_PREFLIGHT" && -n "$__orca_codex_binary" && -x "$__orca_codex_binary" ]]

One added conjunct: the preflight path must be executable. Strictly narrowing — it can only cause the preflight to be skipped, never to run where it previously didn't. When skipped, the wrapper still launches codex normally: fail-open on the heal, never on the launch.

The skip path is itself the security fix. The pin test that changed here previously asserted the defect ("would run the impostor if the preflight carried an unqualified command name", expecting the hijack marker to exist); it now asserts the marker is never written, so an unqualified preflight can no longer be hijacked through a profile PATH entry. The test was rewritten to the new contract, not loosened.

2. host-env/assembly.ts — runs on every spawn, but the change is one extra argument:

- wslHookRelayManager.ensureForDistro(distro)
+ wslHookRelayManager.ensureForDistro(distro, opts.selectedCodexHomePath)

That call sits inside the WSL branch; on macOS and Linux there is no distro and the line is not reached.

Does it survive the codex_home mirror deletion?

Yes. wslCodexRuntimeHomeForGuestHome — which the re-land removes — has no callers on this branch; the only hit is its own definition. The convergence was reshaped to key on the runtime home each lane resolves to rather than on mirror path shapes (e526add492).

The config/tsconfig.cli.json entry for codex-home-wsl-env.ts is also gone. It existed only because managed-home-shell-preflight.ts imported that helper and the CLI project failed TS6307 without it; the reshape dropped the import, so the entry went with it rather than being left as a stale line to trip over during the re-land.

Two things this PR adds that outlive the mirror, and that do not exist on main today: relay Codex installs delegating to the runtime-home writer (one canonical representation), and per-home write serialization reusing main's existing async per-config write queue.

Verified

  • 53 CI checks green, including Linux and Windows packaging and both Node matrices
  • Exact-head Windows/WSL Electron QA, with a screenshot showing rendered hook-origin Codex identity after an unchanged typed launch
  • Outside-Orca isolation re-verified after the rebase: paired/relay/mobile clients hard-blocked from the new RPC, params shape-locked to the managed home suffix with traversal rejection, nothing written outside the managed home

Not verified

  • No live macOS or Linux Electron run. Inertness on those platforms is argued from code paths and CI, not from a booted app. Proportionate given the only cross-platform surface is a narrowing shell conjunct — but it is an inference, not a measurement.
  • No hostile-symlink race exercised.
  • The process table still reads wsl.exe at the WSL boundary. Expected, and the reason hook-sourced identity matters there.

Assessment: low risk. The single change touching macOS and Linux makes a security check stricter and can only skip work.

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

1 participant