main
John Lauer
Preserve board29, component assets and scaffold-fit correction candidate with reviewed footage
c54169e
"""Land the independently DRC-checked USB revision with native Undo and recording."""
import json,subprocess
from pathlib import Path
p=Path(__file__).resolve().parents[1];out=p/'design/usb-live';out.mkdir(exist_ok=True)
board='C:/Users/john/adom-projects/adom-custom-electronic-load/kicad/adom-custom-electronic-load.kicad_pcb'
def ab(name,args,label):
r=subprocess.run(['adom-bridge','--target','AdomLapper','--ai-thread','adom-custom-load',name,json.dumps(args)],capture_output=True,text=True);d=json.loads(r.stdout);(out/(label+'.json')).write_text(json.dumps(d,indent=2))
if d.get('success')is False or d.get('error'):raise RuntimeError(str(d)[:1600])
return d
s=ab('kicad_routing_state',{'filePath':board},'before');rev=s['revision'];assert rev=='5fc74b3ece97367e755c50f00aaeaf1863be7e6e867e0475b4f80f7a7daefc19'
changes=json.load(open(p/'checkpoints/usb-inline/usb-inline-changes.json'));plan=json.load(open(p/'checkpoints/usb-inline/plan-v6.json'))
assert json.load(open(p/'checkpoints/usb-inline/run-v6/gate.json'))['errors']==0
ab('kicad_select_net',{'filePath':board,'net':'USB_DP_CONN'},'select');ab('kicad_send_key',{'hwnd':400958,'menu':'Zoom to Selected Objects'},'frame')
rec=ab('desktop_record_window_start',{'hwnd':400958,'fps':30,'audio':False,'cursor':False,'maxDurationMs':120000,'reason':'Actual native USB ESD relocation and route replacement after isolated zero-error zero-open gate'},'record-start')
def mutate(name,args,label):
global rev
d=ab(name,dict(filePath=board,expectedRevision=rev,**args),label)
rev=d.get('revision')or ab('kicad_routing_state',{'filePath':board},label+'-state')['revision'];return d
try:
mutate('kicad_remove_route',{'itemIds':[x['uuid']for x in changes['removed']]},'remove-old-copper')
mutate('kicad_move_footprint',{'refs':[{'ref':r,'x':v[0],'y':v[1],'rotation':v[2]}for r,v in changes['moved'].items()]},'move-esd-and-links')
groups={}
for t in changes['fixedTracks']:
groups.setdefault((t['net'],t['layer'],t['width']),[]).append([t['start'],t['end']])
for i,((net,layer,width),paths)in enumerate(groups.items()):
mutate('kicad_route_net',{'net':net,'layer':layer,'width':width,'paths':paths,'validate':False},f'fixed-{i}-{net}')
# Explicit via transitions; fixed track endpoints do not implicitly create vias.
for i,(net,x,y)in enumerate([('USB_DM_CONN',156.3,43.75),('USB_DM_CONN',152.85,42),('GND',151.9,45.85)]):
mutate('kicad_route_net',{'net':net,'width':.25,'viaSize':.6,'viaDrill':.3,'paths':[[{'x':x,'y':y,'layer':'F.Cu'},{'x':x,'y':y,'layer':'B.Cu'}]],'validate':False},f'fixed-via-{i}')
for i,e in enumerate(plan['nets']):
mutate('kicad_route_net',dict(e,validate=False),f'route-{i}-{e["net"]}')
ab('kicad_select_net',{'filePath':board,'net':'USB_DM_CONN'},'select-final');ab('kicad_send_key',{'hwnd':400958,'menu':'Zoom to Selected Objects'},'frame-final')
finally:
ab('desktop_record_stop',{'recordingId':rec['recordingId']},'record-stop')
print('USB copper landing completed; native fill, silk, properties and saved-board acceptance remain pending')