main
John Lauer Bind IC library reviews to Board31 and verify published component views d1cea8b
"""Verify current board-model lineage against exact component source files."""
from pathlib import Path
import json,hashlib
import sexp
R=Path(__file__).resolve().parents[1];O=R/'checkpoints/board31-ic-library-review'
sha=lambda p:hashlib.sha256(p.read_bytes()).hexdigest()
board=R/'aiflow/run/board-31.kicad_pcb';b=sexp.parse(board.read_text());reg=json.loads((R/'aiflow/run/components.json').read_text());rows=[]
for c in reg['components']:
 if not c['reference'].startswith('U'):continue
 slug=c['review']['wikiPage'].rsplit('/',1)[-1];directory=R/'components'/slug
 page=json.loads((directory/'page.json').read_text());parts=page['component']['parts'];catalog=[]
 for key,path in parts.items():
  file=directory/path
  if file.is_file()and file.suffix.lower()=='.step':catalog.append({'role':key,'file':str(file.relative_to(R)),'sha256':sha(file)})
 bindings=[]
 for path in c['modelReferences']:
  file=Path(path.replace('${KIPRJMOD}',str(board.parent)));h=sha(file);matches=[x for x in catalog if x['sha256']==h];assert matches,(c['reference'],'No exact catalog STEP match')
  bindings.append({'file':str(file.relative_to(R)),'sha256':h,'matchingCatalogAssets':matches})
 provenance=[str(p.relative_to(R))for p in directory.glob('*provenance*.json')]
 licenses=[str(p.relative_to(R))for p in directory.glob('LICENSE*')]
 rows.append({'reference':c['reference'],'wikiPage':c['review']['wikiPage'],'mpn':c['properties']['MPN'],'models':bindings,'provenanceFiles':provenance,'licenseFiles':licenses,'limitations':'Byte identity establishes lineage only. Review provenance and license terms independently; no dimensional or physical acceptance.'})
report={'boardSha256':sha(board),'references':len(rows),'bindings':rows};assert len(rows)==10
(O/'model-bindings.json').write_text(json.dumps(report,indent=2)+'\n');print('PASS: all10 adopted IC models byte-match exact catalog STEP assets')