"""Appendix D (revision point 4): for every pre-registration, the commit that first added it, the results file its own run wrote, the commit that first added that file, and the order of the two in git - "before" when the document is a strict ancestor of the results. The mapping document -> own results file is declared below (read off the sweep script each run used); the commits and the order are read from git. python -u check_prereg_order.py -> markdown rows and a summary on stdout """ from __future__ import annotations import subprocess OWN_RESULTS = { "PREREG_logarithmic_2026-09-20.md": "sweep_log.json", "PREREG_prestep_gate_2026-09-21.md": "sweep_gate.json", "PREREG_slope_gate_2026-09-21.md": "sweep_slope.json", "PREREG_points_and_direction_2026-09-21.md": "sweep_points.json", "PREREG_similarity_per_slot_2026-09-21.md": "sweep_order.json", "PREREG_scale_selection_2026-09-21.md": "sweep_cap.json", "PREREG_decision_place_2026-09-21.md": "sweep_decision.json", "PREREG_step_extrapolation_2026-09-21.md": "results_diag_step_extrapolation.txt", "PREREG_extrapolate_in_method_2026-09-21.md": "sweep_extrap.json", "PREREG_extrapolation_gates_2026-09-21.md": "sweep_extrap2.json", "PREREG_empty_step_2026-09-21.md": "results_diag_empty_step.txt", "PREREG_outcome_memory_2026-09-21.md": "results_diag_outcome_memory.txt", "PREREG_flat_regime_2026-09-21.md": "sweep_flat.json", "PREREG_flat_twice_2026-09-21.md": "sweep_flat2.json", "PREREG_flat_creep_2026-09-21.md": "sweep_flatcreep.json", "PREREG_flat_stick_2026-09-21.md": "sweep_flatstick.json", "PREREG_flat_exit_2026-09-21.md": "sweep_flatexit.json", "PREREG_flat_judge_2026-09-21.md": "sweep_flatjudge.json", "PREREG_flat_analogy_2026-09-21.md": "sweep_flatanalog.json", "PREREG_flat_analogy_mem_2026-09-21.md": None, # decided on the smoke (stated in it) "PREREG_defect_contra_flat_2026-09-21.md": "sweep_defcontra.json", "PREREG_flat_order_point_2026-09-21.md": "sweep_orderpt.json", "PREREG_flat_exp_limit_2026-09-21.md": "sweep_explimit.json", "PREREG_half_contra_2026-09-21.md": "sweep_half.json", "PREREG_out_of_sample_2026-09-21.md": "sweep_oos.json", "PREREG_roots_jl_2026-09-21.md": "sweep_rootsjl.json", "PREREG_applied_2026-09-21.md": "sweep_applied.json", "PREREG_close_sub_2026-09-21.md": "sweep_fourth_fourth.json", "PREREG_modab_2026-09-21.md": "sweep_modab.json", "PREREG_controls_2026-09-22.md": "sweep_controls.json", } def first_commit(path): out = subprocess.run(["git", "log", "--diff-filter=A", "--format=%h", "--", path], capture_output=True, text=True, check=False).stdout.split() return out[-1] if out else None def order(pre, res): if pre == res: return "same commit" r = subprocess.run(["git", "merge-base", "--is-ancestor", pre, res], check=False).returncode return "before" if r == 0 else "after" def rows(): out = [] for doc, res in OWN_RESULTS.items(): hp = first_commit(doc) if res is None: out.append((doc, hp, "—", "—", "decided on the smoke run, no results file")) continue hr = first_commit(res) out.append((doc, hp, res, hr, order(hp, hr) if hr else "results not committed")) return out def main(): rs = rows() for doc, hp, res, hr, o in rs: print(f"| `{doc[7:-3]}` | `{hp}` | `{res}` | `{hr}` | {o} |") n = {k: sum(1 for r in rs if r[4] == k) for k in ("before", "same commit", "after")} print(f"\n{len(rs)} pre-registrations: {n['before']} before their results, " f"{n['same commit']} in the same commit, {n['after']} after") print("prereg order done") if __name__ == "__main__": main()