Skip to content

fix(setup): require ownership before WSL cleanup - #1229

Merged
shanselman merged 1 commit into
mainfrom
shanselman-wsl-cleanup-safety
Aug 25, 2026
Merged

shanselman merged 1 commit into
mainfrom
shanselman-wsl-cleanup-safety

Conversation

@shanselman

@shanselman shanselman commented Aug 25, 2026 •

Copy link
Copy Markdown
Collaborator

Fixes #1050.

Summary

  • Require durable, exact OpenClaw ownership evidence before automatic cleanup unregisters a same-named WSL distro or deletes its data directory.
  • Allow explicit --confirm-destructive CLI consent or ephemeral UI consent scoped to the exact distro name.
  • Fail closed when WSL inventory cannot be inspected safely.
  • Write the setup ownership marker before installation begins, then remove it only after scoped cleanup succeeds or absence is confirmed.
  • Preserve the authoritative DistroInstallPathPolicy path, canonicalization, collision, and reparse-point hardening.

This is a focused recovery of exactly 11 paths from snapshot afa4ed08b8555b0fc230df990d33f132a914f2b2 on origin/recover-maintainer-patches. No unrelated files are included.

Ownership transfer: durable ownership evidence parsing and marker lifecycle move from ExistingConfigDetector, CleanupStaleDistroStep, and CreateWslInstanceStep into authoritative ManagedDistroOwnership. The detector and setup steps retain only ownership queries and scoped marker operations.

Validation

  • dotnet test .\tests\OpenClaw.SetupEngine.Tests\OpenClaw.SetupEngine.Tests.csproj --filter "FullyQualifiedName~CleanupStaleDistro|FullyQualifiedName~ManagedDistroOwnership|FullyQualifiedName~SetupConfig_UiDestructiveConfirmation|FullyQualifiedName~BuildReplacementSummary_Unowned|FullyQualifiedName~CreateWslInstance_ClaimsOwnership"
    • Passed: 18, failed: 0, skipped: 0
  • dotnet test .\tests\OpenClaw.SetupEngine.Tests\OpenClaw.SetupEngine.Tests.csproj --no-restore
    • Passed: 964, failed: 0, skipped: 0
  • dotnet test .\tests\OpenClaw.Shared.Tests\OpenClaw.Shared.Tests.csproj --no-restore
    • Passed: 3,813, failed: 0, skipped: 32
  • dotnet test .\tests\OpenClaw.Tray.Tests\OpenClaw.Tray.Tests.csproj --no-restore
    • Passed: 2,712, failed: 0, skipped: 0
  • .\build.ps1
    • Passed: documentation validation plus Shared, CLI, SetupEngine, WinNodeCli, and WinUI builds
  • git diff --name-only origin/main...HEAD
    • 11 expected paths, 0 unexpected paths
  • Requested paths match snapshot afa4ed08b8555b0fc230df990d33f132a914f2b2 exactly.
  • Blocker-only rubber-duck review: no blockers found.

The first focused --no-restore invocation encountered the documented fresh-worktree missing-assets condition. The test project was restored by rerunning without --no-restore; all final validation above then passed.

Real behavior proof

Current-head proof used isolated temporary roaming and local data directories. The only synthetic target was an empty local\wsl\OpenClawGateway directory with no ownership marker, setup state, or gateway registry binding. Read-only wsl --list --quiet confirmed there was no real OpenClawGateway distro before or after the proof.

The setup UI displayed:

  • Title: Permanently delete WSL distro 'OpenClawGateway'?
  • Warning: WSL data for 'OpenClawGateway' is not proven to be app-owned. Continuing will permanently delete it
  • Actions: Delete and replace and default Cancel

Cancel was selected. The synthetic unowned directory remained present, and the real WSL inventory remained unchanged. The isolated process and temporary proof directories were then removed.

No real WSL distro was unregistered or deleted, by design. The current-head isolated UI proof exercises the destructive-consent gate without risking user data, so the absence of a real destructive run is not a review-readiness blocker.

@clawsweeper

clawsweeper Bot commented Aug 25, 2026

Copy link
Copy Markdown

🦞👀
ClawSweeper picked this up.

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

@shanselman shanselman added the status: 🚢 actively landing A maintainer or agent is actively driving this item through implementation, validation, or merge. label Aug 25, 2026
@shanselman
shanselman marked this pull request as ready for review August 25, 2026 23:19
@clawsweeper

clawsweeper Bot commented Aug 25, 2026

Copy link
Copy Markdown

ClawSweeper status: review started.

I am starting a fresh review of this pull request: fix(setup): require ownership before WSL cleanup 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 merged commit 787db18 into main Aug 25, 2026
27 checks passed
@shanselman
shanselman deleted the shanselman-wsl-cleanup-safety branch August 25, 2026 23:41
@shanselman shanselman removed the status: 🚢 actively landing A maintainer or agent is actively driving this item through implementation, validation, or merge. label Aug 25, 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.

Setup fails at wsl-create step: Wsl/InstallDistro/0x800072f78 on Windows 26200 + WSL 2.7.3

1 participant