Skip to content

fix(wsl): publish the resolved WSL hosts gate state to child processes (kill switch follow-up) - #35543

Merged
nwparker merged 2 commits into
mainfrom
nwparker/wsl-hosts-gate-state-for-children
Oct 29, 2026
Merged

nwparker merged 2 commits into
mainfrom
nwparker/wsl-hosts-gate-state-for-children

Conversation

@nwparker

@nwparker nwparker commented Oct 29, 2026 •

Copy link
Copy Markdown
Contributor
Files Added Deleted Net
Test 2 $\color{#1a7f37}{\Huge{\mathbf{+}}}$​92 $\color{#cf222e}{\Huge{\mathbf{−}}}$​1 $\color{#1a7f37}{\Huge{\mathbf{+}}}$​91
Prod 3 $\color{#1a7f37}{\Huge{\mathbf{+}}}$​51 $\color{#cf222e}{\Huge{\mathbf{−}}}$​10 $\color{#1a7f37}{\Huge{\mathbf{+}}}$​41

Follow-up to #35529 (merged).

ELI5

When the remote kill switch blocks WSL hosts, the Orca app knows about it, but the programs Orca starts don't: the orca command line, servers and terminals. They still see the "WSL hosts on" setting they inherited. This PR has the app hand its final on/off answer down to those programs.

What Changed

  • src/shared/wsl-host-internal-gate.ts:
    • Main publishes its resolved gate state (open, serve-only or closed) as ORCA_WSL_HOSTS_GATE_STATE in its own environment. Every child process it spawns inherits it.
    • The shared serving check (isWslHostsServing, the only gate reader outside main) trusts that value over ORCA_INTERNAL_WSL_HOSTS.
    • Main never reads an inherited value. Its entry (src/main/index.ts) marks the gate as its own to resolve before preflight, so even an early read falls back to the internal gate env. A relaunch or the updater's installer can therefore never carry a parent's state.
  • src/main/wsl/wsl-host-gate.ts: configureWslHostsGate recomputes from the internal gate env and the policy, then overwrites the published value on every path. The test reset withdraws it.

Before:

  • A blocked run: a child such as the orca CLI treated WSL host state as served. An unreadable WSL host record made it throw instead of being skipped.
  • A serve-only run: a child treated the gate as closed.

After: children read the gate exactly as main does.

Why

The first idea was to delete ORCA_INTERNAL_WSL_HOSTS from main's environment during a blocked run. I didn't, because app.relaunch and the installer the updater launches both inherit main's environment. The next Orca would then lose the internal gate, stop fetching the policy, and never learn a later allow. Publishing the resolved state instead leaves the tester's setting intact, and it also fixes the older serve-only gap.

Flag-off: with ORCA_INTERNAL_WSL_HOSTS unset and nothing saved, children see closed, the same as their behavior today. Serve-only children now correctly see serve-only.

Status

Ready. Rebased onto main after #35529 merged. Head 08ad2450443. Checks run locally: pnpm tc, pnpm run typecheck:ci, each touched or gate-reading test file run on its own (12 files), check:code-quality:changed, anti-slop oxlint, ast-grep gates. One reviewer requested: fix-reviewer.

Linked Issue

Internal: WSL-host kill switch follow-up (child-process caveat from the #35529 review).

Visual Proof

N/A: no UI change. This only affects how child processes read the gate.

Testing

  • Automated tests:
    • wsl-host-internal-gate.test.ts:
      • A child trusts the published closed over ORCA_INTERNAL_WSL_HOSTS=1, and the published serve-only with the env unset.
      • An invalid value falls back to the env.
      • A process that resolved the gate itself ignores an inherited value.
      • From main's entry on, an inherited value is ignored even before configure.
    • wsl-host-gate.test.ts:
      • the published state for open, serve-only, closed, blocked-closed and blocked-serve-only, and its withdrawal on reset;
      • main ignores a stale inherited closed (internal gate on) or open (gate off), recomputes, and overwrites it.
    • The runtime-environment-store suites and the window suites still pass.
  • Manual: not run on Windows.

Review

Agent skill upstream boundary

  • Not applicable.

Notes

  • Remote and wire: none. This is a desktop-local env var, and WSL and SSH hosts don't read it.
  • Long-lived terminal daemon: it keeps the value from the run that started it. It doesn't read the environment store, so this has no effect.
  • Terminals: user shells now see one more ORCA_* variable.

Checklist

  • This PR is small and focused
  • I explained what changed and why
  • N/A for visuals, with reason
  • Self-reviewed for correctness, security, and performance
  • Cross-platform, SSH/remote impact considered
  • Load-rule checks pass locally

@nwparker

Copy link
Copy Markdown
Contributor Author

STATUS: ready for review. Head 407b074, stacked on #35529. Load-rule checks pass locally: tc, typecheck:ci, 12 touched or gate-reading test files each run on its own, check:code-quality:changed, anti-slop oxlint, ast-grep gates. Reviewer: fix-reviewer (pending). Open question: the approach publishes the resolved gate state instead of clearing ORCA_INTERNAL_WSL_HOSTS, so a relaunch keeps fetching the policy. The team lead was told and can redirect.

@nwparker

Copy link
Copy Markdown
Contributor Author

STATUS: head e0922d1. Added the team lead's constraint: main never reads an inherited ORCA_WSL_HOSTS_GATE_STATE. It is ignored from main's entry (before preflight), recomputed from the env flag and the policy, and overwritten, with tests for a stale inherited closed and open. Load-rule checks pass again: tc, typecheck:ci, 12 gate-reading test files each run on its own, code-quality, anti-slop, ast-grep gates. Still stacked on #35529; the team lead retargets after it merges. Reviewer: fix-reviewer (pending).

@greptile-apps

greptile-apps Bot commented Oct 29, 2026 •

Copy link
Copy Markdown

RetriggerView in GreptileConfidence Score: 5/5

[Medium impact] The PR appears safe to merge; no blocking issues were found.

Summary

Main publishes its resolved WSL hosts gate through ORCA_WSL_HOSTS_GATE_STATE, so child processes can follow its decision.

  • Child processes now use the WSL gate state resolved by main.

No actionable issues were found.

Diagram

%%{init: {'theme': 'neutral'}}%%
flowchart LR
  A[Internal setting and cached policy] --> B[Main resolves gate]
  B --> C[Publish resolved state in environment]
  C --> D[Child shared reader]
  E[Inherited state on app restart] --> F[Main ignores inherited state]
  F --> B
Loading

Reviews (2) · Last reviewed commit: "fix(wsl): main ignores an inherited WSL ..." · Reviewed by Greptile

@nwparker
nwparker force-pushed the nwparker/wsl-hosts-policy-gate branch from 6fe1411 to 3fd1e58 Compare October 29, 2026 01:52
@nwparker
nwparker changed the base branch from nwparker/wsl-hosts-policy-gate to main October 29, 2026 02:16
@coderabbitai

coderabbitai Bot commented Oct 29, 2026 •

Copy link
Copy Markdown
Contributor

Warning

Review limit reached

You've used all free OSS reviews for now. Wait for the free limit to reset to keep reviewing this public repository.

Next included review available in 19 minutes.

Check out review usage here.

View limit details

Limit details: You’ve used all 10 included reviews currently available.

Learn how review limits work.

Review configuration:

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: 8baec413-3ea4-4c6d-af6f-bf13c0befa98
Commits

Reviewing files that changed from the base of the PR and between ae89e41 and 08ad245.

Files selected for processing: 5
  • src/main/index.ts
  • src/main/wsl/wsl-host-gate.test.ts
  • src/main/wsl/wsl-host-gate.ts
  • src/shared/wsl-host-internal-gate.test.ts
  • src/shared/wsl-host-internal-gate.ts
  • 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.

nwparker and others added 2 commits October 28, 2026 19:19
Children inherit ORCA_INTERNAL_WSL_HOSTS=1 even when a remote policy block
closed the gate, and none inherit serve-only. Main now publishes its
resolved state as ORCA_WSL_HOSTS_GATE_STATE at startup, and the shared
serving check in a child trusts it over the internal gate env. A process
that resolves the gate itself ignores an inherited value, so a relaunch
never carries a stale state. ORCA_INTERNAL_WSL_HOSTS is left intact so a
relaunched or updated Orca keeps fetching the policy.

Co-Authored-By: Claude <[email protected]>
…st line

A relaunch or the updater's installer inherits the parent's published
ORCA_WSL_HOSTS_GATE_STATE. Main's entry now marks the gate as its own to
resolve before preflight, so even a read before configure falls back to
the internal gate env, and configure always overwrites the value. Tests
pin that a stale inherited closed or open is ignored and overwritten.

Co-Authored-By: Claude <[email protected]>
@nwparker
nwparker force-pushed the nwparker/wsl-hosts-gate-state-for-children branch from e0922d1 to 08ad245 Compare October 29, 2026 02:22
@nwparker

Copy link
Copy Markdown
Contributor Author

STATUS: rebased onto main (9b1540c) after #35529 merged. Head 08ad245. The base is main. The range-diff against e0922d1 changes no production code. The only difference is src/shared/wsl-host-internal-gate.test.ts: #35394 deleted that suite on main, so this PR recreates it with only its own tests (inherited-state cases). The deleted cases are not restored. Load-rule checks pass again: tc, typecheck:ci, 12 gate-reading test files each run on its own, code-quality, anti-slop, ast-grep gates.

@nwparker
nwparker merged commit 8d31916 into main Oct 29, 2026
57 checks passed
nwparker added a commit that referenced this pull request Oct 29, 2026
#35667 pruned src/shared/wsl-host-internal-gate.test.ts as a lone suite,
dropping #35543's child-side cases. Two non-redundant ones return inside
wsl-host-gate.test.ts: a child of a blocked run trusts the published
closed over ORCA_INTERNAL_WSL_HOSTS=1 (and serve-only with no env), and
falls back to the env when nothing valid was published. The main-side
cases were already there.

Co-Authored-By: Claude <[email protected]>
nwparker added a commit that referenced this pull request Oct 29, 2026
#35765)

#35667 pruned src/shared/wsl-host-internal-gate.test.ts as a lone suite,
dropping #35543's child-side cases. Two non-redundant ones return inside
wsl-host-gate.test.ts: a child of a blocked run trusts the published
closed over ORCA_INTERNAL_WSL_HOSTS=1 (and serve-only with no env), and
falls back to the env when nothing valid was published. The main-side
cases were already there.

Co-authored-by: Claude <[email protected]>
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