main
John Lauer
Save native two-sided contact artwork and recorded GLB material correction; qualification remains open
57e2489
#!/usr/bin/env python3
"""Require exact reviewed board content, allowing only native number formatting."""
import json,hashlib,decimal
from pathlib import Path
from sexp import parse
R=Path(__file__).resolve().parents[1];O=R/'design/silkscreen-review/front-contacts';candidate=R/'kicad/front-contact-candidate.kicad_pcb';saved=O/'landed/adom-custom-electronic-load.kicad_pcb';review=json.loads((O/'candidate-review.json').read_text());assert hashlib.sha256(candidate.read_bytes()).hexdigest()==review['candidateSha256']
def norm(v):
if isinstance(v,list):return [norm(x) for x in v]
try:
n=decimal.Decimal(v)
if not n.is_finite():return v
return str(n.quantize(decimal.Decimal('0.000001')).normalize())
except (decimal.InvalidOperation,ValueError,TypeError):return v
before=norm(parse(candidate.read_text()));after=norm(parse(saved.read_text()));assert before[0]==after[0]
a=sorted(json.dumps(x) for x in before[1:]);b=sorted(json.dumps(x) for x in after[1:]);assert a==b,'Saved board differs from candidate beyond native 1 nm formatting'
report=dict(status='native saved board matches reviewed candidate',savedSha256=hashlib.sha256(saved.read_bytes()).hexdigest(),sourceSha256=review['sourceSha256'],candidateSha256=review['candidateSha256'],comparison='Full parsed root content; order-independent root nodes; numeric formatting normalized to 1 nm',addedTexts=review['texts'],addedGraphics=review['graphics'],referenceMove=review['referenceMove'],circuitAndCopperUnchanged=True,nativeRevision='8ad5cf23aeb0d12845a382355905c713d28f877ba8c5d1127534893ec4c45fed',nativeDrcPending=True)
(O/'landing-verification.json').write_text(json.dumps(report,indent=2)+'\n');print(json.dumps(report,indent=2))