Skip to content

feat(wsl): WSL host deployment record in its own downgrade-safe store (C2) - #27789

Closed
nwparker wants to merge 2 commits into
mainfrom
nwparker/wsl-c2-wsl-deployment-record
Closed

nwparker wants to merge 2 commits into
mainfrom
nwparker/wsl-c2-wsl-deployment-record

Conversation

@nwparker

@nwparker nwparker commented Oct 12, 2026 •

Copy link
Copy Markdown
Contributor
Files Added Deleted Net
Test 3 $\color{#1a7f37}{\Huge{\mathbf{+}}}$​318 0 $\color{#1a7f37}{\Huge{\mathbf{+}}}$​318
Prod 23 $\color{#1a7f37}{\Huge{\mathbf{+}}}$​355 $\color{#cf222e}{\Huge{\mathbf{−}}}$​63 $\color{#1a7f37}{\Huge{\mathbf{+}}}$​292

ELI5

Later in this plan, Orca will run its server inside a WSL distro, the same way it already does on SSH hosts. Orca needs somewhere to remember "this server lives in distro X". This PR adds that place: a new file that older Orca versions never open, so going back to an older version can't hide or break any servers. Nothing creates these records yet, so users see no change.

What Changed

  • New record and file. A WSL deployment is saved in orca-wsl-host-deployments.json (src/shared/wsl-host-deployment-store.ts). Each record looks like { kind: 'wsl', environmentId, distro, distroId?, localPort, remotePort, createdAt }. distro is the name passed to wsl.exe -d. distroId is the optional registration GUID from HKCU\...\Lxss. A name is case-insensitive and can be reused by a different install, while the GUID changes after an unregister or an export/import, so later steps can tell "same name, different distro" apart. Running state (the holder pid and similar) is not saved here.
  • Records are read one at a time, like the main store. A record this build can't read (a future kind, a corrupt entry, or two records for one server) is kept on disk exactly as written, and the server it belongs to is hidden. A write replaces only the one record it targets and copies every other record through unchanged and in place, including fields a newer build added. If the whole file is corrupt, the read fails closed, the same as the sidecar. Writes are atomic and durable (writeSecureJsonFileWithinLimit(..., { durable: true })).
  • The deployment link type now has two kinds. In memory, OrcadDeploymentLink is now OrcadSshDeploymentLink | { kind: 'wsl', ... }. On SSH links kind is optional and is never written, because the sidecar still saves SSH links with the SSH-only schema. Code that needs SSH fields goes through getOrcadSshDeployment(). The SSH lifecycle code now takes OrcadSshDeploymentLink, so the compiler stops a WSL link from reaching SSH-only code.
  • The connection dependency is unchanged on disk. connectionDependency stays 'ssh-tunnel' | undefined. A WSL server's dependency is the kind: 'wsl' record in the new file. It is never written to orca-environments.json, because older builds would reject the value there.
  • Host picker merging. managed-orcad-execution-host.ts merges rows only for SSH links. A WSL server stays its own runtime:<id> row, even next to an SSH host that has the same name.
  • Browser routing. resolveSshWorkspaceBrowserRouteEligibility returns null for a WSL deployment. That page then goes out through the paired server's own network tunnel, which runs over the wsl.exe bridge. It does not use WSL's localhost forwarding, which can refuse connections and depends on the networking mode (design decision D2).
  • readEnvironmentStore adds the WSL record to the server's data after the sidecar's. A WSL record is ignored with a warning if it conflicts with SSH state, or if its localPort doesn't match the pairing (for example, after an older build re-paired the server).

Why

Compatibility (persisted data and wire):

  • Profiles with only SSH servers are unchanged byte for byte through a read and a rewrite. The new file is not created.
  • No RPC, stream, or published payload changes. The mobile relay listing uses the deployment only to merge rows locally and never sends it.

Linked Issue

None. This is step C2 of the WSL-via-orcad plan (docs/design/wsl-via-orcad.md, decision D9; implementation tracker row C2, open decision 1).

Visual Proof

N/A. This change adds types and storage only, with no UI, and nothing writes WSL records yet.

Testing

  • I manually tested these changes locally
  • Automated tests added/updated, or explained why not below

src/shared/wsl-host-deployment-store.test.ts:

  • (a) An SSH-only profile keeps both orca-environments.json and the sidecar byte-identical through a read and a rewrite, the sidecar never contains kind, and no WSL file is created.
  • (b) With WSL records present: the strict whole-file schema used by builds older than fix(runtime): keep remote servers usable when one saved record can't be read #27685 still parses the store and lists every server. Main's reader (persisted records with the sidecar overlaid) still lists the SSH server as managed and shows the WSL server as a plain pairing. A rewrite by an older build followed by markEnvironmentUsed keeps the WSL link.
  • (c) Unknown records survive verbatim and in order: a future kind, a WSL record with an extra future field, a corrupt record, and one with no id. Records are upserted and removed around them. An unreadable record hides its server and refuses to be replaced. Duplicate records count as unreadable. A corrupt file fails closed.
  • Stale-port and SSH-conflict records are ignored. Invalid distro names and GUIDs are rejected.
  • WSL cases were added to the picker-merge and browser-route-eligibility tests.

Gates run locally: pnpm tc; tests for src/shared/runtime-environment*, managed-orcad*, execution-host*, ssh-workspace-browser-route*, src/main/ssh, src/main/ipc, mobile relay and settings (1 timing test failed under the full parallel run and passes when run alone); oxlint; the anti-slop config; check:code-quality:changed; audit:code-quality:native and type-aware; React Doctor; the max-lines, ts-nocheck, runtime-electron, focus-read and layout-writer ratchets; compat-boundary and process-host imports; reliability gates; pnpm format. knip reports none of the new exports.

AI Disclosure

Review

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.

Notes

  • Windows, macOS and Linux: there is no platform-specific code. Distro identity is stored here but not probed yet; C4 captures it.
  • SSH: SSH lifecycle code only switched to the SSH-typed link, and its behavior is the same.
  • Downgrade limitation: an older build shows a WSL server as a plain paired server, so a user could remove it or re-pair it there. After upgrading, the record then has no server, or a port mismatch, and is ignored (the server shows as plain). It is never trusted against the wrong pairing.

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)

@nwparker

Copy link
Copy Markdown
Contributor Author

Superseded: the WSL host deployment record (its own downgrade-safe store) was folded into C7a #27933, which merged as a65fdc8.

@nwparker nwparker closed this Oct 13, 2026
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