fix: scope runtime plugin preload to effective plugins

This commit is contained in:
Peter Steinberger
2026-05-02 15:54:37 +01:00
parent 5980040894
commit da2a8bd6bb
9 changed files with 314 additions and 40 deletions

View File

@@ -42,6 +42,8 @@ const mocks = vi.hoisted(() => ({
>(),
resolveChannelPluginIds:
vi.fn<typeof import("../plugins/channel-plugin-ids.js").resolveChannelPluginIds>(),
resolveEffectivePluginIds:
vi.fn<typeof import("../plugins/effective-plugin-ids.js").resolveEffectivePluginIds>(),
resolvePluginRuntimeLoadContext:
vi.fn<typeof import("../plugins/runtime/load-context.js").resolvePluginRuntimeLoadContext>(),
}));
@@ -75,6 +77,11 @@ vi.mock("../plugins/channel-plugin-ids.js", () => ({
mocks.resolveChannelPluginIds(...args),
}));
vi.mock("../plugins/effective-plugin-ids.js", () => ({
resolveEffectivePluginIds: (...args: Parameters<typeof mocks.resolveEffectivePluginIds>) =>
mocks.resolveEffectivePluginIds(...args),
}));
vi.mock("../plugins/runtime/load-context.js", () => ({
resolvePluginRuntimeLoadContext: (
...args: Parameters<typeof mocks.resolvePluginRuntimeLoadContext>
@@ -134,6 +141,7 @@ describe("ensurePluginRegistryLoaded", () => {
mocks.resolveConfiguredChannelPluginIds.mockReset();
mocks.resolveDiscoverableScopedChannelPluginIds.mockReset();
mocks.resolveChannelPluginIds.mockReset();
mocks.resolveEffectivePluginIds.mockReset();
mocks.resolvePluginRuntimeLoadContext.mockReset();
resetPluginRegistryLoadedForTests();
@@ -141,6 +149,7 @@ describe("ensurePluginRegistryLoaded", () => {
mocks.resolveCompatibleRuntimePluginRegistry.mockReturnValue(undefined);
mocks.resolveRuntimePluginRegistry.mockReturnValue(undefined);
mocks.resolveDiscoverableScopedChannelPluginIds.mockReturnValue([]);
mocks.resolveEffectivePluginIds.mockReturnValue(["demo"]);
mocks.resolvePluginRuntimeLoadContext.mockImplementation((options) => {
const rawConfig = (options?.config ?? {}) as Record<string, unknown>;
return {
@@ -270,6 +279,7 @@ describe("ensurePluginRegistryLoaded", () => {
expect(mocks.loadOpenClawPlugins).toHaveBeenCalledWith(
expect.objectContaining({
config,
onlyPluginIds: ["demo"],
throwOnLoadError: true,
workspaceDir: "/tmp/workspace",
}),