#!/usr/bin/env python3
"""Verify published aggregate rows for desk log ADR-HMT-20260825.

This script checks the first-party CSV only. It does not reconstruct the
unbound-chat versus pack-bound run, and it is not a third-party
audit or reproduction.
"""

from __future__ import annotations

import csv
import pathlib
import sys

EXPECTED = [
    {
        "retrieval_state": "unbound_chat",
        "bound_sentence_retrieved": "0",
        "window_matches_pack": "0",
        "marketplace_excluded": "0",
        "rows": "14820",
    },
    {
        "retrieval_state": "pack_bound",
        "bound_sentence_retrieved": "1",
        "window_matches_pack": "1",
        "marketplace_excluded": "1",
        "rows": "12410",
    },
]


def main() -> int:
    csv_path = pathlib.Path(__file__).with_name(
        "aggregate-ADR-HMT-20260825.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 ADR-HMT-20260825.")
    return 0


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