"""Explicit provider check; ordinary Studio compilation does not invoke this tool.""" import argparse import hashlib import pathlib import platform import subprocess import tempfile def main(): parser = argparse.ArgumentParser(description=__doc__) parser.add_argument("--runtime", type=pathlib.Path, required=True) args = parser.parse_args() studio = pathlib.Path(__file__).resolve().parents[2] mirror = studio / "docs/vm-arch" properties = dict(line.split("=", 1) for line in (mirror / "runtime-catalog.properties").read_text().splitlines() if line) runtime = args.runtime.resolve(strict=True) revision = subprocess.check_output(["git", "-C", str(runtime), "rev-parse", "HEAD"], text=True).strip() if revision != properties["runtime.revision"]: raise SystemExit(f"Expected selected provider {properties['runtime.revision']}, found {revision}; " "this is an evidence-target mismatch, not a runtime compatibility verdict") # Evidence must correspond to committed source, not just two matching local copies. dirty = subprocess.check_output(["git", "-C", str(runtime), "status", "--porcelain"], text=True) if dirty: raise SystemExit("Provider checkout is dirty; verify the selected revision in a clean checkout") for name in ("INTRINSICS.csv", "BUILTIN_CONSTANTS.csv"): committed = subprocess.check_output(["git", "-C", str(runtime), "show", f"{revision}:docs/vm-arch/{name}"]) if committed != (runtime / "docs/vm-arch" / name).read_bytes() or committed != (mirror / name).read_bytes(): raise SystemExit(f"Provider/mirror bytes differ: {name}") digest = hashlib.sha256(committed).hexdigest() if digest != properties[name + ".sha256"]: raise SystemExit(f"Provenance hash mismatch: {name}") print(f"MATCH {name} sha256={digest}", flush=True) print(f"Provider {revision}; {platform.platform()}; Cargo test profile, default features", flush=True) with tempfile.TemporaryDirectory(prefix="studio-catalog-provider-") as target: subprocess.run(["cargo", "test", "--locked", "--offline", "--target-dir", target, "-p", "prometeu-vm", "--test", "numeric_contract", "exported_artifacts_match_the_single_runtime_catalog", "--", "--exact"], cwd=runtime, check=True) if __name__ == "__main__": main()