Repository navigation
fix(plugins): preserve npm plugin files after uninstall - #134391
Conversation
|
🦞👀 Pull request received. I will update this pull request when review starts. |
|
Codex review: needs maintainer review before merge. Reviewed August 31, 2026, 6:26 PM ET / 22:26 UTC. ClawSweeper reviewWhat this changesThis release-branch PR records an explicit retention reason when Merge readinessKeep 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 Priority: P2 Review scores
Verification
How this fits togetherThe 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]
Decision needed
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
Agent review detailsSecurityNone. PR surfaceSource +34, Tests +188, Other +28. Total +250 across 9 files. View PR surface stats
Review metrics
Stored data modelPersistent data-model change detected: Merge-risk optionsMaintainer options:
Technical reviewBest 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. LabelsLabel changes:
Label justifications:
EvidenceWhat I checked:
Likely related people:
Rank-up movesOptional improvements that raise the rating; they are not merge blockers.
Rating scale
Overall follows the weaker of proof and patch quality. Workflow
HistoryReview history (2 earlier review cycles)
|
|
@clawsweeper re-review |
4c968d7 to
6d18984
Compare
|
🦞🧹 I asked ClawSweeper to review this item again. Re-review progress:
|
6d18984 to
b8860f6
Compare
|
@clawsweeper re-review Addressed the accepted P2: malformed retention-marker JSON is cleanup-eligible again, matching current main. Only a parsed explicit |
|
🦞👀 Re-review progress:
|
Summary
Backport the applicable behavior from #113902 using the 2026.6.35 install-record transaction owner. An explicit
plugins uninstall --keep-filesnow 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 Dockerplugins-offlinelane 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
plugins-offlineafterplugins uninstall demo-plugin-npm --force --keep-files; a freshplugins list --jsonstill containeddemo-plugin-npm.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.pnpm exec oxfmt --check --threads=1 …passed.node scripts/check-changed.mjscould 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-fileslifecycle fact and the cleanup classification required to preserve that public CLI contract.