Skip to content

improve(gateway): defer inactive plugin runtime imports - #119733

Merged
vincentkoc merged 5 commits into
mainfrom
improve/default-plugin-startup-loading-20260805
Aug 5, 2026
Merged

vincentkoc merged 5 commits into
mainfrom
improve/default-plugin-startup-loading-20260805

Conversation

@vincentkoc

@vincentkoc vincentkoc commented Aug 5, 2026 •

Copy link
Copy Markdown
Member

Related: #119087

What Problem This Solves

Reduces eager default-plugin runtime loading during Gateway startup and standalone agent commands when Talk relay cleanup, ACPX session catalog access, Google Meet operations, and memory operations are not used.

This is a partial repair for #119087. It does not change the Gateway readiness contract or claim to resolve the remaining product decision around core readiness versus optional plugin availability.

Why This Change Was Made

Keeps process-stable registration and cleanup metadata in lightweight modules, then defers owner-specific runtime imports until the operation that needs them. Configuration, storage, protocol, and readiness semantics remain unchanged.

The four owner-local changes are:

  • Talk keeps a lightweight session cleanup registry instead of importing relay runtimes from the WebSocket connection path.
  • ACPX keeps the session catalog facade small and imports the Pi catalog runtime on first catalog operation.
  • Google Meet separates lightweight registration from browser, calendar, Meet API, meeting runtime, routing, parameter, transcript, and standalone Gateway helpers.
  • memory-core passes host runtime operations through lazy wrappers instead of reading nested runtime getters during registration.

User Impact

  • Gateway reaches its TCP listener sooner without declaring readiness before sidecars complete.
  • Fresh agent commands avoid loading unused plugin runtime graphs.
  • ACPX and Google Meet cold entrypoint memory is materially lower.
  • First-use behavior remains unchanged; owner runtime work occurs when its operation is invoked.

Evidence

  • Rebased implementation base: ad80956428560ca7f450bd3dadd2eb897acb0d6d
  • Exact current head: d7a95249350fdbc448daccac50e8d1ac86130545
  • Current main integration check: 6d2ba0d5622fa7aa21a4770cb4c6fd93cae44e04; the two newer main commits are path-disjoint and GitHub reports the PR mergeable.
  • Exact measured baseline: 2db3431f4aa198ba84c465bdf15506e783575431
  • Exact measured candidate: aa46d04457393283c7edfe672eeadc4c96b4c842; the current head preserves the same PR production diff after rebasing and includes only the previously reviewed lazy-import test-type narrowing.
  • Matched performance runs:
  • Kova attempt 2, five samples per ref, all 10 scenarios passing:
    • TCP listener: 5028 -> 4778ms (-5.0%)
    • health ready: 5520 -> 5614ms (+1.7%; readiness semantics unchanged)
    • Gateway RSS median: 956.1 -> 963.3MB (+0.8%); p95 967.1 -> 967.9MB
    • cold agent turn: 4450 -> 3729ms (-16.2%)
    • warm agent turn: 4218 -> 3485ms (-17.4%)
    • agent-turn p95: 4546.9 -> 3714.4ms (-18.3%)
    • cold pre-provider: 4265 -> 3586ms (-15.9%)
    • agent RSS median: 885.1 -> 857.3MB (-3.1%)
  • Across both matched Kova attempts, the ten-sample medians are:
    • TCP listener: 5664 -> 4411ms (-22.1%)
    • health ready: 6171 -> 5298.5ms (-14.1%)
    • Gateway RSS: 960.4 -> 964.7MB (+0.45%)
  • Exact source-performance pair:
    • all 87 bundled entrypoints: 703.2 -> 628.0MB (-10.7%)
    • ACPX isolated import: 511.7 -> 135.0MB (-73.6%)
    • Google Meet isolated import: 547.8 -> 364.3MB (-33.5%)
    • prepared one-agent listener: 3662 -> 2615ms (-28.6%)
    • prepared many-agent listener: 4026 -> 2795ms (-30.6%)
    • 50-plugin listener: 5258 -> 2937ms (-44.1%)
    • 50 startup-lazy-plugin listener: 5002 -> 2848ms (-43.1%)
  • Source probes also show the intended Talk phase relocation on the default case: gateway.ws-imports falls from 561.1 -> 11.4ms, while sidecars.model-runtime-build.runtimePluginMs rises from 261.8 -> 1147.9ms on separate runners. The PR therefore does not claim to remove all readiness cost or close [Bug]: Gateway cold start regressed ~2.5x from 2026.7.1-beta.1 to 2026.7.2-beta.7 on a 1-vCPU container #119087.
  • Focused tests at the current exact head: 326 assertions across 12 ACPX, Google Meet, memory-core, Gateway import-boundary, WebSocket connection, and Talk relay/session files.
  • Static/build proof: git diff --check, oxfmt, direct changed-file oxlint, and the no-reconcile sourcePerformance build pass.
  • Structured review: autoreview clean, no accepted/actionable finding, 0.98 correctness confidence; TruffleHog clean.
  • Production delta: +578/-1067, net -489 lines. Tests: +483/-36.
  • Changelog: not required; this changes current-main implementation only and adds no public/config/storage contract.

Root cause: default plugin entrypoints mixed process-stable registration metadata with operational runtime imports, so registry construction loaded unrelated runtime graphs. The canonical fix is to keep registration lightweight and let each owner import its runtime at first use. No readiness fallback, compatibility shim, cache, or alternate execution path is added.

Sibling Codex protocol/runtime verification was performed against openai/codex commit 9d00bb01c0a712fb7c2f5b002bdf33bcc0fc352c:

  • codex-rs/app-server-protocol/src/protocol/common.rs:474-510,855-870
  • codex-rs/app-server/src/message_processor.rs:520-579,659-681,699-735,763-817
  • codex-rs/app-server/src/lib.rs:1150-1160

The lazy plugin registration changes do not alter Codex initialize, thread/turn ordering, or shutdown-drain contracts.

Merge Gate

Merge only after clean exact-head CI and the latest exact-head ClawSweeper review has no unresolved Before merge, finding, security, owner-decision, merge-risk, or blocking rank-up item.

This PR was prepared with AI assistance.

Punchcard-Session: coral-workshop-workshop-3f

@vincentkoc vincentkoc self-assigned this Aug 5, 2026
@vincentkoc
vincentkoc marked this pull request as ready for review August 5, 2026 20:42
@vincentkoc
vincentkoc force-pushed the improve/default-plugin-startup-loading-20260805 branch 2 times, most recently from d476bb9 to 0b320c9 Compare August 5, 2026 21:40
Punchcard-Session: coral-workshop-workshop-3f
Punchcard-Session: coral-workshop-workshop-3f
Punchcard-Session: coral-workshop-workshop-3f
Punchcard-Session: coral-workshop-workshop-3f
Punchcard-Session: coral-workshop-workshop-3f
@vincentkoc
vincentkoc force-pushed the improve/default-plugin-startup-loading-20260805 branch from 0b320c9 to d7a9524 Compare August 5, 2026 22:02
@clawsweeper

clawsweeper Bot commented Aug 5, 2026 •

Copy link
Copy Markdown
Contributor

Codex review: needs maintainer review before merge. Reviewed August 5, 2026, 6:31 PM ET / 22:31 UTC.

ClawSweeper review

What this changes

The PR defers unused Talk, ACPX, Google Meet, and memory runtime imports so gateway startup and inactive plugin paths load less code before first use.

Merge readiness

⚠️ Ready for maintainer review - 1 item remains

No blocking correctness or security finding was identified on the exact PR head. This is a maintainer-authored, maintainer-labeled partial repair for the broader cold-start report, so it should remain open for normal maintainer review rather than automated cleanup.

Priority: P2
Reviewed head: d7a95249350fdbc448daccac50e8d1ac86130545

Review scores

Measure Result What it means
Overall readiness 🐚 platinum hermit (4/6) The patch is a coherent, production-net-negative owner-boundary refactor with focused regression coverage, successful supplied exact-head CI, and benchmark evidence.
Proof confidence 🐚 platinum hermit (4/6) Not applicable: This repository-member PR is not subject to the external-contributor proof gate; its body nevertheless supplies before/after benchmark and focused-test evidence.
Patch quality 🐚 platinum hermit (4/6) No actionable review findings were identified.

Verification

Check Result Evidence
Real behavior Not applicable Not applicable: This repository-member PR is not subject to the external-contributor proof gate; its body nevertheless supplies before/after benchmark and focused-test evidence.
Evidence reviewed 7 items Talk cleanup ownership: The head replaces eager relay imports at the WebSocket disconnect boundary with a lightweight registry that records one cleanup callback per relay kind, deletes callbacks before execution, and continues after an owner cleanup throws.
Talk sibling coverage: The changed producers register owner-local cleanup after session insertion, while existing relay lifecycle scanners still close all matching sessions; regression tests cover dedupe, re-entry, callback failure, and unrelated connections.
Google Meet parity: The lightweight registration module preserves transcript registration, manual-action error identity, node-policy fail-closed behavior, and the two existing SoX command shapes without adding a config or API surface.
Findings None None.
Security None None.

How this fits together

Gateway startup registers bundled plugins before accepting connections, then routes later catalog, meeting, memory, and Talk work to those owners. The PR keeps registration lightweight and imports each owner runtime only when its operation is invoked.

flowchart LR
  A[Gateway startup] --> B[Plugin registration]
  B --> C[Lightweight metadata]
  C --> D[Gateway listener]
  D --> E[First plugin operation]
  E --> F[Owner runtime import]
  F --> G[Catalog, meeting, memory, or Talk operation]
Loading

Before merge

  • Complete next step (P2) - The repository-member author and maintainer label require normal maintainer handling; no narrow automated repair is needed because the review found no actionable defect.
Agent review details

Security

None.

PR surface

Source +176, Tests +455. Total +631 across 23 files.

View PR surface stats
Area Files Added Removed Net
Source 15 1125 949 +176
Tests 8 491 36 +455
Docs 0 0 0 0
Config 0 0 0 0
Generated 0 0 0 0
Other 0 0 0 0
Total 23 1616 985 +631

Review metrics

Metric Value Why it matters
Production versus test delta production +578/-1067 (net -489); tests +483/-36 (net +447) The refactor is production net-negative while adding focused import-boundary and lifecycle regression coverage.

Stored data model

Persistent data-model change detected: unknown-data-model-change: extensions/memory-core/index.test.ts, vector/embedding metadata: extensions/memory-core/index.test.ts, vector/embedding metadata: extensions/memory-core/index.ts. Confirm migration or upgrade compatibility proof before merge.

Root-cause cluster

Relationship: fixed_by_candidate
Canonical: #119087
Summary: This PR is an explicitly partial candidate repair for the canonical gateway cold-start report; it does not claim to settle the remaining readiness product decision.

Members:

Proposal only: this assessment does not dispatch repair, suppress jobs, mutate sibling items, close, or merge anything.

Technical review

Best possible solution:

Keep the lightweight registration/owner-runtime split, preserving the existing first-use contracts and the broader readiness decision tracked by #119087.

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

Not applicable: this PR is a performance refactor, and its body supplies matched runtime benchmarks rather than a discrete new functional bug reproduction.

Is this the best way to solve the issue?

Yes: keeping process-stable registration light and loading owner runtimes at first use addresses the import cost at its owner boundaries without changing readiness, config, or storage contracts.

AGENTS.md: found and applied where relevant.

Codex review notes: model internal, reasoning high; reviewed against 6d2ba0d5622f.

Labels

Label changes:

  • add P2: This is a bounded gateway-startup performance improvement with limited direct blast radius and no confirmed current functional regression in the patch.
  • 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. Not applicable: This repository-member PR is not subject to the external-contributor proof gate; its body nevertheless supplies before/after benchmark and focused-test evidence.

Label justifications:

  • P2: This is a bounded gateway-startup performance improvement with limited direct blast radius and no confirmed current functional regression in the patch.
  • 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. Not applicable: This repository-member PR is not subject to the external-contributor proof gate; its body nevertheless supplies before/after benchmark and focused-test evidence.

Evidence

What I checked:

  • Talk cleanup ownership: The head replaces eager relay imports at the WebSocket disconnect boundary with a lightweight registry that records one cleanup callback per relay kind, deletes callbacks before execution, and continues after an owner cleanup throws. (src/gateway/talk-session-registry.ts:32, d7a95249350f)
  • Talk sibling coverage: The changed producers register owner-local cleanup after session insertion, while existing relay lifecycle scanners still close all matching sessions; regression tests cover dedupe, re-entry, callback failure, and unrelated connections. (src/gateway/talk-realtime-relay-session-create.ts:606, d7a95249350f)
  • Google Meet parity: The lightweight registration module preserves transcript registration, manual-action error identity, node-policy fail-closed behavior, and the two existing SoX command shapes without adding a config or API surface. (extensions/google-meet/src/plugin-registration.ts:19, d7a95249350f)
  • ACPX and memory lazy boundary: ACPX retains public registration and command constants while deferring its catalog runtime; memory-core changes eager nested runtime reads to call-time wrappers while retaining the required host method contracts. (extensions/acpx/src/pi-session-catalog-plugin.ts:95, d7a95249350f)
  • Lazy-loader contract: The shared lazy-runtime helper caches the imported module or surface, matching the intended one-time first-use load behavior used by the ACPX split. (src/shared/lazy-runtime.ts:8, 6d2ba0d5622f)
  • Current-main comparison: The checked-out current main still has the former eager Talk imports, so this PR's central change is neither already implemented nor superseded on main. (src/gateway/server/ws-connection.ts:31, 6d2ba0d5622f)

Likely related people:

  • steipete: Accessible blame and local history connect Peter Steinberger to the current Google Meet registration/config/policy surface and recent memory-core work; older history was unavailable in the partial clone. (role: recent area contributor; confidence: medium; commits: 6269be70c55f; files: extensions/google-meet/index.ts, extensions/google-meet/src/config.ts, extensions/memory-core/index.ts)

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.

@clawsweeper clawsweeper Bot added 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. P2 Normal backlog priority with limited blast radius. labels Aug 5, 2026
@vincentkoc

Copy link
Copy Markdown
Member Author

Maintainer review completed against exact head d7a95249350fdbc448daccac50e8d1ac86130545.

  • ClawSweeper's remaining "normal maintainer handling" item is satisfied by the repo-native review and exact-head CI review.
  • The stored-data-model detector is a false positive: extensions/memory-core/index.ts only replaces eager nested runtime property reads with call-time wrappers. It changes no persisted shape, SQLite schema, vector metadata, migration, config, or upgrade contract.
  • The exact-head review has no findings, no security issue, and no Rank-up moves.

Proceeding to repo-native prepare; merge remains gated on the prepared exact head and green checks.

@vincentkoc
vincentkoc merged commit e41c574 into main Aug 5, 2026
200 of 202 checks passed
@vincentkoc

Copy link
Copy Markdown
Member Author

Merged via squash.

@vincentkoc
vincentkoc deleted the improve/default-plugin-startup-loading-20260805 branch August 5, 2026 23:38
github-actions Bot pushed a commit to Desicool/openclaw that referenced this pull request Aug 6, 2026
)

* perf(gateway): defer Talk relay cleanup imports

Punchcard-Session: coral-workshop-workshop-3f

* perf(acpx): defer Pi session catalog runtime

Punchcard-Session: coral-workshop-workshop-3f

* perf(google-meet): defer meeting runtime imports

Punchcard-Session: coral-workshop-workshop-3f

* improve(memory-core): defer scoped runtime access

Punchcard-Session: coral-workshop-workshop-3f

* perf(google-meet): defer SDK action helpers

Punchcard-Session: coral-workshop-workshop-3f
vincentkoc added a commit to VACInc/openclaw that referenced this pull request Aug 6, 2026
…cope

* origin/main: (24 commits)
  fix(backup): skip transient gateway lock databases (openclaw#119782)
  test(agents): use canonical auth session fixtures (openclaw#119821)
  fix(memory): keep QMD file hints after stale docid misses (issue openclaw#113041) (openclaw#113515)
  test(doctor): align fast-path repair contracts (openclaw#119812)
  perf(agents): index subagent recovery ownership (openclaw#119793)
  fix(gateway): keep chat startup off catalog discovery (openclaw#119742)
  fix(test): keep TUI PTY suites in their owner lane (openclaw#119787)
  docs: correct dashboard auth precedence (openclaw#119785)
  docs: document control ui owner handoff
  fix: grant host-authorized control ui owner access
  fix(worktrees): preserve registered roots during orphan cleanup (openclaw#119709)
  fix(matrix): prevent shared client key collisions (openclaw#119667)
  fix(diagnostics-otel): propagate exported span context (openclaw#112283)
  fix(worker): isolate state observer failures (openclaw#117507)
  fix(qa): attest realized profile executions (openclaw#119761)
  fix(gateway): finish successful sessions after timestamp races (openclaw#119752)
  fix(agents): fence restart recovery lifecycle (openclaw#119776)
  fix(ui): preserve chat history and active run timing (openclaw#119729)
  improve(ollama): reduce inactive startup cost (openclaw#119745)
  improve(gateway): defer inactive plugin runtime imports (openclaw#119733)
  ...
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

extensions: acpx extensions: memory-core Extension: memory-core gateway Gateway runtime maintainer Maintainer-authored PR P2 Normal backlog priority with limited blast radius. plugin: google-meet rating: 🐚 platinum hermit Good normal PR readiness with ordinary maintainer review expected. 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.

[Bug]: Gateway cold start regressed ~2.5x from 2026.7.1-beta.1 to 2026.7.2-beta.7 on a 1-vCPU container

1 participant