Repository navigation
fix(state): release async context when lease timers stop - #149645
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: blocked before merge. Reviewed September 16, 2026, 2:29 AM ET / 06:29 UTC (Revision 7). ClawSweeper reviewWhat this changesRelease canceled lease timer and worker references so retired callers can be collected, add collection regressions, and document timer cleanup for plugin authors. Merge readiness⛔ Blocked before merge - 1 item remains This remains a useful, focused repair absent from current main and the latest release. No actionable patch defects were found, and the documented acceptance of partial memory improvement resolves the earlier scope concern. Priority: P2 Review scores
Verification
How this fits togetherOpenClaw's state leases serialize trusted operations such as plugin lifecycle changes. Their timers maintain ownership while work runs; stopping a lease must also release references that retain the caller's async context. flowchart TD
A[Plugin lifecycle work] --> B[State lease owner]
B --> C[Heartbeat and expiry timers]
B --> D{Pause or complete}
D --> E[Cancel timers and release handles]
E --> F[Caller context can be collected]
D --> G[Existing ownership and release checks]
Before merge
Agent review detailsSecurityNone. PR surfaceSource +5, Tests +111, Docs +13. Total +129 across 4 files. View PR surface stats
Review metrics
Merge-risk optionsMaintainer options:
Technical reviewBest possible solution: Keep resource release in the existing lease owner and preserve the remaining native ESM growth as separate work without relaxing its acceptance bound. Do we have a high-confidence way to reproduce the issue? Yes: current-main source retains canceled timer handles, and the supplied collection regressions isolate completed, worker, and paused leases. This read-only review inspected the recorded failures and successes without executing them. Is this the best way to solve the issue? Yes: clearing references at the existing cancellation points addresses the retaining owner directly while preserving renewal, ownership verification, and database-release behavior. AGENTS.md: found and applied where relevant. Codex review notes: model internal, reasoning medium; reviewed against cda032ef33a1. LabelsLabel justifications:
EvidenceWhat I checked:
Likely related people:
Rating scale
Overall follows the weaker of proof and patch quality. Workflow
HistoryReview history (6 earlier review cycles)
|
6da8b2e to
c456b25
Compare
a0f524e to
ab6e5b7
Compare
c456b25 to
c43309a
Compare
ab6e5b7 to
9deac96
Compare
c43309a to
caab296
Compare
|
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. |
caab296 to
a099b9d
Compare
40af823 to
04d8b22
Compare
a099b9d to
4e87cff
Compare
|
Merged via squash.
|
…9645) * 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 * fix(state): release stopped lease timer and worker handles * docs(plugins): explain native timer handle cleanup
Landed: merged into
mainas8ee2e683ea97fb249ce8702b318017ba8d9f1155on 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
Completed or paused leases kept canceled native timer handles and their async context reachable.
User Impact
Stopped lease owners release their timer and worker references, allowing retired plugin generations to be collected.
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
Centralize timer stop-and-release for pause and final cleanup, then drop the stopped worker reference. Document the same handle-release obligation for plugin authors. No schema, persistence or configuration changes.
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.All three collection regressions failed before repair and passed afterward: completed timers, completed worker heartbeat and pause after renewal. 101 distinct lease/lifecycle cases passed. Paired five-reload Gateway heaps showed cleared lease fields after repair and removal of the three diagnosed owner paths.
Proof source:
6320346a6d281d4ab570cd67b241ec5d9a74ced8; the originally published stack top14a29985cfbc1b6f5e379b225ae7c00078061c16had 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 explicitplugins.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
b036baa80649passed 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
Stack order (review bottom to top):