#!/usr/bin/env python3
"""Verify published aggregate rows for desk log FLF-UFA-20260822.

This script checks the first-party CSV only. It does not reconstruct the
zip-versus-directory run, and it is not a third-party reproduction.
"""

from __future__ import annotations

import csv
import pathlib
import sys

EXPECTED = [
    {
        "retrieval_state": "email_zip_as_chat",
        "folder_registered": "0",
        "week9_extra_field_profiled": "0",
        "file_counts_reconciled": "0",
    },
    {
        "retrieval_state": "directory_as_source",
        "folder_registered": "1",
        "week9_extra_field_profiled": "1",
        "file_counts_reconciled": "1",
    },
]


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


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