main
John Lauer
Review cumulative land candidates and correct complete STEP assembly clearance checks
ca3da55
"""Bound capacitor identity, pin membership, source variants and nominal envelope review."""
from pathlib import Path
import json,hashlib
import sexp
R=Path(__file__).resolve().parents[1];O=R/'checkpoints/capacitor-library-review';src=R/'aiflow/run/board-30.kicad_pcb';candidate=O/'capacitor-land-candidate.kicad_pcb';sha=lambda p:hashlib.sha256(p.read_bytes()).hexdigest()
specs={'0603B104J500CT':('100nF',50,'X7R','X',7),'0603B103J250CT':('10nF',25,'X7R','S',7),'0603B105K160CT':('1uF',16,'X7R','X',7),'0603N102J500CT':('1nF',50,'C0G/NP0','S',5),'0603X475K100CT':('4.7uF',10,'X5R','X',9),'CL21A475KAQNNNG':('4.7uF',25,'X5R','Q',1)}
intent={c['ref']:c for c in json.loads((R/'design/netlist.json').read_text())['components']};rows=[];models={}
for name,bbox in [('C_0603_1608Metric.step',[1.6,.8,.8]),('C_0805_2012Metric.step',[2,1.25,1.25])]:
p=R/'aiflow/run/3d'/name;stock=O/'source'/name;assert sha(p)==sha(stock);models[name]={'sha256':sha(p),'measuredNominalBboxMm':bbox,'measurement':'CadQuery import of selected STEP; all solids in source model bbox','installedStockByteMatch':True,'license':'CC-BY-SA4.0 with KiCad library exception','classification':'Generic KiCad nominal body, not exact manufacturer CAD or tolerance envelope'}
for f in sexp.find(sexp.parse(src.read_text()),'footprint'):
props={p[1]:p[2]for p in sexp.find(f,'property')};ref=props['Reference']
if not ref.startswith('C'):continue
mpn=props['MPN'];value,voltage,dielectric,thickness,page=specs[mpn];assert mpn==intent[ref]['mpn'];pads=sexp.find(f,'pad');assert {p[1]for p in pads}=={'1','2'}
for p in pads:assert sexp.first(p,'net')[-1]==intent[ref]['pins'][p[1]]
model=Path(sexp.find(f,'model')[0][1]).name;assert model in models
if thickness=='S':ranges=[[1.5,1.7],[.7,.9],[.73,.87]]
elif thickness=='X':ranges=[[1.5,1.75],[.7,.95],[.7,.95]]
else:ranges=[[1.85,2.15],[1.10,1.40],[1.10,1.40]]
assert all(lo<=v<=hi for v,(lo,hi)in zip(models[model]['measuredNominalBboxMm'],ranges))
rows.append({'reference':ref,'mpn':mpn,'nominalValue':value,'ratedVoltageV':voltage,'dielectric':dielectric,'pins':intent[ref]['pins'],'nonpolar':True,'thicknessCode':thickness,'manufacturerRangeTablePage':page,'nominalModelWithinDocumentedEnvelope':True,'selectedModel':model,'footprintReview':'C6 unadopted manufacturer example correction'if ref=='C6'else 'Retain KiCad standard dimensions; Wiki variant changes corner radius. No land pattern in reviewed Walsin approval sheet.','status':'partial; native per-reference view and published-page visual review remain open'})
assert len(rows)==18
report={'board':str(src.relative_to(R)),'boardSha256':sha(src),'unadoptedCandidateSha256':sha(candidate),'references':rows,'models':models,'manufacturerDocuments':{'walsin':{'sha256':sha(O/'source/walsin.pdf'),'title':'ASC General Purpose Series, Dec2023,21pages','reviewedPages':[3,5,7,9],'source':'https://wiki.adom.inc/download/aravk/0603b104j500ct/1.0.0/0603B104J500CT-datasheet.pdf'},'samsung':{'sha256':sha(O/'source/samsung.pdf'),'legacyPartInDocument':'CL21A475KAQNNNE','currentFamilyUrl':'https://product.samsungsem.com/mlcc/CL21A475KAQNNN.do','GVariantExplicitlyListed':True,'landPatternPage':32,'sourceCorrectionCommit':'2904d81bb253e5960f69d1821e9c96ac5f92c114'}},'limits':'Identity/library nominal envelope review only. ClassII DC-bias, aging, effective capacitance, ripple heating, regulator stability and physical solder/process qualification remain separate. Voltage-rating table is not proof of circuit transient margin. No gate pass.'}
(O/'capacitor-family-review.json').write_text(json.dumps(report,indent=2)+'\n')
p=R/'aiflow/run/components.json';x=json.loads(p.read_text());assert x['board']=='aiflow/run/board-30.kicad_pcb'
for c in x['components']:
if not c['reference'].startswith('C'):continue
v=c['review'];v['classification']='purchased';v.setdefault('geometryEvidence',[]);e='checkpoints/capacitor-library-review/capacitor-family-review.json'
if e not in v['geometryEvidence']:v['geometryEvidence'].append(e)
v['capacitorReviewNote']='Exact identity/two-pin net membership and selected stock-model nominal dimensions checked against manufacturer tables. C6 footprint correction unadopted; all native/published-page visual and physical/electrical qualification requirements retained.'
p.write_text(json.dumps(x,indent=2)+'\n');print('18 capacitor references reviewed; no model substitutions or gate advancement')