main
John Lauer
Add insulated sensor library and reconcile off-board harness and staged labels
10fc208
"""Correct stale assembly labels in an isolated candidate; no copper or gate changes."""
from pathlib import Path
import shutil,json,hashlib
import sexp
R=Path(__file__).resolve().parents[1];B=R/'checkpoints/fuse-diode-land-review-v2';O=R/'checkpoints/library-label-review';O.mkdir(exist_ok=True)
for d in ['lib','3d']:shutil.copytree(B/d,O/d,dirs_exist_ok=True)
shutil.copy2(B/'fp-lib-table',O/'fp-lib-table')
for ext in ['kicad_pro','kicad_dru']:shutil.copy2(B/('fuse-diode-land-candidate.'+ext),O/('library-label-candidate.'+ext))
for p in B.glob('*.kicad_sch'):shutil.copy2(p,O/p.name)
src=B/'fuse-diode-land-candidate.kicad_pcb';b=sexp.parse(src.read_text());before=[]
changes={'94413533-3792-4a47-a9e6-ac5f8b78a779':('4.7k',None),'e000ee8a-bc52-4c25-b0df-937568a2b053':('J10',[109.25,33.0,0]),'a554257a-37fc-46ce-823b-d3dcfe0a1dc6':('TEMP',[109.25,34.8,0])}
seen=set()
for t in sexp.find(b,'gr_text'):
uid=sexp.first(t,'uuid')[1]
if uid not in changes:continue
assert sexp.first(t,'layer')[1]=='B.SilkS';before.append({'uuid':uid,'text':t[1],'at':sexp.first(t,'at')[1:]});text,at=changes[uid];t[1]=text
if at is not None:sexp.first(t,'at')[1:]=[sexp.Sym(str(x))for x in at]
seen.add(uid)
assert seen==set(changes)
dst=O/'library-label-candidate.kicad_pcb';dst.write_text(sexp.dump(b)+'\n');sha=lambda p:hashlib.sha256(p.read_bytes()).hexdigest()
(O/'label-changes.json').write_text(json.dumps({'sourceSha256':sha(src),'candidateSha256':sha(dst),'before':before,'changes':changes,'scope':'Three B.SilkS text corrections only; same copper, holes, components and nets. Native DRC and visual review required; no adoption.'},indent=2)+'\n')
print('Prepared three stale-label corrections; candidate remains unadopted')