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()