main
John Lauer
Record verified native current-path rework and remaining shunt limitation; refresh compiled bring-up evidence
bc7f073
"""Land the checked current-path candidate on the named project, with revision guards.
Run only after starting the AIFlow step recording. This script does not mark a gate passed.
"""
from pathlib import Path
import hashlib,json,subprocess,time
P=Path(__file__).resolve().parents[1];plan=json.loads((P/'design/current-rework-plan.json').read_text());out=P/'design/current-rework-live';out.mkdir(exist_ok=True)
board='C:/Users/john/adom-projects/adom-custom-electronic-load/kicad/adom-custom-electronic-load.kicad_pcb'
sha=lambda p:hashlib.sha256(p.read_bytes()).hexdigest()
assert sha(P/plan['sourceBoard'])==plan['sourceSha256']
assert sha(P/plan['candidate'])==plan['candidateSha256']
drc=json.loads((P/plan['candidate']).with_name('native-drc.json').read_text())
assert not drc['unconnected_items'] and not any(v['severity']=='error'for v in drc['violations'])
mesh=json.loads((P/'checkpoints/current-rework-mesh-0p1/comparison.json').read_text())
assert mesh['inputsSha256'][plan['candidate']]==plan['candidateSha256']
assert mesh['inputsSha256'][plan['sourceBoard']]==plan['sourceSha256']
for row in mesh['rows']:
if row['net']=='GND': assert row['candidatePeakAperMm2']<60
else: assert row['candidatePeakAperMm2']<row['baselinePeakAperMm2'],row
n=0
def ab(verb,args,label):
global n;n+=1
d=json.loads(subprocess.check_output(['adom-bridge','--target','AdomLapper','--ai-thread','adom-custom-load',verb,json.dumps(args)],text=True))
(out/f'{n:02d}-{label}.json').write_text(json.dumps(d,indent=2))
assert d.get('success')is not False and not d.get('error') and d.get('status')!='error',str(d)[:1000]
print(label,'OK',flush=True);return d
state=ab('kicad_routing_state',{'filePath':board},'before')
assert state['boardPath'].replace('\\','/').replace('//','/')==board
assert state['revision']=='28a0095133f488b59f9fcecf23cea369ce9be18e3b9ef5c2ed95e2a2cef1b64e','Live board changed; recompute from current state'
def mutate(verb,args,label):
global state
ab(verb,dict(filePath=board,expectedRevision=state['revision'],**args),label)
state=ab('kicad_routing_state',{'filePath':board},label+'-state')
mutate('kicad_move_footprint',{'refs':plan['moveFootprints']},'diode-orientation')
mutate('kicad_remove_route',{'itemIds':plan['removeCopperIds']},'remove-replaced-copper')
mutate('kicad_remove_zone',{'itemIds':plan['replaceZones']['ownedItemIds']},'remove-old-diode-spread')
for i,route in enumerate(plan['routes']):mutate('kicad_route_net',dict(route,validate=False),f'route-{i:02d}-{route["net"]}')
mutate('kicad_add_zone',{'zones':plan['replaceZones']['zones'],'validate':False,'refill':False},'new-power-spread-zones')
ab('kicad_zone_state',{'filePath':board,'refill':True},'refill-request')
print('Native edits sent. Wait for stable refill, save, pull and compare to the checked candidate before adopting.',flush=True)