Repository navigation
fix(plugins): keep bundled plugins bundled when selected by plugins.load.paths - #133584
Conversation
|
🦞👀 Pull request received. I will update this pull request when review starts. |
|
Codex review: needs changes before merge. Reviewed August 30, 2026, 6:30 PM ET / 22:30 UTC. ClawSweeper reviewWhat this changesThe PR keeps a bundled plugin’s origin and entry point when its own path is selected through Merge readinessKeep 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 Review scores
Verification
How this fits togetherPlugin 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]
Before merge
Findings
Agent review detailsSecurityNeeds attention: The introduced origin classification broadens a plugin trust boundary beyond the bundled scanner’s admitted roots. PR surfaceSource +28, Tests +89, Docs +4. Total +121 across 5 files. View PR surface stats
Review metrics
Merge-risk optionsMaintainer options:
Copy recommended automerge instructionTechnical reviewBest 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 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:
Overall correctness: patch is incorrect AGENTS.md: found and applied where relevant. Codex review notes: model internal, reasoning high; reviewed against 7504a3b3c453. LabelsLabel changes:
Label justifications:
EvidenceSecurity concerns:
Acceptance criteria:
What 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
HistoryReview history (1 earlier review cycle)
|
…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.
34a0f2f to
e307781
Compare
|
Merged via squash.
|
…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)
…#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.
…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.
…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.
What Problem This Solves
Fixes an issue where operators who point
plugins.load.pathsat 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"toorigin: "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 doctorreport 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
originwas decided by how the operator referenced a plugin rather than where the plugin lives. Configured paths were labelledconfig, and config/global entry resolution prefersdist/index.jswhile bundled resolution does not — so one physical plugin produced two candidates with differentsourcevalues.discovery.finish()already states the invariant in its own comment ("a configured alias must not downgrade that same physical entry"), but it dedupes onsource. The guard therefore stopped applying the moment the two entry resolutions diverged. Both candidates then reached the manifest registry's same-rootDirbranch, which applies the opposite policy and ranksconfigabovebundled. Two dedupe owners with contradictory rules, and which one ran depended on whetherdist/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 asconfigSelected. 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.jsconfig candidate indiscovery.candidatesfor 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 existingdoes not grant bundled provenance to an outside package symlinktest.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 builddoes not leaveextensions/codex/dist/index.js—scripts/build-external-plugin-local-dist.mtsstages that output todist/extensions/codexand deletes the plugin-localdist. 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 invokingbuildPluginNpmRuntimeonextensions/codexdirectly:Regression coverage fails pre-fix in both states. The four existing checkout cases no longer branch on
existsSync; they assertindex.tsunconditionally, 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.ts12/12 withextensions/codex/dist/index.jspresent and after removing it.Full plugins lane: 392 files, 6234 passed, 1 skipped, 0 failed.
Checks:
check-changedexit 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'srechecks a rejected configured path under bundled policyasserted ablocked plugin candidate: world-writable pathdiagnostic. Post-fix that warning is gone: the host-owned path gets bundled policy on the first attempt, so thechmodrepair 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 to0755, accepted asbundled, 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 heresrc/plugins/tools.optional.test.tshad 4 failures on cleanorigin/main, unrelated to this change. Per repo policy I fixed it in the landing PR rather than landing onto red.d3e058ce78c(#133518) movedresolveCompatibleRuntimePluginRegistryout ofloader-runtime-registry.tsintoactive-runtime-registry.tsso active-registry reads stop eagerly importing the loader.tools.tscallsgetLoadedRuntimePluginRegistry, which now reaches that function intra-module, so the file'svi.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 boundarytools.tsactually crosses, delegating to the real implementation.Bisected: 87/87 pass at
d3e058ce78c^, 4 fail atd3e058ce78c.Follow-up (not in this PR): instrumenting the old mock proves the
./loader.jsseam now takes zero calls in that file, so everyresolveCompatibleRuntimePluginRegistryMocksetup is inert — including two tests that usedmockReturnValueto drive registry state and now pass only becausesetActivePluginRegistrysupplies it independently. Restoring that coverage needs a real test audit of what each case protects, which is wider than this PR should absorb.