run_boundary_invariant_atom_ledger_045.py VOYNICH RESEARCH ARCHIVE | 16 SEPTEMBER 2026 2 pd.DataFrame([prospective]).to_csv(OUT / "prospective_sixth_atom_role.csv", index=False) pd.DataFrame([{"record": target.record_id, "atom": x, "position": p, "retained": y, "baseline_p": bp, "atom_role_p": fp} for x,p,y,bp,fp in pred]).to_csv(OUT / "prospective_atom_predictions.csv", index=False) folds = [] for i, r in atom.iterrows(): lb2, lf2, pp = r36.score(r, r36.fit(list(atom.drop(i).itertuples()))) folds.append({"heldout_record": r.record_id, "n_zl_atoms": len(pp), "baseline_bits": lb2, "atom_role_bits": lf2, "gain_bits": lb2-lf2}) fd = pd.DataFrame(folds); fd.to_csv(OUT / "six_record_atom_role_loo.csv", index=False) pass_record = bool(led.iloc[5].atom_jaccard >= .50 and led.iloc[5].atom_lcs >= .75) pass_roles = bool(prospective["gain_bits"] > 0 and fd.gain_bits.mean() > 0 and (fd.gain_bits > 0).sum() >= 5) ledger_pass = bool(pass_record and pv < .05) summary = {"test": "BOUNDARY-INVARIANT-ATOM-LEDGER-045", "glyph_normalization": "NONE_EXACT_ATOMS", "records_before": 5, "records_after": 6, "sixth_record": target.record_id, "sixth_token_jaccard": float(led.iloc[5].token_jaccard), "sixth_token_lcs": float(led.iloc[5].token_lcs), "sixth_atom_jaccard": float(led.iloc[5].atom_jaccard), "sixth_atom_lcs": float(led.iloc[5].atom_lcs), "six_record_mean_atom_jaccard": obs, "pairing_permutation_p": pv, "prospective_atom_role_gain_bits": prospective["gain_bits"], "atom_role_loo_mean_gain_bits": float(fd.gain_bits.mean()), "positive_atom_role_folds": int((fd.gain_bits > 0).sum()), "sixth_record_ledger_pass": ledger_pass, "portable_atom_role_pass": pass_roles, "decision": "LEDGER_PASS_ROLE_EXTENSION_FAIL" if ledger_pass and not pass_roles else "FULL_PASS" if ledger_pass and pass_roles else "FAIL", "boundary": "Exact anonymous glyph-atom streams and retention roles; no semantic gloss or plaintext."} (OUT / "summary.json").write_text(json.dumps(summary, indent=2)) report = ["# BOUNDARY-INVARIANT-ATOM-LEDGER-045", "", "**LEDGER PASS — SIXTH PHYSICAL RECORD RECOVERED; ROLE EXTENSION FAILS**" if ledger_pass and not pass_roles else "**FULL PASS**" if ledger_pass and pass_roles else "**FAIL / NOT PROMOTED**", "", "The only unused same-line, dual-key-hit near miss was re-evaluated below transcription word boundaries. ZL and GC atoms were flattened in order, with no glyph-family merger or spelling normalization.", "", f"- Sixth record token Jaccard / LCS: {led.iloc[5].token_jaccard:.6f} / {led.iloc[5].token_lcs:.6f}", f"- Sixth record exact-atom Jaccard / LCS: {led.iloc[5].atom_jaccard:.6f} / {led.iloc[5].atom_lcs:.6f}", f"- Six-record mean exact-atom Jaccard: {obs:.6f}", f"- Cross-record pairing p: {pv:.6f}", f"- Prospective sixth-record atom-role gain: {prospective['gain_bits']:+.6f} bits/atom", f"- Six-record LOO role gain: {fd.gain_bits.mean():+.6f}; positive folds: {(fd.gain_bits>0).sum()}/6", "", "## Decision split", "", "The sixth-record ledger gate passes. The portable atom-role extension fails because only 4/6 LOO folds are positive, although its prospective sixth-record gain is positive. These decisions are not conflated.", "", "## Interpretation", "", "The ledger pass shows that at least one apparent word-level disagreement is resolved by treating the representation as an ordered glyph-atom stream. It does not assign meanings to atoms.", "", "## Rule audit", "", "CORE PRESERVATION strengthens at the sub-token level. CONTEXTUAL INTERNAL REALIZATION is unchanged because the atom-role extension fails. No seventh rule is added; six remain."] (OUT / "report.md").write_text("\n".join(report) + "\n") pd.DataFrame([ {"test":"BOUNDARY-INVARIANT-ATOM-LEDGER-045","rule":"CORE PRESERVATION","status":"STRENGTHENED","evidence":"Sixth record passes only after exact boundary-invariant atom projection","live_rule_count":6}, {"test":"BOUNDARY-INVARIANT-ATOM-LEDGER-045","rule":"CONTEXTUAL INTERNAL REALIZATION","status":"UNCHANGED","evidence":"Portable atom-role extension has only 4/6 positive LOO folds","live_rule_count":6} ]).to_csv(OUT / "rule_recovery_audit.csv", index=False) 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()}