File size: 2,065 Bytes
1daa78e | 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 | #!/usr/bin/env python3
"""Offline delivery checks only. Visual fidelity is graded by the host VLM."""
import argparse,json,subprocess
from pathlib import Path
def grade(desktop,project,terminal_log):
video=desktop/'final.mp4';meta=None
try:
d=json.loads(subprocess.run(['ffprobe','-v','error','-show_streams','-show_format','-of','json',str(video)],capture_output=True,check=True).stdout)
stream=next(s for s in d['streams'] if s.get('codec_type')=='video');a,b=map(float,stream['avg_frame_rate'].split('/'))
meta={'width':stream['width'],'height':stream['height'],'fps':a/b,'duration':float(d['format']['duration'])}
except (subprocess.CalledProcessError,ValueError,KeyError,StopIteration,ZeroDivisionError):pass
checks={'readable_video':bool(meta),'native_project':project.exists() and project.stat().st_size>=1024,'format':bool(meta and meta['width']==1080 and meta['height']==1080 and abs(meta['fps']-24)<.05 and abs(meta['duration']-15)<.09)}
attempts=terminal_log.read_text(errors='replace').splitlines() if terminal_log.exists() else []
return {'task':'t50','rubric_version':'t50-motion-shape-v2','visual_grade_status':'pending_host_vlm','score':None,'delivery':sum(checks.values())/len(checks),'delivery_checks':checks,'metadata':meta,'terminal_attempts':attempts,'code_access_gate':'terminal-attempt' if attempts else 'clear'}
if __name__=='__main__':
p=argparse.ArgumentParser();p.add_argument('--desktop',type=Path,default=Path('/root/Desktop'));p.add_argument('--project',type=Path,default=Path('/root/edit/project.friction'));p.add_argument('--terminal-log',type=Path,default=Path('/logs/artifacts/terminal-attempts.log'));p.add_argument('--report',type=Path,default=Path('/logs/verifier/score.json'));p.add_argument('--reward',type=Path,default=Path('/logs/verifier/reward.json'));a=p.parse_args()
r=grade(a.desktop,a.project,a.terminal_log);a.report.parent.mkdir(parents=True,exist_ok=True);a.report.write_text(json.dumps(r,indent=2)+'\n');a.reward.write_text(json.dumps({'delivery':r['delivery']})+'\n');print(json.dumps(r,indent=2))
|