Repository navigation
refactor(plugins): move plugin contributions into the registry bundle - #117372
Conversation
|
Codex review: needs real behavior proof before merge. Reviewed August 1, 2026, 9:45 AM ET / 13:45 UTC. ClawSweeper reviewWhat this changesThis PR moves plugin runtime contributions—commands, hooks, context engines, providers, memory state, and session-discussion handlers—from process-global stores into the lifecycle-owned plugin registry while preserving the public accessor APIs. Merge readiness⛔ Blocked until real behavior proof is added - 5 items remain Keep this PR open for maintainer review. Current Priority: P2 Review scores
Verification
How this fits togetherOpenClaw’s plugin loader discovers and registers plugin capabilities, then activates a registry used by gateway, agent, memory, command, and context-engine paths. The PR changes where those capabilities are recorded and how active or scoped registry consumers resolve them. flowchart LR
Plugin[Plugin registration callback] --> Builder[Registry builder]
Builder --> Bundle[Plugin contribution bundle]
Bundle --> Activation[Registry activation]
Activation --> Runtime[Gateway and agent runtime]
Bundle --> Facades[Compatibility accessors]
Facades --> Runtime
Runtime --> Operators[User and operator behavior]
Decision needed
Why: The patch changes cross-cutting runtime ownership and compatibility facades across gateway, agents, sessions, memory, and plugins; source review supports the direction but cannot safely choose the permanent rollout boundary without maintainer intent and exact-head proof. Before merge
Agent review detailsSecurityNone. PR surfaceSource +97, Tests -181, Generated 0, Other +13. Total -71 across 76 files. View PR surface stats
Review metrics
Stored data modelPersistent data-model change detected: Merge-risk optionsMaintainer options:
Technical reviewBest possible solution: Keep one canonical registry-owned contribution bundle, but land it only after exact-head evidence shows fresh activation, a failed replacement registration, cached reactivation, and scoped/pinned consumers retain the correct capability set without changing the public plugin SDK contract. Do we have a high-confidence way to reproduce the issue? Not applicable as a reporter bug reproduction: the PR is an architectural refactor. Its behavioral claims are testable through exact-head activation, failed-registration rollback, and scoped/pinned registry scenarios, but no inspectable runtime artifact for those scenarios was available. Is this the best way to solve the issue? Unclear: the registry-owned direction matches the scoped plugin policy’s preferred ownership model, but the available review evidence cannot establish that this exact large transition is the best safe rollout shape over a narrower staged migration. AGENTS.md: found and applied where relevant. Codex review notes: model internal, reasoning high; reviewed against 56ffa2bca48b. LabelsLabel 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 (6 earlier review cycles)
|
Exact-head runtime proof: registry-lifecycle behavior through the built dist (redacted transcript)Both runs against the dist built from this PR's exact head 1. Contribution ownership + failure isolation via the real loader ( A plugin that registers a harness and then throws mid- 2. Live ephemeral gateway on the same dist (isolated state dir, loopback): Full production path — discovery → load → bundle activation → gateway capability resolution → clean close — through the new registry-owned contribution architecture. On the P1 merge-risk note (deterministic active/pinned selection for existing plugins): the pinned-surface selection heuristics are intentionally untouched by this PR (they are deleted in the follow-up series once scoped loads stop activating); 871 tests across the direct runtime-mock and facade suites plus the full hosted CI matrix on this head exercise those paths unchanged. 🤖 Generated with Claude Code |
|
Merged via squash.
|
* origin/main: docs: generate docs map at publish time (openclaw#117398) refactor(plugins): move plugin contributions into the registry bundle (openclaw#117372) fix(tui): keep PTY progress and lifecycle truthful (openclaw#117402) test(xai): type realtime sent item payloads fix(qa): preserve Slack fallback evidence (openclaw#117420) fix(qa): satisfy update lane execution contracts (openclaw#117388) fix(qa): Matrix replies disappear after final replacement (openclaw#117390) test(xai): prove rejected tool call continuation fix(xai): complete rejected realtime tool calls test(xai): add live tool argument probe test(xai): cover rejected realtime tool arguments fix(xai): validate realtime tool arguments before dispatch fix(xai): skip tool call when rawArgs JSON parse fails instead of silently falling back to empty args
…openclaw#117372) * refactor(plugins): move plugin contributions into the registry bundle * fix(plugins): guard embedding owner union and drop unused test-util imports * fix(plugins): break registry facade import cycles * fix(plugins): remove obsolete registry snapshot seams * test(gateway): preserve plugin runtime mock exports * test(auto-reply): install builder registry in diagnostics fixture * test(plugins): activate registry-backed capability fixtures
* origin/main: docs: generate docs map at publish time (openclaw#117398) refactor(plugins): move plugin contributions into the registry bundle (openclaw#117372) fix(tui): keep PTY progress and lifecycle truthful (openclaw#117402) test(xai): type realtime sent item payloads fix(qa): preserve Slack fallback evidence (openclaw#117420) fix(qa): satisfy update lane execution contracts (openclaw#117388) fix(qa): Matrix replies disappear after final replacement (openclaw#117390) test(xai): prove rejected tool call continuation fix(xai): complete rejected realtime tool calls test(xai): add live tool argument probe test(xai): cover rejected realtime tool arguments fix(xai): validate realtime tool arguments before dispatch fix(xai): skip tool call when rawArgs JSON parse fails instead of silently falling back to empty args
api.registerHook registers into the legacy internal-hook path, while typed lifecycle events (before_tool_call, message_received, ...) are dispatched exclusively by the typed hook runner. Registrations under typed names silently never fired since openclaw#117372 moved the write to legacyInternalHooks. Emit a registration diagnostic pointing to the public api.on(...) API so plugin authors see the no-op at load time instead of trusting a false "loaded". Related to openclaw#116965 Co-Authored-By: deepseek-v4-flash <[email protected]>
…18601) * [AI] fix(plugins): warn when registerHook uses a typed hook event name api.registerHook registers into the legacy internal-hook path, while typed lifecycle events (before_tool_call, message_received, ...) are dispatched exclusively by the typed hook runner. Registrations under typed names silently never fired since #117372 moved the write to legacyInternalHooks. Emit a registration diagnostic pointing to the public api.on(...) API so plugin authors see the no-op at load time instead of trusting a false "loaded". Related to #116965 Co-Authored-By: deepseek-v4-flash <[email protected]> * [AI] fix(plugins): point registerHook comment at public api.on API Condense the inline comment in createToolHookRegistrars and replace the internal registerTypedHook migration reference with the public api.on(...) API, matching the emitted warning and hooks docs. Behavior and tests unchanged. --------- Co-authored-by: deepseek-v4-flash <[email protected]> Co-authored-by: Patrick Erichsen <[email protected]>
…enclaw#118601) * [AI] fix(plugins): warn when registerHook uses a typed hook event name api.registerHook registers into the legacy internal-hook path, while typed lifecycle events (before_tool_call, message_received, ...) are dispatched exclusively by the typed hook runner. Registrations under typed names silently never fired since openclaw#117372 moved the write to legacyInternalHooks. Emit a registration diagnostic pointing to the public api.on(...) API so plugin authors see the no-op at load time instead of trusting a false "loaded". Related to openclaw#116965 Co-Authored-By: deepseek-v4-flash <[email protected]> * [AI] fix(plugins): point registerHook comment at public api.on API Condense the inline comment in createToolHookRegistrars and replace the internal registerTypedHook migration reference with the public api.on(...) API, matching the emitted warning and hooks docs. Behavior and tests unchanged. --------- Co-authored-by: deepseek-v4-flash <[email protected]> Co-authored-by: Patrick Erichsen <[email protected]>
What Problem This Solves
Plugin
register(api)callbacks don't return their contributions — the injected handlers write them into ~11 process-globalSymbol.forcapability stores (agent harnesses, commands, compaction, interactive handlers, embeddings, memory state, session discussion, detached tasks, legacy hooks, artifact memo), with context engines sitting outside even the existing clear/rollback paths. Because loading mutates shared globals, the loader carries an entire defense apparatus: clear-the-world on every activating load, a 233-line snapshot/restore transaction over 13 global fields, cached{registry, processGlobalState}pairs, and lifecycle bugs that machinery cannot fix — a failed re-registration can delete a working context engine; the session-discussion slot is last-writer-wins and evicted by any unrelated scoped load.This is the first PR of the reviewed architecture series (pure build → root-owned bundle → scoped-load handle threading → scaffolding deletion), agreed in the maintainer design session that produced #117236/#117242/#117237/#117253/#117300.
Why This Change Was Made
Contributions now live as owner-scoped tables on the registry value itself; the injected registrar handlers write builder-local state. Every former global store keeps its exact public accessor signatures but reads through the active registry — one facade pattern, applied uniformly, including context engines and an owner-keyed session-discussion table (fixing last-writer-wins). Core-owned contributions (e.g. embedding providers) become static constants consulted directly — swap-proof by construction instead of carried forward. Direct (non-plugin) registrations are ownership-asserted so one owner cannot silently replace another's entry.
Deleted because the move obsoletes them:
clearActivatedPluginRuntimeState(activation = install a reference; nothing to clear),plugin-registration-transaction.tsand its 574-line test (a plugin that throws during register simply discards its builder-local entries — proven by a new regression test), and the process-global snapshot half of the loader cache.Explicitly unchanged in this PR: loader cache keys, permutation matching, surface pinning,
ensure*loaders, gateway startup/reload flows, and every shipped SDK export (getGlobalHookRunner,registerSessionDiscussionProvider, memory-host-search, allregistrationModevalues). Those are the next PRs' deletions; this PR makes them deletable.User Impact
No behavior change intended at any external surface. The bug-class payoff: failed plugin activation can no longer destroy working capabilities registered by other plugins (context-engine regression test included), and scoped loads can no longer evict the session-discussion provider process-wide.
Evidence
pnpm buildclean (no[INEFFECTIVE_DYNAMIC_IMPORT]);plugin-sdk:surface:checkandplugin-sdk:api:checkpass without baseline changes — the public SDK surface is untouched.run-vitest src/pluginsgate was adjudicated unsound — it replays files through incompatible vitest projects and fails identically (~258 lines) on a clean checkout of the base SHA; the five most suspicious files pass 68/68 when invoked properly. Hosted CI's per-project sharding is the arbiter here.🤖 Generated with Claude Code
Exact-head runtime proof (added post-review)
Dist-driven transcript on head 18ca9a6: contribution tables with owner attribution on the registry value; a plugin throwing mid-register leaves sibling contributions intact and its own partial contribution discarded (the deleted transaction's property, now structural); owner-keyed session-discussion table; invalid capability shapes rejected with diagnostics. Live ephemeral gateway on the same dist: 3 plugins load through the bundle in 0.6s, readyz 200, clean 26ms shutdown. Full transcript: #117372 (comment)