Skip to content

feat: manage and reload plugins without restarting the Gateway - #135599

Closed
steipete wants to merge 10 commits into
mainfrom
codex/plugin-lifecycle-reload
Closed

steipete wants to merge 10 commits into
mainfrom
codex/plugin-lifecycle-reload

Conversation

@steipete

@steipete steipete commented Sep 1, 2026 •

Copy link
Copy Markdown
Contributor

This implementation is being split into independently landable PRs. This draft preserves the complete candidate and end-to-end evidence; the full restartless lifecycle feature is not yet landed.

Landed slices:

These twenty-four merged PRs total −1,739 production LOC. #139891 was closed as redundant after #139820 independently fixed its session-delivery completion race. The remaining work is the coherent instance/source/resource ownership foundation, Gateway activation and RPC, then operator and agent surfaces. The separately reproduced process-group cancellation settlement race is fixed by #139957. The old A2UI hover/click test follow-up is already fixed on main by #139635.

What Problem This Solves

Operators and agents can install, enable, disable, uninstall, and reload plugins without restarting the Gateway. CLI, RPC, Control UI, and agent operations report whether a change was saved, applied, rejected, rolled back, or committed with a cleanup failure. TypeScript plugin edits can become available to running conversations without replaying completed actions.

Why This Change Was Made

One instance lifecycle now owns captured code, registrations, admitted calls, streams, and cleanup: prepare and validate replacements, fence affected instances, drain their work, publish replacements, and retire resources. Unrelated plugins retain their instances. This replaces duplicate loading, tool-scope, cache, and rollback paths; config watching and explicit reload share the same owner.

User Impact

Gateway connections stay up; affected services or channel accounts may restart internally. Control UI adds Reload and Remove. Installation supports npm, Git, and local sources, with existing consent, integrity, and enablement policy. Offline mutations save state for startup; reload requires a running Gateway. Bundled plugins can be disabled, and uninstall preserves linked source files.

Reload captures TypeScript, helpers, lazy imports, assets, and declared dependencies. Standalone files support literal local imports and asset URLs; computed inputs require a directory plugin. Plugin authors register cleanup through api.lifecycle.onDispose. Managed facades remain replaceable across generations and reject fixed definitions, freezing, and sealing before they can pin retired code.

Managed Codex conversations refresh native tool catalogs while preserving completed results; imported or supervised sessions need a new session for changed tool names or schemas. Native binary changes and compiled core code retain their build/update/restart path. Custom native module loaders require a separate process. This is a lifecycle boundary for trusted plugins, not a security sandbox. See plugin architecture.

Evidence

Historical donor validation: candidate 453d4ba6d6e1b3ebb2249c0e76ca87dc420957de on main b3bdf3e1 completed a fresh Linux build/live run successfully. All 40 lifecycle scenarios, the separate custom-loader rejection check, and five final-dispatch/authority cases passed. Gateway health-lifetime and plugin-reload recovery suites passed before the build, and all child processes joined. All 182 exported evidence files were preserved and hash-verified through native artifact/download transport. Testbox run. The donor full-branch CI is historical and is not a green-CI claim. Its Android trust-test race was repaired in #139807, and the A2UI hover/click race was independently repaired on main in #139635; each landed slice carries its own exact-head green CI.

That historical donor candidate is −5 handwritten production LOC (+14,648/−14,653), +15,158 tests/support, and +903 generated against its actual base; moves are classified consistently. Split PRs carry their own scoped proof and CI. The later split candidates include additional ownership repairs and are still net-positive in aggregate; the requested overall net-negative production target has not yet been met. Final combined build/live proof remains pending. The separate instance foundation now passes fresh startup and two upgrades from official 2026.9.2: configured TypeScript plugins and a real CLI-managed JavaScript/CJS/assets installation. Those results are tied to the frozen foundation candidate under review, not the complete split feature.

The transcript integration passed 67 checks across four files after reproducing and fixing two cleanup races: shared global/selective stop could report success before cleanup completed, and a late watcher could lose its cleanup owner after failure. It preserves main's capture implementation and the feature's provider-selective restart behavior. Independent integration review completed with no findings. A further 49 catalog checks passed on the d922 predecessor.

The earlier completed Linux proof on 7fb3182c55155e223080841579a4fd4a0c16ad35 also passed full build, singleton/build identity, readiness, startup profile, and 40 runtime scenarios: 13 native Codex, 21 built-Gateway/Control UI, and six discovery cases. These cover fresh linked TypeScript/npm installation, entry/helper/lazy-import/asset reload, failed-reload preservation, disable/enable/uninstall, draining, and conversation continuation. The UI maintained one connection, with zero unexpected closes, document reloads, or page errors; an unrelated service started once.

Final-dispatch proof requested by ClawSweeper: five additional authority cases exercised the real Gateway dispatcher/agent runner or rejection before dispatch. Retained callbacks succeeded; unpublished, replaced, and revoked-during-await callbacks were rejected; admitted work drained after replacement. Two actual HTTP requests reached the scripted localhost provider. The host constructed the trusted registry; this proves the dispatch/revocation boundary, not installer trust selection or external authentication.

Loader compatibility boundary: an unsupported custom native-loader reload returned a visible preparation failure with committed: false and retained the working generation. Ordinary fresh installations and installed-code reloads passed separately. This does not establish compatibility for arbitrary custom loaders or all stable-release upgrades; representative stable-release upgrade coverage remains an explicit limitation for maintainer acceptance.

Config and data-model scope: the current source audit adds no configuration schema keys/defaults, database schema/migrations, or protocol-version bump. Management RPC shapes are additive. The resolved-source write receipt is internal operation metadata, not a persisted configuration key; two existing help descriptions change. The memory settings page removes obsolete restart messaging, not vector/embedding storage. Existing storage encoding and limits remain in place.

All completed runtime phases and child processes joined. The initial artifact protocol failed; all 169 original files were recovered and hash-verified without rerun or resync. The scenarios use synthetic plugins, providers, and channel inputs; real external inference, authentication, and channel delivery are not claimed.

Before/after Control UI captures — completed 7fb318 runtime proof

These captures belong to the explicitly identified earlier build, not the newer 453d4ba runtime run.

Active before reload

Reloaded without reconnecting

Disabled

Enabled again

Removal confirmation

Removed while connected

[email protected]

Credit: @steipete.

@clawsweeper

clawsweeper Bot commented Sep 1, 2026 •

Copy link
Copy Markdown
Contributor

🦞👀
ClawSweeper picked this up.

Pull request received. I will update this pull request when review starts.

ClawSweeper review complete

ClawSweeper finished reviewing this revision. The review result is being finalized.

View the workflow run.

@openclaw-barnacle openclaw-barnacle Bot added docs Improvements or additions to documentation app: android App: android app: web-ui App: web-ui gateway Gateway runtime extensions: memory-lancedb Extension: memory-lancedb cli CLI command changes security Security documentation scripts Repository scripts commands Command implementations agents Agent runtime and tooling extensions: codex plugin: google-meet plugin: file-transfer plugin: workboard plugin: logbook Logbook automatic work journal plugin plugin: beam Beam session sharing plugin extensions: canvas size: XL maintainer Maintainer-authored PR labels Sep 1, 2026
@steipete
steipete marked this pull request as ready for review September 1, 2026 22:32
@steipete
steipete requested a review from a team as a code owner September 1, 2026 22:32
@steipete
steipete force-pushed the codex/plugin-lifecycle-reload branch 2 times, most recently from c942ae5 to 1c2e746 Compare September 2, 2026 03:37
@openclaw-barnacle openclaw-barnacle Bot closed this Sep 2, 2026
@steipete

Copy link
Copy Markdown
Contributor Author

Implemented and landed through 32 independent PRs. The principal feature cuts are #144252 (instance/source/resource ownership), #145484 (Gateway, CLI and UI lifecycle), #145649 (uninstall), #145710 (install writers), #145713 (batch updates), #145648 (embedded conversations), and #145917 (managed native conversations). This umbrella is now superseded by those merged changes.

Final verification used main 93a5d822750d726481ab2998e53b404d04e58b27, containing every campaign merge, after a successful frozen install and normal build. Real Gateway/CLI/PTY flows passed 14 install routes, three batch-update/compensation scenarios, and clean/warning uninstall with held-work ordering and exactly-once cleanup. Five delivery scenarios and 12 embedded requests passed, including edited tools/helpers, no replay, Code Mode and cancellation. An actual Codex 0.153.4 six-request flow retained the question/answer and exact prepared image/text, used updated tools, and recorded the real terminated-command result before continuation without synthesizing a missing result. Node 24.19.0 and Bun 1.4.2 source-Gateway/CLI-handler checks observed changed TypeScript code with the same PID/config and restartRequired:false.

All recorded test processes/listeners closed. The final full source/build/dependency capture matched the initial capture; build fingerprint 9a2c63b73c1146105b9334d6c54376f07ed1737a646aaef7e1ae3b4e2b89e452. These were isolated real processes with synthetic service endpoints, not production messages or external model inference. Native imported/supervised ownership retains its documented new-conversation guidance, and arbitrary plugin-owned leftovers remain best-effort cleanup.

Both final PRs passed exact-head CI: embedded, 136 jobs and native, 131 jobs. Two native test-wiring failures were repaired without weakening runtime or test guards. The final CLI harness also learned the existing typed pre-admission busy contract: verify unchanged state, wait the server's retry interval, and retry that refused request once. Original failures and source-qualified receipts are retained.

The final campaign is net +8,970 production lines, including the earlier −1,841-line cleanup; tests/support, generated code and tooling are counted separately. The aggressive code-size target was not achieved. Startup compatibility and the restart-free behavior are implemented and verified.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

agents Agent runtime and tooling app: android App: android app: macos App: macos app: web-ui App: web-ui channel: discord Channel integration: discord channel: zalo Channel integration: zalo cli CLI command changes commands Command implementations docs Improvements or additions to documentation extensions: codex extensions: memory-core Extension: memory-core extensions: memory-lancedb Extension: memory-lancedb extensions: openshell feature: ✨ showcase ClawSweeper spotlight: unusually compelling feature idea for maintainer attention. gateway Gateway runtime maintainer Maintainer-authored PR merge-risk: 🚨 compatibility 🚨 May break existing users, config, migrations, defaults, or upgrade paths. P2 Normal backlog priority with limited blast radius. plugin: beam Beam session sharing plugin plugin: file-transfer plugin: google-meet plugin: logbook Logbook automatic work journal plugin plugin: mxc plugin: workboard proof: sufficient ClawSweeper judged the real behavior proof convincing. proof: telegram-e2e This PR needs Telegram Test Server proof with the repository E2E skill. rating: 🐚 platinum hermit Good normal PR readiness with ordinary maintainer review expected. scripts Repository scripts security Security documentation 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.

3 participants