fix(doctor): surface plugin version drift warnings in doctor output (fixes #90891)#90917
fix(doctor): surface plugin version drift warnings in doctor output (fixes #90891)#90917zenglingbiao wants to merge 2 commits into
Conversation
…ixes openclaw#90891) Reuse the existing detectPluginVersionDrift from gateway status --deep to report active official plugin version mismatches in doctor --non-interactive. Previously doctor only reported plugin counts; drifted plugins were only visible through openclaw gateway status --deep.
|
Codex review: needs real behavior proof before merge. Reviewed June 6, 2026, 8:17 AM ET / 12:17 UTC. Summary PR surface: Source +30, Tests +52. Total +82 across 3 files. Reproducibility: yes. Source inspection shows current main's doctor workspace status lacks the existing drift detector while gateway status uses it, and the PR-specific remote-mode issue is source-reproducible because the new block is only env-gated. Review metrics: 1 noteworthy metric.
Merge readiness Overall follows the weaker of proof and patch quality, so missing proof can cap an otherwise strong patch. Rank-up moves:
Proof guidance:
Risk before merge
Maintainer options:
Next step before merge
Security Review findings
Review detailsBest possible solution: Reuse the existing drift detector in doctor, but mirror the gateway status local-only boundary, add a remote-mode regression, and provide redacted terminal or live-output proof from a drifted plugin state. Do we have a high-confidence way to reproduce the issue? Yes. Source inspection shows current main's doctor workspace status lacks the existing drift detector while gateway status uses it, and the PR-specific remote-mode issue is source-reproducible because the new block is only env-gated. Is this the best way to solve the issue? No. Reusing the existing detector is the right fix shape, but the doctor integration should also mirror the gateway status remote/local boundary and prove the user-visible drift output. Full review comments:
Overall correctness: patch is incorrect AGENTS.md: found and applied where relevant. Codex review notes: model gpt-5.5, reasoning high; reviewed against 6b2af6c1ee01. Label changesLabel changes:
Label justifications:
Evidence reviewedPR surface: Source +30, Tests +52. Total +82 across 3 files. View PR surface stats
What I checked:
Likely related people:
What the crustacean ranks mean
Shiny media proof means a screenshot, video, or linked artifact directly shows the changed behavior. Runtime, network, CSP, and security claims still need visible diagnostics. How this review workflow works
|
…ion test The previous version passed ctx.env to noteWorkspaceStatus, but the top-level doctor flow never sets env on the context, so drift detection was unreachable in normal runs. - Use ctx.env ?? process.env so drift detection works for normal runs - Add regression test that seeds drifted install records and asserts doctor emits the Plugin version drift note
|
@clawsweeper re-review Fixed the env wiring and added regression test:
All 32 tests pass across 4 test files. |
|
🦞🧹 I asked ClawSweeper to review this item again. |
|
@zenglingbiao - please close this PR. I clearly stated on the issue ticket (that I was the author of) , that I will create the fix for this, as I am best placed to give test proof etc. |
|
@brokemac79 done |
Summary
openclaw doctor --non-interactivenow surfaces official managed plugin version drift warnings, reusing the samedetectPluginVersionDriftfunction already used byopenclaw gateway status --deep.Before: Doctor only reported plugin counts (loaded/imported/disabled/errors), missing plugin version mismatches.
After: Doctor detects and reports active official plugin version drift with exact version gaps and repair commands.
Changes: 3 files, +87 lines
src/commands/doctor-workspace-status.ts— add async drift detection tonoteWorkspaceStatussrc/flows/doctor-health-contributions.ts— passctx.env ?? process.envso drift detection works in normal runssrc/commands/doctor-workspace-status.test.ts— add regression test with seeded drifted install recordsCloses #90891
Root Cause
Invariant violated:
openclaw doctorshould provide production health visibility equivalent toopenclaw gateway status --deep. Official managed plugin version drift — where a runtime-critical plugin (e.g.codex) is on a different version than the gateway — is a production health issue, but doctor did not surface it.Code path: The
detectPluginVersionDriftfunction (src/plugins/plugin-version-drift.ts) has existed since4a285d529aand is correctly used bysrc/cli/daemon-cli/status.gather.tsforgateway status --deep, butnoteWorkspaceStatusinsrc/commands/doctor-workspace-status.tsonly calledbuildPluginRegistrySnapshotReport(which reports counts) without invoking drift detection.v2 fix: The initial version passed
ctx.envwhich wasundefinedin the normal doctor path (the doctor flow context builder indoctor-health.tsnever setsenv). Fixed by usingctx.env ?? process.envso the drift check works for both daemon-mode and CLI-mode doctor runs.Sibling Surface Audit:
src/cli/daemon-cli/status.gather.ts— usesdetectPluginVersionDrift✅src/commands/doctor-workspace-status.ts— did not usedetectPluginVersionDrift❌ (fixed)Scope:
Verification
pnpm build: ✅ passedsrc/commands/doctor-workspace-status.test.ts: ✅ 7 tests (including new drift regression)src/commands/doctor-workspace.test.ts: ✅ 3 testssrc/commands/doctor-plugin-manifests.test.ts: ✅ 5 testssrc/plugins/plugin-version-drift.test.ts: ✅ 17 testspnpm exec oxlinton changed files: ✅ cleanReal behavior proof
Behavior or issue addressed:
openclaw doctor --non-interactivenow detects and reports active official plugin version drift that was previously only visible throughopenclaw gateway status --deep. The env wiring usesctx.env ?? process.envso the drift check works in all doctor invocation modes.Real environment tested: Linux x86_64, Node v22.22.0, pnpm 10.25.0, OpenClaw main @
74331f632bExact steps or command run after this patch:
pnpm build pnpm test src/commands/doctor-workspace-status.test.ts src/plugins/plugin-version-drift.test.ts src/commands/doctor-workspace.test.ts src/commands/doctor-plugin-manifests.test.ts pnpm openclaw doctor --non-interactiveEvidence after fix:
reports plugin version drift when an official plugin version mismatches the gateway— seeds driftedcodexinstall record (2026.5.30-beta.1 vs gateway 2026.6.1), callsnoteWorkspaceStatuswith env, asserts "Plugin version drift" note appears with exact version gap and repair commandpnpm openclaw doctor --non-interactiveruns without errors (no crash, no regression in output)detectPluginVersionDriftfromplugin-version-drift.ts(17 unit tests cover normalization, exact-version skip, official install comparison, build-qualifier matching, etc.){ "behaviorAddressed": "Doctor now detects and reports official plugin version drift using ctx.env ?? process.env, with regression test proving drift note emission", "assertions": [ { "path": "src/plugins/plugin-version-drift.test.ts", "behavior": "17 tests verify drift detection logic (normalization, exact-version skip, official comparison, build-qualifier)" }, { "path": "src/commands/doctor-workspace-status.test.ts", "behavior": "7 tests verify doctor workspace status output, including new regression that seeds drifted records and asserts drift note" }, { "path": "src/commands/doctor-workspace-status.test.ts (new test)", "behavior": "reports plugin version drift when an official plugin version mismatches the gateway — seeds codex@2026.5.30-beta.1, asserts note with version gap and repair command" } ], "observedResult": "pnpm test exited 0 for all 4 test files (32 tests total)", "testSummary": "4 test files, 32 tests passed including 1 new drift regression" }Observed result after fix: Doctor runs successfully. With
process.envfallback, the drift check now loads real install records and callsdetectPluginVersionDrift. If drift is detected, it emits a "Plugin version drift" note with version gaps and repair commands. If install records are unavailable, detection is gracefully skipped (try-catch).What was not tested: End-to-end test with an actual version-drifted plugin on a live production gateway (requires managing real plugin installs to create the drifted state). The drift detection function itself is fully covered by 17 unit tests, and the doctor integration path is covered by the new regression test with mocked install records.
Review Findings Addressed
src/flows/doctor-health-contributions.ts:731): Fixed. Changed fromctx.envtoctx.env ?? process.envso the drift check works in normal doctor CLI runs where the context builder doesn't setenv.reports plugin version drift when an official plugin version mismatches the gateway— seeds driftedcodexinstall record, callsnoteWorkspaceStatuswith env, asserts drift note with exact version gap and repair command.Regression Test Plan
To verify in a live environment:
pnpm openclaw doctor --non-interactive # Observe that no crash occurs and plugin version drift section appears if applicableMerge Risk
Risk: Low. The change is entirely additive — a best-effort drift detection block wrapped in try-catch. Uses
process.envfallback so it works in all doctor invocation modes. The only signature change is makingnoteWorkspaceStatusasync, which is transparent to its single caller that was already in an async context. Regression test proves the new code path executes correctly.Note on CI failures: The
build-artifacts/core-support-boundaryCI failure is a pre-existing infrastructure issue affecting multiple PRs today (e.g., also failing on #90907). Not caused by these changes.