Skip to content

refactor(shared): consolidate provider and utility lazy loaders#98749

Merged
RomneyDa merged 2 commits into
mainfrom
duplicate-utils
Jul 3, 2026
Merged

refactor(shared): consolidate provider and utility lazy loaders#98749
RomneyDa merged 2 commits into
mainfrom
duplicate-utils

Conversation

@RomneyDa

@RomneyDa RomneyDa commented Jul 1, 2026

Copy link
Copy Markdown
Member

Related: #98748

What Problem This Solves

Resolves the final provider and utility portion of a maintainability problem where bundled plugins and provider adapters repeatedly implement their own dynamic-import promise caches. This is PR 6 of 6 in the lazy-runtime consolidation series.

The shared foundation and core leaf batches are already merged:

Why This Change Was Made

Migrates provider and utility plugin loaders to the public openclaw/plugin-sdk/lazy-runtime helper while preserving each existing sticky-rejection, retry, reset, and inspection contract. The memory-lancedb provider path retains retry-after-failure behavior; other runtime imports retain sticky rejection caching.

User Impact

No intended user-visible behavior change. Maintainers get one canonical lazy runtime loader across provider and utility plugins, reducing repeated cache variables and loader functions without changing provider behavior.

Evidence

  • Exact scope: 35 loader files, +149/-328.
  • Focused loader proof: 307 tests passed across 8 Vitest shards, covering shared lazy helpers, ACPX, Codex, browser remote-profile loaders, memory-core/lancedb, OpenAI OAuth, Parallel, and XAI.
  • Format: oxfmt --check passed on all 35 files.
  • Existing broader proof for the same loader changes: Testbox-through-Crabbox check:changed and pnpm build passed.
  • Fresh Codex autoreview: clean with no accepted/actionable findings, confidence 0.98.

@openclaw-barnacle openclaw-barnacle Bot added size: S maintainer Maintainer-authored PR labels Jul 1, 2026
@clawsweeper

clawsweeper Bot commented Jul 1, 2026

Copy link
Copy Markdown
Contributor

Codex review: needs maintainer review before merge. Reviewed July 2, 2026, 11:57 PM ET / 03:57 UTC.

Summary
This PR replaces manual provider and utility plugin dynamic-import promise memoizers with the shared createLazyRuntimeModule helper across 35 files.

PR surface: Source -179. Total -179 across 35 files.

Reproducibility: not applicable. as a runtime bug; this is a maintainer refactor implementing a source-level cleanup tracked by the canonical issue. The reviewable check is whether the shared lazy-loader contract preserves existing import-cache behavior.

Review metrics: 1 noteworthy metric.

  • Public SDK surface: 0 added, 0 removed. The branch consumes the existing openclaw/plugin-sdk/lazy-runtime subpath rather than expanding third-party plugin API surface.

Stored data model
Persistent data-model change detected: migration/backfill/repair: extensions/policy/src/doctor/register.ts, unknown-data-model-change: extensions/memory-core/src/memory/search-manager.ts, unknown-data-model-change: extensions/memory-lancedb/index.ts, vector/embedding metadata: extensions/memory-core/index.ts, vector/embedding metadata: extensions/memory-core/src/cli.ts, vector/embedding metadata: extensions/memory-core/src/memory/search-manager.ts, and 3 more. Confirm migration or upgrade compatibility proof before merge.

Root-cause cluster
Relationship: fixed_by_candidate
Canonical: #98748
Summary: This PR is the active final provider/utility implementation candidate for the canonical lazy dynamic-import memoizer cleanup issue; prior series PRs are merged same-root-cause batches.

Members:

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

Merge readiness
Overall: 🐚 platinum hermit
Proof: 🐚 platinum hermit
Patch quality: 🐚 platinum hermit
Result: ready for maintainer review.

Overall follows the weaker of proof and patch quality, so missing proof can cap an otherwise strong patch.

Rank-up moves:

  • [P2] Resolve the three failed exact-head checks or add a maintainer note documenting them as unrelated before merge.

Risk before merge

  • [P1] Exact-head CI is not green, so maintainers need a green rerun or a documented unrelated-main failure before merge.
  • [P1] The diff changes lazy import cache ownership across many provider and utility runtime boundaries; a missed sticky-rejection, retry, or close-without-import semantic could affect provider/plugin availability at runtime.

Maintainer options:

  1. Resolve exact-head gates (recommended)
    Keep the PR open until the three failed exact-head checks are green or a maintainer documents them as unrelated to this patch.
  2. Accept the broad-loader proof
    If maintainers are satisfied with the focused Testbox, build, import-cycle, and sampled code-path proof, they can accept the remaining availability risk after documenting CI status.
  3. Pause the final batch
    Pause or close this PR if maintainer review finds the provider/utility loader slice should be split or reworked before landing.

Next step before merge

  • [P2] Manual review is the right lane because the branch is maintainer-protected and the remaining action is CI/ownership review, not a narrow automated code repair.

Security
Cleared: No concrete security or supply-chain concern was found; the diff changes lazy import helper usage and does not alter workflows, lockfiles, dependencies, permissions, secrets, downloads, or package metadata.

Review details

Best possible solution:

Land this final cleanup batch only after exact-head checks are green or documented unrelated and maintainer review accepts that the converted loaders preserve their previous lazy-cache semantics.

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

Not applicable as a runtime bug; this is a maintainer refactor implementing a source-level cleanup tracked by the canonical issue. The reviewable check is whether the shared lazy-loader contract preserves existing import-cache behavior.

Is this the best way to solve the issue?

Yes: using the existing Plugin SDK lazy-runtime helper is the right owner-boundary cleanup, and sampled callers preserve sticky rejection caching, peek() inspection, and no-load-on-close behavior. The remaining blocker is merge readiness, not a different implementation shape.

AGENTS.md: found and applied where relevant.

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

Label changes

Label changes:

  • add merge-risk: 🚨 availability: The PR changes lazy module cache ownership across provider and utility runtime boundaries, where a semantic mismatch could make plugin/provider runtime loading or teardown fail.

Label justifications:

  • P3: This is an internal maintainability refactor with no intended user-visible behavior change.
  • merge-risk: 🚨 availability: The PR changes lazy module cache ownership across provider and utility runtime boundaries, where a semantic mismatch could make plugin/provider runtime loading or teardown fail.
  • 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: The external contributor proof gate is not applicable because this is a maintainer-labeled internal refactor; the PR discussion provides focused tests, build, import-cycle, and Testbox proof as validation context.
Evidence reviewed

PR surface:

Source -179. Total -179 across 35 files.

View PR surface stats
Area Files Added Removed Net
Source 35 149 328 -179
Tests 0 0 0 0
Docs 0 0 0 0
Config 0 0 0 0
Generated 0 0 0 0
Other 0 0 0 0
Total 35 149 328 -179

What I checked:

  • Live PR state: Live GitHub shows this PR is open, non-draft, labeled maintainer, at head 0782a9dc63630e7812658c56582b724808e3668d, with 35 files changed and no closing issue reference. (0782a9dc6363)
  • Canonical tracker: The linked canonical issue remains open and tracks consolidating lazy dynamic-import memoizers behind the shared lazy-promise owner; related foundation/core/channel batches are already merged, leaving this as the provider/utility batch.
  • Shared lazy-runtime contract: createLazyRuntimeSurface delegates to createLazyPromiseLoader with cacheRejections: true, then exposes peek and clear, matching the sticky rejected-import behavior expected by the converted module loaders. (src/shared/lazy-runtime.ts:16, c37961fdab6e)
  • Promise cache contract: createLazyPromiseLoader returns the cached promise directly, supports peek and clear, and only evicts rejected loads when rejection caching is not requested. (src/shared/lazy-promise.ts:22, c37961fdab6e)
  • Representative lifecycle preservation: On the PR head, the Canvas route handler uses createLazyRuntimeModule, and service shutdown still checks peek() before closing, so stop does not start the route handler just to close it. (extensions/canvas/index.ts:58, 0782a9dc6363)
  • Representative memory close behavior: On the PR head, memory search manager close paths use the lazy loader's peek() guard before importing builtin manager cleanup, preserving the old no-load-on-close behavior. (extensions/memory-core/src/memory/search-manager.ts:116, 0782a9dc6363)

Likely related people:

  • RomneyDa: Authored the canonical cleanup issue and the merged lazy-runtime foundation/core/channel batches that this final provider/utility PR builds on. (role: cleanup series owner and recent area contributor; confidence: high; commits: 66731b504bcc, 5458e316f363, 5fa20826553c; files: src/shared/lazy-runtime.ts, src/shared/lazy-promise.ts, extensions/canvas/index.ts)
  • Peter Steinberger: git log -S createLazyRuntimeSurface traces the earlier shared lazy runtime helper API and plugin exposure work to these commits. (role: earlier helper area contributor; confidence: high; commits: 9648e7fecb28, 795f1f438b1d, 39a8dab0da60; files: src/shared/lazy-runtime.ts, src/plugin-sdk/lazy-runtime.ts)
  • fuller-stack-dev: Live PR history shows the Codex hosted web-search provider path touched by this lazy-loader migration was introduced in the merged Codex hosted search PR. (role: Codex hosted search feature owner; confidence: medium; commits: 3f61d155e19b, cf835455ecd0, 1e0062b44a51; files: extensions/codex/src/web-search-provider.ts, extensions/codex/src/web-search-provider.runtime.ts, extensions/codex/src/app-server/client-factory.ts)
What the crustacean ranks mean
  • 🦀 challenger crab: rare, exceptional readiness with strong proof, clean implementation, and convincing validation.
  • 🦞 diamond lobster: very strong readiness with only minor maintainer review expected.
  • 🐚 platinum hermit: good normal PR, likely mergeable with ordinary maintainer review.
  • 🦐 gold shrimp: useful signal, but proof or patch confidence is still limited.
  • 🦪 silver shellfish: thin signal; proof, validation, or implementation needs work.
  • 🧂 unranked krab: not merge-ready because proof is missing/unusable or there are serious correctness or safety concerns.
  • 🌊 off-meta tidepool: rating does not apply to this item.

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.

How this review workflow works
  • 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. P3 Low-priority cleanup, docs, polish, ergonomics, or speculative work. labels Jul 1, 2026
@RomneyDa
RomneyDa requested a review from a team as a code owner July 1, 2026 21:42
@openclaw-barnacle openclaw-barnacle Bot added channel: discord Channel integration: discord channel: imessage Channel integration: imessage channel: line Channel integration: line channel: matrix Channel integration: matrix channel: msteams Channel integration: msteams channel: signal Channel integration: signal channel: slack Channel integration: slack channel: telegram Channel integration: telegram channel: voice-call Channel integration: voice-call channel: whatsapp-web Channel integration: whatsapp-web channel: zalo Channel integration: zalo channel: zalouser Channel integration: zalouser gateway Gateway runtime extensions: memory-core Extension: memory-core extensions: memory-lancedb Extension: memory-lancedb cli CLI command changes scripts Repository scripts commands Command implementations agents Agent runtime and tooling channel: feishu Channel integration: feishu extensions: device-pair labels Jul 1, 2026
@clawsweeper clawsweeper Bot added rating: 🦐 gold shrimp Decent PR readiness signal, but merge confidence is limited. status: ⏳ waiting on author ClawSweeper has contributor-facing work open and is waiting for author action. merge-risk: 🚨 compatibility 🚨 May break existing users, config, migrations, defaults, or upgrade paths. and removed 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 Jul 1, 2026
@RomneyDa

RomneyDa commented Jul 1, 2026

Copy link
Copy Markdown
Member Author

Performance and packaging follow-up is now pushed at f756733f7088432bb23a90b46a1f48281037392d:

  • Cached lazy loaders return the exact cached promise directly, avoiding an extra promise allocation and microtask hop on every cached call.
  • createLazyPromise / createLazyPromiseLoader are no longer newly exported through the public Plugin SDK. Bundled plugins use the existing createLazyRuntimeModule surface, which now carries internal peek() / clear() controls.
  • The Code Mode test hook has an explicit return type, restoring dist/plugin-sdk/src/agents/code-mode.d.ts from roughly 80 KB to 4,656 bytes.
  • SDK surface-budget tests now pass with no new public callable exports.
  • Final-base proof: 197 affected tests passed, core and extension typechecks passed, pnpm build passed, import cycles remain zero, and the manual memoizer guard remains clean.
  • Blacksmith Testbox tbx_01kwfwwfx6gqaz3tgmzwhpqrhg reached and passed all guards plus core production typing, then stopped on the pre-existing src/commands/daemon-install-helpers.test.ts type errors; that file is unchanged by this PR. Actions run: https://github.com/openclaw/openclaw/actions/runs/28552025454
  • Final Codex autoreview: clean, 0.93 confidence. One earlier checker-syntax finding was rejected after node --check and direct execution both passed; the corrected review confirmed no duplicate declaration.

@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. and removed rating: 🦐 gold shrimp Decent PR readiness signal, but merge confidence is limited. status: ⏳ waiting on author ClawSweeper has contributor-facing work open and is waiting for author action. labels Jul 1, 2026
@RomneyDa
RomneyDa marked this pull request as draft July 2, 2026 17:51
@clawsweeper clawsweeper Bot removed the merge-risk: 🚨 compatibility 🚨 May break existing users, config, migrations, defaults, or upgrade paths. label Jul 2, 2026
@RomneyDa RomneyDa changed the title refactor(shared): consolidate lazy import memoizers refactor(shared): consolidate provider loaders and enforce lazy runtime helpers Jul 3, 2026
@openclaw-barnacle openclaw-barnacle Bot removed channel: discord Channel integration: discord channel: imessage Channel integration: imessage channel: line Channel integration: line channel: matrix Channel integration: matrix channel: msteams Channel integration: msteams channel: signal Channel integration: signal labels Jul 3, 2026
@RomneyDa

RomneyDa commented Jul 3, 2026

Copy link
Copy Markdown
Member Author

note my agent accidentally removed the clawsweeper labels so I just put them back

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

extensions: acpx extensions: anthropic-vertex extensions: brave extensions: codex extensions: duckduckgo extensions: firecrawl extensions: google extensions: memory-core Extension: memory-core extensions: memory-lancedb Extension: memory-lancedb extensions: minimax extensions: moonshot extensions: openai extensions: parallel extensions: perplexity extensions: policy extensions: qa-lab extensions: tavily extensions: xai maintainer Maintainer-authored PR merge-risk: 🚨 availability 🚨 May cause crashes, hangs, restart loops, stalls, or process outages. P3 Low-priority cleanup, docs, polish, ergonomics, or speculative work. plugin: bonjour Plugin integration: bonjour rating: 🐚 platinum hermit Good normal PR readiness with ordinary maintainer review expected. size: M 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