sidrefresh's picture
Add files using upload-large-folder tool
2e7de11 verified
Raw History Blame Contribute Delete
2.97 kB
"""Read saved effect state through a pinned source-built native loader."""
import hashlib,json,os,subprocess,tempfile
from pathlib import Path
HERE=Path(__file__).parent
def properties(o):
yield o
for c in o.get('children',[]):yield from properties(c)
def objects(o):
yield o
for c in o.get('objects',[]):yield from objects(c)
def blur_from_audit(audit):
if not audit.get('full_load') or not audit.get('capabilities',{}).get('object_tree'):
raise RuntimeError('Native project structure could not be completely inspected')
rows=[]
for scene in audit['scenes']:
for o in objects(scene['structure']):
if o.get('name')!='ball layer':continue
if o.get('type') not in ['Circle','SmartVectorPath','RectangleBox']:
raise RuntimeError('Ball layer geometry mapping needs inspection: '+o.get('type','unknown'))
# A blank group named ball layer cannot receive credit.
props=list(properties(o))
animated=any(len(p.get('keys',[]))>1 or p.get('has_expression') for p in props)
if not animated or not o.get('visible',False):
raise RuntimeError('Named ball layer is not a visible animated vector object')
effects=[p for p in props if p.get('type')=='MotionBlurEffect']
rows.append({'id':o['id'],'name':o['name'],'type':o['type'],'enabled':any(e.get('enabled') is True for e in effects),'effect_count':len(effects)})
return {'value':int(bool(rows) and all(r['enabled'] for r in rows)),'layers':rows,'status':'measured_named_ball_layers','scope':'Saved state on named vector objects; unlabelled ball coverage requires further mapping validation'}
def inspect_blur(edit_dir):
files=list(Path(edit_dir).glob('*.friction'))
if not files:return {'value':0,'layers':[],'reason':'No saved Friction project','status':'missing_artifact'}
project=next((x for x in files if x.name=='pong.friction'),files[0]);binary=HERE/'native/friction';lock=json.loads((HERE/'native/runtime-lock.json').read_text())
if hashlib.sha256(binary.read_bytes()).hexdigest()!=lock['audit_binary_sha256']:raise RuntimeError('Native inspector integrity failure')
env=os.environ.copy();env.update(FRICTION_AUDIT_MODE='1',LD_LIBRARY_PATH='/opt/friction/lib',QT_PLUGIN_PATH='/opt/friction/plugins',LIBGL_ALWAYS_SOFTWARE='1')
with tempfile.TemporaryDirectory(prefix='pong-native-') as td:
out=Path(td)/'structure.json'
command=json.loads(env['T24_NATIVE_COMMAND'])+[ '--project',str(project.resolve()),'--output',str(out),'--max-frames','0'] if env.get('T24_NATIVE_COMMAND') else ['xvfb-run','-a',str(binary),str(project.resolve()),'--audit-output',str(out),'--audit-max-frames','0']
subprocess.run(command,env=env,capture_output=True,timeout=120)
if not out.exists():raise RuntimeError('Native inspector did not produce evidence')
return blur_from_audit(json.loads(out.read_text()))