#!/usr/bin/env python3
"""Verify illustrative opex drivers for FPA-OPEX-20260823."""

from __future__ import annotations

import csv
import pathlib
import sys


def main() -> int:
    path = pathlib.Path(__file__).with_name("driver-table-FPA-OPEX-20260823.csv")
    with path.open(newline="", encoding="utf-8") as handle:
        rows = list(csv.DictReader(handle))
    total = sum(
        int(row["variance_usd_k"])
        for row in rows
        if row["relationship"] == "total_driver"
    )
    component = next(
        row for row in rows if row["relationship"] == "component_of_cloud"
    )
    if total != 570 or component["variance_usd_k"] != "140":
        print("FAIL: total or true-up component does not match the desk log.", file=sys.stderr)
        return 1
    print("OK: total drivers equal 570 and true-up remains a cloud component.")
    return 0


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