diff --git a/src/benchmarks/benchmark-config.test.ts b/src/benchmarks/benchmark-config.test.ts index 74a1ac3..b88b874 100644 --- a/src/benchmarks/benchmark-config.test.ts +++ b/src/benchmarks/benchmark-config.test.ts @@ -1,4 +1,5 @@ import { describe, expect, it } from "bun:test"; +import { spawnSync } from "node:child_process"; import { assertLeft, assertRight } from "../internal/testing"; import { parseSchema } from "../internal/zod"; @@ -12,6 +13,16 @@ import { } from "./benchmark-config"; describe("benchmark config", () => { + it("loads with frozen globals in a workflow sandbox", () => { + const result = spawnSync( + process.execPath, + ["-e", 'Object.freeze(Error); await import("./benchmark-config.ts");'], + { cwd: import.meta.dirname, encoding: "utf8" } + ); + expect(result.stderr).toBe(""); + expect(result.status).toBe(0); + }); + it("keeps native configs precise while parsing them through the native schema", () => { const result = parseSchema(NativeBenchmarkRunConfigSchema, { benchmarkId: "search_hle", diff --git a/src/benchmarks/benchmark-config.ts b/src/benchmarks/benchmark-config.ts index 4727c98..953021c 100644 --- a/src/benchmarks/benchmark-config.ts +++ b/src/benchmarks/benchmark-config.ts @@ -2,10 +2,10 @@ import { COST_TIERS, IMAGE_DETAIL_VALUES, REASONING_EFFORTS, + stripVariantSuffix, SWITCHYARD_ALGORITHMS, VIDEO_PROCESSING_MODES, } from "../harness/constants"; -import { stripVariantSuffix } from "../harness/model"; import { ProviderSort } from "../internal/enums"; import type { ValueOf } from "../internal/guards"; import { z, zDefaultedText, zInt } from "../internal/zod"; diff --git a/src/harness/constants.ts b/src/harness/constants.ts index 355238b..9cc14f3 100644 --- a/src/harness/constants.ts +++ b/src/harness/constants.ts @@ -86,3 +86,8 @@ export const VIDEO_PROCESSING_MODES = [ ] as const; export type VideoProcessingMode = ValueOf; + +export function stripVariantSuffix(model: string): string { + const idx = model.indexOf(":"); + return idx <= 0 ? model : model.slice(0, idx); +} diff --git a/src/harness/model.ts b/src/harness/model.ts index b540a83..ac7c4f9 100644 --- a/src/harness/model.ts +++ b/src/harness/model.ts @@ -14,10 +14,7 @@ import type { ToolDefinition, } from "./core"; -export function stripVariantSuffix(model: string): string { - const idx = model.indexOf(":"); - return idx <= 0 ? model : model.slice(0, idx); -} +export { stripVariantSuffix } from "./constants"; export interface GenerateConfig { readonly temperature?: number;