main
John Lauer
Save native two-sided contact artwork and recorded GLB material correction; qualification remains open
57e2489
#!/usr/bin/env python3
"""Apply the fully checked text and graphics through two native transactions.
Stops on every semantic failure and retains receipts; never automatically replays
an uncertain mutation. Records the exact linked native 3D viewer during landing.
"""
import json,subprocess,hashlib,time
from pathlib import Path
R=Path(__file__).resolve().parents[1];P=R/'design/silkscreen-review';a=json.loads((P/'bottom-artwork.json').read_text());assert not a['findings'];drc=json.loads((P/'bottom-artwork-candidate-drc.json').read_text());assert not drc['violations'] and not drc['unconnected_items']
board='C:/Users/john/adom-projects/adom-custom-electronic-load/kicad/adom-custom-electronic-load.kicad_pcb';pcb=41886014;viewer=1124570
assert hashlib.sha256((R/'kicad/adom-custom-electronic-load.kicad_pcb').read_bytes()).hexdigest()==a['boardSha256']
def call(name,data,label):
raw=subprocess.check_output(['adom-bridge','--target','AdomLapper','--ai-thread','adom-custom-load',name,json.dumps(data)],text=True);(P/f'land-bottom-{label}.json').write_text(raw);r=json.loads(raw)
if not r.get('success',r.get('ok')) or r.get('postCommitError'):raise RuntimeError(f'{label}: inspect receipt before any retry: '+str(r.get('error',r.get('postCommitError'))))
return r
state=call('kicad_routing_state',dict(filePath=board),'before');assert state['revision']==a['nativeRevision']
call('kicad_3d_view',dict(hwnd=viewer,action='view_bottom'),'view-before')
record=call('desktop_record_start',dict(hwnd=viewer,fps=30,cursor=False,audio=False,maxDurationMs=300000,reason='Record native bottom labels and contact frames appearing on the electronic-load PCB'),'record-start');rid=record['recordingId']
try:
texts=[]
for t in a['texts']:
size=t.get('size',t.get('height'));texts.append(dict(text=t['text'],x=t['x'],y=t['y'],height=size,width=t.get('width',size),stroke=t['stroke'],rotation=t.get('angle',t.get('rotation',0)),layer='B.SilkS',mirrored=True,align='center'))
r=call('kicad_silk_text_batch',dict(filePath=board,expectedRevision=state['revision'],create=texts,dryRun=False,save=False),'texts');print('Native text transaction committed',flush=True)
call('kicad_refresh_board_views',dict(pcbHwnd=pcb),'refresh-texts')
state=call('kicad_routing_state',dict(filePath=board),'after-texts')
graphics=[{k:g[k] for k in ['kind','layer','points','stroke']} for g in a['graphics']]
r=call('kicad_silk_graphics_batch',dict(filePath=board,expectedRevision=state['revision'],create=graphics,dryRun=False,save=True),'graphics');print('Native graphics transaction committed',flush=True)
call('kicad_refresh_board_views',dict(pcbHwnd=pcb),'refresh-all')
call('kicad_3d_view',dict(hwnd=viewer,action='tour',steps=[['view_bottom',1],['zoom_in',1],['zoom_out',1]],pauseMs=1000),'review-tour')
call('kicad_routing_state',dict(filePath=board),'after')
finally:
stop=call('desktop_record_stop',dict(recordingId=rid),'record-stop')
path=stop.get('path',record['path']);call('pull_file',dict(filePaths=[path],saveTo=str(R/'videos/raw')),'record-pull')
print('Native landing complete; saved-file readback and DRC still required',flush=True)