"""Whitelist-only export of descriptive model/runtime trial metrics.""" import json import math from pathlib import Path import re import sys NUMBERS=['elapsed_s','initial_input_tokens','initial_ttft_s','tool_calls','tool_errors','visible_stream_tps','visible_cycle_tps'] FLAGS=['completed','gate_pass','full_suite_pass','repair_verified'] def public_run(source): identifier=source.get('run_id') if not isinstance(identifier,str) or not re.fullmatch(r'[A-Za-z0-9_-]{1,100}',identifier): raise ValueError('Invalid run identifier') out={'run_id':identifier} for key in NUMBERS: value=source.get(key) if value is not None and (type(value) not in (int,float) or not math.isfinite(value)): raise ValueError('Invalid numeric metric') out[key]=value for key in FLAGS: value=source.get(key) if value is not None and type(value) is not bool:raise ValueError('Invalid boolean metric') out[key]=value return out def main(): source=Path(sys.argv[1]);dest=Path(sys.argv[2]);raw=json.loads(source.read_text()) result={'schema_version':1,'scope':'Single-run-per-configuration descriptive task measurements; failed/timeout records retained. No private source/transcript is exported.', 'prompt_sha256':raw['prompt_sha256'],'repository_revision':raw['repository_revision'], 'candidate_sampling':raw['candidate_sampling'], 'baseline_sampling_caveat':raw['baseline_sampling_caveat'], 'actual256k_candidate_proof':False,'production_replaced':False, 'runs':[public_run(row) for row in raw['runs']]} dest.parent.mkdir(parents=True,exist_ok=True);dest.write_text(json.dumps(result,indent=2)+'\n') if __name__=='__main__':main()