Repository navigation
feat(wsl): fetch and cache a remote WSL hosts policy (kill switch, remote half 1/2) - #35528
Conversation
Adds the client half of a remote switch that can turn WSL hosts off: a small versioned policy file, downloaded from a fixed release-asset URL per channel, validated, bounded, and cached in userData with a monotonic revision. Nothing reads it yet; wiring into the gate follows. Co-Authored-By: Claude <[email protected]>
|
Warning Review limit reachedYou'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 10 minutes. View limit details
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. Comment |
…missing Co-Authored-By: Claude <[email protected]>
[Low impact] The PR adds a policy updater and cache but does not connect them to WSL behavior. Update the caller in PR #35529 or retain FindingsSummaryAdds a remote WSL hosts policy format, bounded downloads, and separate stable and prerelease caches.
Reviews (2) · Last reviewed commit: "refactor(wsl): expose the cached WSL hos..." · Reviewed by Greptile |
| const cached = readCachedWslHostsPolicy(this.deps.userDataPath, this.deps.appVersion) | ||
| // A stale mirror or replayed file must never undo a newer switch. | ||
| if (cached && parsed.policy.revision <= cached.revision) { | ||
| return | ||
| } | ||
| try { | ||
| await writePluginFileAtomically( |
There was a problem hiding this comment.
Two overlapping refresh() calls can both read revision 4 and accept newer revisions before either write finishes. If revision 5 finishes after revision 6, it replaces the newer policy. writePluginFileAtomically prevents partial files, but does not order writes.
This is non-blocking while the updater remains unused. Before wiring it into startup, serialize the revision check and write, and add a test that overlaps two refreshes and checks that the highest revision survives.
| export type WslHostsPolicyState = 'allow' | 'block' | 'missing' | ||
|
|
||
| export function wslHostsPolicyState(policy: WslHostsPolicy | null): WslHostsPolicyState { | ||
| return policy?.wslHosts ?? 'missing' |
There was a problem hiding this comment.
Removing wslHostsPolicyBlocks breaks the startup caller in stacked PR #35529. At its supplied head, src/main/wsl/wsl-host-gate-startup.ts still imports and calls that export. Once #35529 includes this change, the import will fail type checking.
Keep the boolean helper alongside wslHostsPolicyState, or update #35529 to compare the new result with 'block'.
ELI5
WSL hosts will eventually be on by default. If something goes wrong after that, we need a way to turn them off for people without shipping a new release. This PR adds the part of Orca that downloads and remembers a small "WSL hosts: allow or block" file. Nothing acts on that file yet; the stacked PR that follows does.
What Changed
src/shared/wsl-hosts-policy.ts: the file format is{ version: 1, revision, wslHosts: 'allow' | 'block' }, capped at 16 KB.src/main/wsl/wsl-hosts-policy-live-update.ts: downloads the file and keeps it current.wsl-hosts-policy-stableandwsl-hosts-policy-next. A stable build therefore never applies a prerelease-only switch, even when the two share a profile.allow.Before and after, as the user sees it: no change. Nothing calls this yet. The shared module also exposes the cached policy as
allow,blockormissingfor the gate and telemetry in the stacked PR.Why
This copies the existing agent-state-rules live updater: release-asset URL, channel split, unpackaged guard, atomic cache, bounded read. That mechanism is already proven, so this adds no new remote-config service. I used a revision number rather than a timestamp so client clock skew can't cause a downgrade.
Flag-off: with
ORCA_INTERNAL_WSL_HOSTSunset nothing changes. This PR adds code that nothing calls; the stacked PR starts the download only with the internal gate open.Status
Ready. Head
68d9910c71e. Checks run locally:pnpm tc,pnpm run typecheck:ci,wsl-hosts-policy-live-update.test.ts(18),check:code-quality:changed, anti-slop oxlint, ast-grep gates. Reviews requested from fix-reviewer and e9-reviewer.Linked Issue
Internal: WSL-host kill switch (part 1 of the remote half; the serve-only gate is #34683).
Visual Proof
N/A: no UI and no behavior change, since nothing reads the policy yet.
Testing
src/main/wsl/wsl-hosts-policy-live-update.test.ts(18 tests)Review
Agent skill upstream boundary
Notes
path.join.Checklist
N/Afor visuals, with reasonpnpm tc:nodeandcheck:code-quality:changedpass locally; CI covers the rest