cert_atlas.hf_export
Export the atlas as flat JSON splits for dataset hubs.
The atlas is natively a set of directories and file groups, which a flat table cannot fully represent. This exporter produces a faithful view: each row carries the artifact inline (as text where it is a single file, or as a mapping of relative path to text where it is a directory) plus every label.
Scoring should still be done with cert-atlas score against the real atlas — the
flat view is for browsing, filtering and analysis.
def
to_rows(atlas_dir) -> List[dict]:
SCHEMA =
{'id': "string — stable case identifier, e.g. 'cert.forged_verdict'", 'family': 'string — certificate | receipt | seal', 'valid': 'bool — whether a correct verifier should ACCEPT this artifact', 'defect': 'string — defect key; empty for valid cases', 'severity': 'string — soundness | integrity | vacuity; empty for valid cases', 'title': 'string — one-line description of the mutation; empty for valid cases', 'why_it_looks_valid': 'string — why a naive verifier would accept it; empty if valid', 'caught_by': 'string — the check that is supposed to reject it; empty if valid', 'tags': 'list[string] — free-form labels', 'artifact_files': 'list[string] — filenames making up the artifact', 'artifact_json': 'string — JSON object mapping each filename to its contents', 'atlas_version': 'string — the atlas release this row came from', 'atlas_digest': 'string — content digest; rows are only comparable at equal digest'}
def
export(atlas_dir, out_dir) -> dict:
Write JSONL shards plus a machine-readable schema.
JSONL rather than a JSON array: it streams, it diffs line-by-line in review, and it is what dataset loaders expect.