from pathlib import Path
exec(compile(Path('/tmp/codex/ltb1021/2026-09-26_provider-scale_r01/prepare.py').read_text(),__file__,'exec'))
shutil.copyfile('/workspace/contextra-runtime-config/metadata-active/compose.yaml',PRIVATE/'metadata-compose.before.yaml')
(PRIVATE/'metadata-compose.before.yaml').chmod(0o600)
old=json.loads(Path('/tmp/codex/ltb1021/2026-09-26_provider-linear_r01/image-7d7a97e883.json').read_text())
assert inspect('contextra-analytics-1')['Image']==old['id']
for p,h in old['hashes'].items():
    assert hashlib.sha256((REPO/p).read_bytes()).hexdigest()==h,p
    assert cmd(['docker','exec','contextra-analytics-1','sha256sum','/opt/contextra/'+p]).split()[0]==h,p
save('source-image-match.json',dict(image=old['tag'],id=old['id'],files=len(old['hashes']),match=True))
print('source/image hashes match')
