Skip to content

test(e2e): on the real WSL lane, background work never starts the stopped distro (E9 guard) - #35590

Merged
nwparker merged 12 commits into
mainfrom
nwparker/e9-wsl-bridge-guard
Oct 29, 2026
Merged

nwparker merged 12 commits into
mainfrom
nwparker/e9-wsl-bridge-guard

Conversation

@nwparker

@nwparker nwparker commented Oct 29, 2026 •

Copy link
Copy Markdown
Contributor
Files Added Deleted Net
Test 8 $\color{#1a7f37}{\Huge{\mathbf{+}}}$​789 $\color{#cf222e}{\Huge{\mathbf{−}}}$​2 $\color{#1a7f37}{\Huge{\mathbf{+}}}$​787
Prod 6 $\color{#1a7f37}{\Huge{\mathbf{+}}}$​96 $\color{#cf222e}{\Huge{\mathbf{−}}}$​3 $\color{#1a7f37}{\Huge{\mathbf{+}}}$​93

ELI5

Most of today's "never start a stopped WSL distro" fixes protect ordinary users (WSL hosts flag off). Those code paths only exist on Windows. This adds a test to the Windows CI job that already has a real WSL distro:

  • it opens a project inside that distro, then stops the distro;
  • it keeps Orca busy with everyday background work for a while;
  • it checks nothing started the distro back up;
  • it opens a terminal there and checks that this does start it.

What Changed

  • New tests/e2e/wsl-bridge-no-background-boot.spec.ts. It runs only when ORCA_E2E_WSL_TERMINATE_DISTRO names a distro the run owns, because it terminates that distro. Otherwise it skips, so it never touches a developer's own distros.
  • Setup: the test creates a git repo inside the lane's Ubuntu and adds it as a project (\\wsl.localhost\Ubuntu\...) with a linked issue and PR. It opens that workspace, then switches to the local test workspace.
  • Watching for launches: the test records every child process the Orca main process starts. It does this by wrapping ChildProcess#spawn, which every spawn, exec and execFile call goes through; terminal processes don't, and don't need to.
  • The background window: the test runs wsl --terminate Ubuntu, waits until wsl --list --running no longer shows it, then for two rounds plus 15 s of real time does the following:
    • window focus, blur and reveal events;
    • switching between the local workspace and none;
    • eight Settings panes plus the WSL project's settings;
    • the Tasks page;
    • Codex and Claude account switches.
  • Assertions:
    • no wsl.exe launch ran anything in Ubuntu (-d Ubuntu, or --exec/-e with no distro named). Listings such as --list are allowed;
    • wsl --list --running, checked every second through the whole window, never showed Ubuntu. This also catches a \\wsl.localhost file touch or a Git call with a UNC working directory, which start the distro without any wsl.exe launch;
    • the distro is still stopped at the end.
  • Then the user act: the test activates the WSL workspace and opens a New Terminal, and expects Ubuntu to be running.
  • Lane wiring (windows-wsl-e2e.yml): a new step runs the guard 3 times with ORCA_E2E_WSL_TERMINATE_DISTRO: Ubuntu, the distro this job imports. A new participation check (verify-wsl-no-background-boot-participation.mjs) fails the job if the guard skipped instead of running.
  • PR routing sends changes to this spec or the participation check to the WSL lane. The lane contract test covers the new step.

Why

Each E9 fix guarded one caller. This guards the rule for the flag-off code paths: any future background caller that forgets the gate will start the distro, and the lane will fail. Watching the running list is the ground truth. Logging launches tells you which caller did it.

I used neither a PATH shim nor a wsl.exe path override. Most callers start the absolute System32 wsl.exe, so a shim ahead of it on PATH would miss them. File touches and Git need no wsl.exe at all. Only the running list sees every route.

Linked Issue

Internal E9 guard. No public issue.

Visual Proof

N/A. The change is test and CI only. The spec saves screenshots of the background window and of the terminal opened afterwards.

Testing

  • This PR's own "real WSL terminal" lane runs the new step. It is the only place the guard can execute, and it may show a background caller the gate still misses. Any such hit is a real E9 bug to fix, not test noise.

  • Locally (macOS) the spec skips as expected. The child-process recorder was verified locally with a throwaway spec: it saw the main process's gh and git spawns.

  • The lane contract and participation unit tests pass (22).

  • Load rule: pnpm tc, check:code-quality:changed, anti-slop, the ast-grep gates and the e2e typecheck ratchet pass. typecheck:e2e reports no errors under tests/.

  • I manually tested these changes locally

  • Automated tests added/updated, or explained why not below

Review

Flag-off: this is the flag-off (bridge) path: the WSL hosts flag is unset. No product code changes.

User-risk: none (test and CI only). The lane job gets about 3 runs × ~2 min longer.

Agent skill upstream boundary

  • Not applicable, or this change copies or mechanically translates no upstream skill-installer source, tests, fixtures, registry entries, path tables, comments, or documentation.

Status

Ready for review. The lane result is pending.

Checklist

  • This PR is small and focused
  • I explained what changed and why (ELI5, the user-facing before/after, the mechanism, and why over the alternatives)
  • Before/after screenshots or videos attached for UI changes, or N/A with reason
  • Self-reviewed for correctness, security, and performance
  • Cross-platform, SSH/remote, and path/shortcut impact considered (or N/A)
  • pnpm lint, pnpm typecheck, pnpm test, and pnpm build pass (or CI will cover; local preferred)

@coderabbitai

coderabbitai Bot commented Oct 29, 2026 •

Copy link
Copy Markdown
Contributor

Review in Change Stack →

Walkthrough

The changes add optional process spawn logging and startup handling for its environment setting. A Windows-only WSL E2E test checks whether background activity starts a terminated distro, then verifies that opening a terminal starts it. The Windows WSL workflow runs the test three times and verifies participation through its JSON report.

Priority: Normal

Merge Risk: Low · up to e2455

The Windows guard can miss a brief background restart caused by UNC filesystem access. Include target-distro UNC records in the assertion before relying on the test.

Pre-merge checks: Passed 3 · Failed 2

Failed Failed checks: 2 warnings

Check name Status Explanation Resolution
Description check Warning The description explains the purpose, behavior, implementation, testing, CI wiring, risks, and checklist status. However, the Linked Issue section does not provide an actual issue reference, and the r… Add the applicable issue link under Linked Issue. Add the AI Disclosure section and state the AI usage details, or state that it is not applicable if the contributor is an internal maintainer.
Docstring Coverage Warning Docstring coverage is 30.00% which is insufficient. The required threshold is 80.00%. Docstring coverage is scoped to functions touched by this diff with cyclomatic complexity of at least 2. Documenta… Write docstrings for the functions missing them to satisfy the coverage threshold.
Passed Passed checks: 3 passed
Check name Status Explanation
Title check Passed The title clearly identifies the main change: an end-to-end guard that verifies background work does not restart a stopped WSL distro on the real WSL lane.
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 purpose, behavior, implementation, testing, CI wiring, risks, and checklist status. However, the Linked Issue section does not provide an actual issue reference, and the required AI Disclosure section is omitted.

Resolution

Add the applicable issue link under Linked Issue. Add the AI Disclosure section and state the AI usage details, or state that it is not applicable if the contributor is an internal maintainer.

Full details: Docstring Coverage

Explanation

Docstring coverage is 30.00% which is insufficient. The required threshold is 80.00%. Docstring coverage is scoped to functions touched by this diff with cyclomatic complexity of at least 2. Documentation-only edits and deletions within surviving functions are included; unchanged diff context and fully deleted functions are excluded. Analyzed 10 functions across 13 files.

Resolution

Write docstrings for the functions missing them to satisfy the coverage threshold.

Finishing Touches: 💡 1
📝 Generate docstrings: 💡
  • Commit to this branch
  • Create a new PR
  • Autofix · Keep fixing CodeRabbit findings and required CI, and resolving merge conflicts

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.

@greptile-apps

greptile-apps Bot commented Oct 29, 2026 •

Copy link
Copy Markdown

RetriggerView in GreptileConfidence Score: 5/5

[Low impact] The PR appears safe to merge, with two existing non-blocking coverage gaps.

Findings

  1. P2 WSL account homes stay untested ▶
  2. P2 Helper changes skip the guard ▶

Summary

Adds a real-WSL check that background work leaves a stopped distro stopped, while opening a terminal starts it.

  • Background activity leaves a stopped WSL distro off until someone opens a terminal.
  • E2e runs record process launches and WSL file touches with caller details.
  • The Windows WSL lane runs both background-boot guards three times.

Four earlier threads were manually resolved without explanatory replies. Their current code opens Settings, distinguishes listing errors, preserves the log’s parent directory, and confirms a stopped baseline before counting restarts.

Reviews (13) · Last reviewed commit: "test(e2e): give the focused-idle guard's..." · Reviewed by Greptile

Comment on lines +205 to +207
// Account switches re-sync every account home, including WSL ones.
await window.api.codexAccounts.select({ accountId: null }).catch(() => {})
await window.api.claudeAccounts.select({ accountId: null }).catch(() => {})

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P2 WSL account homes stay untested

The fresh profile has no managed accounts and defaults to the Windows host. Selecting accountId: null without a target uses that host path, and safeSyncToManagedHomes() has no accounts to visit. These switches therefore do not test the WSL home checks described here. Seed a WSL managed account before stopping the distro so the switches exercise those checks.

@nwparker
nwparker force-pushed the nwparker/e9-wsl-bridge-guard branch 3 times, most recently from 0b3adb7 to 0be3fce Compare October 29, 2026 06:13
@nwparker
nwparker force-pushed the nwparker/e9-wsl-bridge-guard branch from 0be3fce to dcb3ae2 Compare October 29, 2026 07:37
matches: (file) =>
isProductSource(file) &&
/^(?:config\/scripts\/(?:verify-wsl-e2e-participation|verify-playwright-participation)\.mjs$|src\/main\/(?:wsl[/-]|pty\/.*wsl|providers\/wsl)|src\/shared\/(?:wsl-|windows-terminal-shell|shell-argument-quoting)|src\/renderer\/src\/.*(?:terminal-paste|pty-paste)|tests\/e2e\/(?:golden-tab-bar-agent-launch\.spec|terminal-windows-shell-paste-ownership\.spec|terminal-inline-images-windows\.spec|helpers\/(?:wsl-golden-stub-agent|golden-stub-agent))|\.github\/(?:actions\/setup-wsl-test-runtime\/|workflows\/windows-wsl-e2e\.yml))/.test(
/^(?:config\/scripts\/(?:verify-wsl-e2e-participation|verify-wsl-no-background-boot-participation|verify-playwright-participation)\.mjs$|src\/main\/(?:wsl[/-]|pty\/.*wsl|providers\/wsl)|src\/shared\/(?:wsl-|windows-terminal-shell|shell-argument-quoting)|src\/renderer\/src\/.*(?:terminal-paste|pty-paste)|tests\/e2e\/(?:golden-tab-bar-agent-launch\.spec|terminal-windows-shell-paste-ownership\.spec|terminal-inline-images-windows\.spec|wsl-bridge-no-background-boot\.spec|helpers\/(?:wsl-golden-stub-agent|golden-stub-agent))|\.github\/(?:actions\/setup-wsl-test-runtime\/|workflows\/windows-wsl-e2e\.yml))/.test(

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P2 Helper changes skip the guard

The route includes the new spec and participation checker, but omits tests/e2e/helpers/wsl-boot-diagnostics-log.ts and src/main/startup/e2e-spawn-log-env.ts. A later PR changing only either helper will skip the only lane that can run this guard, so changes that break it can go unchecked on Windows. Add both paths to the route and its contract test.

Note: If this suggestion doesn't match your team's coding style, reply to this and let me know. I'll remember it for next time!

…pped distro (E9 guard)

The Windows real-WSL lane opens a project inside its own imported distro, terminates that distro,
and runs a window of background work elsewhere (focus/blur/reveal, workspace switches, a linked
issue/PR card, Settings panes, Tasks, account switches). Every child the main process starts is
logged; no wsl.exe may run anything in the distro (listings are fine), and `wsl --list --running`,
watched each second, must never show it, which also catches UNC touches. Opening a terminal in the
WSL workspace then starts it. A participation check fails the lane if the guard skipped.
…ckground window

openSettingsTarget alone only set the navigation target, so no pane mounted and none of its reads
(servers, accounts, agents, integrations, CLI status, the repo pane's orca.yaml check) ran. Open
Settings, wait for each pane's section to mount, then close it.
- process-host logs every spawn to ORCA_E2E_SPAWN_LOG when set, so the guard sees worker-thread
  and inheriting-child spawns (e.g. the Codex rate-limit fetch), sync ones included.
- The spawn baseline is taken before `wsl --terminate`, and the running-list watcher starts right
  after it, so work in the stopping window counts.
- A wsl.exe launch counts as starting the distro unless it names another or only lists/terminates.
- The watcher is async with a 5 s timeout and non-overlapping ticks; a failed read is retried and
  fails the guard after three, never reads as "stopped". The recorder throws if it cannot hook,
  and the spawn log must be non-empty. The doc names the watcher as the authoritative assertion.
…ed runs, tolerate torn lines

- The watcher forgives running reads only within 3 s of `--terminate` and before its first
  not-running read, which the rounds now await; any running read after it fails the guard.
- Main drops ORCA_E2E_SPAWN_LOG outside e2e mode (no ORCA_E2E_USER_DATA_DIR) before anything
  spawns, so no daemon, PTY or agent inherits it; the log holds full argv, tests only.
- readSpawnLog skips a line torn by a concurrent append.
…line for failures

The first lane run was cancelled at the 30-minute job limit while the guard step had run 25
minutes: past three 5-minute test timeouts, which only a blocked worker survives. Every wsl.exe
call (setup, terminate, cleanup) is now async with a timeout, so a hung one fails the test. The
guard logs a timestamped timeline (each running-list read, terminate, rounds) for diagnosis, and
the job limit goes to 50 minutes for the three added runs.
…terminate; 10 s grace

The lane run failed with "Ubuntu was still listed 3000 ms after --terminate" in all three runs.
The timeline showed why: focusing the WSL workspace in setup is a user act that opens a WSL
terminal, and its launch (codex trust probe, PTY, hook relay) landed about a second after the
terminate and restarted the distro. Setup now waits for that terminal's PTY and for wsl.exe
launches to go quiet for 3 s before terminating. The grace is two running-list reads (10 s).
The lane saw the distro boot about two seconds after the terminate with nothing naming the
launcher; each running-list tick now also prints the wsl.exe launches logged since the last one.
The E9 guard printed spawns at its poll time, up to a second late, and with
no caller. Each record now carries when it happened and the caller's stack,
and main's fs touches of \\wsl.localhost paths are logged too, so a boot
with no wsl.exe launch before it can still be attributed.
…mode

process-host now writes the spawn log, and captures caller stacks, only when
ORCA_E2E_USER_DATA_DIR is set as well, so a stray log variable in a CLI or
daemon environment does nothing. The main-process fs/spawn hook refuses to
install outside an e2e-mode app, and a source scan pins that no shipped code
imports or installs it.
Device runs saw a stopped distro restart with its bridge workspace focused
and nothing touched: the stop's own fallout re-ran renderer reads as user
acts. The new case keeps that workspace focused with a folder expanded in
the Explorer and Source Control shown, terminates, and idles. Shared guard
helpers move to tests/e2e/helpers/wsl-boot-guard.ts.
@nwparker
nwparker force-pushed the nwparker/e9-wsl-bridge-guard branch from b2ed728 to e24555d Compare October 29, 2026 12:40

@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
  • Source mode: Auto
  • Repository: Unavailable
  • Branch: Unavailable
  • File: No configuration file from this repository applied
  • Commit: Unavailable
  • Layers: Repository UI
  • Review profile: CHILL
  • Plan: Advanced
  • Run ID: 2fd80a2a-7824-41df-9263-29317015dc67
Commits

Reviewing files that changed from the base of the PR and between 74fe074 and e24555d.

Files selected for processing: 4
  • src/main/index.ts
  • src/packages/process-host/src/spawn-observer.ts
  • tests/e2e/helpers/wsl-boot-diagnostics-log.ts
  • tests/e2e/wsl-bridge-no-background-boot.spec.ts

Included review availability: This review used your included allowance. Your plan provides up to 10 included reviews per hour; 1 remain after this review.

Comment on lines +135 to +137
const background = readDiagnosticLog(SPAWN_LOG).slice(spawnsBefore)
expect(background.length).toBeGreaterThan(0)
expect(background.filter((spawn) => startsDistro(spawn, DISTRO))).toEqual([])

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.

Minor · Functional Correctness · Quick win

Supported by static analysis

Script executed:

sed -n '101,150p' tests/e2e/wsl-bridge-no-background-boot.spec.ts
sed -n '60,95p' tests/e2e/helpers/wsl-boot-diagnostics-log.ts
sed -n '185,220p' tests/e2e/helpers/wsl-boot-guard.ts

Repository: stablyai/orca

Length of output: 4915


Script executed:

set -eu
printf '%s\n' '--- diagnostic helper ---'
sed -n '1,145p' tests/e2e/helpers/wsl-boot-diagnostics-log.ts
printf '%s\n' '--- watcher helper ---'
sed -n '1,220p' tests/e2e/helpers/wsl-boot-guard.ts
printf '%s\n' '--- UNC references ---'
rg -n -F --glob '*.ts' -e '\\wsl.localhost' -e '\\wsl$' -e 'wsl-boot-diagnostics' -e 'UNC_TOUCH' tests src || test "$?" -eq 1
printf '%s\n' '--- changed assertion diff ---'
git diff --unified=80 0ff3fb67c917b7501e6bdb8c11da182bc162b95c e24555de04a862e6fa0872069e5b333e362a3cff -- tests/e2e/wsl-bridge-no-background-boot.spec.ts tests/e2e/helpers/wsl-boot-guard.ts tests/e2e/helpers/wsl-boot-diagnostics-log.ts

Repository: stablyai/orca

Length of output: 42025


Script executed:

set -eu
printf '%s\n' '--- account-selection consumers ---'
rg -n -F --glob '*.ts' -e 'codexAccounts.select' -e 'claudeAccounts.select' -e 'select({ accountId' src tests | head -80
printf '%s\n' '--- WSL home and UNC consumers ---'
rg -n -F --glob '*.ts' -e 'getWslHome' -e '\\wsl.localhost' -e '\\wsl$' src/main src/shared | head -160
printf '%s\n' '--- process-host WSL scope comment ---'
sed -n '1,80p' src/packages/process-host/src/wsl-distro-allowlist.ts
printf '%s\n' '--- diagnostic and assertion imports ---'
sed -n '1,45p' tests/e2e/wsl-bridge-no-background-boot.spec.ts

Repository: stablyai/orca

Length of output: 27778


Script executed:

set -eu
printf '%s\n' '--- UNC access gate ---'
sed -n '1,240p' src/main/wsl/wsl-unc-access-gate.ts
printf '%s\n' '--- account IPC handlers ---'
sed -n '1,100p' src/main/ipc/claude-accounts.ts
sed -n '1,100p' src/main/ipc/codex-accounts.ts
printf '%s\n' '--- account selection definitions ---'
rg -n -F --glob '*.ts' -e 'selectAccount(accountId' -e 'selectAccountForTarget' -e 'getWslHome(' -e 'getWslHomeAsync(' src/main/claude-accounts src/main/codex-accounts src/main/rate-limits src/main | head -140

Repository: stablyai/orca

Length of output: 15479


Include target-distro UNC records in the assertion.

The WSL access gate documents that a UNC filesystem touch boots a stopped distro. The diagnostic wrapper records these touches as file: 'fs', but startsDistro ignores them. A short-lived boot can therefore evade both the one-second watcher and the final assertion.

Filter by the tested distro so accesses to other WSL distros remain valid diagnostics.

Suggested fix
 import { buildWslExecArgs } from '../../../src/shared/wsl-login-shell-command'
+import { parseWslUncPath } from '../../../src/shared/wsl-paths'
 import { readDiagnosticLog, UNC_TOUCH, type DiagnosticRecord } from './wsl-boot-diagnostics-log'
...
 export function startsDistro(spawn: DiagnosticRecord, distro: string): boolean {
...
 }
+
+export function touchesDistro(spawn: DiagnosticRecord, distro: string): boolean {
+  if (spawn.file !== UNC_TOUCH) {
+    return false
+  }
+  return parseWslUncPath(spawn.args[1] ?? '')?.distro.toLowerCase() === distro.toLowerCase()
+}
   startsDistro,
+  touchesDistro,
   timeline,
...
-  expect(background.filter((spawn) => startsDistro(spawn, DISTRO))).toEqual([])
+  expect(
+    background.filter(
+      (spawn) => startsDistro(spawn, DISTRO) || touchesDistro(spawn, DISTRO)
+    )
+  ).toEqual([])

@nwparker
nwparker merged commit 2a5f6c7 into main Oct 29, 2026
88 checks passed
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