Datasets:
File size: 1,903 Bytes
5d12def | 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 | """Verify the unpacked public release using only the Python standard library."""
import hashlib
import json
from pathlib import Path
ROOT = Path(__file__).resolve().parent
KB = ROOT / "kernel_bench"
def read(path):
return json.loads(path.read_bytes())
def digest(path):
return hashlib.sha256(path.read_bytes()).hexdigest()
def verify():
manifest = read(ROOT / "source-manifest.json")
for name, wanted in manifest.items():
path = ROOT / name
if not path.is_file() or path.is_symlink() or digest(path) != wanted:
raise ValueError(f"Missing or modified release file: {name}")
catalog = read(KB / "kernel_catalog_v081.json")["tasks"]
packs = KB / "taskpacks/v0.8.1-kernels"
tasks = {row["id"] for row in catalog}
if tasks != {p.name for p in packs.iterdir() if p.is_dir()} or len(tasks) != 51:
raise ValueError("Task inventory mismatch")
suite = read(KB / "suites/kernel_v081_public.json")
for spec in catalog:
task = spec["id"]
path = packs / task
meta = read(path / "task.json")
for name, field in (("TASK.md", "prompt_sha256"), ("contracts.md", "contract_sha256")):
if digest(path / name) != meta[field]:
raise ValueError(f"{task}: {name} differs from its frozen digest")
cases = [c for c in suite["cases"] if c["task"] == task]
if cases != read(path / "public_cases.json")["cases"] or not cases:
raise ValueError(f"{task}: public cases differ from the suite")
for task, spec in read(KB / "baseline_v081/references.json").items():
if digest(KB / "baseline_v081" / (task + ".py")) != spec["sha256"]:
raise ValueError(f"{task}: frozen performance reference changed")
print(f"Verified {len(manifest)} files, {len(tasks)} packs, {len(suite['cases'])} public cases.")
if __name__ == "__main__":
verify()
|