#!/usr/bin/env python3
"""Verify illustrative join outputs for AERS-JOIN-20260823."""

from __future__ import annotations

import csv
import pathlib
import sys


EXPECTED = ["64200", "2.9", "1.1", "0.3"]


def main() -> int:
    path = pathlib.Path(__file__).with_name("join-summary-AERS-JOIN-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_", "rejected_"))]
    if values != EXPECTED or len(held) != 2 or any(row["value"] for row in held):
        print("FAIL: join outputs or held items are incorrect.", file=sys.stderr)
        return 1
    print("OK: four join aggregates and two held items verified.")
    return 0


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