You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
perf(wsl): read the kernel, login home and platform in one exec - #35070
When Orca connects to a WSL distro, it first asks the distro a few basic questions: the kernel version, the user's home folder, and the CPU and OS. It used to ask each one in a separate trip into the distro. Now one trip answers all three, which removes two of the ~24 trips that happen before the server starts.
What Changed
holdWslDistroWithContext (WSL only) replaces its uname -r exec with one exec. That exec prints the kernel release, $HOME, and the usual marker-backed uname -sm platform probe. The kernel line still drives the WSL 1 refusal and the missing-distro mapping. The proven platform and the login home go to resolveOrcadRemoteContext.
resolveOrcadRemoteContext takes an optional knownLoginHome and passes it to resolveOrcadMachineHome. Only login-home placement uses it (WSL and Windows hosts). Machine-keyed SSH homes ignore it. The existing detectedHost parameter now gets the platform.
ssh-remote-platform-detection.ts exports the probe command it already ran (UNAME_PLATFORM_PROBE_COMMAND) and remoteHostPlatformFromUnameProbe, which runs the existing marker parser on that output. detectRemoteHostPlatform uses the same constant.
The facts are parsed by structure. Each value is printed after its own marker, and the output is accepted only in its exact shape: kernel line, home line, blank separator, platform line. Anything else (stdout noise, a $HOME containing a newline) means a separate uname -r exec for the WSL 1 check, as before, and undefined for both platform and home, so the context runs its own probes. An unsupported platform or an empty $HOME also passes undefined for that value. The WSL 1 check reads only the separately trimmed kernel value.
Why
After #35005 and #35037, the 24 serial checks before launch are the second-biggest desktop-side cost (340–630 ms). This is batch (a) from the batching proposal: the low-risk part. It needs no change to anything read under the activation fence. Batches (b) and (c) are on hold until this and #35064 land and the restart is re-measured.
SSH blast radius: none in behavior. SSH callers pass neither new argument, so detectRemoteHostPlatform and echo $HOME/the machine-home probe run exactly as before. The shared files only gain an optional parameter and two exports, and the existing probe command text is unchanged. Flag-off: no change. The folded probe is only reached through the WSL host deploy (ORCA_INTERNAL_WSL_HOSTS). User-risk: low. The same commands run, in one shell instead of three. The platform is still accepted only from the marker-backed line, so other output folded into the same exec can't be mistaken for it. Validation of the home path is unchanged.
Linked Issue
Internal WSL-via-orcad tracker, D3 bar (restart → first usable prompt). Batching proposal: batch (a).
Visual Proof
N/A: no UI.
Testing
wsl-orcad-held-context.test.ts: one host-facts exec feeds the context the platform and home. Unproven facts fall back to the context's own probes. WSL 1 is refused from the kernel line before any hold or probe. The existing hold-ordering and E9 abort tests are updated to the new probe set.
Structural parse: a $HOME containing a newline falls back to the probes (no truncated path); leading stdout noise falls back without throwing; the real sh output of the facts command parses (a non-Windows test).
orcad-remote-primitives.test.ts: a WSL context given a platform and home runs neither the platform probe nor $HOME.
ssh-remote-platform-detection.test.ts: the marker parser works on folded output and rejects unmarked or unsupported lines.
src/main/wsl, src/main/managed-server/install and src/main/ssh suites: 3679 passed. pnpm tc, typecheck:ci, code-quality, anti-slop and ast-grep pass.
Automated tests added/updated
Status
Ready. Expected saving is two loop round trips, about 30–50 ms. The WSL2 lane phase receipt (preLaunchCommands) should drop from 24 to 22.
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 (SSH passes no new arguments)
pnpm lint, pnpm typecheck, pnpm test, and pnpm build pass (CI runs the rest)
The changes add a reusable parser for marker-backed remote platform probe output and let remote context resolution accept a known login home. WSL holding now retrieves kernel, home, and platform facts in one command when output matches the expected format, then passes available values to the context resolver. If parsing fails, it falls back to the kernel-only probe. Tests cover parsing, context handoff, fallback, and WSL 1 rejection.
Priority: Low
Merge Risk: Low · up to 0204d
A kernel-probe failure can let an unsupported WSL 1 deployment proceed. The risk is limited to that failure path.
Pre-merge checks: 4 · 1
Failed checks: 1 warning
Check name
Status
Explanation
Resolution
Docstring Coverage
Docstring coverage is 44.44% 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 checks: 4 passed
Check name
Status
Explanation
Title check
The title "perf(wsl): read the kernel, login home and platform in one exec" matches the main change. The WSL held-context path now gets the kernel release, $HOME, and the uname platform probe from one…
Description check
The description follows the template's main sections: ELI5, What Changed, Why, Linked Issue, Visual Proof, Testing, Checklist. It explains the before and after, the mechanism, the SSH and flag-off imp…
Linked Issues check
Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check
Check skipped because no linked issues were found for this pull request.
Full details: Title check
Explanation
The title "perf(wsl): read the kernel, login home and platform in one exec" matches the main change. The WSL held-context path now gets the kernel release, $HOME, and the uname platform probe from one exec instead of several serial calls. It uses a conventional type(scope) prefix and states the mechanism and scope. It is specific and does not rely on file lists or vague wording.
Full details: Description check
Explanation
The description follows the template's main sections: ELI5, What Changed, Why, Linked Issue, Visual Proof, Testing, Checklist. It explains the before and after, the mechanism, the SSH and flag-off impact, and the fallback behavior. It states that the N/A visual proof has a reason. Gaps: the Linked Issue section has no real GitHub issue reference ("Fixes #" is blank and it cites an internal tracker), which the template says is required for outside contributors. The template's AI Disclosure and Agent skill upstream boundary sections are missing. The lint/typecheck/test/build checklist item is unchecked, with a note that CI covers it. The Review and Notes sections are not filled in.
Resolution
Optional: add a real linked issue number in the Linked Issue section (the template requires one for outside contributors), fill in the AI Disclosure section if applicable, and complete or remove the 'Agent skill upstream boundary' checkbox. Run or confirm the lint, typecheck, test, and build checks before merge.
Full details: Docstring Coverage
Explanation
Docstring coverage is 44.44% 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 9 functions across 7 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.
The WSL connect's first exec now prints the kernel release, $HOME and the marker-backed uname
platform probe together, and hands the platform and home to resolveOrcadRemoteContext, which
then skips its own uname and $HOME probes: two fewer serial guest round trips per connect. SSH
passes neither, so its probes are unchanged.
Each fact now prints after its own marker, and the output is used only when it has exactly the
kernel line, the home line, the blank separator and the platform line. Anything else (stdout
noise, a HOME containing a newline) falls back to reading the kernel alone and lets the context
probe the platform and home itself, so no truncated path is ever used.
STATUS: reviewer B's structural-parse fix is pushed. Head 0204d9b, rebased on main.
What changed: each fact is now printed after its own marker, and the output is accepted only in its exact shape. Anything else falls back to a separate uname -r exec plus the context's own probes. The WSL 1 check uses only the trimmed kernel value.
New tests: a HOME containing a newline falls back (no truncated path); leading noise falls back without throwing; the real sh output of the facts command parses.
Checks run: pnpm tc, typecheck:ci, the wsl, managed-server/install and ssh suites (3685 passed), code-quality:changed, anti-slop, ast-grep.
Included review availability: This review used your included allowance. Your plan provides up to 10 included reviews per hour; 1 remain after this review.
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 '1,115p' src/main/wsl/wsl-orcad-held-context.ts
git show f231d1cde623d1ad2c85bd066af0f65078131070:src/main/wsl/wsl-orcad-held-context.ts | sed -n '1,115p'
set -o pipefail
printf'%s\n''--- deployment caller ---'
sed -n '105,165p' src/main/wsl/wsl-orcad-deploy.ts
printf'%s\n''--- held-context tests ---'
sed -n '1,275p' src/main/wsl/wsl-orcad-held-context.test.ts
printf'%s\n''--- remote command close/exit handling ---'
sed -n '220,390p' src/main/ssh/remote-exec/remote-exec-command.ts
Repository: stablyai/orca
Length of output: 15191
Reject an empty kernel fact.
If uname -r fails without stdout but uname -sm succeeds, the combined command returns valid platform output. readWslHostFacts accepts the empty kernel, so holdWslDistroWithContext skips the WSL 1 refusal and continues deployment.
IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
ELI5
When Orca connects to a WSL distro, it first asks the distro a few basic questions: the kernel version, the user's home folder, and the CPU and OS. It used to ask each one in a separate trip into the distro. Now one trip answers all three, which removes two of the ~24 trips that happen before the server starts.
What Changed
holdWslDistroWithContext(WSL only) replaces itsuname -rexec with one exec. That exec prints the kernel release,$HOME, and the usual marker-backeduname -smplatform probe. The kernel line still drives the WSL 1 refusal and the missing-distro mapping. The proven platform and the login home go toresolveOrcadRemoteContext.resolveOrcadRemoteContexttakes an optionalknownLoginHomeand passes it toresolveOrcadMachineHome. Only login-home placement uses it (WSL and Windows hosts). Machine-keyed SSH homes ignore it. The existingdetectedHostparameter now gets the platform.ssh-remote-platform-detection.tsexports the probe command it already ran (UNAME_PLATFORM_PROBE_COMMAND) andremoteHostPlatformFromUnameProbe, which runs the existing marker parser on that output.detectRemoteHostPlatformuses the same constant.$HOMEcontaining a newline) means a separateuname -rexec for the WSL 1 check, as before, andundefinedfor both platform and home, so the context runs its own probes. An unsupported platform or an empty$HOMEalso passesundefinedfor that value. The WSL 1 check reads only the separately trimmed kernel value.Why
After #35005 and #35037, the 24 serial checks before launch are the second-biggest desktop-side cost (340–630 ms). This is batch (a) from the batching proposal: the low-risk part. It needs no change to anything read under the activation fence. Batches (b) and (c) are on hold until this and #35064 land and the restart is re-measured.
SSH blast radius: none in behavior. SSH callers pass neither new argument, so
detectRemoteHostPlatformandecho $HOME/the machine-home probe run exactly as before. The shared files only gain an optional parameter and two exports, and the existing probe command text is unchanged.Flag-off: no change. The folded probe is only reached through the WSL host deploy (
ORCA_INTERNAL_WSL_HOSTS).User-risk: low. The same commands run, in one shell instead of three. The platform is still accepted only from the marker-backed line, so other output folded into the same exec can't be mistaken for it. Validation of the home path is unchanged.
Linked Issue
Internal WSL-via-orcad tracker, D3 bar (restart → first usable prompt). Batching proposal: batch (a).
Visual Proof
N/A: no UI.
Testing
wsl-orcad-held-context.test.ts: one host-facts exec feeds the context the platform and home. Unproven facts fall back to the context's own probes. WSL 1 is refused from the kernel line before any hold or probe. The existing hold-ordering and E9 abort tests are updated to the new probe set.$HOMEcontaining a newline falls back to the probes (no truncated path); leading stdout noise falls back without throwing; the realshoutput of the facts command parses (a non-Windows test).orcad-remote-primitives.test.ts: a WSL context given a platform and home runs neither the platform probe nor$HOME.ssh-remote-platform-detection.test.ts: the marker parser works on folded output and rejects unmarked or unsupported lines.src/main/wsl,src/main/managed-server/installandsrc/main/sshsuites: 3679 passed.pnpm tc,typecheck:ci, code-quality, anti-slop and ast-grep pass.Status
Ready. Expected saving is two loop round trips, about 30–50 ms. The WSL2 lane phase receipt (
preLaunchCommands) should drop from 24 to 22.Checklist
N/Afor visuals with reasonpnpm lint,pnpm typecheck,pnpm test, andpnpm buildpass (CI runs the rest)