#!/usr/bin/env python3
"""Verify illustrative weekly-pack rows for FPA-REPLAY-20260823."""

from __future__ import annotations

import csv
import pathlib
import sys

EXPECTED = [
    ("opex", "contractors", "310", "total_driver"),
    ("opex", "cloud", "95", "total_driver"),
    ("opex", "travel", "-50", "total_driver"),
    ("gross_margin", "price", "-80", "total_driver"),
    ("gross_margin", "mix", "30", "total_driver"),
    ("cash_interest", "flat", "0", "total_driver"),
    ("opex", "new_vendor_component", "180", "component_of_contractors"),
]


def main() -> int:
    path = pathlib.Path(__file__).with_name("weekly-pack-FPA-REPLAY-20260823.csv")
    with path.open(newline="", encoding="utf-8") as handle:
        rows = [
            (
                row["question"],
                row["driver"],
                row["variance_usd_k"],
                row["relationship"],
            )
            for row in csv.DictReader(handle)
        ]
    if rows != EXPECTED:
        print("FAIL: weekly-pack rows do not match the desk log.", file=sys.stderr)
        return 1
    print("OK: weekly-pack rows match desk log FPA-REPLAY-20260823.")
    return 0


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