"""Verify primary video models have safety_filter_words populated
(Opus Finding 5, 2026-04-09). The word lists are kept as profile data for a
future Veo-4 safety scrub; their only consumer (VideoEnhancementCritic / IP5)
was retired 2026-06-09 when enrichment was superseded by prose_author."""

import json
from pathlib import Path


def _canonical_profiles_path() -> Path:
    """The canonical profiles file is at recoil/config/model_profiles.json."""
    from recoil.core.paths import CONFIG_DIR

    return CONFIG_DIR / "model_profiles.json"


def test_canonical_profiles_file_exists():
    p = _canonical_profiles_path()
    assert p.exists(), f"Canonical model_profiles.json missing: {p}"


def test_kling_models_have_safety_filter_words():
    profiles = json.loads(_canonical_profiles_path().read_text())
    kling_models = [k for k in profiles.keys() if "kling" in k.lower()]
    assert kling_models, "No Kling models in profiles"
    for model in kling_models:
        words = profiles[model].get("safety_filter_words", [])
        assert len(words) >= 5, f"{model} has empty/sparse safety_filter_words: {words}"


def test_seedance_has_safety_filter_words():
    profiles = json.loads(_canonical_profiles_path().read_text())
    seedance_models = [
        k
        for k in profiles.keys()
        if "seed" in k.lower() and "video" in profiles[k].get("modality", "")
    ]
    for model in seedance_models:
        words = profiles[model].get("safety_filter_words", [])
        assert len(words) >= 5, f"{model} has empty safety_filter_words"
