Repository navigation
Add uninstall choice for local WSL gateway - #591
Conversation
Prompt users during uninstall before removing the local WSL gateway and route the uninstall through a direct WSL cleanup helper so OpenClaw binaries are not launched from the install directory. The helper unregisters OpenClawGateway, cleans setup-managed gateway artifacts, and preserves generated gateway state when the user declines removal. Co-authored-by: Copilot <[email protected]>
|
Codex review: needs maintainer review before merge. Reviewed May 29, 2026, 5:55 PM ET / 21:55 UTC. Summary Reproducibility: not applicable. as a bug reproduction; this PR changes installer behavior. The PR body plus inspected screenshots give a high-confidence behavior path for the prompt/progress/completion flow, while cleanup postconditions are supported by contributor smoke notes. Review metrics: 2 noteworthy metrics.
Merge readiness Overall follows the weaker of proof and patch quality, so missing proof can cap an otherwise strong patch. Rank-up moves:
Risk before merge
Maintainer options:
Next step before merge
Security Review detailsBest possible solution: Land the interactive uninstall flow once maintainers accept the installer-owned direct cleanup path, keeping the reparse-point guard and silent/Yes/No smoke coverage as the merge standard. Do we have a high-confidence way to reproduce the issue? Not applicable as a bug reproduction; this PR changes installer behavior. The PR body plus inspected screenshots give a high-confidence behavior path for the prompt/progress/completion flow, while cleanup postconditions are supported by contributor smoke notes. Is this the best way to solve the issue? Yes, with maintainer acceptance: copying the helper to AGENTS.md: found and applied where relevant. Codex review notes: model gpt-5.5, reasoning high; reviewed against 64b650cb3313. Label changesLabel changes:
Label justifications:
Evidence reviewedAcceptance criteria:
What I checked:
Likely related people:
What the crustacean ranks mean
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. How this review workflow works
|
Refuse recursive gateway directory deletion when the target is a junction or symlink, matching the SetupEngine safety guard and preventing cleanup from crossing outside the app-owned WSL directory. Co-authored-by: Copilot <[email protected]>
|
@clawsweeper re-review please. I added a reparse-point guard before recursive deletion of the app-owned WSL gateway directory and pinned it with installer assertion coverage. Validation rerun: PowerShell parser, targeted InstallerIssAssertionTests, ./build.ps1, Shared tests, Tray tests, reparse-point dry-run, and ARM64 Inno compile all passed. |
|
🦞👀 I queued a lightweight read-only assist pass. It will post a separate answer comment and will not edit the durable ClawSweeper review comment or trigger close, merge, repair, label, or branch changes. Request: re-review please. I added a reparse-point guard before recursive deletion of the app-owned WSL gateway directory and pinned it with installer assertion coverage. Validation rerun: PowerShell parser, targeted InstallerIssAssertionTests, ./build.ps1, Shared tests, Tray tests, reparse-point dry-run, and ARM64 Inno compile all passed. |
|
ClawSweeper assist: This needs a full correctness re-review, not a lightweight Q&A answer. The supplied context shows the prior blocker was the missing reparse-point guard, and the PR now has a new commit claiming to add that guard plus assertion coverage. Evidence:
Suggested next action: Use Source: #591 (comment) |
Real uninstall proof on a guest without WSL surfaced two pre-existing defects in the gateway cleanup helper, both dating to openclaw#591. Neither was reachable before, because earlier proof runs declined gateway removal and never executed this branch. wsl.exe writes UTF-16LE on many Windows builds while the redirected pipe is decoded as 8-bit, so captured output arrived NUL-interleaved. Every pattern in Test-DistroNotFound matched against that text and none could ever fire, leaving the "already unregistered" success path unreachable in practice. Strip NUL in the captured output instead of pinning an encoding that varies by Windows version. A host with no WSL, or with WSL but no distributions, cannot be holding our gateway. Treat both as nothing to remove rather than surfacing "OpenClaw could not remove the local WSL gateway. Exit code: 1", which offered Retry against a condition no retry can fix. The new test executes the real functions extracted from the script rather than asserting on source text, since a source-text contract cannot detect an encoding defect. Reverting either half fails it. Co-authored-by: Copilot <[email protected]> Copilot-Session: d5c700f0-7fa2-46ed-bd1a-10a11521b63a
…e gateway on uninstall (#1461) * feat(migration): checkpoint Inno preservation and gated Store startup Add protected migration records, read-only source inventory, completion-aware Inno safeguards, exact installation discovery, and disabled-by-default Store startup admission. Consent, adoption, and finalization remain future work. Local build, focused tests, and x64 fixture proof passed before checkpoint; structured review remains deferred. Co-authored-by: Copilot <[email protected]> Copilot-Session: a91896be-e75b-4a88-932e-61b78125ab4a * feat(migration): add Store consent and close-Inno retry preview Keep the preview build-time gated and read-only. Consent only observes the Inno mutex and stops before adoption, completion, uninstall, or normal startup. Required validation and x64 packaged VM proof passed; structured review remains deferred. Co-authored-by: Copilot <[email protected]> Copilot-Session: a91896be-e75b-4a88-932e-61b78125ab4a * feat(migration): prepare Inno state under exclusive ownership Co-authored-by: Copilot <[email protected]> Copilot-Session: a91896be-e75b-4a88-932e-61b78125ab4a * feat(migration): record validated Store completion Co-authored-by: Copilot <[email protected]> Copilot-Session: a91896be-e75b-4a88-932e-61b78125ab4a * feat(migration): finalize Store adoption after verified Inno removal Co-authored-by: Copilot <[email protected]> Copilot-Session: a91896be-e75b-4a88-932e-61b78125ab4a * fix(migration): serialize uninstall and scope process inspection Hold the migration operation lock across Inno removal and cleanup, and re-detect the source under the completion lock. Use limited-information process queries to exclude proven unrelated processes while failing closed on uncertain source candidates. Add regression coverage and document the ownership guarantees. Co-authored-by: Copilot <[email protected]> Copilot-Session: a91896be-e75b-4a88-932e-61b78125ab4a * fix(migration): preserve completion across clock rollback Keep completed-receipt reads independent of the current wall clock while retaining write-time timestamp checks, intent policy, and all binding and structural validation. Add backward-clock regressions through the codec, Windows PowerShell checker, and cleanup preservation path. Co-authored-by: Copilot <[email protected]> Copilot-Session: a91896be-e75b-4a88-932e-61b78125ab4a * fix(migration): exclude source runtime across Windows sessions Hold an Inno runtime reader until process exit and validate source activity under Store's exclusive migration lock. Share process inspection, preserve fail-closed startup guidance, and cover contention, exit, and completion retry. Co-authored-by: Copilot <[email protected]> Copilot-Session: d5c700f0-7fa2-46ed-bd1a-10a11521b63a * fix(migration): disclose consent consequences in every locale Explain protected migration records, the Inno startup block after successful validation, manual source uninstall, and the Store restart requirement. Clarify retry guidance and cover all six locales with disclosure regression tests. Co-authored-by: Copilot <[email protected]> Copilot-Session: d5c700f0-7fa2-46ed-bd1a-10a11521b63a * fix(migration): simplify preview Yes and No wording Remove action legends and refer directly to native Yes/No buttons in all six locales without changing consent or retry semantics. Co-authored-by: Copilot <[email protected]> Copilot-Session: d5c700f0-7fa2-46ed-bd1a-10a11521b63a * test(migration): preserve timeout diagnostics and terminate child processes Keep the existing 30-second deadline and parallel test execution. Run fixture scripts noninteractively, terminate timed-out child trees before teardown, and retain the original timeout when cleanup or diagnostic capture fails. Add synchronized parent/child regressions including an unreadable diagnostic log. This hardens the test harness without claiming to resolve the original CI-only timeout. Co-authored-by: Copilot <[email protected]> Copilot-Session: d5c700f0-7fa2-46ed-bd1a-10a11521b63a * test(migration): synchronize timeout fixture with a named event Replace the readiness-file handshake that hit a sharing violation on a Windows CI runner. Signal a named event after diagnostic output is written, and pass the child PID through stdout. This fixes the regression fixture only; the original cleanup timeout remains unresolved. Co-authored-by: Copilot <[email protected]> Copilot-Session: d5c700f0-7fa2-46ed-bd1a-10a11521b63a * fix(migration): fail closed on unverifiable migration receipts Harden the Inno-to-Store migration safety path against outcomes that previously authorized destructive gateway cleanup on incomplete evidence. - Treat a present-but-unverifiable completion receipt as "preserve", not "absent". Only FileNotFoundException/DirectoryNotFoundException exit 0; every other validation failure exits 2. - Bound every child process wait in both shipped scripts via a shared Start-BoundedProcess helper built on ProcessStartInfo, and retain the checker's diagnostics instead of discarding them. - Launch the checker watchdog through the explicit System32 Windows PowerShell path, since $PSHOME under PowerShell 7 has no powershell.exe. - Narrow the destructive admission phase to Enter-DestructivePhase so pre-destructive failures report uncertainty rather than completion. - Route installer exit code 2 to preservation instead of a retry prompt, renumber internal failure codes to 102/103, and keep the cleanup script installed so the uninstaller no longer names a file it deletes. - Allow startup after a failed or refused startup preference, and show a user-visible notice when Windows durably refuses the startup task, since only the user can re-enable it. Validation: build.ps1; Shared 4087 passed; Tray 3098 passed; Connection 1072 passed. Watchdog timeout and admission-phase mutation proofs run locally. Co-authored-by: Copilot <[email protected]> Copilot-Session: d5c700f0-7fa2-46ed-bd1a-10a11521b63a * fix(migration): stop migration state from blocking startup and uninstall Migration coordination is preview-only, but its lock sat outside the preview gate on two ordinary paths. An unreadable prepare.lock refused to launch the app and aborted the uninstaller outright, for users who never migrated. - Inno startup now blocks only when the lock is genuinely contended, which proves a live migration. Any other acquisition failure logs and continues, because an unreachable lock says nothing about migration. The completion receipt check below remains authoritative and still fails closed. - InitializeUninstall never returns False for inaccessible migration state. Only a contended lock stops an uninstall; otherwise removal proceeds and destructive gateway cleanup is suppressed instead. The reparse-point check stays sequential so a rejected path can never reach ForceDirectories. - Apply directory security on create or on drift rather than on every acquisition, so an ordinary launch no longer needs WRITE_DAC/WRITE_OWNER. - Make preservation self-contained: the notice now names the in-app removal path and the wsl --unregister command instead of pointing at documentation the uninstaller does not link, and the silent path logs the preserved distro and directory for enterprise audit. - Document the installer preservation case and why no override is offered. Validation: build.ps1; Shared 4087 passed; Connection 1075 passed; Tray 3100 passed. ActivationRouterTests passed 5/5 on this head, consistent with a baseline flake rather than a regression from this branch. Co-authored-by: Copilot <[email protected]> Copilot-Session: d5c700f0-7fa2-46ed-bd1a-10a11521b63a * fix(migration): bound the preservation checker and stop stranding helpers The checker exists because Add-Type can stall on a contended %TEMP% or an antivirus scan, and installer.iss waits for it with ewWaitUntilTerminated. Falling back to the inline check when the watchdog could not start reintroduced exactly that unbounded stall. Report the uncertain verdict instead; exit 2 already fails closed and preserves the gateway. The three uninstall helpers also carried uninsneveruninstall, but they run during usUninstall, which happens before Inno removes files. Generated app-state deletion only runs after successful gateway cleanup, so any uninstall that kept the local gateway, including the ordinary "No" choice unrelated to migration, left executable helpers behind in the former app directory. The retained-helper contract test pinned the flags it should have rejected, so it is inverted rather than deleted. Co-authored-by: Copilot <[email protected]> Copilot-Session: d5c700f0-7fa2-46ed-bd1a-10a11521b63a * fix(migration): scrub foreign grants from the migration directory DACL RequiresHardening skipped re-hardening whenever the DACL was protected and owned by the current user, without inspecting what those rules granted. A pre-existing store-migration directory can satisfy both conditions and still carry an Allow rule for an unrelated principal. That principal could delete completed.dpapi. Test-InnoMigration.ps1 maps a missing receipt to "no migration happened" and exits 0, which authorizes destructive local gateway cleanup during uninstall. The same receipt gates ordinary Inno startup. Before the hardening shortcut landed, SetAccessControl ran on every acquisition and would have removed such a grant. Restore that guarantee without reintroducing per-launch DACL churn by re-hardening only when a rule falls outside the owner, LocalSystem, and BuiltinAdministrators. RepeatAcquisition_LeavesAnAlreadyHardenedDirectoryUntouched used an Everyone: Read ACE as its no-rewrite canary, which is the grant this change must scrub. Its canary is now a trusted principal with distinct inheritance flags, so it still proves the absence of churn. Co-authored-by: Copilot <[email protected]> Copilot-Session: d5c700f0-7fa2-46ed-bd1a-10a11521b63a * fix(uninstall): treat a WSL-less host as nothing to remove Real uninstall proof on a guest without WSL surfaced two pre-existing defects in the gateway cleanup helper, both dating to #591. Neither was reachable before, because earlier proof runs declined gateway removal and never executed this branch. wsl.exe writes UTF-16LE on many Windows builds while the redirected pipe is decoded as 8-bit, so captured output arrived NUL-interleaved. Every pattern in Test-DistroNotFound matched against that text and none could ever fire, leaving the "already unregistered" success path unreachable in practice. Strip NUL in the captured output instead of pinning an encoding that varies by Windows version. A host with no WSL, or with WSL but no distributions, cannot be holding our gateway. Treat both as nothing to remove rather than surfacing "OpenClaw could not remove the local WSL gateway. Exit code: 1", which offered Retry against a condition no retry can fix. The new test executes the real functions extracted from the script rather than asserting on source text, since a source-text contract cannot detect an encoding defect. Reverting either half fails it. Co-authored-by: Copilot <[email protected]> Copilot-Session: d5c700f0-7fa2-46ed-bd1a-10a11521b63a * fix(migration): reject foreign mutating grants on the uninstall receipt The Inno uninstall checker decided whether to clean up gateway state based on a receipt file it did not verify it could trust. A non-trusted principal who could write the receipt (or its directory) could suppress or forge the cleanup decision. Trust is now established before the receipt is read: - Owner must be the current user, SYSTEM, or Administrators. - Any foreign Allow ACE that can mutate the receipt breaks authority. Read/list grants are tolerated, since installer.iss creates the state directory with plain ForceDirectories and inheritable read ACEs are common in managed fleets. - Generic rights (GENERIC_ALL, GENERIC_WRITE) count as mutating. They intersect no named FileSystemRights bit but the kernel maps them onto FILE_ALL_ACCESS / FILE_ADD_FILE, so a named-bit mask alone missed them. - Inherit-only ACEs are skipped; they do not apply to the object itself. When authority cannot be established the checker exits 2 and the uninstaller preserves state, rather than silently proceeding. Also replaces Get-Acl and Get-ChildItem with .NET types throughout. The uninstaller launches PowerShell in a constrained environment where Microsoft.PowerShell.Security fails to autoload, which made the check throw for every user and strand cleanup unconditionally. Residual, deliberately not sealed: a receipt file's own owner can grant itself DELETE and remove the receipt without altering the directory, which leaves nothing observable to the checker. Inherited Modify grants held by a domain administrators group will likewise strand cleanup rather than authorize it. Both fail closed. Co-authored-by: Copilot <[email protected]> Copilot-Session: d5c700f0-7fa2-46ed-bd1a-10a11521b63a * fix(uninstall): stop quoting wsl.exe control flags Real VM proof on Windows 11 24H2 with WSL 2.7.14 showed every wsl.exe call in the gateway cleanup failing with exit 127: wsl.exe --list --quiet exited 127. /bin/sh: --list: not found wsl.exe matches its control flags against the raw command line and does not strip quotes, so a quoted "--unregister" is not recognized as a flag and is executed as a command inside the distro instead. The gateway distro was therefore never unregistered, and uninstall reported succeeded=false with exit 127. This regressed in 6a8aede, which replaced Start-Process -ArgumentList (an array, never quoted) with ProcessStartInfo (a single string) and quoted every argument to build it. The migration-checker call site was unaffected because it already passes bare flags and quotes only values. Quote only values that need it. The escaping rules for values that do need quoting are unchanged, including doubling trailing backslashes. Reproduced independently against real WSL on a developer host: wsl.exe --list --quiet -> exit 0, lists distros wsl.exe "--list" "--quiet" -> exit 127, /bin/bash: --list: not found Proof: real WSL2 gateway cleanup in a Hyper-V VM, before and after. before: exit 127, "Failed to unregister WSL distro", still registered after: exit 0, "Local WSL gateway removed", unregistered, unrelated bystander distro preserved, second run idempotent The new contract test executes the real function rather than asserting on source text, matching the existing WSL-less-host test. Source-text assertions cannot catch an argv-shape bug. Verified non-vacuous: the previous implementation turns --list into "--list" and fails it. Validation: build.ps1, Shared 4087 passed, Tray 3103 passed. Co-authored-by: Copilot <[email protected]> Copilot-Session: d5c700f0-7fa2-46ed-bd1a-10a11521b63a * fix(migration): require package absence before authorizing gateway cleanup The Inno uninstaller decided whether it could destroy the local WSL gateway from a single signal: the migration completion receipt. Deleting that receipt made a completed handoff indistinguishable from no migration, and the checker returned the cleanup-authorizing exit 0. A cleanup utility sweeping stale AppData, or an attacker, could therefore arrange for the uninstaller to delete the gateway the Store app was actively using. Silent uninstall destroys on exit 0 with no prompt at all. Add a second, independent signal. Cleanup is now authorized only when the receipt is absent AND the packaged-app registration is absent: - Get-StorePackageState returns Present, Absent, or Indeterminate rather than a boolean, because the caller has to say something truthful to the user. - New exit 11 means the Store app is registered without a valid receipt: preserve, and tell the user explicitly not to run wsl --unregister. - An unreadable or empty Packages key is treated as tampering, not absence. That key is user-writable and every real profile has hundreds of subkeys, so an empty enumeration cannot be evidence that nothing is installed. Exit 2 reaches the same preserve decision but previously told the user to run wsl --unregister, which destroys exactly what was just preserved. That advice is reachable on a machine that has already migrated, through an undecryptable receipt after a DPAPI master key loss, a watchdog that cannot start or times out, an Add-Type failure, an unavailable migration lock, or a missing PowerShell. StoreAppRegistered in installer.iss now gates the message itself, so every route to that single advice site is covered rather than the one branch where the checker managed to report exit 11. Destruction is still authorized only by exit 0. Package presence changes what the user is told, never what is deleted. Accepted residual, documented in the checker: a same-user attacker who deletes only the OpenClawFoundation.OpenClaw_* subkey and leaves the rest can still reach exit 0. Closing that needs a signal outside the user's write scope, and %ProgramFiles%\WindowsApps cannot serve because an unelevated process may not enumerate it. Validation: build.ps1, Connection 1113, Shared 4087, Tray 3106, all green. The new guard is mutation-checked: removing it fails both contract tests. installer.iss compiles under ISCC. Runtime VM proof of the regression and the security property is still outstanding and is tracked for this PR. Co-authored-by: Copilot <[email protected]> Copilot-Session: d5c700f0-7fa2-46ed-bd1a-10a11521b63a * fix(installer): report an unreadable package registry as uncertain The uninstall path collapsed three distinct states into one boolean, so an unreadable or empty Appx package registry produced a dialog asserting that the Store app is installed and is using the gateway. That claim is unknown, and it contradicted scripts/Test-InnoMigration.ps1, which deliberately models Present, Absent, and Indeterminate as separate results. StoreAppRegistered is now StorePackagePresence, returning the same three states. A new ReportStoreAppStateUnknown preserves the gateway, makes no ownership claim, withholds the destructive wsl --unregister advice, and names the distro and preserved path in its log. Also addresses three review findings on that change: - Destructive unregister advice was the unguarded fall-through, so any unexpected presence value routed to data-loss guidance. Preservation is now the default and only a positively observed Absent reaches that advice. - Inserting the new procedure widened the slice of Installer_DoesNotAdviseUnregisteringWhenTheStoreAppOwnsTheGateway, which stopped isolating the ownership message. The slice now terminates at the new procedure. - The unknown-state log omitted the distro name and path, leaving an incomplete silent-uninstall audit trail. Validated: build.ps1, Shared 4087 passed, Tray 3107 passed, InnoMigrationContractTests 43/43, and an ISCC compile of installer.iss (mutation-verified that the compile actually rejects bad Pascal). Co-authored-by: Copilot <[email protected]> Copilot-Session: d5c700f0-7fa2-46ed-bd1a-10a11521b63a --------- Co-authored-by: Copilot <[email protected]> Copilot-Session: a91896be-e75b-4a88-932e-61b78125ab4a Copilot-Session: d5c700f0-7fa2-46ed-bd1a-10a11521b63a
Summary
This changes the Windows installer uninstall flow so users explicitly choose whether the local WSL gateway should be removed.
OpenClawGatewayWSL distro.{app}during uninstall, preventing install-directory file locks.--terminate,--shutdown,--unregister) and waits synchronously before uninstall continues.Screenshots
Standard uninstall confirmation
New local gateway choice prompt
Gateway removal progress
Completion dialog
Verification
Automated validation:
./build.ps1dotnet test ./tests/OpenClaw.Shared.Tests/OpenClaw.Shared.Tests.csproj --no-restoredotnet test ./tests/OpenClaw.Tray.Tests/OpenClaw.Tray.Tests.csproj --no-restorescripts/Uninstall-LocalGateway.ps1InstallerIssAssertionTests./scripts/build-inno-local.ps1 -Arch arm64 -Fast -Version 0.0.0-local -NoPublishReal installer smoke validation with disposable temp install roots and a disposable imported
OpenClawGatewayWSL distro:Cleanup checks after smoke validation:
OpenClawGatewaydistro remained.openclaw://protocol registration was restored after each smoke run.