Repository navigation
Conversation
Five decisions have to be made on each `wsl.exe` call. Each has a right answer,
each is invisible in a diff, and each has shipped wrong:
- **Separator.** `--` makes wsl.exe expand `$name` in every forwarded argument
before the guest runs -- even with no shell in the command -- so `awk
'{print $2}'` loses its field reference (#12964).
- **Shell.** A login shell on a probe path sources `~/.profile`, so one blocking
line eats the whole timeout (#14288) and every call pays startup (#9768). No
login shell on a user-facing path means PATH does not match the user's own
terminal, so nvm-installed agents read as absent (#9725, #7563, #8366).
- **Fencing.** An interactive login shell runs the distro rc, and stock Ubuntu
writes its "run as administrator" hint to *stdout* -- so anything parsing that
stream reads the banner as data (#11327, #11823).
- **WSLENV.** Unset, a Windows-side variable silently never crosses (#12557).
- **Payload.** Scripts go in on stdin. A script on stdin has no quoting boundary
to escape from, which is what the base64 and `eval` wrappers work around
(#14292). `filesystem-watcher-wsl.ts` already does this and is the only WSL
caller with no quoting bug in its history.
`runWslProcess` makes them once, on top of W1's `runProcess` so it inherits
windowsHide, shell:false, timeouts and abort. `lane` is required with no
default: picking the wrong lane by omission is the most common WSL defect here.
The probe lane resolves the login PATH/HOME once per distro and then runs with
no shell at all, so #14288 and #9768 are closed by construction rather than by a
longer timeout. An unprobed distro degrades to the interactive lane -- "we could
not ask" must not become "run with no PATH".
Additive only: no call site is migrated yet. The new guard allowlists the 23
files that still spawn directly, and its length is the workstream's goalpost.
Two guard bugs found by testing the guards against planted call sites: a bare
`main/wsl` prefix also exempted `main/wsl.ts`, `wsl-availability.ts` and
`wsl-unc-delete.ts` -- three real offenders.
These two sites make opposite mistakes, and neither is reviewable against the other: - `preflight-wsl-agent-detection.ts` ran `buildWslLoginShellCommand` -- the *uncaptured* variant -- and parsed stdout. An interactive login shell runs the distro rc, and stock Ubuntu writes its "run a command as administrator" hint to stdout, so detection was parsing a stream with a banner in front of it. - `skill-wsl-provider-detection.ts` ran a bare `sh -c` with no login shell at all, so a codex/claude installed through nvm or mise was never on PATH and read as absent. Both want the same thing: the user's real login PATH, without a shell in the loop. That is the probe lane -- the PATH comes from one cached login-shell probe per distro, and no shell runs on the call itself, so there is no banner to strip and no `~/.profile` to stall behind (#9725, #7563, #8366). Also removes the hand-rolled Promise.race timeout in the preflight file; `runProcess` already bounds the child and escalates to SIGKILL. Allowlist: 23 -> 21.
…wrappers Four skill sites spawned wsl.exe directly; two wrapped their payload in `buildEncodedWslBashCommand` -- base64, decoded in-guest, piped to a shell -- purely to get a multi-line script across the argv boundary intact. The runner delivers a script on stdin, which has no quoting boundary to escape from, so the wrapper has nothing left to solve. The trap in this migration is that `bash -c` and the runner's default `sh` are not the same interpreter. These scans use `set -o pipefail`, `read -r -d ''` and `done < <(find ...)` -- all bash-only -- and on Debian/Ubuntu `sh` is dash, which rejects each with `Syntax error: word unexpected`. That is the #14292 signature, and no unit test would have caught it, because the tests mock the runner and the one round-trip test invokes the script through `bash` directly. So scripts now declare their interpreter (`shell: 'sh' | 'bash'`, default `sh`), both bash payloads pin `bash`, and a guard fails any runner caller whose script uses bash-only syntax without saying so. The detector covers the constructs that look like ordinary shell -- `pipefail` and `read -d` -- not just the obvious ones; verified in both directions. Allowlist: 21 -> 17.
An independent review of the runner found two real defects and proved the goalpost was wrong. All verified before fixing. P1 -- `lane: 'interactive'` plus `script` ran with no login shell AND no cached environment. A script never rides the login shell (it owns stdin), so that combination fell into the shell-free branch while the environment was only fetched for `lane: 'probe'` -- giving a caller who explicitly asked for the user's terminal PATH strictly less than the probe lane would have. The cached environment is now fetched whenever there is a script, on either lane. P1 -- the guard missed the largest wsl.exe spawner in the tree. It only matched a named opener, so `git/runner.ts` (`binary: 'wsl.exe'`, spawned four lines later), locally-aliased callers (`run(`, `execFileUtf8(`) and `command:` fields were all invisible. The count was the goalpost, so the goalpost was wrong. The detector now accepts any identifier call and the assignment-style fields, and the five files that reach a spawn through a variable are recorded as a named blind spot rather than left implied. Also: - A missing fence now throws instead of returning `''`. `readStdout` returns null precisely to distinguish "no fence" from "empty payload", and collapsing them is the silent-wrong-answer shape this module exists to avoid. - A `program` containing `=` is rejected: after `env PATH=… HOME=…` it reads as a third assignment, so `env` prints the whole guest environment and exits 0. - An empty argv with a cwd is rejected: `exec` with no operands is a no-op, so the wrapper would cd and exit 0 having run nothing. - The sentinel assertion could not fail (`offenders + allowlist >= 20` with a 23-entry allowlist); it now names a call site that is definitely there.
`wsl-cli-installer.ts` probed on `bash -lc` purely to get a real PATH for its interop checks, which is the direct cause of the 10s timeout behind a blocking `~/.profile` (#14288). The probe lane gives it the same login PATH from one cached probe instead of paying `~/.profile` on every call. `hooks.ts` ran `bash -c` with hand-rolled single-quote escaping; the script now travels on stdin, so there is no quoting boundary left to get wrong. `set -euo pipefail` became `set -eu` in the two transported scripts. That is a semantic change, so it was checked rather than assumed: neither script contains a pipe, and dash -- which is `sh` on Debian/Ubuntu -- has no `pipefail` option at all, so keeping it would have failed the script outright. Deliberately not migrated, with reasons recorded rather than skipped: - `wsl-availability.ts` and `wsl.ts` invoke host-level flags (`--status`, `--list --quiet`). The runner always prepends `--exec`, so a flag-only invocation cannot be expressed through its API at all. - `wsl.ts`'s `getWslHome`/`wslUncDirectoryExists` are synchronous and called synchronously from six production files. The runner is Promise-only, so migrating them means a sync-to-async cascade well outside this scope -- and they share caches with their async twins, so migrating half would split one contract across two transports. Allowlist: 23 -> 21.
Three independent reviews (Opus, Grok, GPT) converged on the same release blocker and several reliability defects. P0 -- WSL hooks silently ran user scripts under dash. `hooks.ts` passed a script with no `shell`, which defaults to `sh`; the native path pins `/bin/bash` and docs/reference/windows-setup-shell.md guarantees bash on every platform. Any `orca.yaml` hook using `[[ ]]`, arrays, `local` or `source` broke on WSL only. The bashism guard cannot see this -- the payload is user data, not caller source -- so the fix is `shell: 'bash'` plus this note. P1 -- a rejected probe poisoned the cache for the process lifetime. `runProcess` rejects when the child cannot start, and the uncaught rejection stayed in `inFlight`, so every WSL feature threw until restart. Now classified transient. P1 -- three skill sites dropped their exit-code checks. `runProcess` resolves on a non-zero exit, so a scan killed at its 10s timeout returned partial stdout that parsed into a valid "zero skills" result -- which reads as "nothing is installed" and re-offers installs for skills that are present. P1 -- probe failure used to fall back to the login shell, which sources `~/.profile`: the stall this runner exists to remove, reintroduced exactly when the distro is slowest. It now runs shell-free and reports `environmentResolved: false`, and agent detection treats that as unknown rather than absent -- reporting an nvm-installed agent absent is #9725. Elegance: four byte-identical POSIX quote helpers collapsed to one; the dead `addWorktreeSetupWslInteropEnv` and the speculative `signal` option removed; the guard scanners share one walker; comments cut to AGENTS.md density.
Three reviews found the same class of defect three different ways: a call that answers "is this installed?" running on the bare default PATH and reporting an nvm-installed tool absent (#9725). Each time the fix was to check a flag at the call site -- and 3 of 8 sites had already forgotten the analogous exit-code check, so that approach was not going to hold. The runner now throws when the login PATH cannot be established. A caller that genuinely tolerates a degraded PATH says `allowDegradedEnvironment: true`, which puts the decision in the one place a reader looks instead of in every caller's memory. No production caller needs it today. Also: the probe no longer runs on its own 10s timer ahead of the caller's budget. A 5s caller could reach `runProcess` with 1ms left and report a timeout for a command that would have taken milliseconds; the probe now gets two thirds of the remaining budget and the command keeps the rest. And `invalidateWslGuestEnvironment` finally has a production caller: Refresh in the Agents pane. Its whole purpose is "installed a new CLI, Orca doesn't see it yet", which could not work while the guest PATH stayed cached for the process lifetime.
Migrating them onto the runner removed their direct child_process import, so the W1 ratchet reports them stale. Second goalpost moving as a consequence of the first: 163 -> 156.
This was referenced Aug 22, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Stacked on #15903 (the runner). This is every call-site migration plus the fixes from three rounds of adversarial review, collapsed into one branch so it can be green on its own.
Supersedes #15907, #15910, #15911 — same content, one reviewable unit. Read it by commit; each is self-contained.
ELI5
Nine places that talked to WSL their own way now call one function. Along the way, reviewers found that hooks had quietly switched to the wrong shell and that several failure paths answered "nothing found" when the honest answer was "couldn't check". Both fixed.
What moves
21 sites across 15 files. Allowlist 23 → 16 on the WSL guard; 163 → 152 on the W1
child_processguard, which moved as a consequence — the shape you want.preflight-wsl-agent-detection.tsskill-wsl-provider-detection.tssh -c, no login PATHskills/*shelldeclaredhooks.tsbash -c+ hand-rolled quotingshell: 'bash'cli/wsl-cli-installer.tsbash -lcper call (#14288)claude-accounts× 2,codex-accounts× 2bash -lcshell: 'bash'execFileThe two findings worth your attention
P0 — hooks ran user scripts under dash.
hooks.tspassed a script with noshell, which defaults tosh. The native path pins/bin/bashanddocs/reference/windows-setup-shell.mdguarantees bash everywhere. Anyorca.yamlhook using[[ ]], arrays,localorsourceworked on macOS and broke on WSL only. The bashism guard cannot catch this — it scans caller source, and a hook script is user data.Design change — a degraded PATH refuses instead of answering. Three reviews found the same defect three ways: a call answering "is this installed?" on the bare default PATH, reporting an nvm-installed tool absent (#9725). Each fix was "check a flag at the call site", and 3 of 8 sites had already forgotten the analogous exit-code check. The runner now throws;
allowDegradedEnvironment: trueopts in. No production caller needs it.Proof of no regression
transcript-watch-liveness.test.ts, passes in isolation and is a pre-existing load flake in untouched code.result.code !== 0 || result.timedOut—runProcessresolves on a non-zero exit, so a timed-out scan previously parsed partial stdout into a valid "zero skills" result.bash, enforced by a guard covering the constructs that look like ordinary shell (pipefail,read -d), verified in both directions.User-facing trade-offs
invalidateWslGuestEnvironmentpreviously had no production caller, so Refresh could never see a newly installed CLI).No other behaviour changes.
Four review rounds
Each round found real defects, several introduced by the previous round's fixes. Rounds 1–3 are closed and re-verified; round 4 is running.
The recurring theme — a call answering "is this installed?" on a degraded PATH — was eventually fixed structurally: the runner refuses an unresolved guest PATH unless the caller opts in. Per-call-site vigilance demonstrably wasn't holding; 3 of 8 sites had already forgotten the analogous exit-code check.
Not in scope
16 files still spawn
wsl.exedirectly, each needing a runner mode that doesn't exist:ChildProcess, stream stdout to detect auth patterns, hold stdin open for the callback server, and tree-kill on cancel. The runner is run-to-completion.codex-accounts' constructor seeds managed-home config on the same tick as startup. The agent measured this rather than assuming: deferring it to a microtask fails four startup tests, so the cascade is real.--status,--list --quietquery the hypervisor, not a guest; the runner always prepends--exec.