Preserve root-managed OpenClaw runtime during plugin installs#81632
Preserve root-managed OpenClaw runtime during plugin installs#81632fuller-stack-dev wants to merge 1 commit into
Conversation
|
Codex review: needs maintainer review before merge. Summary Reproducibility: yes. at source level: current main repairs and scrubs npmRoot/node_modules/openclaw before and after non-openclaw plugin installs whenever that path exists. I did not run a live root-managed install in this read-only review, but the PR body includes after-fix real filesystem proof for the guarded path. Real behavior proof Next step before merge Security Review detailsBest possible solution: Land this focused guard, or fold the same active-host preservation behavior into the broader managed peer-planning work while preserving stale non-host peer cleanup. Do we have a high-confidence way to reproduce the issue? Yes, at source level: current main repairs and scrubs npmRoot/node_modules/openclaw before and after non-openclaw plugin installs whenever that path exists. I did not run a live root-managed install in this read-only review, but the PR body includes after-fix real filesystem proof for the guarded path. Is this the best way to solve the issue? Yes. The realpath equality guard is a narrow maintainable fix for avoiding active-host deletion while leaving stale non-host peer cleanup intact; the main open question is whether to land it separately or reconcile it with #81450. Acceptance criteria:
What I checked:
Likely related people:
Remaining risk / open question:
Codex review notes: model gpt-5.5, reasoning high; reviewed against 256377c029f6. |
Plan managed npm peer dependency pins from npm's lockfile planner instead of recursively scanning nested node_modules packages, preserving host peer ranges when npm cannot produce a usable root pin. Also preserves active root-managed OpenClaw host runtimes during npm plugin installs, folding the active-host guard/test from #81632. Verification: - codex-review --full-access - pnpm check:test-types - pnpm exec oxfmt --check --threads=1 src/infra/npm-managed-root.ts src/infra/npm-managed-root.test.ts src/plugins/install.npm-spec.test.ts CHANGELOG.md test/scripts/mantis-build-telegram-desktop-proof-evidence.test.ts && git diff --check - OPENCLAW_VITEST_MAX_WORKERS=1 pnpm test src/infra/npm-managed-root.test.ts src/plugins/install.npm-spec.test.ts -- --reporter=verbose - OPENCLAW_VITEST_MAX_WORKERS=1 node scripts/test-projects.mjs src/plugins/install.npm-spec.e2e.test.ts -- --reporter=verbose - node scripts/run-vitest.mjs run --config test/vitest/vitest.full-core-support-boundary.config.ts test/scripts/mantis-build-telegram-desktop-proof-evidence.test.ts --reporter=verbose - GitHub current-head checks: 55 completed, 0 failures; remaining Blacksmith-backed jobs capacity-queued at merge decision time. Co-authored-by: fuller-stack-dev <263060202+fuller-stack-dev@users.noreply.github.com>
|
Thanks @fuller-stack-dev. I folded the active-host guard and tests from this PR into #81450, which has now landed on Contributor credit was preserved with your |
Plan managed npm peer dependency pins from npm's lockfile planner instead of recursively scanning nested node_modules packages, preserving host peer ranges when npm cannot produce a usable root pin. Also preserves active root-managed OpenClaw host runtimes during npm plugin installs, folding the active-host guard/test from openclaw#81632. Verification: - codex-review --full-access - pnpm check:test-types - pnpm exec oxfmt --check --threads=1 src/infra/npm-managed-root.ts src/infra/npm-managed-root.test.ts src/plugins/install.npm-spec.test.ts CHANGELOG.md test/scripts/mantis-build-telegram-desktop-proof-evidence.test.ts && git diff --check - OPENCLAW_VITEST_MAX_WORKERS=1 pnpm test src/infra/npm-managed-root.test.ts src/plugins/install.npm-spec.test.ts -- --reporter=verbose - OPENCLAW_VITEST_MAX_WORKERS=1 node scripts/test-projects.mjs src/plugins/install.npm-spec.e2e.test.ts -- --reporter=verbose - node scripts/run-vitest.mjs run --config test/vitest/vitest.full-core-support-boundary.config.ts test/scripts/mantis-build-telegram-desktop-proof-evidence.test.ts --reporter=verbose - GitHub current-head checks: 55 completed, 0 failures; remaining Blacksmith-backed jobs capacity-queued at merge decision time. Co-authored-by: fuller-stack-dev <263060202+fuller-stack-dev@users.noreply.github.com>
Plan managed npm peer dependency pins from npm's lockfile planner instead of recursively scanning nested node_modules packages, preserving host peer ranges when npm cannot produce a usable root pin. Also preserves active root-managed OpenClaw host runtimes during npm plugin installs, folding the active-host guard/test from openclaw#81632. Verification: - codex-review --full-access - pnpm check:test-types - pnpm exec oxfmt --check --threads=1 src/infra/npm-managed-root.ts src/infra/npm-managed-root.test.ts src/plugins/install.npm-spec.test.ts CHANGELOG.md test/scripts/mantis-build-telegram-desktop-proof-evidence.test.ts && git diff --check - OPENCLAW_VITEST_MAX_WORKERS=1 pnpm test src/infra/npm-managed-root.test.ts src/plugins/install.npm-spec.test.ts -- --reporter=verbose - OPENCLAW_VITEST_MAX_WORKERS=1 node scripts/test-projects.mjs src/plugins/install.npm-spec.e2e.test.ts -- --reporter=verbose - node scripts/run-vitest.mjs run --config test/vitest/vitest.full-core-support-boundary.config.ts test/scripts/mantis-build-telegram-desktop-proof-evidence.test.ts --reporter=verbose - GitHub current-head checks: 55 completed, 0 failures; remaining Blacksmith-backed jobs capacity-queued at merge decision time. Co-authored-by: fuller-stack-dev <263060202+fuller-stack-dev@users.noreply.github.com>
Plan managed npm peer dependency pins from npm's lockfile planner instead of recursively scanning nested node_modules packages, preserving host peer ranges when npm cannot produce a usable root pin. Also preserves active root-managed OpenClaw host runtimes during npm plugin installs, folding the active-host guard/test from openclaw#81632. Verification: - codex-review --full-access - pnpm check:test-types - pnpm exec oxfmt --check --threads=1 src/infra/npm-managed-root.ts src/infra/npm-managed-root.test.ts src/plugins/install.npm-spec.test.ts CHANGELOG.md test/scripts/mantis-build-telegram-desktop-proof-evidence.test.ts && git diff --check - OPENCLAW_VITEST_MAX_WORKERS=1 pnpm test src/infra/npm-managed-root.test.ts src/plugins/install.npm-spec.test.ts -- --reporter=verbose - OPENCLAW_VITEST_MAX_WORKERS=1 node scripts/test-projects.mjs src/plugins/install.npm-spec.e2e.test.ts -- --reporter=verbose - node scripts/run-vitest.mjs run --config test/vitest/vitest.full-core-support-boundary.config.ts test/scripts/mantis-build-telegram-desktop-proof-evidence.test.ts --reporter=verbose - GitHub current-head checks: 55 completed, 0 failures; remaining Blacksmith-backed jobs capacity-queued at merge decision time. Co-authored-by: fuller-stack-dev <263060202+fuller-stack-dev@users.noreply.github.com>
Summary
.openclaw/npm/node_modules/openclawis the active OpenClaw runtime, not disposable plugin peer debris.repairManagedNpmRootOpenClawPeernow detects when the managed-rootnode_modules/openclawrealpath matches the active host package root and skips cleanup in that case.openclawpeer cleanup still runs whennode_modules/openclawis not the active host runtime.Change Type (select all)
Scope (select all touched areas)
Linked Issue/PR
Real behavior proof
openclawruntime package instead of treating it as stale peer debris.codex/preserve-host-runtime-plugin-installs, Node via repo toolchain, temporary real managed npm root under/var/folders/.../T, no mocks and no test runner.node --import tsx --input-type=modulescript that created a real managed npm root withpackage.json,package-lock.json,node_modules/openclaw,.bin/openclaw, anddist/cli/gateway-lifecycle.runtime.js, then called the patchedrepairManagedNpmRootOpenClawPeeragainst that active host package.false, did not invoke npm uninstall/prune, and the active host package, lockfile entry, CLI shim, and gateway lifecycle runtime file remained present.ERR_MODULE_NOT_FOUNDfor/Users/jason/.openclaw/npm/node_modules/openclaw/dist/cli/gateway-lifecycle.runtime.jsafter plugin install activity mutated the same managed npm root.Root Cause (if applicable)
openclawpackage. The stale peer cleanup path assumed any root-levelnode_modules/openclawwas plugin peer debris.node_modules/openclawrealpath with the active OpenClaw package root before uninstalling or scrubbing it.dependencies.openclawentry can cause npm to materialize or mutate root-levelopenclawstate during plugin install.Regression Test Plan (if applicable)
src/infra/npm-managed-root.test.tsandsrc/plugins/install.npm-spec.test.ts.openclawpeer packages are still cleaned up.User-visible / Behavior Changes
OpenClaw plugin installs are less likely to break the currently running root-managed OpenClaw runtime when a plugin dependency graph references
openclaw.Diagram (if applicable)
Security Impact (required)
Yes, explain risk + mitigation: N/ARepro + Verification
Environment
openclaw@2026.5.12-beta.6and@xdarkicex/openclaw-memory-libravdb@1.4.69Steps
node_modules/openclawis the active host package.Expected
node_modules/openclawremains installed.Actual
repair_result=false,bin_still_exists=true, andgateway_lifecycle_runtime_still_exists=true.pnpm exec oxfmt --check --threads=1 src/infra/npm-managed-root.ts src/infra/npm-managed-root.test.ts src/plugins/install.npm-spec.test.tspassed.OPENCLAW_VITEST_MAX_WORKERS=1 node scripts/test-projects.mjs src/infra/npm-managed-root.test.ts src/plugins/install.npm-spec.test.tspassed with 12 infra tests and 33 plugin tests.Verification
pnpm exec oxfmt --check --threads=1 src/infra/npm-managed-root.ts src/infra/npm-managed-root.test.ts src/plugins/install.npm-spec.test.tsOPENCLAW_VITEST_MAX_WORKERS=1 node scripts/test-projects.mjs src/infra/npm-managed-root.test.ts src/plugins/install.npm-spec.test.ts