Repository navigation
fix: prevent provider catalog failures during concurrent SDK imports - #196448
Conversation
|
🦞👀 Pull request received. I will update this pull request when review starts. ClawSweeper review completeClawSweeper finished reviewing this revision. The review result is being finalized. |
|
Codex review: needs real behavior proof before merge. What this changesThe PR prepares shared SDK modules before adjacent host imports can race with synchronous plugin loads. Example: OpenAI and xAI concurrently import dist/plugin-sdk/provider-auth-runtime.js.
Review scores
ProductKind: Bug fix · Worth it: Yes · Fix scope: Complete Merge readiness⛔ Blocked before merge - 1 item remains Keep this PR open: it addresses a concrete provider-loading failure still present on current main, and no introduced correctness defect was found. Priority: P2 Before merge
FindingsNone. Tests
Agent review detailsHow this fits togetherThe native plugin resolver sits between Node module requests and the existing SDK alias contexts; it resolves module identities and prepares shared SDK graphs consumed by host chunks and plugins. flowchart TD
A[Provider discovery scheduler] --> B[Host catalog import]
A --> C[Plugin catalog import]
B --> D[Native SDK resolver]
C --> D
D --> E[Existing SDK alias contexts]
D --> F[Shared evaluated SDK module]
Technical reviewBest possible solution: Extend the existing resolver's preparation invariant to matching host SDK imports while retaining concurrent discovery and native asynchronous loading. Do we have a high-confidence way to reproduce the issue? Current-main source exposes the host/plugin preparation mismatch, and the contributor reports the added host regression failing on the pinned base with ERR_REQUIRE_ESM_RACE_CONDITION; this review executed no target code. Is this the best way to solve the issue? The patch repairs the shared resolver rather than serializing discovery or retrying failed catalogs, and its host-only asynchronous fallback preserves the existing plugin loading contract. AGENTS.md: found and applied where relevant. Codex review notes: model internal, reasoning medium; reviewed against 802f67d8d410. Provenance checked
TestingProof path: in-process harness. SecurityNone. EvidenceWhat I checked:
PR surfaceSource +38, Tests +22, Other +2. Total +62 across 3 files. Added test files: 0. View PR surface stats
Preflight sourceSource unknown. Source comparison at the observed PR snapshot only. Completion is self-reported; body, policy, tests, execution, and report bytes are not verified. Review metrics
Root-cause clusterRelationship: Members:
Proposal only: this assessment does not dispatch repair, suppress jobs, mutate sibling items, close, or merge anything. LabelsLabel changes:
Label justifications:
Rating scale6/6 🦀 challenger crab · 5/6 🦞 diamond lobster · 4/6 🐚 platinum hermit · 3/6 🦐 gold shrimp · 2/6 🦪 silver shellfish · 1/6 🧂 unranked krab. Overall follows the weaker of proof and patch quality; ✨ marks media proof (a screenshot, video, or linked artifact) that directly shows the changed behavior. WorkflowClawSweeper edits this one comment on every review. Comment HistoryReview history (1 earlier review cycle)
Reviewed November 10, 2026, 3:24 AM ET / 08:24 UTC (Revision 2). |
|
Added a sanitized real built host/plugin catalog overlap trace to the PR body on unchanged head The body explicitly identifies the boundary: the shipped scheduler consumes harness-combined genuine per-provider preparation with verified common provenance. Ordinary CLI/Gateway refresh still selects OpenAI's lightweight entry and does not demonstrate the root-host scenario. No end-to-end or live-vendor success is claimed. Please assess this added evidence against the requested proof boundary; if the ordinary command path is essential, that gap remains open. The exact hosted CI base was also executed independently: it is already 11 test lines over its ceiling, matching the hosted residual. CI remains failed; no waiver or Baseten root-cause attribution is claimed. @clawsweeper re-review |
|
🦞👀 Re-review progress:
|
Independent isolated-Gateway red/green proofVerified the reported SDK-loading race through an ordinary Gateway + CLI catalog-refresh flow, rather than only the built-catalog harness.
The fixture triggers the normal full-catalog discovery fallback by failing a lightweight discovery entry; the real OpenAI and xAI catalog callbacks are unchanged. Worker-aware tracing confirms OpenAI's root host chunk imports the SDK and xAI starts before OpenAI settles. The CLI refresh and Gateway shutdown exit cleanly. Repeating both revisions without instrumentation gives the same baseline-fails / patch-passes result. Healthy sibling discovery remains present in both. Environment: secretless remote Linux box, Node 26.12.1, isolated temporary home/config/state and loopback Gateway port. No vendor credentials or live inference; this verifies module loading and catalog discovery. The operator's live Gateway was untouched. All test Gateways stopped and the remote box was released after testing. This closes the missing product-entry-point proof for the loader race. CI investigationInspected full logs for run 42758257852, attempt 1. Its tested merge commit is
Disposition: neither failure identifies a regression introduced by this Node SDK-loader repair. Baseten is a separate deadline/test-reliability investigation; its detailed timing cause remains unproven. CI remains red: no checks were waived, rerun, or marked successful, and no unrelated test timeout or allocation was changed. |
Adapt the Coding Plan retained-catalog repair to the stable named forward-compatibility helper without changing native route or auth guards. Exercise real plugin model resolution and final request routing for general, Coding Plan, regional, proxy, and model-level override endpoints. The separately requested SDK import repair (#196448) is already covered by baseline ancestor bcd022a; retain it unchanged. Worked on by: - @jason-allen-oneal (cherry picked from commit aed2383) Co-authored-by: jason-allen-oneal <[email protected]> Co-authored-by: RomneyDa <[email protected]>
…rs (#196448) Also resolves issue #195477. Retain exact registered SDK target and adjacent host checks, native query identity, and the narrow host-only async fallback. (cherry picked from commit f5180d7) Co-authored-by: RomneyDa <[email protected]>
Adapt upstream source 625945b to the beta3 runtime owners. Keep synchronous SDK compatibility while deferring tool, model, plugin, process and state-handler initialization. Integrate on 67cc5d9, preserving #195398, #196301, #196386, #196387, #189991 and #196448. Three automatically merged overlaps retain canonical assertion/mock baseline removals and worker-turn input gating; no new behavioral adaptation. Original source reviews and focused build/test evidence are retained. Fresh integration-only independent review found no actionable issues. Co-authored-by: RomneyDa <[email protected]> Co-authored-by: vincentkoc <[email protected]>
Repair required openclaw#195477 on the frozen 2026.11.3 baseline. Adjacent host chunks prepare only the exact SDK target recognized by a captured alias context; host chunks do not become plugin alias parents. Retain native ESM evaluation for ERR_REQUIRE_ASYNC_MODULE only on that host-path case. Release adaptation: authored from inspection of unmerged PR openclaw#196448, source 2b4d380. Keep the stable contexts/sdkRoots owner rather than importing the later sdk.roots cache refactor. Preserve Windows filename normalization, captured alias grants, exact URL identity, and the existing Node/Bun hook selection. Adapt tests to stable fixture helpers and add host-only fallback/identity negatives. Companions: existing synchronous plugin SDK preparation (05a2844), canonical cached parent boundaries (ea49097), native Windows targets (0e92339), and scoped Bun denial coverage (39c0bed) are present. The source test-line allocation is not applicable: retained allocation files have no consumer in the stable scripts/package/CI graph. No new public SDK export or dependency. Validation: actual native loader host-import/CJS race failed before the production change with ERR_REQUIRE_ESM_RACE_CONDITION; alias/relative siblings passed. Final loader/resolver suite: 41/41 tests. Scoped plugin types, lint, formatting and diff checks pass. Restricted independent autoreview with full owning context is P0/P1 scoped-clean. Original implementation by 1052326311, preserved as author. Co-authored-by: RomneyDa <[email protected]> (cherry picked from commit f68ddc67ca464482f04142b05769e5961eb0e89d)
Closes #195477
What Problem This Solves
Provider catalogs can fail to load with
ERR_REQUIRE_ESM_RACE_CONDITIONwhen a host chunk starts importing the SDK while a plugin requires the same module.User Impact
Catalog discovery can finish for both consumers without serializing providers. Host async imports, query URL identity, and plugin alias restrictions remain intact.
Why This Change Was Made
Prepare an already exported SDK target before an adjacent host chunk starts its ESM evaluation, using the existing resolver and SDK contexts. Host chunks gain no plugin alias grant. Host-only top-level-await graphs retain native async loading; other errors still propagate.
Evidence
Node 26.8.2: the new host regression fails on base
e27557203a5279ca4d56c21a531a291c0d5c794awithERR_REQUIRE_ESM_RACE_CONDITION; existing alias/relative cases pass. The final loader suite passes all 24 tests withOPENCLAW_VITEST_RUNTIME=node node scripts/run-vitest.mjs src/plugins/loader.lazy-alias.test.ts --maxWorkers=1.A local probe through the real
runProviderCatalogand native resolver reproduces a failed plugin catalog on the base and three successful catalogs on the fix, including an independent healthy sibling. Generated module fixtures also verify host TLA, query URLs, unexported imports, unrelated parents, and preserved plugin/error rejection behavior. This uses synthetic SDK/hooks; full implicit discovery, live OpenAI/xAI calls, an installed Gateway, and a stable-to-candidate upgrade were not exercised.Focused plugin-test typecheck, lint, format, plugin import-boundary inventory and staged diff/secret/size checks pass. Independent read-only Codex review found a host TLA compatibility regression and an incorrect fixture preference; both were corrected, with no remaining actionable findings. Local autoreview/ClawSweeper was not run.
The test-line ratchet still fails by 12 inherited lines: exact base 6,615,496 / ceiling 6,615,484; candidate 6,615,518 / ceiling 6,615,506. A separate allocation grants exactly the 22 net regression lines needed for host concurrency and native async boundary coverage; the shared scalar is unchanged. This is a disclosed failed check, not a pass or CI exemption.
pnpm buildcompleted with exit 0, covering runtime bundles, declarations, SDK exports and Control UI. Its UI-size report lists three over-budget measurements; no UI-size qualification is claimed.Built OpenAI and xAI cold imports both complete successfully with the repository profiler, concurrency 1, in an isolated home. The final report qualifies clean source/build/entry identity. The full build ran over the exact committed source bytes before committing; generated build info was refreshed through its canonical script afterward. These are cold-import results, not a claim about activation, live catalog requests, or performance improvement.
Follow-up verification (November 10)
The reviewed source head is unchanged:
2b4d3809aec6ea3ec6d4687576f6e032ca933630.node openclaw.mjs models list --all --refresh --json, with isolated home/config/state, OpenAI and xAI enabled, and no provider credentials. It entered local catalog refresh and exited 0 with 16 OpenAI model rows; no xAI rows were returned without credentials.models.listRPC. The Gateway reached ready, the CLI returned 16 model rows and exit 0, and the Gateway shut down cleanly with exit 0. The local Gateway token was synthetic. These checks exercised empty-auth catalog loading and projection, not live vendor discovery or inference..setupcatalog and xAI's plugin entry resolving the shared SDK. The Gateway refresh trace shows the OpenAI.setupcatalog. They do not show the adjacent root host chunk executing its catalog import. Consequently these successful product-entry smoke checks do not yet fulfill ClawSweeper's requested concurrent host/plugin discovery proof. That evidence request remains open; no re-review or merge-readiness claim is made here.Current failed CI
Run 42758257852 completed with failures.
pnpm test:ci-failed 196448reports the ratchet asnew(matching scheduled main job passed, scope not compared) and the Baseten shard asunknown(no matching main job).568d89f3a4e82d13ecca4ed602c46a04bda322f0now reports 6,615,839 / 6,615,828, over 11, net delta 0. I retrieved only the six missing public test blobs (111,204 bytes total), verified each Git object ID, and ran the staged ratchet with lazy fetching disabled. The candidate adds 22 test lines and 22 allocated lines, so the observed 11-line residual is already present on that exact CI base. This is additional baseline evidence; it does not change the classifier output above, make the hosted check pass, or claim a maintainer waiver. The check remains failed.phase=evaluation, elapsed 7013 ms). The prescribedpnpm test:ci-failed 196448 --runsubsequently passed the selected test locally on macOS at the unchanged source head: 1 passed, 4 skipped, exit 0. A preceding local attempt exhausted disk while compiling test subprocesses and executed no tests. A passing local replay does not establish a fix or explain the hosted failure; its attribution remains unresolved. No CI rerun or unrelated source change was made.Shipped catalog integration: observed host/plugin overlap
On the unchanged head above, an isolated native-Node process loaded the built OpenAI and xAI plugins with the shipped full loader. It obtained each provider's preparation through the shipped
prepareImplicitProviderStaticCatalog, checked that both results retained the same registry/load-context provenance and the registered catalog callbacks, then passed their combined preparation to the unchanged shippedresolveImplicitProvidersscheduler. No catalog callback or SDK module was replaced, no artificial delay was injected, and no vendor credentials were supplied.Sanitized terminal/native-resolver observations (times are process-relative milliseconds):
Both imports resolve to the same shipped SDK facade; the host request is the first SDK request in the trace. The production resolver SHA256 remains
66e994409d35907734d8c0d7755f1fae1d6064735b0f5af8c8dd55ea7c94a38e, and the tracked tree is clean. Node inspector breakpoints observed invocation and post-await settlement, so the timings are not performance evidence.Proof boundary: this is real built loader/catalog integration with harness-combined, genuine per-provider preparation. It is not ordinary top-level CLI/Gateway end-to-end proof, a baseline-red run of this new harness, or successful live-vendor inference. The earlier CLI/Gateway refresh traces still select OpenAI's lightweight
.setupcatalog and do not establish this host import. Source inspection explains that bulk planning queries full runtime providers for[xai], retaining the OpenAI lightweight descriptor, even when the full registry contains both providers. This trace adds the missing real host/plugin overlap without claiming that the ordinary refresh path exercises it.