# recoil/pipeline/tests/test_coverage_routing_config.py
"""pipeline_config.json coverage_strategy.model_routing regression tests.

Locks the JT directive (2026-04-19) that ALL coverage passes default to
seeddance-2.0 — kills the prior veo-3.1/kling-v3 routing that produced
mode='t2v' artifacts. If a future engineer wants to restore tier-based
routing, they must consciously break this test and confirm the change.
"""

import json
from pathlib import Path

PIPELINE_CONFIG_PATH = (
    Path(__file__).resolve().parent.parent.parent / "config" / "pipeline_config.json"
)


def _routing() -> dict:
    cfg = json.loads(PIPELINE_CONFIG_PATH.read_text(encoding="utf-8"))
    return cfg["coverage_strategy"]["model_routing"]


def test_model_routing_defaults_to_seeddance_for_every_tier():
    routing = _routing()
    failures = []
    for key, value in routing.items():
        if key.startswith("_"):
            continue
        if value != "seeddance-2.0":
            failures.append(
                f"model_routing.{key} = '{value}' (expected 'seeddance-2.0')"
            )
    assert not failures, (
        "Per JT directive 2026-04-19, every coverage routing tier defaults to "
        "seeddance-2.0. To change a tier, update both this test and the project memory.\n"
        + "\n".join(failures)
    )


def test_required_routing_keys_present():
    routing = _routing()
    required = {"env_any_tier", "character_default", "climax"}
    missing = required - set(routing.keys())
    assert not missing, f"model_routing missing keys: {sorted(missing)}"
