# decryption_complete: false # source: /Voynich/Voynich_Tests_024_025_reproducibility_bundles.zip!/Voynich_RAW_EDGE_AUDIT_025_reproduci # stated_sha256: efd820772cba6f30db8d8cfecd99efe25509266fda32c87d1509d15bf6248438 # matches_stated_sha256: false # pdf_pages: 770-771 # note: The stated SHA-256 is the digest printed in the PDF. # The PDF page extract follows the form feed. decryption_complete stays false. raw_edge_audit_025.py VOYNICH RESEARCH ARCHIVE | 16 SEPTEMBER 2026 1 raw_edge_audit_025.py Source: /Voynich/Voynich_Tests_024_025_reproducibility_bundles.zip!/Voynich_RAW_EDGE_AUDIT_025_reproduci bility.zip!/raw_edge_audit_025.py SHA-256: efd820772cba6f30db8d8cfecd99efe25509266fda32c87d1509d15bf6248438 !/usr/bin/env python3 """Raw physical-edge transition audit, independent in ZL and GC.""" from pathlib import Path import hashlib,json,re import numpy as np,pandas as pd from sklearn.compose import ColumnTransformer from sklearn.linear_model import LogisticRegression from sklearn.metrics import log_loss from sklearn.pipeline import Pipeline from sklearn.preprocessing import OneHotEncoder,StandardScaler ROOT=Path(__file__).resolve().parent;IN=ROOT/'outer_scaffold_coverage_001/corpus_scaffold.csv';OUT=ROOT/ 'raw_edge_audit_025';OUT.mkdir(exist_ok=True) SEED=20260830;rng=np.random.default_rng(SEED) CAT_BASE=['current_left','payload_first','payload_last','section','pos_bucket','same_payload_prev'] NUM=['payload_len','rel_pos']; EDGE=['current_right'] def sec(f): m=re.match(r'f(\d+)',str(f));n=int(m.group(1)) if m else -1 return 'Herbal' if n<=66 else 'Astro' if n<=73 else 'Bio' if n<=84 else 'Pharma' if n<=102 else 'Recipes' if n<=116 else 'Other' def folds(fs): fs=sorted(fs);q=np.random.default_rng(SEED);q.shuffle(fs);return {f:i%5 for i,f in enumerate(fs)} def pipe(cats): pre=ColumnTransformer([('cat',OneHotEncoder(handle_unknown='ignore'),cats),('num',StandardScaler(),NUM) ]) return Pipeline([('pre',pre),('lr',LogisticRegression(C=.25,max_iter=2000,class_weight='balanced',rando m_state=SEED))]) def make_data(x,w): z=x[x.witness==w].sort_values(['folio','line','index']).copy();z['section']=z.folio.map(sec) grp=z.groupby(['folio','line'],sort=False);z['next_left']=grp.left_atom.shift(-1);z['next_index']=grp[' index'].shift(-1);z['line_n']=grp['index'].transform('count');z['ord']=grp.cumcount() z=z[(z.next_index==z['index']+1)&z.next_left.notna()].copy();p=z.payload.fillna('').astype(str).str.spl it() z['current_left']=z.left_atom.fillna('NA');z['current_right']=z.right_atom.fillna('NA');z['payload_firs t']=p.str[0].fillna('EMPTY');z['payload_last']=p.str[-1].fillna('EMPTY');z['payload_len']=p.str.len();z[ 'rel_pos']=z['ord']/z.line_n.clip(lower=1) z['pos_bucket']=pd.cut(z.rel_pos,[-.01,.2,.8,1.01],labels=['START','MIDDLE','END']).astype(str) z['same_payload_prev']=(z.payload==grp.payload.shift(1).reindex(z.index)).astype(str) z=z[z.next_left.map(z.next_left.value_counts())>=30].copy();z['fold']=z.folio.map(folds(z.folio.unique( )));return z def run(z,w): rows=[];cache=[] for f in range(5): tr=z[z.fold!=f];te=z[z.fold==f] mb=pipe(CAT_BASE).fit(tr,tr.next_left);me=pipe(CAT_BASE+EDGE).fit(tr,tr.next_left) pb=mb.predict_proba(te);pe=me.predict_proba(te);classes=me.named_steps['lr'].classes_ # Both models can have same training classes; explicit labels protects held-out missing classes. llb=log_loss(te.next_left,pb,labels=mb.named_steps['lr'].classes_)/np.log(2);lle=log_loss(te.next_left ,pe,labels=classes)/np.log(2) rows.append({'witness':w,'fold':f,'n':len(te),'base_bits':llb,'edge_bits':lle,'gain_bits':llb-lle}) cache.append((te,me,llb)) obs=float(np.average([r['gain_bits'] for r in rows],weights=[r['n'] for r in rows]));null=[] for b in range(1000): gains=[];ns=[] for te0,m,llb in cache: te=te0.copy();keys=te.section.astype(str)+'|'+te.pos_bucket.astype(str)+'|'+te.payload_last.astype(st r) vals=te.current_right.to_numpy().copy() for k in keys.unique(): raw_edge_audit_025.py VOYNICH RESEARCH ARCHIVE | 16 SEPTEMBER 2026 2 ii=np.where(keys.to_numpy()==k)[0] if len(ii)>1:vals[ii]=vals[rng.permutation(ii)] te['current_right']=vals;p=m.predict_proba(te);ll=log_loss(te.next_left,p,labels=m.named_steps['lr']. classes_)/np.log(2);gains.append(llb-ll);ns.append(len(te)) null.append(np.average(gains,weights=ns)) pv=float((1+sum(q>=obs for q in null))/1001) # Raw transition residual table for cross-witness comparison. tab=pd.crosstab(z.current_right,z.next_left,normalize='index').stack().rename('p').reset_index();tab['w itness']=w return pd.DataFrame(rows),tab,{'witness':w,'n_transitions':len(z),'n_folios':z.folio.nunique(),'gain_bi ts':obs,'positive_folds':sum(r['gain_bits']>0 for r in rows),'permutation_p':pv,'null_mean':float(np.mea n(null))} def main(): x=pd.read_csv(IN);rs=[];ts=[];ss=[] for w in ['ZL','GC']: r,t,s=run(make_data(x,w),w);rs.append(r);ts.append(t);ss.append(s) transitions=pd.concat(ts);a=transitions.pivot_table(index=['current_right','next_left'],columns='witnes s',values='p').dropna();corr=float(a.ZL.corr(a.GC)) summary={'test':'RAW-EDGE-AUDIT-025','seed':SEED,'null_replicates':1000,'results':ss,'cross_witness_tra nsition_correlation':corr} summary['pass']=all(s['gain_bits']>0 and s['positive_folds']>=4 and s['permutation_p']<.05 for s in ss) and corr>.8 pd.concat(rs).to_csv(OUT/'fold_results.csv',index=False);transitions.to_csv(OUT/'transition_probabiliti es.csv',index=False);(OUT/'summary.json').write_text(json.dumps(summary,indent=2)) lines=['# RAW-EDGE-AUDIT-025','',('**PASS**' if summary['pass'] else '**FAIL / NOT PROMOTED**'),'', 'Frozen question: does the raw right-edge atom improve held-out prediction of the next raw left-edge atom after body endpoints, body length, line position, section, and immediate repetition are controlled? No semantic labels or illustrations enter the model.','', '## Results',''] for s in ss:lines += [f"### {s['witness']}",'',f"- Incremental gain: {s['gain_bits']:+.6f} bits/transition",f"- Positive folio-held-out folds: {s['positive_folds']}/5",f"- Conditional permutation p: {s['permutation_p']:.6f}",f"- {s['n_transitions']} transitions across {s['n_folios']} folios",''] lines += ['## Cross-witness replication','',f"Raw transition-profile correlation: **r={corr:.6f}**.",'','## Original-rule audit','',('A pass independently strengthens EDGE HANDOFF in raw atom space; it does not add a seventh rule or supply linguistic glosses.' if summary['pass'] else 'The six-rule ledger is unchanged; raw-edge promotion requires both witnesses and stable held-out folds.')] (OUT/'report.md').write_text('\n'.join(lines));files=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()