"""Freeze 90 fresh cells against the one final roster; no label decoding or GPU work.""" import json import os from pathlib import Path from freeze_g1_components import sha from s2_recovery_supervisor import save from s2_main_data import select_cell ROOT=Path('artifacts/s2-main-matrix-2026-11-15') PREP=Path('artifacts/s2-main-preparation-2026-11-15') GPUS=['GPU-e8853ae7-a302-6a17-bcfa-aa767e9ed20c','GPU-f1c9fd5a-e917-56e0-21fb-24035ba44a36', 'GPU-b8c11c01-c91f-aa0b-abf6-dad35085cc76','GPU-8b71b032-1b75-2891-935c-ce106a53034a'] def build_runs(roster): runs=[];blocks=[];cells=[] for fold in range(5): for pool in [25,50,100]: records,roles=select_cell(roster,fold,pool) cell=dict(fold=fold,pool=pool,roles=roles,learning_nodes=sum(records[k]['nodes'] for k in roles['learning_parts']), validation_nodes=sum(records[k]['nodes'] for k in roles['validation_parts'])) cells.append(cell) for seed in [0,1,2]: indices=[] for arm in ['N','E']: indices.append(len(runs));runs.append(dict(name=f'fold{fold}-pool{pool}-{arm}128-seed{seed}', fold=fold,pool=pool,seed=seed,arm=arm,width=128,initialization='fresh_seeded', cost_nodes=cell['learning_nodes']+cell['validation_nodes'])) blocks.append(dict(fold=fold,pool=pool,seed=seed,run_indices=indices)) return runs,blocks,cells def main(): assert not ROOT.exists(),'Do not overwrite matrix plan or execution' roster_path=PREP/'final-roster.json';roster=json.loads(roster_path.read_text()) rr=json.loads((PREP/'roster-receipt.json').read_text());assert rr['status']=='FROZEN' and sha(roster_path)==rr['sha256'] batch=json.loads((PREP/'batch-complete.json').read_text());assert batch['status']=='ATTEMPTS_COMPLETE' and batch['stop_reason'] is None prior=json.loads((PREP/'contract.json').read_text());runs,blocks,cells=build_runs(roster) assert len(runs)==90 and len(blocks)==45 and len(cells)==15 and sum(p['included'] for p in roster['parts'])==617 pilot=json.loads(Path('artifacts/s2-pilot-v2-continuation-2026-11-15/training-contract.json').read_text()) for p,h in pilot['code_sha256'].items():assert sha(p)==h,p added=['tools/s2_main_data.py','tools/run_s2_main_training.py','tools/run_s2_main_matrix.py','tools/prepare_s2_main_matrix.py', 'tools/test_s2_main_matrix.py','tools/s2_main_memory_guard.py','tools/s2_gpu_idle_gate.py', 'tools/s2_recovery_monitoring.py','tools/s2_recovery_supervisor.py','tools/s2_recovery_gpu_supervisor.py'] paths=set(pilot['code_sha256'])|set(added) available=sorted(os.sched_getaffinity(0));assert len(available)>=12 affinities=[available[2*i:2*i+2] for i in range(4)] old_labels='artifacts/s2-pilot-training-2026-11-15/success-manifest.json' sources=[str(roster_path),str(PREP/'roster-receipt.json'),str(PREP/'batch-complete.json'),old_labels] c=dict(version='S2-fresh-main-matrix-v1',runs=runs,blocks=blocks,cells=cells,E_max=42,cosine_T_max=42, roster=str(roster_path),roster_sha256=sha(roster_path),old_labels_manifest=old_labels,old_labels_manifest_sha256=sha(old_labels), archive=prior['archive'],archive_stat=prior['archive_stat'],gpu_uuids=GPUS,gpu_cpu_affinities=affinities, cpu_affinity_available=available,cpu_affinity_reserved_for_other_work=available[8:], code_sha256={p:sha(p) for p in sorted(paths)},source_sha256={p:sha(p) for p in sources}, limits=dict(aggregate_gpu_seconds=46*3600,run_wall_seconds=1800,idle_seconds_per_run=600,block_wall_seconds=5000, max_concurrent_gpus=4,run_vram_bytes=15*2**30,run_host_rss_bytes=16*2**30,run_disk_bytes=5*2**30,retries=0), allocator_conf='expandable_segments:True',authorizing_rulings=['1794698179.161599','1794698734.967459','1794699027.366469'], capacity='128 chosen by feasibility; width effect not tested',pilot_weights_reused=False, target_access='Current fold learning/validation only; reject current fold test before cache/archive IO. Other folds roles do not grant access.', test_predictions='No predictions/scoring until all90 neural +15 R2 final fits terminal and checkpoints frozen; unified custody only.', supervision='N/E adjacent per fold/pool/seed block, one block perGPU, reserve5000s per active block; charge coordinator-observed block lifetime including idle/setup and failures.', first_eight='All four initial blocks terminal before any fifth block; project remaining work with per-arm max successful wall/node and25percent reserve; stop if over46h or no valid rate.', failure_policy='No retry; retain checkpoint/failure evidence, failed run NA; pair invalid if either arm NA or standardizer mismatch. Budget unstarted cells terminal NA with explicit reason.') ROOT.mkdir();save(ROOT/'training-contract.json',c) save(ROOT/'prelaunch.json',dict(status='FROZEN_NOT_STARTED',contract_sha256=sha(ROOT/'training-contract.json'), roster_sha256=c['roster_sha256'],runs=90,blocks=45,labels_decoded=False,gpu_work_started=False,gpu_cpu_affinities=affinities)) print(json.dumps(json.loads((ROOT/'prelaunch.json').read_text()))) if __name__=='__main__':main()