47 lines
2.5 KiB
Python
47 lines
2.5 KiB
Python
"""Claude1794895409: B7 then B6 once, independent of B1 recovery."""
|
|
import fcntl
|
|
import json
|
|
import os
|
|
from pathlib import Path
|
|
import subprocess
|
|
import sys
|
|
import time
|
|
import psutil
|
|
from phase2_h1_worker_v2 import save,sha,checked
|
|
|
|
BASE=Path('/home/frank14f/optane/MeltMind')
|
|
ROOT=BASE/'artifacts/phase2-b76-released-2026-11-17'
|
|
DEPENDENCY=BASE/'artifacts/phase2-h1-labelled-recovery-2026-11-17'
|
|
def read(p):return json.loads(Path(p).read_text())
|
|
|
|
|
|
def live(root):
|
|
return [p.pid for p in psutil.process_iter(['pid','cmdline']) if p.pid!=os.getpid() and str(root) in (p.info['cmdline'] or [])]
|
|
|
|
|
|
def run():
|
|
c=read(ROOT/'contract.json')
|
|
for p,h in c['source_sha256'].items():checked(BASE/p,h)
|
|
os.sched_setaffinity(0,[24]);start=time.process_time()
|
|
with (ROOT/'run.lock').open('a') as lock:
|
|
fcntl.flock(lock,fcntl.LOCK_EX|fcntl.LOCK_NB)
|
|
if (ROOT/'started.json').exists():raise FileExistsError('Unique existing chain; no restart')
|
|
save(ROOT/'started.json',dict(pid=os.getpid(),unix=time.time(),contract_sha256=sha(ROOT/'contract.json')))
|
|
results=[]
|
|
try:
|
|
for name,module in [('phase2-b7-gate-2026-11-17','phase2_b7_released'),('phase2-b6-gate-2026-11-17','phase2_b6_released')]:
|
|
root=BASE/'artifacts'/name
|
|
for p,h in c['source_sha256'].items():checked(BASE/p,h)
|
|
if live(root) or (root/'started.json').exists():raise RuntimeError('Dependent gate already attempted; do not duplicate')
|
|
save(ROOT/'live-progress.json',dict(stage='RUN_'+module,unix=time.time(),coordinator_cpu_seconds=time.process_time()-start))
|
|
with (ROOT/(module+'.log')).open('x') as log:
|
|
child=subprocess.run([sys.executable,'tools/'+module+'.py',str(root)],stdout=log,stderr=subprocess.STDOUT)
|
|
if not (root/'complete.json').exists() or live(root):raise RuntimeError('Missing terminal or live children')
|
|
result=read(root/'complete.json');results.append(dict(gate=name,returncode=child.returncode,complete_sha256=sha(root/'complete.json'),status=result['status']))
|
|
save(ROOT/'gate-terminals.json',results)
|
|
save(ROOT/'complete.json',dict(status='BOTH_GATES_TERMINAL',results=results,coordinator_cpu_seconds=time.process_time()-start,retry=False))
|
|
except BaseException as exc:
|
|
save(ROOT/'complete.json',dict(status='STOPPED',reason=type(exc).__name__+': '+str(exc),results=results,coordinator_cpu_seconds=time.process_time()-start,retry=False));raise
|
|
|
|
if __name__=='__main__':run()
|