perf: trim vitest hot imports and refresh manifests

This commit is contained in:
Peter Steinberger 2026-03-23 05:25:01 +00:00
parent 7fcbf383d8
commit af9de86286
12 changed files with 1056 additions and 1088 deletions

View File

@ -0,0 +1,6 @@
export function matchesHotspotSummaryLane(lane, targetLane, lanePrefixes = []) {
if (lane === targetLane) {
return true;
}
return lanePrefixes.some((prefix) => prefix.length > 0 && lane.startsWith(prefix));
}

View File

@ -3,12 +3,14 @@ import path from "node:path";
import { parseMemoryTraceSummaryLines } from "./test-parallel-memory.mjs";
import { normalizeTrackedRepoPath, tryReadJsonFile, writeJsonFile } from "./test-report-utils.mjs";
import { unitMemoryHotspotManifestPath } from "./test-runner-manifest.mjs";
import { matchesHotspotSummaryLane } from "./test-update-memory-hotspots-utils.mjs";
function parseArgs(argv) {
const args = {
config: "vitest.unit.config.ts",
out: unitMemoryHotspotManifestPath,
lane: "unit-fast",
lanePrefixes: [],
logs: [],
minDeltaKb: 256 * 1024,
limit: 64,
@ -30,6 +32,14 @@ function parseArgs(argv) {
i += 1;
continue;
}
if (arg === "--lane-prefix") {
const lanePrefix = argv[i + 1];
if (typeof lanePrefix === "string" && lanePrefix.length > 0) {
args.lanePrefixes.push(lanePrefix);
}
i += 1;
continue;
}
if (arg === "--log") {
const logPath = argv[i + 1];
if (typeof logPath === "string" && logPath.length > 0) {
@ -109,8 +119,8 @@ if (existing) {
}
for (const logPath of opts.logs) {
const text = fs.readFileSync(logPath, "utf8");
const summaries = parseMemoryTraceSummaryLines(text).filter(
(summary) => summary.lane === opts.lane,
const summaries = parseMemoryTraceSummaryLines(text).filter((summary) =>
matchesHotspotSummaryLane(summary.lane, opts.lane, opts.lanePrefixes),
);
for (const summary of summaries) {
for (const record of summary.top) {
@ -142,7 +152,10 @@ const output = {
config: opts.config,
generatedAt: new Date().toISOString(),
defaultMinDeltaKb: opts.minDeltaKb,
lane: opts.lane,
lane:
opts.lanePrefixes.length === 0
? opts.lane
: [opts.lane, ...opts.lanePrefixes.map((prefix) => String(prefix).concat("*"))].join(", "),
files,
};

View File

@ -0,0 +1,9 @@
import { normalizeProviderId } from "../agents/model-selection.js";
export function normalizeMediaProviderId(id: string): string {
const normalized = normalizeProviderId(id);
if (normalized === "gemini") {
return "google";
}
return normalized;
}

View File

@ -1,4 +1,3 @@
import { normalizeProviderId } from "../agents/model-selection.js";
import type { OpenClawConfig } from "../config/config.js";
import {
deepgramMediaUnderstandingProvider,
@ -6,6 +5,7 @@ import {
} from "../plugin-sdk/media-understanding.js";
import { loadOpenClawPlugins } from "../plugins/loader.js";
import { getActivePluginRegistry } from "../plugins/runtime.js";
import { normalizeMediaProviderId } from "./provider-id.js";
import type { MediaUnderstandingProvider } from "./types.js";
const PROVIDERS: MediaUnderstandingProvider[] = [
@ -29,13 +29,7 @@ function mergeProviderIntoRegistry(
registry.set(normalizedKey, merged);
}
export function normalizeMediaProviderId(id: string): string {
const normalized = normalizeProviderId(id);
if (normalized === "gemini") {
return "google";
}
return normalized;
}
export { normalizeMediaProviderId } from "./provider-id.js";
export function buildMediaUnderstandingRegistry(
overrides?: Record<string, MediaUnderstandingProvider>,

View File

@ -12,7 +12,7 @@ import {
DEFAULT_MEDIA_CONCURRENCY,
DEFAULT_PROMPT,
} from "./defaults.js";
import { normalizeMediaProviderId } from "./provider-registry.js";
import { normalizeMediaProviderId } from "./provider-id.js";
import { normalizeMediaUnderstandingChatType, resolveMediaUnderstandingScope } from "./scope.js";
import type { MediaUnderstandingCapability } from "./types.js";

View File

@ -0,0 +1,25 @@
const BUNDLED_WEB_SEARCH_PROVIDER_PLUGIN_IDS = {
brave: "brave",
exa: "exa",
firecrawl: "firecrawl",
gemini: "google",
grok: "xai",
kimi: "moonshot",
perplexity: "perplexity",
tavily: "tavily",
} as const satisfies Record<string, string>;
export function resolveBundledWebSearchPluginId(
providerId: string | undefined,
): string | undefined {
if (!providerId) {
return undefined;
}
const normalizedProviderId = providerId.trim().toLowerCase();
if (!(normalizedProviderId in BUNDLED_WEB_SEARCH_PROVIDER_PLUGIN_IDS)) {
return undefined;
}
return BUNDLED_WEB_SEARCH_PROVIDER_PLUGIN_IDS[
normalizedProviderId as keyof typeof BUNDLED_WEB_SEARCH_PROVIDER_PLUGIN_IDS
];
}

View File

@ -2,6 +2,7 @@ import { describe, expect, it } from "vitest";
import { bundledWebSearchPluginRegistrations } from "../bundled-web-search-registry.js";
import type { OpenClawConfig } from "../config/config.js";
import { BUNDLED_WEB_SEARCH_PLUGIN_IDS } from "./bundled-web-search-ids.js";
import { resolveBundledWebSearchPluginId } from "./bundled-web-search-provider-ids.js";
import {
listBundledWebSearchProviders,
resolveBundledWebSearchPluginIds,
@ -90,6 +91,17 @@ describe("bundled web search metadata", () => {
);
});
it("keeps bundled web search provider-to-plugin ids aligned with bundled contracts", () => {
expect(resolveBundledWebSearchPluginId("brave")).toBe("brave");
expect(resolveBundledWebSearchPluginId("exa")).toBe("exa");
expect(resolveBundledWebSearchPluginId("firecrawl")).toBe("firecrawl");
expect(resolveBundledWebSearchPluginId("gemini")).toBe("google");
expect(resolveBundledWebSearchPluginId("kimi")).toBe("moonshot");
expect(resolveBundledWebSearchPluginId("perplexity")).toBe("perplexity");
expect(resolveBundledWebSearchPluginId("tavily")).toBe("tavily");
expect(resolveBundledWebSearchPluginId("grok")).toBe("xai");
});
it("keeps fast-path bundled provider metadata aligned with bundled plugin contracts", async () => {
const fastPathProviders = listBundledWebSearchProviders();

View File

@ -1,5 +1,6 @@
import { bundledWebSearchPluginRegistrations } from "../bundled-web-search-registry.js";
import { listBundledWebSearchPluginIds as listBundledWebSearchPluginIdsFromIds } from "./bundled-web-search-ids.js";
import { resolveBundledWebSearchPluginId as resolveBundledWebSearchPluginIdFromMap } from "./bundled-web-search-provider-ids.js";
import { capturePluginRegistration } from "./captured-registration.js";
import type { PluginLoadOptions } from "./loader.js";
import { loadPluginManifestRegistry } from "./manifest-registry.js";
@ -76,8 +77,5 @@ export function listBundledWebSearchProviders(): PluginWebSearchProviderEntry[]
export function resolveBundledWebSearchPluginId(
providerId: string | undefined,
): string | undefined {
if (!providerId) {
return undefined;
}
return loadBundledWebSearchProviders().find((provider) => provider.id === providerId)?.pluginId;
return resolveBundledWebSearchPluginIdFromMap(providerId);
}

View File

@ -1,9 +1,7 @@
import type { OpenClawConfig } from "../config/config.js";
import { resolveSecretInputRef } from "../config/types.secrets.js";
import {
listBundledWebSearchPluginIds,
resolveBundledWebSearchPluginId,
} from "../plugins/bundled-web-search.js";
import { listBundledWebSearchPluginIds } from "../plugins/bundled-web-search-ids.js";
import { resolveBundledWebSearchPluginId } from "../plugins/bundled-web-search-provider-ids.js";
import type {
PluginWebSearchProviderEntry,
WebSearchCredentialResolutionSource,

View File

@ -1,159 +1,54 @@
{
"config": "vitest.unit.config.ts",
"generatedAt": "2026-03-20T04:59:15.285Z",
"generatedAt": "2026-03-23T05:18:04.876Z",
"defaultMinDeltaKb": 262144,
"lane": "unit-fast",
"lane": "unit-fast, unit-*",
"files": {
"src/config/schema.help.quality.test.ts": {
"src/infra/outbound/targets.channel-resolution.test.ts": {
"deltaKb": 1111491,
"sources": ["openclaw-test-memory-trace:unit-heavy-2"]
},
"src/media/fetch.telegram-network.test.ts": {
"deltaKb": 1101005,
"sources": ["openclaw-test-memory-trace:unit-heavy-1"]
},
"src/cron/isolated-agent/run.skill-filter.test.ts": {
"deltaKb": 1069548,
"sources": ["openclaw-test-memory-trace:unit-run.skill-filter-memory-isolated"]
},
"src/cron/isolated-agent.uses-last-non-empty-agent-text-as.test.ts": {
"deltaKb": 1048576,
"sources": [
"gha-23328306205-compat-node22:unit-fast",
"gha-23328306205-node-test-2-2:unit-fast"
"openclaw-test-memory-trace:unit-isolated-agent.uses-last-non-empty-agent-text-as-memory-isolated"
]
},
"src/cron/isolated-agent.skips-delivery-without-whatsapp-recipient-besteffortdeliver-true.test.ts": {
"deltaKb": 1026355,
"sources": [
"openclaw-test-memory-trace:unit-isolated-agent.skips-delivery-without-whatsapp-recipient-besteffortdeliver-true-memory-isolated"
]
},
"src/cron/isolated-agent/run.cron-model-override.test.ts": {
"deltaKb": 946790,
"sources": ["openclaw-test-memory-trace:unit-run.cron-model-override-memory-isolated"]
},
"src/plugins/install.test.ts": {
"deltaKb": 510874,
"sources": ["openclaw-test-memory-trace:unit-install-memory-isolated"]
},
"ui/src/ui/views/chat.test.ts": {
"deltaKb": 509338,
"sources": ["openclaw-test-memory-trace:unit-chat-memory-isolated"]
},
"src/infra/provider-usage.auth.normalizes-keys.test.ts": {
"deltaKb": 494080,
"sources": [
"openclaw-test-memory-trace:unit-provider-usage.auth.normalizes-keys-memory-isolated"
]
},
"src/plugins/conversation-binding.test.ts": {
"deltaKb": 787149,
"sources": ["gha-23329089711-node-test-2-2:unit-fast"]
},
"src/plugins/contracts/wizard.contract.test.ts": {
"deltaKb": 783770,
"sources": ["gha-23329089711-node-test-1-2:unit-fast"]
},
"ui/src/ui/views/chat.test.ts": {
"deltaKb": 740864,
"sources": ["gha-23329089711-node-test-2-2:unit-fast"]
},
"src/cron/isolated-agent.uses-last-non-empty-agent-text-as.test.ts": {
"deltaKb": 652288,
"sources": ["gha-23328306205-node-test-1-2:unit-fast"]
},
"src/plugins/install.test.ts": {
"deltaKb": 545485,
"sources": ["gha-23328306205-compat-node22:unit-fast"]
},
"src/tui/tui.submit-handler.test.ts": {
"deltaKb": 528486,
"sources": ["gha-23329089711-node-test-1-2:unit-fast"]
},
"src/media-understanding/resolve.test.ts": {
"deltaKb": 516506,
"sources": ["job1:unit-fast"]
},
"src/infra/provider-usage.auth.normalizes-keys.test.ts": {
"deltaKb": 510362,
"sources": ["gha-23329089711-node-test-1-2:unit-fast"]
},
"src/acp/client.test.ts": {
"deltaKb": 491213,
"sources": ["job2:unit-fast"]
},
"src/infra/update-runner.test.ts": {
"deltaKb": 474726,
"sources": ["gha-23328306205-node-test-1-2:unit-fast"]
},
"src/secrets/runtime-web-tools.test.ts": {
"deltaKb": 473190,
"sources": ["job1:unit-fast"]
},
"src/cron/isolated-agent/run.cron-model-override.test.ts": {
"deltaKb": 469914,
"sources": ["gha-23328306205-node-test-2-2:unit-fast"]
},
"src/cron/isolated-agent.skips-delivery-without-whatsapp-recipient-besteffortdeliver-true.test.ts": {
"deltaKb": 457421,
"sources": ["gha-23328306205-node-test-1-2:unit-fast"]
},
"src/cron/isolated-agent/run.skill-filter.test.ts": {
"deltaKb": 446054,
"sources": ["gha-23328306205-compat-node22:unit-fast"]
},
"src/plugins/interactive.test.ts": {
"deltaKb": 441242,
"sources": ["gha-23329089711-node-test-1-2:unit-fast"]
},
"src/infra/run-node.test.ts": {
"deltaKb": 427213,
"sources": ["gha-23328306205-node-test-2-2:unit-fast"]
},
"src/media-understanding/runner.video.test.ts": {
"deltaKb": 402739,
"sources": ["job1:unit-fast"]
},
"src/infra/provider-usage.test.ts": {
"deltaKb": 389837,
"sources": ["gha-23329089711-node-test-2-2:unit-fast"]
},
"src/cron/isolated-agent.delivers-response-has-heartbeat-ok-but-includes.test.ts": {
"deltaKb": 377446,
"sources": ["gha-23328306205-compat-node22:unit-fast"]
},
"src/cron/isolated-agent/delivery-dispatch.named-agent.test.ts": {
"deltaKb": 355840,
"sources": ["gha-23329089711-node-test-1-2:unit-fast"]
},
"src/infra/state-migrations.test.ts": {
"deltaKb": 345805,
"sources": ["gha-23328306205-node-test-1-2:unit-fast"]
},
"src/config/sessions/store.pruning.integration.test.ts": {
"deltaKb": 342221,
"sources": ["gha-23328306205-node-test-1-2:unit-fast"]
},
"src/channels/plugins/contracts/outbound-payload.contract.test.ts": {
"deltaKb": 335565,
"sources": ["gha-23329089711-node-test-1-2:unit-fast"]
},
"src/config/sessions/store.pruning.test.ts": {
"deltaKb": 333312,
"sources": ["job2:unit-fast"]
},
"src/media-understanding/providers/moonshot/video.test.ts": {
"deltaKb": 333005,
"sources": ["gha-23329089711-node-test-2-2:unit-fast"]
},
"src/infra/heartbeat-runner.model-override.test.ts": {
"deltaKb": 325632,
"sources": ["job1:unit-fast"]
},
"src/config/sessions.test.ts": {
"deltaKb": 324813,
"sources": ["gha-23329089711-node-test-2-2:unit-fast"]
},
"src/acp/translator.cancel-scoping.test.ts": {
"deltaKb": 324403,
"sources": ["gha-23328306205-node-test-1-2:unit-fast"]
},
"src/infra/heartbeat-runner.ghost-reminder.test.ts": {
"deltaKb": 321536,
"sources": ["job1:unit-fast"]
},
"src/tui/tui-session-actions.test.ts": {
"deltaKb": 319898,
"sources": ["gha-23328306205-compat-node22:unit-fast"]
},
"src/infra/outbound/message-action-runner.context.test.ts": {
"deltaKb": 318157,
"sources": ["gha-23328306205-compat-node22:unit-fast"]
},
"src/cron/service.store-load-invalid-main-job.test.ts": {
"deltaKb": 308019,
"sources": ["gha-23328306205-node-test-2-2:unit-fast"]
},
"src/channels/plugins/outbound/signal.test.ts": {
"deltaKb": 301056,
"sources": ["job2:unit-fast"]
},
"src/cron/service.store-migration.test.ts": {
"deltaKb": 282931,
"sources": ["gha-23328306205-node-test-2-2:unit-fast"]
},
"src/media-understanding/providers/google/video.test.ts": {
"deltaKb": 274022,
"sources": ["gha-23328306205-node-test-2-2:unit-fast"]
},
"src/infra/heartbeat-runner.sender-prefers-delivery-target.test.ts": {
"deltaKb": 267366,
"sources": ["job2:unit-fast"]
"deltaKb": 485786,
"sources": ["openclaw-test-memory-trace:unit-conversation-binding-memory-isolated"]
}
}
}

File diff suppressed because it is too large Load Diff

View File

@ -0,0 +1,18 @@
import { describe, expect, it } from "vitest";
import { matchesHotspotSummaryLane } from "../../scripts/test-update-memory-hotspots-utils.mjs";
describe("test-update-memory-hotspots lane matching", () => {
it("matches the exact target lane", () => {
expect(matchesHotspotSummaryLane("unit-fast", "unit-fast")).toBe(true);
});
it("matches configured lane prefixes", () => {
expect(matchesHotspotSummaryLane("unit-chat-memory-isolated", "unit-fast", ["unit-"])).toBe(
true,
);
});
it("rejects unrelated lanes", () => {
expect(matchesHotspotSummaryLane("extensions", "unit-fast", ["unit-"])).toBe(false);
});
});