#!/usr/bin/env python3
"""Verify illustrative weekly outputs for EWTP-REPLAY-20260823."""

from __future__ import annotations

import csv
import pathlib
import sys


EXPECTED = ["17200", "1210", "88", "18100", "1224", "91", "4", "1"]


def main() -> int:
    path = pathlib.Path(__file__).with_name("weekly-summary-EWTP-REPLAY-20260823.csv")
    with path.open(newline="", encoding="utf-8") as handle:
        rows = list(csv.DictReader(handle))
    values = [row["value"] for row in rows if row["status"] == "published"]
    held = [row for row in rows if row["status"].startswith("held_")]
    if values != EXPECTED or len(held) != 2:
        print("FAIL: weekly outputs or held actions are incorrect.", file=sys.stderr)
        return 1
    if any(row["value"] for row in held):
        print("FAIL: a held action exposes a result.", file=sys.stderr)
        return 1
    print("OK: eight weekly aggregates and two held actions verified.")
    return 0


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