Skip to content

feat(wsl): let a cached remote policy close the WSL hosts gate (kill switch, remote half 2/2) - #35529

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

nwparker merged 2 commits into
mainfrom
nwparker/wsl-hosts-policy-gate

Conversation

@nwparker

@nwparker nwparker commented Oct 29, 2026 •

Copy link
Copy Markdown
Contributor
Files Added Deleted Net
Test 6 $\color{#1a7f37}{\Huge{\mathbf{+}}}$​236 $\color{#cf222e}{\Huge{\mathbf{−}}}$​6 $\color{#1a7f37}{\Huge{\mathbf{+}}}$​230
Prod 10 $\color{#1a7f37}{\Huge{\mathbf{+}}}$​118 $\color{#cf222e}{\Huge{\mathbf{−}}}$​30 $\color{#1a7f37}{\Huge{\mathbf{+}}}$​88

Stacked on #35528 (base: nwparker/wsl-hosts-remote-policy).

ELI5

If we publish "block" in the WSL hosts policy, the next time Orca starts it acts as if the internal WSL-hosts switch were off. Projects that already moved onto a WSL host keep working, but nobody can add a host or move another project. If nothing is published, or the file can't be read, nothing changes.

What Changed

Gate (src/main/wsl/wsl-host-gate.ts):

  • configureWslHostsGate takes a new policyBlocks fact. It is read only when the launch environment opened the internal gate; an unreadable policy counts as not blocking.
  • wslHostsGateOpen() is now "internal gate open and no policy block". Every existing caller therefore sees a block as a closed gate.
  • This reuses the closed-gate path from feat(wsl): serve saved WSL work behind a closed hosts gate (gate states, kill switch 1/2) #34683 unchanged:
    • Saved host or move journal: the gate becomes serve-only. Hosts stay listed and reachable, committed rewrites, recovery and the way back keep running, and Add host and Move are refused.
    • Nothing saved: the gate is closed, as today.
  • The decision is fixed for the run. A policy downloaded mid-session applies on the next launch, so a flip can't pull a live host or an in-flight move out from under the user.

Shared and preload:

  • Main records the block for shared readers (isWslHostsServing).
  • Main stamps --orca-wsl-hosts-policy-blocked into every window on the shared preload, next to the existing serve-only stamp, so preload hides the API exactly when main does.

Startup:

Telemetry: wsl_usage_snapshot gains an optional wsl_hosts_policy set to allow, block or missing, the cached policy applied at launch. It is omitted when the internal gate is closed, because then no policy is read. It follows the pattern of wsl_hosts_gate_state and carries no identifiers.

Ongoing work under a block:

  • A move already running is never interrupted, because the gate is fixed for the run and a block downloaded mid-session waits for the next launch.
  • At the next launch, an unfinished move's journal makes the gate serve-only, so the existing interrupted-move recovery runs.
  • In serve-only, "Use on this computer again" and Remove host stay available, so users can always take their projects back.

Before and after, as the user sees it:

  • No policy published, which is today's state: nothing changes.
  • A cached block:
    • Internal-gate users see what they would see with ORCA_INTERNAL_WSL_HOSTS unset.
    • Moved projects and saved hosts keep working, with the "paused" notice.
    • Adding WSL hosts and moving projects are unavailable.

Why

I considered three options for already-moved projects:

  • Keep serving them and block new moves (chosen).
  • Auto-undo the moves: rejected. It would end live server sessions and agents in the distro, which risks losing unended work.
  • Read-only: rejected. It breaks running terminals and agents and gains no safety.

Treating a block exactly like the unset environment variable means there's one well-tested stranded-state path instead of two. Applying the block only at the next launch avoids every mid-run transition hazard. The cost is that the switch takes effect when Orca next starts.

Mixed versions and SSH:

  • Nothing changes on the wire, and the server inside the distro doesn't see the policy.
  • Older desktops never fetch the file.
  • SSH hosts are untouched: every check keys on orcadDeployment.kind === 'wsl', and a test covers this.

Flag-off: with ORCA_INTERNAL_WSL_HOSTS unset nothing changes. The policy is never read or downloaded, and the gate behaves exactly as today.

Status

Ready. Head 6fe1411a6b6. Checks run locally as listed under Testing. Reviews requested from fix-reviewer and e9-reviewer.

Linked Issue

Internal: WSL-host kill switch (2/2). Builds on #34683 (gate states) and #35528 (policy download).

Visual Proof

N/A for this PR. The UI under a block is the existing serve-only and closed UI from #34683 with no new strings or layout. Nothing is published, so no user sees a change from this PR alone.

Testing

  • Automated tests added or updated:
    • wsl-host-gate.test.ts: a block closes the gate for main and shared readers, keeps serving saved work as serve-only, and stamps both window arguments. It is never read behind a closed internal gate, an unreadable policy fails open to the internal gate, and SSH is untouched.
    • wsl-host-gate-startup.test.ts, from disk:
      • no cache or allow: open
      • a block with nothing saved: closed
      • a block with a saved host and a committed move: serve-only
      • another channel's block: ignored
      • a corrupt cache: open
    • Also in wsl-host-gate-startup.test.ts: a block cached mid-run applies only at the next launch.
    • wsl-host-handlers-user-actions.test.ts: under a block, Add host is refused and Remove host still works.
    • wsl-move-handlers.test.ts: under a block, the way back is not gated off, unfinished-move listing and pending rewrites still work, and a new move is refused.
    • wsl-hosts-api.test.ts: preload hides the API on the blocked stamp unless serve-only is also stamped.
    • wsl-usage-snapshot.test.ts: allow, block and missing each validate, and the field is omitted when unread.
  • pnpm tc, pnpm run typecheck:ci, each touched test file run on its own, check:code-quality:changed, anti-slop oxlint and ast-grep gates pass.
    • Related suites (window, WSL host and move handlers, deployment store) pass. main-window-updater-deferred-setup.test.ts (1) and main-process-ready-*.test.ts (8) fail identically with these changes stashed, so they don't come from this PR. CI on this PR confirms whether they pass in CI.
  • Not run: a fake-transport e2e that seeds a cached block. The unit tests drive the same startup function from a real profile directory.
  • No live policy file was published or changed.

Review

Agent skill upstream boundary

  • Not applicable.

Notes

  • Security: a remote file can only lower the gate, never open it. A missing or bad file fails safe to the local gate.
  • Cross-platform: the fetch is Windows-only; the gate logic is platform-neutral.
  • SSH: unaffected.
  • Backwards compatibility: the telemetry field is optional, and nothing changes on the wire.
  • Performance: one 16 KB-capped sync read at startup, only with the internal gate open.

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
  • Targeted tests, pnpm tc:node and changed-code checks pass locally; CI covers the rest

@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 with dependent PR #35543 included.

Summary

Applies the cached WSL hosts policy at launch. A block stops new hosts and moves while saved hosts and move recovery stay available.

  • A cached policy can pause new WSL host work at startup.
  • WSL usage snapshots can include the policy applied at launch.

Diagram

%%{init: {'theme': 'neutral'}}%%
flowchart TD
  A[Launch] --> B{Internal gate open?}
  B -->|No| E{Saved host or move journal?}
  B -->|Yes| C[Read cached policy]
  C --> D{Policy blocks?}
  D -->|No| F[Open]
  D -->|Yes| E
  E -->|Yes| G[Serve-only: keep saved work]
  E -->|No| H[Closed]
  F --> I[Refresh cache after proxy setup]
  G --> J[If internal gate was open, refresh cache]
  H --> J
  I --> K[Apply downloaded policy next launch]
  J --> K
Loading

Reviews (3) · Last reviewed commit: "feat(wsl): report the applied WSL hosts ..." · Reviewed by Greptile

@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 2 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: 5f219099-510b-4bbf-b9ca-1bd44f8ece6d
Commits

Reviewing files that changed from the base of the PR and between e1b7248 and 3fd1e58.

Files selected for processing: 16
  • src/main/index.ts
  • src/main/ipc/wsl-host-handlers-user-actions.test.ts
  • src/main/ipc/wsl-move-handlers.test.ts
  • src/main/startup/main-process-ready-foundation.ts
  • src/main/telemetry/wsl-usage-reporter.ts
  • src/main/telemetry/wsl-usage-snapshot.test.ts
  • src/main/telemetry/wsl-usage-snapshot.ts
  • src/main/wsl/wsl-host-gate-startup.test.ts
  • src/main/wsl/wsl-host-gate-startup.ts
  • src/main/wsl/wsl-host-gate.test.ts
  • src/main/wsl/wsl-host-gate.ts
  • src/main/wsl/wsl-hosts-policy-live-update.ts
  • src/preload/api/wsl-hosts-api.test.ts
  • src/preload/api/wsl-hosts-api.ts
  • src/shared/telemetry-wsl-usage-event-schemas.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 18:51
…switch 2/2)

A cached remote policy of "block" now closes an internal gate the launch
environment opened, for the whole run. It reuses the closed-gate path that
already exists: with saved hosts or moves the gate becomes serve-only, so
moved projects keep working while nothing new is added or moved. With
nothing saved it is closed. A missing, unreadable or "allow" policy changes
nothing. Main stamps windows so preload agrees, the download runs only on
Windows with the internal gate open, and telemetry reports the block.

Co-Authored-By: Claude <[email protected]>
…under a block

Telemetry reports the cached policy applied at launch as allow, block or
missing (omitted when the internal gate left it unread). Tests pin that a
block keeps Remove host, the way back and unfinished-move recovery, refuses
new hosts and moves, and that a mid-run download applies only next launch.

Co-Authored-By: Claude <[email protected]>
@nwparker
nwparker force-pushed the nwparker/wsl-hosts-policy-gate branch from 6fe1411 to 3fd1e58 Compare October 29, 2026 01:52
@nwparker
nwparker merged commit 0976872 into main Oct 29, 2026
74 of 76 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