run_glyph_microfeature_audit_026.py VOYNICH RESEARCH ARCHIVE | 16 SEPTEMBER 2026 3 tr]);xbt=dv.transform([base(r) for r in te]);y=[r['target'] for r in tr];yt=[r['target'] for r in te];fits={} for name,key in [('STRUCTURE',None),('RAW_MICRO','raw'),('CALIBRATED_MICRO','cal')]: if key: sc=StandardScaler();zi=sc.fit_transform(np.vstack([r[key] for r in tr]));zt=sc.transform(np.vstack([r[key] for r in te]));x=sparse.hstack([xb,zi],format='csr');xt=sparse.h stack([xbt,zt],format='csr') else:x,xt=xb,xbt m=SGDClassifier(loss='log_loss',alpha=8e-4,max_iter=1600,tol=1e-4,average=True,random_state=SEED).fi t(x,y);p=m.predict_proba(xt);bits=log_loss(yt,p,labels=m.classes_)/math.log(2);acc=accuracy_score(yt,m.c lasses_[p.argmax(1)]);rows.append({'witness':wit,'fold':k,'model':name,'train_n':len(tr),'test_n':len(te ),'bits':bits,'accuracy':acc});fits[name]=(m,bits,acc,xt) # Calibrated blocked alignment null, exact token + section. rng=np.random.default_rng(SEED+k+(wit=='GC')*100);groups=defaultdict(list) for j,r in enumerate(te):groups[(r['current'],r['section'])].append(j) sc=StandardScaler();zi=sc.fit_transform(np.vstack([r['cal'] for r in tr]));zt=sc.transform(np.vstack([r['cal'] for r in te]));m=fits['CALIBRATED_MICRO'][0] for rep in range(REPS): order=np.arange(len(te)) for inds in groups.values(): q=np.array(inds);rng.shuffle(q);order[inds]=q xp=sparse.hstack([xbt,zt[order]],format='csr');p=m.predict_proba(xp);bits=log_loss(yt,p,labels=m.cla sses_)/math.log(2);nullrows.append({'witness':wit,'fold':k,'replicate':rep,'null_gain':fits['STRUCTURE'] [1]-bits}) pd.DataFrame(rows).to_csv(OUT/'heldout_folds.csv',index=False);pd.DataFrame(nullrows).to_csv(OUT/'block ed_microfeature_null.csv',index=False);summary={'test':'GLYPH-MICROFEATURE-AUDIT-026','usable_tokens':le n(raw),'feature_count':len(next(iter(raw.values()))),'calibration':'folio median/MAD, unsupervised','witnesses':{}} d=pd.DataFrame(rows);n=pd.DataFrame(nullrows) for w in ('ZL','GC'): q=d[d.witness==w].pivot(index='fold',columns='model',values=['bits','accuracy']);weights=d[(d.witness= =w)&(d.model=='STRUCTURE')].set_index('fold').test_n.reindex(q.index).to_numpy();g=(q['bits']['STRUCTURE ']-q['bits']['CALIBRATED_MICRO']).to_numpy();rawg=(q['bits']['STRUCTURE']-q['bits']['RAW_MICRO']).to_num py();obs=float(np.average(g,weights=weights));nv=[] for rep in range(REPS):nv.append(float(np.average(n[(n.witness==w)&(n.replicate==rep)].sort_values('fo ld').null_gain,weights=weights))) summary['witnesses'][w]={'events':int(weights.sum()),'calibrated_gain_bits':obs,'raw_gain_bits':float( np.average(rawg,weights=weights)),'positive_folds':int((g>0).sum()),'beats_raw_folds':int((g>rawg).sum() ),'blocked_null_p':float((1+sum(x>=obs for x in nv))/(REPS+1))} summary['replicated_pass']=bool(all(summary['witnesses'][w]['calibrated_gain_bits']>0 and summary['witnesses'][w]['positive_folds']>=4 and summary['witnesses'][w]['beats_raw_folds']>=4 and summary['witnesses'][w]['blocked_null_p']<=.05 for w in ('ZL','GC')));(OUT/'summary.json').write_text(js on.dumps(summary,indent=2)) report=['# GLYPH-MICROFEATURE-AUDIT-026','',('**PASS**' if summary['replicated_pass'] else '**FAIL / NOT PROMOTED**'),'', 'Skeleton topology, endpoints, junctions, curvature proxies, attachment height, holes, slant, entry/exit geometry, and spatial topology were tested beyond exact structural token identity. Folio median/MAD calibration was unsupervised and removed page/scribe drift.',''] for w,s in summary['witnesses'].items():report += [f'## {w}','',f"- Calibrated gain: {s['calibrated_gain_bits']:+.6f} bits/event ({s['positive_folds']}/5 folds)",f"- Raw gain: {s['raw_gain_bits']:+.6f} bits/event",f"- Calibrated beats raw: {s['beats_raw_folds']}/5 folds",f"- Blocked-null p: {s['blocked_null_p']:.6f}",f"- Events: {s['events']}",''] report += ['## Decision','', 'Promotion requires both witnesses, at least 4/5 positive folds, calibration beating raw features in at least 4/5 folds, and blocked p≤.05. A pass would show portable sub-token handwriting detail, not plaintext.','', '## Rule audit','',('A pass strengthens CONTEXTUAL INTERNAL REALIZATION without adding a rule.' if summary['replicated_pass'] else 'The six-rule ledger remains unchanged; no image-specific rule is added.')];(OUT/'report.md').write_text('\n'.join(report));f iles=sorted(p for p in OUT.iterdir() if p.is_file() and p.name!='SHA256SUMS.txt');(OUT/'SHA256SUMS.txt') .write_text('\n'.join(f'{hashlib.sha256(p.read_bytes()).hexdigest()} {p.name}' for p in files)+'\n');print(json.dumps(summary,indent=2)) if __name__=='__main__':main()