Download scripts/verify_release.py from anonymous-quantinv/hybrid50: direct link, hf CLI and curl.
- Browser
- Download file 3.72 kB
-
https://huggingface.co/datasets/anonymous-quantinv/hybrid50/resolve/main/scripts/verify_release.py
- Command line
-
hf download hf://datasets/anonymous-quantinv/hybrid50/scripts/verify_release.py
-
curl -L -o verify_release.py https://huggingface.co/datasets/anonymous-quantinv/hybrid50/resolve/main/scripts/verify_release.py
3.72 kB
| #!/usr/bin/env python3 | |
| """Check release integrity without loading a model or running an agent.""" | |
| from __future__ import annotations | |
| import argparse | |
| from collections import Counter | |
| import hashlib | |
| import json | |
| from pathlib import Path | |
| ROOT = Path(__file__).resolve().parents[1] | |
| NESTED_FIELDS = ("knowledge", "workspace", "evaluation_contract", "reference_solution") | |
| def require(condition, message): | |
| if not condition: | |
| raise ValueError(message) | |
| def verify(check_parquet=False): | |
| manifest = json.loads((ROOT / "manifest.json").read_text(encoding="utf-8")) | |
| for name, expected in manifest["files"].items(): | |
| actual = hashlib.sha256((ROOT / name).read_bytes()).hexdigest() | |
| require(actual == expected["sha256"], f"Checksum mismatch: {name}") | |
| records = [json.loads(line) for line in (ROOT / "tasks.jsonl").read_text(encoding="utf-8").splitlines()] | |
| require(len(records) == 50, "Expected 50 tasks") | |
| require([r["id"] for r in records] == [f"hybrid-{i:03d}" for i in range(1, 51)], "Unexpected task IDs/order") | |
| require(len({r["knowledge"]["source_task_id"] for r in records}) == 50, "Sources must be distinct") | |
| require(dict(Counter(r["workspace"]["scenario"] for r in records)) == manifest["scenario_counts"], "Scenario counts differ") | |
| require(all(len(r["knowledge"]["rag_corpus"]) == 12 for r in records), "Expected 12 retrieval documents per task") | |
| semantic_hash = hashlib.sha256(json.dumps(records, sort_keys=True, ensure_ascii=False).encode()).hexdigest() | |
| require(semantic_hash == manifest["canonical_data"]["parsed_records_sha256"], "Semantic checksum mismatch") | |
| replay = json.loads((ROOT / "audit/verification.json").read_text(encoding="utf-8")) | |
| audit = json.loads((ROOT / "audit/revision_audit.json").read_text(encoding="utf-8")) | |
| require(replay["dataset_sha256"] == semantic_hash, "Replay does not match release") | |
| require(audit["dataset_sha256"] == manifest["files"]["tasks.jsonl"]["sha256"], "Source audit does not match release") | |
| plan = json.loads((ROOT / "attacks/attack_plan.json").read_text(encoding="utf-8")) | |
| expected_pairs = {(r["id"], f"m{m}_g{g}") for r in records for m in (2, 3, 4, 6) for g in (1, 2, 3, 4)} | |
| pairs = [(e["task_id"], e["attack"]) for e in plan["entries"]] | |
| require(len(pairs) == 800 and set(pairs) == expected_pairs, "Attack coverage mismatch") | |
| if check_parquet: | |
| import pyarrow.parquet as pq | |
| rows = pq.read_table(ROOT / "data/test.parquet").to_pylist() | |
| reconstructed = [{"id": r["id"], "schema_version": r["schema_version"], "query": r["query"], | |
| **{f: json.loads(r[f + "_json"]) for f in NESTED_FIELDS}} for r in rows] | |
| require(reconstructed == records, "Parquet view is not lossless") | |
| statuses = {r["task_id"]: r["knowledge_status"] for r in audit["rows"]} | |
| for row, record in zip(rows, records): | |
| require(row["scenario"] == record["workspace"]["scenario"], "Scenario view mismatch") | |
| for field in ("source_task_id", "question", "reference_answer"): | |
| require(row[field] == record["knowledge"][field], f"View mismatch: {field}") | |
| require(row["evidence_status"] == statuses[row["id"]], "Evidence status mismatch") | |
| print(f"Verified 50 tasks, 600 retrieval documents, 800 attack entries, {len(manifest['files'])} file checksums" + | |
| (", and lossless Parquet round-trip." if check_parquet else ".")) | |
| if __name__ == "__main__": | |
| parser = argparse.ArgumentParser(description=__doc__) | |
| parser.add_argument("--check-parquet", action="store_true", help="Also require pyarrow and check the Hub view") | |
| args = parser.parse_args() | |
| verify(args.check_parquet) | |