#!/usr/bin/env python3
"""Regenerate evidence/vsphere-*.json ledgers from the live coverage matrix."""

from __future__ import annotations

import json
from pathlib import Path

from app.vsphere.contracts.compatibility import evidence_ledger
from app.vsphere.contracts.matrix import VERSIONS

ROOT = Path(__file__).resolve().parents[1] / "evidence"


def main() -> int:
    ROOT.mkdir(parents=True, exist_ok=True)
    for major, meta in VERSIONS.items():
        payload = evidence_ledger(major)
        path = ROOT / f"vsphere-{meta['version']}.json"
        path.write_text(json.dumps(payload, indent=2) + "\n", encoding="utf-8")
        summary = payload["summary"]
        print(
            f"{path}  implemented={summary['implemented_methods']}/"
            f"{summary['universe_methods']}  coverage={summary['coverage']}"
        )
    return 0


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