#!/usr/bin/env python3
"""Verify illustrative rows for desk run FPA-PLANV2-20260823."""

from __future__ import annotations

import csv
import pathlib
import sys

EXPECTED = [
    ("contracted_services", "280", "contractor_spend", "total_variance"),
    ("cloud", "120", "usage_and_true_up", "total_variance"),
    ("travel", "-40", "lower_travel_spend", "total_variance"),
    ("mapping_miss", "35", "cost_center_parent_error", "total_variance"),
    ("cloud_true_up_component", "90", "true_up", "component_of_cloud_variance"),
]


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


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