#!/usr/bin/env python3 """Validate JSONL provenance, counts, links and release hashes without networking.""" import sys sys.dont_write_bytecode=True import hashlib,json,re from pathlib import Path,PurePosixPath from export_dataset import rows ROOT=Path(__file__).resolve().parent.parent def main(): expected=rows();counts={} for name,source_rows in expected.items(): actual=[json.loads(line) for line in (ROOT/'data'/(name+'.jsonl')).read_text(encoding='utf-8').splitlines()] assert actual==source_rows,name assert len({r.get('case_id',r.get('claim_id',r.get('suite_id'))) for r in actual})==len(actual) columns=set(actual[0]) assert all(set(row)==columns for row in actual) assert all({k:type(v).__name__ for k,v in row.items()}=={k:type(v).__name__ for k,v in actual[0].items()} for row in actual) counts[name]=len(actual) summary=json.loads((ROOT/'metadata'/'dataset_summary.json').read_text()) assert all(summary[k]==v for k,v in counts.items()) assert sum(x['assertions_count'] for x in expected['verification_suites'])==summary['assertions_total']==711899 assert sum(x['placements_checked'] for x in expected['verification_suites'])==summary['separate_marker_placements']==192780 for file in [ROOT/'README.md',ROOT/'docs'/'DATASET_GUIDE.md']: for target in re.findall(r'\]\(([^)]+)\)',file.read_text(encoding='utf-8')): if '://' not in target and not target.startswith('#'): assert (file.parent/target.split('#')[0]).is_file(),target paths=set() for line in (ROOT/'SHA256SUMS.txt').read_text().splitlines(): digest,name=line.split(' ',1);path=PurePosixPath(name) assert not path.is_absolute() and '..' not in path.parts and name not in paths assert (ROOT/name).is_file() and not (ROOT/name).is_symlink() assert hashlib.sha256((ROOT/name).read_bytes()).hexdigest()==digest,name paths.add(name) actual_files={f.relative_to(ROOT).as_posix() for f in ROOT.rglob('*') if f.is_file()} assert actual_files==paths|{'SHA256SUMS.txt'},actual_files-paths print('JSONL provenance, uniform row schemas, counts, documentation links and checksums passed.') print(json.dumps(summary,indent=2)) if __name__=='__main__':main()