Skip to content

fix(plugins): resolve embedded auth and require restart for bundled code changes - #182403

Merged
steipete merged 3 commits into
mainfrom
fix/static-auth-immutable-plugin-reload
Oct 24, 2026
Merged

steipete merged 3 commits into
mainfrom
fix/static-auth-immutable-plugin-reload

Conversation

@steipete

@steipete steipete commented Oct 24, 2026 •

Copy link
Copy Markdown
Contributor

What Problem This Solves

Provider authentication can fail when its runtime module is embedded without a physical JavaScript file. Explicit bundled-plugin reload also tries to recapture disk code even though the running host owns that code.

User Impact

Authentication resolves through the host-selected runtime module in ordinary Node/Bun and standalone builds. Bundled plugin reload refreshes registrations and reports restartRequired: true, including when files are unchanged. Restart the Gateway to load updated bundled code; rebuild first for compiled installations, and install a new executable when replacing embedded code. External on-disk plugins retain source reload and recovery in Node/Bun and dynamic standalone hosts. AOT hosts continue to admit embedded modules only, as defined by the runtime execution profiles.

Why This Change Was Made

Literal lazy imports replace the repeated filesystem search. Bundled runtime, setup, and public modules keep the host's code identity. Removing bundled-only recapture, cache eviction, and shared-module links avoids creating a second code identity; external captures and state-operation custody remain with their existing owners. Main's runtime-profile admission check remains at the loader boundary. No new configuration or dependency is introduced.

Evidence

  • Regression controls fail against the original auth and bundled-facade owners, then pass with this change. Existing authentication tests, including cancellation and OAuth, pass.
  • Real SDK source calls resolve both provider and model authentication under Node and the pinned Bun runtime. The real Bun facade loader retains bundled code after a disk edit and reloads external code.
  • Small probes compiled with bun compile on the experimental AOT compiler (5d8fe974f) run with their fixture sources hidden: the original physical auth gate fails, the literal import resolves, and deleting a compiled module's require-cache entry retains its original exports. A new worker initializes fresh module state. External disk reload observes 1 → 2 under Node, Bun, and AOT. These are reduced engine-behavior probes; OpenClaw's AOT profile separately restricts plugin admission to embedded modules. No whole-application AOT compilation or interpreter-tripwire claim.
Focused test commands and wall times

All Vitest commands use --maxWorkers=1 and the supported Node runner. Cold worker-artifact preparation dominates these wall times; they are not test-body or startup benchmarks.

Command Result Wall time
pnpm test src/plugin-sdk/provider-auth-runtime-resolution.test.ts --maxWorkers=1 against original owner Expected failure 784.333 s
Bundled case in facade-loader.test.ts against original owner Expected failure 113.532 s
pnpm test src/plugin-sdk/provider-auth-runtime-resolution.test.ts --maxWorkers=1 1 passed 942.787 s
pnpm test src/plugin-sdk/facade-loader.test.ts --maxWorkers=1 11 passed 67.085 s
pnpm test src/plugin-sdk/provider-auth-runtime.test.ts --maxWorkers=1 13 passed 442.534 s
pnpm check:test-mock-exports --base ae2a9dd8ec7445803a336a2eb83b3fa54000df6d Passed 132.362 s

The merged candidate passed targeted lint (124.563 s), core types (12.610 s), affected test-type graphs (154.379 s), formatting (0.712 s), and the existing runtime-profile/plugin-admission suites under Bun (8 tests, 71.858 s combined wall, --maxWorkers=1). Independent Codex review is clean through P2; ClawSweeper reports no remaining actionable finding.

The normal pnpm build at the prior head d43916948280 passed (2288.415 s), including runtime, 99 external plugin packages, declarations, and the Control UI. This head integrates main while preserving its runtime-profile admission check. The only conflict was the loader parameter rename.

Local proof gaps remain explicit: the Node Gateway integration attempt and Bun setup lifecycle attempt were interrupted before an assertion result (861.667 s and 1122.248 s including preparation/cleanup). The prior-head CI completed these consumer suites successfully. OpenAI entrypoint imports and cleanup passed, but the fixed-budget Git cleanliness probe timed out; memory values are unqualified and are not benchmark evidence. Full standalone-image qualification belongs to the standalone build lane.

Current-head CI run 40087299988 has the inherited session-catalog.test.ts case keeps a delayed source off the catalog RPC path: expected CATALOG_LOADING, actual pending: true. The same failure appears in scheduled main run 40074498223. All six relevant source/test blobs are identical across that main baseline, this PR head, and the actual CI merge 066a2aeb3ca549a0925d3ed55c797ce500414a4e and its main parent. The CI merge has the expected ordered parents and matches the reconstructed merge tree. The completed run has 56 successful jobs and 26 legitimate skips; the catalog job and its aggregate CI gate are the only failures. Security and all affected auth/reload consumer coverage passed. This is inherited-only CI evidence for the native landing exception; CI is not green, and no rerun was dispatched.

Resolve authentication runtime helpers through literal lazy imports so embedded code does not require physical JavaScript discovery. Refresh bundled registrations without recapturing code and report the existing Gateway restart requirement. Preserve external plugin source reload and recovery.
@clawsweeper

clawsweeper Bot commented Oct 24, 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.

@openclaw-barnacle openclaw-barnacle Bot added docs Improvements or additions to documentation gateway Gateway runtime size: L labels Oct 24, 2026
@steipete
steipete marked this pull request as ready for review October 24, 2026 08:19
@chatgpt-codex-connector

chatgpt-codex-connector Bot commented Oct 24, 2026 •

Copy link
Copy Markdown
Contributor

Codex Review Summary

This comment shows the latest Codex review activity on this pull request.

Review Status Commit Review trigger
📝 Code Review ✅ Completed 2026-10-24T10:49:42.282379Z 349cd65 New commits
ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review" or "@codex security review".

Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings.

@clawsweeper clawsweeper Bot added clawsweeper:intake:bug Preliminary submission classification; full source review pending. clawsweeper:intake:needs-environment Preliminary submission classification; full source review pending. clawsweeper:intake:needs-repro Preliminary submission classification; full source review pending. P2 Normal backlog priority with limited blast radius. merge-risk: 🚨 automation 🚨 May affect CI, automerge, proof capture, label sync, or maintainer automation. merge-risk: 🚨 compatibility 🚨 May break existing users, config, migrations, defaults, or upgrade paths. rating: 🦐 gold shrimp Decent PR readiness signal, but merge confidence is limited. status: ⏳ waiting on author ClawSweeper has contributor-facing work open and is waiting for author action. and removed clawsweeper:intake:bug Preliminary submission classification; full source review pending. clawsweeper:intake:needs-environment Preliminary submission classification; full source review pending. clawsweeper:intake:needs-repro Preliminary submission classification; full source review pending. labels Oct 24, 2026
@clawsweeper

clawsweeper Bot commented Oct 24, 2026 •

Copy link
Copy Markdown
Contributor

Codex review: needs maintainer review before merge.

What this changes

This PR replaces filesystem-based authentication module discovery with lazy imports and makes bundled-plugin reload retain host code while reporting a required restart.

Example: Change bundled-probe's helper.cjs from A to B and explicitly reload the plugin.

  • Before: Reload executes B and reports restartRequired: false.
  • After: Reload retains A, refreshes registrations, and reports restartRequired: true.

Review scores

Measure Result What it means
Overall readiness 🦐 gold shrimp (3/6) The implementation is focused and has no remaining actionable finding; available evidence supports harness-level confidence.
Proof confidence 🦐 gold shrimp (3/6) This maintainer-authored PR is outside the ordinary contributor-proof gate; supplied evidence covers SDK calls, facade loading, and reduced compiled-runtime probes, without establishing a shipped application flow.
Patch quality 🐚 platinum hermit (4/6) No actionable review findings were identified.

Product

Kind: Bug fix · Worth it: Yes · Fix scope: Complete
User problem: Embedded authentication can fail during runtime discovery, and bundled reload can create a second identity for code owned by the running host.
Reason: The maintainer-authored direction resolves the discovery failure and explicitly accepts restart-based bundled code replacement without adding configuration or a competing owner.

Merge readiness

✅ Ready for maintainer review

Keep open: this maintainer-authored PR provides a useful repair, resolves all four previous findings, and introduces no newly identified actionable defect.

Priority: P2
Reviewed head: d43916948280e0a8df601e45c4e1a5c40046b67a

Before merge

None.

Findings

None.

Tests

  • Missing end-to-end proof: The supplied evidence does not demonstrate this head through the packaged CLI-to-Gateway reload flow; the body explicitly marks local Gateway and setup lifecycle attempts incomplete.
Agent review details

How this fits together

The SDK authentication facade delegates credential lookup to the host runtime, while plugin loaders turn selected modules into instance-owned registrations and lifecycle receipts.

flowchart TD
  A[SDK authentication caller] --> B[Lazy host runtime import]
  B --> C[Existing credential owners]
  D[Plugin reload request] --> E[Plugin instance loader]
  E --> F[Shared bundled code]
  E --> G[Captured external code]
  F --> H[Registrations and restart receipt]
  G --> H
Loading

Technical review

Best possible solution:

Keep authentication imports host-selected and bundled code stable until restart while preserving external-plugin capture and recovery.

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

The original authentication resolver necessarily throws when embedded runtime code has no physical candidate; the PR records failing original-owner controls, but this review executed no target code.

Is this the best way to solve the issue?

The change uses existing authentication and plugin-instance owners, removes the replaced bundled recapture machinery, and preserves the distinct external-plugin path.

AGENTS.md: found and applied where relevant.

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

Provenance checked

  • SDK authentication runtime discovery changes intended behavior with a stated reason (9857d40: Filesystem runtime discovery was introduced to stabilize image-generation authentication loading.)
  • Bundled recapture, shared-module links, and recovery plumbing changes intended behavior with a stated reason (fix(plugins): reload edited bundled code without restarting the gateway #180466: Explicit reload was intended to load edited bundled code while retaining canonical host and SDK identity.)
  • Bundled setup cache eviction changes intended behavior with a stated reason (fix(plugins): reuse bundled setup code across reloads #149646: Ordinary inventories shared bundled setup code, while explicit cold CJS metadata resets refreshed entry and helper modules.)
  • Public-surface module disposal changes intended behavior with a stated reason (05a2844: Module disposal followed inventory ownership while admitted work retained its supplying instance.)

Testing

Proof path: in-process harness.

Security

None.

Evidence

What I checked:

Likely related people:

  • Peter Steinberger: Raw commit 5259702 adds src/plugins/plugin-instance-module-loader.ts:60 relative to its recorded parents. This identifies author metadata, not feature responsibility or a PR merger. (role: source-line author; confidence: high; commits: 525970204ad8; files: src/plugins/plugin-instance-module-loader.ts)
  • Patrick Erichsen: Raw commit 6878654 adds src/plugins/plugin-instance-module-loader.ts:28 relative to its recorded parents. This identifies author metadata, not feature responsibility or a PR merger. (role: source-line author; confidence: high; commits: 687865486444; files: src/plugins/plugin-instance-module-loader.ts)
  • Josh Lehman: Raw commit b8f12d9 adds src/plugin-sdk/provider-auth-runtime.ts:51 relative to its recorded parents. This identifies author metadata, not feature responsibility or a PR merger. (role: source-line author; confidence: high; commits: b8f12d99b254; files: src/plugin-sdk/provider-auth-runtime.ts)

PR surface

Source -258, Tests -348, Docs +2, Other -2. Total -606 across 30 files. Added test files: 1.

View PR surface stats
Area Files Added Removed Net
Source 17 28 286 -258
Tests 6 97 445 -348
Docs 5 27 25 +2
Config 0 0 0 0
Generated 0 0 0 0
Other 2 0 2 -2
Total 30 152 758 -606

Labels

Label changes:

  • add status: 👀 ready for maintainer look: ClawSweeper has no concrete contributor-facing blocker left for this PR.
  • remove merge-risk: 🚨 automation: Current PR review merge-risk labels are merge-risk: 🚨 compatibility.
  • remove status: ⏳ waiting on author: Current PR status label is status: 👀 ready for maintainer look.

Label justifications:

  • P2: This is a focused embedded-runtime authentication repair and an intentional plugin-reload behavior change.
  • merge-risk: 🚨 compatibility: Bundled reload stops replacing code and always reports a restart for loaded, enabled targets; the maintainer-authored PR explicitly accepts and documents this tradeoff.
  • rating: 🦐 gold shrimp: Overall readiness is 🦐 gold shrimp; proof is 🦐 gold shrimp and patch quality is 🐚 platinum hermit.
  • status: 👀 ready for maintainer look: ClawSweeper has no concrete contributor-facing blocker left for this PR.

Rating scale

6/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.

Workflow

ClawSweeper edits this one comment on every review. Comment @clawsweeper re-review for a fresh review only. Repair and merge execution lanes are retired.

History

Review history (1 earlier review cycle)
  • reviewed 2026-10-24T08:34:11.717Z sha 82288ea :: needs changes before merge. :: [P2] Remove the deleted module from the trusted wrapper inventory | [P2] Pass the updated service counters into each bundled probe | [P2] Update the source public-surface regression for retained bundled code | [P2] Remove the obsolete authentication assertion allowance

Reviewed October 24, 2026, 5:35 AM ET / 09:35 UTC (Revision 2).

@openclaw-barnacle openclaw-barnacle Bot added the scripts Repository scripts label Oct 24, 2026
@steipete

Copy link
Copy Markdown
Contributor Author

The four reported cutover findings are addressed in d439169: the deleted wrapper inventory entry and unused assertion allowance are removed, bundled probes receive their retained service counters, and the bundled public-surface expectation retains original code. The setup lifecycle expectations and conflicting reload docs are aligned as well. Codex review of the repair batch is clean through P2; targeted lint and format pass. The PR body distinguishes completed proof from the incomplete local lifecycle attempt, and fresh exact-head CI is running.

@clawsweeper re-review

@clawsweeper

clawsweeper Bot commented Oct 24, 2026 •

Copy link
Copy Markdown
Contributor

🦞👀
Exact review queued.

Re-review progress:

@clawsweeper clawsweeper Bot added clawsweeper:intake:bug Preliminary submission classification; full source review pending. clawsweeper:intake:needs-environment Preliminary submission classification; full source review pending. clawsweeper:intake:needs-repro Preliminary submission classification; full source review pending. status: 👀 ready for maintainer look ClawSweeper has no concrete contributor-facing blocker left for this PR. and removed merge-risk: 🚨 automation 🚨 May affect CI, automerge, proof capture, label sync, or maintainer automation. status: ⏳ waiting on author ClawSweeper has contributor-facing work open and is waiting for author action. clawsweeper:intake:bug Preliminary submission classification; full source review pending. labels Oct 24, 2026
@clawsweeper clawsweeper Bot removed clawsweeper:intake:needs-environment Preliminary submission classification; full source review pending. clawsweeper:intake:needs-repro Preliminary submission classification; full source review pending. labels Oct 24, 2026
@steipete
steipete merged commit ae81c07 into main Oct 24, 2026
159 of 163 checks passed
@steipete
steipete deleted the fix/static-auth-immutable-plugin-reload branch October 24, 2026 11:49
@steipete

Copy link
Copy Markdown
Contributor Author

Merged via explicitly authorized admin squash with attributed pre-existing CI failures.

steipete added a commit that referenced this pull request Oct 25, 2026
* test(gateway): expect restart for bundled reload after cleanup

Align the timeout-recovery retry with the explicit bundled reload contract introduced by ae81c07 (#182403). Keep all cleanup, availability, replacement and service-count assertions.

* test(gateway): explain bundled reload restart receipt

Match the independently prepared lifecycle correction in #182958 so this red-main repair adds no merge conflict.
github-actions Bot pushed a commit to Desicool/openclaw that referenced this pull request Oct 25, 2026
…ode changes (openclaw#182403)

* fix(plugins): keep bundled code host-owned during reload

Resolve authentication runtime helpers through literal lazy imports so embedded code does not require physical JavaScript discovery. Refresh bundled registrations without recapturing code and report the existing Gateway restart requirement. Preserve external plugin source reload and recovery.

* fix(plugins): complete immutable bundled reload cutover
github-actions Bot pushed a commit to Desicool/openclaw that referenced this pull request Oct 25, 2026
…law#183066)

* test(gateway): expect restart for bundled reload after cleanup

Align the timeout-recovery retry with the explicit bundled reload contract introduced by 4cc49e8 (openclaw#182403). Keep all cleanup, availability, replacement and service-count assertions.

* test(gateway): explain bundled reload restart receipt

Match the independently prepared lifecycle correction in openclaw#182958 so this red-main repair adds no merge conflict.
steipete added a commit that referenced this pull request Nov 5, 2026
…#184851)

* test(plugins): cover unused URL expressions in source references

Restore regression coverage for #182194: a discarded new URL(...) or its
discarded .href is not a plugin source asset, while the URL's arguments
are still traced. The original regression was deleted with the bundled
reload module in #182403, and #184340 removed this suite's visitor
assertion.

Before #182194, this pattern in a generated codec made the OpenAI plugin
reload capture the host build, which hung Linux Bun teardown of
server.config-patch.test.ts in restart.close.config-reloader.

* test(plugins): pass a lazy resolver to the source reference visitor

#188890 changed visitPluginSourceReferences to take getResolver. The old
call throws a TypeError on current main, and stale PR CI could not see it.
github-actions Bot pushed a commit to Desicool/openclaw that referenced this pull request Nov 6, 2026
…openclaw#184851)

* test(plugins): cover unused URL expressions in source references

Restore regression coverage for openclaw#182194: a discarded new URL(...) or its
discarded .href is not a plugin source asset, while the URL's arguments
are still traced. The original regression was deleted with the bundled
reload module in openclaw#182403, and openclaw#184340 removed this suite's visitor
assertion.

Before openclaw#182194, this pattern in a generated codec made the OpenAI plugin
reload capture the host build, which hung Linux Bun teardown of
server.config-patch.test.ts in restart.close.config-reloader.

* test(plugins): pass a lazy resolver to the source reference visitor

openclaw#188890 changed visitPluginSourceReferences to take getResolver. The old
call throws a TypeError on current main, and stale PR CI could not see it.
wangmiao0668000666 pushed a commit to wangmiao0668000666/openclaw that referenced this pull request Nov 6, 2026
…openclaw#184851)

* test(plugins): cover unused URL expressions in source references

Restore regression coverage for openclaw#182194: a discarded new URL(...) or its
discarded .href is not a plugin source asset, while the URL's arguments
are still traced. The original regression was deleted with the bundled
reload module in openclaw#182403, and openclaw#184340 removed this suite's visitor
assertion.

Before openclaw#182194, this pattern in a generated codec made the OpenAI plugin
reload capture the host build, which hung Linux Bun teardown of
server.config-patch.test.ts in restart.close.config-reloader.

* test(plugins): pass a lazy resolver to the source reference visitor

openclaw#188890 changed visitPluginSourceReferences to take getResolver. The old
call throws a TypeError on current main, and stale PR CI could not see it.
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 gateway Gateway runtime merge-risk: 🚨 compatibility 🚨 May break existing users, config, migrations, defaults, or upgrade paths. P2 Normal backlog priority with limited blast radius. rating: 🦐 gold shrimp Decent PR readiness signal, but merge confidence is limited. scripts Repository scripts size: L 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