#!/usr/bin/env python3
"""Verify published aggregate rows for desk log AIDB-OPS-PACK-20260822.

This script checks the first-party CSV only. It does not reconstruct the
static-tile versus same-goal-rerun, and it is not a third-party reproduction.
"""

from __future__ import annotations

import csv
import pathlib
import sys

EXPECTED = [
    {
        "state": "static_weekend_tiles",
        "charts": "0",
        "memo": "0",
        "inspectable_sql": "0",
        "postgres_misses_freshness_hours": "48",
        "sku_notes_freshness_hours": "72",
        "standup_pack_freshness_hours": "36",
        "reviewer_downloadable": "no",
    },
    {
        "state": "first_party_same_goal_rerun",
        "charts": "3",
        "memo": "1",
        "inspectable_sql": "1",
        "postgres_misses_freshness_hours": "2",
        "sku_notes_freshness_hours": "1",
        "standup_pack_freshness_hours": "2",
        "reviewer_downloadable": "yes",
    },
]


def main() -> int:
    csv_path = pathlib.Path(__file__).with_name(
        "aggregate-AIDB-OPS-PACK-20260822.csv"
    )
    with csv_path.open(newline="", encoding="utf-8") as handle:
        rows = list(csv.DictReader(handle))
    if rows != EXPECTED:
        print("FAIL: published aggregate rows do not match the desk log.", file=sys.stderr)
        return 1
    print("OK: published aggregate rows match desk log AIDB-OPS-PACK-20260822.")
    return 0


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