|
| 1 | +"""Reference-authority snapshot: flagship release alignment for dashboards and CI.""" |
| 2 | + |
| 3 | +from __future__ import annotations |
| 4 | + |
| 5 | +import json |
| 6 | +from datetime import UTC, datetime |
| 7 | +from pathlib import Path |
| 8 | +from typing import Any |
| 9 | + |
| 10 | +_FLAGSHIP_RUN_ID = "host-realistic-20260525" |
| 11 | +_FAMILY_ID = "conicshield-transition-bank-v1" |
| 12 | + |
| 13 | + |
| 14 | +def _load_json(path: Path) -> dict[str, Any]: |
| 15 | + return json.loads(path.read_text(encoding="utf-8")) |
| 16 | + |
| 17 | + |
| 18 | +def build_reference_authority_snapshot(*, repo_root: Path | None = None) -> dict[str, Any]: |
| 19 | + """Machine-readable flagship + family release state from committed artifacts.""" |
| 20 | + root = repo_root if repo_root is not None else Path.cwd() |
| 21 | + current_path = root / "benchmarks" / "releases" / _FAMILY_ID / "CURRENT.json" |
| 22 | + current = _load_json(current_path) |
| 23 | + registry = _load_json(root / "benchmarks" / "registry.json") |
| 24 | + fam = next(f for f in registry["benchmark_families"] if f["family_id"] == _FAMILY_ID) |
| 25 | + |
| 26 | + flagship_dir = root / "benchmarks" / "published_runs" / _FLAGSHIP_RUN_ID |
| 27 | + prov = _load_json(flagship_dir / "RUN_PROVENANCE.json") if (flagship_dir / "RUN_PROVENANCE.json").is_file() else {} |
| 28 | + gov = ( |
| 29 | + _load_json(flagship_dir / "governance_status.json") |
| 30 | + if (flagship_dir / "governance_status.json").is_file() |
| 31 | + else {} |
| 32 | + ) |
| 33 | + export_prov_path = root / "benchmarks" / "external_evidence" / "EXPORT_PROVENANCE.json" |
| 34 | + export_prov = _load_json(export_prov_path) if export_prov_path.is_file() else {} |
| 35 | + |
| 36 | + gates_ok = all(current.get(g) == "green" for g in ("artifact_gate", "parity_gate", "promotion_gate")) |
| 37 | + native_ok = "shielded-native-moreau" in (current.get("publishable_arms") or []) |
| 38 | + bundle_ok = f"benchmarks/published_runs/{_FLAGSHIP_RUN_ID}" in (current.get("benchmark_bundle_paths") or []) |
| 39 | + gov_gates_ok = gov and all(gov.get(g) == "green" for g in ("parity_gate", "promotion_gate")) |
| 40 | + aligned = ( |
| 41 | + current.get("current_run_id") == _FLAGSHIP_RUN_ID |
| 42 | + and fam.get("current_run_id") == _FLAGSHIP_RUN_ID |
| 43 | + and current.get("state") == "published" |
| 44 | + and prov.get("evidence_tier") == "vendor_native" |
| 45 | + and prov.get("projector_mode") == "real_projector" |
| 46 | + and gates_ok |
| 47 | + and native_ok |
| 48 | + and bundle_ok |
| 49 | + and gov_gates_ok |
| 50 | + ) |
| 51 | + |
| 52 | + return { |
| 53 | + "schema_version": "conicshield_reference_authority_snapshot/v1", |
| 54 | + "generated_at_utc": datetime.now(UTC).strftime("%Y-%m-%dT%H:%M:%SZ"), |
| 55 | + "family_id": _FAMILY_ID, |
| 56 | + "flagship_run_id": _FLAGSHIP_RUN_ID, |
| 57 | + "aligned": aligned, |
| 58 | + "current_release": { |
| 59 | + "current_run_id": current.get("current_run_id"), |
| 60 | + "state": current.get("state"), |
| 61 | + "publishable_arms": current.get("publishable_arms"), |
| 62 | + "artifact_gate": current.get("artifact_gate"), |
| 63 | + "parity_gate": current.get("parity_gate"), |
| 64 | + "promotion_gate": current.get("promotion_gate"), |
| 65 | + "benchmark_bundle_paths": current.get("benchmark_bundle_paths"), |
| 66 | + }, |
| 67 | + "flagship_provenance": { |
| 68 | + "evidence_tier": prov.get("evidence_tier"), |
| 69 | + "projector_mode": prov.get("projector_mode"), |
| 70 | + "source_export_json": prov.get("source_export_json"), |
| 71 | + }, |
| 72 | + "flagship_governance": { |
| 73 | + "state": gov.get("state"), |
| 74 | + "parity_gate": gov.get("parity_gate"), |
| 75 | + "promotion_gate": gov.get("promotion_gate"), |
| 76 | + }, |
| 77 | + "export_provenance": { |
| 78 | + "export_kind": export_prov.get("export_kind"), |
| 79 | + "export_json": export_prov.get("export_json"), |
| 80 | + }, |
| 81 | + } |
0 commit comments