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 / final / run-final-host.py

32 lines · 3827 bytes Raw Blame History
1from pathlib import Path
2import os,json,subprocess,hashlib,time
3h=Path.home();root=h/'workspace/hermes-loop-synapse105-L662';out=h/'handoffs/L662-final-host';out.mkdir(exist_ok=False)
4prior=json.loads((h/'handoffs/L662-postfix-host/state.json').read_text());assert prior['status']=='passed'
5assert all(hashlib.sha256((root/f).read_bytes()).hexdigest()==s for f,s in prior['source_inputs'].items())
6known=['crates/synapse-store/src/blockdev.rs','crates/synapse-store/src/blockdev/repair.rs','crates/synapse-store/src/blockdev_tests.rs']
7assert sorted(subprocess.check_output(['git','-C',str(root),'diff','--name-only'],text=True).splitlines())==sorted(known)
8# The only dirty bytes are the already archived/tested parent fixes, present in the bundle.
9subprocess.run(['git','-C',str(root),'restore','--',*known],check=True)
10subprocess.run(['git','-C',str(root),'fetch',str(h/'handoffs/L662-final-source.bundle'),'refs/heads/qualification/105-recovered'],check=True)
11subprocess.run(['git','-C',str(root),'merge','--ff-only','FETCH_HEAD'],check=True)
12sha=subprocess.check_output(['git','-C',str(root),'rev-parse','HEAD'],text=True).strip();assert sha=='0d95893afc6309dc280befe77806975734af8148'
13assert subprocess.check_output(['git','-C',str(root),'status','--porcelain'],text=True)==''
14paths=subprocess.check_output(['git','-C',str(root),'diff','--name-only','5b732e5d353bbcc3f6d0cd1eac60f2e543601521..HEAD','--','crates','Cargo.toml','Cargo.lock'],text=True).splitlines()
15env=os.environ.copy();env['PATH']=str(h/'.cargo/bin')+':'+str(h/'.local/bin')+':'+env['PATH'];env['TMPDIR']=str(out/'tmp');Path(env['TMPDIR']).mkdir();env['CARGO_TARGET_DIR']=str(h/'workspace/targets/L662'/sha)
16env['SYNAPSE_H1_REAL_REPO']=str(root/'.git')
17fixture_pin='1b6e340d48417dfbcfe2df56d48a0696a3a9b250'
18for candidate in [h/'workspace/aien-sovereign-core',h/'workspace/pipeline/clones/aien-sovereign-core']:
19 if candidate.exists() and subprocess.run(['git','-C',str(candidate),'cat-file','-e',fixture_pin+'^{commit}'],stdout=subprocess.DEVNULL,stderr=subprocess.DEVNULL).returncode==0:
20 env['C1_FIXTURE_REPO']=str(candidate)
21 break
22else:
23 raise RuntimeError('Required immutable Gate4 fixture absent; no test waiver')
24state={'source':sha,'pid':os.getpid(),'started':time.time(),'source_inputs':{f:hashlib.sha256((root/f).read_bytes()).hexdigest() for f in paths},'status':'running','steps':[]}
25commands=[('full-suite',['cargo','test','--locked','-j','6','--workspace','--no-fail-fast']),('both-required-fixtures',['cargo','test','--locked','-j','6','--workspace','--','--ignored','--nocapture','--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']),('pinned-crumb',[str(h/'workspace/hermes-L662-crumb12ad/tools/crumb/crumb'),'verify','.'])]
26for name,cmd in commands:
27 state['current']=name;(out/'state.json').write_text(json.dumps(state,indent=2)+'\n');actual=['timeout','--signal=TERM','20m',str(h/'.local/bin/quiet-build'),*cmd]
28 with (out/(name+'.log')).open('w') as f:rc=subprocess.run(actual,cwd=root,env=env,stdout=f,stderr=subprocess.STDOUT).returncode
29 state['steps'].append({'step':name,'command':actual,'exit':rc});(out/'state.json').write_text(json.dumps(state,indent=2)+'\n')
30 if rc:state['status']='failed' if rc!=124 else 'incomplete_timeout';break
31else:state['status']='passed'
32state['finished']=time.time();state.pop('current',None);assert all(hashlib.sha256((root/f).read_bytes()).hexdigest()==s for f,s in state['source_inputs'].items());(out/'state.json').write_text(json.dumps(state,indent=2)+'\n');print(json.dumps(state,indent=2));raise SystemExit(0 if state['status']=='passed' else 1)