#!/usr/bin/env python3
"""Verify published and suppressed rows for PA-TENURE-20260823."""

from __future__ import annotations

import csv
import pathlib
import sys


def main() -> int:
    path = pathlib.Path(__file__).with_name("attrition-aggregate-PA-TENURE-20260823.csv")
    with path.open(newline="", encoding="utf-8") as handle:
        rows = list(csv.DictReader(handle))
    published = {
        row["period"]: row["voluntary_attrition_pct"]
        for row in rows
        if row["status"] == "published"
    }
    suppressed = [row for row in rows if row["status"] == "suppressed_n_under_5"]
    if published != {"prior_quarter": "6.1", "current_quarter": "8.4"}:
        print("FAIL: published rates do not match the desk log.", file=sys.stderr)
        return 1
    if len(suppressed) != 2 or any(row["voluntary_attrition_pct"] for row in suppressed):
        print("FAIL: suppressed-cell handling is incorrect.", file=sys.stderr)
        return 1
    print("OK: 6.1/8.4 rates and two blank suppressed cells verified.")
    return 0


if __name__ == "__main__":
    raise SystemExit(main())
