claimcheck-bench / validate.py
Luka
Publish claimcheck-bench v1: 300 synthetic agent traces
60a732e verified
Raw History Blame Contribute Delete
2.99 kB
"""Validate this publication: python -m pip install pyarrow; python validate.py.
Checks the preserved source hashes, split counts, Parquet schema, and exact
reconstruction of every canonical trace. Uses no network or API credentials.
"""
from collections import Counter
from hashlib import sha256
import json
from pathlib import Path
import pyarrow as pa
import pyarrow.parquet as pq
ROOT = Path(__file__).resolve().parent
COLUMNS = [
"trace_id", "domain", "instruction", "final_claim_text", "outcome",
"failure_kind", "evidence", "trace_json",
]
SCHEMA = pa.schema([(column, pa.string()) for column in COLUMNS])
def main() -> None:
manifest = json.loads((ROOT / "manifest.json").read_text())
provenance = json.loads((ROOT / "provenance.json").read_text())
seen = set()
for split, expected_count in [("train", 180), ("test", 120)]:
raw_path = ROOT / f"traces.{split}.jsonl"
raw_bytes = raw_path.read_bytes()
assert sha256(raw_bytes).hexdigest() == manifest["sha256"][raw_path.name]
lines = raw_bytes.decode("utf-8").splitlines()
traces = [json.loads(line) for line in lines]
table = pq.read_table(ROOT / f"{split}.parquet")
assert table.schema == SCHEMA, table.schema
assert table.num_rows == len(traces) == expected_count
assert all(column.null_count == 0 for column in table.columns)
rows = table.to_pylist()
for line, trace, row in zip(lines, traces, rows):
assert row["trace_json"] == line
assert json.loads(row["trace_json"]) == trace
expected = {
"trace_id": trace["trace_id"],
"domain": trace["task"]["domain"],
"instruction": trace["task"]["instruction"],
"final_claim_text": trace["final_claim"]["text"],
"outcome": trace["ground_truth"]["outcome"],
"failure_kind": trace["ground_truth"]["details"].get("injection", "none"),
"evidence": trace["ground_truth"]["details"]["evidence"],
"trace_json": line,
}
assert row == expected
assert row["trace_id"] not in seen
seen.add(row["trace_id"])
assert dict(Counter(row["outcome"] for row in rows)) == provenance["splits"][split]["outcomes"]
assert dict(Counter(row["domain"] for row in rows)) == provenance["splits"][split]["domains"]
print(f"{split}: {expected_count} traces; hashes, columns, labels and exact reconstruction OK")
for relpath, digest in provenance["preserved_files_sha256"].items():
assert sha256((ROOT / relpath).read_bytes()).hexdigest() == digest, relpath
for relpath, digest in provenance["derived_files_sha256"].items():
assert sha256((ROOT / relpath).read_bytes()).hexdigest() == digest, relpath
assert len(seen) == 300
print("PASS: 300 unique traces; all recorded file hashes verified")
if __name__ == "__main__":
main()