#!/usr/bin/env python3
"""Verify illustrative Budget v3 drivers for WIFPA-BV3-20260823."""

from __future__ import annotations

import csv
import pathlib
import sys


def main() -> int:
    path = pathlib.Path(__file__).with_name("driver-table-WIFPA-BV3-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 != 515 or component["variance_usd_k"] != "110":
        print("FAIL: driver total or cloud component is incorrect.", file=sys.stderr)
        return 1
    print("OK: total drivers equal 515 and true-up remains a cloud component.")
    return 0


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