from __future__ import annotations

from dataclasses import asdict, dataclass


@dataclass(frozen=True)
class N8nRetirementChecklist:
    inventory_disposition_complete: bool
    all_dataflows_kestra_primary: bool
    business_cycle_and_recovery_complete: bool
    standby_observation_no_rollback: bool
    monitoring_and_alerting_complete: bool
    dependency_failures_safe: bool
    secure_archive_complete: bool
    independent_review_approved: bool
    final_l4_passed: bool


class N8nRetirementGate:
    @staticmethod
    def evaluate(checklist: N8nRetirementChecklist):
        if not isinstance(checklist, N8nRetirementChecklist):
            raise ValueError("n8n retirement checklist is required")
        evidence = asdict(checklist)
        missing = [
            name for name, passed in evidence.items() if passed is not True
        ]
        return {
            "status": "blocked" if missing else "approved",
            "retirement_approved": not missing,
            "missing": missing,
        }
