Repository navigation
refactor(plugins): stage managed npm installs before publication - #140145
Conversation
|
🦞👀 Pull request received. I will update this pull request when review starts. ClawSweeper review completeClawSweeper finished reviewing this revision. The review result is being finalized. |
|
Codex review: needs maintainer review before merge. Reviewed September 6, 2026, 9:57 AM ET / 13:57 UTC. ClawSweeper reviewWhat this changesPrepare npm plugin installations privately, validate and obtain consent before publication, and use the shared directory transaction for replacement and rollback. Merge readiness✅ Ready for maintainer review This PR remains useful: current main still mutates the managed npm project before artifact consent completes. The introduced changes address that boundary coherently, and no blocking correctness finding was established. Priority: P2 Review scores
Verification
How this fits togetherOpenClaw’s plugin installer turns npm package requests into installed plugin directories. It checks package integrity, dependencies, install policy, and capability consent before returning the location used by plugin loading. flowchart TD
A[Npm package request] --> C[Private installation stage]
B[Existing npm project inputs] --> C
C --> D[Integrity and dependency checks]
D --> E[Install policy and artifact consent]
E -->|Accepted and still authorized| F[Publish plugin directory]
E -->|Rejected or cancelled| G[Discard stage and preserve existing install]
Before mergeNone. Agent review detailsSecurityNone. PR surfaceSource -545, Tests +13, Docs +4, Other -1. Total -529 across 11 files. View PR surface stats
Review metricsNone. Technical reviewBest possible solution: Keep npm preparation and consent inside the shared directory transaction while preserving existing generation paths and restoring the prior project on failed publication. Do we have a high-confidence way to reproduce the issue? Yes, from source: current main materializes the final project before consent and can accept cancellation during that callback without a final publication check. This review did not execute the reproduction. Is this the best way to solve the issue? Yes. Reusing the existing directory transaction removes compensating npm rollback machinery while keeping validation, generation selection, and final mutation checks together. AGENTS.md: found and applied where relevant. Codex review notes: model internal, reasoning medium; reviewed against f33ea5960b50. LabelsLabel changes:
Label justifications:
EvidenceWhat I checked:
Likely related people:
Rating scale
Overall follows the weaker of proof and patch quality. Workflow
|
|
Merged via squash.
|
Managed npm installs wrote into their final project before artifact consent finished. Rejection then depended on copied node_modules snapshots, archive backups, or npm uninstall/peer repair to reconstruct the previous state.
Prepare the candidate in a private stage and let the existing package-directory transaction own publication, backup and rollback. Preserve the current generation-target rules, so older running Gateways can keep using native lazy imports. Existing npm manifest, lock/shrinkwrap, project .npmrc and relative archive inputs carry into the stage; installed node_modules does not. Consent refusal and cancellation before publication preserve the original project. A diagnosed corrupt candidate remains in durable quarantine outside stage cleanup and gets only one rebuild attempt.
This also fixes cancellation during artifact consent: the final mutation callback rechecks the existing AbortSignal before displacing or publishing a target. The original callback error survives stage cleanup unchanged. Dead snapshot/uninstall compensation helpers are removed; main's shared package traversal and peer synchronization are preserved. No runtime foundation, Gateway restart feature, configuration option, environment variable or database schema change is required.
Validation: 174 distinct owner tests passed: 104 managed-npm cases, 15 shared traversal cases and 55 npm-root/directory-publication cases. Causal tests first demonstrated premature target mutation and publication after cancellation. Five real npm 11.19 / Node 24.19 scenarios then passed through the installer API on this standalone candidate: late native dependency/asset imports across a generation update; same-generation deferred rollback; consent refusal with exact error identity; one injected missing-integrity result after actual npm materialization, durable quarantine and rejected rebuilt candidate; cancellation during consent. The real npm proof used generated local packages and isolated state, without a Gateway or credentials. Production source and dependencies match the final candidate byte-for-byte; later changes only capture optional fixture values and rename a test-local variable. The process group closed.
Production LOC: 125 added, 670 removed, net −545. Tests: net +13. Documentation explains staging and quarantine; the assertion baseline shrinks only for deleted casts (5→2 and 2→0). This is an independently landable preparation for #135599.
The complete normal changed-code gate passed against the real main base, including formatting, types, lint, dead exports and repository guards. Independent Codex P0–P2 review was clean (v3); its only subsequent source delta was the test-local
npmRoot→attemptRootrename required by lint. Earlier ratchet/type/lint failures are retained in the local evidence.