Skip to content

perf(plugins): resolve SDK aliases on demand - #139997

Merged
steipete merged 1 commit into
mainfrom
codex/perf51-sdk-alias-demand
Sep 6, 2026
Merged

steipete merged 1 commit into
mainfrom
codex/perf51-sdk-alias-demand

Conversation

@steipete

@steipete steipete commented Sep 6, 2026

Copy link
Copy Markdown
Contributor

What Problem This Solves

A plugin importing one SDK entry pays to discover and validate targets for the entire SDK inventory. This adds avoidable cold import work and delays development Gateway readiness.

Why This Change Was Made

Resolve only the requested, permitted SDK subpath and keep the result (including a miss) within the existing loader generation. Native CommonJS and late ESM resolution use this prepared resolver; Jiti and build consumers still receive the complete alias map when they request it. Preserve source/dist selection, private-owner eligibility, both package spellings, parent-root boundaries and first-demand precedence for overlapping roots.

Remove the eager native alias enumerator and redundant map caches. Production changes total −5 lines; tests +81. The assertion budget also shrinks by two to reflect removed casts. No configuration, defaults, schemas, persisted state or public exports change.

User Impact

Less work when loading a small part of the SDK, with unchanged import and plugin behavior. Full-map consumers retain their existing path; this does not claim faster model inference.

Evidence

  • 172 focused tests passed, with one existing Windows-only skip; two complete matched normal builds passed. All 32 normal changed checks and a fresh independent P2 review passed. The initial check required shrinking the assertion budget from three to one; that failure and the generated correction are preserved.
  • Fixed cold-loader cohort: 384 actual resolver/import observations on a synthetic 330-entry inventory. Single-alias medians improved 71.6–75.2%, native CJS 32.0–33.0%, late ESM 33.2–33.6%, and 24 native imports 15.1–17.0%. Complete semantic witnesses matched. Five of 24 owner medians worsened, including Jiti-dist +0.35%/+0.04%; all adverse values remain recorded.
  • Matched real OpenAI development Gateways ran B0/C0/C1/B1, then a separate baseline/candidate CPU-profile pair. Identical nine-turn workloads exercised text, reads, writes, a real web fetch, recall, expected file failure and concurrent sessions. All 36 unprofiled answers passed. Readiness improved 3,394.9→2,999.7 ms and 3,185.5→3,002.2 ms (11.64%/5.75%). Whole-phase duration was +8.60%/−6.45%; no overall turn-latency improvement is established. All 36 adverse comparisons among 90 primary metrics are retained.
  • Across all six Gateways: 53/54 strict answers, all 36 paired tool calls, 84 observed successful provider HTTP requests. The profiled baseline's web answer said “documentation examples” instead of required exact “documentation”; its tool passed. That failure was not rerun or reclassified. Four profiles are structurally valid; original hit-count discrepancies remain. SDK alias-map stacks had 28→13 inclusive samples and artifact checking 13→6; these overlapping single-pair samples are diagnostic, not percentage speedup claims.
  • All 211 observed processes/48 groups, the credential holder and six task ports closed; exact API/service-value scans found no matches in retained evidence. No operator Gateway or user state was touched.

The cold cohort was interrupted after observation 92 by an incorrect output-size projection, then continued only the remaining observations. Original outcomes and the interrupted receipt are preserved; the helper workload did not change. Its initial environment inherited a service credential; an exact scan found zero output occurrences, and continuation excluded it. This is qualified, interrupted component evidence, distinct from the uninterrupted per-phase live measurements. Normal-build elapsed times are not treated as performance measurements. Two live observations per variant do not establish significance or population tails.

@clawsweeper

clawsweeper Bot commented Sep 6, 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.

@steipete
steipete marked this pull request as ready for review September 6, 2026 09:43
@openclaw-barnacle openclaw-barnacle Bot added size: M maintainer Maintainer-authored PR labels Sep 6, 2026
@clawsweeper clawsweeper Bot added P2 Normal backlog priority with limited blast radius. 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 Sep 6, 2026
@clawsweeper

clawsweeper Bot commented Sep 6, 2026

Copy link
Copy Markdown
Contributor

Codex review: needs maintainer review before merge. Reviewed September 6, 2026, 5:53 AM ET / 09:53 UTC.

ClawSweeper review

What this changes

The plugin loader resolves SDK import targets individually, caches results within the existing loader generation, and retains complete alias maps for consumers that need them.

Merge readiness

✅ Ready for maintainer review

This remains a useful performance change: current main and the latest release still prepare the complete SDK alias map on first demand. No blocking correctness or security defect was found in the introduced patch.

Priority: P2
Reviewed head: d78a8ad78d1f7649c3b012d95744941b5fc31f97

Review scores

Measure Result What it means
Overall readiness 🐚 platinum hermit (4/6) A focused optimization with relevant boundary coverage, qualified runtime observations, and no concrete blocking defect found.
Proof confidence 🌊 off-meta tidepool Not applicable: The maintainer-authored PR is exempt from the external-contributor proof gate; its captured body reports actual resolver/import comparisons and matched development Gateway readiness measurements, with adverse results disclosed.
Patch quality 🐚 platinum hermit (4/6) No actionable review findings were identified.

Verification

Check Result Evidence
Real behavior Not applicable Not applicable: The maintainer-authored PR is exempt from the external-contributor proof gate; its captured body reports actual resolver/import comparisons and matched development Gateway readiness measurements, with adverse results disclosed.
Evidence reviewed 8 items Current main still performs eager artifact preparation: The fetched main revision retains resolvePluginSdkScopedAliasMap, which iterates all exported subpaths and validates their artifacts. Its SDK alias source blob is 7b6dcfe824db958505f14ee1bcba15f12f705c1f.
Latest release has the same eager implementation: The v2026.9.2 source also iterates the complete SDK inventory; the requested optimization is not present in this release.
Introduced resolver behavior: The pinned introduction diff replaces native full-map registration with per-specifier resolution while retaining parent containment, JavaScript-only native targets, first-demand precedence, and provider replacement.
Findings None None.
Security None None.

How this fits together

OpenClaw’s plugin loader translates SDK imports into source or built module paths. These aliases feed native CommonJS, ESM, and source-transform loaders while preserving the plugin’s host and permitted SDK inventory.

flowchart TD
  A[Plugin SDK import] --> B[Registered parent scope]
  B --> C[Permitted SDK inventory]
  C --> D[Resolve requested artifact]
  D --> E[Generation cache]
  E --> F[Native module loader]
  C --> G[Complete alias map on demand]
  G --> H[Source transformer or build]
Loading

Before merge

None.

Agent review details

Security

None.

PR surface

Source -5, Tests +81, Other 0. Total +76 across 7 files.

View PR surface stats
Area Files Added Removed Net
Source 3 85 90 -5
Tests 3 93 12 +81
Docs 0 0 0 0
Config 0 0 0 0
Generated 0 0 0 0
Other 1 1 1 0
Total 7 179 103 +76

Review metrics

None.

Technical review

Best possible solution:

Keep SDK target discovery demand-driven within the existing cache generation, with the same permitted inventory and complete-map fallback for transformer consumers.

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

Not applicable as a functional bug reproduction: this is a performance optimization. Current source confirms the eager inventory traversal, and the captured body reports comparative runtime measurements.

Is this the best way to solve the issue?

Yes. Resolving individual targets through the existing prepared context removes unnecessary artifact checks without introducing a competing loader or changing public SDK exports.

AGENTS.md: found and applied where relevant.

Codex review notes: model internal, reasoning medium; reviewed against 8a29e7cd6323.

Labels

Label changes:

  • add P2: This is a bounded plugin startup performance improvement with reported readiness gains and no established urgent user-facing regression.
  • add rating: 🐚 platinum hermit: Overall readiness is 🐚 platinum hermit; proof is 🌊 off-meta tidepool 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: The maintainer-authored PR is exempt from the external-contributor proof gate; its captured body reports actual resolver/import comparisons and matched development Gateway readiness measurements, with adverse results disclosed.

Label justifications:

  • P2: This is a bounded plugin startup performance improvement with reported readiness gains and no established urgent user-facing 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: The maintainer-authored PR is exempt from the external-contributor proof gate; its captured body reports actual resolver/import comparisons and matched development Gateway readiness measurements, with adverse results disclosed.

Evidence

What I checked:

  • Current main still performs eager artifact preparation: The fetched main revision retains resolvePluginSdkScopedAliasMap, which iterates all exported subpaths and validates their artifacts. Its SDK alias source blob is 7b6dcfe824db958505f14ee1bcba15f12f705c1f. (src/plugins/sdk-alias.ts:1173, 8a29e7cd6323)
  • Latest release has the same eager implementation: The v2026.9.2 source also iterates the complete SDK inventory; the requested optimization is not present in this release. (src/plugins/sdk-alias.ts:1173, 3928bad9badf)
  • Introduced resolver behavior: The pinned introduction diff replaces native full-map registration with per-specifier resolution while retaining parent containment, JavaScript-only native targets, first-demand precedence, and provider replacement. (src/plugins/plugin-sdk-native-resolver.ts:280, d78a8ad78d1f)
  • Lifecycle contract: Documentation defines progressively acquired SDK and artifact facts as generation-owned, including misses. The patch captures the same host and private-owner context and resolves deferred targets within the captured cache. Public docs: docs/plugins/architecture-internals.md. (docs/plugins/architecture-internals.md:144, d78a8ad78d1f)
  • Boundary regression coverage inspected: Tests exercise late CJS and ESM imports, unused-artifact avoidance, full-map alias families, host replacement, foreign parents, private-owner separation, and generation retention. Additional cases protect overlapping-root precedence and negative target caching. Tests were inspected, not executed during this read-only review. (src/plugins/loader.lazy-alias.test.ts:94, d78a8ad78d1f)
  • Captured runtime observations: The supplied complete PR body reports 384 resolver/import observations and matched development Gateway runs, including 36 passing unprofiled answers and readiness improvements of 11.64% and 5.75%. It explicitly retains adverse comparisons, the interrupted component cohort, and a profiled baseline answer mismatch. These are author-reported observations; no raw artifact link was supplied. Captured context sourceRevision: b601b146ef6948080e65bf8f25e023314733544961c3412e90ce16403a583352. (d78a8ad78d1f)

Likely related people:

  • steipete: Suggested for follow-up; no historical authorship or introduction is verified. (role: unverified routing candidate; confidence: low)

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.

@steipete
steipete merged commit c5a7231 into main Sep 6, 2026
247 checks passed
@steipete
steipete deleted the codex/perf51-sdk-alias-demand branch September 6, 2026 10:01
@steipete

steipete commented Sep 6, 2026

Copy link
Copy Markdown
Contributor Author

Merged via squash.

steipete added a commit to lucascmg-vx/openclaw that referenced this pull request Sep 6, 2026
Merge verified main c5a7231, including
openclaw#139997 on-demand SDK aliases and openclaw#139924 catalog timeout ownership.
Preserve the Bedrock runtime, fixture and LLM export bytes. Documentation
retains the existing scheduler guidance alongside disjoint main updates.

The prior Bedrock HTTP and build checks passed; shared ACP cleanup and
literal OAuth discovery failures require these canonical owner fixes.
A fresh exact-head CI run follows this reviewed integration.

Co-authored-by: Lucas Cardoso <[email protected]>
github-actions Bot pushed a commit to Desicool/openclaw that referenced this pull request Sep 7, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

maintainer Maintainer-authored PR P2 Normal backlog priority with limited blast radius. 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