Skip to content

fix: keep the local WSL gateway when winget uninstalls Companion - #2324

Merged
shanselman merged 4 commits into
openclaw:mainfrom
MertBasar0:fix/silent-uninstall-keeps-local-gateway
Dec 2, 2026
Merged

shanselman merged 4 commits into
openclaw:mainfrom
MertBasar0:fix/silent-uninstall-keeps-local-gateway

Conversation

@MertBasar0

Copy link
Copy Markdown
Contributor

Closes #1955

What Problem This Solves

winget uninstall, and any other silent uninstall, deletes the local WSL gateway without asking. The distro and everything in it are gone, while the README tells users they will be asked.

User Impact

User impact: a silent uninstall now keeps the OpenClawGateway distro and its generated state. An unattended caller who wants them removed passes /RemoveLocalGateway=yes.

Behavior to review: this reverses the behavior DEVELOPMENT.md documented on purpose. A script that relied on a silent uninstall to remove the gateway must add the switch. The interactive dialog and its No default, and the Store-migration preservation checks, are unchanged.

Why This Change Was Made

EnsureLocalGatewayCleanupChoice already explains why the dialog defaults to No: removal is destructive and unrecoverable. Its silent branch chose the destructive answer, and package managers uninstall silently by default (winget runs the entry's QuietUninstallString, unins000.exe /SILENT, unless --interactive is passed).

#1955 asks for a maintainer decision. This PR implements option 1 there, which is also ClawSweeper's recommendation ("preserve by default, explicit removal switch, keep the migration safeguards"), so the change can be reviewed concretely. If option 2 (keep the behavior, document it) is preferred, this PR can be closed.

The switch is only read in the silent branch, after the existing migration checks. It cannot bypass them: a completed Store migration, an installed Store app, or an unavailable migration check still preserve the gateway.

Evidence

Unsigned Dev installers built with scripts/build-inno-local.ps1 -Dev -Fast from main (558960df) and from this branch. Each case installs the Dev build, registers an empty throwaway OpenClawGateway-Dev distro with wsl --import, then runs the command named in the case and checks the registered distros.

Command Before (main 558960df) After (this PR)
The entry's QuietUninstallString, "<app>\unins000.exe" /SILENT (what winget runs) App removed, distro removed. Log: Silent uninstall: local gateway cleanup will run automatically. App removed, distro kept. Log: Silent uninstall: preserving the OpenClawGateway-Dev WSL distro and generated state. Pass /RemoveLocalGateway=yes to remove them.
unins000.exe /VERYSILENT /SUPPRESSMSGBOXES /NORESTART /RemoveLocalGateway=yes App removed, distro removed, install folder removed. Log: Silent uninstall: /RemoveLocalGateway=yes requested local gateway cleanup. then Local gateway cleanup completed successfully.

The installed release Companion and every other WSL distro were unchanged afterwards.

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: the uninstall path changed. Not run here; it needs exact signed artifacts.

Validation

Run on main 558960df plus this change. Windows 11 x64 build 26200, tr-TR.

  • ./build.ps1: succeeded.
  • InstallerIssAssertionTests: 21/21 passed. With main's installer.iss, Installer_RemovesGeneratedAppStateOnlyAfterGatewayCleanup fails (LocalGatewayCleanupRequested := True found).
  • Tray tests: 6760 passed, 1 failed. The failure is FileWorkerManifestTests.ManifestRejectsDirectAndDelayedSpeechRuntimeDependencies(… "VCRUNTIME140.dll"), which depends on this host's runtime install and is unrelated to the installer script.
  • Shared tests: this PR changes no Shared code. On this host main 558960df fails the same 39 tests (reparse-point and symbolic-link privilege, computer-name length, culture). One more test, GatewaySpeechTests.ActualGatewayRefusalsAreFiniteAndDoNotEchoResponseText, failed once on this branch and passed on rerun (20/20). CI on the PR head is the current-head result.

Real Behavior Proof

  • Environment tested: Windows 11 x64 build 26200 (tr-TR), WSL2.
  • PR head or commit tested: this branch on main 558960df, compared with main 558960df.
  • Exact steps or command run: silent Dev install, wsl --import of an empty rootfs as OpenClawGateway-Dev, read QuietUninstallString from the uninstall key and run it (or run the explicit removal command), wait for the uninstaller to finish, check the registered distros and the uninstall log.
  • Evidence after fix: see the Evidence table.
  • Observed result: the silent uninstall keeps the distro; with /RemoveLocalGateway=yes it is removed.
  • Screenshot or artifact links verified? (Yes/No/N/A): N/A
  • Not verified or blocked:
    • The winget command itself. The Dev entry is not in winget list on this host, and running it on the real package would remove the installed Companion. The cases run the exact command winget reads.
    • Signed artifacts and an upgrade from the latest stable release (windows-clean-installer-upgrade).
    • A distro with a real Gateway inside it.

Security Impact

  • New permissions or capabilities? (No)
  • Secrets or tokens handling changed? (Yes)
  • New or changed network calls? (No)
  • Command or tool execution surface changed? (No)
  • Data access scope changed? (No)
  • If any answer is Yes, explain the risk and mitigation: a silent uninstall now leaves the distro and generated state, including stored tokens, on disk. The uninstall log names them and the switch that removes them. The interactive No answer already leaves the same state.

Compatibility and Migration

  • Backward compatible? (No)
  • Config or environment changes? (Yes)
  • Migration needed? (Yes)
  • If yes, list the exact upgrade steps: add /RemoveLocalGateway=yes to any unattended uninstall that should remove the local gateway.

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.

@clawsweeper

clawsweeper Bot commented Nov 18, 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.

@MertBasar0

Copy link
Copy Markdown
Contributor Author

@RomneyDa a note on why this PR exists before #1955 has a maintainer decision.

#1955 (P0, impact:data-loss) has been waiting on the product question since Nov 1, and the stale bot marked it on Nov 15. Rather than let it close, I opened the option I recommended there, which is also ClawSweeper's recommendation: a silent uninstall keeps the local WSL gateway, and an unattended caller removes it with /RemoveLocalGateway=yes.

What changes, and what doesn't.

  • Only the silent branch of EnsureLocalGatewayCleanupChoice changes. The interactive dialog and its No default are untouched.
  • The switch is read after the existing Store-migration checks, so it cannot override them: a completed migration, an installed Store app, or an unavailable migration check still preserve the gateway.
  • README.md, docs/SETUP.md and DEVELOPMENT.md now describe the silent behavior and the switch.

The tradeoff you would be accepting. This reverses behavior that DEVELOPMENT.md documented on purpose. A script that relies on /SILENT or /VERYSILENT to remove the gateway must add /RemoveLocalGateway=yes. A silent uninstall also leaves stored tokens on disk, as the interactive No answer already does; the uninstall log names what was kept and how to remove it.

Proof so far. Unsigned Dev builds of main (558960df) and this branch, each run on a throwaway OpenClawGateway-Dev distro. The entry's QuietUninstallString (what winget runs) removed the distro on main and kept it here. With /RemoveLocalGateway=yes the distro and install folder were removed. Not covered: running winget itself, signed artifacts (windows-clean-installer-upgrade), and a distro with a real Gateway inside.

What I need from you.

  • If you prefer option 2 (keep the current behavior and document it), say so. I'll close this and send a docs-only PR instead.
  • If option 1 is right, the remaining step is the signed pool, which only a maintainer can schedule.

@clawsweeper clawsweeper Bot added clawsweeper:intake:bug Preliminary submission classification; full source review pending. P0 Emergency: data loss, security bypass, crash loop, or unusable core runtime. merge-risk: 🚨 compatibility 🚨 Merging this PR could break existing users, config, migrations, defaults, or upgrades. rating: 🦪 silver shellfish Thin PR readiness signal; proof, validation, or implementation needs work. status: 📣 needs proof The PR needs real behavior proof before ClawSweeper can clear the contributor ask. and removed clawsweeper:intake:bug Preliminary submission classification; full source review pending. labels Nov 18, 2026
@clawsweeper

clawsweeper Bot commented Nov 18, 2026

Copy link
Copy Markdown

Codex review: needs real behavior proof before merge.

What this changes

Silent Companion uninstall preserves the local WSL gateway unless the caller passes /RemoveLocalGateway=yes.

Example: Run unins000.exe /SILENT with an eligible OpenClawGateway distro registered.

  • Before: Companion and the gateway distro are removed.
  • After: Companion is removed and the distro remains; explicit unattended removal requires /RemoveLocalGateway=yes.

Review scores

Measure Result What it means
Overall readiness 🦪 silver shellfish (2/6) The focused implementation has no identified correctness defect, but available runtime evidence covers only the unsigned Dev path and product direction remains undecided.
Proof confidence 🦪 silver shellfish (2/6) Real behavior proof is necessary before merge. See Before merge.
Patch quality 🐚 platinum hermit (4/6) No actionable review findings were identified.

Product

Kind: Preference · Worth it: Needs a maintainer decision · Fix scope: Complete
User problem: Removing Companion silently can erase the user's local gateway and workspace without separate deletion consent.
Reason: Preservation has clear safety value, but the PR intentionally changes a documented product policy and adds a public uninstall switch without recorded owner approval.

Merge readiness

⛔ Blocked before merge - 3 items remain

Keep this PR open: current main still selects destructive gateway cleanup during silent uninstall, and this focused change deserves an explicit owner decision about reversing that default.

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

Decision needed

  • Question: Should silent Inno uninstall preserve the local WSL gateway unless /RemoveLocalGateway=yes is supplied?
  • Recommendation: Approve preservation by default: Accept the explicit removal switch and the documented change required for unattended scripts that expect full gateway removal.
  • Why: Earlier merged behavior deliberately removes the gateway silently, and neither this PR nor its linked issue records maintainer approval to reverse that contract and retain credentials by default.

Before merge

  • Add real behavior proof - Supplied Windows 11 x64 WSL2 Dev-installer logs exercise the registered QuietUninstallString and explicit removal through the real uninstaller, showing preservation and deletion respectively; the declared signed installer/upgrade pool remains outstanding, so the Dev evidence cannot clear the full gate. After adding proof, update the PR body, then request a new review with @clawsweeper re-review. The PR author or someone with repository write access can request it.
  • Await maintainer action - A maintainer must authorize scheduling the declared windows-clean-installer-upgrade proof pool.
  • Add data-model compatibility proof - The review found that existing stored data may not work after upgrade. Show that existing data still loads and works with this change.

Findings

None.

Tests

  • Missing end-to-end proof: The declared signed installer pool and latest-stable upgrade with populated gateway state remain unverified; the author does report the focused assertion failing on main and passing after the change.
Agent review details

How this fits together

The Inno uninstaller checks Store-migration preservation, selects whether gateway cleanup is authorized, and invokes the existing PowerShell helper before removing generated state.

flowchart TD
A[Silent uninstall] --> B[Migration preservation checks]
B --> C[Preserve gateway]
B --> D[Read explicit removal switch]
D --> C
D --> E[Existing cleanup helper]
E --> F[Unregister WSL and clean generated state]
Loading

Technical review

Best possible solution:

Approve preservation by default with explicit unattended deletion in the existing uninstall owner, retaining all migration safeguards.

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

Current-main source connects silent selection to WSL unregister, corroborated by the author's before/after Dev-installer output; this review ran no target code.

Is this the best way to solve the issue?

The patch is the smallest complete implementation of the proposed safety policy: it changes the existing selection owner, updates its contract assertion and documentation, and preserves migration admission.

AGENTS.md: found and applied where relevant.

Codex review notes: model internal, reasoning medium; reviewed against 558960df22b2.

Provenance checked

  • Silent uninstall selection and its structural assertion changes intended behavior with a stated reason (8af4b70: The earlier uninstall-choice change added interactive consent while explicitly preserving automatic silent removal.)
  • Developer documentation of silent uninstall changes intended behavior with a stated reason (bd9ce43: Store packaging documentation explained coexistence while preserving the existing Inno channel and its uninstall behavior.)
  • README and setup uninstall guidance keeps the original intent (3edc9b1: The documentation change preserved earlier uninstall guidance and documented interactive choices and cleanup boundaries.)

Testing

Proof path: shipped entry point.

Security

None.

Evidence

What I checked:

  • Current main retains automatic silent deletion: EnsureLocalGatewayCleanupChoice sets LocalGatewayCleanupRequested to True after migration admission; the interactive branch instead defaults to No. (installer.iss:559, 558960df22b2)
  • Introduced change preserves existing safety ordering: The only production change reads the removal parameter inside the existing silent branch, after migration-preservation exits; cleanup and generated-state deletion retain their existing owners. (installer.iss:562, cf750f5cd187)
  • Earlier default was intentional: Merged Add uninstall choice for local WSL gateway #591 (Add uninstall choice for local WSL gateway) explicitly retained automatic silent removal; the reviewed commit introduced this selection branch, while gateway removal existed earlier. (installer.iss:559, 8af4b70360a9)
  • Linked report supplies concrete runtime evidence: winget uninstall removes the local WSL gateway without asking #1955 contains before/after distro-registration output and cleanup logs from the registered uninstall command; its discussion contains a bot recommendation, not maintainer approval.
  • Required installer proof is explicitly outstanding: The PR reports unsigned Windows 11 x64 Dev-installer runs for preservation and explicit removal, and expressly excludes signed artifacts and latest-stable upgrade; repository policy makes the declared pool maintainer-scheduled. (docs/PROOF_POOLS.md:34, cf750f5cd187)
  • Existing cleanup still performs the destructive effect: The unchanged helper repeats migration admission before WSL unregister, then removes generated gateway artifacts; the patch gates entry into this existing path. (scripts/Uninstall-LocalGateway.ps1:884, cf750f5cd187)

Likely related people:

  • Ranjesh: Raw commit 8af4b70 adds installer.iss:100 relative to its recorded parents. This identifies author metadata, not feature responsibility or a PR merger. (role: source-line author; confidence: high; commits: 8af4b70360a9; files: installer.iss)
  • Natalie Aguinaldo: Raw commit 5a59535 adds installer.iss:434 relative to its recorded parents. This identifies author metadata, not feature responsibility or a PR merger. (role: source-line author; confidence: high; commits: 5a59535216ee; files: installer.iss)

Preflight source

Source unknown. Source comparison at the observed PR snapshot only. Completion is self-reported; body, policy, tests, execution, and report bytes are not verified.

Root-cause cluster

Relationship: fixed_by_candidate
Canonical: #1955
Summary: This PR implements the preservation option proposed in the linked report, pending the unresolved owner decision.

Members:

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

Labels

Label changes:

  • add P0: The current behavior can irreversibly delete a registered WSL gateway and its workspace during ordinary silent Companion uninstall.
  • add merge-risk: 🚨 compatibility: Existing unattended scripts that rely on automatic gateway removal will instead retain the distro and credentials until they add the explicit removal switch.
  • add rating: 🦪 silver shellfish: Overall readiness is 🦪 silver shellfish; proof is 🦪 silver shellfish and patch quality is 🐚 platinum hermit.
  • add status: 📣 needs proof: The PR needs real behavior proof before ClawSweeper can clear the contributor ask.

Label justifications:

  • P0: The current behavior can irreversibly delete a registered WSL gateway and its workspace during ordinary silent Companion uninstall.
  • merge-risk: 🚨 compatibility: Existing unattended scripts that rely on automatic gateway removal will instead retain the distro and credentials until they add the explicit removal switch.
  • rating: 🦪 silver shellfish: Overall readiness is 🦪 silver shellfish; proof is 🦪 silver shellfish and patch quality is 🐚 platinum hermit.
  • status: 📣 needs proof: The PR needs real behavior proof before ClawSweeper can clear the contributor ask.

Rating scale

6/6 🦀 challenger crab · 5/6 🦞 diamond lobster · 4/6 🐚 platinum hermit · 3/6 🦐 gold shrimp · 2/6 🦪 silver shellfish · 1/6 🧂 unranked krab. Overall follows the weaker of proof and patch quality; ✨ marks media proof (a screenshot, video, or linked artifact) that directly shows the changed behavior.

Workflow

ClawSweeper edits this one comment on every review. Comment @clawsweeper re-review for a fresh review only. Repair and merge execution lanes are retired.

Reviewed November 18, 2026, 4:52 PM ET / 21:52 UTC.

@shanselman

Copy link
Copy Markdown
Collaborator

Hi, I'm a Copilot triage agent helping the maintainers land PRs (I'm not Scott). Here is runtime evidence for head cf750f5c.

Windows Sandbox red/green. I built this branch's installer with Inno Setup 6.7.4 using the v2026.11.3 payload.

  • Red (v2026.11.3, /VERYSILENT uninstall): logged "local gateway cleanup will run automatically" and ran Uninstall-LocalGateway.ps1.
  • Green (this PR, /VERYSILENT): logged "preserving the OpenClawGateway WSL distro and generated state. Pass /RemoveLocalGateway=yes to remove them." and ran no cleanup (exit 0).
  • Green (this PR, /VERYSILENT /RemoveLocalGateway=yes): ran the cleanup (exit 0).
  • Every uninstall removed the app folder and the Add/Remove Programs entry.

Limits: this was an unsigned local build, and the guest has no WSL. It proves the uninstall decision path, not that a real distro survives. The guest also runs as an elevated admin.

Uninstallers from v2026.11.3 and older, including the current WinGet package, still delete the local WSL gateway on a silent uninstall. Add that caveat and fix stale wording in wipe_openclaw_state.py and HARD-CLEAN.md.

Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>
@shanselman

Copy link
Copy Markdown
Collaborator

Hi, Copilot triage agent here (not Scott). I pushed one small maintainer commit, fdc548c, with docs-only changes:

  • README, SETUP and DEVELOPMENT now note that uninstallers from v2026.11.3 and older, including the one the current WinGet package runs, still remove the gateway on a silent uninstall. To keep the gateway on those versions, uninstall interactively and choose No.
  • Fixed stale wording in wipe_openclaw_state.py and HARD-CLEAN.md that said a silent uninstall always removes WSL.

There are no code changes. Thanks again for the fix, @MertBasar0.

Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>
@shanselman

Copy link
Copy Markdown
Collaborator

Hi, Copilot triage agent here (not Scott). One more small docs follow-up: a reviewer noticed the caveat missed the pre-releases published after v2026.11.3, which also remove the gateway on a silent uninstall. The wording now names v2026.11.3 (the current WinGet version) and pre-releases up to v2026.11.12-alpha.1, and the unattended example adds /NORESTART and says to run it from the install folder. Docs and skill validators pass. No code changes.

…comparison

Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>
@shanselman

Copy link
Copy Markdown
Collaborator

Hi, Copilot triage agent here (not Scott). I pushed a small follow-up (e79aabe):

  • HARD-CLEAN.md now says "an earlier release (v2026.11.3 and older, or pre-releases up to v2026.11.12-alpha.1)", so older stable releases are covered too.
  • The installer test now pins the full CompareText(...'yes') = 0 check, so an inverted opt-in comparison would fail.
    unins000.exe stays as written because the Companion detector treats it as the canonical uninstaller name. Thanks again for this fix!

@shanselman
shanselman merged commit 6a92b23 into openclaw:main Dec 2, 2026
31 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

merge-risk: 🚨 compatibility 🚨 Merging this PR could break existing users, config, migrations, defaults, or upgrades. P0 Emergency: data loss, security bypass, crash loop, or unusable core runtime. rating: 🦪 silver shellfish Thin PR readiness signal; proof, validation, or implementation needs work. status: 📣 needs proof The PR needs real behavior proof before ClawSweeper can clear the contributor ask.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

winget uninstall removes the local WSL gateway without asking

2 participants