Skip to content

fix(plugins): release startup-only service references - #148175

Merged
clawsweeper[bot] merged 2 commits into
mainfrom
codex/bun-service-retention
Sep 15, 2026
Merged

clawsweeper[bot] merged 2 commits into
mainfrom
codex/bun-service-retention

Conversation

@steipete

@steipete steipete commented Sep 14, 2026 •

Copy link
Copy Markdown
Contributor

What Problem This Solves

Plugin service handles intentionally keep only the current generation alive. The existing code avoids syntactic references to the predecessor handle and one-shot onHandle callback, but an engine may retain the entire async activation environment for the returned handle closures. Under Bun, every retired handle and registry stayed reachable across reloads, and the publication callback kept its captured payload alive. Node released both.

This is visible in the existing retention contract: the unowned control collects and the newest handle remains usable, while Bun retains 16 completed generation objects or the publication payload.

Why This Change Was Made

Resolve and transfer predecessor ownership in a synchronous wrapper whose activation ends before any long-lived closure is created. Pass only the prepared current owner into the async lifecycle implementation. Keep the publication callback in a small holder and clear it immediately after publishing the handle, before service startup can yield.

The public function signature, Promise return, startup order, transfer policy, timeouts, error handling, and live handle ownership remain unchanged. The retention child now permits 32 full collections for released async frames to converge; the broken owner still retains every old object after 100 collections, so this does not mask a live reference.

User Impact

Long-running Gateways can reload plugin services without retaining completed service generations or data captured only for initial handle publication, on both Bun and Node.

Evidence

  • Before the fix under the custom Bun runtime: both retention cases fail; all 16 retired handle/registry references and the publication payload remain reachable after 100 full collections while the unowned control collects.
  • After the fix: 100 generation scenarios plus 100 publication scenarios pass under the custom Bun runtime, and the focused retention suite passes 2/2 under both Bun and Node.
  • Service lifecycle siblings pass 95/95 under both Bun and Node across reload, replacement, cron, return-contract, and ordinary service suites.
  • node scripts/check-changed.mjs: passed on the rebased head, including core/test types, lint, formatting, boundaries, dead exports, and import-cycle guards.
  • Fresh P0-P2 autoreview: clean.

@clawsweeper

clawsweeper Bot commented Sep 14, 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 14, 2026
@clawsweeper clawsweeper Bot added P2 Normal backlog priority with limited blast radius. 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 14, 2026
@clawsweeper

clawsweeper Bot commented Sep 14, 2026 •

Copy link
Copy Markdown
Contributor

Codex review: passed. Reviewed September 14, 2026, 10:57 PM ET / September 15, 2026, 02:57 UTC (Revision 10).

ClawSweeper review

What this changes

Separates plugin-service startup references from long-lived service handles and increases the retention test’s garbage-collection budget.

Merge readiness

✅ Ready for maintainer review

The fix remains useful beyond the earlier merged retention repair, and no blocking defect was found in the introduced changes. The previous review recorded no findings; this review identifies no additional required action.

Priority: P2
Reviewed head: 5699742d73082add60859bfea0c6ce07fbdd6faf

Review scores

Measure Result What it means
Overall readiness 🐚 platinum hermit (4/6) A focused lifecycle repair with meaningful existing regression coverage, reported cross-runtime validation, and no blocking findings.
Proof confidence 🌊 off-meta tidepool Not applicable: The maintainer-authored PR is exempt from the external-contributor proof gate. Its reported Bun and Node runs exercise service-handle retention and usability through the production owner; this review did not independently execute them.
Patch quality 🐚 platinum hermit (4/6) No actionable review findings were identified.

Verification

Check Result Evidence
Real behavior Not applicable Not applicable: The maintainer-authored PR is exempt from the external-contributor proof gate. Its reported Bun and Node runs exercise service-handle retention and usability through the production owner; this review did not independently execute them.
Evidence reviewed 7 items Introduced lifecycle change: The complete host-pinned introduction delta moves predecessor transfer into a synchronous preparation function and clears the publication holder before service startup. Inspection of the full lifecycle module found the transfer selection, startup ordering, cleanup deadlines, and capability checks otherwise preserved.
Current main still needs the change: Fetched main still accepts previousHandle and onHandle in the async activation that creates the long-lived handle closures. Its difference from the reviewed head matches the supplied retention repair; the requested separation is not already present.
Retention contract and reported results: The existing child exercises the production lifecycle owner, observes eight retired handles and eight registries or one publication payload through WeakRefs, requires an unowned control to collect, and verifies the newest handle can reload and stop. The captured PR body reports 100 passing runs per scenario under custom Bun after the fix, failure after 100 collections before it, and 95 passing lifecycle sibling tests under both Bun and Node. These are reported results, not executions performed by this review.
Findings None None.
Security None None.

How this fits together

The plugin service lifecycle owner starts background services from the active plugin registry and returns handles used for reload and shutdown. Those handles must retain active service resources without keeping completed startup callbacks or retired generations alive.

flowchart TD
  A[Plugin registry and configuration] --> C[Prepare current service owner]
  B[Previous service handle] --> C
  C --> D[Publish new handle]
  D --> E[Release publication callback]
  E --> F[Start plugin services]
  F --> G[Reload and shutdown handle]
Loading

Before merge

None.

Agent review details

Security

None.

PR surface

Source +40, Tests +3. Total +43 across 2 files.

View PR surface stats
Area Files Added Removed Net
Source 1 55 15 +40
Tests 1 4 1 +3
Docs 0 0 0 0
Config 0 0 0 0
Generated 0 0 0 0
Other 0 0 0 0
Total 2 59 16 +43

Review metrics

Metric Value Why it matters
Production versus regression-support growth production net +40 lines; test support net +3 lines The production growth establishes a separate activation boundary for garbage collection; the test change preserves its behavioral assertions.

Technical review

Best possible solution:

Keep one lifecycle owner while ensuring long-lived handles cannot retain predecessor handles or completed publication callbacks.

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

The source identifies two focused GC scenarios and the PR reports before/after failures and recovery under custom Bun. Independent current-main reproduction was not established during this read-only review.

Is this the best way to solve the issue?

Yes. Separating the startup activation and clearing its one-shot callback directly addresses the reported retention mechanism without adding another lifecycle owner or changing supported caller behavior.

AGENTS.md: found and applied where relevant.

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

Labels

Label justifications:

  • P2: This is a bounded memory-retention repair for repeated plugin-service reloads, with no demonstrated urgent outage.
  • rating: 🐚 platinum hermit: Overall readiness is 🐚 platinum hermit; proof is 🌊 off-meta tidepool and patch quality is 🐚 platinum hermit.
  • status: 🚀 automerge armed: This PR is in ClawSweeper's automerge lane. Not applicable: The maintainer-authored PR is exempt from the external-contributor proof gate. Its reported Bun and Node runs exercise service-handle retention and usability through the production owner; this review did not independently execute them.

Evidence

What I checked:

  • Introduced lifecycle change: The complete host-pinned introduction delta moves predecessor transfer into a synchronous preparation function and clears the publication holder before service startup. Inspection of the full lifecycle module found the transfer selection, startup ordering, cleanup deadlines, and capability checks otherwise preserved. (src/plugins/services.ts:104, 5699742d7308)
  • Current main still needs the change: Fetched main still accepts previousHandle and onHandle in the async activation that creates the long-lived handle closures. Its difference from the reviewed head matches the supplied retention repair; the requested separation is not already present. (src/plugins/services.ts:91, e903d3ece751)
  • Retention contract and reported results: The existing child exercises the production lifecycle owner, observes eight retired handles and eight registries or one publication payload through WeakRefs, requires an unowned control to collect, and verifies the newest handle can reload and stop. The captured PR body reports 100 passing runs per scenario under custom Bun after the fix, failure after 100 collections before it, and 95 passing lifecycle sibling tests under both Bun and Node. These are reported results, not executions performed by this review. (src/plugins/services.retention.test-support.ts:40, 5699742d7308)
  • Production callers preserve synchronous publication: Gateway replacement, rollback, initial startup, and one-shot diagnostics consume the issued handle through callbacks before awaiting startup. The patch retains this ordering and the existing Promise result without changing plugin registration APIs or persisted configuration. (src/gateway/server-plugin-reload.ts:428, 5699742d7308)
  • Related merged repair and routing history: Current-main history records the earlier retention repair at 211ff04 and several preceding lifecycle refactors by Peter Steinberger. The supplied GitHub context confirms fix(plugins): release retired service generations after hot reload #146073 merged and addressed the earlier startup-argument retention chain; this PR addresses the remaining Bun async-frame behavior. Local blame and follow-history inspection encountered unavailable historical blobs, so no exact source-line introduction attribution is claimed. (src/plugins/services.ts, 211ff046c28b)
  • Latest release comparison: The v2026.9.4 source uses the older async startPluginServices(params) implementation and invokes params.onHandle directly. It does not contain this PR’s preparation function or cleared publication holder; no released fix is established. (src/plugins/services.ts:204, 3a9d69db306c)

Likely related people:

  • vincentkoc: Suggested for follow-up; no historical authorship or introduction is verified. (role: unverified routing candidate; confidence: low)
  • 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 (9 earlier review cycles; latest 8 shown)
  • reviewed 2026-09-14T12:32:08.799Z sha 4d6d57d :: needs maintainer review before merge. :: none
  • reviewed 2026-09-14T12:49:33.014Z sha 4d6d57d :: needs maintainer review before merge. :: none
  • reviewed 2026-09-14T14:18:36.412Z sha d8b46dd :: needs maintainer review before merge. :: none
  • reviewed 2026-09-14T17:06:38.919Z sha 221841a :: needs maintainer review before merge. :: none
  • reviewed 2026-09-15T01:43:02.832Z sha b9dc141 :: passed. :: none
  • reviewed 2026-09-15T01:48:50.255Z sha b9dc141 :: passed. :: none
  • reviewed 2026-09-15T02:09:37.186Z sha b9dc141 :: passed. :: none
  • reviewed 2026-09-15T02:35:32.056Z sha 61fbf9988644153f555dc2938cd3158c63954e9c :: passed. :: none

@steipete
steipete force-pushed the codex/bun-service-retention branch from 1fd3247 to 4d6d57d Compare September 14, 2026 12:18
@steipete

Copy link
Copy Markdown
Contributor Author

@clawsweeper re-review

@clawsweeper

clawsweeper Bot commented Sep 14, 2026 •

Copy link
Copy Markdown
Contributor

🦞🧹
ClawSweeper re-review requested.

I asked ClawSweeper to review this item again.
Action: item re-review queued (workflow sweep.yml, event exact_review_queue).
Result: when the review finishes, ClawSweeper will create the durable review comment if needed or update the existing comment in place.

Re-review progress:

@steipete
steipete force-pushed the codex/bun-service-retention branch from 4d6d57d to d8b46dd Compare September 14, 2026 14:01
@steipete

Copy link
Copy Markdown
Contributor Author

@clawsweeper re-review

@clawsweeper

clawsweeper Bot commented Sep 14, 2026 •

Copy link
Copy Markdown
Contributor

🦞🧹
ClawSweeper re-review requested.

I asked ClawSweeper to review this item again.
Action: item re-review queued (workflow sweep.yml, event exact_review_queue).
Result: when the review finishes, ClawSweeper will create the durable review comment if needed or update the existing comment in place.

Re-review progress:

@steipete
steipete force-pushed the codex/bun-service-retention branch from d8b46dd to 221841a Compare September 14, 2026 16:43
@steipete

Copy link
Copy Markdown
Contributor Author

@clawsweeper re-review

@clawsweeper

clawsweeper Bot commented Sep 14, 2026 •

Copy link
Copy Markdown
Contributor

🦞🧹
ClawSweeper re-review requested.

I asked ClawSweeper to review this item again.
Action: item re-review queued (workflow sweep.yml, event exact_review_queue).
Result: when the review finishes, ClawSweeper will create the durable review comment if needed or update the existing comment in place.

Re-review progress:

@steipete
steipete force-pushed the codex/bun-service-retention branch from 221841a to b9dc141 Compare September 15, 2026 01:37
@steipete

Copy link
Copy Markdown
Contributor Author

@clawsweeper automerge

@clawsweeper

clawsweeper Bot commented Sep 15, 2026 •

Copy link
Copy Markdown
Contributor

🦞✅
ClawSweeper merged this PR after the passing review.

Source: clawsweeper[bot]
Feedback: structured ClawSweeper verdict: pass (sha=5699742d73082add60859bfea0c6ce07fbdd6faf)
Merge status: merged by ClawSweeper automerge
Merged at: 2026-09-15T03:16:45Z
Merge commit: 5b1d6e02a0f8

What merged:

  • Separates plugin-service startup references from long-lived service handles and increases the retention test’s garbage-collection budget.

Automerge notes:

  • PR branch already contained follow-up commit before automerge: test(plugins): allow GC convergence in retention proof

The automerge loop is complete.

Automerge progress:

  • 2026-09-15 02:04:42 UTC review queued b9dc1410e2a2 (queued)
  • 2026-09-15 02:30:30 UTC review queued 61fbf9988644 (queued)
  • 2026-09-15 02:36:15 UTC review passed 61fbf9988644 (structured ClawSweeper verdict: pass (sha=61fbf9988644153f555dc2938cd3158c639...)
  • 2026-09-15 02:49:07 UTC review queued 61fbf9988644 (queued)
  • 2026-09-15 02:54:13 UTC active review reused 5699742d7308 (waiting)
  • 2026-09-15 02:54:13 UTC review result reused 5699742d7308 (complete)
  • 2026-09-15 02:58:13 UTC review passed 5699742d7308 (structured ClawSweeper verdict: pass (sha=5699742d73082add60859bfea0c6ce07fbd...)
  • 2026-09-15 03:16:47 UTC merged 5699742d7308 (merged by ClawSweeper automerge)

@clawsweeper clawsweeper Bot added clawsweeper:automerge Maintainer opted this PR into bounded ClawSweeper-reviewed automerge status: 🚀 automerge armed This PR is in ClawSweeper's automerge lane. and removed status: 👀 ready for maintainer look ClawSweeper has no concrete contributor-facing blocker left for this PR. labels Sep 15, 2026
@steipete
steipete force-pushed the codex/bun-service-retention branch from b9dc141 to 61fbf99 Compare September 15, 2026 02:27
@steipete

Copy link
Copy Markdown
Contributor Author

@clawsweeper automerge

@steipete
steipete force-pushed the codex/bun-service-retention branch from 61fbf99 to 5699742 Compare September 15, 2026 02:51
@steipete

Copy link
Copy Markdown
Contributor Author

@clawsweeper automerge

@clawsweeper
clawsweeper Bot merged commit 5b1d6e0 into main Sep 15, 2026
188 checks passed
@clawsweeper
clawsweeper Bot deleted the codex/bun-service-retention branch September 15, 2026 03:16
github-actions Bot pushed a commit to Desicool/openclaw that referenced this pull request Sep 15, 2026
Summary:
- Separates plugin-service startup references from long-lived service handles and increases the retention test’s garbage-collection budget.

Automerge notes:
- PR branch already contained follow-up commit before automerge: test(plugins): allow GC convergence in retention proof

Validation:
- ClawSweeper review passed for head 5699742.
- Required merge gates passed before the squash merge.

Prepared head SHA: 5699742
Review: openclaw#148175 (comment)

Co-authored-by: Peter Steinberger <[email protected]>
Approved-by: steipete
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

clawsweeper:automerge Maintainer opted this PR into bounded ClawSweeper-reviewed automerge maintainer Maintainer-authored PR P2 Normal backlog priority with limited blast radius. rating: 🐚 platinum hermit Good normal PR readiness with ordinary maintainer review expected. size: S status: 🚀 automerge armed This PR is in ClawSweeper's automerge lane.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant