interplane.Get Omega
Read in your language

synapse

A component of the AienOS ecosystem.

Brought by drakestapleton

branch main Branches Tags History

synapse / evidence / REPAIR-RECOVERY-L662 / run-initial.py

27 lines · 2718 bytes Raw Blame History
1from pathlib import Path
2import json,os,subprocess,time,sys
3h=Path.home();root=h/'workspace/hermes-loop-synapse105-L662';out=h/'handoffs/L662-initial-host'
4if len(sys.argv)>1 and sys.argv[1]=='setup':
5 if root.exists() or out.exists():raise SystemExit('Existing workspace/run: inspect rather than relaunch')
6 root.parent.mkdir(parents=True,exist_ok=True);out.mkdir(parents=True)
7 subprocess.run(['git','clone','--no-checkout','https://github.com/aien-dev/synapse.git',str(root)],check=True)
8 subprocess.run(['git','-C',str(root),'fetch',str(h/'handoffs/L662-synapse105-initial.bundle'),'refs/heads/qualification/105-recovered'],check=True)
9 subprocess.run(['git','-C',str(root),'switch','-c','qualification/105-recovered','FETCH_HEAD'],check=True)
10 print('Prepared owned Linux checkout',root);raise SystemExit(0)
11sha=subprocess.check_output(['git','-C',str(root),'rev-parse','HEAD'],text=True).strip()
12assert subprocess.check_output(['git','-C',str(root),'status','--porcelain'],text=True)==''
13env=os.environ.copy();env['PATH']=str(h/'.cargo/bin')+':'+str(h/'.local/bin')+':'+env['PATH'];env['TMPDIR']=str(out/'tmp');env['CARGO_TARGET_DIR']=str(h/'workspace/targets/L662'/sha)
14Path(env['TMPDIR']).mkdir(exist_ok=True)
15state={'source':sha,'pid':os.getpid(),'started':time.time(),'status':'running','steps':[]};(out/'state.json').write_text(json.dumps(state,indent=2)+'\n')
16commands=[('tools',['bash','-c','rustc -vV; cargo -V; uname -a']),('full-suite',['cargo','test','--locked','-j','6','--workspace','--no-fail-fast']),('repair',['cargo','test','--locked','-j','6','-p','synapse-store','r1_repair','--','--test-threads=1']),('repair-cli',['cargo','test','--locked','-j','6','-p','synapse-bench','--test','store_repair_cli']),('fmt',['cargo','fmt','--all','--check']),('clippy',['cargo','clippy','--locked','-j','6','--workspace','--all-targets','--','-D','warnings'])]
17for name,cmd in commands:
18 state['current']=name;(out/'state.json').write_text(json.dumps(state,indent=2)+'\n')
19 with (out/(name+'.log')).open('w') as log:
20 actual=['timeout','--signal=TERM','20m',str(h/'.local/bin/quiet-build'),*cmd] if name!='tools' else cmd
21 rc=subprocess.run(actual,cwd=root,env=env,stdout=log,stderr=subprocess.STDOUT).returncode
22 state['steps'].append({'step':name,'command':actual,'exit':rc});(out/'state.json').write_text(json.dumps(state,indent=2)+'\n')
23 if rc:
24 state['status']='failed' if rc!=124 else 'incomplete_timeout';break
25else:state['status']='passed'
26state['finished']=time.time();state.pop('current',None);(out/'state.json').write_text(json.dumps(state,indent=2)+'\n');print(json.dumps(state,indent=2))
27raise SystemExit(0 if state['status']=='passed' else 1)