"""Bounded final packaging, after extraction and proper-pose completion.""" from pathlib import Path import hashlib,json,resource,sys from s2_e1_supervisor import supervise,save,disk_usage ROOT=Path('artifacts/s2-g1-blind120-2026-11-14') def main(): c=json.loads((ROOT/'public/package-build-contract.json').read_text()) for p,h in c['source_sha256'].items(): if hashlib.sha256(Path(p).read_bytes()).hexdigest()!=h:raise ValueError('Packaging source changed') assert json.loads((ROOT/'custodian/pose-batch-complete.json').read_text())['all_pass'] r=supervise([sys.executable,'tools/build_g1_blind120_package.py'],ROOT,'blind-package-build',dict(total_cpu_seconds=57600,job_cpu_seconds=1800,job_wall_seconds=1800,tree_rss_bytes=1342177280,disk_bytes=8*1024**3,max_processes=8),poll=.1) own=sum(resource.getrusage(resource.RUSAGE_SELF)[:2]);ledger=json.loads((ROOT/'ledger.json').read_text());ledger['cpu_seconds_charged']+=own;ledger['attempts'].append({'name':'package-supervisor-self','cpu_seconds':own,'status':'MEASURED_SELF_CPU'});save(ROOT/'ledger.json',ledger) result={'receipt':r,'supervisor_self_cpu_seconds':own,'e1_conservative_cpu_seconds':ledger['cpu_seconds_charged'],'artifact_root_disk_bytes':disk_usage(ROOT)} save(ROOT/'public/package-supervision.json',result);print(json.dumps(result));sys.exit(0 if r['status']=='PASS' else 1) if __name__=='__main__':main()