#!/usr/bin/env python3
"""Verify fire-risk QA scenarios and supporting gates are documented."""

from pathlib import Path


ROOT = Path(__file__).resolve().parents[1]
QA_DOC = ROOT / "Docs" / "QA" / "FireRiskQACoverage.md"
ROADMAP = ROOT / "AGRARIAN_DEVELOPMENT_ROADMAP.md"

REQUIRED_SCENARIOS = [
    "Safe campfire",
    "Unsafe campfire",
    "Vegetation spread",
    "Shelter ignition",
    "Suppression",
    "Save/load recovery",
]

REQUIRED_SCRIPTS = [
    "verify_unattended_fire_risk.py",
    "verify_vegetation_ignition_checks.py",
    "verify_structure_ignition_risk.py",
    "verify_fire_spread_rules.py",
    "verify_fire_maintenance_gameplay.py",
    "verify_fire_suppression_hooks.py",
    "verify_fire_persistence_state.py",
    "verify_fire_risk_qa_coverage.py",
]


def main() -> None:
    doc = QA_DOC.read_text(encoding="utf-8")
    roadmap = ROADMAP.read_text(encoding="utf-8")

    missing = []
    for scenario in REQUIRED_SCENARIOS:
        if scenario not in doc:
            missing.append(f"QA doc missing scenario {scenario!r}")

    for script in REQUIRED_SCRIPTS:
        if script not in doc:
            missing.append(f"QA doc missing script {script!r}")
        if not (ROOT / "Scripts" / script).exists():
            missing.append(f"required script does not exist: Scripts/{script}")

    for token in [
        "`FireRiskScore`",
        "StructureIgnitionRiskScore",
        "suppression pressure",
        "spread radius",
        "server",
    ]:
        if token not in doc:
            missing.append(f"QA doc missing token {token!r}")

    if "[x] Add QA coverage for safe campfires" not in roadmap:
        missing.append("roadmap item is not checked off")

    if missing:
        raise SystemExit("FAILED: " + "; ".join(missing))

    print("OK: fire-risk QA coverage is documented and tied to verifiers.")


if __name__ == "__main__":
    main()
