Skip to content

fix: preserve normal installs during isolated patch cleanup - #1951

Merged
karkarl merged 3 commits into
openclaw:mainfrom
karkarl:karkarl-isolated-patch-cleanup
Nov 5, 2026
Merged

karkarl merged 3 commits into
openclaw:mainfrom
karkarl:karkarl-isolated-patch-cleanup

Conversation

@karkarl

@karkarl karkarl commented Oct 31, 2026 •

Copy link
Copy Markdown
Collaborator

What Problem This Solves

Fixes: isolated development cleanup would select the normal Companion and Store Gateway instead of the named test patch.

User Impact

Developers can explicitly preview and clean one owned development Gateway patch plus disposable Companion directories without selecting their normal install, other patches, WSL or external model weights. Ordinary cleanup defaults are unchanged.

The caller must separately verify and stop its owned Companion instance and ensure no other session uses the disposable directories. Apply requires destructive consent and the unchanged preview digest. In-profile data, including identities and models, is destroyed. Native runtime proof is deferred, so this draft is not approval to run cleanup.

Why This Change Was Made

An isolated-only scope cannot be composed from the old additive flags. A separate path pins the exact registered development package/layout, patched lifecycle alias, affected user, task-owned Companion binary, package-bound session record and explicit profile inventory. An unchanged SHA-256 preview is mandatory for apply. Supported native teardown must confirm structured success before that registration is removed. Existing path/reparse/WSL safeguards are reused; there is no process-killing or account-deletion fallback.

Evidence

The baseline parameter contract rejects -IsolatedOnly. The updated standalone Windows PowerShell 5.1 fixture suite passes 44 cases, covering normal-mode preservation, isolated script routing, exact patch/layout/alias/session ownership, stale previews, teardown failures, explicit profile guards, concurrent unrelated processes and external-cache preservation. These are executable script tests with temporary data and mocked package/process/WSL operations, not real uninstall evidence.

Independent Copilot rubber-duck ownership review and P0-P3 coverage confirmation found no actionable issues. Its assessment has no shared-helper isolation or structured machine-status guarantees; concrete model identity is unverified. Codex CLI is unavailable. The existing named-mutex availability boundary, Windows case-insensitive filename comparison and repeated hashing costs were consciously retained: they preserve cooperative build exclusion, native path semantics and drift guards.

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: one consented live ARM64 development-patch teardown/unregister cycle and preservation checks completed. Further Store reinstall, exhaustive cache-content, residual-state and cross-platform proof remain out of scope/unverified; this single cycle does not complete the entire pool.

Validation

  • powershell.exe -NoProfile -ExecutionPolicy Bypass -File .\scripts\test-clean-uninstall.ps1: passed, 44 cases, no skips.
  • .\build.ps1: passed, all five projects, native ARM64 Debug; includes documentation validation (69 Markdown files and seven proof pools).
  • dotnet test .\tests\OpenClaw.Shared.Tests\OpenClaw.Shared.Tests.csproj --no-restore --logger 'console;verbosity=quiet': passed, 4,810 passed, 24 opt-in native/integration skips, zero failures; 2m36s.
  • dotnet test .\tests\OpenClaw.Tray.Tests\OpenClaw.Tray.Tests.csproj --no-restore --logger 'console;verbosity=quiet': passed, 4,799 passed, zero skips/failures; 1m34s.
  • .\scripts\validate-agent-skills.ps1: passed, 15 skills and 24 Markdown files.
  • .\scripts\test-agent-skills-validator.ps1: passed, 27 fixtures plus repository skills.
  • git diff --check: passed.

Tests set OPENCLAW_REPO_ROOT to this isolated worktree and an isolated temporary OPENCLAW_TRAY_DATA_DIR. Initial .NET runs omitted --no-restore because this was a fresh worktree. One early cleanup-fixture run failed because its invalid-JSON expected error text did not match PowerShell 5.1 wording; the explicit parse error and assertion were corrected, then the entire focused suite was rerun.

Real Behavior Proof

  • Environment tested: Windows ARM64, Windows PowerShell 5.1.
  • PR head or commit tested: b896c9e42500dab049a80aa6dded38bb57d122f9.
  • Exact steps or command run: verified and stopped only the task-owned Companion, preserved its diagnostics/setup-log archives with hash checks, previewed isolated-only cleanup for pr225-test and the approved disposable Companion profile, then applied the same scope using the unchanged preview SHA-256.
  • Evidence after fix: isolated-only apply succeeded. The selected patch registration, its session record and selected profile are absent. Before/after metadata was unchanged for the two other Gateway registrations, one OpenClaw uninstall registration, WSL registrations (none observed), and three preserved root-existence checks. All four historical guest PIDs are absent. A read-only CIM query, using the archived session record bound to the task package family, found zero matching local agent accounts and zero matching Windows profile registrations; the former Windows profile directory was not independently verified. Diagnostic ZIP and setup-log archive hashes remained unchanged.
  • Observed result: this one live ARM64 cycle removed the explicitly selected patch/session/profile while the checked unrelated registration metadata and archives remained unchanged.
  • Screenshot or artifact links verified? (Yes/No/N/A): N/A.
  • Not verified or blocked: this is one live ARM64 cycle only. Store reinstall, exhaustive shared-cache content preservation, other-platform behavior, the former Windows profile directory and absence of all residual files were not verified. No claim is made beyond the checks listed above.

Security Impact

  • New permissions or capabilities? (Yes/No): No.
  • Secrets or tokens handling changed? (Yes/No): No credential export/copy added. Disposable-profile deletion remains explicitly destructive; fingerprints read file bytes without exporting contents.
  • New or changed network calls? (Yes/No): No.
  • Command or tool execution surface changed? (Yes/No): Yes.
  • Data access scope changed? (Yes/No): Yes.
  • If any answer is Yes, explain the risk and mitigation: the new opt-in scope can run only a registered package-qualified patched teardown alias and delete only explicitly supplied disposable directories. Exact registration/development mode/layout/manifest/session ownership and an unchanged affected-user preview digest gate apply. No Companion/process stop, ordinary uninstall, WSL command, wildcard deletion, credential copy or guessed account cleanup is performed. Identifiable unrelated processes may remain; the caller must independently establish exclusive ownership of selected profiles. Cooperating source builds are excluded by the existing named mutex; hostile writers and concurrent out-of-band lifecycle operations are not supported.

Compatibility and Migration

  • Backward compatible? (Yes/No): Yes, ordinary cleanup behavior remains unchanged.
  • Config or environment changes? (Yes/No): No persistent changes; new isolated command parameters only.
  • Migration needed? (Yes/No): No.
  • If yes, list the exact upgrade steps: N/A. Isolated mode intentionally rejects unknown session schema/identity encodings rather than converting them.

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.

Add an explicit exact development patch and disposable Companion profile scope, bound to an unchanged preview and verified native teardown.

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

clawsweeper Bot commented Oct 31, 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.

@clawsweeper clawsweeper Bot added clawsweeper:intake:bug Preliminary submission classification; full source review pending. clawsweeper:intake:needs-environment Preliminary submission classification; full source review pending. clawsweeper:intake:needs-repro Preliminary submission classification; full source review pending. P2 Normal priority bug or improvement with limited blast radius. merge-risk: 🚨 security-boundary 🚨 Merging this PR could weaken sandboxing, authorization, credentials, or sensitive data. rating: 🧂 unranked krab Not merge-ready due to missing proof or serious correctness/safety concerns. 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. clawsweeper:intake:needs-environment Preliminary submission classification; full source review pending. clawsweeper:intake:needs-repro Preliminary submission classification; full source review pending. labels Oct 31, 2026
@clawsweeper

clawsweeper Bot commented Oct 31, 2026

Copy link
Copy Markdown

Codex review: needs real behavior proof before merge.

What this changes

Adds explicit cleanup of one development Gateway patch and selected disposable Companion directories, guarded by an unchanged preview digest.

Example: Clean development patch pr225-test while retaining the normal Companion and Store Gateway.

  • Before: Standalone cleanup selects ordinary installations and cannot express this isolated scope.
  • After: IsolatedOnly selects the exact development registration and explicit disposable directories, then requires matching preview and successful native teardown.

Review scores

Measure Result What it means
Overall readiness 🧂 unranked krab (1/6) The scoped implementation and fixture coverage are coherent, but mocked results cannot establish the required destructive runtime authority boundary.
Proof confidence 🧂 unranked krab (1/6) Real behavior proof is necessary before merge. See Before merge.
Patch quality 🦐 gold shrimp (3/6) Security review found an item that needs attention.

Product

Kind: Feature · Worth it: Yes · Fix scope: Complete
User problem: Developers lack a standalone cleanup scope for one named development patch and disposable Companion data while preserving normal installations.
Reason: The collaborator-authored PR supplies owner direction, preserves ordinary defaults and addresses a concrete gap in isolated development cleanup.

Merge readiness

⛔ Blocked before merge - 4 items remain

Keep open: this maintainer-authored draft adds a useful cleanup scope absent from main; no discrete introduced code defect was found.

Priority: P2
Reviewed head: b896c9e42500dab049a80aa6dded38bb57d122f9

Before merge

  • Add real behavior proof - Authority-chain proof required: the supplied Windows PowerShell fixtures exercise the cleanup functions with mocked package, process and teardown operations. Provide current-head native terminal output or redacted logs showing real package-qualified activation, successful owned-session deprovision and exact registration/profile removal, with the normal install and another patch unchanged; also show foreign session ownership and a stale or reassigned preview rejected before destructive I/O. Redact credentials, IPs and non-public endpoints. 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.
  • Resolve security review attention item - No concrete security defect was found, but native enforcement of the destructive ownership boundary remains unproven.
  • Resolve merge risk - The destructive authority boundary between package-qualified activation, persisted sandbox ownership and native deprovision remains unverified at the final runtime effect.
  • 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: Missing current-head shipped-script proof of real patch teardown/unregister, preserved normal installations and existing data, and rejection of foreign ownership or a stale preview before destructive effects.
Agent review details

How this fits together

The standalone PowerShell cleanup script consumes current-user package, session, process and filesystem inventories, delegates session teardown to the selected package CLI, then unregisters that package and deletes approved directories.

flowchart TD
A[Explicit patch and profile scope] --> B[Package and ownership inventory]
B --> C[Preview digest and consent]
C --> D[Package qualified teardown CLI]
D --> E[Revalidate ownership and state]
E --> F[Unregister selected patch]
F --> G[Delete selected disposable directories]
Loading

Technical review

Best possible solution:

Keep exact-scope selection in the standalone cleanup owner and delegate MXC session removal to the registered patch's lifecycle CLI.

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

Source confirms that main's standalone script cannot express isolated-patch-only cleanup and always enters ordinary cleanup; no target code was run during this read-only review.

Is this the best way to solve the issue?

The maintainer-authorized standalone scope is coherent: existing source-build unregister requires its packaging checkout and does not provide preview-bound disposable-directory cleanup; the added checks serve distinct safety invariants.

AGENTS.md: found and applied where relevant.

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

Merge-risk options

Maintainer options:

  1. Verify the destructive ownership boundary (recommended)
    The PR owner supplies consented native evidence that the selected patch is removed and foreign or stale ownership is rejected before teardown or deletion.
  2. Keep the draft paused
    Retain the draft until an authorized disposable Windows environment is available.

Provenance checked

  • Standalone cleanup routing and uninstall guidance keeps the original intent (839dad2: Provide explicit, consented clean-retest tooling for demo devices without requiring a build environment or agent.)
  • Existing native patch unregister ownership keeps the original intent (unknown: Current source verifies the registered development layout before invoking patch teardown and retains payloads; this PR documents why a self-contained standalone route is needed.)

Testing

Proof path: in-process harness.

Security

Needs attention: No concrete security defect was found, but native enforcement of the destructive ownership boundary remains unproven.

Evidence

What I checked:

  • Pinned introduction and ordinary-mode preservation: The introduced diff adds a separate isolated route; ordinary cleanup retains its existing arguments and defaults. The fetched main has no IsolatedOnly parameter. (scripts/clean-uninstall.ps1:1061, b896c9e42500)
  • Destructive operation gates: Apply binds the preview to user identity, registration, manifest, session, Companion binary and profile contents; structured teardown success precedes unregister, and profile fingerprints are checked before deletion. (scripts/clean-uninstall.ps1:738, b896c9e42500)
  • Existing lifecycle capability and standalone boundary: Build-NativeGatewayFromSource already supports exact-patch unregister through its packaging checkout; this PR supplies a standalone, preview-bound workflow that also inventories disposable Companion directories. (scripts/Build-NativeGatewayFromSource.ps1:237, a4dd026cc5f8)
  • Supplied validation and explicit runtime deferral: The PR reports 44 passing PowerShell fixture cases and passing build, Shared and Tray validation, but explicitly says real alias activation, teardown, package removal and preservation inventories were not exercised. Discussion contains only bot status comments. (scripts/test-clean-uninstall.ps1:400, b896c9e42500)
  • Original intent and feature history: The standalone cleanup owner came from feat: add standalone clean uninstall for demo devices #1598, preserving explicit destructive scope and native teardown ownership; earlier uninstall guidance came from docs: document safe uninstall and dev cleanup #1383. Scoped history and blame identify karkarl and shanselman. Follow-history traversal encountered an unavailable older object; ordinary scoped history and supplied provenance remained available. (.agents/skills/uninstall/SKILL.md:10, 839dad2936c7)
  • Affirmative runtime dependency and teardown contract: The patch executes this repository's packaged lifecycle CLI and interprets its persisted session contract. SessionStateStore owns schema-2 identity validation; TeardownOrchestrator acquires the lifecycle lock and SessionCoordinator deprovisions before clearing the session record. The dependency's root policy was read. (src/OpenClaw.Launcher/Session/TeardownOrchestrator.cs:37, 62c79e281fe9)

Likely related people:

  • Karen: Raw commit 839dad2 adds scripts/clean-uninstall.ps1:5 relative to its recorded parents. This identifies author metadata, not feature responsibility or a PR merger. (role: source-line author; confidence: high; commits: 839dad2936c7; files: scripts/clean-uninstall.ps1)
  • Scott Hanselman: Raw commit 3edc9b1 adds .agents/skills/uninstall/SKILL.md:8 relative to its recorded parents. This identifies author metadata, not feature responsibility or a PR merger. (role: source-line author; confidence: medium; commits: 3edc9b1b5b6e; files: .agents/skills/uninstall/SKILL.md)

Review metrics

Metric Value Why it matters
Change size Production +286/-4 lines; tests +248/-0; guidance +89/-1. Growth implements distinct inventory, ownership, consent and deletion checks within the existing standalone owner; no unnecessary added module was identified.

Labels

Label changes:

  • add P2: This is a useful opt-in developer cleanup capability with limited exposure; ordinary installation and cleanup defaults remain unchanged.
  • add merge-risk: 🚨 security-boundary: The new mode invokes package-scoped session destruction and filesystem deletion using persisted ownership evidence, requiring final-effect isolation proof.
  • add rating: 🧂 unranked krab: Overall readiness is 🧂 unranked krab; proof is 🧂 unranked krab and patch quality is 🦐 gold shrimp.
  • add status: 📣 needs proof: The PR needs real behavior proof before ClawSweeper can clear the contributor ask.

Label justifications:

  • P2: This is a useful opt-in developer cleanup capability with limited exposure; ordinary installation and cleanup defaults remain unchanged.
  • merge-risk: 🚨 security-boundary: The new mode invokes package-scoped session destruction and filesystem deletion using persisted ownership evidence, requiring final-effect isolation proof.
  • rating: 🧂 unranked krab: Overall readiness is 🧂 unranked krab; proof is 🧂 unranked krab and patch quality is 🦐 gold shrimp.
  • status: 📣 needs proof: The PR needs real behavior proof before ClawSweeper can clear the contributor ask.

Rank-up moves

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

  • Add native final-effect proof for the selected patch and nearest forbidden patch or session, including stale-preview rejection.
  • Demonstrate preservation of an existing stable installation's settings and data alongside the disposable development patch.

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 October 31, 2026, 12:29 PM ET / 16:29 UTC.

@karkarl
karkarl marked this pull request as ready for review November 4, 2026 23:02
@karkarl
karkarl merged commit e4a92c8 into openclaw:main Nov 5, 2026
23 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

merge-risk: 🚨 security-boundary 🚨 Merging this PR could weaken sandboxing, authorization, credentials, or sensitive data. P2 Normal priority bug or improvement with limited blast radius. rating: 🧂 unranked krab Not merge-ready due to missing proof or serious correctness/safety concerns. 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.

1 participant