run_exact_atom_ledger_expansion_037.py VOYNICH RESEARCH ARCHIVE | 16 SEPTEMBER 2026 2 abs(z['y']-g['y'])/837<=.03 and jac>=.5 and lcs>=.75 and new row.update({'zl_selected_line':z['line'],'gc_selected_line':g['line'],'zl_hit':int(z['hit']),'gc_hit ':int(g['hit']),'vertical_center_delta':abs(z['y']-g['y'])/837,'jaccard':jac,'lcs':lcs,'new_physical_rec ord':int(new),'qualifies':int(ok)}) if ok:qual.append({'record_id':f"{r.folio}:{z['line']}/{g['line']}",'folio':r.folio,'zl_line':z['lin e'],'gc_line':g['line'],'keys':r.payload,'zl_residual':' | '.join(z['residual']),'gc_residual':' | '.join(g['residual']),'multiset_jaccard':jac,'ordered_lcs_ratio':lcs}) audit.append(row) a=pd.DataFrame(audit);q=pd.DataFrame(qual).drop_duplicates(['folio','zl_line','gc_line']) if qual else pd.DataFrame(columns=['record_id','folio','zl_line','gc_line','keys','zl_residual','gc_residual','multis et_jaccard','ordered_lcs_ratio']) expanded=pd.concat([old,q],ignore_index=True);expanded.to_csv(OUT/'expanded_anonymous_ledger.csv',index =False);a.to_csv(OUT/'candidate_audit.csv',index=False);q.to_csv(OUT/'new_qualifying_records.csv',index= False) summary={'test':'EXACT-ATOM-LEDGER-EXPANSION-037','zl_projected_label_events':len(zl),'exact_gc_subsequ ence_events':int(a.exact_subsequence.sum()),'events_with_label_boxes':int(a.has_label_box.sum()),'new_qu alifying_physical_records':len(q),'ledger_records_before':len(old),'ledger_records_after':len(expanded), 'pass':len(q)>=1,'boundary':'Anonymous label-to-record expansions only; no plaintext or semantic gloss.'};(OUT/'summary.json').write_text(json.dumps(summary,indent=2)) report=['# EXACT-ATOM-LEDGER-EXPANSION-037','',('**PASS — LEDGER EXPANDED**' if len(q) else '**FAIL — NO NEW RECORDS**'),'','All projected ZL label events were searched at the same GC locus. Recovery required an exact contiguous atom subsequence, a physical label box, unchanged vertical selection, both-witness key hits, vertical-center agreement <=.03 page heights, residual Jaccard >=.50, ordered LCS >=.75, and a new physical record.','',f"- ZL label events: {len(zl)}",f"- Exact GC subsequence events: {int(a.exact_subsequence.sum())}",f"- New qualifying physical records: {len(q)}",f"- Ledger size: {len(old)} -> {len(expanded)}",''] if len(q):report += ['## New records','',*['- '+r.record_id+f"; key {r.keys}; Jaccard {r.multiset_jaccard:.3f}; LCS {r.ordered_lcs_ratio:.3f}" for r in q.itertuples()],''] report += ['## Rule audit','',('CORE PRESERVATION, EDGE HANDOFF, CONTEXTUAL INTERNAL REALIZATION, and REGISTER SHIFT strengthen; six rules remain.' if len(q) else 'No rule change; six remain.')] (OUT/'report.md').write_text('\n'.join(report));files=sorted(x for x in OUT.iterdir() if x.is_file() and x.name!='SHA256SUMS.txt');(OUT/'SHA256SUMS.txt').write_text('\n'.join(f'{hashlib.sha256(x.read_bytes ()).hexdigest()} {x.name}' for x in files)+'\n');print(json.dumps(summary,indent=2)) if __name__=='__main__':main()