Skip to content

fix(plugins): release predecessor registries after replacement - #149644

Merged
Patrick-Erichsen merged 3 commits into
mainfrom
pe/plugin-reload-resolver-retention
Sep 16, 2026
Merged

Patrick-Erichsen merged 3 commits into
mainfrom
pe/plugin-reload-resolver-retention

Conversation

@Patrick-Erichsen

@Patrick-Erichsen Patrick-Erichsen commented Sep 16, 2026 •

Copy link
Copy Markdown
Contributor

Landed: merged into main as 36e07b8f00243891da8649812863c8cf3ba95349 on September 16, 2026. Required CI passed on the final PR head. All five stack layers are merged; final receipts and before/after proof. The accepted partial repair boundary is unchanged: ESM forced-GC growth remains 36.65 MiB against the 32 MiB limit.

What Problem This Solves

An escaped capability resolver retained the loader scope and its previous plugin registry after replacement.

User Impact

The live replacement can retain its prepared capability facts without retaining the chain of retired registries.

This is one layer of a partial memory repair: the combined ESM forced-GC endurance result is still 36.65 MiB against a 32 MiB limit (failed).

Why This Change Was Made

Create the resolver outside the loader lexical scope. Route the companion runtime-registry tests through the required host-process lane.

Evidence

Landing CI exposed a Reef test teardown bug: native reset preceded temporary-file deletion without draining async database admissions. Both fixtures now await the existing lifecycle close. The real Linux SQLite/inode probe changed from 511 failures to zero under the same 511 inode reuses; the complete Reef file passed 30/30 locally. No production changes, timeout increases or relaxed assertions. Local extension lint could not run through the borrowed-dependency guard; current hosted CI remains required. Reef cleanup proof.

The combined plugin source passed 356/356 tests across 18 files before this test-only cleanup; every production byte remains identical. Integration results.

The four remaining plugin layers were refreshed onto main 08584b3d34c526ad438b39b32931a64a6c61a992. Every authored plugin-layer added/removed line is unchanged. Temporary Goal-test, planner-fixture and chat-renderer corrections were removed because main now owns their repairs: planner fixture, Goal read reuse and UI cleanup. The three files now exactly match main. The original stricter Goal bound passes all12 cases; removing canonical entry reuse still fails at four reads against its three-read limit. Fresh hosted CI is required for the refreshed heads. Refresh proof and identities.

With the independent cached-error repair applied, the predecessor-collection regression still failed; after this repair all 18 retention cases passed. The host-process routing correction separately passed 33 registry tests. Five live CJS replacements removed the observed resolver/predecessor retaining paths.

Proof source: 6320346a6d281d4ab570cd67b241ec5d9a74ced8; the originally published stack top 14a29985cfbc1b6f5e379b225ae7c00078061c16 had the identical Git tree (bcdb4a87fb86add0a49982acf26af4568056f61b). The source-built live runs completed all four 20-warmup/500-measured lanes with functional checks passing and stable Gateway PID/socket. Real CLI install/reinstall auto-application and a separate physical shutdown/relaunch also passed. The 500-update trigger was source edits plus explicit plugins.reload; HTTP/tool checks were sampled, with full per-update tuples verified in the short diagnostics.

Layer proof and reproduction commands · Before/after log excerpts · Live reload/restart measurements · Fresh review and commit provenance.

Fresh publication validation: P0–P2 cumulative review found no actionable defects. At publication, the stack plus main b036baa80649 passed 99 tests across 11 files, zero failed/skipped, including cache, registry-retention and state-lease owner/sibling coverage. The first integration attempt lacked package-local dependency links; the same command passed after restoring the existing links without an install or source changes. This combined-tree check supplements the exact-source build and live evidence above.

Landing follow-up: two test-only corrections now distinguish retained task bytes from Vite source-map text and bundled companion reuse from installed-plugin capture. The paired reproductions passed 36/36 lifecycle tests and 8/8 companion cases; both scoped P0–P2 reviews and full changed-file gates passed. These follow-up commits change tests only; the five reviewed production patches are preserved. CI repair proof and commands. Those original test repairs remain in their owning layers; their historical results retain their source identities.

Scope and limitations
  • Earlier whole-session shared-OCM isolation failed; later private-store cleanup and named-epoch peer continuity passed separately. The initiating writer was not established.
  • Test counts from overlapping historical suites are not additive. No real external channel account or universal plugin compatibility claim.
  • Production +10/−1 (net +9); tests/support +100/−3; docs +0/−0. The factory establishes a distinct lexical owner so escaped callbacks cannot capture loader options.
  • No new configuration, public protocol or persistent-store contract.

Stack order (review bottom to top):

  1. fix(plugins): release retired callers retained by cached errors
  2. fix(plugins): release predecessor registries after replacement ← this PR
  3. fix(state): release async context when lease timers stop
  4. fix(plugins): reuse bundled setup code across reloads
  5. fix(plugins): reuse the published inbound registry during reload

@clawsweeper

clawsweeper Bot commented Sep 16, 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 size: S maintainer Maintainer-authored PR labels Sep 16, 2026
@Patrick-Erichsen
Patrick-Erichsen marked this pull request as ready for review September 16, 2026 03:42
@clawsweeper clawsweeper Bot added P2 Normal backlog priority with limited blast radius. 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. labels Sep 16, 2026
@clawsweeper

clawsweeper Bot commented Sep 16, 2026 •

Copy link
Copy Markdown
Contributor

Codex review: needs maintainer review before merge. Reviewed September 16, 2026, 2:28 AM ET / 06:28 UTC (Revision 8).

ClawSweeper review

What this changes

The PR prevents plugin replacement callbacks from retaining older registries, adds collection coverage, and corrects database-related test routing and teardown.

Merge readiness

✅ Ready for maintainer review

This remains a useful, focused repair absent from current main. No actionable defects were found. The documented acceptance of the broader memory shortfall resolves the previous review’s blocker for this bounded change.

Priority: P2
Reviewed head: c78c6731e1cef62ebfa0dfbaae425e1b447e9ca3

Review scores

Measure Result What it means
Overall readiness 🐚 platinum hermit (4/6) A focused repair with strong scoped runtime evidence, useful regression coverage, and no actionable findings.
Proof confidence 🦞 diamond lobster (5/6) ✨ media proof bonus Sufficient (linked_artifact): The inspected evidence connects the loader closure repair to five real CJS Gateway reloads that removed the diagnosed predecessor retaining path while preserving functionality. Historical collection regressions and source-built install/restart observations supplement this; the separately accepted ESM endurance failure remains explicitly unresolved.
Patch quality 🐚 platinum hermit (4/6) No actionable review findings were identified.

Verification

Check Result Evidence
Real behavior Verified Sufficient (linked_artifact): The inspected evidence connects the loader closure repair to five real CJS Gateway reloads that removed the diagnosed predecessor retaining path while preserving functionality. Historical collection regressions and source-built install/restart observations supplement this; the separately accepted ESM endurance failure remains explicitly unresolved.
Evidence reviewed 9 items Introduced production change: The module-level factory captures the same selected capability context without sharing the loader’s lexical scope. Registry assembly and provider registration continue consuming the existing resolver contract; no public API, authorization decision, or persisted format changes.
Current-main necessity and release check: Fetched main still creates the resolver inside the loader at line 183. The latest release’s file also contains the inline resolver at line 160. No supplied merged PR fixes this separate retention path; the merged cached-error repair addresses another owner.
Latest released source: GitHub’s contents endpoint for v2026.9.4 confirms the inline capability resolver. This verified release read replaced an unsuccessful local historical-blob read.
Findings None None.
Security None None.

How this fits together

OpenClaw’s plugin loader builds registries from plugin code, configuration, and prepared capability information. Replacement registries keep active plugin operations available while retired registries release their resources.

flowchart LR
  A[Plugin code and configuration] --> B[Plugin loader]
  C[Prepared capability information] --> D[Isolated resolver closure]
  D --> B
  E[Previous registry] --> B
  B --> F[Replacement registry]
  F --> G[Active plugin operations]
  E --> H[Retirement and collection]
Loading

Before merge

None.

Agent review details

Security

None.

PR surface

Source +9, Tests +97. Total +106 across 5 files.

View PR surface stats
Area Files Added Removed Net
Source 1 10 1 +9
Tests 4 100 3 +97
Docs 0 0 0 0
Config 0 0 0 0
Generated 0 0 0 0
Other 0 0 0 0
Total 5 110 4 +106

Review metrics

Metric Value Why it matters
Production versus validation growth Production net +9 lines; tests/support net +97 lines Production growth creates a separate closure scope; most added code exercises collection and orderly test cleanup.

Technical review

Best possible solution:

Keep capability callbacks scoped to their prepared facts and preserve normal registry retirement, with broader native ESM memory work remaining separate.

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

Yes: current main retains the implicated inline closure, and the supplied before/after collection regression isolates its predecessor-retention effect. This read-only review did not execute a current-main reproduction.

Is this the best way to solve the issue?

Yes: moving closure creation outside the loader removes the diagnosed capture while preserving the returned context and existing lifecycle contracts.

AGENTS.md: found and applied where relevant.

Codex review notes: model internal, reasoning medium; reviewed against cda032ef33a1.

Labels

Label justifications:

  • P2: This is a bounded plugin-reload memory repair with demonstrated benefit and no established urgent outage.
  • 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 (linked_artifact): The inspected evidence connects the loader closure repair to five real CJS Gateway reloads that removed the diagnosed predecessor retaining path while preserving functionality. Historical collection regressions and source-built install/restart observations supplement this; the separately accepted ESM endurance failure remains explicitly unresolved.
  • proof: sufficient: Contributor real behavior proof is sufficient. The inspected evidence connects the loader closure repair to five real CJS Gateway reloads that removed the diagnosed predecessor retaining path while preserving functionality. Historical collection regressions and source-built install/restart observations supplement this; the separately accepted ESM endurance failure remains explicitly unresolved.

Evidence

What I checked:

  • Introduced production change: The module-level factory captures the same selected capability context without sharing the loader’s lexical scope. Registry assembly and provider registration continue consuming the existing resolver contract; no public API, authorization decision, or persisted format changes. (src/plugins/loader-runtime-core.ts:84, c78c6731e1ce)
  • Current-main necessity and release check: Fetched main still creates the resolver inside the loader at line 183. The latest release’s file also contains the inline resolver at line 160. No supplied merged PR fixes this separate retention path; the merged cached-error repair addresses another owner. (src/plugins/loader-runtime-core.ts:183, cda032ef33a1)
  • Latest released source: GitHub’s contents endpoint for v2026.9.4 confirms the inline capability resolver. This verified release read replaced an unsuccessful local historical-blob read. (src/plugins/loader-runtime-core.ts:160, 3a9d69db306c)
  • Meaningful collection regression: The added scenario loads a real generated plugin through the production loader, retires its predecessor, checks predecessor collection with a WeakRef, and then executes the replacement’s tool. It extends the existing subprocess collection table without adding a production testing seam. (src/plugins/runtime.retention.test-support.ts:78, c78c6731e1ce)
  • Inspected owner-specific and live evidence: Read the linked gist’s capability-resolver note, historical result excerpts, and live-proof summary. The predecessor test failed after the independent cache repair and passed after this repair. Five real CJS reloads removed the diagnosed resolver/predecessor paths. The source-built macOS Node 24.19.0 Gateway evidence identifies OpenClaw source 6320346a6d281d4ab570cd67b241ec5d9a74ced8 and records functional reload, install/reinstall, and physical restart success. The combined ESM forced-GC result remains failed at 36.65 MiB against 32 MiB; this is not evidence of complete memory acceptance. Source: https://gist.github.com/Patrick-Erichsen/8ccf64da00f2486dcb05ebf0adc3e711.
  • Re-review continuity and accepted scope: The supplied prior review contained no findings or published rank-up moves; its blocker concerned complete memory acceptance. The dated disposition explicitly accepts landing the focused stack with that remaining failure: fix(plugins): release predecessor registries after replacement #149644 (comment). Comparing the prior reviewed head with this head shows only Reef teardown changes; production bytes are unchanged. (extensions/reef/src/state.test.ts:91, c78c6731e1ce)

Likely related people:

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

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 (7 earlier review cycles)
  • reviewed 2026-09-16T03:47:55.021Z sha a0f524e :: blocked before merge. :: none
  • reviewed 2026-09-16T04:16:11.780Z sha ab6e5b7d54e5f10e1a80d0d6d32ebe048a1a9c5a :: needs maintainer review before merge. :: none
  • reviewed 2026-09-16T04:47:11.055Z sha 9deac962eae4b29802bcc37c32b9ba07c19e30d7 :: needs maintainer review before merge. :: none
  • reviewed 2026-09-16T05:09:41.474Z sha 667440a7bb537b48c94c684f8a7ac78537ffdecb :: blocked before merge. :: none
  • reviewed 2026-09-16T05:30:03.982Z sha 40af8236c963f2aa083ea55491a8fa33a1f075bd :: needs maintainer review before merge. :: none
  • reviewed 2026-09-16T05:48:00.864Z sha 40af8236c963f2aa083ea55491a8fa33a1f075bd :: blocked before merge. :: none
  • reviewed 2026-09-16T06:07:04.159Z sha 04d8b22 :: blocked before merge. :: none

@Patrick-Erichsen

Copy link
Copy Markdown
Contributor Author

Maintainer disposition for the review’s memory-limit item: land this focused repair as part of the five-PR retention stack, subject to CI and the native landing gates. The maintainer explicitly approved landing the stack with the documented remaining failure.

This accepts the independently demonstrated owner repairs; it does not claim complete reload-memory acceptance. The 500-update ESM forced-GC result remains 36.65 MiB against the unchanged 32 MiB limit. The remaining native ESM module-job growth stays open for further work; no threshold increase, idle subtraction, or plateau claim is being used to turn that result green.

The linked proof separately demonstrates caller collection, predecessor release, stopped-handle cleanup, bundled setup code reuse, and published-registry reuse. Functional reload/install/restart observations retain their recorded scope. Installed/source plugins keep their captured generations, and compiled bundled code replacement retains its documented build-and-restart requirement.

Proof: https://gist.github.com/Patrick-Erichsen/8ccf64da00f2486dcb05ebf0adc3e711

@Patrick-Erichsen Patrick-Erichsen self-assigned this Sep 16, 2026
@Patrick-Erichsen
Patrick-Erichsen force-pushed the pe/plugin-reload-resolver-retention branch from a0f524e to ab6e5b7 Compare September 16, 2026 04:08
Base automatically changed from pe/plugin-reload-diagnostic-retention to main September 16, 2026 04:36
@openclaw-barnacle openclaw-barnacle Bot added gateway Gateway runtime size: M and removed size: S labels Sep 16, 2026
@Patrick-Erichsen
Patrick-Erichsen force-pushed the pe/plugin-reload-resolver-retention branch from ab6e5b7 to 9deac96 Compare September 16, 2026 04:38
@openclaw-barnacle openclaw-barnacle Bot added size: S app: web-ui App: web-ui and removed gateway Gateway runtime size: M labels Sep 16, 2026
@Patrick-Erichsen
Patrick-Erichsen force-pushed the pe/plugin-reload-resolver-retention branch from 40af823 to 04d8b22 Compare September 16, 2026 05:55
@Patrick-Erichsen
Patrick-Erichsen merged commit 36e07b8 into main Sep 16, 2026
190 of 192 checks passed
@Patrick-Erichsen
Patrick-Erichsen deleted the pe/plugin-reload-resolver-retention branch September 16, 2026 06:36
@Patrick-Erichsen

Copy link
Copy Markdown
Contributor Author

Merged via squash.

github-actions Bot pushed a commit to Desicool/openclaw that referenced this pull request Sep 17, 2026
…law#149644)

* fix(plugins): isolate retained capability resolver scope

* test(plugins): run runtime registry state checks in host processes

* test(reef): drain state lifecycle before fixture removal
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

app: web-ui App: web-ui maintainer Maintainer-authored PR P2 Normal backlog priority with limited blast radius. proof: sufficient ClawSweeper judged the real behavior proof convincing. rating: 🐚 platinum hermit Good normal PR readiness with ordinary maintainer review expected. size: S 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.

1 participant