"""Final checks of environments, assets, provenance and the uncommitted tree.""" import json from pathlib import Path import subprocess from datetime import datetime,timezone ROOT=Path(__file__).resolve().parents[1];UV=str(Path.home()/'.local/bin/uv') reports=ROOT/'reports' results={} with (reports/'dependency_check.log').open('w') as log: for name,folder in [('ours',ROOT),*[(m,ROOT/'baselines'/m) for m in ('mezo','agzo','lozo','loren')]]: log.write(f'\n=== {name} ===\n');log.flush() process=subprocess.run([UV,'pip','check','--python',str(folder/'.venv/bin/python')],stdout=log,stderr=subprocess.STDOUT) assert process.returncode==0,name path=reports/f'{name}_environment.json' data=subprocess.check_output([str(folder/'.venv/bin/python'),str(ROOT/'scripts/doctor.py')],text=True) path.write_text(data);results[name]=json.loads(data) assert results[name]['sst2']['train']==67349 and results[name]['drop']['train']==77400 for m in ('mezo','agzo','lozo','loren'): for required in ('pyproject.toml','uv.lock','.python-version','TROUBLESHOOTING.md','native.py','run_compatible.py'): assert (ROOT/'baselines'/m/required).is_file() validation=json.loads((reports/'validation_report.json').read_text()) assert validation['passed'] and len(validation['checks'])==45 checkpoint=json.loads((reports/'checkpoint_restore.json').read_text()) assert checkpoint['passed'] source=json.loads((reports/'source_audit.json').read_text()) assert all(not v['tracked_upstream_changes'] for v in source['official_sources'].values()) assert subprocess.check_output(['git','-C',str(ROOT),'rev-list','--all','--count'],text=True).strip()=='0' assert not subprocess.check_output(['git','-C',str(ROOT),'diff','--cached','--name-only'],text=True).strip() ignored=['.env','.venv/bin/python','baselines/mezo/.venv/bin/python','baselines/mezo/.upstream-git/config','models/test.bin','data/test.parquet','results/test.json'] check=subprocess.run(['git','-C',str(ROOT),'check-ignore','--stdin'],input='\n'.join(ignored)+'\n',capture_output=True,text=True,check=True) assert check.stdout.splitlines()==ignored result=dict(passed=True,checked_at=datetime.now(timezone.utc).isoformat(),validation_checks=45,mechanism_tests=5,checkpoint_roundtrip=checkpoint, environments=results,git=dict(commits=0,staged_files=0,official_source_changes=0), scope='Small real-model independent execution, dependency and inference checks; no full benchmark or paper accuracy reproduction', final_environment_change='HF defaults initialized before library imports; final modern model/task matrix, doctor in all five environments, mechanism tests and checkpoint roundtrip validate this routing change.') (reports/'final_audit.json').write_text(json.dumps(result,indent=2)) progress=dict(stage='complete',completed=45,total=45,current_unit='Packaging, independent environments and smoke validation complete',last_update=result['checked_at'],output_directory=str(ROOT),no_commit_or_push=True) tmp=reports/'progress.json.tmp';tmp.write_text(json.dumps(progress,indent=2));tmp.replace(reports/'progress.json') tmp=reports/'progress.md.tmp';tmp.write_text('# Preparation complete\n\n45 independent checks passed; 5 numerical mechanism tests passed. Checkpoint reload, evaluation and generation passed. Five independent uv environments pass dependency checks and read both datasets.\n\nNo commit or push; no full benchmark launched.\n\nSee final_audit.json and validation_report.json for scope and exact logs.\n');tmp.replace(reports/'progress.md') print(json.dumps({'passed':True,'validation_checks':45,'environments':list(results),'root':str(ROOT)}))