main
John Lauer Review cumulative land candidates and correct complete STEP assembly clearance checks ca3da55
"""Bind three exact-part library reviews to the cumulative unadopted candidate."""
from pathlib import Path
import hashlib,json
import sexp
R=Path(__file__).resolve().parents[1];O=R/'checkpoints/fuse-diode-land-review-v2';board=O/'fuse-diode-land-candidate.kicad_pcb'
sha=lambda p:hashlib.sha256(p.read_bytes()).hexdigest()
intent={c['ref']:c for c in json.loads((R/'design/netlist.json').read_text())['components']}
fps={next(p[2]for p in sexp.find(f,'property')if p[1]=='Reference'):f for f in sexp.find(sexp.parse(board.read_text()),'footprint')}
slugs={'F1':'0466005-nr','D4':'b140-13-f','L1':'amplh5030s-100mt'};rows=[]
for ref,slug in slugs.items():
 f=fps[ref];props={p[1]:p[2]for p in sexp.find(f,'property')};assert props['MPN']==intent[ref]['mpn']
 catalog=R/'components'/slug;cf=sexp.parse((catalog/(slug+'.kicad_mod')).read_text());cp={p[1]:p for p in sexp.find(cf,'pad')};pads=sexp.find(f,'pad');assert {p[1]for p in pads}==set(cp)=={'1','2'}
 for p in pads:
  assert sexp.first(p,'net')[-1]==intent[ref]['pins'][p[1]]
  for key in ['at','size']:
   assert list(map(float,sexp.first(p,key)[1:3]))==list(map(float,sexp.first(cp[p[1]],key)[1:3])),(ref,key)
 model=Path(sexp.first(f,'model')[1].replace('${KIPRJMOD}',str(O)));catmodel=catalog/(slug+'.step')
 rows.append({'reference':ref,'mpn':props['MPN'],'wiki':'https://wiki.adom.inc/adom/'+slug,'pins':intent[ref]['pins'],'catalogPadCentersAndSizesMatch':True,'selectedModelSha256':sha(model),'catalogModelSha256':sha(catmodel),'selectedModelMatchesCatalog':sha(model)==sha(catmodel),'polarity':'1=cathode V_GATE; 2=anode BOOST_SW; band inspected in d4-native-detail.png'if ref=='D4'else 'nonpolar','modelReview':'model-envelope-review.json','candidateAdopted':False})
report={'candidateSha256':sha(board),'references':rows,'limitations':['D4 retains nominal KiCad SMA model; catalog uses a different nominal Adom model. No silent model substitution.','F1/L1 selected models match the catalog hashes. Nominal geometry is not a tolerance or physical acceptance proof.','Native live visual, published-page visual and physical process reviews remain pending. No library gate advancement.']}
(O/'fuse-diode-inductor-review.json').write_text(json.dumps(report,indent=2)+'\n')
p=R/'aiflow/run/components.json';reg=json.loads(p.read_text());assert reg['board']=='aiflow/run/board-30.kicad_pcb'
for c in reg['components']:
 if c['reference']in slugs:
  review=c['review'];review['classification']='purchased';e=review.setdefault('geometryEvidence',[]);path='checkpoints/fuse-diode-land-review-v2/fuse-diode-inductor-review.json'
  if path not in e:e.append(path)
p.write_text(json.dumps(reg,indent=2)+'\n');print(json.dumps(report,indent=2))