From 9489cd1f96a989375b9baf36a964d103be5fb4fa Mon Sep 17 00:00:00 2001 From: Peter Steinberger Date: Wed, 12 Aug 2026 18:39:08 -0700 Subject: [PATCH] test(commands): stub plugin metadata snapshot in onboard-inference test (#122901) The configured-model case lacked a current plugin metadata snapshot, so model normalization cold-discovered every bundled manifest; the prepared empty snapshot keeps the test on its intended boundary and reduced Vitest file wall time from 26.72s to 2.57s (the shell measurements were 194.45s and 56.21s including unrelated lock queues). --- src/commands/onboard-inference.test.ts | 51 +++++++++++++++++++++++++- 1 file changed, 50 insertions(+), 1 deletion(-) diff --git a/src/commands/onboard-inference.test.ts b/src/commands/onboard-inference.test.ts index f86b69a2286c..31f79114e099 100644 --- a/src/commands/onboard-inference.test.ts +++ b/src/commands/onboard-inference.test.ts @@ -1,5 +1,5 @@ // Inference backend detection tests cover the documented ladder and login-awareness. -import { describe, expect, it } from "vitest"; +import { afterAll, describe, expect, it, vi } from "vitest"; import type { LocalCommandProbe } from "../system-agent/probes.js"; import { ANTHROPIC_API_DEFAULT_MODEL_REF, @@ -7,6 +7,55 @@ import { detectInferenceBackends, } from "./onboard-inference.js"; +const emptyPluginMetadataSnapshot = vi.hoisted(() => ({ + policyHash: "onboard-inference-test-empty-plugin-policy", + configFingerprint: "onboard-inference-test-empty-plugin-metadata", + index: { + version: 1, + hostContractVersion: "test", + compatRegistryVersion: "test", + migrationVersion: 1, + policyHash: "onboard-inference-test-empty-plugin-policy", + generatedAtMs: 0, + 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, + }, +})); + +vi.mock("../plugins/current-plugin-metadata-snapshot.js", () => ({ + getCurrentPluginMetadataSnapshot: () => emptyPluginMetadataSnapshot, +})); + +afterAll(() => { + vi.doUnmock("../plugins/current-plugin-metadata-snapshot.js"); + vi.resetModules(); +}); + function probeDeps(found: Record) { return async (command: string): Promise => ({ command,