Skip to content

fix(tooling): preserve compiled plugin loading in source Gateways - #135077

Merged
steipete merged 1 commit into
mainfrom
steipete/session-continuation-1b730a
Sep 1, 2026
Merged

steipete merged 1 commit into
mainfrom
steipete/session-continuation-1b730a

Conversation

@steipete

@steipete steipete commented Sep 1, 2026 •

Copy link
Copy Markdown
Contributor

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-only unicorn-magic export) into an unsupported require(); selecting tsx/esm corrects 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 on 2b6b1e2a8b81ee420bc08244d34a5927a404f785.

Current head 4e3926ac662d72a96950b9bde88fa9748a5eb1ff preserves all four code/test files byte-for-byte from that verified patch and retains newer upstream documentation. Its fresh full pnpm build has 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 ended GREEN. 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.

Actual boundary Full-tsx baseline Repaired repository preload
Compiled OpenAI and memory-core registration Both error Both loaded
Actual registered provider/image-provider objects Empty openai
OpenAI HTTP route Absent Registered
image_generate provider listing No providers OpenAI available
Image generation through /tools/invoke Capability unavailable Mock /v1/images/generations reached; PNG saved; owning task persisted status=succeeded, error=null
HTTP readiness and built Control UI Both available despite plugin failures Both available

The image task's delivery status was not_applicable in 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:

  • The new generated-plugin regression fails on the pre-fix production code for the intended import-only export error in both wrapper and direct-preload cases, then passes on the repair. It also verifies a single module evaluation and shared identity across repeated require/import, real TypeScript transformation, source aliases, and native CommonJS loading.
  • 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.
  • Fresh native built CLI runtime inspection: OpenAI loaded, eight capabilities, no diagnostics. Separate Node 24.20.0 and 26.8.1 controls preserve require/import identity, source transforms, and aliases.
  • Independent isolated Codex autoreview: no actionable findings at the requested P0 threshold. Direct owner/caller/sibling and installed dependency-contract inspection supplemented that review.

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 calls getCachedPluginModuleLoader. 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.

Baseline static catalog despite runtime load failures

Repaired source Gateway static catalog

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.
@clawsweeper

clawsweeper Bot commented Sep 1, 2026

Copy link
Copy Markdown
Contributor

🦞👀
ClawSweeper picked this up.

Pull request received. I will update this pull request when review starts.

@openclaw-barnacle openclaw-barnacle Bot added docs Improvements or additions to documentation scripts Repository scripts size: S maintainer Maintainer-authored PR labels Sep 1, 2026
@clawsweeper clawsweeper Bot added P2 Normal backlog priority with limited blast radius. merge-risk: 🚨 compatibility 🚨 May break existing users, config, migrations, defaults, or upgrade paths. 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 1, 2026
@clawsweeper

clawsweeper Bot commented Sep 1, 2026 •

Copy link
Copy Markdown
Contributor

Codex review: needs maintainer review before merge. Reviewed September 1, 2026, 12:43 PM ET / 16:43 UTC.

ClawSweeper review

What this changes

This PR switches repository TypeScript launchers to tsx’s ESM entry and adds a regression fixture for compiled ESM plugins with import-only dependencies.

Regression provenance

Possible regression — probable (reviewed change; failure trace). No predecessor PR is attributed.

Merge readiness

⚠️ Ready for maintainer review - 3 items remain

No 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
Reviewed head: 4e3926ac662d72a96950b9bde88fa9748a5eb1ff
Owner decision: Required. See Decision needed.

Review scores

Measure Result What it means
Overall readiness 🐚 platinum hermit (4/6) A focused, low-surface repair with meaningful boundary coverage and no supported correctness finding; final acceptance is a maintainer compatibility decision.
Proof confidence 🌊 off-meta tidepool Not applicable: This maintainer-authored PR is exempt from the external-contributor proof gate; its supplied discussion nevertheless records an isolated after-fix source-Gateway run through plugin registration and a mock image-generation request.
Patch quality 🐚 platinum hermit (4/6) No actionable review findings were identified.

Verification

Check Result Evidence
Real behavior Not applicable Not applicable: This maintainer-authored PR is exempt from the external-contributor proof gate; its supplied discussion nevertheless records an isolated after-fix source-Gateway run through plugin registration and a mock image-generation request.
Evidence reviewed 6 items Introduced loader selection: The introduced hunk resolves and imports tsx’s ESM entry, while retaining the existing cache policy and launcher boundary.
Current-main baseline remains affected: Fetched current main still resolves the full tsx entry rather than tsx/esm, so the central repair is not already present on main.
Boundary regression coverage: The new test exercises both a maintained wrapper and the direct preload against a compiled ESM fixture, checking import-only resolution, module identity, TypeScript transformation, and source aliases.
Findings None None.
Security None None.

How this fits together

Source 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]
Loading

Decision needed

Question Recommendation
Should this protected, repository-wide source-tooling preload change be accepted for landing on the supplied exact-head validation? Accept the loader repair: Land the ESM-only preload, relying on the focused fresh-process regression coverage and supplied exact-head Gateway and CI evidence.

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

  • Resolve merge risk (P1) - This changes the preload used by many source tooling commands; the reviewed checkout lacks the pinned tsx package source, so its exported ESM entry could not be independently inspected despite the supplied exact-head runtime evidence and CI.
  • Complete next step (P2) - No mechanical repair is indicated; explicit maintainer acceptance is needed for the compatibility-sensitive shared preload change.
Agent review details

Security

None.

PR surface

Tests +77, Docs +6, Other +2. Total +85 across 5 files.

View PR surface stats
Area Files Added Removed Net
Source 0 0 0 0
Tests 3 79 2 +77
Docs 1 9 3 +6
Config 0 0 0 0
Generated 0 0 0 0
Other 1 3 1 +2
Total 5 91 6 +85

Review metrics

Metric Value Why it matters
Production versus test delta production executable net 0 (+2 comments); tests/support +79/-2; docs +9/-3 The runtime change is a one-for-one loader-entry substitution; most added surface is focused regression coverage.

Root-cause cluster

Relationship: fixed_by_candidate
Canonical: #134864
Summary: This PR is the candidate repair for the linked source-Gateway preload defect; the earlier merged artifact-loader repair is related but distinct.

Members:

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

Merge-risk options

Maintainer options:

  1. Accept the shared loader change (recommended)
    Land after maintainer review of the supplied exact-head proof and compatibility coverage for maintained source launchers.
  2. Pause for hydrated dependency review
    Wait for direct inspection of the pinned tsx ESM export before accepting the repository-wide preload selection.

Technical review

Best 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.

Labels

Label justifications:

  • P2: This repairs source-tooling plugin loading with limited operator blast radius and no demonstrated production outage.
  • merge-risk: 🚨 compatibility: The shared preload affects maintained source tooling entrypoints and can alter module-resolution behavior for existing developer workflows.
  • 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: This maintainer-authored PR is exempt from the external-contributor proof gate; its supplied discussion nevertheless records an isolated after-fix source-Gateway run through plugin registration and a mock image-generation request.

Evidence

What I checked:

  • Introduced loader selection: The introduced hunk resolves and imports tsx’s ESM entry, while retaining the existing cache policy and launcher boundary. (scripts/lib/tsx-cli-shim.mjs:46, 4e3926ac662d)
  • Current-main baseline remains affected: Fetched current main still resolves the full tsx entry rather than tsx/esm, so the central repair is not already present on main. (scripts/lib/tsx-cli-shim.mjs:44, 520f6f7d22af)
  • Boundary regression coverage: The new test exercises both a maintained wrapper and the direct preload against a compiled ESM fixture, checking import-only resolution, module identity, TypeScript transformation, and source aliases. (test/scripts/direct-run-entrypoints.test.ts:168, 4e3926ac662d)
  • Documented operator contract: The updated reference accurately limits the behavior to maintained launchers and explicitly says raw external tsx invocations remain unchanged. Public docs: docs/reference/test.md. (docs/reference/test.md:173, 4e3926ac662d)
  • Maintained tooling history: The same author previously landed the shared-cache tooling change that established this loader boundary; the exact source-line introduction could not be established from the partial local history. (scripts/lib/tsx-cli-shim.mjs:30, ce0fafefcedc)
  • Exact-head validation supplied in discussion: The supplied maintainer comment records successful exact-head CI and an isolated after-fix Gateway comparison; its earlier exact-head CI rank-up move is therefore addressed. (4e3926ac662d)

Likely related people:

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

Rank-up moves

Optional improvements that raise the rating; they are not merge blockers.

  • Obtain the protected maintainer landing decision for the shared preload boundary.

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.

History

Review history (2 earlier review cycles)
  • reviewed 2026-09-01T10:06:26.286Z sha 4e3926a :: needs maintainer review before merge. :: none
  • reviewed 2026-09-01T16:22:28.405Z sha 4e3926a :: needs maintainer review before merge. :: none

@steipete
steipete marked this pull request as ready for review September 1, 2026 16:14
@steipete

steipete commented Sep 1, 2026

Copy link
Copy Markdown
Contributor Author

Land-ready proof for 4e3926ac662d72a96950b9bde88fa9748a5eb1ff.

CI run 33530598869 completed successfully on this exact head; the repo watcher ended GREEN. Fresh isolated Codex review found no actionable findings at the requested P0 threshold. Native review artifacts have been validated. The current-main baseline still selects full tsx, so this repair is not superseded.

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 /v1/images/generations, and persists an image task with status=succeeded, error=null, and Generated 1 image. Native built CLI inspection reports eight OpenAI capabilities and no diagnostics. Both task Gateways shut down cleanly, their synthetic state was removed, and their ports are closed. No operator Gateway or live credentials were used.

Exact validation commands include:

pnpm build

Passed 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.md

Passed, 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.ts

The 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 4e3926ac662d72a96950b9bde88fa9748a5eb1ff

Ended GREEN.

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 not_applicable.

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.

@steipete
steipete merged commit 83e75f5 into main Sep 1, 2026
244 checks passed
@steipete
steipete deleted the steipete/session-continuation-1b730a branch September 1, 2026 16:51
@steipete

steipete commented Sep 1, 2026

Copy link
Copy Markdown
Contributor Author

Merged via squash.

steipete added a commit that referenced this pull request Sep 1, 2026
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.
steipete added a commit that referenced this pull request Sep 1, 2026
…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.
github-actions Bot pushed a commit to Desicool/openclaw that referenced this pull request Sep 2, 2026
…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.
github-actions Bot pushed a commit to Desicool/openclaw that referenced this pull request Sep 2, 2026
…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.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

docs Improvements or additions to documentation maintainer Maintainer-authored PR merge-risk: 🚨 compatibility 🚨 May break existing users, config, migrations, defaults, or upgrade paths. P2 Normal backlog priority with limited blast radius. rating: 🐚 platinum hermit Good normal PR readiness with ordinary maintainer review expected. scripts Repository scripts size: S 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.

[Bug]: Source Gateway preload breaks compiled plugin ESM dependencies

1 participant