#!/usr/bin/env python3
"""Verify illustrative store-web outputs for EDA-SKU-20260823."""

from __future__ import annotations

import csv
import pathlib
import sys


EXPECTED = {
    "store_lines": "9400",
    "web_lines": "7100",
    "unmapped_barcodes": "740",
    "pickup_overlap": "210",
    "rank_flips": "6",
    "store_share_change": "-4.2",
}


def main() -> int:
    path = pathlib.Path(__file__).with_name("store-web-summary-EDA-SKU-20260823.csv")
    with path.open(newline="", encoding="utf-8") as handle:
        rows = list(csv.DictReader(handle))
    observed = {row["metric"]: row["value"] for row in rows if row["status"] == "published"}
    held = [row for row in rows if row["status"].startswith("held_")]
    if observed != EXPECTED or len(held) != 2:
        print("FAIL: store-web 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: six store-web aggregates and two held actions verified.")
    return 0


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