Skip to content

fix(plugins): keep bundled plugins bundled when selected by plugins.load.paths - #133584

Merged
steipete merged 2 commits into
mainfrom
steipete/elastic-clarke-d81de0
Aug 30, 2026
Merged

steipete merged 2 commits into
mainfrom
steipete/elastic-clarke-d81de0

Conversation

@steipete

Copy link
Copy Markdown
Contributor

What Problem This Solves

Fixes an issue where operators who point plugins.load.paths at a plugin that already ships with OpenClaw would silently lose that plugin's host privileges — but only when compiled output happened to exist beside the source.

A bundled plugin selected this way was reclassified from origin: "bundled" to origin: "config". That origin is not just reporting; it gates real runtime behavior. A demoted plugin is refused host-owned agent event streams (src/plugins/agent-event-emission.ts:66), and drops out of bundled channel runtime, bundled capability runtime, and active-runtime-registry trust. The demotion happens in the built configuration, which is the one that ships.

The same inconsistency made openclaw doctor report a non-pristine startup state for a configured bundled path purely because the checkout was built, since its pristine check compares registry and candidate counts.

Why This Change Was Made

origin was decided by how the operator referenced a plugin rather than where the plugin lives. Configured paths were labelled config, and config/global entry resolution prefers dist/index.js while bundled resolution does not — so one physical plugin produced two candidates with different source values.

discovery.finish() already states the invariant in its own comment ("a configured alias must not downgrade that same physical entry"), but it dedupes on source. The guard therefore stopped applying the moment the two entry resolutions diverged. Both candidates then reached the manifest registry's same-rootDir branch, which applies the opposite policy and ranks config above bundled. Two dedupe owners with contradictory rules, and which one ran depended on whether dist/ happened to exist.

The fix classifies at the producer: a configured path whose resolved root lies inside the trees the bundled scan itself walks stays bundled, and the operator's selection is recorded separately as configSelected. One physical plugin now yields one candidate whose entry point and provenance match the bundled scan in either build state.

Fixing this in the registry instead would have left a bogus dist/index.js config candidate in discovery.candidates for every other consumer (doctor, status, snapshot) — compensating downstream for a producer failure.

Containment is realpath-based, so the security boundary is unchanged: a directory symlinked into the bundled root from outside still classifies as config, covered by the existing does not grant bundled provenance to an outside package symlink test.

Production delta is +28 lines in discovery.ts. That growth buys a named predicate for an ownership/security boundary; I could not get it lower without leaving the entry-point divergence in place.

User Impact

Operators can list a bundled plugin's own path in plugins.load.paths — to pin load order, or alongside other entries — without silently stripping that plugin's host privileges. Behavior no longer depends on whether compiled output exists next to the source, so a built checkout and a fresh one now behave identically.

Evidence

Reproduction. A plain pnpm build does not leave extensions/codex/dist/index.js — scripts/build-external-plugin-local-dist.mts stages that output to dist/extensions/codex and deletes the plugin-local dist. The state is reached through an interrupted build, a standalone plugin package build, or package validation, and it is what the published plugin package ships. Produced here by invoking buildPluginNpmRuntime on extensions/codex directly:

- Expected                + Received
-   "origin": "bundled",  +   "origin": "config",
    "rootDir": ".../extensions/codex",
    "source":  ".../extensions/codex/dist/index.js",

Regression coverage fails pre-fix in both states. The four existing checkout cases no longer branch on existsSync; they assert index.ts unconditionally, which is what the bundled scan resolves either way. A new hermetic suite parametrizes build state × alias shape over a temp bundled tree, so the guard no longer depends on what the checkout contains, and asserts the candidate-level invariant (one physical plugin, one candidate, configSelected: true) rather than only the registry outcome.

Pre-fix: the 2 original directory cases fail on origin; the 2 new built directory cases fail on candidate count. The file and unbuilt cases pass pre-fix, as they should — they were never broken.

Verified in both states: src/plugins/discovery-checkout.test.ts 12/12 with extensions/codex/dist/index.js present and after removing it.

Full plugins lane: 392 files, 6234 passed, 1 skipped, 0 failed.
Checks: check-changed exit 0 (oxfmt, tsgo, oxlint, import cycles, plugin-boundary, schema/store/pairing guards).
Autoreview: Codex, branch scope — scoped-clean, no P0 findings, confidence 0.97.

One judgment call worth a reviewer's eye

discovery.test.ts's rechecks a rejected configured path under bundled policy asserted a blocked plugin candidate: world-writable path diagnostic. Post-fix that warning is gone: the host-owned path gets bundled policy on the first attempt, so the chmod repair runs once and the candidate is accepted. The warning was always false — the plugin loaded anyway via the bundled phase, so operators saw "blocked" for something that did load. I retitled the test and asserted the new contract positively (repaired to 0755, accepted as bundled, deduped, no diagnostics) rather than deleting the check. If you read that warning as load-bearing, this is the line to push back on.

Second commit: unrelated red main, fixed here

src/plugins/tools.optional.test.ts had 4 failures on clean origin/main, unrelated to this change. Per repo policy I fixed it in the landing PR rather than landing onto red.

d3e058ce78c (#133518) moved resolveCompatibleRuntimePluginRegistry out of loader-runtime-registry.ts into active-runtime-registry.ts so active-registry reads stop eagerly importing the loader. tools.ts calls getLoadedRuntimePluginRegistry, which now reaches that function intra-module, so the file's vi.mock("./loader.js") seam stopped observing it. Behavior was never affected — the implementation moved verbatim, tool names still resolve, no cold load happens — only the observation point went stale. The fix counts the call at the boundary tools.ts actually crosses, delegating to the real implementation.

Bisected: 87/87 pass at d3e058ce78c^, 4 fail at d3e058ce78c.

Follow-up (not in this PR): instrumenting the old mock proves the ./loader.js seam now takes zero calls in that file, so every resolveCompatibleRuntimePluginRegistryMock setup is inert — including two tests that used mockReturnValue to drive registry state and now pass only because setActivePluginRegistry supplies it independently. Restoring that coverage needs a real test audit of what each case protects, which is wider than this PR should absorb.

@clawsweeper

clawsweeper Bot commented Aug 30, 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 size: S labels Aug 30, 2026
@steipete
steipete marked this pull request as ready for review August 30, 2026 22:08
@openclaw-barnacle openclaw-barnacle Bot added the maintainer Maintainer-authored PR label Aug 30, 2026
@clawsweeper clawsweeper Bot added merge-risk: 🚨 security-boundary 🚨 May affect sandboxing, authorization, credentials, or sensitive data. P1 High-priority user-facing bug, regression, or broken workflow. rating: 🦪 silver shellfish Thin PR readiness signal; proof, validation, or implementation needs work. status: ⏳ waiting on author ClawSweeper has contributor-facing work open and is waiting for author action. labels Aug 30, 2026
@clawsweeper

clawsweeper Bot commented Aug 30, 2026 •

Copy link
Copy Markdown
Contributor

Codex review: needs changes before merge. Reviewed August 30, 2026, 6:30 PM ET / 22:30 UTC.

ClawSweeper review

What this changes

The PR keeps a bundled plugin’s origin and entry point when its own path is selected through plugins.load.paths, with discovery, registry-reuse test, and documentation updates.

Merge readiness

⚠️ Ready for maintainer review - 5 items remain

Keep open: the prior P1 remains because the new bundled-origin predicate grants host trust to configured nested packages the bundled scanner deliberately excludes.

Priority: P1
Reviewed head: e30778111f9dd47b9f2918a4f97daf8f551c9fb4

Review scores

Measure Result What it means
Overall readiness 🦐 gold shrimp (3/6) The PR has a focused repair and useful coverage, but its current trust predicate leaves a high-confidence security-boundary blocker.
Proof confidence 🌊 off-meta tidepool Not applicable: This maintainer-authored PR is exempt from the external-contributor proof gate; the supplied test-run claims are supplemental, while the remaining security defect is deterministically established by the changed discovery and privilege paths.
Patch quality 🦐 gold shrimp (3/6) Security review found an item that needs attention.

Verification

Check Result Evidence
Real behavior Not applicable Not applicable: This maintainer-authored PR is exempt from the external-contributor proof gate; the supplied test-run claims are supplemental, while the remaining security defect is deterministically established by the changed discovery and privilege paths.
Evidence reviewed 5 items Introduced trust broadening: The introduced predicate treats every real-path descendant of either bundled tree as bundled, and the configured-path flow applies that origin before manifest discovery.
Bundled admission boundary: Automatic bundled scanning explicitly ignores dist and node_modules, so they are not canonical bundled plugin roots; a configured path bypasses that scan and enters direct package discovery.
Privilege consequence: A bundled origin permits host-owned agent event streams, while non-bundled origins are rejected before the event is emitted.
Findings 1 actionable finding [P1] Restrict bundled provenance to admitted plugin roots
Security Needs attention Configured nested packages gain bundled privileges: A valid package under an ignored nested directory can be labeled bundled solely from containment, bypassing non-bundled restrictions such as host event-stream rejection.

How this fits together

Plugin discovery turns bundled-tree and configured-path inputs into registry candidates. Candidate origin controls the manifest registry, startup activation, and which plugin runtime privileges are available.

flowchart LR
  A[Bundled plugin tree] --> C[Plugin discovery]
  B[Configured plugin path] --> C
  C --> D[Origin classification]
  D --> E[Candidate registry]
  E --> F[Startup activation]
  E --> G[Host plugin privileges]
Loading

Before merge

  • Restrict bundled provenance to admitted plugin roots (P1) - This accepts any descendant of a bundled tree, although bundled scanning deliberately ignores node_modules and dist. A configured nested package reaches direct manifest discovery with bundled origin and can use host-only privileges; restrict this to roots the bundled scan admits and add a nested ignored-path regression. This re-raises the prior P1 on unchanged code.
  • Resolve security concern: Configured nested packages gain bundled privileges - A valid package under an ignored nested directory can be labeled bundled solely from containment, bypassing non-bundled restrictions such as host event-stream rejection.
  • Resolve merge risk (P1) - A configured package under a bundled tree’s ignored node_modules or dist directory can receive bundled trust and its privileged runtime behavior if this predicate merges unchanged.
  • Resolve merge risk (P1) - bestSolution should replace the broad descendant check with canonical bundled-root admission while keeping the necessary owner-boundary repair compact; the current production delta is +28 net lines.
  • Complete next step (P2) - The remaining blocker is a narrow, source-proven trust-boundary repair with clear ownership and regression coverage.

Findings

  • [P1] Restrict bundled provenance to admitted plugin roots — src/plugins/discovery.ts:1161-1165
  • [high] Configured nested packages gain bundled privileges — src/plugins/discovery.ts:1161
Agent review details

Security

Needs attention: The introduced origin classification broadens a plugin trust boundary beyond the bundled scanner’s admitted roots.

PR surface

Source +28, Tests +89, Docs +4. Total +121 across 5 files.

View PR surface stats
Area Files Added Removed Net
Source 1 30 2 +28
Tests 3 102 13 +89
Docs 1 4 0 +4
Config 0 0 0 0
Generated 0 0 0 0
Other 0 0 0 0
Total 5 136 15 +121

Review metrics

Metric Value Why it matters
Production versus test delta production +30/-2; tests +102/-13; docs +4 The net production growth is an ownership-boundary predicate, but it currently over-broadens that boundary and must be narrowed before it is justified.

Merge-risk options

Maintainer options:

  1. Narrow bundled provenance (recommended)
    Restrict promotion to canonical roots admitted by bundled discovery and add a nested ignored-package regression before merge.
  2. Pause the trust change
    Leave configured paths as non-bundled until the exact admission boundary has a safe implementation and regression proof.
Copy recommended automerge instruction
@clawsweeper automerge

Special instructions:
Restrict provenance to bundled-scan-admitted plugin roots and add a configured nested ignored-path regression.

Technical review

Best possible solution:

Classify configured aliases as bundled only when they resolve to the same canonical plugin root admitted by the bundled scan, and cover ignored nested directories without regressing direct or symlink aliases.

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

Yes, from source: configure a valid plugin below a bundled tree’s ignored node_modules or dist directory and discovery assigns it bundled origin before direct manifest admission. A reviewer-side execution was not needed to establish this deterministic path.

Is this the best way to solve the issue?

No. The producer-level repair is the right boundary, but containment in the whole tree is broader than bundled admission; canonical plugin-root matching is the safer fix.

Full review comments:

  • [P1] Restrict bundled provenance to admitted plugin roots — src/plugins/discovery.ts:1161-1165
    This accepts any descendant of a bundled tree, although bundled scanning deliberately ignores node_modules and dist. A configured nested package reaches direct manifest discovery with bundled origin and can use host-only privileges; restrict this to roots the bundled scan admits and add a nested ignored-path regression. This re-raises the prior P1 on unchanged code.
    Confidence: 0.98

Overall correctness: patch is incorrect
Overall confidence: 0.98

AGENTS.md: found and applied where relevant.

Codex review notes: model internal, reasoning high; reviewed against 7504a3b3c453.

Labels

Label changes:

  • add rating: 🦐 gold shrimp: Overall readiness is 🦐 gold shrimp; proof is 🌊 off-meta tidepool and patch quality is 🦐 gold shrimp.
  • remove rating: 🦪 silver shellfish: Current PR rating is rating: 🦐 gold shrimp, so this older rating label is no longer current.

Label justifications:

  • P1: The introduced path can grant host-only plugin privileges to packages the bundled scanner intentionally excludes.
  • merge-risk: 🚨 security-boundary: Merging the broad descendant predicate would let configured nested packages receive bundled trust and bypass non-bundled privilege restrictions.
  • rating: 🦐 gold shrimp: Overall readiness is 🦐 gold shrimp; proof is 🌊 off-meta tidepool and patch quality is 🦐 gold shrimp.
  • status: ⏳ waiting on author: ClawSweeper has contributor-facing work open and is waiting for author action. Not applicable: This maintainer-authored PR is exempt from the external-contributor proof gate; the supplied test-run claims are supplemental, while the remaining security defect is deterministically established by the changed discovery and privilege paths.

Evidence

Security concerns:

  • [high] Configured nested packages gain bundled privileges — src/plugins/discovery.ts:1161
    A valid package under an ignored nested directory can be labeled bundled solely from containment, bypassing non-bundled restrictions such as host event-stream rejection.
    Confidence: 0.98

Acceptance criteria:

  • [P1] node scripts/run-vitest.mjs src/plugins/discovery-checkout.test.ts src/plugins/discovery.test.ts.
  • [P1] node scripts/check-changed.mjs -- src/plugins/discovery.ts src/plugins/discovery-checkout.test.ts src/plugins/discovery.test.ts docs/plugins/sdk-entrypoints.md.

What I checked:

  • Introduced trust broadening: The introduced predicate treats every real-path descendant of either bundled tree as bundled, and the configured-path flow applies that origin before manifest discovery. (src/plugins/discovery.ts:1161, 0f091eaa2843)
  • Bundled admission boundary: Automatic bundled scanning explicitly ignores dist and node_modules, so they are not canonical bundled plugin roots; a configured path bypasses that scan and enters direct package discovery. (src/plugins/discovery.ts:65, c04bee452e70)
  • Privilege consequence: A bundled origin permits host-owned agent event streams, while non-bundled origins are rejected before the event is emitted. (src/plugins/agent-event-emission.ts:66, c04bee452e70)
  • Coverage gap: The new parameterized suite covers direct top-level bundled plugin aliases only; it has no configured nested ignored-path case to preserve the security boundary. (src/plugins/discovery-checkout.test.ts:153, e30778111f9d)
  • Unrelated test repair: The active-registry mock delegates to the real registry reader that tools.ts imports, which is a coherent repair for the stale loader-mock observations following merged PR 133518. (src/plugins/tools.optional.test.ts:44, e30778111f9d)

Likely related people:

  • Vincent Koc: Suggested for follow-up; no historical authorship or introduction is verified. (role: unverified routing candidate; confidence: low)
  • 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.

  • Restrict the predicate to canonical bundled plugin roots and demonstrate that configured nested ignored paths remain non-bundled.

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 (1 earlier review cycle)
  • reviewed 2026-08-30T22:16:19.122Z sha 34a0f2fd29eddb915f2a0f8ccd694de6a2f8f20c :: found issues before merge. :: [P1] Restrict bundled provenance to admitted plugin roots

…oad.paths

Pointing `plugins.load.paths` at a plugin that already lives in the host's own
bundled tree demoted it from `origin: "bundled"` to `origin: "config"` whenever
compiled output existed beside the source. That silently revoked the host-owned
runtime privileges bundled plugins get: host agent event streams, bundled
channel and capability runtime registration, and active-runtime registry trust.

Origin was decided by how the operator referenced a plugin rather than where it
physically lives. Configured paths were labelled `config`, and config/global
entry resolution prefers `dist/index.js` while bundled resolution does not, so
one physical plugin produced two candidates with different `source` values.
`discovery.finish()` intends "a configured alias must not downgrade that same
physical entry" but dedupes on `source`, so the guard stopped applying the
moment the two entry resolutions diverged. Both candidates then reached the
manifest registry's same-`rootDir` branch, which applies the opposite policy and
ranks `config` above `bundled`.

Classify at the producer instead: a configured path whose resolved root lies
inside the trees the bundled scan itself walks stays `bundled`, and the
operator's selection is recorded separately as `configSelected`. Containment is
realpath-based, so a directory symlinked into the bundled root from outside
still stays `config`.

Incidentally repairs `openclaw doctor`, whose pristine-startup check compares
registry and candidate counts and read a configured bundled path as
non-pristine purely because the checkout was built.
… crosses

Four `resolvePluginTools` tests failed on `main`: the compatible-registry mock
was never called. #133518 moved `resolveCompatibleRuntimePluginRegistry` out of
`loader-runtime-registry.ts` into `active-runtime-registry.ts` so active-registry
reads stop pulling in the loader eagerly. `tools.ts` calls
`getLoadedRuntimePluginRegistry`, which now reaches that function intra-module,
so the file's `vi.mock("./loader.js")` seam stopped observing it.

Behavior was never affected: the tool names resolve and no cold load happens,
because the real implementation moved verbatim. Only the observation point was
stale, so count the call at the boundary `tools.ts` actually crosses and keep
delegating to the real implementation.

Verified against d3e058c^ (87/87 pass) and d3e058c (4 fail), and the
probe that proves the old `./loader.js` seam now takes zero calls in this file.
@steipete
steipete force-pushed the steipete/elastic-clarke-d81de0 branch from 34a0f2f to e307781 Compare August 30, 2026 22:24
@clawsweeper clawsweeper Bot added rating: 🦐 gold shrimp Decent PR readiness signal, but merge confidence is limited. and removed rating: 🦪 silver shellfish Thin PR readiness signal; proof, validation, or implementation needs work. labels Aug 30, 2026
@steipete
steipete merged commit 47f2529 into main Aug 30, 2026
239 checks passed
@steipete
steipete deleted the steipete/elastic-clarke-d81de0 branch August 30, 2026 22:41
@steipete

Copy link
Copy Markdown
Contributor Author

Merged via squash.

vincentkoc added a commit to shojikumaru/openclaw that referenced this pull request Aug 30, 2026
…cked-delivery

* origin/main:
  fix(ui): wait for restored draft before clearing (openclaw#133575)
  fix(deps): update fast-uri security patches (openclaw#133572)
  test: reduce workflow sanity fixture cleanup time (openclaw#133588)
  fix(media): normalize detected Matroska MIME (openclaw#133383)
  refactor(docker): retire ClawDock shell helpers (openclaw#133594)
  perf(browser): reuse snapshot refs and screenshot metadata (openclaw#133598)
  perf: load web chat history in larger, faster batches (openclaw#133565)
  fix(plugins): keep bundled plugins bundled when selected by plugins.load.paths (openclaw#133584)
  test: isolate shared /tmp session-store paths in runner and health suites (openclaw#133568)
  fix(cron): avoid no-op schedule repair writes (openclaw#133552)
steipete added a commit that referenced this pull request Aug 31, 2026
…#133656)

#133584 repointed the four failing call-count assertions at
`getLoadedRuntimePluginRegistry`, but left the rest of the `./loader.js`
scaffolding in place. Every remaining `resolveCompatibleRuntimePluginRegistryMock`
setup in this file was inert: #133518 moved `resolveCompatibleRuntimePluginRegistry`
into `active-runtime-registry.ts`, where `getLoadedRuntimePluginRegistry` reaches it
intra-module, so the `vi.mock("./loader.js")` seam observes nothing. A
`mockImplementation` probe on that mock takes zero calls in this file.

Six `mockReturnValue` sites therefore claimed to steer the reuse-vs-rebuild
decision while steering nothing. They passed only because each test also called
`setActivePluginRegistry`, so the real resolver quietly did the work: the tests
were green for a reason none of them asserted.

Delete the dead scaffolding and drive the same states through the boundary
`tools.ts` actually crosses. The counting mock becomes the delegate rather than a
side-channel counter, so the resolver's return value is observable: the partial-
and stale-root tests now assert that the active registry really was consulted and
still rebuilt, and the disabled-owner test pins `requiredPluginIds` to the owner
that may enter the runtime scope. `./loader.js` keeps every binding its consumers
import, but the registry-resolution ones now delegate to their real owners
instead of to a double no production path reaches.

Behavior is unchanged; production is untouched. Each revised test was verified to
fail when the invariant it names is broken: skipping the active-registry consult
in `resolvePluginToolRegistry` (22 red), scoping on plugin records instead of tool
entries (the 4 tests whose overrides were removed), dropping the disabled-entry
guards in `resolvePluginToolRuntimePluginIds` and `manifest-owner-policy.ts`, and
re-consulting the seam on either the reuse or the cold-load branch.
github-actions Bot pushed a commit to Desicool/openclaw that referenced this pull request Aug 31, 2026
…oad.paths (openclaw#133584)

* fix(plugins): keep bundled plugins bundled when selected by plugins.load.paths

Pointing `plugins.load.paths` at a plugin that already lives in the host's own
bundled tree demoted it from `origin: "bundled"` to `origin: "config"` whenever
compiled output existed beside the source. That silently revoked the host-owned
runtime privileges bundled plugins get: host agent event streams, bundled
channel and capability runtime registration, and active-runtime registry trust.

Origin was decided by how the operator referenced a plugin rather than where it
physically lives. Configured paths were labelled `config`, and config/global
entry resolution prefers `dist/index.js` while bundled resolution does not, so
one physical plugin produced two candidates with different `source` values.
`discovery.finish()` intends "a configured alias must not downgrade that same
physical entry" but dedupes on `source`, so the guard stopped applying the
moment the two entry resolutions diverged. Both candidates then reached the
manifest registry's same-`rootDir` branch, which applies the opposite policy and
ranks `config` above `bundled`.

Classify at the producer instead: a configured path whose resolved root lies
inside the trees the bundled scan itself walks stays `bundled`, and the
operator's selection is recorded separately as `configSelected`. Containment is
realpath-based, so a directory symlinked into the bundled root from outside
still stays `config`.

Incidentally repairs `openclaw doctor`, whose pristine-startup check compares
registry and candidate counts and read a configured bundled path as
non-pristine purely because the checkout was built.

* test(plugins): observe active registry reuse at the boundary tools.ts crosses

Four `resolvePluginTools` tests failed on `main`: the compatible-registry mock
was never called. openclaw#133518 moved `resolveCompatibleRuntimePluginRegistry` out of
`loader-runtime-registry.ts` into `active-runtime-registry.ts` so active-registry
reads stop pulling in the loader eagerly. `tools.ts` calls
`getLoadedRuntimePluginRegistry`, which now reaches that function intra-module,
so the file's `vi.mock("./loader.js")` seam stopped observing it.

Behavior was never affected: the tool names resolve and no cold load happens,
because the real implementation moved verbatim. Only the observation point was
stale, so count the call at the boundary `tools.ts` actually crosses and keep
delegating to the real implementation.

Verified against 735a37c^ (87/87 pass) and 735a37c (4 fail), and the
probe that proves the old `./loader.js` seam now takes zero calls in this file.
github-actions Bot pushed a commit to Desicool/openclaw that referenced this pull request Aug 31, 2026
…openclaw#133656)

openclaw#133584 repointed the four failing call-count assertions at
`getLoadedRuntimePluginRegistry`, but left the rest of the `./loader.js`
scaffolding in place. Every remaining `resolveCompatibleRuntimePluginRegistryMock`
setup in this file was inert: openclaw#133518 moved `resolveCompatibleRuntimePluginRegistry`
into `active-runtime-registry.ts`, where `getLoadedRuntimePluginRegistry` reaches it
intra-module, so the `vi.mock("./loader.js")` seam observes nothing. A
`mockImplementation` probe on that mock takes zero calls in this file.

Six `mockReturnValue` sites therefore claimed to steer the reuse-vs-rebuild
decision while steering nothing. They passed only because each test also called
`setActivePluginRegistry`, so the real resolver quietly did the work: the tests
were green for a reason none of them asserted.

Delete the dead scaffolding and drive the same states through the boundary
`tools.ts` actually crosses. The counting mock becomes the delegate rather than a
side-channel counter, so the resolver's return value is observable: the partial-
and stale-root tests now assert that the active registry really was consulted and
still rebuilt, and the disabled-owner test pins `requiredPluginIds` to the owner
that may enter the runtime scope. `./loader.js` keeps every binding its consumers
import, but the registry-resolution ones now delegate to their real owners
instead of to a double no production path reaches.

Behavior is unchanged; production is untouched. Each revised test was verified to
fail when the invariant it names is broken: skipping the active-registry consult
in `resolvePluginToolRegistry` (22 red), scoping on plugin records instead of tool
entries (the 4 tests whose overrides were removed), dropping the disabled-entry
guards in `resolvePluginToolRuntimePluginIds` and `manifest-owner-policy.ts`, and
re-consulting the seam on either the reuse or the cold-load branch.
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: 🚨 security-boundary 🚨 May affect sandboxing, authorization, credentials, or sensitive data. P1 High-priority user-facing bug, regression, or broken workflow. rating: 🦐 gold shrimp Decent PR readiness signal, but merge confidence is limited. size: S status: ⏳ waiting on author ClawSweeper has contributor-facing work open and is waiting for author action.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant