Skip to content

fix(plugins): release retired callers retained by cached errors - #149643

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

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

Conversation

@Patrick-Erichsen

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

Copy link
Copy Markdown
Contributor

Landed: merged into main as ff7f96f6c132e9eb7be9d71888287ab2396574cf 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

Cached metadata failures kept retired plugin registries alive through lazy Error stacks.

User Impact

Repeated reloads can release the caller retained by a cached diagnostic while preserving the original Error, message, code and cause.

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

Materialize cached stacks as text at the cache owner, including throwing or structured custom formatters. The shared helper also handles retirement diagnostics and wrapped causes.

Evidence

11 cached-error collection cases failed before the first repair. Two custom-formatter cases then exposed the incomplete read-only approach. All 13 final cached-error GC regressions pass; six Node dependency probes confirm the assignment behavior.

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. Production files are unchanged from the original published stack. CI repair proof and commands. Fresh hosted CI must pass on the corrected heads before landing.

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 +33/−7 (net +26); tests/support +212/−4; docs +0/−0. The added owner helper detaches diagnostics consistently across five admission paths and retirement.
  • 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 ← this PR
  2. fix(plugins): release predecessor registries after replacement
  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: M 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: blocked before merge. Reviewed September 16, 2026, 12:16 AM ET / 04:16 UTC (Revision 2).

ClawSweeper review

What this changes

The PR converts cached plugin error stacks and wrapped causes to text so retired callers can be collected, adds collection regressions, and corrects a source-map-sensitive Gateway test.

Merge readiness

⛔ Blocked before merge - 1 item remains

This remains a useful, distinct memory repair that current main does not contain. No blocking correctness findings remain; the inspected evidence supports the scoped fix without claiming that all reload memory growth is resolved.

Priority: P2
Reviewed head: 567bdf9bc1626f46aa702678c828e4036f4ce842

Review scores

Measure Result What it means
Overall readiness 🐚 platinum hermit (4/6) A focused, sound repair with strong scoped runtime evidence and clearly disclosed broader memory limitations.
Proof confidence 🦞 diamond lobster (5/6) ✨ media proof bonus Sufficient (linked_artifact): The inspected linked evidence connects the cache owner to source-built Node 24.19.0 macOS Gateway reloads and heap observations showing detached diagnostic stacks and no observed predecessor-retaining error path. Thirteen collection regressions supplement that scoped live result; the unchanged production code preserves its applicability after the test correction.
Patch quality 🐚 platinum hermit (4/6) No actionable review findings were identified.

Verification

Check Result Evidence
Real behavior Verified Sufficient (linked_artifact): The inspected linked evidence connects the cache owner to source-built Node 24.19.0 macOS Gateway reloads and heap observations showing detached diagnostic stacks and no observed predecessor-retaining error path. Thirteen collection regressions supplement that scoped live result; the unchanged production code preserves its applicability after the test correction.
Evidence reviewed 9 items Cache admission and diagnostic preservation: Five failure-admission paths materialize stacks before retaining errors. Error objects, failure reasons, codes, causes, file-boundary checks, and cache invalidation behavior remain intact.
Shared owner handles custom formatters and causes: The helper assigns string stacks, handles throwing formatters, and traverses causes with cycle detection; retirement uses the same helper. This explicitly depends on Node/V8 stack storage, not a Codex implementation.
Current-main and release necessity: Fetched main has no materializePluginCacheError implementation and still only reads the retirement error stack. The inspected v2026.9.4 directory reader also caches the original error without materializing it; no merged replacement was established.
Findings None None.
Security None None.

How this fits together

OpenClaw’s plugin cache retains metadata and diagnostics for discovery and reload operations. These diagnostics must remain available without keeping retired plugin registries and their callers alive.

flowchart LR
  A[Plugin metadata reads] --> B[Read or parse failure]
  B --> C[Convert error stacks to text]
  D[Cache retirement] --> C
  C --> E[Retained diagnostic]
  C --> F[Caller eligible for collection]
Loading

Before merge

  • Resolve merge risk (P1) - The combined stack still exceeds the ESM forced-GC memory bound; the evidence establishes removal of this retaining path, not complete reload-memory recovery.
Agent review details

Security

None.

PR surface

Source +26, Tests +208. Total +234 across 5 files.

View PR surface stats
Area Files Added Removed Net
Source 2 33 7 +26
Tests 3 212 4 +208
Docs 0 0 0 0
Config 0 0 0 0
Generated 0 0 0 0
Other 0 0 0 0
Total 5 245 11 +234

Review metrics

Metric Value Why it matters
Production versus regression coverage Production net +26 lines; tests/support net +208 lines The production growth centralizes detachment across five cached-failure paths and retirement; most growth exercises collection and diagnostic preservation.

Merge-risk options

Maintainer options:

  1. Decide the mitigation before merge
    Keep diagnostic detachment in the cache owner while preserving error identity and treating remaining reload-memory growth as separate work.
  2. Pause or close
    Do not merge this PR until maintainers decide whether the risk is worth taking.

Technical review

Best possible solution:

Keep diagnostic detachment in the cache owner while preserving error identity and treating remaining reload-memory growth as separate work.

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

Yes: current-main cached failures retain lazy stacks, and the supplied before/after collection cases exercise those production readers. This read-only review inspected source and recorded results without executing tests.

Is this the best way to solve the issue?

Yes: detaching diagnostic stacks at cache admission addresses the retaining owner without replacing errors, weakening file checks, or adding another cache lifecycle.

AGENTS.md: found and applied where relevant.

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

Labels

Label justifications:

  • P2: This is a bounded plugin-reload memory improvement with demonstrated retaining-path recovery 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 linked evidence connects the cache owner to source-built Node 24.19.0 macOS Gateway reloads and heap observations showing detached diagnostic stacks and no observed predecessor-retaining error path. Thirteen collection regressions supplement that scoped live result; the unchanged production code preserves its applicability after the test correction.
  • proof: sufficient: Contributor real behavior proof is sufficient. The inspected linked evidence connects the cache owner to source-built Node 24.19.0 macOS Gateway reloads and heap observations showing detached diagnostic stacks and no observed predecessor-retaining error path. Thirteen collection regressions supplement that scoped live result; the unchanged production code preserves its applicability after the test correction.

Evidence

What I checked:

  • Cache admission and diagnostic preservation: Five failure-admission paths materialize stacks before retaining errors. Error objects, failure reasons, codes, causes, file-boundary checks, and cache invalidation behavior remain intact. (src/plugins/plugin-cache-files.ts:113, 567bdf9bc162)
  • Shared owner handles custom formatters and causes: The helper assigns string stacks, handles throwing formatters, and traverses causes with cycle detection; retirement uses the same helper. This explicitly depends on Node/V8 stack storage, not a Codex implementation. (src/plugins/plugin-cache.ts:52, 567bdf9bc162)
  • Current-main and release necessity: Fetched main has no materializePluginCacheError implementation and still only reads the retirement error stack. The inspected v2026.9.4 directory reader also caches the original error without materializing it; no merged replacement was established. (src/plugins/plugin-cache.ts:363, 027f99d61a93)
  • Re-review continuity: Comparison with the previous reviewed head shows unchanged plugin production code. The only subsequent change generates a runtime payload marker and uses it in the existing JSON.parse assertion, preserving detection of actual retained task reads. (src/gateway/session-utils.subagent.test.ts:178, 567bdf9bc162)
  • Inspected runtime and regression evidence: Read the linked gist at revision d8d77561187053712629b0da2c3de3f15c4c2935, updated 2026-09-16T04:09:31Z. Its cached-diagnostics report describes live five-reload heap inspections with string stack storage and no observed cached-error path to predecessor registries. Recorded regressions show 11 original failures, two additional formatter failures, and 13 final passes. The source-built Node 24.19.0 macOS Gateway completed four 500-update functional lanes; ESM forced-GC growth remained 36.65 MiB against 32 MiB. The CI correction report records the original-order lifecycle file changing from 35 passes/1 failure to 36 passes. Source/build identities and limitations are preserved in the publication and live-proof receipts: https://gist.github.com/Patrick-Erichsen/8ccf64da00f2486dcb05ebf0adc3e711.
  • Node stack-assignment contract: Node v24.19.0 resolves to the recorded dependency SHA. V8’s SetFormattedStack replaces formatted-stack storage or the private error-stack property, supporting the helper’s assignment rather than read-only approach. (deps/v8/src/execution/messages.cc:1192, cdc1b38d40cb)

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 (1 earlier review cycle)
  • reviewed 2026-09-16T03:48:14.000Z sha 9a045a4 :: needs maintainer review before merge. :: none

@Patrick-Erichsen Patrick-Erichsen self-assigned this Sep 16, 2026
@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 merged commit ff7f96f into main Sep 16, 2026
196 checks passed
@Patrick-Erichsen
Patrick-Erichsen deleted the pe/plugin-reload-diagnostic-retention branch September 16, 2026 04: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
…claw#149643)

* fix(plugins): release callers retained by cached diagnostic stacks

* fix(plugins): detach cached stacks from custom formatters

* test(gateway): distinguish retained task data from source maps
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

gateway Gateway runtime 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: M 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