from pathlib import Path import hashlib,json,datetime R=Path(__file__).resolve().parent.parent;P=R/'.local/runtime-notices-20260913';Q=R/'.local/runtime-notices-integration-20260913';D=R/'harness/experiments/runtime-notices-20260913' def sha(b):return hashlib.sha256(b).hexdigest() def new(p,b): p.parent.mkdir(parents=True,exist_ok=True) with p.open('xb') as f:f.write(b) receipt=json.loads((Q/'result.json').read_bytes());assert receipt['exit']==1 and receipt['inputs_unchanged'] corrected=json.loads((Q/'module-isolated-r1/result.json').read_bytes());assert corrected['exit']==0 and corrected['inputs_unchanged'] original_inventory=(P/'evidence-inventory.json').read_bytes() assert sha(original_inventory)=='fd4bf29355d320a1a1f00716c5c6abe4e0055e15cd556ee4763a0b0af485e4f0' inventory=json.loads(original_inventory) assert len(inventory['files'])==56 assert not D.exists();D.mkdir() rows=[];bindings=[] def add(src,dest): b=src.read_bytes();new(D/dest,b) rows.append({'path':dest,'source':str(src.relative_to(R)).replace('\\','/'),'bytes':len(b),'sha256':sha(b)}) for x in inventory['files']: src=P/x['path'];b=src.read_bytes();assert sha(b)==x['sha256'] and len(b)==x['bytes'] if x['path'].startswith('notice-inputs/') and x['path']!='notice-inputs/manifest.json': existing=R/'scripts/windows-notices'/src.name elif x['path']=='llvm-libunwind-LICENSE.TXT': existing=R/'scripts/windows-notices/llvm-ea7d852a70e8-libunwind-LICENSE.TXT' else: add(src,'proposal/'+x['path']);continue assert existing.read_bytes()==b bindings.append({'logical_source':x['path'],'existing_path':str(existing.relative_to(R)).replace('\\','/'),'bytes':len(b),'sha256':sha(b)}) add(P/'evidence-inventory.json','proposal/evidence-inventory.json') for name in ['result.json','synthetic.stdout.log','synthetic.stderr.log']: add(Q/name,'integration/'+name) for name in ['result.json','stdout.log','stderr.log','run.ps1']: add(Q/'module-isolated-r1'/name,'integration/module-isolated-r1/'+name) add(R/'.local/integrate-runtime-notices-20260913.py','tools/integrate-runtime-notices-20260913.py') add(R/'.local/rerun-runtime-notice-contract-20260913.py','tools/rerun-runtime-notice-contract-20260913.py') add(Path(__file__).resolve(),'tools/archive-runtime-notices-20260913.py') add(R/'scripts/test-windows-notices.ps1','integration/test-windows-notices.ps1') add(R/'scripts/windows-notices.ps1','integration/windows-notices.ps1') bindingbytes=(json.dumps({'scope':'Exact external tracked supplement bindings; all compared with original local proposal and original inventory. No copied supplement payloads needed.','bindings':bindings},indent=2)+'\n').encode() new(D/'supplement-bindings.json',bindingbytes) rows.append({'path':'supplement-bindings.json','source':'generated from verified original proposal inventory and tracked supplements','bytes':len(bindingbytes),'sha256':sha(bindingbytes)}) new(D/'archive-manifest.json',(json.dumps({'utc':datetime.datetime.now(datetime.timezone.utc).isoformat(),'scope':'Unique source/provenance/proposal and actual synthetic gate evidence; large distribution ZIP/DLL and unchanged tracked supplements are external hashed bindings. No package/application acceptance.','original_proposal_inventory_sha256':sha(original_inventory),'files':rows},indent=2)+'\n').encode()) # Exact all-payload readback and unchanged original proposal, including omitted files. for row in rows: b=(D/row['path']).read_bytes();assert sha(b)==row['sha256'] and len(b)==row['bytes'] for x in inventory['files']: b=(P/x['path']).read_bytes();assert sha(b)==x['sha256'] and len(b)==x['bytes'] assert (P/'evidence-inventory.json').read_bytes()==original_inventory print(json.dumps({'payloads_in_manifest':len(rows),'external_supplement_bindings':len(bindings),'original_proposal_unchanged':True,'all_payload_readbacks_pass':True,'archive_manifest_sha256':sha((D/'archive-manifest.json').read_bytes())},indent=2))