Repository navigation
refactor(plugins): decouple tool metadata from runtime loading - #132932
Conversation
|
🦞👀 Pull request received. I will update this pull request when review starts. |
|
Codex review: needs maintainer review before merge. Reviewed August 30, 2026, 2:35 AM ET / 06:35 UTC. ClawSweeper reviewWhat this changesThe branch moves plugin-tool ownership metadata into a lightweight module and retargets CLI, agent, Gateway, SDK, build, and test consumers away from the plugin tool-construction runtime. Merge readinessThe refactor remains necessary: current main still keeps plugin-tool metadata inside the runtime-loading module. Source review found the single WeakMap and SDK behavior preserved, with no introduced correctness or security defect; this member-authored, Priority: P3 Review scores
Verification
How this fits togetherPlugin tool factories attach ownership and MCP metadata that agent policy, CLI cataloging, and Gateway dispatch consume later. The new metadata owner separates that record from runtime plugin loading while preserving the same tool-instance identity. flowchart LR
A[Plugin tool factory] --> B[Tool metadata owner]
B --> C[MCP materialization]
B --> D[Agent and Gateway policy]
C --> E[CLI catalog and tool list]
D --> F[Tool dispatch]
E --> F
Decision needed
Why: Repository policy keeps member-authored and Before merge
Agent review detailsSecurityNone. PR surfaceSource +7, Tests +107, Other +47. Total +161 across 73 files. View PR surface stats
Review metrics
Stored data modelPersistent data-model change detected: Technical reviewBest possible solution: Land the dependency-light metadata owner while retaining the existing SDK accessors and tool-instance metadata identity. Do we have a high-confidence way to reproduce the issue? Not applicable: this PR refactors an internal module boundary rather than reporting a user-facing failure; the relevant behavior is covered by source-level import-boundary and metadata-identity tests. Is this the best way to solve the issue? Yes. Moving the existing record into one dependency-light owner removes the unnecessary runtime-loading edge without adding a parallel store or compatibility barrel. AGENTS.md: found and applied where relevant. Codex review notes: model internal, reasoning high; reviewed against 136eab023035. LabelsLabel justifications:
EvidenceWhat I checked:
Likely related people:
Rating scale
Overall follows the weaker of proof and patch quality. Workflow
HistoryReview history (5 earlier review cycles)
|
afd6240 to
493aa38
Compare
Move tool metadata into one dependency-light owner so catalog and MCP materialization no longer import the plugin tool-construction runtime. Keep the single metadata store, shipped SDK exports, record identity, and tool semantics unchanged; migrate internal readers and producers. Cover the boundary with original-source import-denial reproduction and native loader/SDK metadata singleton proof on the exact candidate tree. Follow up on the startup preparation cleanup in #131503.
493aa38 to
30c5d98
Compare
Post-merge correction — 2026-08-30The merged tree contained an incoming caller that this extraction missed: Eden's one-line canonical-owner repair, PR #133155, is merged as be5e79ca4713. It changes only that import to Land-ready for reviewed head The latest ClawSweeper review found no correctness/security defect and asks for explicit maintainer handling. This landing is proceeding under the maintainer's explicit rebase-and-land request, not an automated closure. Its persistent-data classification does not apply: the change relocates one process-local WeakMap and its existing accessors; it changes no persisted state, database schema, serialization, or vector/embedding storage. Exact native commands, with the installed protected GitHub shim retained: env -u GITHUB_TOKEN -u GH_TOKEN -u HOMEBREW_GITHUB_API_TOKEN OPENCLAW_GH_BIN="$(command -v gh)" scripts/pr review-validate-artifacts 132932env -u GITHUB_TOKEN -u GH_TOKEN -u HOMEBREW_GITHUB_API_TOKEN OPENCLAW_GH_BIN="$(command -v gh)" OPENCLAW_TESTBOX=1 scripts/pr prepare-run 132932The PR body preserves the original-candidate red/green import-denial proof, actual loader/stdio tests, normal build and clean Linux native/SDK singleton proof. Those historical runs are not relabeled as execution of this rebased tree. Earlier timing failures remain recorded; no timeout increase or isolated speedup claim is made. The separate transport/auth/provider loader route remains outside this extraction. Production +112/-101 (net +11); tests/support +319/-169 (net +150); build tooling +1/-1. The production increase is import/type scaffolding for the lightweight owner. Metadata identity, copying, optional/replay/media/side-effect semantics, existing SDK accessors and approval/authority implementations are preserved. |
|
Merged via squash.
|
…aw#132932) Move tool metadata into one dependency-light owner so catalog and MCP materialization no longer import the plugin tool-construction runtime. Keep the single metadata store, shipped SDK exports, record identity, and tool semantics unchanged; migrate internal readers and producers. Cover the boundary with original-source import-denial reproduction and native loader/SDK metadata singleton proof on the exact candidate tree. Follow up on the startup preparation cleanup in openclaw#131503.
Related: #131503 — avoid repeated plugin preparation at startup.
What Problem This Solves
MCP command registration and catalog inspection still imported the plugin tool-construction runtime solely to read or attach tool metadata. The confirmed edge was
mcp-cli.ts→agent-bundle-mcp-materialize.ts→plugins/tools.ts, where metadata accessors shared a module with loader imports. This is the separately scoped metadata-owner follow-up left out of the startup-preparation change above.Why This Change Was Made
Move the existing metadata types, one WeakMap, and five helpers into a dependency-light canonical owner. Fresh/cached tool producers, wrapper copying, and metadata readers use that same owner. Plugin loading, registry/scope caches, optional grants, replay safety, local-media trust, side-effect policy, and approval decisions remain with their existing owners and retain their implementations.
Keep the shipped agent-harness SDK exports, retargeted directly to the new owner. Replace the old internal build-harness entry and migrate its MCP consumer; do not retain an unneeded compatibility barrel. Tests that previously used name-indexed metadata or a second WeakMap now tag concrete fixture tools through the actual owner, and clone-boundary coverage asserts preservation of the exact full metadata record. Extend the existing compiled-plugin singleton smoke to check that the public SDK reads the materializer's exact metadata record, after—not before—its existing cold-native loader assertions.
User Impact
No tool, permission, approval, configuration, or default changes. MCP metadata access no longer requires the plugin tool-construction module. The entire MCP CLI is not claimed to be loader-free: an independent transport/auth/provider import route remains a separate follow-up. This change does not claim an isolated startup-speed improvement or a fix for previously observed 30-second process timeouts.
Production LOC: +112/-101 (net +11). Tests/support: +319/-169 (net +150). Build tooling: +1/-1 (net 0). The small production increase is module/type-import scaffolding and split imports for the new ownership boundary, not a second store or new runtime policy.
Evidence
The branch was refreshed onto
e7f6aaa2c3bb3651e13d79aa1e6989718fedd18bafter GitHub reported conflicts. Current head is30c5d9829c20c37e8c181acb73c0c359fe8eb980, treecc347a81d3b3091004bd5488f3072b59b575aa40. The latest resolution preserves main's prepared tool-policy matcher and narrow provider-schema mock, while removing the obsolete metadata mock so the real normalizer/copier remain active. The earlier shared result renderer is also preserved. The metadata owner, helper/type bodies, and import-denial/materialization/native assertion sources are unchanged. Fresh review of the resolved full patch returned scoped-clean with no actionable P0 findings.Current-head CI run 33294630435 passed, including the required
openclaw/ci-gatefrom GitHub Actions on this exact head. The preceding head passed CI run 33288039766. The local/build/native evidence below belongs to the original pre-rebase candidate and is not represented as execution proof for this latest tree; current-head CI remains required before merge.plugins/toolsedge, then passed on the restored candidate. It performs actual CLI registration/reload, projects a nonempty catalog, and checks inventory-only execution rejection. A separate metadata-leaf case forbids tool construction, loader imports, and channel serving. Both retain their 30-second child bounds; neither mocks the loader.Commands used for the principal build/check and owner/bridge proofs:
Fresh pre-commit Codex autoreview returned scoped-clean, with no actionable P0 findings.
Clean Linux native proof also passed on Blacksmith Testbox run 33281891979, lease
tbx_01m17yw2gkwa4scmt39748qjf3: exact baseb3362142c72bcde6dae141e649826de10da0c000and source tree9cf9ed7549b680a792ff117290e9a61ab581d2eawere verified before execution and remained unchanged. Node 24.19.0, pnpm 12.0.0, frozen install, normal build, targeted script/tooling checks, and the existing native singleton smoke including the new SDK metadata-record assertion all passed. The command used isolated environment/HOME/state paths on a prepared CI machine; it was not a secretless-machine claim. The one-shot lease was stopped and its completed state verified. Its backing Actions lifecycle may show cancellation during Testbox cleanup; the command exit, exact source/success markers, and completed lease are the proof, not a PR-head CI gate.The earlier broad native probes did not complete inside their task-local 30-second observation bounds. They remain failed observations; the canonical native smoke has no such per-command deadline, and no limit was changed. One pre-warmed Testbox attempt expired during local source preparation before any build/test ran; the supported one-shot flow corrected allocation ordering without extending a deadline. Timings were non-exclusive and do not isolate this edge's cost. No loader mock, test-mode flag, schema, or dependency workaround was added. Exact PR-head CI remains required before merge.
AI-assisted implementation and independent review.