"""Preserve this run's initial association preview before a display-only correction."""
import hashlib
import json
from pathlib import Path
import sys

root=Path(__file__).resolve().parent.parent
src=root/'download/01_camera24_fight'
kind=sys.argv[1] if len(sys.argv)>1 else 'association'
assert kind in ('association','motion')
dest=root/('reports/initial_'+kind+'_preview')
assert not dest.exists()
video=src/('B_Association_Difference_Review.mp4' if kind=='association' else 'B_Motion_Evidence_Review.mp4')
report=src/('data/'+kind+'_video_validation.json')
assert hashlib.sha256(video.read_bytes()).hexdigest()==json.loads(report.read_text())['sha256']
dest.mkdir(parents=True)
paths=[video,report]+sorted((src/'data').glob(kind+'_sample_*.jpg'))
for path in paths:path.rename(dest/path.name)
(dest/'reason.txt').write_text('Display only: clarify unselected association reference or add body-relative contact failure detail. Core results unchanged.\n')
print('PREVIEW_PRESERVED',len(paths))
