Repository navigation
fix(tooling): preserve compiled plugin loading in source Gateways - #135077
Conversation
Select the documented ESM-only tsx preload so compiled dependencies keep their import export conditions. Preserve existing cache policy and regression-test wrapper/direct preload module identity, TypeScript aliases, and CommonJS callers. Fixes #134864.
|
🦞👀 Pull request received. I will update this pull request when review starts. |
|
Codex review: needs maintainer review before merge. Reviewed September 1, 2026, 12:43 PM ET / 16:43 UTC. ClawSweeper reviewWhat this changesThis PR switches repository TypeScript launchers to tsx’s ESM entry and adds a regression fixture for compiled ESM plugins with import-only dependencies. Regression provenancePossible regression — probable (reviewed change; failure trace). No predecessor PR is attributed. Merge readinessNo discrete correctness defect was found in the introduced patch. It remains open because the shared source-tooling preload is compatibility-sensitive and carries the protected maintainer label, requiring an explicit maintainer landing decision. Priority: P2 Review scores
Verification
How this fits togetherSource tooling and Gateway development commands preload TypeScript support before loading compiled plugin artifacts. The preload determines whether compiled ESM dependencies retain native import resolution and therefore whether plugin capabilities register. flowchart LR
A[Source tooling command] --> B[Repository TypeScript preload]
B --> C[tsx ESM loader]
C --> D[Compiled plugin module]
D --> E[Import-only dependency]
E --> F[Plugin capabilities register]
Decision needed
Why: The patch has no supported code-level blocker, but changing the common loader selection can affect many maintained source commands and is explicitly marked for maintainer handling. Before merge
Agent review detailsSecurityNone. PR surfaceTests +77, Docs +6, Other +2. Total +85 across 5 files. View PR surface stats
Review metrics
Root-cause clusterRelationship: Members:
Proposal only: this assessment does not dispatch repair, suppress jobs, mutate sibling items, close, or merge anything. Merge-risk optionsMaintainer options:
Technical reviewBest possible solution: Land the ESM-only preload after a maintainer accepts the shared source-tooling compatibility boundary, retaining the fresh-process regression fixture as its contract. Do we have a high-confidence way to reproduce the issue? Yes, source-reproducible: current main still imports the full tsx entry, and the PR supplies a focused fresh-process fixture plus exact-head runtime evidence. The reviewer did not execute the reproduction in this read-only checkout. Is this the best way to solve the issue? Yes: changing the shared preload at its producer preserves native ESM dependency resolution without adding plugin-specific fallbacks or changing dependency exports. AGENTS.md: found and applied where relevant. Codex review notes: model internal, reasoning high; reviewed against 520f6f7d22af. LabelsLabel justifications:
EvidenceWhat I checked:
Likely related people:
Rank-up movesOptional improvements that raise the rating; they are not merge blockers.
Rating scale
Overall follows the weaker of proof and patch quality. Workflow
History |
|
Land-ready proof for CI run 33530598869 completed successfully on this exact head; the repo watcher ended The current-head real source-Gateway comparison reproduced the actual behavior: full-tsx baseline gives OpenAI and memory-core load errors, no actual provider/image-provider registrations, and five observed export errors. The repaired repository preload loads both plugins, registers OpenAI's HTTP route, reaches the loopback mock Exact validation commands include: pnpm buildPassed on this head in 47m52s; no ineffective-dynamic-import warnings. node scripts/check-changed.mjs -- scripts/lib/tsx-cli-shim.mjs test/scripts/direct-run-entrypoints.test.ts test/scripts/direct-run-entrypoints.test-support.ts test/scripts/release-preflight.test.ts docs/reference/test.mdPassed, including selected formatting, lint, types and guards. node scripts/run-vitest.mjs test/scripts/direct-run-entrypoints.test.ts test/scripts/managed-child-process.test.ts test/scripts/release-preflight.test.ts src/plugins/native-module-require.test.ts src/plugins/loader.native-module-loader.test.tsThe current tooling shard passed 133 cases with one Linux-only skip, and the native-require cases passed 15. Some broad cold-import cases exceeded the existing local time budget, so this is not claimed as a passing full local suite. An original-order matched diagnostic passed 16 cases with two unselected, without changing assertions, timeouts, pool or isolation. Source tracing confirms the separate spawned Vitest process does not inherit this changed parent preload. Existing cold-preparation/obsolete-mock cleanup is recorded separately; exact-head CI and the real changed runtime boundary are green. node scripts/watch-pr-ci.mjs 135077 4e3926ac662d72a96950b9bde88fa9748a5eb1ffEnded No extra cache was disabled. Production executable LOC is unchanged; the +2 tooling lines are comments explaining export conditions. Tests/support are +79/-2; docs +9/-3. No dependency, configuration, schema, version or fallback-policy changes. No real OpenAI API call, new npm tarball installation, external channel delivery, or performance benchmark is claimed. The image task's HTTP-only delivery status is No ClawSweeper PR review comment or Rank-up list was present in the latest fresh comments read; the linked issue's request for hydrated dependency and actual registration proof is fulfilled. The publisher is not treated as a merge gate. The PR body preserves the inspected UI-parity captures and detailed before/after evidence. |
|
Merged via squash.
|
Replace the stale source-only loader mock with native-hit and source-transform counter assertions at the real registry boundary. Preserve packaged loaded-status and published SDK-bridge coverage, and remove mock-only module resets and duplicate fixture setup. Follow-up to #135077. Negative controls prove the original assertions falsely passed on native fallback; repaired assertions reject it. Clean Linux baseline passed 3 tests and candidate plus siblings passed 70. No production changes or claim to fix local cold-import timing.
…5425) Replace the stale source-only loader mock with native-hit and source-transform counter assertions at the real registry boundary. Preserve packaged loaded-status and published SDK-bridge coverage, and remove mock-only module resets and duplicate fixture setup. Follow-up to #135077. Negative controls prove the original assertions falsely passed on native fallback; repaired assertions reject it. Clean Linux baseline passed 3 tests and candidate plus siblings passed 70. No production changes or claim to fix local cold-import timing.
…enclaw#135077) Select the documented ESM-only tsx preload so compiled dependencies keep their import export conditions. Preserve existing cache policy and regression-test wrapper/direct preload module identity, TypeScript aliases, and CommonJS callers. Fixes openclaw#134864.
…nclaw#135425) Replace the stale source-only loader mock with native-hit and source-transform counter assertions at the real registry boundary. Preserve packaged loaded-status and published SDK-bridge coverage, and remove mock-only module resets and duplicate fixture setup. Follow-up to openclaw#135077. Negative controls prove the original assertions falsely passed on native fallback; repaired assertions reject it. Clean Linux baseline passed 3 tests and candidate plus siblings passed 70. No production changes or claim to fix local cold-import timing.
What Problem This Solves
Fixes an issue where developers running a source Gateway would lose OpenAI and memory-core plugin capabilities when the repository TypeScript preload loaded their compiled JavaScript entries. The Gateway could still report ready and serve the Control UI, while repeated plugin discovery logged
ERR_PACKAGE_PATH_NOT_EXPORTED.Closes #134864. AI-assisted maintainer repair.
Why This Change Was Made
The shared tooling preload now selects tsx's documented ESM entry rather than its full entry. The full entry installs CommonJS hooks that rewrite a valid compiled ESM dependency edge (
execa→npm-run-path→ the import-onlyunicorn-magicexport) into an unsupportedrequire(); selectingtsx/esmcorrects that environment at its producer instead of changing plugin policy, dependency exports, or fallback handling.This removes the unwanted global CommonJS transformation from the maintained source launchers. It does not change the dependency versions or the existing cache policy. Source TypeScript, tsconfig aliases, native CommonJS, inherited forks, and module identity remain covered.
User Impact
Source-Gateway development and proof runs can load the compiled plugins and use their registered capabilities. No additional cache is disabled: tsx's in-process transform cache and Node's module cache remain enabled, and the existing shared-disk-cache setting is unchanged. The normal native built CLI remains working. No configuration options, migrations, schema changes, or version bumps are introduced.
Evidence
The reported failure and repair were exercised through real isolated source Gateways on Node 24.20.0, using freshly built Control UI/plugin artifacts, fresh secretless HOME/state directories, separate loopback ports, and a local mock HTTP provider. The most recent comparison ran on exact PR head
4e3926ac662d72a96950b9bde88fa9748a5eb1ff, holding the cache policy constant and comparing full tsx with the repaired repository preload. It reproduced the same outcomes as the earlier verified patch on2b6b1e2a8b81ee420bc08244d34a5927a404f785.Current head
4e3926ac662d72a96950b9bde88fa9748a5eb1ffpreserves all four code/test files byte-for-byte from that verified patch and retains newer upstream documentation. Its fresh fullpnpm buildhas passed in 47m52s with no ineffective-dynamic-import warnings. The current multi-config replay has 133 tooling cases passing (one platform skip), but cold preparation in the broader native-loader group exceeded its existing timeout. An isolated first-case diagnostic passes, and matched diagnostics in the original native-first order pass 16 cases (two unselected), with 23.318s preparation and a 54.775s loader case. No assertion, timeout, pool, or isolation setting was relaxed. Source inspection confirms the separate Vitest process is spawned with explicit arguments and does not inherit the parent's changed tsx registration; no ambient loader preload was present. Different default cache paths/preparation costs remain a local proof caveat, not a demonstrated regression from this patch. The renewed current-head Gateway proof, selected changed-file checks, and fresh isolated Codex review (no actionable P0 findings) have completed successfully. Exact-head CI run 33530598869 completed successfully, and the repo CI watcher endedGREEN. The current built CLI also loads OpenAI with eight capabilities and no diagnostics. Both proof Gateways shut down with no cleanup errors, their synthetic state removed, and both ports closed.openaiimage_generateprovider listing/tools/invoke/v1/images/generationsreached; PNG saved; owning task persistedstatus=succeeded,error=nullThe image task's delivery status was
not_applicablein this HTTP-only rig; no external channel delivery is claimed. The UI's installed-plugin catalog and HTTP readiness are not used as runtime plugin-health evidence.Focused reproducible dependency controls (full-tsx fails with the export error; the repaired repository preload succeeds):
node --import tsx -e 'require("execa")'node --import ./scripts/tsx.mjs -e 'require("execa")'Validation completed on the original verified source snapshot:
node scripts/run-vitest.mjs test/scripts/direct-run-entrypoints.test.ts test/scripts/managed-child-process.test.ts test/scripts/release-preflight.test.ts src/plugins/native-module-require.test.ts src/plugins/loader.native-module-loader.test.ts: 150 passed, one Linux-only test skipped on macOS.node scripts/check-changed.mjs -- scripts/lib/tsx-cli-shim.mjs test/scripts/direct-run-entrypoints.test.ts test/scripts/direct-run-entrypoints.test-support.ts test/scripts/release-preflight.test.ts docs/reference/test.md: passed, including formatting, lint, root-test types, and selected guards. Checked on Node 24 and again on Node 26.pnpm build: passed in 7m57s, with no ineffective-dynamic-import warnings.Installed dependency contracts inspected directly: tsx 4.23.12, Execa 10.0.1, npm-run-path 6.0.0, unicorn-magic 0.3.0. No live OpenAI API credentials or freshly installed npm tarball were used; these results establish source-loader integration, not an external-provider service claim. Windows execution and a performance benchmark were not run locally; no overall speed claim is made.
Production/tooling LOC: +3/-1, entirely the one-for-one executable substitution plus two explanatory comment lines (executable net zero). Tests/support: +79/-2. Docs: +9/-3. No new production helper, fallback, or branch.
Related source-public-artifact repair #132166 is already merged; this change repairs the distinct full-preload interception of the compiled native path. Original regression introduction is unknown; no carrier commit or contributor is blamed. A separate follow-up is recorded for the older native-loader tests' partial mock: it watches
getCachedPluginSourceModuleLoader, while the current runtime callsgetCachedPluginModuleLoader. This PR adds real fresh-process boundary coverage without expanding into that test cleanup or changing runtime health presentation/negative-result reuse.Release context: source Gateway runs retain compiled-plugin capabilities without disabling additional caching. Updated operator/developer documentation: https://docs.openclaw.ai/reference/test.
Supplementary UI parity from the original proof snapshot
Both screenshots show the static installed-plugin catalog remaining available. They are not runtime plugin-health proof; actual registration and capability behavior are recorded above.