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

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

from __future__ import annotations

import csv
import pathlib
import sys

EXPECTED = [
    {
        "state": "invite_paste",
        "chat_screenshots": "1",
        "downloadable_charts": "0",
        "csv_and_memo": "0",
        "manifest_present": "no",
        "inspectable_lineage": "no",
        "reviewer_opened": "no",
    },
    {
        "state": "first_party_workspace_download",
        "chat_screenshots": "0",
        "downloadable_charts": "3",
        "csv_and_memo": "2",
        "manifest_present": "yes",
        "inspectable_lineage": "yes",
        "reviewer_opened": "yes",
    },
]


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


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