"""Exercise the real chain with exhausted fit allocation: no model/GPU launches.""" import json from pathlib import Path import subprocess import sys from gre24_prepare_v2 import sha from s2_recovery_supervisor import save def main(): root=Path('artifacts/gre24-reproduction-2026-11-15/budget-chain-test');root.mkdir(exist_ok=False) reference=Path('artifacts/gre24-reproduction-2026-11-15/integration-03') good=json.loads((reference/'preparation-freeze.json').read_text())['successful'];records=[] for case,p in good.items(): result=root/(case+'-prep-result.json') save(result,dict(status='PASS',case=case,geometry=dict(tet_nodes=p['nodes'],outside_tet_nodes=0), t_scale_seconds=2.,output_sha256=p['output_sha256'])) # Result's parent defines input root; use separate existing arrays via copied tiny files. folder=root/case;folder.mkdir();result=folder/'result.json' for file in Path(p['output']).glob('*.npy'):(folder/file.name).write_bytes(file.read_bytes()) save(result,dict(status='PASS',case=case,geometry=dict(tet_nodes=p['nodes'],outside_tet_nodes=0), t_scale_seconds=2.,output_sha256=p['output_sha256'])) records.append(dict(case=case,worker={'status':'PASS'},result_path=str(result),result_sha256=sha(result))) save(root/'contract.json',dict(parts=list(good))) save(root/'complete.json',dict(status='COMPLETE',accounting_complete=True,records=records, worker_cpu_seconds=0.,initial_cpu_reserve_seconds=0.)) (root/'splits.json').write_bytes((reference/'splits.json').read_bytes()) paths=['tools/run_gre24_models.py','tools/gre24_fit.py','tools/gre24_score.py','tools/gre24_models.py','tools/gre24_gpu_guard.py','tools/gre24_job_guard.py'] plan=dict(code_sha256={p:sha(p) for p in paths},total_worker_cpu_seconds=1000,postfit_cpu_reserve_seconds=998, total_gpu_seconds=60,initial_gpu_seconds=0,dataset_version='synthetic_budget_only',protocol='synthetic', xgb_threads=1,fnn_cpu_threads=1,xgb_per_fit_cpu_seconds=10,fnn_per_fit_cpu_seconds=10,gpu_reserved_byte_cap=15*2**30) save(root/'plan.json',plan) subprocess.run([sys.executable,'tools/run_gre24_models.py',str(root),str(root/'plan.json')],check=True) result=json.loads((root/'reproduction-complete.json').read_text()) assert all(v['status']=='NOT_ATTEMPTED' for v in result['fits'].values()) assert result['charged_gpu_seconds']==0 assert not list((root/'fits').glob('**/started.json')) if (root/'fits').exists() else True assert result['charged_worker_cpu_seconds']<1000 save(root/'test-acceptance.json',dict(status='PASS',checks=['CPU reserve prevents all fits','no GPU starts', 'terminal model freeze exists before prediction','naive score survives missing models','actual postfit CPU charged'],result=result)) print('PASS actual chain budget boundary, zero GPU fits') if __name__=='__main__':main()