Skip to content

fix(plugins): uninstall fully removes isolated npm plugin files - #123973

Merged
steipete merged 2 commits into
mainfrom
fix/autoqa-refill-plugin-package-v2
Aug 15, 2026
Merged

steipete merged 2 commits into
mainfrom
fix/autoqa-refill-plugin-package-v2

Conversation

@steipete

@steipete steipete commented Aug 15, 2026 •

Copy link
Copy Markdown
Contributor

Closes #123972

What Problem This Solves

Fixes an issue where users who normally uninstalled an npm-managed plugin would still have its isolated OpenClaw npm project left on disk, including cached pack archives, package metadata, and transitive dependency debris.

Why This Change Was Made

The uninstall owner now treats an exactly validated per-plugin npm project as the removal target, while shared legacy npm roots continue to remove only the selected package. The package-path equality check prevents ambiguous or nested records from widening deletion, and replaced npm generations continue to retain the original package path for running-process safety.

This is the canonical lifecycle-owner cleanup: no fallback, compatibility shim, config key, public API/Plugin SDK surface, protocol, dependency, security boundary, persistence contract, or schema changes.

Failed-install compensation consumes the same uninstall plan. When persistence fails after an npm install, it now accepts the wider project target only when the planner identifies npm cleanup, the target exactly equals that cleanup's npm root, and the newly installed package is contained within it. Shared or ambiguous targets remain refused.

User Impact

Ordinary plugin uninstall now removes all OpenClaw-owned files for that isolated npm plugin project. Shared roots remain intact, and --keep-files plus retained update generations keep their existing behavior.

Evidence

  • Before the fix, the focused regression failed because the per-plugin project root still existed after uninstall.

  • node scripts/run-vitest.mjs src/plugins/management-service.test.ts src/plugins/management-service.install-compensation.test.ts src/plugins/uninstall.test.ts src/plugins/install-record-commit.test.ts src/plugins/install-record-commit.retention.test.ts — 126 tests passed, including a real-planner persistence-conflict regression that removes the isolated project and cached pack archive.

  • node_modules/.bin/oxfmt --check --no-error-on-unmatched-pattern -- scripts/e2e/lib/plugins/assertions.mjs src/plugins/install-record-commit.ts src/plugins/management-service.install-compensation.test.ts src/plugins/management-service.ts src/plugins/uninstall.test.ts src/plugins/uninstall.ts and git diff --check origin/main...HEAD — passed.

  • node scripts/check-changed.mjs -- scripts/e2e/lib/plugins/assertions.mjs src/plugins/install-record-commit.ts src/plugins/management-service.install-compensation.test.ts src/plugins/management-service.ts src/plugins/uninstall.test.ts src/plugins/uninstall.ts — full changed gate passed. The ci-fast remote route had no ready provider, so the wrapper used its explicit trusted local fallback.

  • OPENCLAW_PLUGINS_E2E_CLAWHUB=0 pnpm test:docker:plugins — passed against the exact rebased commit. The lane built and validated the OpenClaw tarball, installed it source-absent in Docker with npm install --omit=dev, exercised plugin install/runtime/update/keep-files/reinstall, and proved ordinary uninstall removes the isolated project root and dependency debris.

  • .agents/skills/autoreview/scripts/autoreview --mode branch --base origin/main — TruffleHog clean; one complete Codex pass over the final six-file branch; no accepted/actionable findings.

  • ClawSweeper's P2 failed-install compensation finding was accepted and repaired. Its rank-up moves are applied: compensation recognizes only the validated isolated npm target, and the new regression uses the real planner and proves the project root is removed.

Production LOC: +19/-10 (net +9). The bounded growth is the exact package-path ownership guard plus the compensation check that preserves cleanup only for the planner-validated isolated npm root.

Tests and E2E support: +69/-1 (net +68).

No CHANGELOG.md edit. AI-assisted and maintainer-approved for landing.

@clawsweeper

clawsweeper Bot commented Aug 15, 2026

Copy link
Copy Markdown
Contributor

🦞👀
ClawSweeper picked this up.

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

@steipete steipete self-assigned this Aug 15, 2026
@openclaw-barnacle openclaw-barnacle Bot added the scripts Repository scripts label Aug 15, 2026
@steipete
steipete marked this pull request as ready for review August 15, 2026 03:12
@openclaw-barnacle openclaw-barnacle Bot added size: XS maintainer Maintainer-authored PR labels Aug 15, 2026
@clawsweeper clawsweeper Bot added merge-risk: 🚨 other 🚨 Merging this PR has meaningful risk outside the owned taxonomy. P2 Normal backlog priority with limited blast radius. 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 Aug 15, 2026
@clawsweeper

clawsweeper Bot commented Aug 15, 2026 •

Copy link
Copy Markdown
Contributor

Codex review: needs changes before merge. Reviewed August 14, 2026, 11:59 PM ET / August 15, 2026, 03:59 UTC.

ClawSweeper review

What this changes

The PR changes npm-managed plugin uninstall so a validated isolated per-plugin npm project, including its package artifacts and dependencies, is removed as one lifecycle-owned unit.

Regression provenance

Possible regression — probable (reproduction; reviewed change). No predecessor PR is attributed.

Merge readiness

⚠️ Ready for maintainer review - 3 items remain

Keep this maintainer-authored PR open: it fixes the reported isolated-project leak, but the new recursive root target is not restricted to a canonical OpenClaw project root.

Priority: P2
Reviewed head: c5b62918eaa7f1cdb4417bb0d8ebee0462f43ab7

Review scores

Measure Result What it means
Overall readiness 🦐 gold shrimp (3/6) The central behavior is well targeted, but the widened deletion scope needs one ownership-safety repair.
Proof confidence 🌊 off-meta tidepool Not applicable: This maintainer-authored PR reports a packaged Docker lifecycle run; the external-contributor proof gate does not apply.
Patch quality 🦐 gold shrimp (3/6) Security review found an item that needs attention.

Verification

Check Result Evidence
Real behavior Not applicable Not applicable: This maintainer-authored PR reports a packaged Docker lifecycle run; the external-contributor proof gate does not apply.
Evidence reviewed 5 items Current-main defect: Current main returns the package directory for an install below a project root, leaving project-level archives and dependencies behind.
Incomplete final-head ownership check: The PR derives a deletion root from any first segment beneath npm/projects and verifies only the package leaf before returning that root for removal.
Canonical root contract: The install owner creates only the canonical package project root or a package-prefixed generation root, providing the missing ownership predicate.
Findings 1 actionable finding [P1] Restrict project-root removal to canonical managed roots
Security Needs attention Noncanonical project root can be recursively removed: A malformed or stale install record under the managed projects parent can select its parent directory for recursive deletion without proving it was generated for that package.

How this fits together

Plugin installation creates isolated npm project roots below OpenClaw state, and the management service uses the uninstall planner for ordinary removal and persistence-failure compensation. The planner selects a filesystem target, then npm cleanup and directory removal remove package artifacts before the plugin registry refreshes.

flowchart LR
  A[Plugin install record] --> B[Uninstall planner]
  B --> C{Owned isolated project?}
  C -->|yes| D[Remove project root]
  C -->|no| E[Remove package directory only]
  D --> F[Registry refresh]
  E --> F
Loading

Before merge

  • Restrict project-root removal to canonical managed roots (P1) - The new leaf comparison accepts any npm/projects/<name>/node_modules/<package> record, then recursively removes <name>. Compare that root with OpenClaw’s canonical package or generation root before widening deletion, and add the noncanonical sibling case.
  • Resolve security concern: Noncanonical project root can be recursively removed - A malformed or stale install record under the managed projects parent can select its parent directory for recursive deletion without proving it was generated for that package.
  • Resolve merge risk (P1) - Merging this form lets a crafted or stale npm install record make ordinary uninstall recursively remove an arbitrary sibling project beneath OpenClaw’s shared npm/projects directory.

Findings

  • [P1] Restrict project-root removal to canonical managed roots — src/plugins/uninstall.ts:217-230
  • [medium] Noncanonical project root can be recursively removed — src/plugins/uninstall.ts:217
Agent review details

Security

Needs attention: The widened recursive deletion target lacks a complete ownership check.

PR surface

Source +9, Tests +60, Other +8. Total +77 across 6 files.

View PR surface stats
Area Files Added Removed Net
Source 3 19 10 +9
Tests 2 61 1 +60
Docs 0 0 0 0
Config 0 0 0 0
Generated 0 0 0 0
Other 1 8 0 +8
Total 6 88 11 +77

Review metrics

Metric Value Why it matters
Production versus test LOC production +19/-10 (net +9); tests and E2E support +69/-1 (net +68) The bug fix adds deletion-authorization logic, so its positive production delta requires a complete ownership guard.

Root-cause cluster

Relationship: fixed_by_candidate
Canonical: #123972
Summary: This PR is the linked candidate repair for the isolated npm-project cleanup bug, with one remaining safety correction.

Members:

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

Merge-risk options

Maintainer options:

  1. Constrain project-root ownership (recommended)
    Verify the root against OpenClaw’s ordinary or generation project naming before allowing recursive removal, and cover a noncanonical sibling record.
  2. Pause the root-removal change
    Keep package-directory cleanup until the project-root ownership predicate is implemented and verified.
Copy recommended automerge instruction
@clawsweeper automerge

Special instructions:
Constrain isolated npm-root deletion to canonical project roots and add a regression for a noncanonical sibling under npm/projects.

Technical review

Best possible solution:

Require the selected root to equal the canonical ordinary project directory for the package or a package-prefixed generation root, then prove a noncanonical sibling remains untouched.

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

Yes, from source: a record at npm/projects/<noncanonical>/node_modules/<package> passes the final-head leaf check and selects <noncanonical> for recursive removal.

Is this the best way to solve the issue?

No; project-root cleanup is the right boundary for canonical isolated projects, but the current guard proves only package-leaf shape rather than OpenClaw ownership of that root.

Full review comments:

  • [P1] Restrict project-root removal to canonical managed roots — src/plugins/uninstall.ts:217-230
    The new leaf comparison accepts any npm/projects/&lt;name>/node_modules/&lt;package> record, then recursively removes &lt;name>. Compare that root with OpenClaw’s canonical package or generation root before widening deletion, and add the noncanonical sibling case.
    Confidence: 0.94

Overall correctness: patch is incorrect
Overall confidence: 0.94

AGENTS.md: found and applied where relevant.

Codex review notes: model internal, reasoning high; reviewed against 103e1a4cc9de.

Labels

Label changes:

  • add merge-risk: 🚨 security-boundary: The patch widens recursive deletion from one package directory to a project root without fully proving ownership of that root.
  • remove merge-risk: 🚨 other: Current PR review merge-risk labels are merge-risk: 🚨 security-boundary.

Label justifications:

  • P2: This repairs a bounded plugin lifecycle defect and needs one focused ownership-safety correction.
  • merge-risk: 🚨 security-boundary: The patch widens recursive deletion from one package directory to a project root without fully proving ownership of that root.
  • rating: 🦐 gold shrimp: Overall readiness is 🦐 gold shrimp; proof is 🌊 off-meta tidepool and patch quality is 🦐 gold shrimp.
  • status: ⏳ waiting on author: ClawSweeper has contributor-facing work open and is waiting for author action. Not applicable: This maintainer-authored PR reports a packaged Docker lifecycle run; the external-contributor proof gate does not apply.

Evidence

Security concerns:

  • [medium] Noncanonical project root can be recursively removed — src/plugins/uninstall.ts:217
    A malformed or stale install record under the managed projects parent can select its parent directory for recursive deletion without proving it was generated for that package.
    Confidence: 0.94

Acceptance criteria:

  • [P1] node scripts/run-vitest.mjs src/plugins/uninstall.test.ts src/plugins/management-service.install-compensation.test.ts.
  • [P1] node scripts/check-changed.mjs -- src/plugins/uninstall.ts src/plugins/uninstall.test.ts src/plugins/management-service.ts src/plugins/management-service.install-compensation.test.ts.

What I checked:

Likely related people:

  • steipete: Authored both focused commits in this PR, including the final compensation repair. (role: current lifecycle repair contributor; confidence: high; commits: 6d211475b5f8, c5b62918eaa7; files: src/plugins/uninstall.ts, src/plugins/management-service.ts)
  • ClawSweeper: Current-main blame attributes the pre-fix project resolver to this commit author. (role: current-main source author; confidence: medium; commits: d8cbcf64e53c; files: src/plugins/uninstall.ts)

Rank-up moves

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

  • Constrain root selection to canonical project naming and add the stale/noncanonical-record regression.

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.

History

Review history (1 earlier review cycle)
  • reviewed 2026-08-15T03:18:21.617Z sha 78ec8a8d238d67c57b96ac66d883ad9475e53515 :: needs changes before merge. :: [P2] Preserve failed-install cleanup for isolated npm projects

Ordinary uninstall now removes the whole owner-managed per-plugin npm project, including packed archives and transitive dependency debris, while shared roots and retained update generations keep their existing lifecycle behavior.
Allow persistence-failure compensation to remove only a planner-validated isolated npm project root, while continuing to reject shared or ambiguous cleanup targets.
@steipete
steipete force-pushed the fix/autoqa-refill-plugin-package-v2 branch from 78ec8a8 to c5b6291 Compare August 15, 2026 03:50
@steipete

Copy link
Copy Markdown
Contributor Author

Addressed the actionable ClawSweeper finding on final head c5b62918eaa7f1cdb4417bb0d8ebee0462f43ab7.

Failed-install compensation now accepts the wider cleanup target only when the real uninstall plan identifies npm cleanup, the planned target exactly equals that cleanup's npm root, and the newly installed package directory is contained within it. Shared and ambiguous targets remain refused.

The new regression uses the real planner, injects a persistence conflict after an npm install, and proves the isolated project root plus cached pack archive are removed. Final proof: 126 focused tests, full six-file changed gate, source-absent packed Docker plugin lifecycle with npm install --omit=dev, and clean full-branch Codex autoreview. Both listed rank-up moves are applied.

@clawsweeper clawsweeper Bot added merge-risk: 🚨 security-boundary 🚨 May affect sandboxing, authorization, credentials, or sensitive data. and removed merge-risk: 🚨 other 🚨 Merging this PR has meaningful risk outside the owned taxonomy. labels Aug 15, 2026
@steipete
steipete merged commit d6e6d67 into main Aug 15, 2026
196 checks passed
@steipete

Copy link
Copy Markdown
Contributor Author

Merged via squash.

@steipete
steipete deleted the fix/autoqa-refill-plugin-package-v2 branch August 15, 2026 04:03
github-actions Bot pushed a commit to Desicool/openclaw that referenced this pull request Aug 15, 2026
…claw#123973)

* fix(plugins): remove isolated npm projects on uninstall

Ordinary uninstall now removes the whole owner-managed per-plugin npm project, including packed archives and transitive dependency debris, while shared roots and retained update generations keep their existing lifecycle behavior.

* fix(plugins): preserve failed install cleanup

Allow persistence-failure compensation to remove only a planner-validated isolated npm project root, while continuing to reject shared or ambiguous cleanup targets.
RomneyDa pushed a commit that referenced this pull request Sep 3, 2026
)

* fix(plugins): remove isolated npm projects on uninstall

Ordinary uninstall now removes the whole owner-managed per-plugin npm project, including packed archives and transitive dependency debris, while shared roots and retained update generations keep their existing lifecycle behavior.

* fix(plugins): preserve failed install cleanup

Allow persistence-failure compensation to remove only a planner-validated isolated npm project root, while continuing to reject shared or ambiguous cleanup targets.

(cherry picked from commit d6e6d67)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

maintainer Maintainer-authored PR merge-risk: 🚨 security-boundary 🚨 May affect sandboxing, authorization, credentials, or sensitive data. P2 Normal backlog priority with limited blast radius. rating: 🦐 gold shrimp Decent PR readiness signal, but merge confidence is limited. scripts Repository scripts size: S 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.

[Bug]: Plugin uninstall leaves isolated npm project root behind

1 participant