From 24235f9f1187ab849345ebb2567033a3311106e4 Mon Sep 17 00:00:00 2001 From: pumpkinxing Date: Mon, 4 May 2026 20:18:07 +0800 Subject: [PATCH] fix(plugins): break catalog->ledger import cycle Importing `loadInstalledPluginIndexInstallRecordsSync` from `./installed-plugin-index-records.js` pulled in the store/config-state re-export chain, closing a runtime value cycle through `channels/bundled-channel-catalog-read.ts` -> `plugins/channel-catalog-registry.ts` -> `plugins/installed-plugin-index-records.ts` -> `plugins/installed-plugin-index-store.ts` -> `plugins/config-state.ts` -> `plugins/config-normalization-shared.ts` -> `channels/ids.ts` -> `channels/bundled-channel-catalog-read.ts`. That tripped `pnpm check:import-cycles` and produced module-init TDZ errors like `ReferenceError: Cannot access 'OFFICIAL_CHANNEL_CATALOG_RELATIVE_PATH' before initialization` across many CI shards. Switch the import to the lower-level `./installed-plugin-index-record-reader.js`, which only depends on filesystem helpers and path resolution, and update the unit-test mock target to match. Functional behaviour is unchanged; the same reader function is re-exported from the records module. Co-authored-by: Cursor --- src/plugins/channel-catalog-registry.test.ts | 4 ++-- src/plugins/channel-catalog-registry.ts | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/src/plugins/channel-catalog-registry.test.ts b/src/plugins/channel-catalog-registry.test.ts index d21d3e85d56..377e4c645bd 100644 --- a/src/plugins/channel-catalog-registry.test.ts +++ b/src/plugins/channel-catalog-registry.test.ts @@ -6,7 +6,7 @@ afterEach(() => { vi.restoreAllMocks(); vi.resetModules(); vi.doUnmock("./discovery.js"); - vi.doUnmock("./installed-plugin-index-records.js"); + vi.doUnmock("./installed-plugin-index-record-reader.js"); }); const ENV: NodeJS.ProcessEnv = { HOME: "/tmp/openclaw-test-home" }; @@ -41,7 +41,7 @@ async function loadWithMocks(params: { }); vi.doMock("./discovery.js", () => ({ discoverOpenClawPlugins: discoverSpy })); - vi.doMock("./installed-plugin-index-records.js", () => ({ + vi.doMock("./installed-plugin-index-record-reader.js", () => ({ loadInstalledPluginIndexInstallRecordsSync: loadRecordsSpy, })); diff --git a/src/plugins/channel-catalog-registry.ts b/src/plugins/channel-catalog-registry.ts index 8a596b80ca2..6fa47fe70a1 100644 --- a/src/plugins/channel-catalog-registry.ts +++ b/src/plugins/channel-catalog-registry.ts @@ -1,6 +1,6 @@ import type { PluginInstallRecord } from "../config/types.plugins.js"; import { discoverOpenClawPlugins } from "./discovery.js"; -import { loadInstalledPluginIndexInstallRecordsSync } from "./installed-plugin-index-records.js"; +import { loadInstalledPluginIndexInstallRecordsSync } from "./installed-plugin-index-record-reader.js"; import { loadPluginManifest, type PluginPackageChannel,