"""Recording diagnostics; reward withheld until visual criteria are calibrated. A provenance match establishes direct desktop capture and content identity, not that a recording depicts the right animation or keeps it in frame. """ import hashlib import json from pathlib import Path import shutil import subprocess class RecordingVerifierError(RuntimeError):pass def sha(path): h=hashlib.sha256() with Path(path).open('rb') as f: for block in iter(lambda:f.read(1048576),b''):h.update(block) return h.hexdigest() def inspect_recording(walk,root,events): root=Path(root);video=root/(walk+'.mp4');blend=root/(walk+'.blend') if not video.is_file():return {'status':'missing','checks':{'recording_present':False}} for tool in ('ffprobe','ffmpeg'): if not shutil.which(tool):raise RecordingVerifierError(tool+' missing') result=subprocess.run(['ffprobe','-v','error','-show_streams','-show_format','-of','json',str(video)],capture_output=True,text=True,timeout=60) if result.returncode:return {'status':'invalid_video','checks':{'recording_present':True,'video_decodes':False}} try:meta=json.loads(result.stdout) except ValueError as e:raise RecordingVerifierError('Invalid ffprobe JSON') from e stream=next((s for s in meta.get('streams',[]) if s.get('codec_type')=='video'),None) if not stream:return {'status':'invalid_video','checks':{'recording_present':True,'video_decodes':False}} duration=float(meta.get('format',{}).get('duration',0)) if not 0