Skip to content

refactor(shared): consolidate remaining channel lazy loaders#99302

Merged
RomneyDa merged 1 commit into
mainfrom
refactor/lazy-runtime-remaining-channels
Jul 3, 2026
Merged

refactor(shared): consolidate remaining channel lazy loaders#99302
RomneyDa merged 1 commit into
mainfrom
refactor/lazy-runtime-remaining-channels

Conversation

@RomneyDa

@RomneyDa RomneyDa commented Jul 3, 2026

Copy link
Copy Markdown
Member

Related: #98748

What Problem This Solves

Matrix and the remaining channel plugins independently maintained the same lazy dynamic-import memoization pattern. Repeated promise state, loader wrappers, rejection handling, and test reset logic made startup boundaries and channel-specific semantics harder to compare and audit.

This is PR 5 of 6 in the lazy-runtime utility consolidation series.

The preceding batches established the shared loader foundation in #99261, migrated core leaf and infrastructure loaders in #99278, and cover the core gateway/stateful runtime plus Discord, Slack, and Telegram channel surfaces. After this PR, only the final provider/utility plugin migration and enforcement guard remain.

Why This Change Was Made

Migrates the authoritative 45-file Matrix and remaining-channel slice to openclaw/plugin-sdk/lazy-runtime. The consolidation preserves Matrix crypto retry behavior by clearing the cached loader after a rejected native crypto import, retains approval-reaction test resets, keeps transport startup and teardown behavior unchanged, preserves test dependency overrides, and does not move hot entrypoint imports across lazy boundaries.

The change removes 283 net lines without adding a second runtime path or changing configuration, protocol, or user-facing behavior.

User Impact

No intended user-visible behavior change. Maintainers get one consistent lazy-loader implementation across Matrix, WhatsApp, Signal, iMessage, Feishu, IRC, LINE, Teams, QQBot, voice-call, Zalo/ZaloUser, device-pair, and Google Meet, with fewer bespoke cache variables and reset wrappers to maintain.

Evidence

  • Scope proof: exactly 45 authoritative files changed; 246 additions, 529 deletions, 283 net lines removed.
  • Import audit: zero production modules imported both statically and dynamically in the owned slice; no leftover manual runtime-module promise memoizers.
  • Focused local Node-harness run: 266 tests passed across 17 selected Matrix/channel test files. One grouped Google Meet async last-call assertion observed an intermediate status result; the exact test passed in isolation on Blacksmith Testbox tbx_01kwjt4adhdz5ydzh5wh8b5123 (Actions run 28632803151).
  • Blacksmith Testbox tbx_01kwjsj1awxz3d2wb5zwmt6b51: focused formatting and extension lint passed, extensions typecheck passed, full build passed, and import-cycle check reported 0 runtime value cycles (Actions run 28632456395).
  • Fresh Codex autoreview completed with no accepted/actionable findings and 0.96 confidence.
  • Post-rebase patch identity matched the reviewed commit exactly.

@openclaw-barnacle openclaw-barnacle Bot added 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: voice-call Channel integration: voice-call channel: whatsapp-web Channel integration: whatsapp-web channel: zalo Channel integration: zalo channel: zalouser Channel integration: zalouser channel: feishu Channel integration: feishu extensions: device-pair channel: irc channel: qqbot plugin: google-meet size: L maintainer Maintainer-authored PR labels Jul 3, 2026
@RomneyDa
RomneyDa force-pushed the refactor/lazy-runtime-remaining-channels branch from 6d48fdf to e771361 Compare July 3, 2026 01:52
@clawsweeper

clawsweeper Bot commented Jul 3, 2026

Copy link
Copy Markdown
Contributor

Codex review: needs maintainer review before merge. Reviewed July 2, 2026, 10:04 PM ET / 02:04 UTC.

Summary
The PR replaces remaining Matrix and channel/plugin hand-written dynamic-import memoizers with the shared openclaw/plugin-sdk/lazy-runtime helper.

PR surface: Source -283. Total -283 across 45 files.

Reproducibility: not applicable. this is a maintainer refactor PR rather than a bug report; the source-shape duplication is tracked by the linked maintainer issue.

Review metrics: none identified.

Stored data model
Persistent data-model change detected: migration/backfill/repair: extensions/matrix/src/channel.ts. Confirm migration or upgrade compatibility proof before merge.

Root-cause cluster
Relationship: fixed_by_candidate
Canonical: #98748
Summary: This PR is one implementation slice for the canonical lazy dynamic-import memoizer consolidation tracker.

Members:

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

Merge readiness
Overall: 🐚 platinum hermit
Proof: 🌊 off-meta tidepool
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:

  • none.

Risk before merge

  • [P1] Live status check rollup still had QA and whole-shard CI jobs in progress with mergeStateStatus UNSTABLE; that is a merge gate rather than a source finding.

Maintainer options:

  1. Decide the mitigation before merge
    Keep this maintainer-labeled PR open for maintainer review and completed broad CI; the reviewed source paths do not need a ClawSweeper repair PR.
  2. Pause or close
    Do not merge this PR until maintainers decide whether the risk is worth taking.

Next step before merge

  • [P2] The remaining action is maintainer review and current CI completion for a broad maintainer-labeled refactor, not a narrow automated repair.

Security
Cleared: No concrete security concern surfaced; the diff does not change workflows, dependencies, lockfiles, scripts, secrets, or permissions.

Review details

Best possible solution:

Keep this maintainer-labeled PR open for maintainer review and completed broad CI; the reviewed source paths do not need a ClawSweeper repair PR.

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

Not applicable: this is a maintainer refactor PR rather than a bug report; the source-shape duplication is tracked by the linked maintainer issue.

Is this the best way to solve the issue?

Yes: using the existing SDK lazy-runtime helper is the narrow canonical cleanup path, and the sampled retry/reset behaviors are preserved.

AGENTS.md: found and applied where relevant.

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

Label changes

Label changes:

  • add P3: The PR is an internal maintainability cleanup with no intended user-visible behavior change or reported production regression.
  • add rating: 🐚 platinum hermit: Overall readiness is 🐚 platinum hermit; proof is 🌊 off-meta tidepool and patch quality is 🐚 platinum hermit.
  • remove rating: 🦐 gold shrimp: Current PR rating is rating: 🐚 platinum hermit, so this older rating label is no longer current.

Label justifications:

  • P3: The PR is an internal maintainability cleanup with no intended user-visible behavior change or reported production regression.
  • rating: 🐚 platinum hermit: Overall readiness is 🐚 platinum hermit; proof is 🌊 off-meta tidepool and patch quality is 🐚 platinum hermit.
  • status: 👀 ready for maintainer look: ClawSweeper has no concrete contributor-facing blocker left for this PR. Not applicable: Not applicable for this maintainer-labeled internal refactor; no external contributor real-behavior proof gate applies.
Evidence reviewed

PR surface:

Source -283. Total -283 across 45 files.

View PR surface stats
Area Files Added Removed Net
Source 45 246 529 -283
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 45 246 529 -283

What I checked:

  • Repository policy applied: Root, extensions, and plugin-sdk AGENTS.md were read; the scoped extension policy expects bundled plugin production code to use openclaw/plugin-sdk/*, which matches the new lazy-runtime imports. (extensions/AGENTS.md:23, b47fe7a4b313)
  • Shared helper contract: createLazyRuntimeModule delegates to createLazyRuntimeSurface, which caches runtime import rejections and exposes peek/clear on the loader function. (src/shared/lazy-runtime.ts:16, b47fe7a4b313)
  • Special retry behavior preserved: At the PR head, Matrix native crypto loading still clears the cached loader on rejection before rethrowing, preserving the prior retry-on-failure behavior. (extensions/matrix/src/matrix/sdk/crypto-facade.ts:75, ae5c4a7b4016)
  • Approval reset behavior preserved: iMessage, Signal, and WhatsApp approval reset hooks now call the shared loader's clear() instead of assigning the old promise variable to undefined. (extensions/imessage/src/approval-reactions.ts:637, ae5c4a7b4016)
  • Changed slice cleanup proof: A fixed-string search over the 45 PR-changed files at the PR head found no remaining ??= import( occurrences, and git diff --check returned cleanly. (ae5c4a7b4016)
  • Live PR state: Live GitHub shows the PR is open, mergeable, labeled maintainer, and tied to the canonical lazy memoizer tracker; current status rollup still had broad CI shards in progress with mergeStateStatus UNSTABLE. (ae5c4a7b4016)

Likely related people:

  • RomneyDa: Authored the canonical tracker, the shared lazy-runtime helper history visible in this checkout, and this remaining-channel consolidation PR. (role: recent feature owner; confidence: high; commits: 6432808ad297, ae5c4a7b4016; files: src/shared/lazy-runtime.ts, src/plugin-sdk/lazy-runtime.ts, extensions/matrix/src/matrix/sdk/crypto-facade.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.

@RomneyDa
RomneyDa force-pushed the refactor/lazy-runtime-remaining-channels branch from e771361 to ae5c4a7 Compare July 3, 2026 01:58
@clawsweeper clawsweeper Bot added rating: 🦐 gold shrimp Decent PR readiness signal, but merge confidence is limited. status: 👀 ready for maintainer look ClawSweeper has no concrete contributor-facing blocker left for this PR. rating: 🐚 platinum hermit Good normal PR readiness with ordinary maintainer review expected. P3 Low-priority cleanup, docs, polish, ergonomics, or speculative work. and removed rating: 🦐 gold shrimp Decent PR readiness signal, but merge confidence is limited. labels Jul 3, 2026
@RomneyDa

RomneyDa commented Jul 3, 2026

Copy link
Copy Markdown
Member Author

@clawsweeper re-review

@clawsweeper

clawsweeper Bot commented Jul 3, 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 repository_dispatch).
Result: the existing ClawSweeper review comment will be edited in place when the review finishes.

@RomneyDa
RomneyDa merged commit 59b08b4 into main Jul 3, 2026
129 of 135 checks passed
@RomneyDa
RomneyDa deleted the refactor/lazy-runtime-remaining-channels branch July 3, 2026 02:08
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

channel: feishu Channel integration: feishu channel: imessage Channel integration: imessage channel: irc channel: line Channel integration: line channel: matrix Channel integration: matrix channel: msteams Channel integration: msteams channel: qqbot channel: signal Channel integration: signal channel: voice-call Channel integration: voice-call channel: whatsapp-web Channel integration: whatsapp-web channel: zalo Channel integration: zalo channel: zalouser Channel integration: zalouser extensions: device-pair maintainer Maintainer-authored PR P3 Low-priority cleanup, docs, polish, ergonomics, or speculative work. plugin: google-meet rating: 🐚 platinum hermit Good normal PR readiness with ordinary maintainer review expected. size: L 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