mirror of
https://github.com/openclaw/openclaw.git
synced 2026-08-27 12:56:01 -06:00
refactor: eliminate export name collisions (#122084)
* refactor: eliminate export name collisions * chore(scripts): burn resolved collision baselines * refactor: narrow legacy session load options * chore: refresh SDK and session debt baselines * refactor: adopt upstream secrets collision fix * test(plugin-sdk): mock renamed session store core * fix(scripts): track renamed session accessor core
This commit is contained in:
committed by
GitHub
parent
653ab3b2aa
commit
ebb2770000
@@ -9,12 +9,12 @@ import { CLAWHUB_INSTALL_ERROR_CODE } from "../plugins/clawhub-error-codes.js";
|
||||
import { VERSION } from "../version.js";
|
||||
import {
|
||||
createTestInstalledPluginIndex,
|
||||
loadConfig,
|
||||
pluginCliConfigMock,
|
||||
notifyGatewayPluginMetadataChangedMock,
|
||||
readConfigFileSnapshotForWrite,
|
||||
readPersistedInstalledPluginIndex,
|
||||
refreshPluginRegistry,
|
||||
replaceConfigFile,
|
||||
readConfigFileSnapshotForWriteMock,
|
||||
readPersistedInstalledPluginIndexMock,
|
||||
refreshPluginRegistryMock,
|
||||
replaceConfigFileMock,
|
||||
resetPluginsCliTestState,
|
||||
restorePersistedInstalledPluginIndexIfCurrent,
|
||||
runPluginsCommand,
|
||||
@@ -144,8 +144,8 @@ function primeUpdateConfigSnapshot(params: {
|
||||
includeFileTargetsForWrite: params.includeFileTargetsForWrite,
|
||||
},
|
||||
};
|
||||
loadConfig.mockReturnValue(params.loadedConfig ?? params.config);
|
||||
readConfigFileSnapshotForWrite.mockResolvedValue(prepared);
|
||||
pluginCliConfigMock.mockReturnValue(params.loadedConfig ?? params.config);
|
||||
readConfigFileSnapshotForWriteMock.mockResolvedValue(prepared);
|
||||
return prepared;
|
||||
}
|
||||
|
||||
@@ -222,7 +222,7 @@ async function expectSkippedClawHubPluginUpdate(params: {
|
||||
},
|
||||
},
|
||||
} as OpenClawConfig;
|
||||
loadConfig.mockReturnValue(config);
|
||||
pluginCliConfigMock.mockReturnValue(config);
|
||||
setInstalledPluginIndexInstallRecords(config.plugins?.installs ?? {});
|
||||
primePluginUpdate(config, [
|
||||
{
|
||||
@@ -294,7 +294,7 @@ describe("plugins cli update", () => {
|
||||
pluginId: "alpha",
|
||||
spec: "@acme/alpha@1.0.0",
|
||||
});
|
||||
loadConfig.mockReturnValue(config);
|
||||
pluginCliConfigMock.mockReturnValue(config);
|
||||
setInstalledPluginIndexInstallRecords(config.plugins?.installs ?? {});
|
||||
primePluginUpdate(config, [
|
||||
{
|
||||
@@ -314,9 +314,9 @@ describe("plugins cli update", () => {
|
||||
);
|
||||
expect(acquireLease).not.toHaveBeenCalled();
|
||||
expect(writeConfigFile).not.toHaveBeenCalled();
|
||||
expect(replaceConfigFile).not.toHaveBeenCalled();
|
||||
expect(replaceConfigFileMock).not.toHaveBeenCalled();
|
||||
expect(writePersistedInstalledPluginIndexInstallRecordsWithLease).not.toHaveBeenCalled();
|
||||
expect(refreshPluginRegistry).not.toHaveBeenCalled();
|
||||
expect(refreshPluginRegistryMock).not.toHaveBeenCalled();
|
||||
expect(pluginsCliRuntimeLogs).toContain("Would update alpha: 1.0.0 -> 1.1.0.");
|
||||
} finally {
|
||||
acquireLease.mockRestore();
|
||||
@@ -412,10 +412,10 @@ describe("plugins cli update", () => {
|
||||
expect(hookUpdateParams.hookIds).toEqual(["demo-hooks"]);
|
||||
expect(updateNpmInstalledPlugins).not.toHaveBeenCalled();
|
||||
expect(writeConfigFile).toHaveBeenCalledWith(nextConfig);
|
||||
expect(replaceConfigFile).toHaveBeenCalledWith(
|
||||
expect(replaceConfigFileMock).toHaveBeenCalledWith(
|
||||
expect.objectContaining({ nextConfig, baseHash: "update-config" }),
|
||||
);
|
||||
expect(refreshPluginRegistry).not.toHaveBeenCalled();
|
||||
expect(refreshPluginRegistryMock).not.toHaveBeenCalled();
|
||||
expectRestartNoticeLogged();
|
||||
});
|
||||
|
||||
@@ -675,8 +675,8 @@ describe("plugins cli update", () => {
|
||||
expect(runtimeErrors).toEqual([]);
|
||||
expectInstallRecordsWrittenWithLease(nextRecords, sourceCfg);
|
||||
expect(writeConfigFile).not.toHaveBeenCalled();
|
||||
expect(replaceConfigFile).not.toHaveBeenCalled();
|
||||
expect(refreshPluginRegistry).toHaveBeenCalledWith({
|
||||
expect(replaceConfigFileMock).not.toHaveBeenCalled();
|
||||
expect(refreshPluginRegistryMock).toHaveBeenCalledWith({
|
||||
config: sourceCfg,
|
||||
installRecords: nextRecords,
|
||||
reason: "source-changed",
|
||||
@@ -729,7 +729,7 @@ describe("plugins cli update", () => {
|
||||
load: { paths: [nextInstallPath, customPath] },
|
||||
},
|
||||
});
|
||||
expect(replaceConfigFile).toHaveBeenCalledWith({
|
||||
expect(replaceConfigFileMock).toHaveBeenCalledWith({
|
||||
nextConfig: {
|
||||
plugins: {
|
||||
load: { paths: [nextInstallPath, customPath] },
|
||||
@@ -740,7 +740,7 @@ describe("plugins cli update", () => {
|
||||
afterWrite: { mode: "restart", reason: "plugin source changed" },
|
||||
}),
|
||||
});
|
||||
expect(refreshPluginRegistry).toHaveBeenCalledWith({
|
||||
expect(refreshPluginRegistryMock).toHaveBeenCalledWith({
|
||||
config: {
|
||||
plugins: {
|
||||
load: { paths: [nextInstallPath, customPath] },
|
||||
@@ -785,7 +785,7 @@ describe("plugins cli update", () => {
|
||||
hash: "changed-config",
|
||||
},
|
||||
};
|
||||
readConfigFileSnapshotForWrite
|
||||
readConfigFileSnapshotForWriteMock
|
||||
.mockResolvedValueOnce(initialSnapshot)
|
||||
.mockResolvedValueOnce(changedSnapshot);
|
||||
const { previousRecords, nextRecords } = primeBravePluginRecordUpdate(cfg);
|
||||
@@ -793,7 +793,7 @@ describe("plugins cli update", () => {
|
||||
policyHash: "previous-policy",
|
||||
installRecords: previousRecords,
|
||||
});
|
||||
readPersistedInstalledPluginIndex.mockResolvedValue(previousPersistedIndex);
|
||||
readPersistedInstalledPluginIndexMock.mockResolvedValue(previousPersistedIndex);
|
||||
|
||||
await expect(runPluginsCommand(["plugins", "update", "brave"])).rejects.toThrow(
|
||||
"config changed since last load",
|
||||
@@ -809,8 +809,8 @@ describe("plugins cli update", () => {
|
||||
}),
|
||||
);
|
||||
expect(writeConfigFile).not.toHaveBeenCalled();
|
||||
expect(replaceConfigFile).not.toHaveBeenCalled();
|
||||
expect(refreshPluginRegistry).not.toHaveBeenCalled();
|
||||
expect(replaceConfigFileMock).not.toHaveBeenCalled();
|
||||
expect(refreshPluginRegistryMock).not.toHaveBeenCalled();
|
||||
expect(notifyGatewayPluginMetadataChangedMock).not.toHaveBeenCalled();
|
||||
});
|
||||
|
||||
@@ -847,7 +847,7 @@ describe("plugins cli update", () => {
|
||||
},
|
||||
},
|
||||
};
|
||||
readConfigFileSnapshotForWrite
|
||||
readConfigFileSnapshotForWriteMock
|
||||
.mockResolvedValueOnce(initialSnapshot)
|
||||
.mockResolvedValueOnce(changedSnapshot);
|
||||
const { previousRecords, nextRecords } = primeBravePluginRecordUpdate(cfg);
|
||||
@@ -855,7 +855,7 @@ describe("plugins cli update", () => {
|
||||
policyHash: "previous-policy",
|
||||
installRecords: previousRecords,
|
||||
});
|
||||
readPersistedInstalledPluginIndex.mockResolvedValue(previousPersistedIndex);
|
||||
readPersistedInstalledPluginIndexMock.mockResolvedValue(previousPersistedIndex);
|
||||
|
||||
await expect(runPluginsCommand(["plugins", "update", "brave"])).rejects.toThrow(
|
||||
"included config changed since last load",
|
||||
@@ -871,8 +871,8 @@ describe("plugins cli update", () => {
|
||||
}),
|
||||
);
|
||||
expect(writeConfigFile).not.toHaveBeenCalled();
|
||||
expect(replaceConfigFile).not.toHaveBeenCalled();
|
||||
expect(refreshPluginRegistry).not.toHaveBeenCalled();
|
||||
expect(replaceConfigFileMock).not.toHaveBeenCalled();
|
||||
expect(refreshPluginRegistryMock).not.toHaveBeenCalled();
|
||||
});
|
||||
|
||||
it("rolls back persisted install records when records-only update invalidates config", async () => {
|
||||
@@ -902,7 +902,7 @@ describe("plugins cli update", () => {
|
||||
],
|
||||
},
|
||||
};
|
||||
readConfigFileSnapshotForWrite
|
||||
readConfigFileSnapshotForWriteMock
|
||||
.mockResolvedValueOnce(initialSnapshot)
|
||||
.mockResolvedValueOnce(invalidSnapshot);
|
||||
const { previousRecords, nextRecords } = primeBravePluginRecordUpdate(cfg);
|
||||
@@ -910,7 +910,7 @@ describe("plugins cli update", () => {
|
||||
policyHash: "previous-policy",
|
||||
installRecords: previousRecords,
|
||||
});
|
||||
readPersistedInstalledPluginIndex.mockResolvedValue(previousPersistedIndex);
|
||||
readPersistedInstalledPluginIndexMock.mockResolvedValue(previousPersistedIndex);
|
||||
|
||||
await expect(runPluginsCommand(["plugins", "update", "brave"])).rejects.toThrow(
|
||||
"invalid config for plugin brave",
|
||||
@@ -926,8 +926,8 @@ describe("plugins cli update", () => {
|
||||
}),
|
||||
);
|
||||
expect(writeConfigFile).not.toHaveBeenCalled();
|
||||
expect(replaceConfigFile).not.toHaveBeenCalled();
|
||||
expect(refreshPluginRegistry).not.toHaveBeenCalled();
|
||||
expect(replaceConfigFileMock).not.toHaveBeenCalled();
|
||||
expect(refreshPluginRegistryMock).not.toHaveBeenCalled();
|
||||
});
|
||||
|
||||
it("blocks legacy plugin id migration before updater side effects", async () => {
|
||||
@@ -1193,7 +1193,7 @@ describe("plugins cli update", () => {
|
||||
});
|
||||
|
||||
it("exits when update is called without id and without --all", async () => {
|
||||
loadConfig.mockReturnValue({
|
||||
pluginCliConfigMock.mockReturnValue({
|
||||
plugins: {
|
||||
installs: {},
|
||||
},
|
||||
@@ -1206,7 +1206,7 @@ describe("plugins cli update", () => {
|
||||
});
|
||||
|
||||
it("reports no tracked plugins or hook packs when update --all has empty install records", async () => {
|
||||
loadConfig.mockReturnValue({
|
||||
pluginCliConfigMock.mockReturnValue({
|
||||
plugins: {
|
||||
installs: {},
|
||||
},
|
||||
@@ -1224,7 +1224,7 @@ describe("plugins cli update", () => {
|
||||
pluginId: "openclaw-codex-app-server",
|
||||
spec: "openclaw-codex-app-server@beta",
|
||||
});
|
||||
loadConfig.mockReturnValue(config);
|
||||
pluginCliConfigMock.mockReturnValue(config);
|
||||
setInstalledPluginIndexInstallRecords(config.plugins?.installs ?? {});
|
||||
primePluginUpdate(config);
|
||||
|
||||
@@ -1268,7 +1268,7 @@ describe("plugins cli update", () => {
|
||||
resolvedName: "@openclaw/codex",
|
||||
});
|
||||
config.update = { channel: updateChannel };
|
||||
loadConfig.mockReturnValue(config);
|
||||
pluginCliConfigMock.mockReturnValue(config);
|
||||
setInstalledPluginIndexInstallRecords(config.plugins?.installs ?? {});
|
||||
primePluginUpdate(config);
|
||||
|
||||
@@ -1290,7 +1290,7 @@ describe("plugins cli update", () => {
|
||||
spec: "@openclaw/codex",
|
||||
resolvedName: "@openclaw/codex",
|
||||
});
|
||||
loadConfig.mockReturnValue(config);
|
||||
pluginCliConfigMock.mockReturnValue(config);
|
||||
setInstalledPluginIndexInstallRecords(config.plugins?.installs ?? {});
|
||||
primePluginUpdate(config);
|
||||
|
||||
@@ -1311,7 +1311,7 @@ describe("plugins cli update", () => {
|
||||
resolvedName: "@openclaw/codex",
|
||||
});
|
||||
config.update = { channel: "beta" };
|
||||
loadConfig.mockReturnValue(config);
|
||||
pluginCliConfigMock.mockReturnValue(config);
|
||||
setInstalledPluginIndexInstallRecords(config.plugins?.installs ?? {});
|
||||
primePluginUpdate(config);
|
||||
|
||||
@@ -1330,7 +1330,7 @@ describe("plugins cli update", () => {
|
||||
spec: "@openclaw/codex",
|
||||
resolvedName: "@openclaw/codex",
|
||||
});
|
||||
loadConfig.mockReturnValue(config);
|
||||
pluginCliConfigMock.mockReturnValue(config);
|
||||
setInstalledPluginIndexInstallRecords(config.plugins?.installs ?? {});
|
||||
primePluginUpdate(config);
|
||||
|
||||
@@ -1349,7 +1349,7 @@ describe("plugins cli update", () => {
|
||||
resolvedName: "@openclaw/codex",
|
||||
});
|
||||
config.update = { channel: "extended-stable" };
|
||||
loadConfig.mockReturnValue(config);
|
||||
pluginCliConfigMock.mockReturnValue(config);
|
||||
setInstalledPluginIndexInstallRecords(config.plugins?.installs ?? {});
|
||||
primePluginUpdate(config);
|
||||
|
||||
@@ -1369,7 +1369,7 @@ describe("plugins cli update", () => {
|
||||
pluginId: "openclaw-codex-app-server",
|
||||
spec: "openclaw-codex-app-server@beta",
|
||||
});
|
||||
loadConfig.mockReturnValue(config);
|
||||
pluginCliConfigMock.mockReturnValue(config);
|
||||
setInstalledPluginIndexInstallRecords(config.plugins?.installs ?? {});
|
||||
primePluginUpdate(config);
|
||||
|
||||
@@ -1395,7 +1395,7 @@ describe("plugins cli update", () => {
|
||||
pluginId: "openclaw-codex-app-server",
|
||||
spec: "clawhub:openclaw-codex-app-server",
|
||||
});
|
||||
loadConfig.mockReturnValue(config);
|
||||
pluginCliConfigMock.mockReturnValue(config);
|
||||
setInstalledPluginIndexInstallRecords(config.plugins?.installs ?? {});
|
||||
primePluginUpdate(config);
|
||||
|
||||
@@ -1466,7 +1466,7 @@ describe("plugins cli update", () => {
|
||||
expectInstallRecordsWrittenWithLease(nextConfig.plugins?.installs, {});
|
||||
expect(updateNpmInstalledHookPacks).not.toHaveBeenCalled();
|
||||
expect(writeConfigFile).toHaveBeenCalledWith({});
|
||||
expect(replaceConfigFile).toHaveBeenCalledWith({
|
||||
expect(replaceConfigFileMock).toHaveBeenCalledWith({
|
||||
nextConfig: {},
|
||||
baseHash: "update-config",
|
||||
writeOptions: expect.objectContaining({
|
||||
@@ -1475,7 +1475,7 @@ describe("plugins cli update", () => {
|
||||
},
|
||||
}),
|
||||
});
|
||||
expect(refreshPluginRegistry).toHaveBeenCalledWith({
|
||||
expect(refreshPluginRegistryMock).toHaveBeenCalledWith({
|
||||
config: {},
|
||||
installRecords: nextConfig.plugins?.installs,
|
||||
reason: "source-changed",
|
||||
@@ -1512,7 +1512,7 @@ describe("plugins cli update", () => {
|
||||
},
|
||||
},
|
||||
} as OpenClawConfig;
|
||||
loadConfig.mockReturnValue(cfg);
|
||||
pluginCliConfigMock.mockReturnValue(cfg);
|
||||
setInstalledPluginIndexInstallRecords(cfg.plugins?.installs ?? {});
|
||||
primePluginUpdate(
|
||||
nextConfig,
|
||||
@@ -1531,7 +1531,7 @@ describe("plugins cli update", () => {
|
||||
await expect(runPluginsCommand(["plugins", "update", "--all"])).rejects.toThrow("__exit__:1");
|
||||
|
||||
expectInstallRecordsWrittenWithLease(nextConfig.plugins?.installs, {});
|
||||
expect(refreshPluginRegistry).toHaveBeenCalledWith({
|
||||
expect(refreshPluginRegistryMock).toHaveBeenCalledWith({
|
||||
config: {},
|
||||
installRecords: nextConfig.plugins?.installs,
|
||||
reason: "source-changed",
|
||||
@@ -1569,7 +1569,7 @@ describe("plugins cli update", () => {
|
||||
|
||||
it("exits non-zero when a hook pack update reports an error", async () => {
|
||||
const cfg = {} as OpenClawConfig;
|
||||
loadConfig.mockReturnValue(cfg);
|
||||
pluginCliConfigMock.mockReturnValue(cfg);
|
||||
setHookInstallRecords({
|
||||
"demo-hooks": {
|
||||
source: "npm",
|
||||
|
||||
Reference in New Issue
Block a user