Skip to content

fix(plugins): keep Gateway responsive during initial plugin loading - #198302

Merged
RomneyDa merged 5 commits into
mainfrom
openclaw/rri508-initial-binding
Nov 16, 2026
Merged

RomneyDa merged 5 commits into
mainfrom
openclaw/rri508-initial-binding

Conversation

@RomneyDa

@RomneyDa RomneyDa commented Nov 13, 2026 •

Copy link
Copy Markdown
Member

What Problem This Solves

Fixes Gateway stalls when dependency-heavy plugins are initially loaded: executable binding calls back into the preparation worker synchronously while the plugin loader is running.

User Impact

Initial plugin loading keeps the foreground event loop moving while preserving plugin execution, retained-source ownership, and recovery. No configuration or public SDK change is required. This removes the measured synchronous worker-wait path; it is not a universal startup-latency guarantee.

Why This Change Was Made

The worker retains source custody and plain inspection facts. The existing capture owner reconstructs local executable bindings, replaying ordered acquisitions without repeating covered source inspection or retaining a host Jiti compiler. Initial file reconstruction and receipt validation yield cooperatively; synchronous CLI and lazy callbacks drain the same steps synchronously. Frozen recovery, native admission, and worker-exit cleanup remain attached to their existing owners. Obsolete remote source-mapping callbacks are removed.

Related: #176192. Thanks to @ExoHumann (Krzysztof Kisiel) for the original cooperative-capture/local-binding design and investigation. This is a separately implemented, initial-binding-only repair against current source, not a copy of that contributor branch.

Scope excludes the separate failed-reload transaction repair in #198262, broader startup optimization, and the original PR's Windows installed-package claims. The unused asynchronous recovery API and test-only callers were removed; existing synchronous recovery remains. The complete #198262 patch was not composed or retested here. No merge is requested.

Evidence

November 15 conflict reconciliation

Merged main a4cc2adb5d1a746296803f73955e089df98a68df into the existing PR lineage. Tested local commit: 864eecaa97934addc51268b18e8958f3310a16ae; tree: 266a9295626f4a05ed61cd49c99e4057eb322ef8. Published to the existing PR through the explicitly approved standard Git push route, without force. New-head CI is pending; the previous green run is historical evidence only.

  • Resolved both actual conflicts, retaining cooperative local binding and cleanup alongside main’s asynchronous snapshot admission. Both sides’ validation, availability, retirement, and cleanup regressions remain.
  • Focused worker, snapshot-worker, source-lookup, and snapshot-artifact suites: 62 passed across 4 files, 52.28 seconds Vitest / 53.86 seconds wrapper. Initial dependency/config and nonexistent test-path setup failures were corrected before this successful run.
  • Targeted two-file oxfmt and oxlint, plugins-platform test typecheck, and whitespace checks passed. Worker compilation and SDK boundary declaration generation completed. No new full package build or live Gateway run is claimed.
  • Fresh independent native review of the two conflicted files and three overlapping auto-merges found no actionable findings. Five-file diff SHA-256 against main: 003dccb34635d6d42d8df7607f5d2b4bd6c63ff65bae89873aacd6affb50f1d2. This is the authorized substitute, not local ClawSweeper or autoreview; the reviewer did not execute tests. Simplification added no new production machinery.
  • Current test delta: 532 net lines; the retained 142-line allocation covers the 132 lines beyond the allowance. Earlier figures below describe historical revisions, not exact-tree proof of this integrated head.

Historical repair evidence

Tested repair commit: d3b1a14b0f7d118e9e599a714763410f56a7fdc9; published head: 2dce362c929017c06959d0a25829b83fefd8330b; base: 60aead2d9454cbd26c4101ecf8613599c540d6b2. The publisher's final metadata commit has no tree change: both tested and published trees are aa66e7b493443e176c25ddfb08178c57a62e4876.

  • Trusted-base regression: dependency execution preserved, with 78 synchronous Atomics.wait calls on the base and zero with the fix.
  • The first exact-head CI and hosted review exposed a missing wrapper inventory closure, repeated host-side bundled inspection, and stale consumer accounting. The repair includes both new wrapper modules, retains worker-inspected facts, and reconciles exact capture/receipt/native-byte/recovery-location assertions without weakening ownership or cleanup checks.
  • Native pnpm test:ci-failed 198302 --run replay: 66 passed / 3 skipped across 6 files, 210.88s wrapper. All baseline ratchets passed. Separate host-inspection validation: 68 passed across 5 files, with core/plugins-platform test typechecks. Consumer validation: 10 passed across 3 files. Combined repair lint, format, and whitespace checks passed. These runs overlap.
  • Earlier focused validation: 157 passed / 1 skipped, then 166 passed / 6 skipped; Node counterpart 78 passed. Failure-cleanup follow-up: 57 passed across 4 files, including regressions red before the correction and green with zero synchronous waits and removed capture directories. These are separate, overlapping runs, not an aggregate unique-test count.
  • Real Gateway + live OpenAI gpt-4.1 rerun on November 13, 2026: 130 foreground timer advances during preparation, zero synchronous worker waits, actual initial_probe tool call, fresh dependency sentinel in its result, and exact final sentinel in chat history. Both provider requests returned HTTP 200 SSE. The existing call-through transport hook selects the native tool on request one and no tool on request two; responses and plugin execution are not mocked. Earlier auto-choice text-only attempts are not counted as tool-flow proof. Final runtime rebuild: 2m 7s; test: 22.16s; full build/test wrapper: 185.35s. Synthetic real-Gateway E2E also passed.
  • Fresh independent native review covered the complete original patch and the final 14-file repair. The cleanup P2 and all four hosted finding groups are addressed; final repair review found no actionable findings. Committed repair diff exactly matches reviewed SHA256 4d02b3eb91c69eb1e55dc10fead0c561d4547ca7c547ea1d029672e345bc24c1. This is the explicitly approved independent-review substitute, not an autoreview or local ClawSweeper result. Reviewers did not independently execute tests. New exact-head CI and hosted re-review remain separate.

Test growth is 542 net lines for the real Gateway tool-flow fixture and distinct custody, cleanup, off-thread inspection, and accounting regressions. A focused allocation records exactly 142 lines beyond the unchanged 400-line allowance. The repair removes unused asynchronous recovery machinery rather than retaining parallel APIs.

Coverage limits: one Linux host; no new Windows installed-package, universal responsiveness, upgrade, or combined #198262 verification is claimed. No credentials, live configuration, provider request bodies, or generated proof files are included.

Worked on by

RomneyDa and others added 2 commits November 13, 2026 14:00
Bind retained plugin sources locally and reconstruct initial captures cooperatively without synchronous preparation-worker calls. Preserve frozen recovery and await failed reconstruction cleanup.

Co-authored-by: Krzysztof Kisiel <[email protected]>
Co-authored-by: vincentkoc <[email protected]>
Co-authored-by: RomneyDa <[email protected]>
Worked on by:
- @vincentkoc

Co-authored-by: vincentkoc <[email protected]>
OpenClaw-Publication: 9a492d90-c371-4517-8294-a206174abd17
@clawsweeper

clawsweeper Bot commented Nov 13, 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.

@clawsweeper clawsweeper Bot added clawsweeper:intake:bug Preliminary submission classification; full source review pending. clawsweeper:intake:needs-environment Preliminary submission classification; full source review pending. clawsweeper:intake:needs-repro Preliminary submission classification; full source review pending. P1 High-priority user-facing bug, regression, or broken workflow. merge-risk: 🚨 automation 🚨 May affect CI, automerge, proof capture, label sync, or maintainer automation. rating: 🦪 silver shellfish Thin PR readiness signal; proof, validation, or implementation needs work. status: ⏳ waiting on author ClawSweeper has contributor-facing work open and is waiting for author action. and removed clawsweeper:intake:bug Preliminary submission classification; full source review pending. clawsweeper:intake:needs-environment Preliminary submission classification; full source review pending. clawsweeper:intake:needs-repro Preliminary submission classification; full source review pending. labels Nov 13, 2026
@clawsweeper

clawsweeper Bot commented Nov 13, 2026 •

Copy link
Copy Markdown
Contributor

Codex review: needs maintainer review before merge.

What this changes

This PR reconstructs executable plugin bindings locally and yields during initial capture instead of synchronously calling the preparation worker.

Example: Load initial-probe and execute its initial_probe tool, which imports initial-dependency.

  • Before: The reported baseline executes the dependency but performs 78 synchronous worker waits.
  • After: The reported live Gateway run performs zero synchronous worker waits, advances a foreground timer 130 times during preparation, and returns the dependency sentinel.

Review scores

Measure Result What it means
Overall readiness 🐚 platinum hermit (4/6) A useful, focused repair with public live behavior evidence, distinct lifecycle regressions, and successful exact-head gates; the persisted snapshot format and receipt contract remain unchanged.
Proof confidence 🐚 platinum hermit (4/6) Sufficient (live_output): The public live-run report exercises actual initial preparation in a Linux Gateway, foreground timer progress, real provider responses, plugin-tool execution, and chat-history delivery on the published tree; Windows and combined reload-recovery behavior are explicitly excluded.
Patch quality 🐚 platinum hermit (4/6) No actionable review findings were identified.

Product

Kind: Bug fix · Worth it: Yes · Fix scope: Complete
User problem: The Gateway can stop making foreground progress while initially binding dependency-heavy plugins.
Reason: The maintainer-authored direction repairs a demonstrated responsiveness failure while preserving configuration, public SDK contracts, and the separately scoped reload-recovery work.

Merge readiness

✅ Ready for maintainer review

Keep this PR open: the initial-binding stall remains on main, all four earlier findings are addressed, and no new actionable defect was found.

Priority: P1
Reviewed head: 2dce362c929017c06959d0a25829b83fefd8330b

Before merge

None.

Findings

None.

Agent review details

How this fits together

The plugin loader prepares source and dependency custody in a worker, then binds executable modules to plugin instances that register Gateway capabilities.

flowchart LR
  A[Plugin loader] --> B[Preparation worker]
  B --> C[Retained source and inspection facts]
  C --> D[Cooperative local reconstruction]
  D --> E[Plugin instance bindings]
  E --> F[Gateway tools and callbacks]
Loading

Technical review

Best possible solution:

Keep source inspection and custody with the existing worker while using the shared capture steps for cooperative initial binding and synchronous lazy consumers.

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

Current-main source exposes the synchronous worker-call path, and the supplied base/head regression reports 78 waits versus zero with dependency execution preserved; this read-only review ran no target code.

Is this the best way to solve the issue?

The repair addresses executable binding at its existing owner, removes remote mapping callbacks, and shares acquisition logic across synchronous and cooperative consumers without introducing a competing capture implementation.

AGENTS.md: found and applied where relevant.

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

Provenance checked

  • Worker preparation and executable binding changes intended behavior with a stated reason (fix: keep gateway responsive during external plugin preparation #172750: Move external source preparation off the serving thread while retaining synchronous consumers, native custody, and recovery.)
  • Shared preparation worker lifetime keeps the original intent (dfb91dc: Share physical preparation execution while preserving independent artifact state, cleanup, and worker-exit invalidation.)
  • Off-thread inspection and retained source facts keeps the original intent (c7693dd: Prepare Doctor contracts off-thread and reuse source custody without sharing callback instances.)
  • Capture cleanup and acquisition failures keeps the original intent (feat: manage and reload plugins without Gateway restarts #145484: Keep failed acquisitions rejected and bind cleanup to captured-source lifetime; subsequent asynchronous cleanup work preserves foreground progress.)
  • Guarded file batches and receipts keeps the original intent (perf(plugins): batch guarded file opens during startup #172333: Reuse guarded filesystem roots within synchronous work while preserving containment and receipt bytes; this patch closes batches before asynchronous yields.)
  • Frozen snapshots and bundled development reload keeps the original intent (feat(plugins): publish installed source snapshots #189624: Preserve immutable snapshot bindings and independent runtime ownership; bundled development reload retains its existing opt-in and shared-host handling.)

Testing

Proof path: in-process harness.

Security

None.

Evidence

What I checked:

Likely related people:

  • Krzysztof Kisiel: Raw commit a99f797 adds src/plugins/plugin-generation-worker.ts:31 relative to its recorded parents. This identifies author metadata, not feature responsibility or a PR merger. (role: source-line author; confidence: high; commits: a99f797f39ce; files: src/plugins/plugin-generation-worker.ts)
  • Peter Steinberger: Raw commit c7693dd adds src/plugins/plugin-generation-worker.ts:205 relative to its recorded parents. This identifies author metadata, not feature responsibility or a PR merger. (role: source-line author; confidence: high; commits: c7693dd033d5; files: src/plugins/plugin-generation-worker.ts)
  • Vincent Koc: Raw commit 720f842 adds src/plugins/plugin-generation-capture.ts:44 relative to its recorded parents. This identifies author metadata, not feature responsibility or a PR merger. (role: source-line author; confidence: high; commits: 720f8423c8cd; files: src/plugins/plugin-generation-capture.ts)

PR surface

Source +279, Tests +542, Other +5. Total +826 across 27 files. Added test files: 1.

View PR surface stats
Area Files Added Removed Net
Source 13 508 229 +279
Tests 12 655 113 +542
Docs 0 0 0 0
Config 0 0 0 0
Generated 0 0 0 0
Other 2 5 0 +5
Total 27 1168 342 +826

Preflight source

Source unknown. Source comparison at the observed PR snapshot only. Completion is self-reported; body, policy, tests, execution, and report bytes are not verified.

Labels

Label changes:

  • add proof: sufficient: Contributor real behavior proof is sufficient.
  • add rating: 🐚 platinum hermit: Overall readiness is 🐚 platinum hermit; proof is 🐚 platinum hermit and patch quality is 🐚 platinum hermit.
  • add status: 👀 ready for maintainer look: ClawSweeper has no concrete contributor-facing blocker left for this PR.

Label justifications:

  • P1: Dependency-heavy initial plugin binding can block the Gateway foreground event loop, affecting serving responsiveness.
  • rating: 🐚 platinum hermit: Overall readiness is 🐚 platinum hermit; proof is 🐚 platinum hermit and patch quality is 🐚 platinum hermit.
  • status: 👀 ready for maintainer look: ClawSweeper has no concrete contributor-facing blocker left for this PR.
  • proof: sufficient: Contributor real behavior proof is sufficient.

Rating scale

6/6 🦀 challenger crab · 5/6 🦞 diamond lobster · 4/6 🐚 platinum hermit · 3/6 🦐 gold shrimp · 2/6 🦪 silver shellfish · 1/6 🧂 unranked krab. Overall follows the weaker of proof and patch quality; ✨ marks media proof (a screenshot, video, or linked artifact) that directly shows the changed behavior.

Workflow

ClawSweeper edits this one comment on every review. Comment @clawsweeper re-review for a fresh review only. Repair and merge execution lanes are retired.

History

Review history (1 earlier review cycle)
  • reviewed 2026-11-13T14:17:15.103Z sha 658f721 :: needs changes before merge. :: [P2] Add the new modules to the trusted wrapper inventory | [P2] Preserve off-thread inspection for bundled operation sources | [P2] Remove unused asynchronous rollback copying from this repair | [P2] Migrate the tests consuming the changed capture lifecycle

Reviewed November 13, 2026, 10:21 AM ET / 15:21 UTC (Revision 2).

RomneyDa and others added 2 commits November 13, 2026 14:34
Keep worker-inspected module facts when reconstructing local executable bindings; include the new runtime owners in the extracted PR wrapper inventory and reconcile exact capture lifecycle proofs. Remove the unused async recovery API from this initial-binding repair.

Co-authored-by: Krzysztof Kisiel <[email protected]>
Co-authored-by: vincentkoc <[email protected]>
Co-authored-by: RomneyDa <[email protected]>
Worked on by:
- @vincentkoc

Co-authored-by: vincentkoc <[email protected]>
OpenClaw-Publication: 70724870-17ea-47f5-9efd-1e35a58e0ab1
@openclaw-barnacle openclaw-barnacle Bot added gateway Gateway runtime scripts Repository scripts labels Nov 13, 2026
@clawsweeper clawsweeper Bot removed rating: 🦪 silver shellfish Thin PR readiness signal; proof, validation, or implementation needs work. merge-risk: 🚨 automation 🚨 May affect CI, automerge, proof capture, label sync, or maintainer automation. status: ⏳ waiting on author ClawSweeper has contributor-facing work open and is waiting for author action. labels Nov 13, 2026
@RomneyDa

Copy link
Copy Markdown
Member Author

@clawsweeper re-review

@clawsweeper

clawsweeper Bot commented Nov 13, 2026 •

Copy link
Copy Markdown
Contributor

🦞👀
Exact review queued.

Re-review progress:

@clawsweeper clawsweeper Bot added clawsweeper:intake:bug Preliminary submission classification; full source review pending. clawsweeper:intake:needs-environment Preliminary submission classification; full source review pending. clawsweeper:intake:needs-repro Preliminary submission classification; full source review pending. and removed clawsweeper:intake:bug Preliminary submission classification; full source review pending. clawsweeper:intake:needs-environment Preliminary submission classification; full source review pending. clawsweeper:intake:needs-repro Preliminary submission classification; full source review pending. labels Nov 13, 2026
Preserve cooperative local binding and async cleanup while integrating current main snapshot admission, native source validation, and shared-worker regressions.

Co-authored-by: vincentkoc <[email protected]>
Co-authored-by: RomneyDa <[email protected]>
@RomneyDa
RomneyDa merged commit d0e09e4 into main Nov 16, 2026
134 of 135 checks passed
@RomneyDa
RomneyDa deleted the openclaw/rri508-initial-binding branch November 16, 2026 02:13
github-actions Bot pushed a commit to Desicool/openclaw that referenced this pull request Nov 16, 2026
…penclaw#198302)

* fix(plugins): keep Gateway responsive during initial plugin loading

Bind retained plugin sources locally and reconstruct initial captures cooperatively without synchronous preparation-worker calls. Preserve frozen recovery and await failed reconstruction cleanup.

Co-authored-by: Krzysztof Kisiel <[email protected]>
Co-authored-by: vincentkoc <[email protected]>
Co-authored-by: RomneyDa <[email protected]>

* fix(plugins): keep Gateway responsive during initial plugin loading

Worked on by:
- @vincentkoc

Co-authored-by: vincentkoc <[email protected]>
OpenClaw-Publication: 9a492d90-c371-4517-8294-a206174abd17

* fix(plugins): preserve off-thread source inspection during local binding

Keep worker-inspected module facts when reconstructing local executable bindings; include the new runtime owners in the extracted PR wrapper inventory and reconcile exact capture lifecycle proofs. Remove the unused async recovery API from this initial-binding repair.

Co-authored-by: Krzysztof Kisiel <[email protected]>
Co-authored-by: vincentkoc <[email protected]>
Co-authored-by: RomneyDa <[email protected]>

* Publish openclaw/rri508-initial-binding

Worked on by:
- @vincentkoc

Co-authored-by: vincentkoc <[email protected]>
OpenClaw-Publication: 70724870-17ea-47f5-9efd-1e35a58e0ab1

---------

Co-authored-by: Krzysztof Kisiel <[email protected]>
Co-authored-by: vincentkoc <[email protected]>
Co-authored-by: RomneyDa <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

gateway Gateway runtime P1 High-priority user-facing bug, regression, or broken workflow. proof: sufficient ClawSweeper judged the real behavior proof convincing. rating: 🐚 platinum hermit Good normal PR readiness with ordinary maintainer review expected. scripts Repository scripts size: XL 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