/**
 * pipeline/rubric-loader.ts — Load and validate rubric config.
 *
 * Extracted from the legacy expand-tasks.ts so that callers (e.g.,
 * calculate-scores.ts) can load rubric templates without pulling in
 * the deprecated task expansion machinery.
 *
 * @see packages/eval/config/rubrics.ts — the rubric configuration
 * @see packages/core/src/schemas/pipeline.ts — RubricConfigSchema
 */
import { RubricConfigSchema } from "../_vendor/ailf-core/index.js";
import { loadConfigFile } from "./compiler/config-loader.js";
let cachedRubricConfig = null;
/**
 * Load and validate config/rubrics from the given root directory.
 * Caches the result for subsequent calls with the same rootDir.
 */
export function loadRubricTemplates(rootDir) {
    if (cachedRubricConfig)
        return cachedRubricConfig;
    const { data } = loadConfigFile("rubrics", rootDir);
    const result = RubricConfigSchema.safeParse(data);
    if (!result.success) {
        const messages = result.error.issues
            .map((i) => `  [${i.path.join(".")}]: ${i.message}`)
            .join("\n");
        throw new Error(`Invalid config/rubrics:\n${messages}`);
    }
    cachedRubricConfig = result.data;
    return result.data;
}
/**
 * Reset the rubric config cache. Useful in tests.
 */
export function resetRubricCache() {
    cachedRubricConfig = null;
}
