cell02-integrate.py
from pathlib import Path
import subprocess,json,hashlib
root=Path('/tmp/mizoki-readiness-cell02-integrated');records=[]
def read(sha,p):return subprocess.check_output(['git','show',sha+':'+p])
def put(sha,p):
q=root/p;q.parent.mkdir(parents=True,exist_ok=True);q.write_bytes(read(sha,p));records.append({'path':p,'source':sha,'sha256':hashlib.sha256(q.read_bytes()).hexdigest()})
for p in subprocess.check_output(['git','diff','f422ea4c...42b4e2d9','--name-only','--','src/cells/cell02']).decode().splitlines():put('42b4e2d9',p)
p='src/cells/cell02/Cell2.py'
base=subprocess.check_output(['git','merge-base','42b4e2d9','40e29542']).decode().strip()
for n,sha in [('ours','42b4e2d9'),('base',base),('theirs','40e29542')]:Path('/tmp/cell02-merge-'+n).write_bytes(read(sha,p))
r=subprocess.run(['git','merge-file','-p','/tmp/cell02-merge-ours','/tmp/cell02-merge-base','/tmp/cell02-merge-theirs'],capture_output=True)
assert r.returncode==0,r.stdout.decode();(root/p).write_bytes(r.stdout);records.append({'path':p,'operation':'git merge-file three-way','ours':'42b4e2d9','base':base,'theirs':'40e29542','exit':r.returncode,'sha256':hashlib.sha256(r.stdout).hexdigest()})
put('40e29542','src/cells/cell02/tests/test_health_truth.py')
for p in ['src/cells/cell02/srpvdal_api.py','src/cells/cell02/tests/test_srpvdal_provider.py']:put('4dc55fcb',p)
for p in subprocess.check_output(['git','diff','f422ea4c...65bff209','--name-only','--','src/cells/cell02','security_tests/urllib3']).decode().splitlines():put('65bff209',p)
assert read('3968d6c31','src/cells/cell02/Cell2.py')==read('b1dde0b1','src/cells/cell02/Cell2.py')
Path('/tmp/cell02-integrated-composition.json').write_text(json.dumps(records,indent=2)+'\n')
print('composed',len(records),'records; Cell2 three-way clean; FR41 latest appsource identical')