fix(doctor): repair managed plugin openclaw peer links#77412
Conversation
|
Codex review: needs real behavior proof before merge. Summary Reproducibility: yes. by source inspection. Current main lacks the doctor peer-link audit/repair path, and the PR head still has a concrete read-only audit false-negative when Real behavior proof Next step before merge Security Review findings
Review detailsBest possible solution: Keep the doctor-owned repair boundary, make read-only doctor report host-root resolution failures, and require real Do we have a high-confidence way to reproduce the issue? Yes, by source inspection. Current main lacks the doctor peer-link audit/repair path, and the PR head still has a concrete read-only audit false-negative when Is this the best way to solve the issue? Not yet. Doctor is the right repair boundary for managed npm peer-link drift, but the PR should report host-root audit failures and include real behavior proof before it is the best merge candidate. Full review comments:
Overall correctness: patch is incorrect Acceptance criteria:
What I checked:
Likely related people:
Remaining risk / open question:
Codex review notes: model gpt-5.5, reasoning high; reviewed against f863447fe165. Re-review progress:
|
There was a problem hiding this comment.
Pull request overview
This PR extends doctor’s managed-plugin repair flow so OpenClaw can restore missing/stale package-local openclaw peer links for managed npm plugins, which helps plugin SDK imports keep resolving after npm drift or updates.
Changes:
- Added managed npm peer-link detection/repair for plugins that declare
peerDependencies.openclaw. - Ran that repair before missing configured plugin install repair in the doctor fix sequence.
- Documented the behavior in CLI/gateway docs and added a changelog entry.
Reviewed changes
Copilot reviewed 8 out of 8 changed files in this pull request and generated 3 comments.
Show a summary per file
| File | Description |
|---|---|
src/commands/doctor/repair-sequencing.ts |
Inserts peer-link repair into the doctor fix order before missing-plugin installs. |
src/commands/doctor/repair-sequencing.test.ts |
Updates sequencing tests to cover the new repair step ordering. |
src/commands/doctor-plugin-registry.ts |
Adds detection, warning, repair, and refresh hooks for managed npm openclaw peer links. |
src/commands/doctor-plugin-registry.test.ts |
Adds tests for missing/stale peer-link warning and repair behavior. |
docs/gateway/doctor.md |
Documents peer-link repair in gateway doctor docs. |
docs/cli/plugins.md |
Documents peer-link repair in plugin registry docs. |
docs/cli/doctor.md |
Updates doctor CLI notes to mention peer-link relinking. |
CHANGELOG.md |
Adds release note for the new doctor/plugin repair behavior. |
| cwd: process.cwd(), | ||
| }); | ||
| if (!hostRoot) { | ||
| return []; |
| "Managed npm plugin packages are missing their OpenClaw host peer link:", | ||
| ...missingOrStaleLinks.map((link) => `- ${link.packageName}`), | ||
| `Repair with ${formatCliCommand("openclaw doctor --fix")} to relink the host openclaw package for plugin SDK imports.`, |
| "Repaired OpenClaw host peer link(s) for managed npm plugins:", | ||
| ...repaired.map((link) => `- ${link.packageName}`), |
aad9b4b to
bd43607
Compare
|
Updated this PR after the review comments. Addressed:
Re-ran after rebasing onto current
|
bd43607 to
cd02893
Compare
|
Landing proof for PR 77412:
Known gap: production gateway startup was not exercised; the changed behavior is limited to CLI doctor/install/update repair of plugin-local peer links. Thanks @TheCrazyLex. |
|
Landed on
Thanks @TheCrazyLex. Re-review progress:
|
"## Summary\n- Repair missing or stale host
openclawpeer links for managed npm plugins that declarepeerDependencies.openclaw.\n- Warn in read-only doctor mode, and relink<plugin>/node_modules/openclawduringopenclaw doctor --fixbefore missing-plugin install repair runs.\n- Document the repair path and add changelog coverage for theopenclaw/plugin-sdk/*import failure.\n\n## Verification\n-corepack pnpm exec oxfmt --check --threads=1 CHANGELOG.md docs/cli/doctor.md docs/cli/plugins.md docs/gateway/doctor.md src/commands/doctor-plugin-registry.ts src/commands/doctor-plugin-registry.test.ts src/commands/doctor/repair-sequencing.ts src/commands/doctor/repair-sequencing.test.ts\n-git diff --check\n-corepack pnpm test src/commands/doctor-plugin-registry.test.ts src/commands/doctor/repair-sequencing.test.ts\n-codex review --base origin/main\n-corepack pnpm changed:lanes --jsonselected the core, coreTests, and docs lanes; I did not run the broad changed gate locally because this machine does not have Blacksmith/Testbox available and the repository guidance routes broad changed gates through Testbox.\n\ncorepack pnpm installcompleted successfully before validation. It logged an optional@discordjs/opusnative build fallback failure on this ARM/Node 25 environment, but pnpm exited 0 and the targeted checks above passed.\n\n## AI-assisted\n- AI-assisted: yes, prepared with Codex.\n- Testing: targeted local tests, formatting, diff whitespace checks, lane selection, and Codex review completed.\n- I understand the change: doctor now restores the hostopenclawpeer link that package-local managed npm plugin runtimes need foropenclaw/plugin-sdk/*imports, without running npm or modifying unrelated dependencies.\n"Real behavior proof
peerDependencies.openclawbut are missing<plugin>/node_modules/openclaware now reported by read-onlyopenclaw doctor, andopenclaw doctor --fixrelinks them.OPENCLAW_STATE_DIR=/tmp/openclaw-peer-proof.Aujcax/state, OpenClaw CLI2026.5.12-beta.1 (974f3df).peerDependencies.openclawand nonode_modules/openclaw, then ranpnpm openclaw doctor --non-interactive,pnpm openclaw doctor --non-interactive --fix, and inspected the resulting link with Nodefs.lstatSync/fs.realpathSync.openclaw doctor --fixcreated a symlink whose realpath resolves back to the OpenClaw checkout.