mirror of
https://github.com/moltbot/moltbot.git
synced 2026-05-06 15:18:58 +00:00
test(perf): avoid compaction hook plugin metadata scans
This commit is contained in:
@@ -1,4 +1,5 @@
|
||||
import { vi, type Mock } from "vitest";
|
||||
import type { PluginMetadataSnapshot } from "../../plugins/plugin-metadata-snapshot.js";
|
||||
import { clearAgentHarnesses } from "../harness/registry.js";
|
||||
import type { CompactionTranscriptRotation } from "./compaction-successor-transcript.js";
|
||||
|
||||
@@ -105,6 +106,45 @@ export const rotateTranscriptAfterCompactionMock: Mock<
|
||||
rotated: false,
|
||||
}));
|
||||
|
||||
const emptyPluginMetadataSnapshot: PluginMetadataSnapshot = {
|
||||
policyHash: "",
|
||||
index: {
|
||||
version: 1,
|
||||
hostContractVersion: "test",
|
||||
compatRegistryVersion: "test",
|
||||
migrationVersion: 1,
|
||||
policyHash: "",
|
||||
generatedAtMs: 1,
|
||||
installRecords: {},
|
||||
plugins: [],
|
||||
diagnostics: [],
|
||||
},
|
||||
registryDiagnostics: [],
|
||||
manifestRegistry: { plugins: [], diagnostics: [] },
|
||||
plugins: [],
|
||||
diagnostics: [],
|
||||
byPluginId: new Map(),
|
||||
normalizePluginId: (pluginId: string) => pluginId,
|
||||
owners: {
|
||||
channels: new Map(),
|
||||
channelConfigs: new Map(),
|
||||
providers: new Map(),
|
||||
modelCatalogProviders: new Map(),
|
||||
cliBackends: new Map(),
|
||||
setupProviders: new Map(),
|
||||
commandAliases: new Map(),
|
||||
contracts: new Map(),
|
||||
},
|
||||
metrics: {
|
||||
registrySnapshotMs: 0,
|
||||
manifestRegistryMs: 0,
|
||||
ownerMapsMs: 0,
|
||||
totalMs: 0,
|
||||
indexPluginCount: 0,
|
||||
manifestPluginCount: 0,
|
||||
},
|
||||
};
|
||||
|
||||
export function resetCompactSessionStateMocks(): void {
|
||||
sanitizeSessionHistoryMock.mockReset();
|
||||
sanitizeSessionHistoryMock.mockImplementation(async (params: { messages: unknown[] }) => {
|
||||
@@ -211,6 +251,10 @@ export async function loadCompactHooksHarness(): Promise<{
|
||||
ensureRuntimePluginsLoaded,
|
||||
}));
|
||||
|
||||
vi.doMock("../../plugins/current-plugin-metadata-snapshot.js", () => ({
|
||||
getCurrentPluginMetadataSnapshot: () => emptyPluginMetadataSnapshot,
|
||||
}));
|
||||
|
||||
vi.doMock("../harness/selection.js", () => ({
|
||||
maybeCompactAgentHarnessSession: maybeCompactAgentHarnessSessionMock,
|
||||
}));
|
||||
|
||||
Reference in New Issue
Block a user