Files
MeltMind/artifacts/phase3-item-c-launch-2026-11-18/launch-reviewed.py
T

34 lines
2.9 KiB
Python

"""One reviewed c launch under Claude1795010251; no code/contract changes."""
import json,os,socket,subprocess,time
from pathlib import Path
import psutil
from phase2_h1_worker_v2 import sha,checked,save
from phase2_gate_outcome_review import validate_review
from phase3_item_c_common import ROOT,config
from phase3_shared_capacity import SHARED,host_snapshot,admission,GPUS
B=Path('/home/frank14f/optane/MeltMind');PY=B/'artifacts/gre24-reproduction-2026-11-15/environment/venv/bin/python'
unit='meltmind-phase3-item-c-20261118.service'
assert socket.gethostname()=='frank14f-Horsea'
c,_=config(ROOT);validate_review(ROOT)
assert sha(ROOT/'contract.json')=='0e8533194b9987d234a8ea419a2d4e1a3993ab18c41400d5a89d0beaacf6a465'
assert sha(ROOT/'review.json')=='e30612eabf43037f6258644945e9f486dc99426f08d1da160d14cfd6b3163632'
assert not any((ROOT/f).exists() for f in ['started.json','complete.json','launch-attempt.json']) and not SHARED.exists()
for p in psutil.process_iter(['pid','cmdline']):
assert not any(Path(x).name in {'phase3_item_c_queue.py','phase3_item_c_guard.py','phase3_item_c_worker.py'} for x in p.info['cmdline'] or []),p.info
for name in ['phase3-seed1-v2-2026-11-18','track-a-recovery-2026-11-18']:
d=json.loads((ROOT.with_name(name)/'contract.json').read_text())
for p,h in d['code_sha256'].items():checked(p,h)
s=host_snapshot();decisions={u:admission(s,[],u) for u in GPUS[1:3]}
assert any(x[0] for x in decisions.values()) and psutil.disk_usage(ROOT).free>=100*2**30
old=subprocess.run(['systemctl','--user','show',unit,'-p','LoadState','-p','ActiveState','-p','MainPID'],capture_output=True,text=True)
assert 'LoadState=not-found' in old.stdout,old.stdout
command=['systemd-run','--user','--collect','--unit='+unit,'--working-directory='+str(B),'--property=Restart=no','--property=KillMode=control-group','--property=TimeoutStopSec=60','--property=StandardOutput=append:'+str(ROOT/'service.log'),'--property=StandardError=inherit']
for k,v in dict(OPENBLAS_NUM_THREADS='1',OMP_NUM_THREADS='1',MKL_NUM_THREADS='1',NUMEXPR_NUM_THREADS='1',PYTHONPATH='tools',PYTORCH_CUDA_ALLOC_CONF='expandable_segments:True',PYTHONUNBUFFERED='1').items():command.append('--setenv='+k+'='+v)
command += [str(PY),str(B/'tools/phase3_item_c_queue.py')]
save(ROOT/'host-prelaunch-refreshed.json',dict(unix=time.time(),snapshot=s,admission=decisions,old_pins='78PASS',duplicate_count=0))
save(ROOT/'launch-attempt.json',dict(unix=time.time(),command=command,claude_ruling='1795010251.158839',review_sha256=sha(ROOT/'review.json'),contract_sha256=sha(ROOT/'contract.json'),new_fits=5,seed=0,epochs=200,gpu_cap=205200,postfit_reserve=7200,phase3_cap=720000,no_retry=True))
p=subprocess.run(command,capture_output=True,text=True)
save(ROOT/'service-launch.json',dict(returncode=p.returncode,stdout=p.stdout,stderr=p.stderr,unit=unit,unix=time.time()))
print(json.dumps(dict(returncode=p.returncode,stdout=p.stdout,stderr=p.stderr,unit=unit)))
raise SystemExit(p.returncode)