Repository navigation
fix(plugins): prevent uninstalled npm plugins from coming back - #113902
Conversation
|
Codex review: needs changes before merge. Reviewed August 9, 2026, 10:45 AM ET / 14:45 UTC. ClawSweeper reviewWhat this changesThe PR records an explicit retained state for managed npm plugins removed with Regression provenancePossible regression — suspected (reviewed change). No predecessor PR is attributed. Merge readinessKeep open. Current main still resurrects npm plugins uninstalled with Priority: P2 Review scores
Verification
How this fits togetherThe plugin lifecycle records installed npm packages, startup recovery rebuilds records for untracked packages, and Gateway later cleans retired package generations. A retained uninstall must suppress recovery while telling cleanup that its files remain intentional. flowchart LR
A[Plugin uninstall with keep-files] --> B[Install-record transaction]
B --> C[Retained package marker]
C --> D[Startup recovery]
C --> E[Gateway idle cleanup]
D --> F[Plugin stays unloaded]
E --> G[Package files preserved]
B --> H[Reinstall or ordinary uninstall]
Before merge
Findings
Agent review detailsSecurityNone. PR surfaceSource +89, Tests +320, Other +28. Total +437 across 9 files. View PR surface stats
Review metrics
Stored data modelPersistent data-model change detected: Merge-risk optionsMaintainer options:
Copy recommended automerge instructionTechnical reviewBest possible solution: Before merge, preserve any existing unreadable retention marker during cleanup while retaining cleanup for known valid non-keep marker reasons, with regressions for legacy and generated npm roots. Do we have a high-confidence way to reproduce the issue? Yes, from source: create a managed package with an unreadable retained marker, then run Gateway cleanup; recovery excludes it by marker existence while the proposed classifier makes cleanup delete it. Is this the best way to solve the issue? No. Marking retention in the install-record transaction is the best owner boundary, but unreadable existing markers must be preserved; atomic writes alone would not protect preexisting partial markers. Full review comments:
Overall correctness: patch is incorrect AGENTS.md: found and applied where relevant. Codex review notes: model internal, reasoning high; reviewed against fc9905edb2b8. LabelsLabel changes:
Label justifications:
EvidenceAcceptance criteria:
What 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 (3 earlier review cycles) |
0f087dd to
94753b4
Compare
94753b4 to
39305af
Compare
…law#113902) * fix(plugins): preserve retained uninstall files * test(plugins): track retention temp dirs * fix(plugins): retain rollback marker snapshots
What Problem This Solves
openclaw plugins uninstall <id> --force --keep-filesremoved the install record but left the managed npm package unmarked. A fresh process then recovered that package from disk, rebuilt the install record, and loaded the plugin again.The stale PR's marker-only repair had a second bug: Gateway idle cleanup deletes inactive marked generations, so it would have converted resurrection into delayed deletion of files the user explicitly asked to keep.
Why This Change Was Made
The canonical install-record transaction now retires retained managed npm packages while it owns the current plugin lifecycle lease and receipt-conditional rollback. It validates managed npm root ownership, protects active direct and symlinked paths, and compensates marker changes only when the tentative index revision is still current.
The marker reason distinguishes two lifecycle facts at their owner: ordinary retired generations remain cleanup-eligible, while an explicit
--keep-filesretirement suppresses recovery but is never deleted by Gateway idle cleanup. Reinstall uses the existing active-record path to clear the marker. Each cleared marker is recorded for rollback immediately, so a later filesystem failure cannot leave an earlier package recoverable after the index revision is restored.No recovery fallback was disabled and no second index/config path was added. No config key, environment variable, default, public/plugin API, protocol, schema, or storage location changes.
User Impact
An npm plugin uninstalled with
--keep-filesstays uninstalled across fresh CLI/Gateway processes and its package/dependency files remain on disk. Reinstall works normally, and a later ordinary uninstall still removes the managed files. npm-to-npm/source-change and doctor-retired generations remain cleanup-eligible.Evidence
src/plugins/install-record-commit.tsrequired both previous and next records to be npm, but keep-files uninstall removes the next record insrc/cli/plugins-uninstall-command.ts; recovery accepts an unmarked package insrc/plugins/installed-plugin-index-record-reader.ts.hasRetainedManagedNpmInstallMarkerreturned false after the install record was removed.corepack pnpm test:docker:pluginspassed the real install → update → keep-files uninstall → fresh-process absence/files-preserved → reinstall → ordinary uninstall lifecycle on Testboxtbx_01kzk8gkk5yh63se73yj6x10hq: https://github.com/openclaw/openclaw/actions/runs/31313803490tbx_01kzkemkmvfc25s48qnx7yqr0r(exitCode=0), including production/test typechecks, core and script lint, formatting, SDK/plugin boundaries, storage/schema, cycles, webhook, and pairing guards: https://github.com/openclaw/openclaw/actions/runs/31318414416ClawSweeper rank-up moves
Migration
No doctor migration is possible or appropriate: historical on-disk packages do not record whether the missing ledger entry came from deliberate
--keep-filesor recoverable index loss. Affected users can rerun the explicit keep-files uninstall after upgrading.