refactor(shared): establish lazy runtime loader foundation#99261
Conversation
|
Codex review: needs maintainer review before merge. Reviewed July 2, 2026, 7:57 PM ET / 23:57 UTC. Summary PR surface: Source +2, Tests +54. Total +56 across 5 files. Reproducibility: not applicable. as a bug reproduction: this is an internal cleanup refactor. Current-main source inspection does confirm the cleanup target, including separate lazy-runtime cache ownership and five manual library facade memoizers. Review metrics: 1 noteworthy metric.
Root-cause cluster Members:
Proposal only: this assessment does not dispatch repair, suppress jobs, mutate sibling items, close, or merge anything. Merge readiness Overall follows the weaker of proof and patch quality, so missing proof can cap an otherwise strong patch. Rank-up moves:
Next step before merge
Security Review detailsBest possible solution: Land this bounded foundation after ordinary maintainer review, while keeping the canonical tracker and broader draft available for follow-up migration batches. Do we have a high-confidence way to reproduce the issue? Not applicable as a bug reproduction: this is an internal cleanup refactor. Current-main source inspection does confirm the cleanup target, including separate lazy-runtime cache ownership and five manual library facade memoizers. Is this the best way to solve the issue? Yes: delegating lazy-runtime caching to the existing lazy-promise owner and migrating one bounded facade batch is the narrow maintainable first step. The broader repository-wide migration remains better handled in follow-up batches rather than forcing the draft reference implementation into this PR. AGENTS.md: found and applied where relevant. Codex review notes: model internal, reasoning high; reviewed against e701dc76b060. Label changesLabel justifications:
Evidence reviewedPR surface: Source +2, Tests +54. Total +56 across 5 files. View PR surface stats
What I checked:
Likely related people:
What the crustacean ranks mean
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
|
Related: #98748
What Problem This Solves
Resolves the first dependency in the lazy dynamic-import memoizer consolidation: callers need one well-tested cache owner before the repository can migrate repeated module-level promise variables in reviewable batches.
This is PR 1 of 6. It intentionally limits migration to the five representative lazy loaders in
src/library.ts; the remaining core, gateway, channel, and plugin batches will follow separately.Why This Change Was Made
Generalizes the existing lazy promise cache with explicit inspection and clearing, while preserving direct cached-promise identity and selectable rejection caching. The higher-level lazy runtime helpers delegate to that cache and retain sticky dynamic-import rejection behavior.
Only
src/library.tsadopts the new function API in this foundation PR.User Impact
No intended user-visible behavior change. Maintainers get the canonical lazy runtime primitive required for smaller follow-up deduplication PRs without changing module boundaries or publishing new Plugin SDK exports.
Evidence
node scripts/run-vitest.mjs src/shared/lazy-promise.test.ts src/shared/lazy-runtime.test.ts src/library.test.ts— 3 files, 10 tests passed across 2 shards.node scripts/run-tsgo.mjs -p tsconfig.core.json --incremental --tsBuildInfoFile .artifacts/tsgo-cache/core.tsbuildinfo.tbx_01kwjkfh0kb96nsja4bck61zz3—pnpm buildandpnpm check:import-cyclespassed; 0 runtime value cycles. Actions run: https://github.com/openclaw/openclaw/actions/runs/28628654780Series