Repository navigation
improve(doctor): avoid repeated plugin metadata scans - #119482
Conversation
|
Codex review: needs maintainer review before merge. Reviewed August 5, 2026, 6:46 AM ET / 10:46 UTC. ClawSweeper reviewWhat this changesThe PR makes OpenClaw Doctor retain a compatible plugin-metadata snapshot per workspace, reuse it across diagnostics, and refresh or invalidate it after inventory repairs. Merge readinessNo blocking correctness or security defect was found in the exact PR head. This remains open for explicit maintainer acceptance because it is maintainer-authored and changes the Doctor lifecycle that governs plugin, provider, and tool discovery. Priority: P2 Review scores
Verification
How this fits togetherDoctor reads configuration and plugin manifests before running repair, health, provider, tool, and status diagnostics. This change carries that metadata through those downstream checks while ensuring inventory mutations cause a fresh generation to be used. flowchart TD
A[Doctor preflight] --> B[Plugin metadata snapshot]
B --> C[Workspace snapshot scope]
C --> D[Config repair and health checks]
D --> E{Plugin inventory changed?}
E -->|No| F[Reuse compatible snapshot]
E -->|Yes| G[Clear and reload generation]
F --> H[Provider, tool, and status diagnostics]
G --> H
Decision needed
Why: The patch is source-consistent and covered, but a maintainer must own the operational tradeoff of caching plugin inventory across Doctor repair stages. Before merge
Agent review detailsSecurityNone. PR surfaceSource +596, Tests +890. Total +1486 across 41 files. View PR surface stats
Review metrics
Stored data modelPersistent data-model change detected: Root-cause clusterRelationship: Members:
Proposal only: this assessment does not dispatch repair, suppress jobs, mutate sibling items, close, or merge anything. Merge-risk optionsMaintainer options:
Technical reviewBest possible solution: Keep the lifecycle-owned, per-workspace snapshot design and land it only after a Doctor/plugin owner accepts the explicit invalidation coverage for manifest, registry, install, and host-link repairs. Do we have a high-confidence way to reproduce the issue? Yes. Current-main source shows normal Doctor preflight discards the reusable metadata handoff, and the exact-head process test provides a focused plugin-heavy lifecycle path; this read-only review did not execute it. Is this the best way to solve the issue? Yes. A Doctor-owned per-workspace scope is a better fit than a global cache because it preserves config and workspace compatibility while keeping mutation invalidation at the lifecycle owner. AGENTS.md: found and applied where relevant. Codex review notes: model internal, reasoning high; reviewed against a52b336f260f. LabelsLabel changes:
Label justifications:
EvidenceWhat 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 (12 earlier review cycles; latest 8 shown)
|
13bdbc1 to
75044b6
Compare
|
@clawsweeper re-review Please review exact head The previous Before merge and Rank-up items are now implemented:
Please evaluate the complete current diff and list every remaining Before merge and Rank-up move explicitly. |
|
🦞🧹 I asked ClawSweeper to review this item again. Re-review progress:
|
990d477 to
ce0e9c4
Compare
|
@clawsweeper re-review |
|
🦞🧹 I asked ClawSweeper to review this item again. |
ce0e9c4 to
c393794
Compare
c393794 to
c0ecc69
Compare
c0ecc69 to
6a541cf
Compare
Punchcard-Session: coral-workshop-workshop-3f
Punchcard-Session: coral-workshop-workshop-3f
|
@clawsweeper re-review Exact-head merge evidence is now attached to the PR body for
Please refresh the durable review against this exact head and clear or restate every |
|
🦞🧹 I asked ClawSweeper to review this item again. Re-review progress:
|
|
Maintainer disposition for the latest ClawSweeper review of exact head
No ClawSweeper finding is being skipped. Exact-head CI and exact-head Kova evidence are published in the PR body. |
|
Merged via squash.
|
Post-merge exact-head proofReviewed PR head The root cause was lifecycle ownership: Doctor prepared plugin metadata during preflight but discarded it, so later config, repair, health, status, tool-schema, and per-workspace checks independently rescanned the same inventory. The final repair carries one immutable compatible generation per workspace, invalidates both base and derived workspace generations after manifest/install/registry mutations, and runs runtime tool discovery after plugin repair. Proof:
Linked issue #119481 is closed. |
* perf(doctor): reuse plugin metadata snapshot Punchcard-Session: coral-workshop-workshop-3f * test(doctor): update legacy issue mock Punchcard-Session: coral-workshop-workshop-3f * fix(doctor): refresh metadata after repairs * test(doctor): type legacy issue mock arguments Punchcard-Session: coral-workshop-workshop-3f * fix(doctor): invalidate scoped plugin metadata Punchcard-Session: coral-workshop-workshop-3f * fix(doctor): keep snapshot scope type private Punchcard-Session: coral-workshop-workshop-3f --------- Co-authored-by: Peter Steinberger <[email protected]>
Closes #119481
Problem
An exact-main Kova diagnostic found 553 completed
plugins.metadata.scanspans in each plugin-heavy gateway-performance record. The dominant Doctor process accounted for 493 of them, roughly 15-17 seconds of aggregate synchronous scan work, even though Doctor preflight had already loaded the authoritative plugin inventory.Baseline evidence: https://github.com/openclaw/openclaw/actions/runs/30973747306
Root Cause
Normal
openclaw doctorpreflight prepared plugin-aware config but did not retain a completePluginMetadataSnapshotfor the rest of the lifecycle. Config repair, configured-channel discovery, health checks, per-agent checks, preview warnings, and status helpers therefore fell back to independent metadata loads. Workspace-specific checks also needed an explicit scope transition rather than reuse of a default-workspace snapshot.Later health contributions can rewrite plugin manifests, install configured plugins, repair host links, or refresh the persisted registry. Those mutations occurred after the initial Doctor generation was prepared, so subsequent tool and provider discovery could reuse stale metadata unless the lifecycle owner explicitly invalidated it.
Fix
AsyncLocalStorage, while allowing inner per-agent workspace scopes to override and then restore the outer scope.This does not add or change config, defaults, public APIs, storage schemas, migrations, or fallback behavior.
User Impact
Doctor keeps plugin metadata work bounded by lifecycle and workspace rather than multiplying it by every downstream stage. Plugin-count growth no longer increases the scan count for the same workspace, while distinct agent workspaces still receive independently compatible metadata. Repairs that change manifests or installed inventory now force the next diagnostic to observe the repaired generation instead of stale provider or tool facts.
ClawSweeper Follow-Through
The exact-head patch and proof resolve every item from the latest review:
Verification
26a58bcd92baeb8ed6595d5202b16bd4e08be704ff416393255918172633e82a4d6f7f1d9e4f1ff4a52b336f260f7d074bf4f33d05952902584a81b0. The latest intervening changes cover Windows exec decoding and Matrix QA account isolation; no changed file overlaps this PR.ff416393255918172633e82a4d6f7f1d9e4f1ff4and Kovadfafaff9dcd49b9c76788c6260f1f72dd2ced593: https://github.com/openclaw/openclaw/actions/runs/30997538679oxfmt,oxlint --deny-warnings,git diff --check, and the dead-code export check passed.The Kova mock lane still crosses the existing 1,050 MB gateway RSS threshold (1,144.7 MB median, 1,189.5 MB max), and the source concurrency probe still shows roughly 19.5-second p99 control-plane latency. Those are separate startup/runtime hotspots: plugin load failures and missing dependency errors were zero, and neither warning changes the exact Doctor scan-count result.
Change Shape
Punchcard-Session: coral-workshop-workshop-3f