/**
 * Phase-level model routing — per-phase model selection with fallback cascade.
 *
 * Sprint-563: B4 — PhaseModelConfig + ModelSpec.fallback + resolveForPhase.
 *
 * Each OODA phase can specify its own model, independent of other phases.
 * When a provider fails (429/503), the fallback cascade tries the next model.
 * resolveForPhase(phaseModels, phase) returns the resolved ModelSpec.
 */
/**
 * Resolve the ModelSpec for a given phase. Falls back to defaultModel if
 * the phase has no explicit config.
 */
export function resolveForPhase(config, phase) {
    return config.phases[phase] ?? config.defaultModel;
}
/**
 * Get the full fallback chain for a phase — the primary model first,
 * then its fallback cascade, then defaultModel + its cascade.
 */
export function getFallbackChain(config, phase) {
    const primary = config.phases[phase];
    const chain = [];
    if (primary) {
        chain.push(primary);
        if (primary.fallback)
            chain.push(...primary.fallback);
    }
    // Always append default as last resort
    chain.push(config.defaultModel);
    if (config.defaultModel.fallback)
        chain.push(...config.defaultModel.fallback);
    // Deduplicate by provider+model
    const seen = new Set();
    return chain.filter((spec) => {
        const key = `${spec.provider}:${spec.model}`;
        if (seen.has(key))
            return false;
        seen.add(key);
        return true;
    });
}
//# sourceMappingURL=phase-routing.js.map