Skip to content

fix(plugins): preserve npm plugin files after uninstall - #134391

Merged
RomneyDa merged 1 commit into
extended-stable/2026.6.33from
codex/backport-es35-retained-npm
Aug 31, 2026
Merged

RomneyDa merged 1 commit into
extended-stable/2026.6.33from
codex/backport-es35-retained-npm

Conversation

@RomneyDa

@RomneyDa RomneyDa commented Aug 31, 2026 •

Copy link
Copy Markdown
Member

Summary

Backport the applicable behavior from #113902 using the 2026.6.35 install-record transaction owner. An explicit plugins uninstall --keep-files now records the managed NPM package as retained before removing its install record, so a fresh process cannot reconstruct that record from the package files.

The marker is limited to the existing managed-NPM uninstall plan and is requested only by --keep-files; a normal uninstall remains unmarked and retains its existing cleanup behavior. Reinstalling an active NPM record clears the marker. Cleanup preserves explicit keep-files markers (and unreadable markers, because recovery already treats marker presence as authoritative).

Root cause and scope

The candidate already removed the persisted install record for --keep-files, but its fresh-list recovery scanned the still-present managed package and reconstructed the record. The Docker plugins-offline lane consequently reported the plugin as installed immediately after a keep-files uninstall.

This is the native 2026.6.35 adaptation of source commit 0fe49c5731f31737b0e7ceab52528d93b01ceddd (#113902), without the newer main install-record lease refactor or any version/SHA-specific condition.

Proof

  • Reproduction: candidate full-validation child 33358560442 failed plugins-offline after plugins uninstall demo-plugin-npm --force --keep-files; a fresh plugins list --json still contained demo-plugin-npm.
  • The Docker regression performs that exact uninstall → fresh-list assertion, confirms package and dependency files remain, reinstalls/uses the plugin, then performs normal uninstall.
  • Focused tests: node scripts/run-vitest.mjs src/cli/plugins-install-record-commit.test.ts src/plugins/managed-npm-retention.test.ts src/plugins/installed-plugin-index-records.test.ts (43 tests passed). These cover the explicit marker, fresh recovery exclusion, normal-uninstall non-marker, active reinstall marker clearing, config-write rollback, and unreadable-marker cleanup safety.
  • Formatting: pnpm exec oxfmt --check --threads=1 … passed. node scripts/check-changed.mjs could not dispatch because the remote Testbox endpoint returned HTTP 429, not because of a source failure.

Design

The transaction is the canonical owner because it atomically moves the install index with the config mutation and already restores newly-created markers on failure. The CLI supplies explicit retention intent; recovery keeps its generic package scan but recognizes the existing marker contract. No config shape, dependency, SQLite schema, package, tag, or release ref changes.

Production delta: +46/-11 lines across the CLI transaction, uninstall caller, and retention owner. Test/E2E delta: +217/-1. The added production code represents the explicit --keep-files lifecycle fact and the cleanup classification required to preserve that public CLI contract.

@clawsweeper

clawsweeper Bot commented Aug 31, 2026

Copy link
Copy Markdown
Contributor

🦞👀
ClawSweeper picked this up.

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

@openclaw-barnacle openclaw-barnacle Bot added cli CLI command changes scripts Repository scripts size: M maintainer Maintainer-authored PR labels Aug 31, 2026
@clawsweeper clawsweeper Bot added P2 Normal backlog priority with limited blast radius. rating: 🐚 platinum hermit Good normal PR readiness with ordinary maintainer review expected. status: 👀 ready for maintainer look ClawSweeper has no concrete contributor-facing blocker left for this PR. labels Aug 31, 2026
@clawsweeper

clawsweeper Bot commented Aug 31, 2026 •

Copy link
Copy Markdown
Contributor

Codex review: needs maintainer review before merge. Reviewed August 31, 2026, 6:26 PM ET / 22:26 UTC.

ClawSweeper review

What this changes

This release-branch PR records an explicit retention reason when plugins uninstall --keep-files removes a managed npm plugin’s install record, preventing fresh discovery from restoring it while preserving the package files.

Merge readiness

⚠️ Ready for maintainer review - 2 items remain

Keep open for normal maintainer review: this protected, member-authored release-branch backport resolves the prior malformed-marker concern and has no blocking code finding. The merged main counterpart, #113902, confirms the root behavior, but inclusion in extended-stable/2026.6.33 remains a release-owner decision.

Priority: P2
Reviewed head: b8860f62754bd0b226e4f1258d96936836110f1a
Owner decision: Required. See Decision needed.

Review scores

Measure Result What it means
Overall readiness 🐚 platinum hermit (4/6) The focused transaction, recovery, cleanup, and packaged lifecycle coverage support a sound bounded backport with no remaining code finding.
Proof confidence 🌊 off-meta tidepool Not applicable: Not applicable to the external-contributor proof gate because the PR author is a repository member; the changed E2E scenario nevertheless maps the CLI command to fresh-process recovery, retained files, reinstall, and ordinary cleanup.
Patch quality 🐚 platinum hermit (4/6) No actionable review findings were identified.

Verification

Check Result Evidence
Real behavior Not applicable Not applicable: Not applicable to the external-contributor proof gate because the PR author is a repository member; the changed E2E scenario nevertheless maps the CLI command to fresh-process recovery, retained files, reinstall, and ordinary cleanup.
Evidence reviewed 6 items Keep-files intent reaches the transaction owner: The CLI plans no directory deletion for --keep-files, removes the install record, and passes the removed plugin id only when file retention was requested; the transaction then validates that the previous path is a managed npm install before writing a marker.
Recovery and cleanup preserve the intended distinction: Fresh managed-npm recovery excludes packages with a marker, while cleanup now retains only a parsed marker carrying the explicit keep-files reason; malformed marker JSON remains cleanup-eligible.
Prior review finding is addressed at the introduced lines: The current head introduced a parser that returns false for malformed marker content, replacing the earlier broad preservation behavior identified in the preceding review cycle.
Findings None None.
Security None None.

How this fits together

The plugins CLI removes configuration and the persisted install record, while npm-plugin discovery may reconstruct records from managed package directories on the next process. Retention markers bridge those lifecycle stages so deliberate file preservation neither reloads the plugin nor causes Gateway cleanup to delete it.

flowchart LR
  A[Plugins uninstall command] --> B[Install-record transaction]
  B --> C[Retention marker]
  C --> D[Fresh plugin discovery]
  C --> E[Gateway startup cleanup]
  D --> F[Plugin list and runtime]
  E --> G[Preserved or removed package files]
Loading

Decision needed

Question Recommendation
Should extended-stable/2026.6.33 receive this keep-files lifecycle backport, accepting that historical unmarked retained installs need one explicit rerun after upgrade? Include after stable-head lifecycle confirmation: Accept the backport after the exact-head packaged uninstall, fresh-list, reinstall, and ordinary-uninstall lifecycle completes successfully.

Why: The code matches the documented contract and merged main counterpart, but deciding whether this behavioral repair belongs in the extended-stable train is a release-support choice rather than an automated correctness conclusion.

Before merge

  • Resolve merge risk (P1) - This stable-branch backport changes durable retention-marker semantics; installs already uninstalled with --keep-files before the backport have no marker and require the documented explicit uninstall to be rerun rather than receiving an automatic migration.
Agent review details

Security

None.

PR surface

Source +34, Tests +188, Other +28. Total +250 across 9 files.

View PR surface stats
Area Files Added Removed Net
Source 3 45 11 +34
Tests 4 196 8 +188
Docs 0 0 0 0
Config 0 0 0 0
Generated 0 0 0 0
Other 2 28 0 +28
Total 9 269 19 +250

Review metrics

Metric Value Why it matters
Retention-marker states 1 explicit preservation reason added The existing marker gains a durable distinction between user-requested file retention and ordinary cleanup-eligible retirement.

Stored data model

Persistent data-model change detected: serialized state: src/plugins/managed-npm-retention.ts, unknown-data-model-change: src/plugins/managed-npm-retention.ts. Confirm migration or upgrade compatibility proof before merge.

Merge-risk options

Maintainer options:

  1. Hold for stable-head lifecycle confirmation (recommended)
    Before merging, confirm the exact release-branch head preserves files, omits the plugin from a fresh process, permits reinstall, and still removes files on ordinary uninstall.
  2. Accept the historical-state limitation
    Merge with the documented understanding that older unmarked keep-files uninstalls are repaired only when the operator reruns the explicit command.

Technical review

Best possible solution:

Keep the transaction-owned marker design, land it only if the release owner accepts the one-time rerun limitation for historical retained installs, and confirm the exact stable-head packaged lifecycle before merge.

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

Yes. The pre-patch transaction required a next npm record even though keep-files uninstall removes that record, while fresh discovery restores an unmarked managed package; the added Docker scenario exercises that exact lifecycle.

Is this the best way to solve the issue?

Yes. Recording explicit retention at the install-record transaction is the narrowest owner boundary; moving the exception into generic discovery would leave lifecycle intent implicit and create recovery-policy drift.

AGENTS.md: found and applied where relevant.

Codex review notes: model internal, reasoning high; reviewed against 2846c3ca8b0f.

Labels

Label changes:

  • add rating: 🐚 platinum hermit: Overall readiness is 🐚 platinum hermit; proof is 🌊 off-meta tidepool and patch quality is 🐚 platinum hermit.
  • add status: 👀 ready for maintainer look: ClawSweeper has no concrete contributor-facing blocker left for this PR. Not applicable: Not applicable to the external-contributor proof gate because the PR author is a repository member; the changed E2E scenario nevertheless maps the CLI command to fresh-process recovery, retained files, reinstall, and ordinary cleanup.
  • remove rating: 🦐 gold shrimp: Current PR rating is rating: 🐚 platinum hermit, so this older rating label is no longer current.
  • remove status: ⏳ waiting on author: Current PR status label is status: 👀 ready for maintainer look.

Label justifications:

  • P2: The change repairs a bounded plugin lifecycle defect without evidence of emergency availability, security, or data-loss impact.
  • merge-risk: 🚨 compatibility: The backport changes persisted marker interpretation and has a deliberate upgrade limitation for pre-existing unmarked retained installs.
  • rating: 🐚 platinum hermit: Overall readiness is 🐚 platinum hermit; proof is 🌊 off-meta tidepool and patch quality is 🐚 platinum hermit.
  • status: 👀 ready for maintainer look: ClawSweeper has no concrete contributor-facing blocker left for this PR. Not applicable: Not applicable to the external-contributor proof gate because the PR author is a repository member; the changed E2E scenario nevertheless maps the CLI command to fresh-process recovery, retained files, reinstall, and ordinary cleanup.

Evidence

What I checked:

  • Keep-files intent reaches the transaction owner: The CLI plans no directory deletion for --keep-files, removes the install record, and passes the removed plugin id only when file retention was requested; the transaction then validates that the previous path is a managed npm install before writing a marker. (src/cli/plugins-uninstall-command.ts:177, b8860f62754b)
  • Recovery and cleanup preserve the intended distinction: Fresh managed-npm recovery excludes packages with a marker, while cleanup now retains only a parsed marker carrying the explicit keep-files reason; malformed marker JSON remains cleanup-eligible. (src/plugins/managed-npm-retention.ts:14, b8860f62754b)
  • Prior review finding is addressed at the introduced lines: The current head introduced a parser that returns false for malformed marker content, replacing the earlier broad preservation behavior identified in the preceding review cycle. (src/plugins/managed-npm-retention.ts:16, b8860f62754b)
  • Packaged lifecycle coverage follows the user path: The Docker plugins scenario performs uninstall with retained files, starts a fresh CLI listing, asserts the package and dependency remain on disk, reinstalls and runs the plugin, then verifies ordinary uninstall removes it. (scripts/e2e/lib/plugins/sweep.sh:152, b8860f62754b)
  • Existing CLI contract: The docs define --keep-files as retaining managed install directories while uninstall removes the plugin records, so preventing fresh recovery is consistent with the established user-facing contract. Public docs: docs/cli/plugins.md. (docs/cli/plugins.md:378, b8860f62754b)
  • Merged main counterpart: The supplied GitHub context identifies fix(plugins): prevent uninstalled npm plugins from coming back #113902 as a merged main-branch implementation of the same keep-files recovery defect, merged as commit 0fe49c5. This PR is explicitly a stable-branch adaptation rather than redundant main work. (0fe49c5731f3)

Likely related people:

  • steipete: Suggested for follow-up; no historical authorship or introduction is verified. (role: unverified routing candidate; confidence: low)

Rank-up moves

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

  • Confirm the exact stable-head packaged lifecycle before accepting the release-branch backport.

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 (2 earlier review cycles)
  • reviewed 2026-08-31T19:03:37.776Z sha 4c968d77834a5ba42fe71f4e1894e58efeb17149 :: needs maintainer review before merge. :: none
  • reviewed 2026-08-31T19:45:19.633Z sha 6d18984a4f1d294fa60559d551e6e0be9cde7f6e :: needs changes before merge. :: [P2] Keep malformed retention markers cleanup-eligible

@RomneyDa

Copy link
Copy Markdown
Member Author

@clawsweeper re-review

@RomneyDa
RomneyDa force-pushed the codex/backport-es35-retained-npm branch from 4c968d7 to 6d18984 Compare August 31, 2026 19:35
@clawsweeper

clawsweeper Bot commented Aug 31, 2026 •

Copy link
Copy Markdown
Contributor

🦞🧹
ClawSweeper re-review requested.

I asked ClawSweeper to review this item again.
Action: item re-review queued (workflow sweep.yml, event exact_review_queue).
Result: when the review finishes, ClawSweeper will create the durable review comment if needed or update the existing comment in place.

Re-review progress:

@clawsweeper clawsweeper Bot added merge-risk: 🚨 compatibility 🚨 May break existing users, config, migrations, defaults, or upgrade paths. 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. and removed rating: 🐚 platinum hermit Good normal PR readiness with ordinary maintainer review expected. status: 👀 ready for maintainer look ClawSweeper has no concrete contributor-facing blocker left for this PR. labels Aug 31, 2026
@RomneyDa
RomneyDa force-pushed the codex/backport-es35-retained-npm branch from 6d18984 to b8860f6 Compare August 31, 2026 22:20
@RomneyDa

Copy link
Copy Markdown
Member Author

@clawsweeper re-review

Addressed the accepted P2: malformed retention-marker JSON is cleanup-eligible again, matching current main. Only a parsed explicit --keep-files reason now preserves package files. Focused lifecycle coverage: 53 passed.

@clawsweeper

clawsweeper Bot commented Aug 31, 2026 •

Copy link
Copy Markdown
Contributor

🦞👀
Exact review queued.

Re-review progress:

@clawsweeper clawsweeper Bot added rating: 🐚 platinum hermit Good normal PR readiness with ordinary maintainer review expected. status: 👀 ready for maintainer look ClawSweeper has no concrete contributor-facing blocker left for this PR. and removed 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 31, 2026
@RomneyDa
RomneyDa merged commit 1c01739 into extended-stable/2026.6.33 Aug 31, 2026
103 checks passed
@RomneyDa
RomneyDa deleted the codex/backport-es35-retained-npm branch August 31, 2026 22:28
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

cli CLI command changes maintainer Maintainer-authored PR merge-risk: 🚨 compatibility 🚨 May break existing users, config, migrations, defaults, or upgrade paths. P2 Normal backlog priority with limited blast radius. rating: 🐚 platinum hermit Good normal PR readiness with ordinary maintainer review expected. scripts Repository scripts size: M status: 👀 ready for maintainer look ClawSweeper has no concrete contributor-facing blocker left for this PR.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant