Repository navigation
Conversation
|
🦞👀 Pull request received. I will update this pull request when review starts. ClawSweeper review completeClawSweeper finished reviewing this revision. The review result is being finalized. |
|
Codex review: needs real behavior proof before merge. Reviewed September 29, 2026, 3:53 AM ET / 07:53 UTC (Revision 2). ClawSweeper reviewWhat this changesThe branch shares unchanged captured plugin code and module results across Gateway and prepared-runtime inventories, checks source freshness before reuse, retains native capture custody, and updates plugin lifecycle tests and documentation. Regression provenancePossible regression — probable (failure trace; reviewed change). No predecessor PR is attributed. Merge readiness⛔ Blocked before merge - 9 items remain This PR addresses a real Gateway capture stall, and its new isolated Gateway measurements support the performance gain. It remains blocked because sharing evaluated modules changes the installed-plugin instance contract, while lazy imports can borrow another instance’s admission after their original instance retires. Priority: P1 Review scores
Verification
How this fits togetherOpenClaw’s plugin loader captures installed package files and loads them into managed instances used by Gateway and prepared agent registries. Those instances supply callbacks and module work until retirement releases their resources. flowchart LR
A[Installed plugin files] --> B[Source freshness check]
B --> C[Shared captured code]
C --> D[Gateway instance]
C --> E[Prepared runtime instance]
D --> F[Callbacks and lazy imports]
E --> F
F --> G[Retirement and cleanup]
Decision needed
Why: The PR explicitly relaxes a documented instance-lifetime rule introduced by the merged plugin foundation; the performance benefit does not establish that this compatibility and authority change is acceptable. Before merge
Findings
Agent review detailsSecurityNeeds attention: The shared lazy loader can admit module I/O through a surviving instance after the originating instance retires. PR surfaceSource +209, Tests +111, Docs +6. Total +326 across 11 files. View PR surface stats
Review metrics
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: Reuse captured package bytes while preserving each installed plugin instance’s module evaluation and lazy-import admission, then verify the chosen contract with an existing-install upgrade run. Do we have a high-confidence way to reproduce the issue? Yes. The linked report and PR describe a repeatable isolated Gateway startup and republish path with a large installed plugin, and current-main source shows each fresh registry captures it again; this read-only review did not execute the path. Is this the best way to solve the issue? No, not yet. Sharing capture bytes addresses repeated copying, but sharing evaluated modules and transferable lazy-work admission needs an explicit owner decision or a narrower implementation. Full review comments:
Overall correctness: patch is incorrect AGENTS.md: found and applied where relevant. Codex review notes: model internal, reasoning high; reviewed against e694fa756e3d. LabelsLabel changes:
Label justifications:
EvidenceSecurity concerns:
What 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 (1 earlier review cycle)
|
Republished registries load through fresh plugin inventories, so a per-inventory share still recaptured large plugins on every republish. Share unchanged captures process-wide; every holding inventory borrows the capture's native admission custody, and a capture that observed a missing module is never reused. Refs #160959
|
@clawsweeper re-review |
|
🦞👀 Re-review progress:
|
|
External-plugin compatibility check for c9325fb: confirmed break for a documented plugin pattern. The published external plugins I checked are not affected. Canonical pattern: a plugin module opens a resource at import and closes it in Regression test, not pushed. It goes in
Live test: isolated Gateway, same script on both builds. Steps: startup, 5 forced republishes (
Freeze numbers from the same runs (gbrain capture ≈2.4 GB):
Survey: I downloaded 350 npm packages from OpenClaw plugin searches; 221 declare Bun: Options (not implemented):
|
|
Closing without merging. Sharing loaded plugin code across plugin inventories breaks a documented lifecycle guarantee: a plugin that opens a resource at import and closes it in onDispose fails after a republish with 'database is not open'. A regression test and live runs confirm this (evidence above). Keeping main's behavior while reusing the capture would mean remapping every captured path per instance (roughly +250/-150 lines, with risky native and TypeScript-output remapping), and it would still cost several seconds per bind on large plugins. The owner-level fix is for prepared-runtime republish (and the second startup registry) to reuse the live plugin instance when a plugin's source and config are unchanged, rather than creating a new inventory. That keeps main's semantics and skips the capture entirely. Tracking on #160959. |
Refs #160959
Problem
A Gateway with a large installed plugin blocks its event loop for tens of seconds whenever that plugin is captured.
capturePluginGenerationArtifactcopies the plugin package and its declared dependency tree synchronously. The same unchanged plugin is also captured again every time another registry loads it:loadAgentRuntimePluginRegistryHandle,src/agents/runtime-plugins.ts) then loads its own registry and captures the same plugin a second time.agents.defaults.modelpatch, auth/model reloads, [Bug]: Uncredentialed/expired auth profile causes perpetual prepared-model-catalog refresh loop (100% 1-core CPU, memory leak, tmp disk leak); openclaw doctor does not detect or fix it #160120-style refresh loops) loads plugins in a newPluginCacheinventory and captures again.The first revision of this PR (bfacdaa) shared captures per inventory. That fixed nothing in the live Gateway because each republish uses a fresh inventory. This revision shares them process-wide.
Fix
Captured code for an unchanged installed plugin is shared by every instance that binds it, across inventories.
expectedSourceDigestmust match.isSourceUnchanged()must pass: it checks every captured input's stat identity (dev/ino/mode/size/mtime/ctime) and directory listing, plus every selected native namespace. It does not reread file bytes.reloaded or disabled).borrowPluginNativeAdmissions). Native namespace roots are released only after the last holding inventory retires. This also covers a native namespace admitted lazily after another inventory started sharing the capture.nativeRecovery,recoverySourceMap) are never shared.Behavior change (@steipete, owner decision needed: this relaxes a #144252 invariant)
Removed invariant: a new inventory implies fresh module identity for unchanged source. Unchanged installed plugins now share module identity and module results across live instances and inventories, including Gateway and prepared-runtime registries. Bundled plugins already work this way.
register()still runs per instance with that instance's API. Registered callbacks, runtime-store slots, lifecycle and cleanup stay per instance. Module-scope state in plugin code is shared.What stays isolated:
Lazy module work runs inside the holder that currently has an active call, or else inside the newest accepting holder. For shared code, a retired instance can no longer be told apart from a live one as the origin of that work. This follows from sharing module identity and is part of the same decision.
docs/plugins/architecture.md("Runtime instance and source lifetime") is updated.Evidence
Like-for-like live runs on this Mac: an isolated Gateway (own state dir and port), the same synthetic 878 MB plugin (
plugins.load.paths, 20,403 files, 200 dependency packages), and the same script: startup, 5 forced republishes viaconfig.patch agents.defaults.model,plugins.reloadof the unchanged plugin, then an edit and another reload. Event-loop stalls come from a 50 ms-tick preload that logs gaps over 500 ms./healthzanswerconfig.patchround tripforced retirementwarningsplugins.reload, unchanged sourceplugins.reloadafter editing one fileplugins.reloadof unchanged source still recaptures once. Reload deliberately disposes the old registration before it activates the replacement (server-plugin-reload.ts: drain → dispose → activate), so no holder carries the capture across. The prepared runtime is also marked stale before that drain. This PR does not change that ordering.Tests:
shares one unchanged capture across live instances and recaptures edited sourcebinds through a fresh inventory each time. It fails on main 4d4d99d (different captured file) and passes here. About 80 ms.recaptures unchanged source after a missing dependency is installedfails if the missing-module reuse block is removed. About 40 ms.keeps lazily admitted native bytes while another inventory holds the shared capturefails withENOENTon the captured.soif the native custody borrow is removed. About 60 ms.reclaims only the retired … generation's Node cache records,shares the native %s host owner across plugin generations and recovered workers,keeps declared source package imports and self exports in one emitted graph) expected fresh module identity for unchanged source. They now edit the source before the next load, which keeps their fresh-generation assertions.pnpm tsgo:coreandpnpm tsgo:core:testpass.Not in this PR: the cost of the first capture (about 20–50 s for this plugin, depending on page cache). That work is O(files) and synchronous (
copyFile+ FICLONE, pinned lstat traversal, rehash). It remains a follow-up on #160959.Also note: the
thinkingDefault→ prepared-runtime refresh → restart seen in #160959 is already fixed on main by #160274 (cb3755a).