Skip to content

fix(setup): let uninstall recover from absent WSL distro - #1348

Merged
shanselman merged 3 commits into
mainfrom
validation/pr-1322
Sep 7, 2026
Merged

shanselman merged 3 commits into
mainfrom
validation/pr-1322

Conversation

@shanselman

Copy link
Copy Markdown
Collaborator

Supersedes #1322 because the repository ruleset cannot attach the required GitHub Actions CI Gate check to a fork PR after a maintainer updates its head. This branch contains the same contributor changes merged with current main.

What Problem This Solves

Fixes an issue where users rerunning an uninstall would receive a failure after OpenClawGateway-Dev had already been removed. Legacy Windows-node context cleanup attempted a distro-specific WSL command even though the configured distro was absent.

Why This Change Was Made

The legacy cleanup path now checks wsl --list --quiet before it resolves the prior distro workspace. An absent distro short-circuits cleanup successfully, while an unavailable WSL listing remains an explicit failure. Missing-distro diagnostics are recognized from either process output stream to handle an unregister race after the registration check.

An inspection failure is treated as "nothing to clean" only when WSL conclusively reports no installed distributions or wsl.exe cannot be launched (process start failure). Ambiguous failures such as a timeout or access denied remain explicit uninstall errors, so a hung or failing WSL never silently skips legacy cleanup.

User Impact

A repeated uninstall now completes when its dev WSL distro has already been unregistered. It does not attempt commands against an unrelated or missing distro. On hosts where WSL is not installed at all, uninstall also completes instead of failing, while genuinely ambiguous WSL failures still stop the uninstall with a clear error.

Evidence

  • Current-head dev executable completed the destructive uninstall with EXIT=0 after the target distro was already absent.
  • Output included Uninstalling: Inject Windows node context, followed by Uninstall completed successfully in 0.8s and UNINSTALL COMPLETE.
  • Structured autoreview reported no accepted or actionable findings for the source-equivalent patch.
  • Rubber-duck review accepted the final logic and tests with no actionable finding.

Change Type

  • Bug fix
  • Feature
  • Refactor
  • Docs or instructions
  • Tests or validation
  • Security hardening
  • Chore or infrastructure

Scope

  • Tray or WinUI UX
  • Windows node capability
  • Local MCP or winnode
  • Gateway, connection, or pairing
  • Setup or onboarding
  • Permissions, privacy, or security
  • Tests, CI, or docs

Required proof pools

  • windows-clean-installer-upgrade: uninstall behavior changed. Not verified on this maintainer-scheduled signed-artifact pool.
    • Environment class this pool would cover: repeat-uninstall on a host with no WSL distributions or no wsl.exe. Now covered in-process by WindowsNodeContext_Rollback_SkipsLegacyCleanupWhenWslHasNoDistributions and WindowsNodeContext_Rollback_SkipsLegacyCleanupWhenWslExeCannotStart (and the ambiguous-failure guards WindowsNodeContext_Rollback_FailsWhenDistroInspectionIsAmbiguous / ...TimesOut). Not a pool run.
  • windows-wsl-gateway-e2e: WSL recovery behavior changed. Not verified on this maintainer-scheduled clean WSL pool.
    • Environment class this pool would cover: registered app-owned distro cleanup through the real gateway path. Now covered in-process by the rollback/restore regression tests and by real-wsl.exe harness proof against the registered OpenClawGateway-Dev distro. Not a pool run.

Validation

  • ./build.ps1: passed.
  • dotnet build tests/OpenClaw.SetupEngine.Tests/OpenClaw.SetupEngine.Tests.csproj: passed.
  • dotnet test tests/OpenClaw.SetupEngine.Tests/OpenClaw.SetupEngine.Tests.csproj --no-restore: 1039 passed, 0 failed (baseline 1035 at ebc9f176 plus 4 new rollback regression tests).
  • dotnet test tests/OpenClaw.Shared.Tests/OpenClaw.Shared.Tests.csproj --no-restore: 3905 passed, 32 skipped, 0 failed.
  • dotnet test tests/OpenClaw.Tray.Tests/OpenClaw.Tray.Tests.csproj --no-restore: 2833 passed, 0 failed.
  • Mutant sanity check: reverting the conclusive-unavailable escape fails both new skip tests; replacing it with a bare nonzero-exit skip fails both new ambiguous-failure tests. The four tests are load-bearing.

Real Behavior Proof

  • Environment tested: native ARM64 dev build with the target OpenClawGateway-Dev distro absent.
  • PR head or commit tested: ebc9f176.
  • Exact steps or command run: built OpenClaw.Tray.WinUI.exe with -DevBuild, verified app-identity.txt equals dev, then ran OpenClaw.Tray.WinUI.exe --uninstall --confirm-destructive.
  • Evidence after fix: process exit 0; the output traversed Inject Windows node context without a distro query and ended with Uninstall completed successfully in 0.8s and UNINSTALL COMPLETE.
  • Observed result: idempotent cleanup succeeds when the configured WSL distro is already gone.
  • Screenshot or artifact links verified? N/A.
  • Not verified or blocked: official signed-installer and clean WSL Gateway proof-pool runs are maintainer-scheduled and capacity-dependent. Local proof used dev-only data and did not expose model paths, credentials, tokens, identities, or gateway settings.
  • Mitigation decision: adopt maintainer option 1 - keep the registration pre-check and the explicit inspection-failure path, with conclusive-unavailable results treated as no legacy target, so legacy teardown is idempotent without masking a real WSL failure.
  • Additional proof at new head 8e89578e (throwaway harness outside the repo, real wsl.exe, dev runner logging visible):
    • Absent configured distro (OpenClawGateway-Absent-Proof): exactly one real wsl.exe --list --quiet (exit 0, 235 ms), zero in-distro commands, no exception, harness printed ABSENT-OK.
    • Registered configured distro (OpenClawGateway-Dev): wsl.exe --list --quiet, in-distro getent passwd "$(id -un)" | cut -d: -f6, then the stdin-fed rollback script (exit 0), then ExecuteAsync restore printing RESTORE=Success message=Windows node context injected, then a second rollback for idempotency (exit 0), harness printed REGISTERED-OK.
    • Post-proof host state: wsl.exe -l -v still lists OpenClawGateway-Dev as Running, version 2. No distro contents, tokens, or gateway records were read or published; Windows user and profile paths redacted.
    • No destructive uninstall was rerun in this pass: OpenClawGateway-Dev is registered and running and hosts the live dev gateway; the CLI-level destructive-uninstall proof at ebc9f176 above remains the CLI-level evidence.

Security Impact

  • New permissions or capabilities? No
  • Secrets or tokens handling changed? No
  • New or changed network calls? No
  • Command or tool execution surface changed? No
  • Data access scope changed? No

Compatibility and Migration

  • Backward compatible? Yes
  • Config or environment changes? No
  • Migration needed? No

Review Conversations

  • I replied to or resolved every bot review conversation addressed by this PR.
  • I left unresolved only conversations that still need maintainer judgment.

plarroy-nv and others added 3 commits September 3, 2026 22:04
Legacy Windows-node context cleanup now checks the registered WSL distributions before querying the prior distro. This makes a rerun idempotent after OpenClawGateway-Dev has already been removed instead of failing the uninstall. Missing-distro diagnostics are also recognized across stdout and stderr.
@clawsweeper

clawsweeper Bot commented Sep 7, 2026 •

Copy link
Copy Markdown

🦞👀
ClawSweeper picked this up.

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

ClawSweeper review complete

ClawSweeper finished reviewing this revision. The review result is being finalized.

View the workflow run.

@shanselman shanselman added the status: 🚢 actively landing A maintainer or agent is actively driving this item through implementation, validation, or merge. label Sep 7, 2026
@clawsweeper clawsweeper Bot added P2 Normal priority bug or improvement with limited blast radius. proof: sufficient Contributor real behavior proof is sufficient. rating: 🦐 gold shrimp Decent PR readiness signal, but merge confidence is limited. status: ⏳ waiting on author ClawSweeper has contributor-facing work open and is waiting for author action. labels Sep 7, 2026
@clawsweeper

clawsweeper Bot commented Sep 7, 2026

Copy link
Copy Markdown

Codex review: blocked before merge. Reviewed September 6, 2026, 9:30 PM ET / September 7, 2026, 01:30 UTC.

ClawSweeper review

What this changes

The PR checks registered WSL distributions before removing legacy Windows-node instructions during uninstall and recognizes missing-distribution errors from both output streams.

Merge readiness

⛔ Blocked before merge - 3 items remain

This remains useful work absent from pinned main, with credible real WSL proof. One error-classification defect needs correction before merge.

Priority: P2
Reviewed head: d07ecc4cfc2dbe16260ccd664e178572917b6624

Review scores

Measure Result What it means
Overall readiness 🦐 gold shrimp (3/6) Focused implementation and strong runtime evidence are limited by one concrete error-classification defect.
Proof confidence 🦞 diamond lobster (5/6) Sufficient (terminal): The captured native uninstall output and real-wsl.exe cleanup/restore traces exercise the changed production step for absent and registered distributions; the tested production file matches the reviewed head. They do not cover the newly identified process-start access-denied case, and declared custom pools remain unrun.
Patch quality 🦐 gold shrimp (3/6) 1 actionable review finding remain.

Verification

Check Result Evidence
Real behavior Verified Sufficient (terminal): The captured native uninstall output and real-wsl.exe cleanup/restore traces exercise the changed production step for absent and registered distributions; the tested production file matches the reviewed head. They do not cover the newly identified process-start access-denied case, and declared custom pools remain unrun.
Evidence reviewed 9 items Introduced failure-classification defect: The new unavailable predicate accepts every stderr containing 'Failed to start process'. Its caller consequently returns no legacy target instead of reporting an inspection failure.
Production trigger: CommandRunner catches every Win32Exception from process.Start and produces the same 'Failed to start process' prefix, including access-denied and other failures that do not establish that WSL or its distributions are absent.
Regression-test gap: The new ambiguous-inspection test supplies only 'Access is denied.', omitting the prefix emitted when process creation itself fails. The missing-executable test includes that prefix, so the distinction is not tested.
Findings 1 actionable finding [P2] Restrict the launch-failure exemption to confirmed absence
Security None None.

How this fits together

The setup engine installs Windows-node instructions into a WSL agent workspace and removes them during uninstall. Legacy installations without recorded workspace state require discovering the configured distribution and workspace first.

flowchart TD
 A[Uninstall request] --> B[Recorded workspace state]
 B -->|Present| C[Clean recorded workspace]
 B -->|Absent| D[Inspect WSL distributions]
 D -->|Target absent| E[Finish legacy cleanup]
 D -->|Target present| F[Discover and clean workspace]
 D -->|Inspection failed| G[Report cleanup error]
Loading

Before merge

  • Restrict the launch-failure exemption to confirmed absence (P2) - When wsl.exe exists but Process.Start throws access denied, CommandRunner.RunAsync returns Failed to start process '...': Access is denied. This predicate accepts that result and skips legacy cleanup, leaving its workspace instructions untouched while recording the step as successful. The new access-denied test lacks the production prefix and therefore misses this path. Preserve an explicit failure for ambiguous launch errors and exempt only confirmed missing-executable cases.
  • Resolve merge risk (P1) - Signed-installer and clean WSL proof-pool coverage remains explicitly unverified; the supplied runtime evidence uses a development build and real WSL harness.
  • Complete next step (P2) - Narrow the unavailable-WSL classifier so process-start access-denied errors remain failures, and cover that production-shaped result in regression tests.

Findings

  • [P2] Restrict the launch-failure exemption to confirmed absence — src/OpenClaw.SetupEngine/WindowsNodeBootstrapContextStep.cs:292-295
Agent review details

Security

None.

Review metrics

Metric Value Why it matters
Production and test delta production +29/-1; tests +107/-1 Growth is confined to legacy cleanup classification and focused regression coverage.

Root-cause cluster

Relationship: canonical
Canonical: #1348
Summary: The supplied body explicitly designates this branch as the replacement landing path for the original contributor PR.

Members:

Proposal only: this assessment does not dispatch repair, suppress jobs, mutate sibling items, close, or merge anything.

Merge-risk options

Maintainer options:

  1. Decide the mitigation before merge
    Keep idempotent absent-distro cleanup while distinguishing confirmed missing executables from launch failures that leave the cleanup target unknown.
  2. Pause or close
    Do not merge this PR until maintainers decide whether the risk is worth taking.

Technical review

Best possible solution:

Keep idempotent absent-distro cleanup while distinguishing confirmed missing executables from launch failures that leave the cleanup target unknown.

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

Yes, source establishes the review finding: a process-start Win32 access-denied exception receives the accepted prefix and causes legacy cleanup to return successfully. This was not executed during review.

Is this the best way to solve the issue?

Mostly yes: checking registration is a focused repair, but treating every process-start failure as conclusive absence contradicts the intended ambiguous-error behavior.

Full review comments:

  • [P2] Restrict the launch-failure exemption to confirmed absence — src/OpenClaw.SetupEngine/WindowsNodeBootstrapContextStep.cs:292-295
    When wsl.exe exists but Process.Start throws access denied, CommandRunner.RunAsync returns Failed to start process '...': Access is denied. This predicate accepts that result and skips legacy cleanup, leaving its workspace instructions untouched while recording the step as successful. The new access-denied test lacks the production prefix and therefore misses this path. Preserve an explicit failure for ambiguous launch errors and exempt only confirmed missing-executable cases.
    Confidence: 0.99

Overall correctness: patch is incorrect
Overall confidence: 0.96

AGENTS.md: found and applied where relevant.

Codex review notes: model internal, reasoning medium; reviewed against 89adfe2eadda.

Labels

Label changes:

  • add P2: This repairs a bounded repeated-uninstall failure, with one localized classification defect remaining.
  • add proof: sufficient: Contributor real behavior proof is sufficient. The captured native uninstall output and real-wsl.exe cleanup/restore traces exercise the changed production step for absent and registered distributions; the tested production file matches the reviewed head. They do not cover the newly identified process-start access-denied case, and declared custom pools remain unrun.
  • add rating: 🦐 gold shrimp: Overall readiness is 🦐 gold shrimp; proof is 🦞 diamond lobster and patch quality is 🦐 gold shrimp.
  • add status: ⏳ waiting on author: ClawSweeper has contributor-facing work open and is waiting for author action. Sufficient (terminal): The captured native uninstall output and real-wsl.exe cleanup/restore traces exercise the changed production step for absent and registered distributions; the tested production file matches the reviewed head. They do not cover the newly identified process-start access-denied case, and declared custom pools remain unrun.

Label justifications:

  • P2: This repairs a bounded repeated-uninstall failure, with one localized classification defect remaining.
  • rating: 🦐 gold shrimp: Overall readiness is 🦐 gold shrimp; proof is 🦞 diamond lobster and patch quality is 🦐 gold shrimp.
  • status: ⏳ waiting on author: ClawSweeper has contributor-facing work open and is waiting for author action. Sufficient (terminal): The captured native uninstall output and real-wsl.exe cleanup/restore traces exercise the changed production step for absent and registered distributions; the tested production file matches the reviewed head. They do not cover the newly identified process-start access-denied case, and declared custom pools remain unrun.
  • proof: sufficient: Contributor real behavior proof is sufficient. The captured native uninstall output and real-wsl.exe cleanup/restore traces exercise the changed production step for absent and registered distributions; the tested production file matches the reviewed head. They do not cover the newly identified process-start access-denied case, and declared custom pools remain unrun.

Evidence

Acceptance criteria:

  • [P1] ./build.ps1.
  • [P1] dotnet build ./tests/OpenClaw.SetupEngine.Tests/OpenClaw.SetupEngine.Tests.csproj.
  • [P1] dotnet test ./tests/OpenClaw.SetupEngine.Tests/OpenClaw.SetupEngine.Tests.csproj --no-restore.
  • [P1] dotnet test ./tests/OpenClaw.Shared.Tests/OpenClaw.Shared.Tests.csproj --no-restore.
  • [P1] dotnet test ./tests/OpenClaw.Tray.Tests/OpenClaw.Tray.Tests.csproj --no-restore.

What I checked:

Likely related people:

  • shanselman: Suggested for follow-up; no historical authorship or introduction is verified. (role: unverified routing candidate; confidence: low)
  • Barbara Kudiess: Suggested for follow-up; no historical authorship or introduction is verified. (role: unverified routing candidate; confidence: low)

Rank-up moves

Optional improvements that raise the rating; they are not merge blockers.

  • Distinguish missing executables from other process-start failures and add regression coverage using production-shaped access-denied output.

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.

@shanselman
shanselman merged commit e29bc41 into main Sep 7, 2026
22 checks passed
@shanselman
shanselman deleted the validation/pr-1322 branch September 7, 2026 01:43
@shanselman shanselman removed the status: 🚢 actively landing A maintainer or agent is actively driving this item through implementation, validation, or merge. label Sep 7, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

P2 Normal priority bug or improvement with limited blast radius. proof: sufficient Contributor real behavior proof is sufficient. rating: 🦐 gold shrimp Decent PR readiness signal, but merge confidence is limited. status: ⏳ waiting on author ClawSweeper has contributor-facing work open and is waiting for author action.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants