vieval 0.0.5 → 0.0.6
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/bin/vieval.mjs +1 -1
- package/dist/cli/index.mjs +1 -1
- package/dist/{cli-DayPXzHX.mjs → cli-sanbKtQq.mjs} +277 -49
- package/dist/cli-sanbKtQq.mjs.map +1 -0
- package/dist/config.d.mts +2 -2
- package/dist/config.mjs +1 -1
- package/dist/core/assertions/index.d.mts +1 -1
- package/dist/core/inference-executors/index.d.mts +1 -1
- package/dist/core/inference-executors/index.mjs +1 -1
- package/dist/core/processors/results/index.d.mts +1 -1
- package/dist/core/runner/index.d.mts +3 -2
- package/dist/core/runner/index.mjs +3 -2
- package/dist/core/runner/index.mjs.map +1 -1
- package/dist/core/scheduler/index.d.mts +2 -0
- package/dist/core/scheduler/index.mjs +188 -0
- package/dist/core/scheduler/index.mjs.map +1 -0
- package/dist/{env-BFSjny07.mjs → env--94B0UtW.mjs} +1 -1
- package/dist/{env-BFSjny07.mjs.map → env--94B0UtW.mjs.map} +1 -1
- package/dist/{env-BTq3dV7C.d.mts → env-BeHv_5mo.d.mts} +1 -1
- package/dist/{expect-extensions-QLXESWjn.mjs → expect-extensions-DCSqlneN.mjs} +1 -1
- package/dist/{expect-extensions-QLXESWjn.mjs.map → expect-extensions-DCSqlneN.mjs.map} +1 -1
- package/dist/expect.mjs +1 -1
- package/dist/{index-OEdqjQSe.d.mts → index-DBZKkpBe.d.mts} +105 -3
- package/dist/index-fakXoZEe.d.mts +147 -0
- package/dist/index.d.mts +110 -11
- package/dist/index.mjs +214 -53
- package/dist/index.mjs.map +1 -1
- package/dist/{models-D_MsBtYw.mjs → models-DIGdOUpJ.mjs} +1 -1
- package/dist/models-DIGdOUpJ.mjs.map +1 -0
- package/dist/plugins/chat-models/index.d.mts +21 -1
- package/dist/plugins/chat-models/index.mjs +27 -1
- package/dist/plugins/chat-models/index.mjs.map +1 -1
- package/dist/queue-DsZQkZO_.mjs +21 -0
- package/dist/queue-DsZQkZO_.mjs.map +1 -0
- package/dist/{registry-CwcMMjnZ.mjs → registry-CcKZqDJY.mjs} +25 -3
- package/dist/registry-CcKZqDJY.mjs.map +1 -0
- package/dist/testing/expect-extensions.mjs +1 -1
- package/package.json +7 -1
- package/dist/cli-DayPXzHX.mjs.map +0 -1
- package/dist/models-D_MsBtYw.mjs.map +0 -1
- package/dist/registry-CwcMMjnZ.mjs.map +0 -1
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.mjs","names":[],"sources":["../../../src/core/cache/filesystem.ts","../../../src/core/runner/aggregate.ts","../../../src/core/runner/collect.ts","../../../src/core/runner/run.ts","../../../src/core/runner/runtime-context.ts","../../../src/core/runner/schedule.ts","../../../src/core/runner/task-context.ts"],"sourcesContent":["import type { CacheFileHandle, CacheFileOptions, CacheNamespace, TaskCacheRuntime } from './types'\n\nimport process from 'node:process'\n\nimport { Buffer } from 'node:buffer'\nimport { createReadStream, createWriteStream } from 'node:fs'\nimport { access, mkdir, readFile, rename, writeFile } from 'node:fs/promises'\nimport { dirname, join } from 'node:path'\n\n/**\n * Options for creating the filesystem-backed task cache runtime.\n */\nexport interface CreateFilesystemTaskCacheRuntimeOptions {\n /**\n * Absolute cache root directory.\n */\n cacheRootDirectory: string\n /**\n * Project identifier under one workspace cache scope.\n */\n projectName: string\n /**\n * Workspace identifier used to share cache roots across projects.\n */\n workspaceId: string\n}\n\nfunction sanitizePathSegment(value: string): string {\n const normalized = value.trim()\n if (normalized.length === 0) {\n return 'default'\n }\n\n return normalized.replace(/[^\\w.-]+/g, '-')\n}\n\nfunction normalizeExtension(extension: string | undefined, mediaType: string | undefined): string | undefined {\n if (extension != null && extension.length > 0) {\n return extension.startsWith('.') ? extension.slice(1) : extension\n }\n\n if (mediaType == null || mediaType.length === 0) {\n return undefined\n }\n\n if (mediaType === 'application/json') {\n return 'json'\n }\n\n if (mediaType === 'text/plain') {\n return 'txt'\n }\n\n if (mediaType === 'audio/wav') {\n return 'wav'\n }\n\n return undefined\n}\n\n/**\n * Normalizes cache file options into deterministic relative path segments.\n *\n * Before:\n * - `{ key: ['cases', 'dataset hash', 'v1'], ext: 'json' }`\n *\n * After:\n * - `['cases', 'dataset-hash', 'v1.json']`\n */\nexport function normalizeCacheFilePathSegments(options: CacheFileOptions): string[] {\n const sanitizedKey = options.key.map(segment => sanitizePathSegment(segment))\n const extension = normalizeExtension(options.ext, options.mediaType)\n\n if (sanitizedKey.length === 0) {\n return extension == null ? ['artifact'] : [`artifact.${extension}`]\n }\n\n if (extension == null) {\n return sanitizedKey\n }\n\n const withoutTail = sanitizedKey.slice(0, Math.max(0, sanitizedKey.length - 1))\n const tail = sanitizedKey[sanitizedKey.length - 1] ?? 'artifact'\n return [...withoutTail, `${tail}.${extension}`]\n}\n\nasync function writeAtomically(path: string, content: Buffer | string): Promise<void> {\n const directory = dirname(path)\n const temporaryPath = `${path}.tmp-${process.pid}-${Date.now()}-${Math.random().toString(36).slice(2, 10)}`\n await mkdir(directory, { recursive: true })\n await writeFile(temporaryPath, content)\n await rename(temporaryPath, path)\n}\n\nfunction createCacheFileHandle(path: string): CacheFileHandle {\n return {\n path,\n async exists() {\n try {\n await access(path)\n return true\n }\n catch {\n return false\n }\n },\n openReadStream() {\n return createReadStream(path)\n },\n async openWriteStream() {\n await mkdir(dirname(path), { recursive: true })\n return createWriteStream(path)\n },\n async readBuffer() {\n return await readFile(path)\n },\n async writeBuffer(value) {\n await writeAtomically(path, value)\n },\n async readText(encoding = 'utf-8') {\n return await readFile(path, encoding)\n },\n async writeText(value, encoding = 'utf-8') {\n await writeAtomically(path, Buffer.from(value, encoding))\n },\n async readJson<T>() {\n return JSON.parse(await readFile(path, 'utf-8')) as T\n },\n async writeJson(value) {\n await writeAtomically(path, `${JSON.stringify(value, null, 2)}\\n`)\n },\n async loadAsCasesInput<T>() {\n return await this.readJson<T[]>()\n },\n async loadAsExpectFixture<T>() {\n return await this.readJson<T>()\n },\n }\n}\n\nfunction createCacheNamespace(baseDirectory: string, namespace: string): CacheNamespace {\n return {\n file(options) {\n const relativePathSegments = normalizeCacheFilePathSegments(options)\n return createCacheFileHandle(join(baseDirectory, sanitizePathSegment(namespace), ...relativePathSegments))\n },\n }\n}\n\n/**\n * Creates a deterministic filesystem-backed task cache runtime.\n *\n * Use when:\n * - eval tasks need reproducible cache paths for expensive pre-processing outputs\n * - benchmark adapters need one artifact-oriented API for text/json/binary reads and writes\n *\n * Expects:\n * - `cacheRootDirectory` to be writable by the running process\n * - `workspaceId` + `projectName` to stay stable for reproducible paths\n *\n * Returns:\n * - task cache runtime that resolves namespaced file handles under:\n * `<cacheRootDirectory>/<workspaceId>/<projectName>/<namespace>/...`\n */\nexport function createFilesystemTaskCacheRuntime(\n options: CreateFilesystemTaskCacheRuntimeOptions,\n): TaskCacheRuntime {\n const workspaceDirectory = sanitizePathSegment(options.workspaceId)\n const projectDirectory = sanitizePathSegment(options.projectName)\n const baseDirectory = join(options.cacheRootDirectory, workspaceDirectory, projectDirectory)\n\n return {\n namespace(name) {\n return createCacheNamespace(baseDirectory, name)\n },\n }\n}\n","import type { ScheduledTaskMatrix } from './schedule'\n\n/**\n * Identifies the scoring family for a single eval score.\n */\nexport type RunScoreKind = 'exact' | 'judge'\n\n/**\n * Represents one normalized score emitted by a completed eval run.\n */\nexport interface RunScore {\n /**\n * Score family used for aggregation.\n */\n kind: RunScoreKind\n /**\n * Normalized score in the `0..1` range.\n */\n score: number\n}\n\n/**\n * Captures the output of one scheduled runner task.\n */\nexport interface RunResult {\n /**\n * Stable run id, usually copied from the scheduled task id.\n */\n id: string\n /**\n * Collected eval entry id.\n */\n entryId: string\n /**\n * Stable inferenceExecutor id.\n */\n inferenceExecutorId: string\n /**\n * Concrete matrix selection used by the run.\n */\n matrix: ScheduledTaskMatrix\n /**\n * Raw scores emitted by the eval.\n */\n scores: readonly RunScore[]\n}\n\n/**\n * Stores the per-run score averages after normalization.\n */\nexport interface AggregatedRunSummary {\n /**\n * Stable run id.\n */\n id: string\n /**\n * Collected eval entry id.\n */\n entryId: string\n /**\n * Stable inferenceExecutor id.\n */\n inferenceExecutorId: string\n /**\n * Concrete matrix selection used by the run.\n */\n matrix: ScheduledTaskMatrix\n /**\n * Mean of exact-match scores or `null` when absent.\n */\n exactAverage: number | null\n /**\n * Mean of judge-based scores or `null` when absent.\n */\n judgeAverage: number | null\n /**\n * Hybrid average. Uses both families when present, otherwise falls back to the\n * single available family.\n */\n hybridAverage: number | null\n}\n\n/**\n * Stores inferenceExecutor-level score aggregates across multiple runs.\n */\nexport interface AggregatedProviderSummary {\n /**\n * Stable inferenceExecutor id.\n */\n inferenceExecutorId: string\n /**\n * Number of runs included in this inferenceExecutor bucket.\n */\n runCount: number\n /**\n * Mean of all exact-match scores or `null` when absent.\n */\n exactAverage: number | null\n /**\n * Mean of all judge-based scores or `null` when absent.\n */\n judgeAverage: number | null\n /**\n * Hybrid average derived from the inferenceExecutor exact and judge means.\n */\n hybridAverage: number | null\n}\n\n/**\n * Stores the final aggregation output for a batch of runner results.\n */\nexport interface AggregatedRunResults {\n /**\n * Per-run normalized score summaries.\n */\n runs: AggregatedRunSummary[]\n /**\n * Provider-level summaries sorted by inferenceExecutor id.\n */\n inferenceExecutors: AggregatedProviderSummary[]\n /**\n * Overall summary across every run.\n */\n overall: {\n exactAverage: number | null\n judgeAverage: number | null\n hybridAverage: number | null\n runCount: number\n }\n}\n\ninterface ScoreBuckets {\n exact: number[]\n judge: number[]\n}\n\nfunction cloneScheduledTaskMatrix(matrix: ScheduledTaskMatrix): ScheduledTaskMatrix {\n return {\n eval: {\n ...matrix.eval,\n },\n meta: {\n ...matrix.meta,\n },\n run: {\n ...matrix.run,\n },\n }\n}\n\nfunction assertKnownScoreKind(kind: string): RunScoreKind {\n if (kind === 'exact' || kind === 'judge') {\n return kind\n }\n\n throw new TypeError(`Unknown eval score kind \"${kind}\".`)\n}\n\nfunction average(scores: readonly number[]): number | null {\n if (scores.length === 0) {\n return null\n }\n\n const total = scores.reduce((sum, score) => sum + score, 0)\n return total / scores.length\n}\n\nfunction createHybridAverage(exactAverage: number | null, judgeAverage: number | null): number | null {\n if (exactAverage != null && judgeAverage != null) {\n return (exactAverage + judgeAverage) / 2\n }\n\n if (exactAverage != null) {\n return exactAverage\n }\n\n if (judgeAverage != null) {\n return judgeAverage\n }\n\n return null\n}\n\nfunction collectScoreBuckets(scores: readonly RunScore[]): ScoreBuckets {\n const buckets: ScoreBuckets = {\n exact: [],\n judge: [],\n }\n\n for (const score of scores) {\n const kind = assertKnownScoreKind(score.kind)\n\n if (kind === 'exact') {\n buckets.exact.push(score.score)\n continue\n }\n\n buckets.judge.push(score.score)\n }\n\n return buckets\n}\n\nfunction createRunSummary(result: RunResult): AggregatedRunSummary {\n const buckets = collectScoreBuckets(result.scores)\n const exactAverage = average(buckets.exact)\n const judgeAverage = average(buckets.judge)\n\n return {\n entryId: result.entryId,\n exactAverage,\n hybridAverage: createHybridAverage(exactAverage, judgeAverage),\n id: result.id,\n judgeAverage,\n matrix: cloneScheduledTaskMatrix(result.matrix),\n inferenceExecutorId: result.inferenceExecutorId,\n }\n}\n\nfunction createProviderSummary(inferenceExecutorId: string, results: readonly RunResult[]): AggregatedProviderSummary {\n const exactScores: number[] = []\n const judgeScores: number[] = []\n\n for (const result of results) {\n const buckets = collectScoreBuckets(result.scores)\n exactScores.push(...buckets.exact)\n judgeScores.push(...buckets.judge)\n }\n\n const exactAverage = average(exactScores)\n const judgeAverage = average(judgeScores)\n\n return {\n exactAverage,\n hybridAverage: createHybridAverage(exactAverage, judgeAverage),\n judgeAverage,\n inferenceExecutorId,\n runCount: results.length,\n }\n}\n\n/**\n * Aggregates exact-match and judge-based scores into hybrid runner summaries.\n *\n * Call stack:\n *\n * {@link runScheduledTasks}\n * -> {@link aggregateRunResults}\n * -> {@link createRunSummary}\n * -> {@link createProviderSummary}\n * -> `report output`\n *\n * Use when:\n * - a runner batch mixes deterministic exact checks with judge-based grading\n * - inferenceExecutor comparison should preserve both score families and one hybrid view\n *\n * Expects:\n * - each score to be normalized to the `0..1` range before aggregation\n * - `scores.kind` to use only `'exact'` or `'judge'`\n */\nexport function aggregateRunResults(results: readonly RunResult[]): AggregatedRunResults {\n const runs = results.map(createRunSummary)\n\n const inferenceExecutorIds = Array.from(new Set(results.map(result => result.inferenceExecutorId)))\n const inferenceExecutors = inferenceExecutorIds\n .map((inferenceExecutorId) => {\n const providerResults = results.filter(result => result.inferenceExecutorId === inferenceExecutorId)\n return createProviderSummary(inferenceExecutorId, providerResults)\n })\n .sort((left, right) => left.inferenceExecutorId.localeCompare(right.inferenceExecutorId))\n\n const overall = createProviderSummary(\n 'overall',\n results,\n )\n\n return {\n overall: {\n exactAverage: overall.exactAverage,\n hybridAverage: overall.hybridAverage,\n judgeAverage: overall.judgeAverage,\n runCount: overall.runCount,\n },\n inferenceExecutors,\n runs,\n }\n}\n","import type { CollectedEvalEntry, EvalModule, EvalModuleMap } from '../../config'\nimport type { RunnerRuntimeContext } from './runtime-context'\n\nimport { basename, dirname, relative } from 'node:path'\nimport { fileURLToPath } from 'node:url'\n\nconst evalFileSuffix = '.eval.ts'\nconst absolutePathPattern = /^(?:[A-Z]:\\/|\\/|\\\\\\\\)/i\n\nfunction normalizePath(value: string): string {\n return value.replaceAll('\\\\', '/')\n}\n\n/**\n * Converts a file path into a project-relative path when possible.\n *\n * Before: `/repo/plugins/airi-plugin-game-chess/src/agent/evals/chess-commentary.eval.ts`\n * After: `plugins/airi-plugin-game-chess/src/agent/evals/chess-commentary.eval.ts`\n *\n * Before: `D:/repo/plugins/airi-plugin-game-chess/src/agent/evals/chess-commentary.eval.ts`\n * After: `D:/repo/plugins/airi-plugin-game-chess/src/agent/evals/chess-commentary.eval.ts`\n */\nexport function asProjectRelativePath(filePath: string, context: RunnerRuntimeContext): string {\n const normalizedFilePath = normalizePath(filePath)\n const normalizedProjectRootDirectory = normalizePath(context.projectRootDirectory)\n const filePathWindowsDrive = normalizedFilePath.match(/^[A-Z]:\\//i)?.[0]\n const projectRootWindowsDrive = normalizedProjectRootDirectory.match(/^[A-Z]:\\//i)?.[0]\n\n if (filePathWindowsDrive != null && projectRootWindowsDrive == null) {\n return normalizedFilePath\n }\n\n if (\n filePathWindowsDrive != null\n && projectRootWindowsDrive != null\n && filePathWindowsDrive.toLowerCase() !== projectRootWindowsDrive.toLowerCase()\n ) {\n return normalizedFilePath\n }\n\n const projectRootDirectory = context.projectRootDirectory\n const relativeFilePath = normalizePath(relative(projectRootDirectory, filePath))\n\n if (!absolutePathPattern.test(relativeFilePath)) {\n if (relativeFilePath === '..') {\n return normalizePath(filePath)\n }\n\n if (!relativeFilePath.startsWith('../')) {\n return relativeFilePath\n }\n }\n\n return normalizePath(filePath)\n}\n\nfunction resolveModuleFilePath(moduleHref: string): string | null {\n if (!moduleHref.startsWith('file:')) {\n return null\n }\n\n try {\n return fileURLToPath(moduleHref)\n }\n catch {\n return null\n }\n}\n\nfunction createCollectedEvalEntry(\n moduleHref: string,\n moduleDefinition: EvalModule,\n context: RunnerRuntimeContext,\n): CollectedEvalEntry | null {\n const filePath = resolveModuleFilePath(moduleHref)\n\n if (!filePath) {\n return null\n }\n\n const relativeFilePath = asProjectRelativePath(filePath, context)\n\n if (!relativeFilePath.endsWith(evalFileSuffix)) {\n return null\n }\n\n const entryName = basename(relativeFilePath, evalFileSuffix)\n\n if (entryName.length === 0) {\n return null\n }\n\n const relativeDirectory = dirname(relativeFilePath)\n const directory = relativeDirectory === '.' ? '' : relativeDirectory\n\n return {\n ...moduleDefinition.default,\n directory,\n filePath,\n id: directory.length === 0 ? entryName : `${directory}/${entryName}`,\n name: entryName,\n }\n}\n\n/**\n * Collects loaded vieval modules into sorted runner entries with stable ids.\n *\n * Call stack:\n *\n * `import.meta.glob(...)`\n * -> {@link collectEvalEntries}\n * -> {@link createCollectedEvalEntry}\n * -> {@link CollectedEvalEntry}[]\n *\n * Use when:\n * - the runner has already loaded candidate eval modules\n * - downstream scheduling needs stable entry ids and directory metadata\n */\nexport function collectEvalEntries(\n modules: EvalModuleMap,\n context: RunnerRuntimeContext,\n): CollectedEvalEntry[] {\n return Object.entries(modules)\n .flatMap(([moduleHref, moduleDefinition]) => {\n const entry = createCollectedEvalEntry(moduleHref, moduleDefinition, context)\n\n if (!entry) {\n return []\n }\n\n return [entry]\n })\n .sort((left, right) => left.id.localeCompare(right.id))\n}\n","import type { TaskCacheRuntime } from '../cache'\nimport type { AggregatedRunResults, RunResult } from './aggregate'\nimport type { ScheduledTask } from './schedule'\nimport type { TaskExecutionContext } from './task-context'\n\nimport { errorMessageFrom } from '@moeru/std'\nimport { limitConcurrency } from '@vitest/runner/utils'\n\nimport { aggregateRunResults } from './aggregate'\n\n/**\n * Executes one scheduled runner task and returns a normalized run result.\n *\n * Use when:\n * - a scheduler already selected the task and execution context\n * - the caller wants a typed executor contract for runner workers\n *\n * Expects:\n * - the task context to be ready for model resolution and task-scoped work\n *\n * Returns:\n * - a normalized run result with score entries ready for aggregation\n */\nexport type ScheduledTaskExecutor = (\n task: ScheduledTask,\n context: TaskExecutionContext,\n) => Promise<RunResult>\n\n/**\n * Terminal task state reported by runner lifecycle hooks.\n *\n * Use when:\n * - reporting the outcome of one scheduled task to lifecycle observers\n *\n * Expects:\n * - hooks treat the value as final for the completed task\n */\nexport type RunnerTaskState = 'passed' | 'failed'\n\n/**\n * Optional runner execution hooks used while processing scheduled tasks.\n *\n * Use when:\n * - callers want lifecycle visibility around sequential task execution\n * - task execution should remain deterministic while still observable\n *\n * Expects:\n * - hook functions are synchronous lifecycle observers\n */\nexport interface RunScheduledTasksOptions {\n /**\n * Creates per-task execution context.\n *\n * Use when:\n * - executor code needs per-task model resolution or other task-scoped data\n */\n createExecutionContext?: (task: ScheduledTask) => TaskExecutionContext\n /**\n * Runs before the executor starts handling a task.\n *\n * Use when:\n * - callers want to observe task activation before execution begins\n *\n * Expects:\n * - thrown errors abort the task before executor work starts\n */\n onTaskStart?: (task: ScheduledTask) => void\n /**\n * Runs after the executor settles for a task.\n *\n * Use when:\n * - callers want to observe successful and failed task completion\n *\n * Expects:\n * - thrown errors abort successful runs\n * - failed-task observers do not override the executor error for the task\n */\n onTaskEnd?: (task: ScheduledTask, state: RunnerTaskState) => void\n /**\n * Maximum number of tasks to execute concurrently.\n *\n * @default 1\n */\n maxConcurrency?: number\n}\n\nfunction createDefaultExecutionContext(task: ScheduledTask): TaskExecutionContext {\n const cache: TaskCacheRuntime = {\n namespace(name) {\n return {\n file(options) {\n const key = options.key.join('/')\n throw new Error(`Task cache runtime is not configured. Requested namespace \"${name}\" and key \"${key}\".`)\n },\n }\n },\n }\n\n return {\n cache,\n model(options) {\n const requestedModelName = typeof options === 'string' ? options : options?.name\n if (requestedModelName != null) {\n throw new Error(`No model registry configured. Requested model: ${requestedModelName}`)\n }\n\n throw new Error(`No model registry configured for task inferenceExecutor id \"${task.inferenceExecutor.id}\".`)\n },\n }\n}\n\n/**\n * Error thrown when a scheduled run fails before producing a normalized result.\n */\nexport class RunnerExecutionError extends Error {\n /**\n * Stable task id that failed.\n */\n taskId: string\n\n constructor(taskId: string, cause: unknown) {\n const message = errorMessageFrom(cause) ?? 'Unknown runner execution failure.'\n super(`Runner task \"${taskId}\" failed: ${message}`)\n this.name = 'RunnerExecutionError'\n this.taskId = taskId\n this.cause = cause\n }\n}\n\nfunction createRunnerExecutionError(taskId: string, cause: unknown): RunnerExecutionError {\n if (cause instanceof RunnerExecutionError && cause.taskId === taskId) {\n return cause\n }\n\n return new RunnerExecutionError(taskId, cause)\n}\n\n/**\n * Executes runner tasks sequentially and aggregates the normalized results.\n *\n * Call stack:\n *\n * {@link createRunnerSchedule}\n * -> {@link runScheduledTasks}\n * -> `executor(task)`\n * -> {@link aggregateRunResults}\n *\n * Use when:\n * - the caller already expanded the runner matrix\n * - task execution should stay deterministic and easy to debug\n *\n * Expects:\n * - `executor` to return normalized `0..1` scores\n * - callers to handle concurrency outside this helper when needed\n * - `onTaskStart` / `onTaskEnd` hooks to be synchronous lifecycle observers\n *\n * Throws:\n * - `RunnerExecutionError` when task setup, hooks, or the executor throws\n */\nexport async function runScheduledTasks(\n tasks: readonly ScheduledTask[],\n executor: ScheduledTaskExecutor,\n options: RunScheduledTasksOptions = {},\n): Promise<AggregatedRunResults> {\n if (tasks.length === 0) {\n return aggregateRunResults([])\n }\n\n async function executeScheduledTask(task: ScheduledTask): Promise<RunResult> {\n let executionContext: TaskExecutionContext\n\n try {\n executionContext = options.createExecutionContext?.(task) ?? createDefaultExecutionContext(task)\n }\n catch (error) {\n throw createRunnerExecutionError(task.id, error)\n }\n\n try {\n options.onTaskStart?.(task)\n }\n catch (error) {\n throw createRunnerExecutionError(task.id, error)\n }\n\n let runResult: RunResult\n try {\n runResult = await executor(task, executionContext)\n }\n catch (error) {\n try {\n options.onTaskEnd?.(task, 'failed')\n }\n catch {\n // Failed-task observers must not mask the task execution failure.\n }\n throw createRunnerExecutionError(task.id, error)\n }\n\n try {\n options.onTaskEnd?.(task, 'passed')\n }\n catch (error) {\n throw createRunnerExecutionError(task.id, error)\n }\n\n return runResult\n }\n\n const maxConcurrency = options.maxConcurrency ?? 1\n if (maxConcurrency <= 1) {\n const results: RunResult[] = []\n for (const task of tasks) {\n results.push(await executeScheduledTask(task))\n }\n return aggregateRunResults(results)\n }\n\n const runWithLimit = limitConcurrency(maxConcurrency)\n const resultPairs = await Promise.all(tasks.map(async (task, index) => {\n const result = await runWithLimit(async () => executeScheduledTask(task))\n return { index, result }\n }))\n\n const sortedResults = resultPairs\n .sort((left, right) => left.index - right.index)\n .map(item => item.result)\n\n return aggregateRunResults(sortedResults)\n}\n","import { createRequire } from 'node:module'\nimport { dirname } from 'node:path'\nimport { fileURLToPath } from 'node:url'\n\nconst require = createRequire(import.meta.url)\n\n/**\n * Shared runtime context used by the vieval runner.\n *\n * Use when:\n * - runner services need stable path resolution without module-level side effects\n * - call sites want deterministic control over workspace root detection\n */\nexport interface RunnerRuntimeContext {\n /**\n * Absolute project root directory used for path normalization.\n */\n projectRootDirectory: string\n}\n\n/**\n * Options used to construct the runner runtime context.\n */\nexport interface CreateVievalRunnerRuntimeContextOptions {\n /**\n * Directory used to search for the nearest pnpm workspace.\n *\n * @default directory of this module file\n */\n cwd?: string\n /**\n * Absolute fallback directory when a pnpm workspace root is not found.\n *\n * @default package root directory (`packages/vieval`)\n */\n fallbackProjectRootDirectory?: string\n}\n\n/**\n * Creates a side-effect-free runtime context for runner path normalization.\n *\n * Call stack:\n *\n * {@link createRunnerRuntimeContext}\n * -> `findWorkspaceDir(cwd)`\n * -> `resolve projectRootDirectory`\n * -> `{ projectRootDirectory }`\n *\n * Use when:\n * - initializing runner infrastructure before collecting eval modules\n * - tests need deterministic root resolution behavior\n */\nexport async function createRunnerRuntimeContext(\n options: CreateVievalRunnerRuntimeContextOptions = {},\n): Promise<RunnerRuntimeContext> {\n const cwd = options.cwd ?? dirname(fileURLToPath(import.meta.url))\n const fallbackProjectRootDirectory = options.fallbackProjectRootDirectory\n ?? fileURLToPath(new URL('../../../', import.meta.url))\n\n // NOTICE:\n // We use dynamic `require` here because `@pnpm/find-workspace-dir` is CommonJS.\n // Keeping this load inside the factory avoids module-level initialization side effects.\n const { findWorkspaceDir } = require('@pnpm/find-workspace-dir') as {\n findWorkspaceDir: (currentWorkingDirectory: string) => Promise<string | undefined>\n }\n\n // NOTICE:\n // Workspace discovery is required to keep collected eval ids stable when this\n // package is moved inside different monorepo layouts.\n const workspaceDirectory = await findWorkspaceDir(cwd)\n\n return {\n projectRootDirectory: workspaceDirectory ?? fallbackProjectRootDirectory,\n }\n}\n","import type { CollectedEvalEntry, MatrixDefinition, MatrixLayer, MatrixValue } from '../../config'\n\n/**\n * Describes the inferenceExecutor target for a scheduled eval run.\n */\nexport interface InferenceExecutor {\n /**\n * Stable inferenceExecutor identifier such as `openai:gpt-4.1-mini`.\n */\n id: string\n}\n\n/**\n * Stores the selected value for each matrix axis.\n */\nexport type RunnerMatrixSelection = Record<string, string>\n\n/**\n * Stores stable row ids for one resolved scheduled task matrix.\n */\nexport interface ScheduledTaskMatrixMeta {\n /**\n * Stable row id for the resolved run matrix selection.\n */\n runRowId: string\n /**\n * Stable row id for the resolved eval matrix selection.\n */\n evalRowId: string\n}\n\n/**\n * Stores the structured matrix payload for one scheduled task.\n */\nexport interface ScheduledTaskMatrix {\n /**\n * Runtime matrix selection visible to task code.\n */\n run: RunnerMatrixSelection\n /**\n * Eval-time matrix selection visible to task code.\n */\n eval: RunnerMatrixSelection\n /**\n * Stable row ids for both scopes.\n */\n meta: ScheduledTaskMatrixMeta\n}\n\n/**\n * Maps matrix axis names to the values that should be expanded.\n */\nexport type RunnerMatrixDefinition = MatrixDefinition\n\n/**\n * Accepts either flat axis definitions or one layered matrix object.\n */\nexport type RunnerMatrixInput = RunnerMatrixDefinition | MatrixLayer\n\nconst matrixLayerKeys = new Set(['disable', 'extend', 'override'])\nconst ambiguousMatrixDefinitionErrorMessage = 'Ambiguous matrix definition: cannot mix reserved layer keys (disable, extend, override) with matrix axis keys.'\n\n/**\n * Represents one fully expanded runner task.\n */\nexport interface ScheduledTask {\n /**\n * Stable task id derived from the entry, inferenceExecutor, and matrix selection.\n */\n id: string\n /**\n * The collected eval entry to execute.\n */\n entry: CollectedEvalEntry\n /**\n * The inferenceExecutor selected for this task.\n */\n inferenceExecutor: InferenceExecutor\n /**\n * The concrete scoped matrix selection for this task.\n */\n matrix: ScheduledTaskMatrix\n}\n\n/**\n * Configures how the runner should expand its execution matrix.\n */\nexport interface CreateRunnerScheduleOptions {\n /**\n * Collected eval entries that should be scheduled.\n */\n entries: readonly CollectedEvalEntry[]\n /**\n * Providers that should run each entry.\n */\n inferenceExecutors: readonly InferenceExecutor[]\n /**\n * Optional run-time matrix axes expanded as a cartesian product.\n */\n runMatrix?: RunnerMatrixInput\n /**\n * Optional eval-time matrix axes expanded as a cartesian product.\n */\n evalMatrix?: RunnerMatrixInput\n}\n\nfunction encodeTaskIdSegment(value: string): string {\n return encodeURIComponent(value)\n}\n\nfunction stringifyMatrixValue(value: MatrixValue): string {\n return String(value)\n}\n\nfunction cloneMatrixSelection(matrix: RunnerMatrixSelection): RunnerMatrixSelection {\n return { ...matrix }\n}\n\nfunction createScheduledTaskMatrix(\n runMatrix: RunnerMatrixSelection,\n evalMatrix: RunnerMatrixSelection,\n): ScheduledTaskMatrix {\n return {\n eval: cloneMatrixSelection(evalMatrix),\n meta: {\n evalRowId: createStableRowId(evalMatrix),\n runRowId: createStableRowId(runMatrix),\n },\n run: cloneMatrixSelection(runMatrix),\n }\n}\n\nfunction isMatrixLayer(matrix: RunnerMatrixInput): matrix is MatrixLayer {\n const matrixKeys = Object.keys(matrix)\n return (\n matrixKeys.length > 0\n && matrixKeys.every(key => matrixLayerKeys.has(key))\n )\n}\n\nfunction assertNonAmbiguousMatrixDefinition(matrix: RunnerMatrixInput): void {\n const matrixKeys = Object.keys(matrix)\n const hasReservedKeys = matrixKeys.some(key => matrixLayerKeys.has(key))\n const hasAxisKeys = matrixKeys.some(key => !matrixLayerKeys.has(key))\n\n if (hasReservedKeys && hasAxisKeys) {\n throw new TypeError(ambiguousMatrixDefinitionErrorMessage)\n }\n}\n\nfunction normalizeLayerInputToAxes(matrix: RunnerMatrixInput | undefined): MatrixLayer | undefined {\n if (matrix == null) {\n return undefined\n }\n\n assertNonAmbiguousMatrixDefinition(matrix)\n\n if (isMatrixLayer(matrix)) {\n return matrix\n }\n\n return {\n extend: matrix,\n }\n}\n\nfunction dedupeAxisValues(values: readonly MatrixValue[]): string[] {\n return Array.from(new Set(values.map(stringifyMatrixValue)))\n}\n\nfunction applyAxisValues(\n axes: Map<string, string[]>,\n definition: RunnerMatrixDefinition | undefined,\n mode: 'extend' | 'override',\n): void {\n if (definition == null) {\n return\n }\n\n for (const [axis, values] of Object.entries(definition)) {\n const nextValues = dedupeAxisValues(values)\n\n if (mode === 'extend') {\n const existingValues = axes.get(axis) ?? []\n axes.set(axis, Array.from(new Set([...existingValues, ...nextValues])))\n continue\n }\n\n axes.set(axis, nextValues)\n }\n}\n\nfunction applyLayer(\n baseAxes: ReadonlyMap<string, string[]>,\n layer: MatrixLayer | undefined,\n): Map<string, string[]> {\n const nextAxes = new Map<string, string[]>(\n Array.from(baseAxes.entries()).map(([axis, values]) => [axis, [...values]]),\n )\n\n for (const axis of layer?.disable ?? []) {\n nextAxes.delete(axis)\n }\n\n applyAxisValues(nextAxes, layer?.extend, 'extend')\n applyAxisValues(nextAxes, layer?.override, 'override')\n\n return nextAxes\n}\n\nfunction expandAxesToRows(axes: ReadonlyMap<string, readonly string[]>): RunnerMatrixSelection[] {\n if (axes.size === 0) {\n return [{}]\n }\n\n const dimensions = Array.from(axes.entries())\n\n let selections: RunnerMatrixSelection[] = [{}]\n\n for (const [axis, values] of dimensions) {\n if (values.length === 0) {\n return []\n }\n\n const nextSelections: RunnerMatrixSelection[] = []\n\n for (const selection of selections) {\n for (const value of values) {\n nextSelections.push({\n ...selection,\n [axis]: value,\n })\n }\n }\n\n selections = nextSelections\n }\n\n return selections\n}\n\nfunction createStableRowId(matrix: RunnerMatrixSelection): string {\n const segments = Object.entries(matrix)\n .sort(([leftAxis], [rightAxis]) => leftAxis.localeCompare(rightAxis))\n .map(([axis, value]) => `${encodeTaskIdSegment(axis)}=${encodeTaskIdSegment(value)}`)\n\n if (segments.length === 0) {\n return 'default'\n }\n\n return segments.join('&')\n}\n\nfunction createTaskId(entryId: string, inferenceExecutorId: string, runRowId: string, evalRowId: string): string {\n const encodedEntryId = encodeTaskIdSegment(entryId)\n const encodedProviderId = encodeTaskIdSegment(inferenceExecutorId)\n\n return [\n encodedEntryId,\n encodedProviderId,\n `run=${encodeTaskIdSegment(runRowId)}`,\n `eval=${encodeTaskIdSegment(evalRowId)}`,\n ].join('::')\n}\n\nfunction createResolvedRunAxes(\n entry: CollectedEvalEntry,\n runMatrix: RunnerMatrixInput | undefined,\n): Map<string, string[]> {\n let resolvedAxes = new Map<string, string[]>()\n\n for (const layerInput of [\n runMatrix,\n entry.matrix?.runMatrix,\n entry.task?.matrix?.runMatrix,\n ]) {\n resolvedAxes = applyLayer(resolvedAxes, normalizeLayerInputToAxes(layerInput))\n }\n\n return resolvedAxes\n}\n\nfunction createResolvedEvalAxes(\n entry: CollectedEvalEntry,\n evalMatrix: RunnerMatrixInput | undefined,\n): Map<string, string[]> {\n let resolvedAxes = new Map<string, string[]>()\n\n for (const layerInput of [\n evalMatrix,\n entry.matrix?.evalMatrix,\n entry.task?.matrix?.evalMatrix,\n ]) {\n resolvedAxes = applyLayer(resolvedAxes, normalizeLayerInputToAxes(layerInput))\n }\n\n return resolvedAxes\n}\n\n/**\n * Expands collected entries into a stable runner schedule.\n *\n * Call stack:\n *\n * {@link collectEvalEntries} (`../runner`)\n * -> {@link createRunnerSchedule}\n * -> {@link expandAxesToRows}\n * -> {@link ScheduledTask}[]\n *\n * Use when:\n * - the runner already knows which eval entries are available\n * - each entry must run against multiple inferenceExecutors or matrix variants\n *\n * Expects:\n * - `entries` and `inferenceExecutors` to be provided in the desired execution order\n * - matrix axes to use insertion order when generating combinations\n */\nexport function createRunnerSchedule(options: CreateRunnerScheduleOptions): ScheduledTask[] {\n if (options.entries.length === 0) {\n return []\n }\n\n if (options.inferenceExecutors.length === 0) {\n return []\n }\n\n const tasks: ScheduledTask[] = []\n\n for (const entry of options.entries) {\n const runSelections = expandAxesToRows(createResolvedRunAxes(entry, options.runMatrix))\n const evalSelections = expandAxesToRows(createResolvedEvalAxes(entry, options.evalMatrix))\n\n if (runSelections.length === 0 || evalSelections.length === 0) {\n continue\n }\n\n for (const inferenceExecutor of options.inferenceExecutors) {\n for (const runMatrix of runSelections) {\n for (const evalMatrix of evalSelections) {\n const isolatedMatrix = createScheduledTaskMatrix(runMatrix, evalMatrix)\n\n tasks.push({\n entry,\n id: createTaskId(\n entry.id,\n inferenceExecutor.id,\n isolatedMatrix.meta.runRowId,\n isolatedMatrix.meta.evalRowId,\n ),\n matrix: isolatedMatrix,\n inferenceExecutor,\n })\n }\n }\n }\n }\n\n return tasks\n}\n","import type { ModelDefinition } from '../../config/models'\nimport type { TaskCacheRuntime } from '../cache'\nimport type { ScheduledTask } from './schedule'\n\nimport { resolveModelByName } from '../../config/models'\n\n/**\n * Options for selecting a model from the execution context.\n */\nexport interface TaskModelSelectionOptions {\n /**\n * Model id or alias name.\n */\n name: string\n}\n\n/**\n * Task-scoped execution context exposed to runner executors.\n */\nexport interface TaskExecutionContext {\n /**\n * Deterministic cache runtime scoped to the current task project.\n */\n cache: TaskCacheRuntime\n /**\n * Resolves model configuration for the current task.\n *\n * Use when:\n * - no arguments are provided to use the model selected by run matrix/inferenceExecutor\n * - `name` is provided to resolve a specific model id or alias\n */\n model: (\n selection?: string | TaskModelSelectionOptions,\n ) => ModelDefinition\n}\n\n/**\n * Inputs used to build task execution context.\n */\nexport interface CreateTaskExecutionContextOptions {\n cache?: TaskCacheRuntime\n models: readonly ModelDefinition[]\n task: ScheduledTask\n}\n\nfunction createNoopTaskCacheRuntime(): TaskCacheRuntime {\n return {\n namespace(name) {\n return {\n file(options) {\n const key = options.key.join('/')\n throw new Error(`Task cache runtime is not configured. Requested namespace \"${name}\" and key \"${key}\".`)\n },\n }\n },\n }\n}\n\nfunction resolveDefaultTaskModel(\n models: readonly ModelDefinition[],\n task: ScheduledTask,\n): ModelDefinition {\n const runMatrixModelName = task.matrix.run.model\n if (runMatrixModelName != null) {\n const matrixSelectedModel = resolveModelByName(models, runMatrixModelName)\n if (matrixSelectedModel != null) {\n return matrixSelectedModel\n }\n\n throw new Error(`Unknown configured model \"${runMatrixModelName}\" from task.matrix.run.model.`)\n }\n\n const matched = resolveModelByName(models, task.inferenceExecutor.id)\n if (matched != null) {\n return matched\n }\n\n if (models.length > 1) {\n throw new Error(\n [\n `Multiple configured models are available, but no default model is selected for inferenceExecutor \"${task.inferenceExecutor.id}\".`,\n 'Select one model explicitly by either:',\n '- setting runMatrix.override.model (or task matrix run.model)',\n '- setting project.inferenceExecutors to a matching model id',\n '- calling context.model({ name: \"your-model-id-or-alias\" })',\n ].join('\\n'),\n )\n }\n\n if (models.length === 1) {\n const firstModel = models[0]\n if (firstModel != null) {\n return firstModel\n }\n }\n\n throw new Error(`No configured model found for inferenceExecutor id \"${task.inferenceExecutor.id}\".`)\n}\n\n/**\n * Creates task-scoped model resolver context for runner execution.\n *\n * Call stack:\n *\n * {@link runScheduledTasks}\n * -> {@link createTaskExecutionContext}\n * -> {@link resolveModelByName}\n * -> `task.model()` / `task.model({ name })`\n */\nexport function createTaskExecutionContext(options: CreateTaskExecutionContextOptions): TaskExecutionContext {\n return {\n cache: options.cache ?? createNoopTaskCacheRuntime(),\n model(selection) {\n if (selection == null) {\n return resolveDefaultTaskModel(options.models, options.task)\n }\n\n const name = typeof selection === 'string' ? selection : selection.name\n\n const namedModel = resolveModelByName(options.models, name)\n if (namedModel == null) {\n throw new Error(`Unknown configured model \"${name}\".`)\n }\n\n return namedModel\n },\n }\n}\n"],"mappings":";;;;;;;;;;;AA2BA,SAAS,oBAAoB,OAAuB;CAClD,MAAM,aAAa,MAAM,MAAM;AAC/B,KAAI,WAAW,WAAW,EACxB,QAAO;AAGT,QAAO,WAAW,QAAQ,aAAa,IAAI;;AAG7C,SAAS,mBAAmB,WAA+B,WAAmD;AAC5G,KAAI,aAAa,QAAQ,UAAU,SAAS,EAC1C,QAAO,UAAU,WAAW,IAAI,GAAG,UAAU,MAAM,EAAE,GAAG;AAG1D,KAAI,aAAa,QAAQ,UAAU,WAAW,EAC5C;AAGF,KAAI,cAAc,mBAChB,QAAO;AAGT,KAAI,cAAc,aAChB,QAAO;AAGT,KAAI,cAAc,YAChB,QAAO;;;;;;;;;;;AAeX,SAAgB,+BAA+B,SAAqC;CAClF,MAAM,eAAe,QAAQ,IAAI,KAAI,YAAW,oBAAoB,QAAQ,CAAC;CAC7E,MAAM,YAAY,mBAAmB,QAAQ,KAAK,QAAQ,UAAU;AAEpE,KAAI,aAAa,WAAW,EAC1B,QAAO,aAAa,OAAO,CAAC,WAAW,GAAG,CAAC,YAAY,YAAY;AAGrE,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,QAAQ,KAAK;GAG9D,MAAM,OAAO,OAAO,cAAc,WAAW,YAAY,UAAU;GAEnE,MAAM,aAAa,mBAAmB,QAAQ,QAAQ,KAAK;AAC3D,OAAI,cAAc,KAChB,OAAM,IAAI,MAAM,6BAA6B,KAAK,IAAI;AAGxD,UAAO;;EAEV"}
|
|
1
|
+
{"version":3,"file":"index.mjs","names":[],"sources":["../../../src/core/cache/filesystem.ts","../../../src/core/runner/aggregate.ts","../../../src/core/runner/collect.ts","../../../src/core/runner/run.ts","../../../src/core/runner/runtime-context.ts","../../../src/core/runner/schedule.ts","../../../src/core/runner/task-context.ts"],"sourcesContent":["import type { CacheFileHandle, CacheFileOptions, CacheNamespace, TaskCacheRuntime } from './types'\n\nimport process from 'node:process'\n\nimport { Buffer } from 'node:buffer'\nimport { createReadStream, createWriteStream } from 'node:fs'\nimport { access, mkdir, readFile, rename, writeFile } from 'node:fs/promises'\nimport { dirname, join } from 'node:path'\n\n/**\n * Options for creating the filesystem-backed task cache runtime.\n */\nexport interface CreateFilesystemTaskCacheRuntimeOptions {\n /**\n * Absolute cache root directory.\n */\n cacheRootDirectory: string\n /**\n * Project identifier under one workspace cache scope.\n */\n projectName: string\n /**\n * Workspace identifier used to share cache roots across projects.\n */\n workspaceId: string\n}\n\nfunction sanitizePathSegment(value: string): string {\n const normalized = value.trim()\n if (normalized.length === 0) {\n return 'default'\n }\n\n return normalized.replace(/[^\\w.-]+/g, '-')\n}\n\nfunction normalizeExtension(extension: string | undefined, mediaType: string | undefined): string | undefined {\n if (extension != null && extension.length > 0) {\n return extension.startsWith('.') ? extension.slice(1) : extension\n }\n\n if (mediaType == null || mediaType.length === 0) {\n return undefined\n }\n\n if (mediaType === 'application/json') {\n return 'json'\n }\n\n if (mediaType === 'text/plain') {\n return 'txt'\n }\n\n if (mediaType === 'audio/wav') {\n return 'wav'\n }\n\n return undefined\n}\n\n/**\n * Normalizes cache file options into deterministic relative path segments.\n *\n * Before:\n * - `{ key: ['cases', 'dataset hash', 'v1'], ext: 'json' }`\n *\n * After:\n * - `['cases', 'dataset-hash', 'v1.json']`\n */\nexport function normalizeCacheFilePathSegments(options: CacheFileOptions): string[] {\n const sanitizedKey = options.key.map(segment => sanitizePathSegment(segment))\n const extension = normalizeExtension(options.ext, options.mediaType)\n\n if (sanitizedKey.length === 0) {\n return extension == null ? ['artifact'] : [`artifact.${extension}`]\n }\n\n if (extension == null) {\n return sanitizedKey\n }\n\n const withoutTail = sanitizedKey.slice(0, Math.max(0, sanitizedKey.length - 1))\n const tail = sanitizedKey[sanitizedKey.length - 1] ?? 'artifact'\n return [...withoutTail, `${tail}.${extension}`]\n}\n\nasync function writeAtomically(path: string, content: Buffer | string): Promise<void> {\n const directory = dirname(path)\n const temporaryPath = `${path}.tmp-${process.pid}-${Date.now()}-${Math.random().toString(36).slice(2, 10)}`\n await mkdir(directory, { recursive: true })\n await writeFile(temporaryPath, content)\n await rename(temporaryPath, path)\n}\n\nfunction createCacheFileHandle(path: string): CacheFileHandle {\n return {\n path,\n async exists() {\n try {\n await access(path)\n return true\n }\n catch {\n return false\n }\n },\n openReadStream() {\n return createReadStream(path)\n },\n async openWriteStream() {\n await mkdir(dirname(path), { recursive: true })\n return createWriteStream(path)\n },\n async readBuffer() {\n return await readFile(path)\n },\n async writeBuffer(value) {\n await writeAtomically(path, value)\n },\n async readText(encoding = 'utf-8') {\n return await readFile(path, encoding)\n },\n async writeText(value, encoding = 'utf-8') {\n await writeAtomically(path, Buffer.from(value, encoding))\n },\n async readJson<T>() {\n return JSON.parse(await readFile(path, 'utf-8')) as T\n },\n async writeJson(value) {\n await writeAtomically(path, `${JSON.stringify(value, null, 2)}\\n`)\n },\n async loadAsCasesInput<T>() {\n return await this.readJson<T[]>()\n },\n async loadAsExpectFixture<T>() {\n return await this.readJson<T>()\n },\n }\n}\n\nfunction createCacheNamespace(baseDirectory: string, namespace: string): CacheNamespace {\n return {\n file(options) {\n const relativePathSegments = normalizeCacheFilePathSegments(options)\n return createCacheFileHandle(join(baseDirectory, sanitizePathSegment(namespace), ...relativePathSegments))\n },\n }\n}\n\n/**\n * Creates a deterministic filesystem-backed task cache runtime.\n *\n * Use when:\n * - eval tasks need reproducible cache paths for expensive pre-processing outputs\n * - benchmark adapters need one artifact-oriented API for text/json/binary reads and writes\n *\n * Expects:\n * - `cacheRootDirectory` to be writable by the running process\n * - `workspaceId` + `projectName` to stay stable for reproducible paths\n *\n * Returns:\n * - task cache runtime that resolves namespaced file handles under:\n * `<cacheRootDirectory>/<workspaceId>/<projectName>/<namespace>/...`\n */\nexport function createFilesystemTaskCacheRuntime(\n options: CreateFilesystemTaskCacheRuntimeOptions,\n): TaskCacheRuntime {\n const workspaceDirectory = sanitizePathSegment(options.workspaceId)\n const projectDirectory = sanitizePathSegment(options.projectName)\n const baseDirectory = join(options.cacheRootDirectory, workspaceDirectory, projectDirectory)\n\n return {\n namespace(name) {\n return createCacheNamespace(baseDirectory, name)\n },\n }\n}\n","import type { ScheduledTaskMatrix } from './schedule'\n\n/**\n * Identifies the scoring family for a single eval score.\n */\nexport type RunScoreKind = 'exact' | 'judge'\n\n/**\n * Represents one normalized score emitted by a completed eval run.\n */\nexport interface RunScore {\n /**\n * Score family used for aggregation.\n */\n kind: RunScoreKind\n /**\n * Normalized score in the `0..1` range.\n */\n score: number\n}\n\n/**\n * Captures the output of one scheduled runner task.\n */\nexport interface RunResult {\n /**\n * Stable run id, usually copied from the scheduled task id.\n */\n id: string\n /**\n * Collected eval entry id.\n */\n entryId: string\n /**\n * Stable inferenceExecutor id.\n */\n inferenceExecutorId: string\n /**\n * Concrete matrix selection used by the run.\n */\n matrix: ScheduledTaskMatrix\n /**\n * Raw scores emitted by the eval.\n */\n scores: readonly RunScore[]\n}\n\n/**\n * Stores the per-run score averages after normalization.\n */\nexport interface AggregatedRunSummary {\n /**\n * Stable run id.\n */\n id: string\n /**\n * Collected eval entry id.\n */\n entryId: string\n /**\n * Stable inferenceExecutor id.\n */\n inferenceExecutorId: string\n /**\n * Concrete matrix selection used by the run.\n */\n matrix: ScheduledTaskMatrix\n /**\n * Mean of exact-match scores or `null` when absent.\n */\n exactAverage: number | null\n /**\n * Mean of judge-based scores or `null` when absent.\n */\n judgeAverage: number | null\n /**\n * Hybrid average. Uses both families when present, otherwise falls back to the\n * single available family.\n */\n hybridAverage: number | null\n}\n\n/**\n * Stores inferenceExecutor-level score aggregates across multiple runs.\n */\nexport interface AggregatedProviderSummary {\n /**\n * Stable inferenceExecutor id.\n */\n inferenceExecutorId: string\n /**\n * Number of runs included in this inferenceExecutor bucket.\n */\n runCount: number\n /**\n * Mean of all exact-match scores or `null` when absent.\n */\n exactAverage: number | null\n /**\n * Mean of all judge-based scores or `null` when absent.\n */\n judgeAverage: number | null\n /**\n * Hybrid average derived from the inferenceExecutor exact and judge means.\n */\n hybridAverage: number | null\n}\n\n/**\n * Stores the final aggregation output for a batch of runner results.\n */\nexport interface AggregatedRunResults {\n /**\n * Per-run normalized score summaries.\n */\n runs: AggregatedRunSummary[]\n /**\n * Provider-level summaries sorted by inferenceExecutor id.\n */\n inferenceExecutors: AggregatedProviderSummary[]\n /**\n * Overall summary across every run.\n */\n overall: {\n exactAverage: number | null\n judgeAverage: number | null\n hybridAverage: number | null\n runCount: number\n }\n}\n\ninterface ScoreBuckets {\n exact: number[]\n judge: number[]\n}\n\nfunction cloneScheduledTaskMatrix(matrix: ScheduledTaskMatrix): ScheduledTaskMatrix {\n return {\n eval: {\n ...matrix.eval,\n },\n meta: {\n ...matrix.meta,\n },\n run: {\n ...matrix.run,\n },\n }\n}\n\nfunction assertKnownScoreKind(kind: string): RunScoreKind {\n if (kind === 'exact' || kind === 'judge') {\n return kind\n }\n\n throw new TypeError(`Unknown eval score kind \"${kind}\".`)\n}\n\nfunction average(scores: readonly number[]): number | null {\n if (scores.length === 0) {\n return null\n }\n\n const total = scores.reduce((sum, score) => sum + score, 0)\n return total / scores.length\n}\n\nfunction createHybridAverage(exactAverage: number | null, judgeAverage: number | null): number | null {\n if (exactAverage != null && judgeAverage != null) {\n return (exactAverage + judgeAverage) / 2\n }\n\n if (exactAverage != null) {\n return exactAverage\n }\n\n if (judgeAverage != null) {\n return judgeAverage\n }\n\n return null\n}\n\nfunction collectScoreBuckets(scores: readonly RunScore[]): ScoreBuckets {\n const buckets: ScoreBuckets = {\n exact: [],\n judge: [],\n }\n\n for (const score of scores) {\n const kind = assertKnownScoreKind(score.kind)\n\n if (kind === 'exact') {\n buckets.exact.push(score.score)\n continue\n }\n\n buckets.judge.push(score.score)\n }\n\n return buckets\n}\n\nfunction createRunSummary(result: RunResult): AggregatedRunSummary {\n const buckets = collectScoreBuckets(result.scores)\n const exactAverage = average(buckets.exact)\n const judgeAverage = average(buckets.judge)\n\n return {\n entryId: result.entryId,\n exactAverage,\n hybridAverage: createHybridAverage(exactAverage, judgeAverage),\n id: result.id,\n judgeAverage,\n matrix: cloneScheduledTaskMatrix(result.matrix),\n inferenceExecutorId: result.inferenceExecutorId,\n }\n}\n\nfunction createProviderSummary(inferenceExecutorId: string, results: readonly RunResult[]): AggregatedProviderSummary {\n const exactScores: number[] = []\n const judgeScores: number[] = []\n\n for (const result of results) {\n const buckets = collectScoreBuckets(result.scores)\n exactScores.push(...buckets.exact)\n judgeScores.push(...buckets.judge)\n }\n\n const exactAverage = average(exactScores)\n const judgeAverage = average(judgeScores)\n\n return {\n exactAverage,\n hybridAverage: createHybridAverage(exactAverage, judgeAverage),\n judgeAverage,\n inferenceExecutorId,\n runCount: results.length,\n }\n}\n\n/**\n * Aggregates exact-match and judge-based scores into hybrid runner summaries.\n *\n * Call stack:\n *\n * {@link runScheduledTasks}\n * -> {@link aggregateRunResults}\n * -> {@link createRunSummary}\n * -> {@link createProviderSummary}\n * -> `report output`\n *\n * Use when:\n * - a runner batch mixes deterministic exact checks with judge-based grading\n * - inferenceExecutor comparison should preserve both score families and one hybrid view\n *\n * Expects:\n * - each score to be normalized to the `0..1` range before aggregation\n * - `scores.kind` to use only `'exact'` or `'judge'`\n */\nexport function aggregateRunResults(results: readonly RunResult[]): AggregatedRunResults {\n const runs = results.map(createRunSummary)\n\n const inferenceExecutorIds = Array.from(new Set(results.map(result => result.inferenceExecutorId)))\n const inferenceExecutors = inferenceExecutorIds\n .map((inferenceExecutorId) => {\n const providerResults = results.filter(result => result.inferenceExecutorId === inferenceExecutorId)\n return createProviderSummary(inferenceExecutorId, providerResults)\n })\n .sort((left, right) => left.inferenceExecutorId.localeCompare(right.inferenceExecutorId))\n\n const overall = createProviderSummary(\n 'overall',\n results,\n )\n\n return {\n overall: {\n exactAverage: overall.exactAverage,\n hybridAverage: overall.hybridAverage,\n judgeAverage: overall.judgeAverage,\n runCount: overall.runCount,\n },\n inferenceExecutors,\n runs,\n }\n}\n","import type { CollectedEvalEntry, EvalModule, EvalModuleMap } from '../../config'\nimport type { RunnerRuntimeContext } from './runtime-context'\n\nimport { basename, dirname, relative } from 'node:path'\nimport { fileURLToPath } from 'node:url'\n\nconst evalFileSuffix = '.eval.ts'\nconst absolutePathPattern = /^(?:[A-Z]:\\/|\\/|\\\\\\\\)/i\n\nfunction normalizePath(value: string): string {\n return value.replaceAll('\\\\', '/')\n}\n\n/**\n * Converts a file path into a project-relative path when possible.\n *\n * Before: `/repo/plugins/airi-plugin-game-chess/src/agent/evals/chess-commentary.eval.ts`\n * After: `plugins/airi-plugin-game-chess/src/agent/evals/chess-commentary.eval.ts`\n *\n * Before: `D:/repo/plugins/airi-plugin-game-chess/src/agent/evals/chess-commentary.eval.ts`\n * After: `D:/repo/plugins/airi-plugin-game-chess/src/agent/evals/chess-commentary.eval.ts`\n */\nexport function asProjectRelativePath(filePath: string, context: RunnerRuntimeContext): string {\n const normalizedFilePath = normalizePath(filePath)\n const normalizedProjectRootDirectory = normalizePath(context.projectRootDirectory)\n const filePathWindowsDrive = normalizedFilePath.match(/^[A-Z]:\\//i)?.[0]\n const projectRootWindowsDrive = normalizedProjectRootDirectory.match(/^[A-Z]:\\//i)?.[0]\n\n if (filePathWindowsDrive != null && projectRootWindowsDrive == null) {\n return normalizedFilePath\n }\n\n if (\n filePathWindowsDrive != null\n && projectRootWindowsDrive != null\n && filePathWindowsDrive.toLowerCase() !== projectRootWindowsDrive.toLowerCase()\n ) {\n return normalizedFilePath\n }\n\n const projectRootDirectory = context.projectRootDirectory\n const relativeFilePath = normalizePath(relative(projectRootDirectory, filePath))\n\n if (!absolutePathPattern.test(relativeFilePath)) {\n if (relativeFilePath === '..') {\n return normalizePath(filePath)\n }\n\n if (!relativeFilePath.startsWith('../')) {\n return relativeFilePath\n }\n }\n\n return normalizePath(filePath)\n}\n\nfunction resolveModuleFilePath(moduleHref: string): string | null {\n if (!moduleHref.startsWith('file:')) {\n return null\n }\n\n try {\n return fileURLToPath(moduleHref)\n }\n catch {\n return null\n }\n}\n\nfunction createCollectedEvalEntry(\n moduleHref: string,\n moduleDefinition: EvalModule,\n context: RunnerRuntimeContext,\n): CollectedEvalEntry | null {\n const filePath = resolveModuleFilePath(moduleHref)\n\n if (!filePath) {\n return null\n }\n\n const relativeFilePath = asProjectRelativePath(filePath, context)\n\n if (!relativeFilePath.endsWith(evalFileSuffix)) {\n return null\n }\n\n const entryName = basename(relativeFilePath, evalFileSuffix)\n\n if (entryName.length === 0) {\n return null\n }\n\n const relativeDirectory = dirname(relativeFilePath)\n const directory = relativeDirectory === '.' ? '' : relativeDirectory\n\n return {\n ...moduleDefinition.default,\n directory,\n filePath,\n id: directory.length === 0 ? entryName : `${directory}/${entryName}`,\n name: entryName,\n }\n}\n\n/**\n * Collects loaded vieval modules into sorted runner entries with stable ids.\n *\n * Call stack:\n *\n * `import.meta.glob(...)`\n * -> {@link collectEvalEntries}\n * -> {@link createCollectedEvalEntry}\n * -> {@link CollectedEvalEntry}[]\n *\n * Use when:\n * - the runner has already loaded candidate eval modules\n * - downstream scheduling needs stable entry ids and directory metadata\n */\nexport function collectEvalEntries(\n modules: EvalModuleMap,\n context: RunnerRuntimeContext,\n): CollectedEvalEntry[] {\n return Object.entries(modules)\n .flatMap(([moduleHref, moduleDefinition]) => {\n const entry = createCollectedEvalEntry(moduleHref, moduleDefinition, context)\n\n if (!entry) {\n return []\n }\n\n return [entry]\n })\n .sort((left, right) => left.id.localeCompare(right.id))\n}\n","import type { TaskCacheRuntime } from '../cache'\nimport type { AggregatedRunResults, RunResult } from './aggregate'\nimport type { ScheduledTask } from './schedule'\nimport type { TaskExecutionContext } from './task-context'\n\nimport { errorMessageFrom } from '@moeru/std'\nimport { limitConcurrency } from '@vitest/runner/utils'\n\nimport { aggregateRunResults } from './aggregate'\n\n/**\n * Executes one scheduled runner task and returns a normalized run result.\n *\n * Use when:\n * - a scheduler already selected the task and execution context\n * - the caller wants a typed executor contract for runner workers\n *\n * Expects:\n * - the task context to be ready for model resolution and task-scoped work\n *\n * Returns:\n * - a normalized run result with score entries ready for aggregation\n */\nexport type ScheduledTaskExecutor = (\n task: ScheduledTask,\n context: TaskExecutionContext,\n) => Promise<RunResult>\n\n/**\n * Terminal task state reported by runner lifecycle hooks.\n *\n * Use when:\n * - reporting the outcome of one scheduled task to lifecycle observers\n *\n * Expects:\n * - hooks treat the value as final for the completed task\n */\nexport type RunnerTaskState = 'passed' | 'failed'\n\n/**\n * Optional runner execution hooks used while processing scheduled tasks.\n *\n * Use when:\n * - callers want lifecycle visibility around sequential task execution\n * - task execution should remain deterministic while still observable\n *\n * Expects:\n * - hook functions are synchronous lifecycle observers\n */\nexport interface RunScheduledTasksOptions {\n /**\n * Creates per-task execution context.\n *\n * Use when:\n * - executor code needs per-task model resolution or other task-scoped data\n */\n createExecutionContext?: (task: ScheduledTask) => TaskExecutionContext\n /**\n * Runs before the executor starts handling a task.\n *\n * Use when:\n * - callers want to observe task activation before execution begins\n *\n * Expects:\n * - thrown errors abort the task before executor work starts\n */\n onTaskStart?: (task: ScheduledTask) => void\n /**\n * Runs after the executor settles for a task.\n *\n * Use when:\n * - callers want to observe successful and failed task completion\n *\n * Expects:\n * - thrown errors abort successful runs\n * - failed-task observers do not override the executor error for the task\n */\n onTaskEnd?: (task: ScheduledTask, state: RunnerTaskState) => void\n /**\n * Maximum number of tasks to execute concurrently.\n *\n * @default 1\n */\n maxConcurrency?: number\n}\n\nfunction createDefaultExecutionContext(task: ScheduledTask): TaskExecutionContext {\n const cache: TaskCacheRuntime = {\n namespace(name) {\n return {\n file(options) {\n const key = options.key.join('/')\n throw new Error(`Task cache runtime is not configured. Requested namespace \"${name}\" and key \"${key}\".`)\n },\n }\n },\n }\n\n return {\n cache,\n model(options) {\n const requestedModelName = typeof options === 'string' ? options : options?.name\n if (requestedModelName != null) {\n throw new Error(`No model registry configured. Requested model: ${requestedModelName}`)\n }\n\n throw new Error(`No model registry configured for task inferenceExecutor id \"${task.inferenceExecutor.id}\".`)\n },\n }\n}\n\n/**\n * Error thrown when a scheduled run fails before producing a normalized result.\n */\nexport class RunnerExecutionError extends Error {\n /**\n * Stable task id that failed.\n */\n taskId: string\n\n constructor(taskId: string, cause: unknown) {\n const message = errorMessageFrom(cause) ?? 'Unknown runner execution failure.'\n super(`Runner task \"${taskId}\" failed: ${message}`)\n this.name = 'RunnerExecutionError'\n this.taskId = taskId\n this.cause = cause\n }\n}\n\nfunction createRunnerExecutionError(taskId: string, cause: unknown): RunnerExecutionError {\n if (cause instanceof RunnerExecutionError && cause.taskId === taskId) {\n return cause\n }\n\n return new RunnerExecutionError(taskId, cause)\n}\n\n/**\n * Executes runner tasks sequentially and aggregates the normalized results.\n *\n * Call stack:\n *\n * {@link createRunnerSchedule}\n * -> {@link runScheduledTasks}\n * -> `executor(task)`\n * -> {@link aggregateRunResults}\n *\n * Use when:\n * - the caller already expanded the runner matrix\n * - task execution should stay deterministic and easy to debug\n *\n * Expects:\n * - `executor` to return normalized `0..1` scores\n * - callers to handle concurrency outside this helper when needed\n * - `onTaskStart` / `onTaskEnd` hooks to be synchronous lifecycle observers\n *\n * Throws:\n * - `RunnerExecutionError` when task setup, hooks, or the executor throws\n */\nexport async function runScheduledTasks(\n tasks: readonly ScheduledTask[],\n executor: ScheduledTaskExecutor,\n options: RunScheduledTasksOptions = {},\n): Promise<AggregatedRunResults> {\n if (tasks.length === 0) {\n return aggregateRunResults([])\n }\n\n async function executeScheduledTask(task: ScheduledTask): Promise<RunResult> {\n let executionContext: TaskExecutionContext\n\n try {\n executionContext = options.createExecutionContext?.(task) ?? createDefaultExecutionContext(task)\n }\n catch (error) {\n throw createRunnerExecutionError(task.id, error)\n }\n\n try {\n options.onTaskStart?.(task)\n }\n catch (error) {\n throw createRunnerExecutionError(task.id, error)\n }\n\n let runResult: RunResult\n try {\n runResult = await executor(task, executionContext)\n }\n catch (error) {\n try {\n options.onTaskEnd?.(task, 'failed')\n }\n catch {\n // Failed-task observers must not mask the task execution failure.\n }\n throw createRunnerExecutionError(task.id, error)\n }\n\n try {\n options.onTaskEnd?.(task, 'passed')\n }\n catch (error) {\n throw createRunnerExecutionError(task.id, error)\n }\n\n return runResult\n }\n\n const maxConcurrency = options.maxConcurrency ?? 1\n if (maxConcurrency <= 1) {\n const results: RunResult[] = []\n for (const task of tasks) {\n results.push(await executeScheduledTask(task))\n }\n return aggregateRunResults(results)\n }\n\n const runWithLimit = limitConcurrency(maxConcurrency)\n const resultPairs = await Promise.all(tasks.map(async (task, index) => {\n const result = await runWithLimit(async () => executeScheduledTask(task))\n return { index, result }\n }))\n\n const sortedResults = resultPairs\n .sort((left, right) => left.index - right.index)\n .map(item => item.result)\n\n return aggregateRunResults(sortedResults)\n}\n","import { createRequire } from 'node:module'\nimport { dirname } from 'node:path'\nimport { fileURLToPath } from 'node:url'\n\nconst require = createRequire(import.meta.url)\n\n/**\n * Shared runtime context used by the vieval runner.\n *\n * Use when:\n * - runner services need stable path resolution without module-level side effects\n * - call sites want deterministic control over workspace root detection\n */\nexport interface RunnerRuntimeContext {\n /**\n * Absolute project root directory used for path normalization.\n */\n projectRootDirectory: string\n}\n\n/**\n * Options used to construct the runner runtime context.\n */\nexport interface CreateVievalRunnerRuntimeContextOptions {\n /**\n * Directory used to search for the nearest pnpm workspace.\n *\n * @default directory of this module file\n */\n cwd?: string\n /**\n * Absolute fallback directory when a pnpm workspace root is not found.\n *\n * @default package root directory (`packages/vieval`)\n */\n fallbackProjectRootDirectory?: string\n}\n\n/**\n * Creates a side-effect-free runtime context for runner path normalization.\n *\n * Call stack:\n *\n * {@link createRunnerRuntimeContext}\n * -> `findWorkspaceDir(cwd)`\n * -> `resolve projectRootDirectory`\n * -> `{ projectRootDirectory }`\n *\n * Use when:\n * - initializing runner infrastructure before collecting eval modules\n * - tests need deterministic root resolution behavior\n */\nexport async function createRunnerRuntimeContext(\n options: CreateVievalRunnerRuntimeContextOptions = {},\n): Promise<RunnerRuntimeContext> {\n const cwd = options.cwd ?? dirname(fileURLToPath(import.meta.url))\n const fallbackProjectRootDirectory = options.fallbackProjectRootDirectory\n ?? fileURLToPath(new URL('../../../', import.meta.url))\n\n // NOTICE:\n // We use dynamic `require` here because `@pnpm/find-workspace-dir` is CommonJS.\n // Keeping this load inside the factory avoids module-level initialization side effects.\n const { findWorkspaceDir } = require('@pnpm/find-workspace-dir') as {\n findWorkspaceDir: (currentWorkingDirectory: string) => Promise<string | undefined>\n }\n\n // NOTICE:\n // Workspace discovery is required to keep collected eval ids stable when this\n // package is moved inside different monorepo layouts.\n const workspaceDirectory = await findWorkspaceDir(cwd)\n\n return {\n projectRootDirectory: workspaceDirectory ?? fallbackProjectRootDirectory,\n }\n}\n","import type { CollectedEvalEntry, MatrixDefinition, MatrixLayer, MatrixValue } from '../../config'\n\n/**\n * Describes the inferenceExecutor target for a scheduled eval run.\n */\nexport interface InferenceExecutor {\n /**\n * Stable inferenceExecutor identifier such as `openai:gpt-4.1-mini`.\n */\n id: string\n}\n\n/**\n * Stores the selected value for each matrix axis.\n */\nexport type RunnerMatrixSelection = Record<string, string>\n\n/**\n * Stores stable row ids for one resolved scheduled task matrix.\n */\nexport interface ScheduledTaskMatrixMeta {\n /**\n * Stable row id for the resolved run matrix selection.\n */\n runRowId: string\n /**\n * Stable row id for the resolved eval matrix selection.\n */\n evalRowId: string\n}\n\n/**\n * Stores the structured matrix payload for one scheduled task.\n */\nexport interface ScheduledTaskMatrix {\n /**\n * Runtime matrix selection visible to task code.\n */\n run: RunnerMatrixSelection\n /**\n * Eval-time matrix selection visible to task code.\n */\n eval: RunnerMatrixSelection\n /**\n * Stable row ids for both scopes.\n */\n meta: ScheduledTaskMatrixMeta\n}\n\n/**\n * Maps matrix axis names to the values that should be expanded.\n */\nexport type RunnerMatrixDefinition = MatrixDefinition\n\n/**\n * Accepts either flat axis definitions or one layered matrix object.\n */\nexport type RunnerMatrixInput = RunnerMatrixDefinition | MatrixLayer\n\nconst matrixLayerKeys = new Set(['disable', 'extend', 'override'])\nconst ambiguousMatrixDefinitionErrorMessage = 'Ambiguous matrix definition: cannot mix reserved layer keys (disable, extend, override) with matrix axis keys.'\n\n/**\n * Represents one fully expanded runner task.\n */\nexport interface ScheduledTask {\n /**\n * Stable task id derived from the entry, inferenceExecutor, and matrix selection.\n */\n id: string\n /**\n * The collected eval entry to execute.\n */\n entry: CollectedEvalEntry\n /**\n * The inferenceExecutor selected for this task.\n */\n inferenceExecutor: InferenceExecutor\n /**\n * The concrete scoped matrix selection for this task.\n */\n matrix: ScheduledTaskMatrix\n}\n\n/**\n * Configures how the runner should expand its execution matrix.\n */\nexport interface CreateRunnerScheduleOptions {\n /**\n * Collected eval entries that should be scheduled.\n */\n entries: readonly CollectedEvalEntry[]\n /**\n * Providers that should run each entry.\n */\n inferenceExecutors: readonly InferenceExecutor[]\n /**\n * Optional run-time matrix axes expanded as a cartesian product.\n */\n runMatrix?: RunnerMatrixInput\n /**\n * Optional eval-time matrix axes expanded as a cartesian product.\n */\n evalMatrix?: RunnerMatrixInput\n}\n\nfunction encodeTaskIdSegment(value: string): string {\n return encodeURIComponent(value)\n}\n\nfunction stringifyMatrixValue(value: MatrixValue): string {\n return String(value)\n}\n\nfunction cloneMatrixSelection(matrix: RunnerMatrixSelection): RunnerMatrixSelection {\n return { ...matrix }\n}\n\nfunction createScheduledTaskMatrix(\n runMatrix: RunnerMatrixSelection,\n evalMatrix: RunnerMatrixSelection,\n): ScheduledTaskMatrix {\n return {\n eval: cloneMatrixSelection(evalMatrix),\n meta: {\n evalRowId: createStableRowId(evalMatrix),\n runRowId: createStableRowId(runMatrix),\n },\n run: cloneMatrixSelection(runMatrix),\n }\n}\n\nfunction isMatrixLayer(matrix: RunnerMatrixInput): matrix is MatrixLayer {\n const matrixKeys = Object.keys(matrix)\n return (\n matrixKeys.length > 0\n && matrixKeys.every(key => matrixLayerKeys.has(key))\n )\n}\n\nfunction assertNonAmbiguousMatrixDefinition(matrix: RunnerMatrixInput): void {\n const matrixKeys = Object.keys(matrix)\n const hasReservedKeys = matrixKeys.some(key => matrixLayerKeys.has(key))\n const hasAxisKeys = matrixKeys.some(key => !matrixLayerKeys.has(key))\n\n if (hasReservedKeys && hasAxisKeys) {\n throw new TypeError(ambiguousMatrixDefinitionErrorMessage)\n }\n}\n\nfunction normalizeLayerInputToAxes(matrix: RunnerMatrixInput | undefined): MatrixLayer | undefined {\n if (matrix == null) {\n return undefined\n }\n\n assertNonAmbiguousMatrixDefinition(matrix)\n\n if (isMatrixLayer(matrix)) {\n return matrix\n }\n\n return {\n extend: matrix,\n }\n}\n\nfunction dedupeAxisValues(values: readonly MatrixValue[]): string[] {\n return Array.from(new Set(values.map(stringifyMatrixValue)))\n}\n\nfunction applyAxisValues(\n axes: Map<string, string[]>,\n definition: RunnerMatrixDefinition | undefined,\n mode: 'extend' | 'override',\n): void {\n if (definition == null) {\n return\n }\n\n for (const [axis, values] of Object.entries(definition)) {\n const nextValues = dedupeAxisValues(values)\n\n if (mode === 'extend') {\n const existingValues = axes.get(axis) ?? []\n axes.set(axis, Array.from(new Set([...existingValues, ...nextValues])))\n continue\n }\n\n axes.set(axis, nextValues)\n }\n}\n\nfunction applyLayer(\n baseAxes: ReadonlyMap<string, string[]>,\n layer: MatrixLayer | undefined,\n): Map<string, string[]> {\n const nextAxes = new Map<string, string[]>(\n Array.from(baseAxes.entries()).map(([axis, values]) => [axis, [...values]]),\n )\n\n for (const axis of layer?.disable ?? []) {\n nextAxes.delete(axis)\n }\n\n applyAxisValues(nextAxes, layer?.extend, 'extend')\n applyAxisValues(nextAxes, layer?.override, 'override')\n\n return nextAxes\n}\n\nfunction expandAxesToRows(axes: ReadonlyMap<string, readonly string[]>): RunnerMatrixSelection[] {\n if (axes.size === 0) {\n return [{}]\n }\n\n const dimensions = Array.from(axes.entries())\n\n let selections: RunnerMatrixSelection[] = [{}]\n\n for (const [axis, values] of dimensions) {\n if (values.length === 0) {\n return []\n }\n\n const nextSelections: RunnerMatrixSelection[] = []\n\n for (const selection of selections) {\n for (const value of values) {\n nextSelections.push({\n ...selection,\n [axis]: value,\n })\n }\n }\n\n selections = nextSelections\n }\n\n return selections\n}\n\nfunction createStableRowId(matrix: RunnerMatrixSelection): string {\n const segments = Object.entries(matrix)\n .sort(([leftAxis], [rightAxis]) => leftAxis.localeCompare(rightAxis))\n .map(([axis, value]) => `${encodeTaskIdSegment(axis)}=${encodeTaskIdSegment(value)}`)\n\n if (segments.length === 0) {\n return 'default'\n }\n\n return segments.join('&')\n}\n\nfunction createTaskId(entryId: string, inferenceExecutorId: string, runRowId: string, evalRowId: string): string {\n const encodedEntryId = encodeTaskIdSegment(entryId)\n const encodedProviderId = encodeTaskIdSegment(inferenceExecutorId)\n\n return [\n encodedEntryId,\n encodedProviderId,\n `run=${encodeTaskIdSegment(runRowId)}`,\n `eval=${encodeTaskIdSegment(evalRowId)}`,\n ].join('::')\n}\n\nfunction createResolvedRunAxes(\n entry: CollectedEvalEntry,\n runMatrix: RunnerMatrixInput | undefined,\n): Map<string, string[]> {\n let resolvedAxes = new Map<string, string[]>()\n\n for (const layerInput of [\n runMatrix,\n entry.matrix?.runMatrix,\n entry.task?.matrix?.runMatrix,\n ]) {\n resolvedAxes = applyLayer(resolvedAxes, normalizeLayerInputToAxes(layerInput))\n }\n\n return resolvedAxes\n}\n\nfunction createResolvedEvalAxes(\n entry: CollectedEvalEntry,\n evalMatrix: RunnerMatrixInput | undefined,\n): Map<string, string[]> {\n let resolvedAxes = new Map<string, string[]>()\n\n for (const layerInput of [\n evalMatrix,\n entry.matrix?.evalMatrix,\n entry.task?.matrix?.evalMatrix,\n ]) {\n resolvedAxes = applyLayer(resolvedAxes, normalizeLayerInputToAxes(layerInput))\n }\n\n return resolvedAxes\n}\n\n/**\n * Expands collected entries into a stable runner schedule.\n *\n * Call stack:\n *\n * {@link collectEvalEntries} (`../runner`)\n * -> {@link createRunnerSchedule}\n * -> {@link expandAxesToRows}\n * -> {@link ScheduledTask}[]\n *\n * Use when:\n * - the runner already knows which eval entries are available\n * - each entry must run against multiple inferenceExecutors or matrix variants\n *\n * Expects:\n * - `entries` and `inferenceExecutors` to be provided in the desired execution order\n * - matrix axes to use insertion order when generating combinations\n */\nexport function createRunnerSchedule(options: CreateRunnerScheduleOptions): ScheduledTask[] {\n if (options.entries.length === 0) {\n return []\n }\n\n if (options.inferenceExecutors.length === 0) {\n return []\n }\n\n const tasks: ScheduledTask[] = []\n\n for (const entry of options.entries) {\n const runSelections = expandAxesToRows(createResolvedRunAxes(entry, options.runMatrix))\n const evalSelections = expandAxesToRows(createResolvedEvalAxes(entry, options.evalMatrix))\n\n if (runSelections.length === 0 || evalSelections.length === 0) {\n continue\n }\n\n for (const inferenceExecutor of options.inferenceExecutors) {\n for (const runMatrix of runSelections) {\n for (const evalMatrix of evalSelections) {\n const isolatedMatrix = createScheduledTaskMatrix(runMatrix, evalMatrix)\n\n tasks.push({\n entry,\n id: createTaskId(\n entry.id,\n inferenceExecutor.id,\n isolatedMatrix.meta.runRowId,\n isolatedMatrix.meta.evalRowId,\n ),\n matrix: isolatedMatrix,\n inferenceExecutor,\n })\n }\n }\n }\n }\n\n return tasks\n}\n","import type { ModelDefinition } from '../../config/models'\nimport type { TaskCacheRuntime } from '../cache'\nimport type { ScheduledTask } from './schedule'\n\nimport { resolveModelByName } from '../../config/models'\n\n/**\n * Options for selecting a model from the execution context.\n */\nexport interface TaskModelSelectionOptions {\n /**\n * Model id or alias name.\n */\n name: string\n}\n\n/**\n * Task-scoped execution context exposed to runner executors.\n */\nexport interface TaskExecutionContext {\n /**\n * Deterministic cache runtime scoped to the current task project.\n */\n cache: TaskCacheRuntime\n /**\n * Resolves model configuration for the current task.\n *\n * Use when:\n * - no arguments are provided to use the model selected by run matrix/inferenceExecutor\n * - `name` is provided to resolve a specific model id or alias\n */\n model: (\n selection?: string | TaskModelSelectionOptions,\n ) => ModelDefinition\n}\n\n/**\n * Inputs used to build task execution context.\n */\nexport interface CreateTaskExecutionContextOptions {\n cache?: TaskCacheRuntime\n models: readonly ModelDefinition[]\n task: ScheduledTask\n}\n\nfunction createNoopTaskCacheRuntime(): TaskCacheRuntime {\n return {\n namespace(name) {\n return {\n file(options) {\n const key = options.key.join('/')\n throw new Error(`Task cache runtime is not configured. Requested namespace \"${name}\" and key \"${key}\".`)\n },\n }\n },\n }\n}\n\nfunction resolveDefaultTaskModel(\n models: readonly ModelDefinition[],\n task: ScheduledTask,\n): ModelDefinition {\n const runMatrixModelName = task.matrix.run.model\n if (runMatrixModelName != null) {\n const matrixSelectedModel = resolveModelByName(models, runMatrixModelName)\n if (matrixSelectedModel != null) {\n return matrixSelectedModel\n }\n\n throw new Error(`Unknown configured model \"${runMatrixModelName}\" from task.matrix.run.model.`)\n }\n\n const matched = resolveModelByName(models, task.inferenceExecutor.id)\n if (matched != null) {\n return matched\n }\n\n if (models.length > 1) {\n throw new Error(\n [\n `Multiple configured models are available, but no default model is selected for inferenceExecutor \"${task.inferenceExecutor.id}\".`,\n 'Select one model explicitly by either:',\n '- setting runMatrix.override.model (or task matrix run.model)',\n '- setting project.inferenceExecutors to a matching model id',\n '- calling context.model({ name: \"your-model-id-or-alias\" })',\n ].join('\\n'),\n )\n }\n\n if (models.length === 1) {\n const firstModel = models[0]\n if (firstModel != null) {\n return firstModel\n }\n }\n\n throw new Error(`No configured model found for inferenceExecutor id \"${task.inferenceExecutor.id}\".`)\n}\n\n/**\n * Creates task-scoped model resolver context for runner execution.\n *\n * Call stack:\n *\n * {@link runScheduledTasks}\n * -> {@link createTaskExecutionContext}\n * -> {@link resolveModelByName}\n * -> `task.model()` / `task.model({ name })`\n */\nexport function createTaskExecutionContext(options: CreateTaskExecutionContextOptions): TaskExecutionContext {\n return {\n cache: options.cache ?? createNoopTaskCacheRuntime(),\n model(selection) {\n if (selection == null) {\n return resolveDefaultTaskModel(options.models, options.task)\n }\n\n const name = typeof selection === 'string' ? selection : selection.name\n\n const namedModel = resolveModelByName(options.models, name)\n if (namedModel == null) {\n throw new Error(`Unknown configured model \"${name}\".`)\n }\n\n return namedModel\n },\n }\n}\n"],"mappings":";;;;;;;;;;;;AA2BA,SAAS,oBAAoB,OAAuB;CAClD,MAAM,aAAa,MAAM,MAAM;AAC/B,KAAI,WAAW,WAAW,EACxB,QAAO;AAGT,QAAO,WAAW,QAAQ,aAAa,IAAI;;AAG7C,SAAS,mBAAmB,WAA+B,WAAmD;AAC5G,KAAI,aAAa,QAAQ,UAAU,SAAS,EAC1C,QAAO,UAAU,WAAW,IAAI,GAAG,UAAU,MAAM,EAAE,GAAG;AAG1D,KAAI,aAAa,QAAQ,UAAU,WAAW,EAC5C;AAGF,KAAI,cAAc,mBAChB,QAAO;AAGT,KAAI,cAAc,aAChB,QAAO;AAGT,KAAI,cAAc,YAChB,QAAO;;;;;;;;;;;AAeX,SAAgB,+BAA+B,SAAqC;CAClF,MAAM,eAAe,QAAQ,IAAI,KAAI,YAAW,oBAAoB,QAAQ,CAAC;CAC7E,MAAM,YAAY,mBAAmB,QAAQ,KAAK,QAAQ,UAAU;AAEpE,KAAI,aAAa,WAAW,EAC1B,QAAO,aAAa,OAAO,CAAC,WAAW,GAAG,CAAC,YAAY,YAAY;AAGrE,KAAI,aAAa,KACf,QAAO;CAGT,MAAM,cAAc,aAAa,MAAM,GAAG,KAAK,IAAI,GAAG,aAAa,SAAS,EAAE,CAAC;CAC/E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AAK;AAC3D,OAAI,cAAc,KAChB,OAAM,IAAI,MAAM,6BAA6B,KAAK,IAAI;AAGxD,UAAO;;EAEV"}
|
|
@@ -0,0 +1,2 @@
|
|
|
1
|
+
import { a as SchedulerMiddleware, c as SchedulerScopeContext, i as SchedulerConcurrencyConfig, n as getActiveScopes, o as SchedulerRuntime, r as CreateSchedulerRuntimeOptions, s as SchedulerScope, t as createSchedulerRuntime } from "../../index-fakXoZEe.mjs";
|
|
2
|
+
export { CreateSchedulerRuntimeOptions, SchedulerConcurrencyConfig, SchedulerMiddleware, SchedulerRuntime, SchedulerScope, SchedulerScopeContext, createSchedulerRuntime, getActiveScopes };
|
|
@@ -0,0 +1,188 @@
|
|
|
1
|
+
import { t as createSchedulerQueue } from "../../queue-DsZQkZO_.mjs";
|
|
2
|
+
//#region src/core/scheduler/runtime.ts
|
|
3
|
+
const schedulerScopeOrder = [
|
|
4
|
+
"workspace",
|
|
5
|
+
"project",
|
|
6
|
+
"task",
|
|
7
|
+
"attempt",
|
|
8
|
+
"case"
|
|
9
|
+
];
|
|
10
|
+
/**
|
|
11
|
+
* Creates the core scheduler runtime used to serialize work by scope.
|
|
12
|
+
*
|
|
13
|
+
* Call stack:
|
|
14
|
+
*
|
|
15
|
+
* {@link createSchedulerRuntime}
|
|
16
|
+
* -> `createRuntimeQueues`
|
|
17
|
+
* -> `runtime.runCase(context, execute)`
|
|
18
|
+
* -> `runWithQueues`
|
|
19
|
+
* -> `runAcquireMiddleware`
|
|
20
|
+
* -> `execute`
|
|
21
|
+
* -> `runReleaseMiddleware`
|
|
22
|
+
*
|
|
23
|
+
* Use when:
|
|
24
|
+
* - runner code needs concurrency caps for queued case execution
|
|
25
|
+
* - middleware should wrap work with acquire/release lifecycle hooks
|
|
26
|
+
*
|
|
27
|
+
* Expects:
|
|
28
|
+
* - middleware is ordered from outermost to innermost concern
|
|
29
|
+
* - concurrency caps are positive integers when provided
|
|
30
|
+
*
|
|
31
|
+
* Returns:
|
|
32
|
+
* - a scheduler runtime with case execution support
|
|
33
|
+
*/
|
|
34
|
+
function createSchedulerRuntime(options = {}) {
|
|
35
|
+
const middleware = options.middleware ?? [];
|
|
36
|
+
const queues = createRuntimeQueues(options.concurrency ?? {});
|
|
37
|
+
return { runCase(context, execute) {
|
|
38
|
+
return runWithQueues(getActiveScopes(context), context, queues, () => {
|
|
39
|
+
if (middleware.length === 0) return execute();
|
|
40
|
+
return runWithMiddlewareEnvelope(middleware, context, execute);
|
|
41
|
+
});
|
|
42
|
+
} };
|
|
43
|
+
}
|
|
44
|
+
/**
|
|
45
|
+
* Resolves the scheduler scopes that apply to a context.
|
|
46
|
+
*
|
|
47
|
+
* Before:
|
|
48
|
+
* - `{ scope: 'case', workspaceId: 'ws', experimentId: 'exp', caseId: 'case-1' }`
|
|
49
|
+
*
|
|
50
|
+
* After:
|
|
51
|
+
* - `['workspace', 'project', 'task', 'attempt', 'case']` up to the requested scope
|
|
52
|
+
*/
|
|
53
|
+
function getActiveScopes(context) {
|
|
54
|
+
const targetScopeIndex = schedulerScopeOrder.indexOf(context.scope);
|
|
55
|
+
if (targetScopeIndex < 0) return [];
|
|
56
|
+
return schedulerScopeOrder.slice(0, targetScopeIndex + 1);
|
|
57
|
+
}
|
|
58
|
+
function createRuntimeQueues(concurrency) {
|
|
59
|
+
const queues = /* @__PURE__ */ new Map();
|
|
60
|
+
for (const scope of schedulerScopeOrder) {
|
|
61
|
+
const scopeConcurrency = concurrency[scope];
|
|
62
|
+
if (scopeConcurrency === void 0) continue;
|
|
63
|
+
validateSchedulerConcurrency(scope, scopeConcurrency);
|
|
64
|
+
queues.set(scope, {
|
|
65
|
+
concurrency: scopeConcurrency,
|
|
66
|
+
instances: /* @__PURE__ */ new Map()
|
|
67
|
+
});
|
|
68
|
+
}
|
|
69
|
+
return queues;
|
|
70
|
+
}
|
|
71
|
+
async function runWithQueues(scopes, context, queues, execute, index = 0) {
|
|
72
|
+
const scope = scopes[index];
|
|
73
|
+
if (scope === void 0) return execute();
|
|
74
|
+
const queue = getScopeQueue(scope, context, queues);
|
|
75
|
+
if (queue === void 0) return runWithQueues(scopes, context, queues, execute, index + 1);
|
|
76
|
+
return queue.run(() => runWithQueues(scopes, context, queues, execute, index + 1));
|
|
77
|
+
}
|
|
78
|
+
function getScopeQueue(scope, context, queues) {
|
|
79
|
+
const queueRegistry = queues.get(scope);
|
|
80
|
+
if (queueRegistry === void 0) return;
|
|
81
|
+
const scopeKey = getSchedulerScopeInstanceKey(scope, context);
|
|
82
|
+
const existingQueue = queueRegistry.instances.get(scopeKey);
|
|
83
|
+
if (existingQueue !== void 0) return existingQueue;
|
|
84
|
+
const queue = createSchedulerQueue(queueRegistry.concurrency);
|
|
85
|
+
queueRegistry.instances.set(scopeKey, queue);
|
|
86
|
+
return queue;
|
|
87
|
+
}
|
|
88
|
+
function getSchedulerScopeInstanceKey(scope, context) {
|
|
89
|
+
const workspaceKey = `workspace:${context.workspaceId}:experiment:${context.experimentId}`;
|
|
90
|
+
const projectKey = `${workspaceKey}:project:${context.projectName ?? "(missing-project)"}`;
|
|
91
|
+
const taskKey = `${projectKey}:task:${context.taskId ?? "(missing-task)"}`;
|
|
92
|
+
const attemptKey = `${taskKey}:attempt:${context.attemptIndex ?? "(missing-attempt)"}`;
|
|
93
|
+
switch (scope) {
|
|
94
|
+
case "workspace": return workspaceKey;
|
|
95
|
+
case "project": return projectKey;
|
|
96
|
+
case "task": return taskKey;
|
|
97
|
+
case "attempt": return attemptKey;
|
|
98
|
+
case "case": return attemptKey;
|
|
99
|
+
}
|
|
100
|
+
}
|
|
101
|
+
async function runWithMiddlewareEnvelope(middleware, context, execute) {
|
|
102
|
+
const result = await runAcquireMiddleware(middleware, context, execute, 0);
|
|
103
|
+
try {
|
|
104
|
+
switch (result.outcome.status) {
|
|
105
|
+
case "succeeded": return result.outcome.value;
|
|
106
|
+
case "failed": throw result.outcome.error;
|
|
107
|
+
case "skipped": throw createSchedulerShortCircuitError();
|
|
108
|
+
}
|
|
109
|
+
} finally {
|
|
110
|
+
await runReleaseMiddleware(result.releaseStack, context, result.releaseStack.length - 1);
|
|
111
|
+
}
|
|
112
|
+
}
|
|
113
|
+
async function runAcquireMiddleware(middleware, context, execute, index) {
|
|
114
|
+
const currentMiddleware = middleware[index];
|
|
115
|
+
if (currentMiddleware === void 0) return createSchedulerExecutionResult([], execute);
|
|
116
|
+
let nextResult = createSchedulerShortCircuitResult();
|
|
117
|
+
let didCallNext = false;
|
|
118
|
+
const next = async () => {
|
|
119
|
+
didCallNext = true;
|
|
120
|
+
nextResult = await runAcquireMiddleware(middleware, context, execute, index + 1);
|
|
121
|
+
};
|
|
122
|
+
try {
|
|
123
|
+
if (currentMiddleware.onAcquire === void 0) await next();
|
|
124
|
+
else await currentMiddleware.onAcquire(context, next);
|
|
125
|
+
} catch (error) {
|
|
126
|
+
if (!didCallNext) return createSchedulerFailureResult([], error);
|
|
127
|
+
return createSchedulerFailureResult([currentMiddleware, ...nextResult.releaseStack], error);
|
|
128
|
+
}
|
|
129
|
+
return {
|
|
130
|
+
releaseStack: [currentMiddleware, ...nextResult.releaseStack],
|
|
131
|
+
outcome: nextResult.outcome
|
|
132
|
+
};
|
|
133
|
+
}
|
|
134
|
+
async function runReleaseMiddleware(releaseStack, context, index) {
|
|
135
|
+
const currentMiddleware = releaseStack[index];
|
|
136
|
+
if (currentMiddleware === void 0) return;
|
|
137
|
+
if (currentMiddleware.onRelease === void 0) {
|
|
138
|
+
await runReleaseMiddleware(releaseStack, context, index - 1);
|
|
139
|
+
return;
|
|
140
|
+
}
|
|
141
|
+
await currentMiddleware.onRelease(context, async () => {
|
|
142
|
+
await runReleaseMiddleware(releaseStack, context, index - 1);
|
|
143
|
+
});
|
|
144
|
+
}
|
|
145
|
+
async function createSchedulerExecutionResult(releaseStack, execute) {
|
|
146
|
+
try {
|
|
147
|
+
return {
|
|
148
|
+
releaseStack,
|
|
149
|
+
outcome: {
|
|
150
|
+
status: "succeeded",
|
|
151
|
+
value: await execute()
|
|
152
|
+
}
|
|
153
|
+
};
|
|
154
|
+
} catch (error) {
|
|
155
|
+
return {
|
|
156
|
+
releaseStack,
|
|
157
|
+
outcome: {
|
|
158
|
+
status: "failed",
|
|
159
|
+
error
|
|
160
|
+
}
|
|
161
|
+
};
|
|
162
|
+
}
|
|
163
|
+
}
|
|
164
|
+
function createSchedulerFailureResult(releaseStack, error) {
|
|
165
|
+
return {
|
|
166
|
+
releaseStack,
|
|
167
|
+
outcome: {
|
|
168
|
+
status: "failed",
|
|
169
|
+
error
|
|
170
|
+
}
|
|
171
|
+
};
|
|
172
|
+
}
|
|
173
|
+
function createSchedulerShortCircuitResult() {
|
|
174
|
+
return {
|
|
175
|
+
releaseStack: [],
|
|
176
|
+
outcome: { status: "skipped" }
|
|
177
|
+
};
|
|
178
|
+
}
|
|
179
|
+
function validateSchedulerConcurrency(scope, concurrency) {
|
|
180
|
+
if (!Number.isFinite(concurrency) || !Number.isInteger(concurrency) || concurrency <= 0) throw new Error(`Invalid scheduler concurrency for "${scope}": ${String(concurrency)}`);
|
|
181
|
+
}
|
|
182
|
+
function createSchedulerShortCircuitError() {
|
|
183
|
+
return /* @__PURE__ */ new Error("Scheduler middleware short-circuited execution.");
|
|
184
|
+
}
|
|
185
|
+
//#endregion
|
|
186
|
+
export { createSchedulerRuntime, getActiveScopes };
|
|
187
|
+
|
|
188
|
+
//# sourceMappingURL=index.mjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.mjs","names":[],"sources":["../../../src/core/scheduler/runtime.ts"],"sourcesContent":["import type {\n CreateSchedulerRuntimeOptions,\n SchedulerConcurrencyConfig,\n SchedulerMiddleware,\n SchedulerRuntime,\n SchedulerScope,\n SchedulerScopeContext,\n} from './types'\n\nimport { createSchedulerQueue } from './queue'\n\nconst schedulerScopeOrder: SchedulerScope[] = [\n 'workspace',\n 'project',\n 'task',\n 'attempt',\n 'case',\n]\n\n/**\n * Creates the core scheduler runtime used to serialize work by scope.\n *\n * Call stack:\n *\n * {@link createSchedulerRuntime}\n * -> `createRuntimeQueues`\n * -> `runtime.runCase(context, execute)`\n * -> `runWithQueues`\n * -> `runAcquireMiddleware`\n * -> `execute`\n * -> `runReleaseMiddleware`\n *\n * Use when:\n * - runner code needs concurrency caps for queued case execution\n * - middleware should wrap work with acquire/release lifecycle hooks\n *\n * Expects:\n * - middleware is ordered from outermost to innermost concern\n * - concurrency caps are positive integers when provided\n *\n * Returns:\n * - a scheduler runtime with case execution support\n */\nexport function createSchedulerRuntime(\n options: CreateSchedulerRuntimeOptions = {},\n): SchedulerRuntime {\n const middleware = options.middleware ?? []\n const queues = createRuntimeQueues(options.concurrency ?? {})\n\n return {\n runCase<T>(context: SchedulerScopeContext, execute: () => Promise<T>) {\n const activeScopes = getActiveScopes(context)\n\n return runWithQueues(activeScopes, context, queues, () => {\n if (middleware.length === 0) {\n return execute()\n }\n\n return runWithMiddlewareEnvelope(middleware, context, execute)\n })\n },\n }\n}\n\n/**\n * Resolves the scheduler scopes that apply to a context.\n *\n * Before:\n * - `{ scope: 'case', workspaceId: 'ws', experimentId: 'exp', caseId: 'case-1' }`\n *\n * After:\n * - `['workspace', 'project', 'task', 'attempt', 'case']` up to the requested scope\n */\nexport function getActiveScopes(context: SchedulerScopeContext): SchedulerScope[] {\n const targetScopeIndex = schedulerScopeOrder.indexOf(context.scope)\n\n if (targetScopeIndex < 0) {\n return []\n }\n\n return schedulerScopeOrder.slice(0, targetScopeIndex + 1)\n}\n\nfunction createRuntimeQueues(concurrency: SchedulerConcurrencyConfig) {\n const queues = new Map<SchedulerScope, SchedulerScopeQueueRegistry>()\n\n for (const scope of schedulerScopeOrder) {\n const scopeConcurrency = concurrency[scope]\n\n if (scopeConcurrency === undefined) {\n continue\n }\n\n validateSchedulerConcurrency(scope, scopeConcurrency)\n\n queues.set(scope, {\n concurrency: scopeConcurrency,\n instances: new Map<string, ReturnType<typeof createSchedulerQueue>>(),\n })\n }\n\n return queues\n}\n\nasync function runWithQueues<T>(\n scopes: SchedulerScope[],\n context: SchedulerScopeContext,\n queues: Map<SchedulerScope, SchedulerScopeQueueRegistry>,\n execute: () => Promise<T>,\n index = 0,\n): Promise<T> {\n const scope = scopes[index]\n\n if (scope === undefined) {\n return execute()\n }\n\n const queue = getScopeQueue(scope, context, queues)\n\n if (queue === undefined) {\n return runWithQueues(scopes, context, queues, execute, index + 1)\n }\n\n return queue.run(() => runWithQueues(scopes, context, queues, execute, index + 1))\n}\n\ninterface SchedulerScopeQueueRegistry {\n concurrency: number\n instances: Map<string, ReturnType<typeof createSchedulerQueue>>\n}\n\ninterface SchedulerEnvelopeResult<T> {\n releaseStack: SchedulerMiddleware[]\n outcome: SchedulerExecutionOutcome<T>\n}\n\ninterface SchedulerExecutionFailure {\n error: unknown\n status: 'failed'\n}\n\ninterface SchedulerExecutionSkipped {\n status: 'skipped'\n}\n\ninterface SchedulerExecutionSuccess<T> {\n status: 'succeeded'\n value: T\n}\n\ntype SchedulerExecutionOutcome<T>\n = | SchedulerExecutionFailure\n | SchedulerExecutionSkipped\n | SchedulerExecutionSuccess<T>\n\nfunction getScopeQueue(\n scope: SchedulerScope,\n context: SchedulerScopeContext,\n queues: Map<SchedulerScope, SchedulerScopeQueueRegistry>,\n) {\n const queueRegistry = queues.get(scope)\n\n if (queueRegistry === undefined) {\n return undefined\n }\n\n const scopeKey = getSchedulerScopeInstanceKey(scope, context)\n const existingQueue = queueRegistry.instances.get(scopeKey)\n\n if (existingQueue !== undefined) {\n return existingQueue\n }\n\n const queue = createSchedulerQueue(queueRegistry.concurrency)\n queueRegistry.instances.set(scopeKey, queue)\n return queue\n}\n\nfunction getSchedulerScopeInstanceKey(\n scope: SchedulerScope,\n context: SchedulerScopeContext,\n): string {\n const workspaceKey = `workspace:${context.workspaceId}:experiment:${context.experimentId}`\n const projectKey = `${workspaceKey}:project:${context.projectName ?? '(missing-project)'}`\n const taskKey = `${projectKey}:task:${context.taskId ?? '(missing-task)'}`\n const attemptKey = `${taskKey}:attempt:${context.attemptIndex ?? '(missing-attempt)'}`\n\n switch (scope) {\n case 'workspace':\n return workspaceKey\n case 'project':\n return projectKey\n case 'task':\n return taskKey\n case 'attempt':\n return attemptKey\n case 'case':\n return attemptKey\n }\n}\n\nasync function runWithMiddlewareEnvelope<T>(\n middleware: SchedulerMiddleware[],\n context: SchedulerScopeContext,\n execute: () => Promise<T>,\n): Promise<T> {\n const result = await runAcquireMiddleware(middleware, context, execute, 0)\n\n try {\n switch (result.outcome.status) {\n case 'succeeded':\n return result.outcome.value\n case 'failed':\n throw result.outcome.error\n case 'skipped':\n throw createSchedulerShortCircuitError()\n }\n }\n finally {\n await runReleaseMiddleware(result.releaseStack, context, result.releaseStack.length - 1)\n }\n}\n\nasync function runAcquireMiddleware<T>(\n middleware: SchedulerMiddleware[],\n context: SchedulerScopeContext,\n execute: () => Promise<T>,\n index: number,\n): Promise<SchedulerEnvelopeResult<T>> {\n const currentMiddleware = middleware[index]\n\n if (currentMiddleware === undefined) {\n return createSchedulerExecutionResult([], execute)\n }\n\n let nextResult = createSchedulerShortCircuitResult<T>()\n let didCallNext = false\n\n const next = async () => {\n didCallNext = true\n nextResult = await runAcquireMiddleware(middleware, context, execute, index + 1)\n }\n\n try {\n if (currentMiddleware.onAcquire === undefined) {\n await next()\n }\n else {\n await currentMiddleware.onAcquire(context, next)\n }\n }\n catch (error) {\n if (!didCallNext) {\n return createSchedulerFailureResult([], error)\n }\n\n return createSchedulerFailureResult(\n [currentMiddleware, ...nextResult.releaseStack],\n error,\n )\n }\n\n return {\n releaseStack: [currentMiddleware, ...nextResult.releaseStack],\n outcome: nextResult.outcome,\n }\n}\n\nasync function runReleaseMiddleware(\n releaseStack: SchedulerMiddleware[],\n context: SchedulerScopeContext,\n index: number,\n): Promise<void> {\n const currentMiddleware = releaseStack[index]\n\n if (currentMiddleware === undefined) {\n return\n }\n\n if (currentMiddleware.onRelease === undefined) {\n await runReleaseMiddleware(releaseStack, context, index - 1)\n return\n }\n\n await currentMiddleware.onRelease(context, async () => {\n await runReleaseMiddleware(releaseStack, context, index - 1)\n })\n}\n\nasync function createSchedulerExecutionResult<T>(\n releaseStack: SchedulerMiddleware[],\n execute: () => Promise<T>,\n): Promise<SchedulerEnvelopeResult<T>> {\n try {\n return {\n releaseStack,\n outcome: {\n status: 'succeeded',\n value: await execute(),\n },\n }\n }\n catch (error) {\n return {\n releaseStack,\n outcome: {\n status: 'failed',\n error,\n },\n }\n }\n}\n\nfunction createSchedulerFailureResult<T>(\n releaseStack: SchedulerMiddleware[],\n error: unknown,\n): SchedulerEnvelopeResult<T> {\n return {\n releaseStack,\n outcome: {\n status: 'failed',\n error,\n },\n }\n}\n\nfunction createSchedulerShortCircuitResult<T>(): SchedulerEnvelopeResult<T> {\n return {\n releaseStack: [],\n outcome: {\n status: 'skipped',\n },\n }\n}\n\nfunction validateSchedulerConcurrency(scope: SchedulerScope, concurrency: number): void {\n if (!Number.isFinite(concurrency) || !Number.isInteger(concurrency) || concurrency <= 0) {\n throw new Error(`Invalid scheduler concurrency for \"${scope}\": ${String(concurrency)}`)\n }\n}\n\nfunction createSchedulerShortCircuitError(): Error {\n return new Error('Scheduler middleware short-circuited execution.')\n}\n"],"mappings":";;AAWA,MAAM,sBAAwC;CAC5C;CACA;CACA;CACA;CACA;CACD;;;;;;;;;;;;;;;;;;;;;;;;;AA0BD,SAAgB,uBACd,UAAyC,EAAE,EACzB;CAClB,MAAM,aAAa,QAAQ,cAAc,EAAE;CAC3C,MAAM,SAAS,oBAAoB,QAAQ,eAAe,EAAE,CAAC;AAE7D,QAAO,EACL,QAAW,SAAgC,SAA2B;AAGpE,SAAO,cAFc,gBAAgB,QAAQ,EAEV,SAAS,cAAc;AACxD,OAAI,WAAW,WAAW,EACxB,QAAO,SAAS;AAGlB,UAAO,0BAA0B,YAAY,SAAS,QAAQ;IAC9D;IAEL;;;;;;;;;;;AAYH,SAAgB,gBAAgB,SAAkD;CAChF,MAAM,mBAAmB,oBAAoB,QAAQ,QAAQ,MAAM;AAEnE,KAA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,SAAS,YAAY;AACrD,QAAM,qBAAqB,cAAc,SAAS,QAAQ,EAAE;GAC5D;;AAGJ,eAAe,+BACb,cACA,SACqC;AACrC,KAAI;AACF,SAAO;GACL;GACA,SAAS;IACP,QAAQ;IACR,OAAO,MAAM,SAAS;IACvB;GACF;UAEI,OAAO;AACZ,SAAO;GACL;GACA,SAAS;IACP,QAAQ;IACR;IACD;GACF;;;AAIL,SAAS,6BACP,cACA,OAC4B;AAC5B,QAAO;EACL;EACA,SAAS;GACP,QAAQ;GACR;GACD;EACF;;AAGH,SAAS,oCAAmE;AAC1E,QAAO;EACL,cAAc,EAAE;EAChB,SAAS,EACP,QAAQ,WACT;EACF;;AAGH,SAAS,6BAA6B,OAAuB,aAA2B;AACtF,KAAI,CAAC,OAAO,SAAS,YAAY,IAAI,CAAC,OAAO,UAAU,YAAY,IAAI,eAAe,EACpF,OAAM,IAAI,MAAM,sCAAsC,MAAM,KAAK,OAAO,YAAY,GAAG;;AAI3F,SAAS,mCAA0C;AACjD,wBAAO,IAAI,MAAM,kDAAkD"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"env
|
|
1
|
+
{"version":3,"file":"env--94B0UtW.mjs","names":[],"sources":["../src/core/inference-executors/env.ts"],"sourcesContent":["/**\n * Supported env value coercion types.\n */\nexport type EnvValueType = 'string'\n\n/**\n * Common options for env readers.\n */\nexport interface EnvFromOptions {\n /**\n * Expected env value type.\n */\n type: EnvValueType\n /**\n * Whether an empty or missing value should throw.\n *\n * @default false\n */\n required?: boolean\n /**\n * Optional key name used for clearer error messages.\n */\n name?: string\n}\n\n/**\n * Env options used by the required helper.\n *\n * `required` is intentionally omitted because this helper is always required.\n */\nexport type RequiredEnvFromOptions = Omit<EnvFromOptions, 'required'>\n\nfunction assertNonEmptyString(value: string | undefined, options: EnvFromOptions): string | undefined {\n if (value == null || value.trim().length === 0) {\n if (options.required === true) {\n const label = options.name ?? 'environment variable'\n throw new Error(`Missing required ${label}.`)\n }\n\n return undefined\n }\n\n return value\n}\n\n/**\n * Parses one env value with optional required behavior.\n *\n * Example:\n * `const apiKey = envFrom(process.env.OPENAI_API_KEY, { type: 'string', required: true, name: 'OPENAI_API_KEY' })`\n */\nexport function envFrom(\n value: string | undefined,\n options: EnvFromOptions,\n): string | undefined {\n if (options.type === 'string') {\n return assertNonEmptyString(value, options)\n }\n\n return undefined\n}\n\n/**\n * Parses one required env value.\n *\n * Example:\n * `const apiKey = requiredEnvFrom(process.env.OPENAI_API_KEY, { type: 'string', name: 'OPENAI_API_KEY' })`\n */\nexport function requiredEnvFrom(\n value: string | undefined,\n options: RequiredEnvFromOptions,\n): string {\n const parsed = envFrom(value, {\n ...options,\n required: true,\n })\n\n if (parsed == null) {\n const label = options.name ?? 'environment variable'\n throw new Error(`Missing required ${label}.`)\n }\n\n return parsed\n}\n"],"mappings":";AAgCA,SAAS,qBAAqB,OAA2B,SAA6C;AACpG,KAAI,SAAS,QAAQ,MAAM,MAAM,CAAC,WAAW,GAAG;AAC9C,MAAI,QAAQ,aAAa,MAAM;GAC7B,MAAM,QAAQ,QAAQ,QAAQ;AAC9B,SAAM,IAAI,MAAM,oBAAoB,MAAM,GAAG;;AAG/C;;AAGF,QAAO;;;;;;;;AAST,SAAgB,QACd,OACA,SACoB;AACpB,KAAI,QAAQ,SAAS,SACnB,QAAO,qBAAqB,OAAO,QAAQ;;;;;;;;AAY/C,SAAgB,gBACd,OACA,SACQ;CACR,MAAM,SAAS,QAAQ,OAAO;EAC5B,GAAG;EACH,UAAU;EACX,CAAC;AAEF,KAAI,UAAU,MAAM;EAClB,MAAM,QAAQ,QAAQ,QAAQ;AAC9B,QAAM,IAAI,MAAM,oBAAoB,MAAM,GAAG;;AAG/C,QAAO"}
|
|
@@ -44,4 +44,4 @@ declare function envFrom(value: string | undefined, options: EnvFromOptions): st
|
|
|
44
44
|
declare function requiredEnvFrom(value: string | undefined, options: RequiredEnvFromOptions): string;
|
|
45
45
|
//#endregion
|
|
46
46
|
export { requiredEnvFrom as a, envFrom as i, EnvValueType as n, RequiredEnvFromOptions as r, EnvFromOptions as t };
|
|
47
|
-
//# sourceMappingURL=env-
|
|
47
|
+
//# sourceMappingURL=env-BeHv_5mo.d.mts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"expect-extensions-QLXESWjn.mjs","names":[],"sources":["../src/testing/runtime-expect.ts","../src/testing/expect-extensions.ts"],"sourcesContent":["import type { ExpectStatic, MatchersObject, MatcherState, Tester } from '@vitest/expect'\n\nimport {\n addCustomEqualityTesters,\n ASYMMETRIC_MATCHERS_OBJECT,\n chai,\n ChaiStyleAssertions,\n customMatchers,\n getState,\n GLOBAL_EXPECT,\n JestAsymmetricMatchers,\n JestChaiExpect,\n JestExtend,\n setState,\n} from '@vitest/expect'\n\nlet isPluginInstalled = false\nlet runtimeExpectInstance: ExpectStatic | undefined\n\n/**\n * Installs Vitest expect plugins once for process-local runtime assertions.\n *\n * Use when:\n * - running eval tasks outside Vitest worker runtime\n * - building an `expect` instance that does not rely on Vitest internal state\n *\n * Expects:\n * - `@vitest/expect` is available in runtime dependencies\n *\n * Returns:\n * - nothing; side-effects are applied to `chai`\n */\nfunction ensureRuntimeExpectPluginsInstalled(): void {\n if (isPluginInstalled) {\n return\n }\n\n chai.use(JestExtend)\n chai.use(JestChaiExpect)\n chai.use(ChaiStyleAssertions)\n chai.use(JestAsymmetricMatchers)\n isPluginInstalled = true\n}\n\n/**\n * Creates a Vitest-compatible `expect` instance without worker-state coupling.\n *\n * Use when:\n * - CLI runtime needs assertion helpers from `vieval/expect`\n * - code is executed outside `vitest run`\n *\n * Expects:\n * - plugins from {@link ensureRuntimeExpectPluginsInstalled} are installed\n * - callers do not depend on Vitest worker-only features (snapshot/poll internals)\n *\n * Returns:\n * - standalone expect instance with core matcher APIs and `extend`\n */\nfunction createRuntimeExpect(): ExpectStatic {\n ensureRuntimeExpectPluginsInstalled()\n\n const runtimeExpect = ((value: unknown, message?: string) => {\n const currentState = getState(runtimeExpect)\n setState({ assertionCalls: currentState.assertionCalls + 1 }, runtimeExpect)\n return chai.expect(value, message)\n }) as unknown as ExpectStatic\n\n Object.assign(runtimeExpect, chai.expect)\n Object.assign(runtimeExpect, (globalThis as Record<PropertyKey, unknown>)[ASYMMETRIC_MATCHERS_OBJECT] as object)\n\n runtimeExpect.getState = () => getState(runtimeExpect)\n runtimeExpect.setState = (state: Partial<MatcherState>) => setState(state, runtimeExpect)\n runtimeExpect.assert = chai.assert\n // NOTICE:\n // Chai's public `ExpectStatic` type does not expose Vitest's plugin-added `extend`.\n // Runtime `chai.expect.extend` exists after `JestExtend` plugin installation.\n // Source/context: `@vitest/expect` plugin pipeline in `dist/index.js`.\n // Removal condition: remove this cast if upstream exposes `extend` on Chai expect types.\n const chaiExpectWithExtend = chai.expect as unknown as {\n extend: (expect: ExpectStatic, matchers: MatchersObject) => void\n }\n runtimeExpect.extend = (matchers: MatchersObject) => chaiExpectWithExtend.extend(runtimeExpect, matchers)\n runtimeExpect.addEqualityTesters = (customTesters: Tester[]) => addCustomEqualityTesters(customTesters)\n runtimeExpect.unreachable = (message?: string) => {\n chai.assert.fail(`expected${message ? ` \"${message}\" ` : ' '}not to be reached`)\n }\n\n runtimeExpect.setState({\n assertionCalls: 0,\n currentTestName: '',\n expectedAssertionsNumber: null,\n expectedAssertionsNumberErrorGen: null,\n isExpectingAssertions: false,\n isExpectingAssertionsError: null,\n })\n\n runtimeExpect.extend(customMatchers)\n\n return runtimeExpect\n}\n\n/**\n * Returns process-local runtime `expect` instance used by Vieval.\n *\n * Use when:\n * - you need matcher assertions in eval files and CLI runtime\n * - importing from `vitest` would crash outside Vitest worker contexts\n *\n * Expects:\n * - single-process usage (instance is memoized per process)\n *\n * Returns:\n * - memoized runtime `expect` instance\n */\nexport function getRuntimeExpect(): ExpectStatic {\n if (runtimeExpectInstance != null) {\n return runtimeExpectInstance\n }\n\n runtimeExpectInstance = createRuntimeExpect()\n Object.defineProperty(globalThis, GLOBAL_EXPECT, {\n configurable: true,\n value: runtimeExpectInstance,\n writable: true,\n })\n\n return runtimeExpectInstance\n}\n","import type { RubricJudgeResult, ToolCall } from '../core/assertions'\n\nimport { normalizeMatchText } from '../core/assertions'\nimport { getRuntimeExpect } from './runtime-expect'\n\n/**\n * Options for keyword-based matcher behavior.\n */\nexport interface KeywordMatcherOptions {\n /**\n * Case-sensitive matching toggle.\n *\n * @default false\n */\n caseSensitive?: boolean\n /**\n * Match mode.\n *\n * @default 'all'\n */\n mode?: 'all' | 'any'\n}\n\n/**\n * Shape used by tool-call matchers.\n */\nexport interface ToolCallContainer {\n /**\n * Tool calls to inspect.\n */\n toolCalls?: readonly ToolCall[]\n}\n\nfunction toKeywordArray(keywords: string | readonly string[]): readonly string[] {\n if (typeof keywords === 'string') {\n return [keywords]\n }\n\n return keywords\n}\n\n/**\n * Registers vieval custom matchers on Vitest `expect`.\n *\n * Call stack:\n *\n * {@link installVievalExpectMatchers}\n * -> `expect.extend(...)`\n * -> `expect(received).toMustInclude(...)`\n * -> `expect(received).toScoreRubricGreaterThan(...)`\n *\n * Use when:\n * - eval suites need domain assertions while preserving native Vitest ergonomics\n * - callers want native `.not` chaining with the same matchers\n */\nexport function installVievalExpectMatchers(): void {\n const expect = getRuntimeExpect()\n\n expect.extend({\n toMustExclude(received: unknown, keywords: string | readonly string[], options: KeywordMatcherOptions = {}) {\n const keywordList = toKeywordArray(keywords)\n\n if (typeof received !== 'string') {\n return {\n message: () => 'Expected received value to be a string.',\n pass: false,\n }\n }\n\n const normalizedText = normalizeMatchText(received, options.caseSensitive ?? false)\n const forbiddenMatches = keywordList.filter((keyword) => {\n return normalizedText.includes(normalizeMatchText(keyword, options.caseSensitive ?? false))\n })\n\n const pass = forbiddenMatches.length === 0\n\n return {\n message: () => {\n if (pass) {\n return `Expected text to include forbidden keywords: ${keywordList.join(', ')}`\n }\n\n return `Expected text not to include forbidden keywords, but matched: ${forbiddenMatches.join(', ')}`\n },\n pass,\n }\n },\n\n toMustInclude(received: unknown, keywords: string | readonly string[], options: KeywordMatcherOptions = {}) {\n const keywordList = toKeywordArray(keywords)\n\n if (typeof received !== 'string') {\n return {\n message: () => 'Expected received value to be a string.',\n pass: false,\n }\n }\n\n const normalizedText = normalizeMatchText(received, options.caseSensitive ?? false)\n const matches = keywordList.filter((keyword) => {\n return normalizedText.includes(normalizeMatchText(keyword, options.caseSensitive ?? false))\n })\n\n const mode = options.mode ?? 'all'\n const pass = mode === 'all' ? matches.length === keywordList.length : matches.length > 0\n\n return {\n message: () => {\n if (pass) {\n return `Expected text not to match required keywords, but matched: ${matches.join(', ')}`\n }\n\n return `Expected text to match required keywords (${mode}), but matched ${matches.length}/${keywordList.length}.`\n },\n pass,\n }\n },\n\n toScoreRubricGreaterThan(received: unknown, threshold: number) {\n const score = typeof received === 'number'\n ? received\n : (received as RubricJudgeResult | null)?.score\n\n if (typeof score !== 'number') {\n return {\n message: () => 'Expected received value to be a number or RubricJudgeResult.',\n pass: false,\n }\n }\n\n const pass = score > threshold\n\n return {\n message: () => {\n if (pass) {\n return `Expected rubric score ${score} to be less than or equal to ${threshold}.`\n }\n\n return `Expected rubric score ${score} to be greater than ${threshold}.`\n },\n pass,\n }\n },\n\n toSatisfyStructuredOutput<T>(received: unknown, validator: (value: unknown) => value is T) {\n const pass = validator(received)\n\n return {\n message: () => pass\n ? 'Expected structured output validator to fail.'\n : 'Expected structured output validator to pass.',\n pass,\n }\n },\n\n toSatisfyToolCallArgs(\n received: unknown,\n toolName: string,\n validator: (args: unknown) => boolean,\n ) {\n const toolCalls = (received as ToolCallContainer | null)?.toolCalls\n\n if (toolCalls == null) {\n return {\n message: () => 'Expected received value to provide toolCalls array.',\n pass: false,\n }\n }\n\n const targetCall = toolCalls.find(call => call.name === toolName)\n if (targetCall == null) {\n return {\n message: () => `Expected tool call ${toolName} to exist.`,\n pass: false,\n }\n }\n\n const pass = validator(targetCall.args)\n\n return {\n message: () => pass\n ? `Expected tool call args for ${toolName} to fail validation.`\n : `Expected tool call args for ${toolName} to pass validation.`,\n pass,\n }\n },\n })\n}\n\ninterface VievalCustomMatchers {\n /**\n * Asserts that text includes required keywords.\n *\n * Example:\n * `expect('calm answer').toMustInclude(['calm'])`\n */\n toMustInclude: (keywords: string | readonly string[], options?: KeywordMatcherOptions) => void\n /**\n * Asserts that text excludes forbidden keywords.\n *\n * Example:\n * `expect('calm answer').toMustExclude(['bestmove'])`\n */\n toMustExclude: (keywords: string | readonly string[], options?: KeywordMatcherOptions) => void\n /**\n * Asserts rubric score is greater than a threshold.\n *\n * Example:\n * `expect({ score: 0.91 }).toScoreRubricGreaterThan(0.8)`\n */\n toScoreRubricGreaterThan: (threshold: number) => void\n /**\n * Asserts structured output satisfies a validator.\n *\n * Example:\n * `expect(value).toSatisfyStructuredOutput(isMyShape)`\n */\n toSatisfyStructuredOutput: <TValue>(validator: (value: unknown) => value is TValue) => void\n /**\n * Asserts selected tool-call args satisfy validator.\n *\n * Example:\n * `expect({ toolCalls }).toSatisfyToolCallArgs('builtIn_sparkCommand', isSparkArgs)`\n */\n toSatisfyToolCallArgs: (toolName: string, validator: (args: unknown) => boolean) => void\n}\n\n/* eslint-disable unused-imports/no-unused-vars */\ndeclare module '@vitest/expect' {\n interface Matchers<T = any> extends VievalCustomMatchers {}\n interface Assertion<T = any> extends VievalCustomMatchers {}\n}\n\ndeclare module 'vitest' {\n interface Assertion extends VievalCustomMatchers {}\n interface Matchers<T = any> extends VievalCustomMatchers {}\n}\n/* eslint-enable unused-imports/no-unused-vars */\n"],"mappings":";;;AAgBA,IAAI,oBAAoB;AACxB,IAAI;;;;;;;;;;;;;;AAeJ,SAAS,sCAA4C;AACnD,KAAI,kBACF;AAGF,MAAK,IAAI,WAAW;AACpB,MAAK,IAAI,eAAe;AACxB,MAAK,IAAI,oBAAoB;AAC7B,MAAK,IAAI,uBAAuB;AAChC,qBAAoB;;;;;;;;;;;;;;;;AAiBtB,SAAS,sBAAoC;AAC3C,sCAAqC;CAErC,MAAM,kBAAkB,OAAgB,Y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AGH,sBACE,UACA,UACA,WACA;GACA,MAAM,YAAa,UAAuC;AAE1D,OAAI,aAAa,KACf,QAAO;IACL,eAAe;IACf,MAAM;IACP;GAGH,MAAM,aAAa,UAAU,MAAK,SAAQ,KAAK,SAAS,SAAS;AACjE,OAAI,cAAc,KAChB,QAAO;IACL,eAAe,sBAAsB,SAAS;IAC9C,MAAM;IACP;GAGH,MAAM,OAAO,UAAU,WAAW,KAAK;AAEvC,UAAO;IACL,eAAe,OACX,+BAA+B,SAAS,wBACxC,+BAA+B,SAAS;IAC5C;IACD;;EAEJ,CAAC"}
|
|
1
|
+
{"version":3,"file":"expect-extensions-DCSqlneN.mjs","names":[],"sources":["../src/testing/runtime-expect.ts","../src/testing/expect-extensions.ts"],"sourcesContent":["import type { ExpectStatic, MatchersObject, MatcherState, Tester } from '@vitest/expect'\n\nimport {\n addCustomEqualityTesters,\n ASYMMETRIC_MATCHERS_OBJECT,\n chai,\n ChaiStyleAssertions,\n customMatchers,\n getState,\n GLOBAL_EXPECT,\n JestAsymmetricMatchers,\n JestChaiExpect,\n JestExtend,\n setState,\n} from '@vitest/expect'\n\nlet isPluginInstalled = false\nlet runtimeExpectInstance: ExpectStatic | undefined\n\n/**\n * Installs Vitest expect plugins once for process-local runtime assertions.\n *\n * Use when:\n * - running eval tasks outside Vitest worker runtime\n * - building an `expect` instance that does not rely on Vitest internal state\n *\n * Expects:\n * - `@vitest/expect` is available in runtime dependencies\n *\n * Returns:\n * - nothing; side-effects are applied to `chai`\n */\nfunction ensureRuntimeExpectPluginsInstalled(): void {\n if (isPluginInstalled) {\n return\n }\n\n chai.use(JestExtend)\n chai.use(JestChaiExpect)\n chai.use(ChaiStyleAssertions)\n chai.use(JestAsymmetricMatchers)\n isPluginInstalled = true\n}\n\n/**\n * Creates a Vitest-compatible `expect` instance without worker-state coupling.\n *\n * Use when:\n * - CLI runtime needs assertion helpers from `vieval/expect`\n * - code is executed outside `vitest run`\n *\n * Expects:\n * - plugins from {@link ensureRuntimeExpectPluginsInstalled} are installed\n * - callers do not depend on Vitest worker-only features (snapshot/poll internals)\n *\n * Returns:\n * - standalone expect instance with core matcher APIs and `extend`\n */\nfunction createRuntimeExpect(): ExpectStatic {\n ensureRuntimeExpectPluginsInstalled()\n\n const runtimeExpect = ((value: unknown, message?: string) => {\n const currentState = getState(runtimeExpect)\n setState({ assertionCalls: currentState.assertionCalls + 1 }, runtimeExpect)\n return chai.expect(value, message)\n }) as unknown as ExpectStatic\n\n Object.assign(runtimeExpect, chai.expect)\n Object.assign(runtimeExpect, (globalThis as Record<PropertyKey, unknown>)[ASYMMETRIC_MATCHERS_OBJECT] as object)\n\n runtimeExpect.getState = () => getState(runtimeExpect)\n runtimeExpect.setState = (state: Partial<MatcherState>) => setState(state, runtimeExpect)\n runtimeExpect.assert = chai.assert\n // NOTICE:\n // Chai's public `ExpectStatic` type does not expose Vitest's plugin-added `extend`.\n // Runtime `chai.expect.extend` exists after `JestExtend` plugin installation.\n // Source/context: `@vitest/expect` plugin pipeline in `dist/index.js`.\n // Removal condition: remove this cast if upstream exposes `extend` on Chai expect types.\n const chaiExpectWithExtend = chai.expect as unknown as {\n extend: (expect: ExpectStatic, matchers: MatchersObject) => void\n }\n runtimeExpect.extend = (matchers: MatchersObject) => chaiExpectWithExtend.extend(runtimeExpect, matchers)\n runtimeExpect.addEqualityTesters = (customTesters: Tester[]) => addCustomEqualityTesters(customTesters)\n runtimeExpect.unreachable = (message?: string) => {\n chai.assert.fail(`expected${message ? ` \"${message}\" ` : ' '}not to be reached`)\n }\n\n runtimeExpect.setState({\n assertionCalls: 0,\n currentTestName: '',\n expectedAssertionsNumber: null,\n expectedAssertionsNumberErrorGen: null,\n isExpectingAssertions: false,\n isExpectingAssertionsError: null,\n })\n\n runtimeExpect.extend(customMatchers)\n\n return runtimeExpect\n}\n\n/**\n * Returns process-local runtime `expect` instance used by Vieval.\n *\n * Use when:\n * - you need matcher assertions in eval files and CLI runtime\n * - importing from `vitest` would crash outside Vitest worker contexts\n *\n * Expects:\n * - single-process usage (instance is memoized per process)\n *\n * Returns:\n * - memoized runtime `expect` instance\n */\nexport function getRuntimeExpect(): ExpectStatic {\n if (runtimeExpectInstance != null) {\n return runtimeExpectInstance\n }\n\n runtimeExpectInstance = createRuntimeExpect()\n Object.defineProperty(globalThis, GLOBAL_EXPECT, {\n configurable: true,\n value: runtimeExpectInstance,\n writable: true,\n })\n\n return runtimeExpectInstance\n}\n","import type { RubricJudgeResult, ToolCall } from '../core/assertions'\n\nimport { normalizeMatchText } from '../core/assertions'\nimport { getRuntimeExpect } from './runtime-expect'\n\n/**\n * Options for keyword-based matcher behavior.\n */\nexport interface KeywordMatcherOptions {\n /**\n * Case-sensitive matching toggle.\n *\n * @default false\n */\n caseSensitive?: boolean\n /**\n * Match mode.\n *\n * @default 'all'\n */\n mode?: 'all' | 'any'\n}\n\n/**\n * Shape used by tool-call matchers.\n */\nexport interface ToolCallContainer {\n /**\n * Tool calls to inspect.\n */\n toolCalls?: readonly ToolCall[]\n}\n\nfunction toKeywordArray(keywords: string | readonly string[]): readonly string[] {\n if (typeof keywords === 'string') {\n return [keywords]\n }\n\n return keywords\n}\n\n/**\n * Registers vieval custom matchers on Vitest `expect`.\n *\n * Call stack:\n *\n * {@link installVievalExpectMatchers}\n * -> `expect.extend(...)`\n * -> `expect(received).toMustInclude(...)`\n * -> `expect(received).toScoreRubricGreaterThan(...)`\n *\n * Use when:\n * - eval suites need domain assertions while preserving native Vitest ergonomics\n * - callers want native `.not` chaining with the same matchers\n */\nexport function installVievalExpectMatchers(): void {\n const expect = getRuntimeExpect()\n\n expect.extend({\n toMustExclude(received: unknown, keywords: string | readonly string[], options: KeywordMatcherOptions = {}) {\n const keywordList = toKeywordArray(keywords)\n\n if (typeof received !== 'string') {\n return {\n message: () => 'Expected received value to be a string.',\n pass: false,\n }\n }\n\n const normalizedText = normalizeMatchText(received, options.caseSensitive ?? false)\n const forbiddenMatches = keywordList.filter((keyword) => {\n return normalizedText.includes(normalizeMatchText(keyword, options.caseSensitive ?? false))\n })\n\n const pass = forbiddenMatches.length === 0\n\n return {\n message: () => {\n if (pass) {\n return `Expected text to include forbidden keywords: ${keywordList.join(', ')}`\n }\n\n return `Expected text not to include forbidden keywords, but matched: ${forbiddenMatches.join(', ')}`\n },\n pass,\n }\n },\n\n toMustInclude(received: unknown, keywords: string | readonly string[], options: KeywordMatcherOptions = {}) {\n const keywordList = toKeywordArray(keywords)\n\n if (typeof received !== 'string') {\n return {\n message: () => 'Expected received value to be a string.',\n pass: false,\n }\n }\n\n const normalizedText = normalizeMatchText(received, options.caseSensitive ?? false)\n const matches = keywordList.filter((keyword) => {\n return normalizedText.includes(normalizeMatchText(keyword, options.caseSensitive ?? false))\n })\n\n const mode = options.mode ?? 'all'\n const pass = mode === 'all' ? matches.length === keywordList.length : matches.length > 0\n\n return {\n message: () => {\n if (pass) {\n return `Expected text not to match required keywords, but matched: ${matches.join(', ')}`\n }\n\n return `Expected text to match required keywords (${mode}), but matched ${matches.length}/${keywordList.length}.`\n },\n pass,\n }\n },\n\n toScoreRubricGreaterThan(received: unknown, threshold: number) {\n const score = typeof received === 'number'\n ? received\n : (received as RubricJudgeResult | null)?.score\n\n if (typeof score !== 'number') {\n return {\n message: () => 'Expected received value to be a number or RubricJudgeResult.',\n pass: false,\n }\n }\n\n const pass = score > threshold\n\n return {\n message: () => {\n if (pass) {\n return `Expected rubric score ${score} to be less than or equal to ${threshold}.`\n }\n\n return `Expected rubric score ${score} to be greater than ${threshold}.`\n },\n pass,\n }\n },\n\n toSatisfyStructuredOutput<T>(received: unknown, validator: (value: unknown) => value is T) {\n const pass = validator(received)\n\n return {\n message: () => pass\n ? 'Expected structured output validator to fail.'\n : 'Expected structured output validator to pass.',\n pass,\n }\n },\n\n toSatisfyToolCallArgs(\n received: unknown,\n toolName: string,\n validator: (args: unknown) => boolean,\n ) {\n const toolCalls = (received as ToolCallContainer | null)?.toolCalls\n\n if (toolCalls == null) {\n return {\n message: () => 'Expected received value to provide toolCalls array.',\n pass: false,\n }\n }\n\n const targetCall = toolCalls.find(call => call.name === toolName)\n if (targetCall == null) {\n return {\n message: () => `Expected tool call ${toolName} to exist.`,\n pass: false,\n }\n }\n\n const pass = validator(targetCall.args)\n\n return {\n message: () => pass\n ? `Expected tool call args for ${toolName} to fail validation.`\n : `Expected tool call args for ${toolName} to pass validation.`,\n pass,\n }\n },\n })\n}\n\ninterface VievalCustomMatchers {\n /**\n * Asserts that text includes required keywords.\n *\n * Example:\n * `expect('calm answer').toMustInclude(['calm'])`\n */\n toMustInclude: (keywords: string | readonly string[], options?: KeywordMatcherOptions) => void\n /**\n * Asserts that text excludes forbidden keywords.\n *\n * Example:\n * `expect('calm answer').toMustExclude(['bestmove'])`\n */\n toMustExclude: (keywords: string | readonly string[], options?: KeywordMatcherOptions) => void\n /**\n * Asserts rubric score is greater than a threshold.\n *\n * Example:\n * `expect({ score: 0.91 }).toScoreRubricGreaterThan(0.8)`\n */\n toScoreRubricGreaterThan: (threshold: number) => void\n /**\n * Asserts structured output satisfies a validator.\n *\n * Example:\n * `expect(value).toSatisfyStructuredOutput(isMyShape)`\n */\n toSatisfyStructuredOutput: <TValue>(validator: (value: unknown) => value is TValue) => void\n /**\n * Asserts selected tool-call args satisfy validator.\n *\n * Example:\n * `expect({ toolCalls }).toSatisfyToolCallArgs('builtIn_sparkCommand', isSparkArgs)`\n */\n toSatisfyToolCallArgs: (toolName: string, validator: (args: unknown) => boolean) => void\n}\n\n/* eslint-disable unused-imports/no-unused-vars */\ndeclare module '@vitest/expect' {\n interface Matchers<T = any> extends VievalCustomMatchers {}\n interface Assertion<T = any> extends VievalCustomMatchers {}\n}\n\ndeclare module 'vitest' {\n interface Assertion extends VievalCustomMatchers {}\n interface Matchers<T = any> extends VievalCustomMatchers {}\n}\n/* eslint-enable unused-imports/no-unused-vars */\n"],"mappings":";;;AAgBA,IAAI,oBAAoB;AACxB,IAAI;;;;;;;;;;;;;;AAeJ,SAAS,sCAA4C;AACnD,KAAI,kBAC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I,KACF,QAAO,yBAAyB,MAAM,+BAA+B,UAAU;AAGjF,YAAO,yBAAyB,MAAM,sBAAsB,UAAU;;IAExE;IACD;;EAGH,0BAA6B,UAAmB,WAA2C;GACzF,MAAM,OAAO,UAAU,SAAS;AAEhC,UAAO;IACL,eAAe,OACX,kDACA;IACJ;IACD;;EAGH,sBACE,UACA,UACA,WACA;GACA,MAAM,YAAa,UAAuC;AAE1D,OAAI,aAAa,KACf,QAAO;IACL,eAAe;IACf,MAAM;IACP;GAGH,MAAM,aAAa,UAAU,MAAK,SAAQ,KAAK,SAAS,SAAS;AACjE,OAAI,cAAc,KAChB,QAAO;IACL,eAAe,sBAAsB,SAAS;IAC9C,MAAM;IACP;GAGH,MAAM,OAAO,UAAU,WAAW,KAAK;AAEvC,UAAO;IACL,eAAe,OACX,+BAA+B,SAAS,wBACxC,+BAA+B,SAAS;IAC5C;IACD;;EAEJ,CAAC"}
|
package/dist/expect.mjs
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { n as getRuntimeExpect, t as installVievalExpectMatchers } from "./expect-extensions-
|
|
1
|
+
import { n as getRuntimeExpect, t as installVievalExpectMatchers } from "./expect-extensions-DCSqlneN.mjs";
|
|
2
2
|
//#region src/expect.ts
|
|
3
3
|
let isInstalled = false;
|
|
4
4
|
function ensureExpectMatchersInstalled() {
|