Skip to content

fix(plugins): share unchanged captured plugin code across inventories - #160983

Closed
obviyus wants to merge 2 commits into
mainfrom
fix/plugin-capture-freeze
Closed

obviyus wants to merge 2 commits into
mainfrom
fix/plugin-capture-freeze

Conversation

@obviyus

@obviyus obviyus commented Sep 29, 2026 •

Copy link
Copy Markdown
Collaborator

Refs #160959

Problem

A Gateway with a large installed plugin blocks its event loop for tens of seconds whenever that plugin is captured. capturePluginGenerationArtifact copies the plugin package and its declared dependency tree synchronously. The same unchanged plugin is also captured again every time another registry loads it:

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.

  • Key: origin, real root, entry, standalone flag, dev source root and SDK resolution. expectedSourceDigest must 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.
  • Custody: the capture directory, loader hooks and TypeScript builds are released when the last holder's module disposal runs. A retiring instance's own value views are still revoked (reloaded or disabled).
  • Native custody: every inventory that holds a capture borrows the capture's native admission state (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.
  • Missing modules: once a capture observes a module it cannot resolve, it is not reused. Installing that dependency later therefore gets a fresh capture.
  • Recovery binds (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:

  • Edited source, a changed native namespace, or a module missing at capture time gets a fresh capture and fresh module evaluation. The old holder keeps its old bytes.
  • A retired instance's views are revoked.
  • Capture bytes and native roots are not deleted while any holder or holding inventory remains.

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 via config.patch agents.defaults.model, plugins.reload of 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.

main 4d4d99d this PR c9325fb
Startup captures 2 1
Startup event-loop stalls 51.3 s + 48.3 s 20.2 s
First /healthz answer 67.6 s 26.6 s
Republishes 1–5: new captures 5 (one per republish) 0
Republishes 1–5: config.patch round trip 39.7–98.5 s 1.2–2.2 s
Republishes 1–5: max event-loop stall 37.1–96.0 s each 0.7 s
Capture dir set across republishes changes every republish, 2–3 dirs constant (1 dir)
Capture disk across republishes 1.7–2.6 GB 877 MB constant
forced retirement warnings on every republish none
plugins.reload, unchanged source 2 new captures; stalls 16.5 + 26.9 + 24.9 s 1 new capture, old released; stalls 11.5 + 17.3 s
plugins.reload after editing one file 2 fresh captures (2 dirs, 1.7 GB) 1 fresh capture; old released after drain (1 dir, 877 MB)

plugins.reload of 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 source binds 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 installed fails if the missing-module reuse block is removed. About 40 ms.
  • keeps lazily admitted native bytes while another inventory holds the shared capture fails with ENOENT on the captured .so if the native custody borrow is removed. About 60 ms.
  • Three existing tests (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.
  • Focused suites pass: 365 tests across 16 files (plugin module generation incl. interop/sdk/disposal/update/sibling-assets/native-layout, generation artifact incl. admission/ownership/streaming, loader recovery, capture recovery/directory, conditions, provider-discovery capture lifetime, doctor lint plugin captures/native admission, startup source captures, run-main cleanup, prepared catalog worker custody/captures), plus 7 adjacent loader-consumer files (116 tests). pnpm tsgo:core and pnpm tsgo:core:test pass.

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).

@clawsweeper

clawsweeper Bot commented Sep 29, 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.

@clawsweeper clawsweeper Bot added P1 High-priority user-facing bug, regression, or broken workflow. 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. rating: 🦪 silver shellfish Thin PR readiness signal; proof, validation, or implementation needs work. status: 📣 needs proof The PR needs real behavior proof before ClawSweeper can clear the contributor ask. labels Sep 29, 2026
@clawsweeper

clawsweeper Bot commented Sep 29, 2026 •

Copy link
Copy Markdown
Contributor

Codex review: needs real behavior proof before merge. Reviewed September 29, 2026, 3:53 AM ET / 07:53 UTC (Revision 2).

ClawSweeper review

What this changes

The 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 provenance

Possible 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
Reviewed head: c9325fb4f50c46ec0c0257f9e828c9a74db7a746
Owner decision: Required. See Decision needed.

Review scores

Measure Result What it means
Overall readiness 🦐 gold shrimp (3/6) The real Gateway measurements make the performance case credible, but the changed instance contract and unproven retired-holder boundary prevent merge confidence.
Proof confidence 🦐 gold shrimp (3/6) Needs stronger real behavior proof before merge: Authority-chain proof required: The PR body’s isolated Mac Gateway run reports fewer captures, shorter config-patch stalls, and a faster health response after this loader change. It does not show an allowed lazy import and the nearest retired-holder import being accepted or rejected before module I/O; an existing-install published-updater-to-candidate run is also absent. No stored-data contract changes. After adding proof, update the PR body; ClawSweeper should re-review automatically. If it does not, the PR author or someone with repository write access can comment @clawsweeper re-review.
Patch quality 🦐 gold shrimp (3/6) Security review found an item that needs attention.

Verification

Check Result Evidence
Real behavior Needs proof Needs stronger real behavior proof before merge: Authority-chain proof required: The PR body’s isolated Mac Gateway run reports fewer captures, shorter config-patch stalls, and a faster health response after this loader change. It does not show an allowed lazy import and the nearest retired-holder import being accepted or rejected before module I/O; an existing-install published-updater-to-candidate run is also absent. No stored-data contract changes. After adding proof, update the PR body; ClawSweeper should re-review automatically. If it does not, the PR author or someone with repository write access can comment @clawsweeper re-review.
Evidence reviewed 10 items Introduced cross-inventory sharing: The pinned PR head reuses a published capture and binds another instance to its loader when source checks pass.
Lazy admission selection: The new owner chooses any active holder, then the newest accepting holder, for module work; it does not identify the instance that originated a deferred import.
Final module work: The shared hook can resolve a dependency and call captureModule before returning its module URL, so choosing a different holder can reach module I/O.
Findings 2 actionable findings [P1] Preserve per-instance module state when reusing captures
[P1] Reject lazy imports originating from a retired instance
Security Needs attention Retired module work can borrow another instance’s admission: The holder fallback does not establish that the selected live instance authorized a deferred import from the old graph, so stale work can reach dependency capture under a different owner.

How this fits together

OpenClaw’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]
Loading

Decision needed

Question Recommendation
Should unchanged installed plugins share evaluated module identity across live inventories, including lazy work that can be admitted by a different holder? Share bytes, preserve instances: Reuse the costly capture while keeping each instance’s module state and deferred import authority separate.

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

  • Add real behavior proof - Needs stronger real behavior proof before merge: Authority-chain proof required: The PR body’s isolated Mac Gateway run reports fewer captures, shorter config-patch stalls, and a faster health response after this loader change. It does not show an allowed lazy import and the nearest retired-holder import being accepted or rejected before module I/O; an existing-install published-updater-to-candidate run is also absent. No stored-data contract changes. After adding proof, update the PR body; ClawSweeper should re-review automatically. If it does not, the PR author or someone with repository write access can comment @clawsweeper re-review.
  • Preserve per-instance module state when reusing captures (P1) - This reuse binds another live instance to the same evaluated module results. An installed plugin that stores its register() configuration at module scope can then make callbacks in the first registry observe the second registry’s state, whereas current main gives those instances distinct module results. Preserve that boundary or obtain explicit approval and upgrade proof for changing it.
  • Reject lazy imports originating from a retired instance (P1) - When deferred work from a retired holder reaches the shared hook, this fallback can select another accepting holder and proceed to dependency capture and module I/O. The original instance would reject a new run. Keep the originating admission through resolution or reject the stale import before its final side effect.
  • Resolve security concern: Retired module work can borrow another instance’s admission - The holder fallback does not establish that the selected live instance authorized a deferred import from the old graph, so stale work can reach dependency capture under a different owner.
  • Resolve merge risk (P1) - Existing installed plugins can silently share mutable module-scope state between live Gateway and prepared-runtime instances, changing the documented per-instance behavior without an accepted compatibility decision.
  • Resolve merge risk (P1) - A deferred import from a retired instance can select another accepting holder; rejection before dependency capture or module evaluation has not been shown.
  • Resolve merge risk (P1) - The isolated fresh Gateway run does not establish how an existing installation behaves when the published updater hands its plugin state to this candidate.
  • Complete next step (P2) - Resolve the two instance-boundary findings, obtain the plugin owner’s module-identity decision, and provide retired-holder final-effect plus published-upgrade proof before merge.
  • Resolve maintainer decision - Resolve the maintainer decision shown above before merge.

Findings

  • [P1] Preserve per-instance module state when reusing captures — src/plugins/plugin-instance-module-loader.ts:159-160
  • [P1] Reject lazy imports originating from a retired instance — src/plugins/plugin-instance-module-loader.ts:169-175
  • [medium] Retired module work can borrow another instance’s admission — src/plugins/plugin-instance-module-loader.ts:169
Agent review details

Security

Needs attention: The shared lazy loader can admit module I/O through a surviving instance after the originating instance retires.

PR surface

Source +209, Tests +111, Docs +6. Total +326 across 11 files.

View PR surface stats
Area Files Added Removed Net
Source 7 255 46 +209
Tests 3 111 0 +111
Docs 1 13 7 +6
Config 0 0 0 0
Generated 0 0 0 0
Other 0 0 0 0
Total 11 379 53 +326

Review metrics

Metric Value Why it matters
Implementation growth production +209, tests +111 The growth implements cross-inventory capture custody for the reported stall, while the ownership contract remains unresolved.

Root-cause cluster

Relationship: fixed_by_candidate
Canonical: #160959
Summary: This PR targets repeated capture in the open Gateway-stall report; the credential-driven refresh-loop report describes a distinct trigger that can amplify the capture cost.

Members:

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

Merge-risk options

Maintainer options:

  1. Preserve instance boundaries (recommended)
    Keep capture reuse but isolate evaluated module state and bind deferred work to its admitting instance before module I/O.
  2. Approve the contract change
    Accept shared module state only with explicit owner approval, published-upgrade evidence, and allowed-versus-retired final-effect proof.

Technical review

Best 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:

  • [P1] Preserve per-instance module state when reusing captures — src/plugins/plugin-instance-module-loader.ts:159-160
    This reuse binds another live instance to the same evaluated module results. An installed plugin that stores its register() configuration at module scope can then make callbacks in the first registry observe the second registry’s state, whereas current main gives those instances distinct module results. Preserve that boundary or obtain explicit approval and upgrade proof for changing it.
    Confidence: 0.91
  • [P1] Reject lazy imports originating from a retired instance — src/plugins/plugin-instance-module-loader.ts:169-175
    When deferred work from a retired holder reaches the shared hook, this fallback can select another accepting holder and proceed to dependency capture and module I/O. The original instance would reject a new run. Keep the originating admission through resolution or reject the stale import before its final side effect.
    Confidence: 0.85

Overall correctness: patch is incorrect
Overall confidence: 0.88

AGENTS.md: found and applied where relevant.

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

Labels

Label changes:

  • add rating: 🦐 gold shrimp: Overall readiness is 🦐 gold shrimp; proof is 🦐 gold shrimp and patch quality is 🦐 gold shrimp.
  • remove rating: 🦪 silver shellfish: Current PR rating is rating: 🦐 gold shrimp, so this older rating label is no longer current.

Label justifications:

  • P1: The reported recapture path can stall the Gateway and channel work for tens of seconds during startup and prepared-runtime refresh.
  • merge-risk: 🚨 compatibility: The PR changes installed plugins from per-instance evaluated modules to shared module results across inventories.
  • merge-risk: 🚨 security-boundary: Deferred module work can use another instance’s live admission after its originating instance retires.
  • rating: 🦐 gold shrimp: Overall readiness is 🦐 gold shrimp; proof is 🦐 gold shrimp and patch quality is 🦐 gold shrimp.
  • status: 📣 needs proof: The PR needs real behavior proof before ClawSweeper can clear the contributor ask. Needs stronger real behavior proof before merge: Authority-chain proof required: The PR body’s isolated Mac Gateway run reports fewer captures, shorter config-patch stalls, and a faster health response after this loader change. It does not show an allowed lazy import and the nearest retired-holder import being accepted or rejected before module I/O; an existing-install published-updater-to-candidate run is also absent. No stored-data contract changes. After adding proof, update the PR body; ClawSweeper should re-review automatically. If it does not, the PR author or someone with repository write access can comment @clawsweeper re-review.

Evidence

Security concerns:

  • [medium] Retired module work can borrow another instance’s admission — src/plugins/plugin-instance-module-loader.ts:169
    The holder fallback does not establish that the selected live instance authorized a deferred import from the old graph, so stale work can reach dependency capture under a different owner.
    Confidence: 0.85

What I checked:

Likely related people:

  • steipete: Suggested for follow-up; no historical authorship or introduction is verified. (role: unverified routing candidate; confidence: low)
  • Patrick Erichsen: Suggested for follow-up; no historical authorship or introduction is verified. (role: unverified routing candidate; confidence: low)

Rank-up moves

Optional improvements that raise the rating; they are not merge blockers.

  • Resolve the instance module-identity decision with the plugin lifecycle owner.
  • Show final-effect proof for an allowed lazy import and a retired holder’s import, including rejection before module I/O.
  • Add a published-updater-to-candidate run using existing installed plugin state.

Rating scale

Score Internal tier Crab rank Meaning
6/6 S 🦀 challenger crab Exceptional readiness
5/6 A 🦞 diamond lobster Very strong readiness
4/6 B 🐚 platinum hermit Good normal PR; ordinary maintainer review
3/6 C 🦐 gold shrimp Useful, but confidence is limited
2/6 D 🦪 silver shellfish Proof or implementation needs work
1/6 F 🧂 unranked krab Not merge-ready
N/A NA 🌊 off-meta tidepool Rating does not apply

Overall follows the weaker of proof and patch quality.
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.

Workflow

  • 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.

History

Review history (1 earlier review cycle)
  • reviewed 2026-09-29T05:15:04.544Z sha bfacdaa :: needs real behavior proof before merge. :: [P1] Preserve instance-local module state when reusing captures | [P1] Reject lazy imports from a retired holder

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
@obviyus
obviyus requested a review from steipete September 29, 2026 07:47
@obviyus obviyus changed the title fix(plugins): share unchanged captured plugin code across instances fix(plugins): share unchanged captured plugin code across inventories Sep 29, 2026
@obviyus
obviyus marked this pull request as ready for review September 29, 2026 07:47
@openclaw-barnacle openclaw-barnacle Bot added the docs Improvements or additions to documentation label Sep 29, 2026
@obviyus

obviyus commented Sep 29, 2026

Copy link
Copy Markdown
Collaborator Author

@clawsweeper re-review

@clawsweeper

clawsweeper Bot commented Sep 29, 2026 •

Copy link
Copy Markdown
Contributor

🦞👀
Exact review queued.

Re-review progress:

@clawsweeper clawsweeper Bot added rating: 🦐 gold shrimp Decent PR readiness signal, but merge confidence is limited. and removed rating: 🦪 silver shellfish Thin PR readiness signal; proof, validation, or implementation needs work. labels Sep 29, 2026
@obviyus

obviyus commented Sep 29, 2026

Copy link
Copy Markdown
Collaborator Author

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 api.lifecycle.onDispose. The v2026.9.6 docs support this pattern: "A managed runtime instance owns its module results" and "release … sockets … in onDispose".

Regression test, not pushed. It goes in src/plugins/loader.instance-cleanup.test.ts: load the unchanged plugin through a fresh inventory, retire the previous inventory, then call the new instance's tool. The module holds a node:sqlite DatabaseSync(":memory:").

  • main 4d4d99d: passes
  • this PR: fails with Error: database is not open. The retiring instance's onDispose closes the handle that the live instance shares.

Live test: isolated Gateway, same script on both builds. Steps: startup, 5 forced republishes (config.patch agents.defaults.model), then plugins.reload. After every step I called each plugin's tools through /tools/invoke, then ran a real agent turn that calls the probe tool. The same PI turn also checks that gbrain's systemPromptAddition was applied.

Plugin Module-scope pattern main this PR
probe (sqlite at import, closed in onDispose) canonical risky pattern OK after every step database is not open after republishes 1–5 (tools/invoke and agent turn); recovers only after plugins.reload (fresh capture)
gbrain-context-engine (garrytan/gbrain latest-stable, 0.59.18.0, via plugins.load.paths) lazy module-level Postgres singleton and caches; no onDispose teardown addition applied on every turn that ran (5/5) addition applied 7/7, 0 assemble failures
openclaw-code-agent 5.0.0 (npm) onDispose and lifecycle.signal teardown, but registration-scoped with a globalThis owner registry agent_stats and agent_sessions OK after every step OK after every step

Freeze numbers from the same runs (gbrain capture ≈2.4 GB):

main this PR
republish config.patch round trip 0.8–186 s; 4 of 5 returned "recovery restart required" 3.6–6.8 s, all ok
max event-loop stall per republish 93–180 s (4 of 5 republishes) 2.6–5.4 s
forced retirement warnings 32 0

Survey: I downloaded 350 npm packages from OpenClaw plugin searches; 221 declare openclaw.extensions. Only openclaw-code-agent uses lifecycle.onDispose or lifecycle.signal, and none closes an import-time resource there. Plugins with lazy module singletons (gbrain PG engine, forge-openclaw-plugin's managed child, tencent-weixin quote store) keep working under sharing; by inspection, sharing would also stop main's per-republish duplicates of those singletons (not exercised: no Postgres or forge runtime configured).

Bun: plugin-module-generation.bun.test.ts passes (OPENCLAW_TEST_BUN_LAUNCHER=1, Bun 1.4.2).

Options (not implemented):

  1. Land the contract change: document in sdk-runtime.md that module scope is shared across instances of unchanged installed code, as it already is for bundled code. Resources should be allocated in register() and released in onDispose. This silently breaks plugins that follow the current docs, although none of the plugins surveyed do.
  2. Sharing only among concurrently live inventories does not fix it. The regression test and the live break are both concurrent cases: the new inventory binds before the old one retires.
  3. Share capture bytes but evaluate each instance's own plugin modules fresh. In the capture profile, copy + hash + lstat is ~25 s of 30.9 s, so most of the gain stays. A fresh evaluation needs a distinct real path per instance: CommonJS resolves symlinks to the real file and caches modules by filename, while ESM ?query does give a fresh module. On the 20,403-file synthetic plugin, a full clonefile tree took 3.9 s and a hardlink tree 5.3 s (measured while a Gateway was running). Linking only the plugin package's own files, and sharing node_modules, would cost roughly O(own files).

@obviyus

obviyus commented Sep 29, 2026

Copy link
Copy Markdown
Collaborator Author

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.

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

Labels

docs Improvements or additions to documentation 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. P1 High-priority user-facing bug, regression, or broken workflow. rating: 🦐 gold shrimp Decent PR readiness signal, but merge confidence is limited. size: M status: 📣 needs proof The PR needs real behavior proof before ClawSweeper can clear the contributor ask.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant