// engine/compact/registry-loader.ts — SPEC-922: Load compact-thresholds.json registry
import { readFileSync } from 'node:fs';
import { join } from 'node:path';
import { loadThresholds } from './threshold-evaluator.js';
const REGISTRY_PATH = join(process.cwd(), 'src', 'config', 'registries', 'compact-thresholds.json');
let cachedThresholds;
/** Load thresholds from disk; caches after first read. */
export function loadCompactThresholds() {
    if (cachedThresholds !== undefined) {
        return cachedThresholds;
    }
    try {
        const raw = readFileSync(REGISTRY_PATH, 'utf8');
        const parsed = JSON.parse(raw);
        cachedThresholds = loadThresholds(parsed);
        return cachedThresholds;
    }
    catch {
        // Fail-safe: return defaults on any error
        cachedThresholds = loadThresholds(undefined);
        return cachedThresholds;
    }
}
/** Invalidate cache (useful in tests). */
export function invalidateCompactThresholdsCache() {
    cachedThresholds = undefined;
}
//# sourceMappingURL=registry-loader.js.map