| |
| """Verify FrontierChallenge HF package checksums and release invariants.""" |
| from __future__ import annotations |
|
|
| import hashlib |
| import json |
| from pathlib import Path |
|
|
| |
| |
| ROOT = Path(__file__).absolute().parents[1] |
| EXPECTED_TASKS = 97 |
| EXPECTED_IMAGE_ARCHIVE = True |
|
|
|
|
| def digest(path: Path) -> str: |
| h = hashlib.sha256() |
| with path.open("rb") as handle: |
| for block in iter(lambda: handle.read(1024 * 1024), b""): |
| h.update(block) |
| return h.hexdigest() |
|
|
|
|
| def main() -> int: |
| rows = [json.loads(line) for line in (ROOT / "manifest.jsonl").read_text().splitlines()] |
| if len(rows) != EXPECTED_TASKS or len({row["task_id"] for row in rows}) != EXPECTED_TASKS: |
| raise SystemExit(f"expected {EXPECTED_TASKS} unique tasks, found {len(rows)}") |
| if {row["difficulty"] for row in rows} - {"hard", "medium"}: |
| raise SystemExit("manifest contains an unknown difficulty label") |
| if any(not row.get("domain") or not row.get("subdomain") for row in rows): |
| raise SystemExit("manifest contains a task without domain labels") |
| if any(row.get("tags") != [row["domain"], row["subdomain"]] for row in rows): |
| raise SystemExit("manifest taxonomy/tag fields disagree") |
| if json.loads((ROOT / "missing_assets.json").read_text()).get("files"): |
| raise SystemExit("package is incomplete: missing_assets.json is non-empty") |
| missing_runtime = [] |
| for row in rows: |
| task = ROOT / "tasks" / row["task_id"] |
| for relative in ("task.toml", "instruction.md", "environment/Dockerfile"): |
| if not (task / relative).is_file(): |
| missing_runtime.append(f"{row['task_id']}/{relative}") |
| instruction_path = task / "instruction.md" |
| if instruction_path.is_file(): |
| instruction = instruction_path.read_text(encoding="utf-8") |
| if row.get("instruction") != instruction: |
| raise SystemExit(f"manifest instruction mismatch: {row['task_id']}") |
| if missing_runtime: |
| raise SystemExit(f"runtime files missing: {', '.join(missing_runtime[:10])}") |
| image_counts = {} |
| contract_failures = [] |
| for row in rows: |
| image = row["environment"] |
| image_counts[image] = image_counts.get(image, 0) + 1 |
| dockerfile = ROOT / "tasks" / row["task_id"] / "environment" / "Dockerfile" |
| if image == "licensed-orca" and "frontierchallenge/orca-user-local:6.0.1" not in dockerfile.read_text(errors="ignore"): |
| contract_failures.append(row["task_id"]) |
| if image_counts != {"open": 81, "licensed-orca": 16}: |
| raise SystemExit(f"unexpected task image split: {image_counts}") |
| if contract_failures: |
| raise SystemExit(f"ORCA tasks do not use the local-only contract: {contract_failures[:10]}") |
| optional_archive = None |
| image_manifest = ROOT / "images" / "manifest.json" |
| if EXPECTED_IMAGE_ARCHIVE: |
| if not image_manifest.is_file(): |
| raise SystemExit("HF image archive manifest is missing") |
| image = json.loads(image_manifest.read_text()) |
| if image.get("format") != "docker-archive+zstd": |
| raise SystemExit("unsupported HF image archive format") |
| if image.get("platform") != "linux/amd64" or image.get("contains_orca") is not False: |
| raise SystemExit("HF image archive violates the open-image contract") |
| optional_archive = f"images/{image.get('archive')}" |
| orca_payloads = [ |
| p for p in ROOT.rglob("*") if p.is_file() and ( |
| p.name.lower() == "orca" |
| or ( |
| p.name.lower().startswith("orca") |
| and any(p.name.lower().endswith(suffix) for suffix in ( |
| ".run", ".exe", ".zip", ".tar", ".tar.gz", ".tar.xz" |
| )) |
| ) |
| ) |
| ] |
| if orca_payloads: |
| raise SystemExit(f"ORCA binary/installer found in solve package: {orca_payloads[0]}") |
| forbidden = [p for p in ROOT.rglob("*") if p.is_file() and ( |
| "tests" in p.relative_to(ROOT).parts |
| or p.name in {"instruction.zh.md", "statement.fcref", "verifier.fcref"} |
| )] |
| if forbidden: |
| raise SystemExit(f"plaintext evaluator/task material found: {forbidden[0]}") |
| failures = [] |
| for line in (ROOT / "checksums.sha256").read_text().splitlines(): |
| expected, relative = line.split(" ", 1) |
| path = ROOT / relative |
| if not path.is_file() and relative == optional_archive: |
| continue |
| if not path.is_file() or digest(path) != expected: |
| failures.append(relative) |
| if failures: |
| raise SystemExit(f"checksum failures: {', '.join(failures[:10])}") |
| print(f"ok: {EXPECTED_TASKS} tasks, complete inputs, checksums verified") |
| return 0 |
|
|
|
|
| if __name__ == "__main__": |
| raise SystemExit(main()) |
|
|