main
John Lauer Preserve adopted board30 and validated resistor library candidates with native-render dependency 7fa0c9c
"""Regression: only explicitly reviewed, unchanged, unnetted mechanical tabs are accepted."""
from pathlib import Path
import tempfile,subprocess,json,hashlib,copy
import sexp
R=Path(__file__).resolve().parents[1];O=R/'checkpoints/sensor-gh-review-v8';b=O/'sensor-gh-candidate.kicad_pcb';report=json.loads((O/'retention-pad-review.json').read_text());rows=[]
with tempfile.TemporaryDirectory()as folder:
 d=Path(folder)
 for name in ['baseline','missing-evidence','stale-hash','tab-net','tab-size','extra-pad']:
  tree=sexp.parse(b.read_text());e=copy.deepcopy(report);fp=next(f for f in sexp.find(tree,'footprint')if any(p[1:3]==['Reference','J10']for p in sexp.find(f,'property')));mp=next(x for x in sexp.find(fp,'pad')if x[1]=='MP')
  if name=='tab-net':mp.append([sexp.Sym('net'),'GND'])
  if name=='tab-size':sexp.first(mp,'size')[1]=sexp.Sym('1.1')
  if name=='extra-pad':new=copy.deepcopy(mp);new[1]='UNREVIEWED';fp.append(new)
  out=d/(name+'.kicad_pcb');out.write_text(sexp.dump(tree)+'\n');e['boardSha256']=hashlib.sha256(out.read_bytes()).hexdigest()
  if name=='stale-hash':e['boardSha256']='0'*64
  manifest=d/(name+'.json');manifest.write_text(json.dumps(e));args=['python3',str(R/'tools/audit_library.py'),'--board',str(out),'--project-dir',str(O),'--netlist',str(O/'netlist.json'),'--output',str(d/(name+'-result.json'))]
  if name!='missing-evidence':args+=['--mechanical-pads',str(manifest)]
  p=subprocess.run(args,capture_output=True,text=True);expected=name=='baseline';assert (p.returncode==0)==expected,(name,p.stdout,p.stderr);rows.append({'case':name,'accepted':p.returncode==0,'expected':expected})
(O/'mechanical-audit-regression.json').write_text(json.dumps({'cases':rows,'pass':True},indent=2)+'\n');print(json.dumps(rows))