"""Synthetic JPEG marker streams and R09-shaped pins; never capture evidence. Streams exercise the structural parser, not a decoder or visual acceptance. Independent of all operational Root handoff documents. """ import hashlib import json import shutil import struct def put(path, value): path.write_text(json.dumps(value, sort_keys=True)+'\n') def jpeg(width=1280, height=752, progressive=False): def segment(marker, body): return bytes((255, marker))+struct.pack('>H', len(body)+2)+body frame = segment(0xc2 if progressive else 0xc0, b'\x08'+struct.pack('>HH', height, width)+b'\x01\x01\x11\x00') scan = segment(0xda, b'\x01\x01\x00\x00\x3f\x00')+b'\x12\xff\x00\x34\xff\xd0\x56' return b'\xff\xd8'+segment(0xe0, b'SYNTHETIC')+frame+scan+(scan if progressive else b'')+b'\xff\xd9' def make(base, candidate): out, original = base/'canonical', base/'original' out.mkdir(); index = {'commit':candidate, 'artifacts':{}} measurement = {'scope':'synthetic post-collection measurement', 'images':[]} for role, count in (('reader',5), ('writer',64)): for i in range(1,count+1): for side in ('before','after'): name = f'os-pair/{role}-request-{i:04d}/screen-{side}.png' path = out/name; path.parent.mkdir(parents=True, exist_ok=True) path.write_bytes(jpeg(progressive=i%2 == 0)) measurement['images'].append({'file':name, 'source_sha256':hashlib.sha256(path.read_bytes()).hexdigest(), 'width':1280,'height':752,'format_by_magic':'JPEG'}) for name in ('runner-input.json','runner-ended.json','os-runs/writer/ended.json','os-runs/reader/ended.json'): path = out/name; path.parent.mkdir(parents=True,exist_ok=True); put(path, {'synthetic':True}) refresh(out, index, measurement) shutil.copytree(out, original) def pin(name): p=original/name return {'path':str(p),'bytes':p.stat().st_size,'sha256':hashlib.sha256(p.read_bytes()).hexdigest()} pins = {'original_root':str(original),'native_candidate':candidate,'index':pin('index.json'), 'runner_input':pin('runner-input.json'),'runner_ended':pin('runner-ended.json'), 'OS':{role:{'receipt':pin('os-runs/'+role+'/ended.json')} for role in ('writer','reader')}} return out, original, index, measurement, pins def refresh(out, index, measurement): index['artifacts'] = {p.relative_to(out).as_posix():{'bytes':p.stat().st_size, 'sha256':hashlib.sha256(p.read_bytes()).hexdigest()} for p in out.rglob('*') if p.is_file() and p.name != 'index.json'} put(out/'index.json',index) measurement['original_index_sha256'] = hashlib.sha256((out/'index.json').read_bytes()).hexdigest()