from pathlib import Path import json,hashlib,shutil,time R=Path.home()/'run/pets-knp';M=R/'head-v2';proof=json.loads((R/'eval-v2-final/VERIFIED.json').read_text());smoke=json.loads((R/'eval-v2-smoke/VERIFIED.json').read_text());assert proof['model_sha256']==smoke['model_sha256'] files=[R/'detectors/det_w.bin',R/'detectors/det_b.bin',R/'detectors/meta.txt']+[M/f for f in ['hidden_w.bin','hidden_b.bin','hidden_thresholds.bin','weights.bin','bias.bin']] headsha=hashlib.sha256(b''.join((M/f).read_bytes() for f in ['hidden_w.bin','hidden_b.bin','hidden_thresholds.bin','weights.bin','bias.bin'])).hexdigest();assert headsha==proof['model_sha256'] manifest={str(p.relative_to(R)):hashlib.sha256(p.read_bytes()).hexdigest() for p in files};pipeline=hashlib.sha256(b''.join(p.read_bytes() for p in files)).hexdigest() summary={'version':'pets-knp-conv200-hidden256-v1','classes':['cat','dog'],'test_accuracy':proof['test']['accuracy'],'test_correct':proof['test']['correct'],'test_total':proof['test']['total'],'validation_accuracy':proof['validation']['accuracy'],'test_confusion':proof['test']['confusion'],'model_sha256':headsha,'pipeline_sha256':pipeline,'files_sha256':manifest,'learned_inference':'KNP CUDA AltAILIF/Delta for convolutional detectors, nonlinear hidden layer and two opponent output neurons','host_operations':'RGB BILINEAR32 resize, fixed quadrant sum, root-L2 normalization and temporal spike packet routing; no learned arithmetic','data':'CIFAR10 cats3/dogs5;8000train+flips/2000val/2000officialtest','gallery_selection':'first12 official test images per class in frozen shuffled order; no filtering by prediction','golden_model_verified':False,'physical_chip_verified':False,'tie_rule':'both outputs silent=>cat','proofs':proof,'smoke':smoke} (R/'final-summary.json').write_text(json.dumps(summary,indent=2)+'\n');print(json.dumps({k:summary[k] for k in ['test_accuracy','test_total','pipeline_sha256']}))