Skip to content

refactor(plugins): decompose plugin registry - #105783

Merged
steipete merged 2 commits into
mainfrom
codex/refactor-plugin-registry-domains
Jul 13, 2026
Merged

steipete merged 2 commits into
mainfrom
codex/refactor-plugin-registry-domains

Conversation

@steipete

@steipete steipete commented Jul 13, 2026 •

Copy link
Copy Markdown
Contributor

Closes #105758

What Problem This Solves

createPluginRegistry was a 3,577-line closure inside a 4,022-line module. Every plugin registration domain captured the same implicit mutable scope, making unrelated plugin work collide in one file and obscuring each domain's state and lifecycle dependencies.

Why This Change Was Made

Replace the mega-closure with one typed registry state object and compose focused registrar modules for capabilities, tools/hooks, network/channel surfaces, providers, operations, host/session surfaces, and memory. The scoped plugin runtime proxy and plugin API builder now have explicit modules; registry.ts is the 130-line lifecycle composition root. Existing registry, plugin API, validation, rollback, and runtime ownership contracts are preserved.

User Impact

No user-visible behavior change. Maintainers get smaller owner-specific review surfaces, explicit shared state, and fewer conflicts when extending separate plugin domains.

AI-assisted implementation; the complete patch was reviewed with the repository autoreview helper.

Evidence

  • Blacksmith Testbox through Crabbox: tbx_01kxcbcnse4nqt5w0xkr9hjf30 (harbor-krill-63eb).
  • Focused remote Vitest: 302 tests passed across registry, loader, captured registration, HTTP, provider/channel/control UI, host hooks, memory embedding, and session actions.
  • Remote pnpm check:changed: core production and test tsgo, changed-file formatting, full core oxlint shards, plugin SDK baseline, import-cycle check, and repository guards passed.
  • Exact CI follow-up: moved the existing session-accessor debt baseline from registry.ts to registry-runtime.ts; node scripts/check-session-accessor-boundary.mjs passed.
  • Remote pnpm build: full runtime, plugin SDK declaration/export, asset, and Control UI build passed.
  • Structured autoreview: .agents/skills/autoreview/scripts/autoreview --mode local --stream-engine-output reported no accepted/actionable findings; correctness confidence 0.94.
  • src/plugins/registry.ts: 4,022 lines before; 130 lines after.
  • No changelog: internal refactor with no user-visible contract change.

@steipete steipete self-assigned this Jul 13, 2026
@openclaw-barnacle openclaw-barnacle Bot added size: XL maintainer Maintainer-authored PR labels Jul 13, 2026
@clawsweeper clawsweeper Bot added rating: 🐚 platinum hermit Good normal PR readiness with ordinary maintainer review expected. status: 👀 ready for maintainer look ClawSweeper has no concrete contributor-facing blocker left for this PR. P3 Low-priority cleanup, docs, polish, ergonomics, or speculative work. merge-risk: 🚨 compatibility 🚨 May break existing users, config, migrations, defaults, or upgrade paths. merge-risk: 🚨 security-boundary 🚨 May affect sandboxing, authorization, credentials, or sensitive data. labels Jul 13, 2026
@clawsweeper

clawsweeper Bot commented Jul 13, 2026 •

Copy link
Copy Markdown
Contributor

Codex review: needs maintainer review before merge. Reviewed July 12, 2026, 8:38 PM ET / July 13, 2026, 00:38 UTC.

Summary
Decomposes the monolithic plugin registry into explicit shared state, API/runtime helpers, and domain-specific registrar modules while preserving registry.ts as the lifecycle composition root.

PR surface: Source +206, Other 0. Total +206 across 13 files.

Reproducibility: not applicable. This PR is a structural refactor with no reported user-facing failure to reproduce. The relevant verification question is behavioral equivalence, for which the PR supplies broad remote test and build evidence.

Review metrics: none identified.

Stored data model
Persistent data-model change detected: vector/embedding metadata: src/plugins/registry-registrars-memory.ts, vector/embedding metadata: src/plugins/registry-registrars-providers.ts. Confirm migration or upgrade compatibility proof before merge.

Root-cause cluster
Relationship: fixed_by_candidate
Canonical: #105758
Summary: This PR is the explicit implementation candidate for the linked plugin-registry decomposition issue; the issue should remain open until this PR merges or another implementation replaces it.

Members:

Proposal only: this assessment does not dispatch repair, suppress jobs, mutate sibling items, close, or merge anything.

Merge readiness
Overall: 🐚 platinum hermit
Proof: 🦞 diamond lobster
Patch quality: 🐚 platinum hermit
Result: ready for maintainer review.

Overall follows the weaker of proof and patch quality, so missing proof can cap an otherwise strong patch.

Rank-up moves:

  • Rebase onto current main and refresh the focused registry, boundary, build, and smoke proof on the exact merge candidate.
  • Have a plugin-registry owner inspect lifecycle ordering, rollback, registration modes, and runtime authorization equivalence.

Risk before merge

  • [P1] The PR base is behind current main, so the final owner review and required checks should be refreshed on the rebased or merged result rather than relying solely on the earlier base.
  • [P1] Because almost every plugin registration domain and the gateway/session runtime guard path moved, a subtle omission or altered initialization order could affect existing plugins even though no API change is intended.
  • [P1] The supplied context contains extensive patches and validation results, but local read-only shell execution failed before every moved function and its history could be independently inspected; no discrete defect is asserted from that limitation.

Maintainer options:

  1. Refresh equivalence proof (recommended)
    Rebase onto current main and repeat the registry, loader, rollback, boundary, build, and runtime smoke validation before owner approval.
  2. Accept the broad refactor
    A plugin-area owner may accept the residual compatibility and authorization risk based on the reported Testbox proof and successful checks.
  3. Split or pause
    Split security-sensitive runtime resolution from the registrar decomposition, or pause the PR if the combined equivalence review is not tractable.

Next step before merge

  • [P2] The protected maintainer label, stale base, and broad compatibility/security-sensitive equivalence question require exact-head owner review rather than an automated repair job.

Maintainer decision needed

  • Question: After refreshing this branch against current main, does the plugin-registry owner accept the behavioral-equivalence evidence for the moved lifecycle, rollback, and runtime authorization paths?
  • Rationale: The branch is a very broad internal refactor of compatibility- and security-sensitive plugin infrastructure, carries a protected maintainer label, and has no narrow mechanical defect that automation can resolve instead of owner review.
  • Likely owner: steipete — The available evidence identifies this person as the issue author, PR assignee, implementation author, and coordinator of the maintainer-requested registry refactor.
  • Options:
    • Refresh and approve (recommended): Rebase the branch, rerun the focused registry and boundary proof, and approve after owner inspection confirms behavior equivalence.
    • Narrow the refactor: Split the API/runtime authorization movement from the domain registrar extraction if the combined review surface is too large to validate safely.
    • Pause the decomposition: Leave the linked issue open and close this branch if maintainers no longer want to absorb the broad refactor risk.

Security
Cleared: No dependency, workflow, package-resolution, secret-handling, or new authority surface is apparent; the remaining security concern is equivalence review of relocated existing runtime guards rather than a concrete introduced vulnerability.

Review details

Best possible solution:

Rebase onto current main, preserve the single explicit registry-state design, and land only after a plugin-area owner confirms activation-mode, rollback, registration-order, runtime-scope, and gateway/session authorization equivalence on the exact head.

Do we have a high-confidence way to reproduce the issue?

Not applicable: this PR is a structural refactor with no reported user-facing failure to reproduce. The relevant verification question is behavioral equivalence, for which the PR supplies broad remote test and build evidence.

Is this the best way to solve the issue?

Yes, provisionally: one explicit state object with domain registrars is a cleaner owner boundary than helper extraction inside the original mega-closure. The best version is the current design after exact-head equivalence review of lifecycle and authorization paths.

AGENTS.md: found and applied where relevant.

Codex review notes: model internal, reasoning high; reviewed against e01d1e85f372.

Label changes

Label changes:

  • add merge-risk: 🚨 compatibility: The patch relocates nearly the entire plugin registration implementation, where mode, ordering, rollback, or shared-state drift could break existing plugins.
  • add merge-risk: 🚨 security-boundary: The moved runtime module governs plugin gateway/session mutation permissions and ownership scoping, so an equivalence error could alter plugin authority.
  • add proof: sufficient: Contributor real behavior proof is sufficient. The PR supplies after-change Blacksmith Testbox execution, 302 focused passing tests across real registry consumers, changed checks, boundary validation, and a full build, which is strong real execution proof for an internal refactor.
  • add rating: 🐚 platinum hermit: Overall readiness is 🐚 platinum hermit; proof is 🦞 diamond lobster and patch quality is 🐚 platinum hermit.
  • add status: 👀 ready for maintainer look: ClawSweeper has no concrete contributor-facing blocker left for this PR. Sufficient (live_output): The PR supplies after-change Blacksmith Testbox execution, 302 focused passing tests across real registry consumers, changed checks, boundary validation, and a full build, which is strong real execution proof for an internal refactor.

Label justifications:

  • P3: This is a maintainer-focused internal cleanup with no intended user-visible behavior change or urgent regression.
  • merge-risk: 🚨 compatibility: The patch relocates nearly the entire plugin registration implementation, where mode, ordering, rollback, or shared-state drift could break existing plugins.
  • merge-risk: 🚨 security-boundary: The moved runtime module governs plugin gateway/session mutation permissions and ownership scoping, so an equivalence error could alter plugin authority.
  • rating: 🐚 platinum hermit: Overall readiness is 🐚 platinum hermit; proof is 🦞 diamond lobster and patch quality is 🐚 platinum hermit.
  • status: 👀 ready for maintainer look: ClawSweeper has no concrete contributor-facing blocker left for this PR. Sufficient (live_output): The PR supplies after-change Blacksmith Testbox execution, 302 focused passing tests across real registry consumers, changed checks, boundary validation, and a full build, which is strong real execution proof for an internal refactor.
  • proof: sufficient: Contributor real behavior proof is sufficient. The PR supplies after-change Blacksmith Testbox execution, 302 focused passing tests across real registry consumers, changed checks, boundary validation, and a full build, which is strong real execution proof for an internal refactor.
Evidence reviewed

PR surface:

Source +206, Other 0. Total +206 across 13 files.

View PR surface stats
Area Files Added Removed Net
Source 12 4163 3957 +206
Tests 0 0 0 0
Docs 0 0 0 0
Config 0 0 0 0
Generated 0 0 0 0
Other 1 1 1 0
Total 13 4164 3958 +206

What I checked:

  • Linked implementation: The PR explicitly implements the decomposition requested by the linked issue, including typed shared state and registrars for capabilities, hooks/tools, network, providers, operations, host/session surfaces, and memory. (src/plugins/registry-registrars.ts:1, 2735d9e5055b)
  • Composition boundary: The new composition module constructs all seven registrar domains over one registry state object and retains the model-catalog registration handler from that state. (src/plugins/registry-registrars.ts:11, 2735d9e5055b)
  • Security-sensitive runtime surface: The refactor relocates gateway and session mutation allowlists plus plugin runtime scoping into the new runtime resolver, making equivalence of authorization and ownership checks an important review boundary. (src/plugins/registry-runtime.ts:24, 2735d9e5055b)
  • Registration-mode preservation: The shared state module centralizes the existing full, discovery, tool-discovery, setup-runtime, and setup-only capability distinctions rather than introducing another public mode. (src/plugins/registry-state.ts:29, 2735d9e5055b)
  • Current-head follow-up: The second commit moves the existing session-accessor boundary debt entry from the old composition root to the new runtime module, matching the code relocation. (scripts/lib/session-accessor-debt-baseline.json:31, 8d42c6751676)
  • Behavior proof: The PR reports a Blacksmith Testbox run, 302 focused passing tests, changed checks, the session-accessor boundary check, a full build, and a clean structured autoreview; GitHub context also shows the relevant build, type, lint, boundary, QA smoke, security, and proof checks succeeding on the current head. (8d42c6751676)

Likely related people:

  • steipete: Authored the detailed canonical issue, is assigned to the PR, supplied the implementation and validation evidence, and describes the work as a maintainer-requested refactor of the central plugin registry. (role: linked refactor owner and assignee; confidence: medium; commits: 2735d9e5055b, 8d42c6751676; files: src/plugins/registry.ts, src/plugins/registry-state.ts, src/plugins/registry-runtime.ts)
What the crustacean ranks mean
  • 🦀 challenger crab: rare, exceptional readiness with strong proof, clean implementation, and convincing validation.
  • 🦞 diamond lobster: very strong readiness with only minor maintainer review expected.
  • 🐚 platinum hermit: good normal PR, likely mergeable with ordinary maintainer review.
  • 🦐 gold shrimp: useful signal, but proof or patch confidence is still limited.
  • 🦪 silver shellfish: thin signal; proof, validation, or implementation needs work.
  • 🧂 unranked krab: not merge-ready because proof is missing/unusable or there are serious correctness or safety concerns.
  • 🌊 off-meta tidepool: rating does not apply to this item.

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
  • ClawSweeper keeps one durable marker-backed review comment per issue or PR.
  • Re-runs edit this comment so the latest verdict, findings, and automation markers stay together instead of adding duplicate bot comments.
  • A fresh review can be triggered by eligible @clawsweeper re-review comments, exact-item GitHub events, scheduled/background review runs, or manual workflow dispatch.
  • PR/issue authors and users with repository write access can comment @clawsweeper re-review or @clawsweeper re-run on an open PR or issue to request a fresh review only.
  • Maintainers can also comment @clawsweeper review to request a fresh review only.
  • Fresh-review commands do not start repair, autofix, rebase, CI repair, or automerge.
  • Maintainer-only repair and merge flows require explicit commands such as @clawsweeper autofix, @clawsweeper automerge, @clawsweeper fix ci, or @clawsweeper address review.
  • Maintainers can comment @clawsweeper explain to ask for more context, or @clawsweeper stop to stop active automation.
Review history (1 earlier review cycle)
  • reviewed 2026-07-13T00:27:42.070Z sha 2735d9e :: needs real behavior proof before merge. :: none

@clawsweeper

clawsweeper Bot commented Jul 13, 2026

Copy link
Copy Markdown
Contributor

ClawSweeper status: review started.

I am starting a fresh review of this pull request: refactor(plugins): decompose plugin registry This is item 1/1 in the current shard. Shard 0/1.

This placeholder means the worker is alive and reading the current context. I will edit this same comment with the actual review when the claws are done clicking.

Crustacean status: shell secured, claws on keyboard, evidence pebbles being sorted.

@openclaw-barnacle openclaw-barnacle Bot added the scripts Repository scripts label Jul 13, 2026
@clawsweeper clawsweeper Bot added proof: sufficient ClawSweeper judged the real behavior proof convincing. rating: 🐚 platinum hermit Good normal PR readiness with ordinary maintainer review expected. status: 👀 ready for maintainer look ClawSweeper has no concrete contributor-facing blocker left for this PR. merge-risk: 🚨 compatibility 🚨 May break existing users, config, migrations, defaults, or upgrade paths. merge-risk: 🚨 security-boundary 🚨 May affect sandboxing, authorization, credentials, or sensitive data. and removed rating: 🐚 platinum hermit Good normal PR readiness with ordinary maintainer review expected. merge-risk: 🚨 compatibility 🚨 May break existing users, config, migrations, defaults, or upgrade paths. merge-risk: 🚨 security-boundary 🚨 May affect sandboxing, authorization, credentials, or sensitive data. status: 👀 ready for maintainer look ClawSweeper has no concrete contributor-facing blocker left for this PR. labels Jul 13, 2026
@steipete

Copy link
Copy Markdown
Contributor Author

Land-ready proof for 8d42c675167633f1ff3a1d55b23f18d7092522a2:

Known proof gaps: none for this internal refactor. No plugin SDK, config, docs, changelog, or user-visible runtime contract changed.

@steipete
steipete merged commit fbade91 into main Jul 13, 2026
162 of 175 checks passed
@steipete
steipete deleted the codex/refactor-plugin-registry-domains branch July 13, 2026 00:44
github-actions Bot pushed a commit to Desicool/openclaw that referenced this pull request Jul 13, 2026
* refactor(plugins): decompose plugin registry

* chore(plugins): move session accessor debt baseline
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

maintainer Maintainer-authored PR merge-risk: 🚨 compatibility 🚨 May break existing users, config, migrations, defaults, or upgrade paths. merge-risk: 🚨 security-boundary 🚨 May affect sandboxing, authorization, credentials, or sensitive data. P3 Low-priority cleanup, docs, polish, ergonomics, or speculative work. proof: sufficient ClawSweeper judged the real behavior proof convincing. rating: 🐚 platinum hermit Good normal PR readiness with ordinary maintainer review expected. scripts Repository scripts size: XL status: 👀 ready for maintainer look ClawSweeper has no concrete contributor-facing blocker left for this PR.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Refactor plugin registry into domain registrars

1 participant