Skip to content

fix(setup): recover uninitialized WSL automatically - #1202

Merged
shanselman merged 4 commits into
mainfrom
karkarl-auto-recover-missing-wsl
Aug 28, 2026
Merged

shanselman merged 4 commits into
mainfrom
karkarl-auto-recover-missing-wsl

Conversation

@karkarl

@karkarl karkarl commented Aug 21, 2026 •

Copy link
Copy Markdown
Collaborator

Summary

  • recognize the Windows optional-component-required WSL states during both replacement inspection and setup preflight
  • route those states through the existing elevated wsl.exe --install --no-distribution recovery step instead of stopping at the Welcome page with a manual wsl --list --quiet instruction
  • re-inspect WSL after recovery and report a required Windows restart when initialization is still pending
  • preserve the fail-closed path for unknown inspection failures, the existing hardware-virtualization diagnostics, and single-shot elevation with no automatic retry
  • merge current origin/main without rebasing

Validation

Current head: 48db001a4f32af7e73db5740b58d0ee98237df80

  • .\build.ps1: PASS. Shared, CLI, WinNode CLI, SetupEngine, and WinUI built successfully; 46 Markdown files validated
  • dotnet test .\tests\OpenClaw.Shared.Tests\OpenClaw.Shared.Tests.csproj: PASS, 3,819 passed, 32 skipped, 0 failed
  • dotnet test .\tests\OpenClaw.SetupEngine.Tests\OpenClaw.SetupEngine.Tests.csproj --no-restore: PASS, 1,020 passed, 0 failed
  • targeted WSL recovery filter covering installability, one-time elevation, reinspection, reboot-required handling, cancellation, unknown-failure fail-closed behavior, and replacement inspection: PASS, 15 passed, 0 failed
  • git diff --check origin/main...HEAD: PASS
  • Rubber-duck review: PASS, no blocking findings. It independently confirmed the WSL classifier ordering, fail-closed boundary, single-shot mutation, UAC cancellation propagation, post-install reinspection, and current-main merge safety
  • python .agents\skills\autoreview\scripts\autoreview --mode branch --base origin/main --engine codex --model gpt-5.6-sol --thinking high --stream-engine-output: PASS, clean with no accepted or actionable findings, 0.91 confidence
  • Local Tray suite: NOT VERIFIED / BLOCKED by a host networking enumeration issue unrelated to this diff. The exact command reached 2,275 passing tests, then the .NET IPGlobalProperties.GetActiveTcpListeners() call remained active until the 5-minute blame timeout. The isolated named test reproduces the same host-level hang.
  • Exact-head GitHub checks: PASS. The full test job, win-x64 and win-arm64 builds, setup-connect E2E, network-recovery E2E, revocation-recovery E2E, CodeQL, Socket Security, and repository hygiene are green. The first setup-connect attempt hit a transient hosted-runner WSL post-install registration timeout; rerunning the failed job passed without code changes.

Real behavior proof

  • Non-destructive host proof on the current head: wsl.exe --version, wsl.exe --status, and wsl.exe --list --quiet all exited 0. The host reports WSL 2.9.9.0 with WSL2 as the default.
  • Isolated current-head UI proof: .\run-app-local.ps1 -NoBuild -Isolated -AllowNonMain launched successfully. Computer-use exercised Security notice -> Install a local gateway (WSL) -> replacement confirmation -> Set up the WSL gateway, and the app reported Local AI available on the healthy WSL host.
  • Production-path tests prove that an uninitialized optional component is treated as recoverable, the installer is invoked exactly once, readiness is re-inspected, installed WSL is not mutated, cancellation stops without reinspection, and a still-pending platform returns an explicit reboot requirement.
  • Not verified / blocked: a screenshot of the real missing-WSL UAC and reboot flow on this host. Disabling or removing WSL would disrupt existing distributions and require a Windows restart, so that destructive proof was not performed. The exact diagnostic and recovery transitions are covered by the focused SetupEngine tests.

Scope

This change is limited to missing or uninitialized WSL recovery. It does not change Local AI qualification or hardware-virtualization readiness behavior. PR #1202 should land before #1203 because #1203 depends on this recovery path.

Co-authored-by: Copilot App <[email protected]>

Copilot-Session: 7fa07d03-b4a0-4474-b9f2-2300ddb1b3e1
@clawsweeper

clawsweeper Bot commented Aug 21, 2026

Copy link
Copy Markdown

🦞👀
ClawSweeper picked this up.

Pull request received. I will update this pull request when review starts.

@karkarl karkarl added the status: 🚢 actively landing A maintainer or agent is actively driving this item through implementation, validation, or merge. label Aug 21, 2026
@clawsweeper clawsweeper Bot added P0 Emergency: data loss, security bypass, crash loop, or unusable core runtime. rating: 🐚 platinum hermit Good normal PR readiness with ordinary maintainer review expected. status: 👀 ready for maintainer look ClawSweeper has no concrete contributor-facing blocker left for this PR. labels Aug 21, 2026
@clawsweeper

clawsweeper Bot commented Aug 21, 2026 •

Copy link
Copy Markdown

Codex review: needs real behavior proof before merge. Reviewed August 28, 2026, 3:37 AM ET / 07:37 UTC.

ClawSweeper review

What this changes

This PR recognizes uninitialized WSL optional-component failures, invokes the existing elevated WSL installer once, reinspects readiness, and gives reboot guidance when initialization is pending.

Merge readiness

⚠️ Ready for maintainer review - 5 items remain

Keep open for human approval. The current main base lacks this exact optional-component recovery, while the PR adds it with narrow classifier, reinspection, and non-retry coverage; no introduced correctness or security defect was found. The collaborator-authored PR should not be auto-closed, and exact-head CI is still running.

Priority: P0
Reviewed head: 48db001a4f32af7e73db5740b58d0ee98237df80
Owner decision: Required. See Decision needed.

Review scores

Measure Result What it means
Overall readiness 🦞 diamond lobster (5/6) PR readiness rating was derived from proof quality, review findings, security review, and reviewer confidence.
Proof confidence 🌊 off-meta tidepool Not applicable: This collaborator PR is exempt from the external-contributor proof gate; its body nevertheless records exact-head healthy-host UI exercise and focused recovery-path tests, with the destructive missing-WSL flow explicitly blocked.
Patch quality 🦞 diamond lobster (5/6) No actionable review findings were identified.

Verification

Check Result Evidence
Real behavior Not applicable Not applicable: This collaborator PR is exempt from the external-contributor proof gate; its body nevertheless records exact-head healthy-host UI exercise and focused recovery-path tests, with the destructive missing-WSL flow explicitly blocked.
Evidence reviewed 5 items Known-state classifier: The introduced classifier maps only the documented optional-component-required signatures to the existing Installable state before general environment or unknown-failure handling.
Safe recovery boundary: The installer step remains after read-only preflight, does not retry an elevated mutation, reinspects after success, and terminates with explicit reboot guidance if WSL remains installable.
Focused behavior coverage: Current-head tests cover no mutation during preflight, one installer call, post-install readiness, reboot-required handling, elevation cancellation, pipeline non-retry, and the existing-configuration inspection path.
Findings None None.
Security None None.

Live Verification

Command: dotnet test ./tests/OpenClaw.SetupEngine.Tests/OpenClaw.SetupEngine.Tests.csproj --filter "FullyQualifiedName~PreflightWsl_UninitializedPlatformIsInstallable|FullyQualifiedName~EnsureWslPlatform"

Result: FAIL (failed) — execution before step 1 expect_output: sh -lc pnpm install --ignore-scripts --frozen-lockfile failed: ! Corepack is about to download https://registry.npmjs.org/pnpm/-/pnpm-11.24.0.tgz | [ERR_PNPM_NO_LOCKFILE] Cannot install with "frozen-lockfile" because pnpm-lock.yaml is absent Note that in CI environments this setting is true by default. If you still need to run install in such cases, use "pnpm install --no-frozen-lockfile"

sh -lc pnpm install --ignore-scripts --frozen-lockfile failed: ! Corepack is about to download https://registry.npmjs.org/pnpm/-/pnpm-11.24.0.tgz | [ERR_PNPM_NO_LOCKFILE] Cannot install with "frozen-lockfile" because pnpm-lock.yaml is absent Note that in CI environments this setting is true by default. If you still need to run install in such cases, use "pnpm install --no-frozen-lockfile"

Assertions:

  • FAIL expect_output: Passed!

How this fits together

The setup engine checks Windows WSL before creating OpenClaw’s app-owned gateway distro. Its result either continues setup, invokes the existing elevated recovery, requests a reboot, or stops safely with diagnostics.

flowchart LR
  A[Windows WSL status] --> B[WSL readiness inspection]
  B --> C{Platform state}
  C -->|Ready| D[Continue gateway setup]
  C -->|Uninitialized| E[Elevated WSL installation]
  E --> F[Readiness recheck]
  F -->|Ready| D
  F -->|Restart needed| G[Reboot guidance]
  C -->|Blocked or unknown| H[Safe diagnostic failure]
Loading

Decision needed

Question Recommendation
After the exact-head checks finish, should the setup owner approve this collaborator PR as the WSL recovery prerequisite for #1203? Approve after exact-head CI: Merge once the remaining checks succeed because the recovery reuses the existing installer and preserves the known-state and no-retry safeguards.

Why: The branch is review-clean but collaborator-authored PRs require explicit maintainer judgment, and sequencing the adjacent onboarding change is a release-train choice.

Before merge

  • Add real behavior proof - Not applicable: This collaborator PR is exempt from the external-contributor proof gate; its body nevertheless records exact-head healthy-host UI exercise and focused recovery-path tests, with the destructive missing-WSL flow explicitly blocked.
  • Resolve merge risk (P1) - The destructive uninitialized-WSL and UAC/reboot transition was not exercised live from this head because recreating it would alter the validation host and require a restart; focused production-path tests cover the intended transitions.
  • Resolve merge risk (P1) - Several exact-head CI jobs remain in progress, so approval should wait for their final result.
  • Complete next step (P2) - No mechanical repair is needed; wait for the in-progress exact-head checks, then obtain normal human approval for this collaborator PR.
Agent review details

Security

None.

Review metrics

Metric Value Why it matters
Production versus test delta production +29/-4, tests +198/-3, docs +1/-1 The small recovery implementation is accompanied by substantially broader focused regression coverage across its state transitions.

Merge-risk options

Maintainer options:

  1. Decide the mitigation before merge
    Approve the focused recovery after the exact-head CI finishes, retaining the known-error-only classifier, one-shot elevation, post-install recheck, and terminal reboot path.
  2. Pause or close
    Do not merge this PR until maintainers decide whether the risk is worth taking.

Technical review

Best possible solution:

Approve the focused recovery after the exact-head CI finishes, retaining the known-error-only classifier, one-shot elevation, post-install recheck, and terminal reboot path.

Do we have a high-confidence way to reproduce the issue?

Yes, from source: the pre-PR main path classifies the optional-component failure as a terminal inspection failure, while this head routes the same documented output through the existing recovery step. A live recreation was appropriately not attempted because it would change the Windows host and require a reboot.

Is this the best way to solve the issue?

Yes. The patch uses the existing elevated installer only for specific known WSL signals, preserves fail-closed handling for unknown failures and virtualization diagnostics, then confirms readiness before continuing.

AGENTS.md: found and applied where relevant.

Codex review notes: model internal, reasoning high; reviewed against 1955282412bd.

Labels

Label changes:

  • add rating: 🦞 diamond lobster: Overall readiness is 🦞 diamond lobster; proof is 🌊 off-meta tidepool and patch quality is 🦞 diamond lobster.
  • add status: needs maintainer proof decision: A ClawSweeper-authored PR needs a maintainer proof capture or override decision. Not applicable: This collaborator PR is exempt from the external-contributor proof gate; its body nevertheless records exact-head healthy-host UI exercise and focused recovery-path tests, with the destructive missing-WSL flow explicitly blocked.
  • remove status: 👀 ready for maintainer look: Current PR status label is status: needs maintainer proof decision.
  • remove rating: 🦐 gold shrimp: Current PR rating is rating: 🦞 diamond lobster, so this older rating label is no longer current.

Label justifications:

  • P0: An uninitialized required WSL component blocks a non-technical user’s first local-gateway setup until recovery or manual system changes occur.
  • rating: 🦞 diamond lobster: Overall readiness is 🦞 diamond lobster; proof is 🌊 off-meta tidepool and patch quality is 🦞 diamond lobster.
  • status: needs maintainer proof decision: A ClawSweeper-authored PR needs a maintainer proof capture or override decision. Not applicable: This collaborator PR is exempt from the external-contributor proof gate; its body nevertheless records exact-head healthy-host UI exercise and focused recovery-path tests, with the destructive missing-WSL flow explicitly blocked.

Evidence

What I checked:

  • Known-state classifier: The introduced classifier maps only the documented optional-component-required signatures to the existing Installable state before general environment or unknown-failure handling. (src/OpenClaw.SetupEngine/PreflightWslStep.cs:118, 48db001a4f32)
  • Safe recovery boundary: The installer step remains after read-only preflight, does not retry an elevated mutation, reinspects after success, and terminates with explicit reboot guidance if WSL remains installable. (src/OpenClaw.SetupEngine/PreflightWslStep.cs:294, 48db001a4f32)
  • Focused behavior coverage: Current-head tests cover no mutation during preflight, one installer call, post-install readiness, reboot-required handling, elevation cancellation, pipeline non-retry, and the existing-configuration inspection path. (tests/OpenClaw.SetupEngine.Tests/SetupStepsTests.cs:2002, 48db001a4f32)
  • Current-main necessity and provenance: The base revision lacks the optional-component classifier and still marks the elevated WSL mutation retryable; the feature history dates to Joel’s managed-local-AI setup commit, followed by the two focused WSL recovery commits. (src/OpenClaw.SetupEngine/PreflightWslStep.cs:117, bc3c312bd9cc)
  • Release and review-host check: The supplied latest release is v2026.7.1 and this unmerged head is not release provenance. The bundled structured reviewer could not start because the review host has no usable temporary directory; manual source review continued without modifying the checkout. (48db001a4f32)

Likely related people:

  • Joel: Introduced the managed local-AI and WSL setup surface that contains the original readiness flow. (role: feature introducer; confidence: high; commits: ccd64bbb7d68; files: src/OpenClaw.SetupEngine/PreflightWslStep.cs, src/OpenClaw.SetupEngine/SetupPipeline.cs)
  • Karen Lai: Recent history includes the prior WSL readiness retry work and the two focused recovery commits on this path. (role: recent setup contributor; confidence: high; commits: 2eab151b6e13, a9ad12cc6c9f, bc3c312bd9cc; files: src/OpenClaw.SetupEngine/PreflightWslStep.cs, tests/OpenClaw.SetupEngine.Tests/SetupStepsTests.cs)

Rating scale

Score Internal tier Crab rank Meaning
6/6 S 🦀 challenger crab Exceptional readiness
5/6 A 🦞 diamond lobster Very strong readiness
4/6 B 🐚 platinum hermit Good normal PR; ordinary maintainer review
3/6 C 🦐 gold shrimp Useful, but confidence is limited
2/6 D 🦪 silver shellfish Proof or implementation needs work
1/6 F 🧂 unranked krab Not merge-ready
N/A NA 🌊 off-meta tidepool Rating does not apply

Overall follows the weaker of proof and patch quality.
Shiny media proof means a screenshot, video, or linked artifact directly shows the changed behavior. Runtime, network, CSP, and security claims still need visible diagnostics.

Workflow

  • ClawSweeper keeps one durable marker-backed review comment per issue or PR.
  • Re-runs edit this comment so the latest verdict, findings, and automation markers stay together instead of adding duplicate bot comments.
  • A fresh review can be triggered by eligible @clawsweeper re-review comments, exact-item GitHub events, scheduled/background review runs, or manual workflow dispatch.
  • PR/issue authors and users with repository write access can comment @clawsweeper re-review or @clawsweeper re-run on an open PR or issue to request a fresh review only.
  • Maintainers can also comment @clawsweeper review to request a fresh review only.
  • Fresh-review commands do not start repair, autofix, rebase, CI repair, or automerge.
  • Maintainer-only repair and merge flows require explicit commands such as @clawsweeper autofix, @clawsweeper automerge, @clawsweeper fix ci, or @clawsweeper address review.
  • Maintainers can comment @clawsweeper explain to ask for more context, or @clawsweeper stop to stop active automation.

History

Review history (3 earlier review cycles)
  • reviewed 2026-08-21T23:41:33.080Z sha a9ad12c :: needs maintainer review before merge. :: none
  • reviewed 2026-08-27T22:04:50.828Z sha a9ad12c :: needs maintainer review before merge. :: none
  • reviewed 2026-08-27T23:58:38.521Z sha 8971907 :: needs maintainer review before merge. :: none

@karkarl karkarl removed the status: 🚢 actively landing A maintainer or agent is actively driving this item through implementation, validation, or merge. label Aug 27, 2026
@karkarl karkarl added the status: 🚢 actively landing A maintainer or agent is actively driving this item through implementation, validation, or merge. label Aug 27, 2026
Co-authored-by: Copilot App <[email protected]>

Copilot-Session: 117b368d-db79-4380-bc7d-de26acc3f15b
Co-authored-by: Copilot App <[email protected]>

Copilot-Session: 117b368d-db79-4380-bc7d-de26acc3f15b
@clawsweeper clawsweeper Bot added rating: 🦐 gold shrimp Decent PR readiness signal, but merge confidence is limited. and removed rating: 🐚 platinum hermit Good normal PR readiness with ordinary maintainer review expected. labels Aug 28, 2026
@karkarl

karkarl commented Aug 28, 2026

Copy link
Copy Markdown
Collaborator Author

Adversarial release review

A dual-model Opus + Codex review examined the WSL recovery change and its setup-pipeline behavior.

Review result: The fixed implementation had no remaining code defect, but the review initially returned HOLD because the retry fix was local-only and the branch conflicted with main.

Finding addressed: EnsureWslPlatformStep could be retried by SetupPipeline, reopening cancelled UAC prompts or repeating failed wsl --install --no-distribution mutations. The fix makes the mutation single-shot and adds pipeline-level coverage proving one installer invocation.

Current disposition: The fix is now pushed at 8971907b, conflicts are resolved, the branch is clean, and required checks are green.

Recommendation: READY TO MERGE with 98% merge confidence. Merge before #1203 because #1203 depends on this PR for optional-component WSL recovery.

The requested Hanselman skill was unavailable in the review runtime, so the installed equivalent adversarial workflow ran the same Opus + Codex review.

@clawsweeper clawsweeper Bot added rating: 🦞 diamond lobster Very strong PR readiness with only minor maintainer review expected. status: needs maintainer proof decision A ClawSweeper-authored PR needs a maintainer proof capture or override decision. and removed status: 👀 ready for maintainer look ClawSweeper has no concrete contributor-facing blocker left for this PR. rating: 🦐 gold shrimp Decent PR readiness signal, but merge confidence is limited. labels Aug 28, 2026
@clawsweeper

clawsweeper Bot commented Aug 28, 2026

Copy link
Copy Markdown

ClawSweeper status: review started.

I am starting a fresh review of this pull request: fix(setup): recover uninitialized WSL automatically This is item 1/1 in the current shard. Shard 0/1.

This placeholder means the worker is alive and reading the current context. I will edit this same comment with the actual review when the claws are done clicking.

Crustacean status: shell secured, claws on keyboard, evidence pebbles being sorted.

@shanselman shanselman removed the status: needs maintainer proof decision A ClawSweeper-authored PR needs a maintainer proof capture or override decision. label Aug 28, 2026
@shanselman
shanselman merged commit 4c078f9 into main Aug 28, 2026
34 of 35 checks passed
@shanselman
shanselman deleted the karkarl-auto-recover-missing-wsl branch August 28, 2026 08:18
@shanselman shanselman removed the status: 🚢 actively landing A maintainer or agent is actively driving this item through implementation, validation, or merge. label Aug 28, 2026
shanselman pushed a commit that referenced this pull request Aug 28, 2026
Gate fresh Local AI setup on authoritative WSL readiness while preserving the one-shot recovery and installed-runtime behavior landed in #1202.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

P0 Emergency: data loss, security bypass, crash loop, or unusable core runtime. rating: 🦞 diamond lobster Very strong PR readiness with only minor maintainer review expected.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants