main
John Lauer Review cumulative land candidates and correct complete STEP assembly clearance checks ca3da55
"""Shift one45-degree DUT_POS escape by0.2mm; preserve widths, lengths and all gates."""
from pathlib import Path
import shutil,json,hashlib,math
import sexp
R=Path(__file__).resolve().parents[1];B=R/'checkpoints/fuse-diode-land-review';O=R/'checkpoints/fuse-diode-land-review-v2';O.mkdir(exist_ok=True)
for d in ['lib','3d']:shutil.copytree(B/d,O/d,dirs_exist_ok=True)
for p in B.iterdir():
 if p.suffix in ['.kicad_pcb','.kicad_pro','.kicad_dru','.kicad_sch']or p.name=='fp-lib-table':shutil.copy2(p,O/p.name)
p=O/'fuse-diode-land-candidate.kicad_pcb';src=p.read_bytes();b=sexp.parse(src.decode());S=sexp.Sym
plan={'059ce1a7-f433-469d-9b6a-678dc218a59a':{'start':([108,94.1],[108,94.3]),'end':([105,91.1],[105,91.3])},'1ec11d4d-a7f8-43ba-89f2-d39a2f8a9acd':{'start':([105,91.1],[105,91.3])},'da79ab43-5f04-49aa-ad8d-811344153464':{'end':([108,94.1],[108,94.3])}};rows=[];seen=set()
for s in sexp.find(b,'segment'):
 uid=sexp.first(s,'uuid')[1]
 if uid not in plan:continue
 assert sexp.first(s,'net')[-1]=='DUT_POS'and sexp.first(s,'layer')[1]=='F.Cu';seen.add(uid);before=sexp.dump(s);length=lambda:math.dist([float(v)for v in sexp.first(s,'start')[1:]],[float(v)for v in sexp.first(s,'end')[1:]]);oldlen=length()
 for k,(old,new)in plan[uid].items():
  a=sexp.first(s,k);assert [float(v)for v in a[1:]]==old;(a.__setitem__(slice(1,None),[S(str(v))for v in new]))
 rows.append({'uuid':uid,'before':before,'after':sexp.dump(s),'oldLengthMm':oldlen,'newLengthMm':length(),'widthMm':float(sexp.first(s,'width')[1])})
assert seen==set(plan);assert abs(sum(r['oldLengthMm']-r['newLengthMm']for r in rows))<1e-8
p.write_text(sexp.dump(b)+'\n');review={'adopted':False,'sourceSha256':hashlib.sha256(src).hexdigest(),'candidateSha256':hashlib.sha256(p.read_bytes()).hexdigest(),'reason':'F1 pad2 clearance0.1339mm versus required0.20mm with manufacturer pattern','changes':rows,'rulesChanged':False,'trackWidthsChanged':False,'addedVias':0,'totalChangedPathLengthDeltaMm':0,'limits':'Geometry repair candidate. Full native refill/DRC, current and thermal analysis and native views remain required. Copper thickness unresolved; existing strict rules retained.'};(O/'escape-repair.json').write_text(json.dumps(review,indent=2)+'\n');print('Shifted DUT_POS elbow0.2mm; widths1.5/2mm and total path length preserved')