main
John Lauer Save native two-sided contact artwork and recorded GLB material correction; qualification remains open 57e2489
#!/usr/bin/env python3
"""Land checked front art with one required footprint-field file edit.

KiCad 10's tested field API cannot update J8's Reference property. Save and close
only this board, preserve its exact source, then reopen the checked candidate.
"""
import json,subprocess,hashlib,shutil,time
from pathlib import Path
R=Path(__file__).resolve().parents[1];O=R/'design/silkscreen-review/front-contacts';a=json.loads((O/'artwork.json').read_text());report=json.loads((O/'candidate-review.json').read_text());d=json.loads((O/'front-contact-drc.json').read_text());assert not a['findings'] and not d['violations'] and not d['unconnected_items'];candidate=R/'kicad/front-contact-candidate.kicad_pcb';assert hashlib.sha256(candidate.read_bytes()).hexdigest()==report['candidateSha256']
remote='C:/Users/john/adom-projects/adom-custom-electronic-load/kicad/adom-custom-electronic-load.kicad_pcb';pcb=41886014

def call(v,p,label):
 raw=subprocess.check_output(['adom-bridge','--target','AdomLapper','--ai-thread','adom-custom-load',v,json.dumps(p)],text=True);(O/('land-'+label+'.json')).write_text(raw);r=json.loads(raw);assert r.get('success',r.get('ok')),r;return r
state=call('kicad_routing_state',dict(filePath=remote),'before');assert state['revision']==a['nativeRevision']
call('kicad_send_key',dict(hwnd=pcb,menu='Save'),'save-before')
call('pull_file',dict(filePaths=[remote],saveTo=str(O/'before')),'backup');assert hashlib.sha256((O/'before/adom-custom-electronic-load.kicad_pcb').read_bytes()).hexdigest()==a['boardSha256']
call('desktop_close_window',dict(hwnd=pcb),'close')
for i in range(5):
 r=call('desktop_list_windows',{},f'windows-{i}');w=json.loads(r['output'])['data']['windows']
 if not any(x['hwnd']==pcb for x in w):break
 time.sleep(1)
else:raise RuntimeError('Task editor did not close; inspect dialogs without discarding work')
shutil.copy2(candidate,R/'kicad/adom-custom-electronic-load.kicad_pcb')
call('send_files',dict(filePaths=[str(R/'kicad/adom-custom-electronic-load.kicad_pcb')],dest=remote.rsplit('/',1)[0],reason='Adopt DRC-clean front legends and move J8 reference out of corner tag; copper unchanged'),'send')
call('kicad_open_board',dict(filePath=remote,foreground=False,waitSeconds=15),'open')
state=call('kicad_routing_state',dict(filePath=remote),'after');print(json.dumps(dict(revision=state['revision'],boardPath=state['boardPath'],netsRemaining=state.get('netsRemaining'))),flush=True)
call('kicad_open_editors',{},'editors')