Skip to content

fix(plugins): release idle workers after preparing bundled state operations - #206172

Merged
vincentkoc merged 2 commits into
mainfrom
fix/retire-bundled-operation-capture-20261127
Nov 26, 2026
Merged

vincentkoc merged 2 commits into
mainfrom
fix/retire-bundled-operation-capture-20261127

Conversation

@vincentkoc

@vincentkoc vincentkoc commented Nov 26, 2026 •

Copy link
Copy Markdown
Member

Refs #192547

What Problem This Solves

A Gateway that prepares bundled state operations can keep a JavaScript worker alive until the plugin registration closes. In a one-CPU ARM64 Gateway with the default memory plugin, the preparation worker held nine callable handles and had no pending calls at readiness, in the first chat handler, and at acknowledgement. The worker remained alive through the following 60-second soak. Its physical V8 heap was 32.5 MiB in the 2 GiB reference service. That figure measures the worker heap. The 768 MiB service has a separate first-reply test. Gateway measurements

User Impact

The Gateway can retire the last preparation worker before the first late state operation. Registered operations continue using their admitted code and dependencies after installed files change or disappear. An independent borrower keeps the shared worker until it releases its own capture. An in-place edit to an already loaded bundled export still requires a Gateway restart.

Why This Change Was Made

The preparation worker owned the final copy of the selected operation graph. The host now transfers the same captured file facts, module lookups and native leases, and makes that final copy directly into an independent recovery claim. It releases the source worker after the transfer completes. Failed replies and synchronous binding cleanup both join physical resource disposal. The change applies to immutable bundled state-operation captures. External-plugin preparation retains its existing ownership and timing. Related external-plugin experiment

Evidence

  • On stock ee4061ce, both async loader cases observed a live preparation worker at first use. Both synchronous controls passed. On b6e51224, seven focused suites passed all 90 tests, including first invocation after file removal, replacement registration, scoped and unscoped capture, native files, recovery, unexpected worker exit, and final teardown. The lost-reply and pending-close controls each failed independently on the respective pre-fix implementation. The plugin-platform TypeScript check and typed lint passed. Linux x64 proof host
  • Forty synthetic registrations ran in stock/fixed/fixed/stock order on the same host, with 10 samples per dependency shape and revision. Every relative-dependency registration selected 115 original bytes and copied 230 logical bytes. Every package-import registration selected 218 and copied 436. Both revisions recorded two captures and two receipt passes. Registration p50/p95 was 239/509 ms on stock and 245/524 ms on the fix for relative dependencies, and 244/273 ms versus 250/272 ms for package imports. The two late exports together took 2.16/3.09 ms versus 2.10/2.79 ms and 1.52/2.34 ms versus 1.34/1.59 ms respectively.
  • Independent lifecycle review covered native lease transfer, the bundled restart guard and both error paths. Local ClawSweeper completed the exact committed range ee4061ce..b6e51224 with no listed risks or open questions. The signed successor 2417dad8 moves one existing ownership comment immediately above its type assertion. Executable source lines match the tested b6e51224 exactly. The repository’s assertion guard counted 0 uncovered assertions on ee4061ce, 1 on b6e51224, and 0 on 2417dad8. Local ClawSweeper also completed the successor range. Production changes add 137 lines and remove 45. Tests add 183 and remove 8.
  • The matched ARM64 test used one CPU, a 768 MiB service cgroup, a 1 GiB outer cgroup and zero swap. Stock and patched images reached readiness at 33.206 s and 33.876 s, and acknowledged the first chat at 37.418 s and 37.488 s, respectively. Both peaked at 768 MiB and both lost the Gateway before the mock inference endpoint received a request. The first service OOM kill fell in 35.499–35.763 s on stock and 39.979–40.245 s on the patch, with three and two local kills in total. This single pair establishes that the 768 MiB first reply still fails. The external sampler did not measure worker ownership or a successful state operation in that run. ARM64 comparison and limits

@vincentkoc vincentkoc self-assigned this Nov 26, 2026
@clawsweeper

clawsweeper Bot commented Nov 26, 2026

Copy link
Copy Markdown
Contributor

🦞👀
ClawSweeper picked this up.

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

@clawsweeper clawsweeper Bot added P2 Normal backlog priority with limited blast radius. impact:other This issue has meaningful maintainer-visible impact outside the owned taxonomy. labels Nov 26, 2026
@vincentkoc
vincentkoc marked this pull request as ready for review November 26, 2026 21:03
@vincentkoc
vincentkoc enabled auto-merge (squash) November 26, 2026 21:23
@vincentkoc
vincentkoc merged commit 65a8bc8 into main Nov 26, 2026
125 checks passed
@vincentkoc
vincentkoc deleted the fix/retire-bundled-operation-capture-20261127 branch November 26, 2026 21:25
@vincentkoc

Copy link
Copy Markdown
Member Author

Merged via squash auto-merge.

github-actions Bot pushed a commit to Desicool/openclaw that referenced this pull request Nov 27, 2026
…ations (openclaw#206172)

* fix(plugins): retire preparation workers for bundled state operations

* chore(plugins): place the capture handoff invariant at its assertion
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

impact:other This issue has meaningful maintainer-visible impact outside the owned taxonomy. P2 Normal backlog priority with limited blast radius. size: M

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant