diff --git "a/pages/conclusion/page.md" "b/pages/conclusion/page.md" new file mode 100644--- /dev/null +++ "b/pages/conclusion/page.md" @@ -0,0 +1,1878 @@ +# Conclusion + + +--- + +````bash +$ python scripts/audit_results.py --structural-dir outputs/jobs/paper-native-v1/raw/structural --figure4-dir outputs/jobs/paper-native-v1/raw/figure4 --size-dir outputs/jobs/size-adjudication-v1/raw_size --output-dir outputs/final_audit --profile frozen +```` + +exit 0 · 0.1s + + +````python title=audit_results.py +#!/usr/bin/env python3 +"""Recompute all frozen claim metrics from raw CSV/JSON outputs. + +This script performs no model fitting. Its inputs are the immutable seed-level +rows emitted by ``run_reproduction.py``; its outputs are aggregate tables and +machine-readable pass/fail dispositions tied directly to ``CLAIMS.md``. +""" + +from __future__ import annotations + +import argparse +import csv +import json +import math +import statistics +from collections import defaultdict +from pathlib import Path +from typing import Any, Iterable + + +def read_csv(path: Path) -> list[dict[str, str]]: + with path.open(newline="", encoding="utf-8") as handle: + return list(csv.DictReader(handle)) + + +def number(row: dict[str, str], key: str) -> float: + return float(row[key]) + + +def integer(row: dict[str, str], key: str) -> int: + return int(float(row[key])) + + +def key_float(value: float) -> str: + return f"{float(value):.14g}" + + +def median(values: Iterable[float]) -> float: + materialized = list(values) + if not materialized: + return float("nan") + return float(statistics.median(materialized)) + + +def mean(values: Iterable[float]) -> float: + materialized = list(values) + if not materialized: + return float("nan") + return float(statistics.fmean(materialized)) + + +def quantile(values: Iterable[float], probability: float) -> float: + ordered = sorted(float(value) for value in values) + if not ordered: + return float("nan") + if len(ordered) == 1: + return ordered[0] + position = probability * (len(ordered) - 1) + lower = int(math.floor(position)) + upper = int(math.ceil(position)) + weight = position - lower + return float((1.0 - weight) * ordered[lower] + weight * ordered[upper]) + + +def sample_standard_error(values: list[float]) -> float: + if len(values) < 2: + return float("nan") + return float(statistics.stdev(values) / math.sqrt(len(values))) + + +def write_csv(path: Path, rows: list[dict[str, Any]]) -> None: + path.parent.mkdir(parents=True, exist_ok=True) + if not rows: + raise ValueError(f"empty aggregate table: {path}") + fields: list[str] = [] + seen: set[str] = set() + for row in rows: + for key in row: + if key not in seen: + fields.append(key) + seen.add(key) + with path.open("w", newline="", encoding="utf-8") as handle: + writer = csv.DictWriter(handle, fieldnames=fields) + writer.writeheader() + writer.writerows(rows) + + +def write_json(path: Path, payload: Any) -> None: + path.parent.mkdir(parents=True, exist_ok=True) + path.write_text(json.dumps(payload, indent=2, sort_keys=True, allow_nan=False) + "\n", encoding="utf-8") + + +def safe_json_float(value: float) -> float | None: + return float(value) if math.isfinite(float(value)) else None + + +def gate(name: str, passed: bool, value: Any, threshold: str, detail: str = "") -> dict[str, Any]: + return { + "name": name, + "passed": bool(passed), + "value": value, + "threshold": threshold, + "detail": detail, + } + + +def audit_claim1(structural_dir: Path) -> tuple[dict[str, Any], list[dict[str, Any]]]: + path_rows = read_csv(structural_dir / "structural_path.csv") + affine_rows = read_csv(structural_dir / "affine_refits.csv") + degenerate_rows = read_csv(structural_dir / "degenerate_control.csv") + stationary = json.loads((structural_dir / "stationary_point.json").read_text(encoding="utf-8")) + + max_affine = max(number(row, "coefficient_error") for row in affine_rows) + usable = [row for row in path_rows if number(row, "D_direct") > 1e-12] + max_formula = max( + max(number(row, "xi_formula_error"), number(row, "risk_formula_error")) + for row in usable + ) + nonstationary = [row for row in usable if number(row, "normalized_slope") > 1e-9] + strict_count = sum( + number(row, "gain") > 2e-12 * max(1.0, number(row, "risk_teacher")) + for row in nonstationary + ) + sign_count = sum(integer(row, "sign_rule_holds") == 1 for row in nonstationary) + over_regularized = [ + row + for row in nonstationary + if number(row, "risk_derivative") > 0.0 + ] + over_pass_count = 0 + for row in over_regularized: + teacher = number(row, "risk_teacher") + constrained = number(row, "risk_constrained") + over_pass_count += int( + number(row, "xi_decomposition") < 0.0 + and abs(number(row, "xi_constrained")) <= 2e-10 + and abs(constrained - teacher) / max(1.0, abs(teacher), abs(constrained)) <= 2e-10 + and number(row, "gain") > 2e-12 * max(1.0, teacher) + ) + degenerate_risks = [number(row, "risk") for row in degenerate_rows] + degenerate_range = max(degenerate_risks) - min(degenerate_risks) + max_degenerate_d = max(abs(number(row, "D")) for row in degenerate_rows) + identifiable_count = sum(integer(row, "optimizer_identifiable") for row in degenerate_rows) + + gates = [ + gate( + "affine_refit_identity", + max_affine <= 2e-10, + max_affine, + "max coefficient error <= 2e-10", + f"{len(affine_rows)} direct mixed-label refits", + ), + gate( + "closed_form_identities", + max_formula <= 2e-9, + max_formula, + "max symmetric formula error <= 2e-9", + f"{len(usable)} D-positive path points", + ), + gate( + "strict_nonstationary_improvement", + bool(nonstationary) and strict_count == len(nonstationary), + {"passing": strict_count, "tested": len(nonstationary)}, + "all normalized-slope > 1e-9 points have gain > numerical tolerance", + ), + gate( + "sign_rule", + bool(nonstationary) and sign_count == len(nonstationary), + {"passing": sign_count, "tested": len(nonstationary)}, + "100% sign agreement", + ), + gate( + "stationary_touch", + float(stationary["xi_symmetric_scale"]) <= 2e-7 + and float(stationary["gain_symmetric_scale"]) <= 2e-9, + { + "lambda": stationary["lambda"], + "xi_scale": stationary["xi_symmetric_scale"], + "gain_scale": stationary["gain_symmetric_scale"], + }, + "xi scale <= 2e-7 and gain scale <= 2e-9", + ), + gate( + "negative_xi_beats_constrained_control", + bool(over_regularized) and over_pass_count == len(over_regularized), + {"passing": over_pass_count, "tested": len(over_regularized)}, + "all over-regularized points: xi*<0, clipped xi=0, only unrestricted fit gains", + ), + gate( + "D_zero_nonidentifiability_control", + degenerate_range <= 2e-12 + and max_degenerate_d <= 2e-12 + and identifiable_count == 0, + { + "risk_range": degenerate_range, + "max_abs_D": max_degenerate_d, + "identifiable_count": identifiable_count, + }, + "risk range and |D| <= 2e-12; optimizer never marked identifiable", + ), + ] + passed = all(item["passed"] for item in gates) + summary = { + "claim": 1, + "headline": "Exact pointwise improvement and unconstrained sign rule", + "passed": passed, + "verdict": "Supported, conditional" if passed else "Not reproduced", + "evidence_class": "full algebraic/numerical identity check on a conditional OOD problem", + "gates": gates, + "counts": { + "path_rows": len(path_rows), + "nonstationary_rows": len(nonstationary), + "over_regularized_rows": len(over_regularized), + "affine_refits": len(affine_rows), + "degenerate_controls": len(degenerate_rows), + }, + "scope": "Conditional seeded mechanism evidence; D>0 and nonstationarity are essential.", + } + return summary, path_rows + + +def theory_map(rows: list[dict[str, str]], include_size: bool) -> dict[tuple[str, ...], dict[str, str]]: + result: dict[tuple[str, ...], dict[str, str]] = {} + for row in rows: + components = [] + if include_size: + components.extend([str(integer(row, "n")), str(integer(row, "p"))]) + components.extend([key_float(number(row, "snr")), key_float(number(row, "lambda"))]) + result[tuple(components)] = row + return result + + +def audit_claim2( + figure4_dir: Path, + size_dir: Path, + output_dir: Path, +) -> tuple[dict[str, Any], list[dict[str, Any]]]: + raw = read_csv(figure4_dir / "figure4_raw.csv") + theory = read_csv(figure4_dir / "figure4_theory.csv") + lookup = theory_map(theory, include_size=False) + grouped: dict[tuple[str, str], list[dict[str, str]]] = defaultdict(list) + for row in raw: + grouped[(key_float(number(row, "snr")), key_float(number(row, "lambda")))].append(row) + + aggregates: list[dict[str, Any]] = [] + for key, rows in sorted(grouped.items(), key=lambda item: (float(item[0][0]), float(item[0][1]))): + theory_row = lookup[key] + d_theory = number(theory_row, "D_theory") + empirical_risks = [number(row, "risk_sd_oracle") for row in rows] + empirical_xis = [number(row, "xi_oracle") for row in rows] + risk_mean = mean(empirical_risks) + risk_theory = number(theory_row, "risk_sd_theory") + relative_error = abs(risk_mean - risk_theory) / max(1e-12, abs(risk_theory)) + risk_se = sample_standard_error(empirical_risks) + covered = int( + (math.isfinite(risk_se) and abs(risk_mean - risk_theory) <= 2.0 * risk_se) + or relative_error <= 0.03 + ) + xi_mean = mean(empirical_xis) + xi_theory = number(theory_row, "xi_theory") + xi_scaled_error = abs(xi_mean - xi_theory) / max(1.0, abs(xi_theory)) + sign_eligible = int(abs(xi_theory) >= 0.1) + sign_agrees = int(not sign_eligible or math.copysign(1.0, xi_mean) == math.copysign(1.0, xi_theory)) + aggregates.append( + { + "snr": number(theory_row, "snr"), + "lambda": number(theory_row, "lambda"), + "seed_count": len(rows), + "D_theory": d_theory, + "risk_sd_theory": risk_theory, + "risk_sd_empirical_mean": risk_mean, + "risk_sd_empirical_se": risk_se, + "risk_relative_error": relative_error, + "risk_covered_2se_or_3pct": covered, + "xi_theory": xi_theory, + "xi_empirical_mean": xi_mean, + "xi_scaled_error": xi_scaled_error, + "xi_sign_eligible": sign_eligible, + "xi_sign_agrees": sign_agrees, + "fixed_point_residual": number(theory_row, "fixed_point_residual"), + "min_D_oracle": min(number(row, "D_oracle") for row in rows), + } + ) + + usable = [row for row in aggregates if float(row["D_theory"]) > 1e-8] + risk_errors = [float(row["risk_relative_error"]) for row in usable] + median_risk_error = median(risk_errors) + p90_risk_error = quantile(risk_errors, 0.9) + coverage_rate = mean(float(row["risk_covered_2se_or_3pct"]) for row in usable) + xi_eligible = [row for row in usable if int(row["xi_sign_eligible"]) == 1] + sign_rate = mean(float(row["xi_sign_agrees"]) for row in xi_eligible) + median_xi_scaled_error = median(float(row["xi_scaled_error"]) for row in usable) + max_fp_residual = max(float(row["fixed_point_residual"]) for row in aggregates) + min_d = min( + min(float(row["D_theory"]), float(row["min_D_oracle"])) + for row in usable + ) + + size_raw = read_csv(size_dir / "size_ladder_raw.csv") + size_theory = read_csv(size_dir / "size_ladder_theory.csv") + size_lookup = theory_map(size_theory, include_size=True) + size_groups: dict[tuple[str, str, str, str], list[dict[str, str]]] = defaultdict(list) + for row in size_raw: + key = ( + str(integer(row, "n")), + str(integer(row, "p")), + key_float(number(row, "snr")), + key_float(number(row, "lambda")), + ) + size_groups[key].append(row) + size_cell_rows: list[dict[str, Any]] = [] + for key, rows in size_groups.items(): + theory_row = size_lookup[key] + empirical_mean = mean(number(row, "risk_sd_oracle") for row in rows) + theoretical = number(theory_row, "risk_sd_theory") + size_cell_rows.append( + { + "n": int(key[0]), + "p": int(key[1]), + "lambda": number(theory_row, "lambda"), + "seed_count": len(rows), + "risk_sd_empirical_mean": empirical_mean, + "risk_sd_theory": theoretical, + "risk_relative_error": abs(empirical_mean - theoretical) + / max(1e-12, abs(theoretical)), + } + ) + errors_by_size: dict[int, list[float]] = defaultdict(list) + for row in size_cell_rows: + errors_by_size[int(row["n"])].append(float(row["risk_relative_error"])) + size_error_rows = [ + { + "n": size, + "cell_count": len(values), + "mean_risk_relative_error": mean(values), + "median_risk_relative_error": median(values), + } + for size, values in sorted(errors_by_size.items()) + ] + smallest = min(errors_by_size) + largest = max(errors_by_size) + smallest_error = mean(errors_by_size[smallest]) + largest_error = mean(errors_by_size[largest]) + + gates = [ + gate( + "median_risk_error", + median_risk_error <= 0.05, + median_risk_error, + "<= 5%", + ), + gate( + "p90_risk_error", + p90_risk_error <= 0.12, + p90_risk_error, + "<= 12%", + ), + gate( + "risk_coverage", + coverage_rate >= 0.80, + coverage_rate, + ">= 80% within 2 SE or 3%", + ), + gate( + "xi_sign_agreement", + bool(xi_eligible) and sign_rate >= 0.95, + {"rate": sign_rate, "eligible_cells": len(xi_eligible)}, + ">= 95% where |xi_theory| >= 0.1", + ), + gate( + "median_xi_scaled_error", + median_xi_scaled_error <= 0.15, + median_xi_scaled_error, + "<= 15%", + ), + gate( + "size_convergence", + largest_error < smallest_error, + { + "smallest_n": smallest, + "smallest_mean_error": smallest_error, + "largest_n": largest, + "largest_mean_error": largest_error, + }, + "largest-size aggregate risk error < smallest-size error", + ), + gate( + "fixed_point_and_positive_D", + max_fp_residual < 1e-10 and min_d > 0.0, + {"max_fixed_point_residual": max_fp_residual, "minimum_usable_D": min_d}, + "fixed-point residual < 1e-10 and all usable D positive", + ), + ] + passed = all(item["passed"] for item in gates) + summary = { + "claim": 2, + "headline": "Deterministic equivalents align with finite-sample Figure 4 behavior", + "passed": passed, + "verdict": "Supported" if passed else "Partially supported", + "evidence_class": "paper-native stochastic reproduction plus proportional size check", + "gates": gates, + "counts": { + "raw_seed_rows": len(raw), + "theory_cells": len(aggregates), + "usable_theory_cells": len(usable), + "size_raw_rows": len(size_raw), + "size_cells": len(size_cell_rows), + }, + "scope": "Gaussian AR(1), fixed top-aligned signal, analytic in-distribution risk.", + } + write_csv(output_dir / "claim2_figure4_aggregates.csv", aggregates) + write_csv(output_dir / "claim2_size_cells.csv", size_cell_rows) + write_csv(output_dir / "claim2_size_summary.csv", size_error_rows) + return summary, aggregates + + +def audit_claim3(size_dir: Path, output_dir: Path) -> tuple[dict[str, Any], list[dict[str, Any]]]: + raw = read_csv(size_dir / "size_ladder_raw.csv") + selected_over_lambda = max(number(row, "lambda") for row in raw) + usable: list[dict[str, Any]] = [] + excluded = 0 + for row in raw: + d_oracle = number(row, "D_oracle") + d_hat = number(row, "D_hat") + if d_oracle <= 1e-10 or d_hat <= 1e-10: + excluded += 1 + continue + xi_oracle = number(row, "xi_oracle") + xi_hat = number(row, "xi_hat") + xi_wrong = number(row, "xi_wrong_df") + risk_oracle = number(row, "risk_sd_oracle") + risk_hat = number(row, "risk_sd_hat") + actual = number(row, "risk_sd_xihat_actual") + wrong_actual = number(row, "risk_wrong_df_actual") + usable.append( + { + "n": integer(row, "n"), + "p": integer(row, "p"), + "seed": integer(row, "seed"), + "lambda": number(row, "lambda"), + "xi_oracle": xi_oracle, + "xi_hat": xi_hat, + "xi_wrong_df": xi_wrong, + "xi_scaled_error": abs(xi_hat - xi_oracle) / max(1.0, abs(xi_oracle)), + "xi_wrong_scaled_error": abs(xi_wrong - xi_oracle) / max(1.0, abs(xi_oracle)), + "risk_estimate_scaled_error": abs(risk_hat - risk_oracle) + / max(1.0, risk_oracle), + "actual_regret_scaled": max(0.0, actual - risk_oracle) / max(1.0, risk_oracle), + "wrong_actual_regret_scaled": max(0.0, wrong_actual - risk_oracle) + / max(1.0, risk_oracle), + "sign_eligible": int(abs(xi_oracle) >= 0.1), + "sign_agrees": int( + abs(xi_oracle) < 0.1 + or math.copysign(1.0, xi_hat) == math.copysign(1.0, xi_oracle) + ), + "negative_oracle": int(xi_oracle < -0.1), + "negative_sign_agrees": int(xi_oracle >= -0.1 or xi_hat < 0.0), + "selected_over_negative": int( + abs(number(row, "lambda") - selected_over_lambda) <= 1e-12 + and xi_oracle < -0.1 + ), + "selected_over_sign_agrees": int( + abs(number(row, "lambda") - selected_over_lambda) > 1e-12 + or xi_oracle >= -0.1 + or xi_hat < 0.0 + ), + "D_hat": d_hat, + "D_hat_identity_error": number(row, "D_hat_identity_error"), + } + ) + + grouped: dict[int, list[dict[str, Any]]] = defaultdict(list) + for row in usable: + grouped[int(row["n"])].append(row) + size_summaries: list[dict[str, Any]] = [] + for n, rows in sorted(grouped.items()): + eligible = [row for row in rows if row["sign_eligible"]] + negatives = [row for row in rows if row["negative_oracle"]] + selected_over_negatives = [row for row in rows if row["selected_over_negative"]] + size_summaries.append( + { + "n": n, + "p": int(rows[0]["p"]), + "usable_rows": len(rows), + "mean_xi_scaled_error": mean(row["xi_scaled_error"] for row in rows), + "median_xi_scaled_error": median(row["xi_scaled_error"] for row in rows), + "mean_risk_estimate_scaled_error": mean( + row["risk_estimate_scaled_error"] for row in rows + ), + "median_risk_estimate_scaled_error": median( + row["risk_estimate_scaled_error"] for row in rows + ), + "mean_actual_regret_scaled": mean(row["actual_regret_scaled"] for row in rows), + "median_actual_regret_scaled": median(row["actual_regret_scaled"] for row in rows), + "sign_eligible_rows": len(eligible), + "sign_agreement": mean(row["sign_agrees"] for row in eligible), + "negative_oracle_rows": len(negatives), + "negative_sign_agreement": mean(row["negative_sign_agrees"] for row in negatives), + "selected_over_lambda": selected_over_lambda, + "selected_over_negative_rows": len(selected_over_negatives), + "selected_over_sign_agreement": mean( + row["selected_over_sign_agrees"] for row in selected_over_negatives + ), + "mean_wrong_xi_scaled_error": mean( + row["xi_wrong_scaled_error"] for row in rows + ), + "mean_wrong_actual_regret_scaled": mean( + row["wrong_actual_regret_scaled"] for row in rows + ), + "max_D_hat_identity_error": max(row["D_hat_identity_error"] for row in rows), + "min_D_hat": min(row["D_hat"] for row in rows), + } + ) + + smallest_n = min(grouped) + largest_n = max(grouped) + smallest = next(row for row in size_summaries if int(row["n"]) == smallest_n) + largest = next(row for row in size_summaries if int(row["n"]) == largest_n) + all_max_identity = max(row["D_hat_identity_error"] for row in usable) + all_min_d_hat = min(row["D_hat"] for row in usable) + + gates = [ + gate( + "pointwise_error_decreases", + float(largest["mean_xi_scaled_error"]) < float(smallest["mean_xi_scaled_error"]) + and float(largest["mean_risk_estimate_scaled_error"]) + < float(smallest["mean_risk_estimate_scaled_error"]), + { + "smallest_n": smallest_n, + "smallest_mean_xi_error": smallest["mean_xi_scaled_error"], + "largest_n": largest_n, + "largest_mean_xi_error": largest["mean_xi_scaled_error"], + "smallest_mean_risk_error": smallest["mean_risk_estimate_scaled_error"], + "largest_mean_risk_error": largest["mean_risk_estimate_scaled_error"], + }, + "largest-size mean xi and risk errors < smallest-size errors", + ), + gate( + "largest_size_accuracy", + float(largest["median_xi_scaled_error"]) <= 0.15 + and float(largest["median_risk_estimate_scaled_error"]) <= 0.05 + and float(largest["median_actual_regret_scaled"]) <= 0.02, + { + "median_xi_error": largest["median_xi_scaled_error"], + "median_risk_error": largest["median_risk_estimate_scaled_error"], + "median_actual_regret": largest["median_actual_regret_scaled"], + }, + "largest size: xi <=15%, risk estimate <=5%, actual regret <=2%", + ), + gate( + "largest_size_signs_including_negative", + int(largest["sign_eligible_rows"]) > 0 + and int(largest["selected_over_negative_rows"]) > 0 + and float(largest["sign_agreement"]) >= 0.90 + and float(largest["selected_over_sign_agreement"]) >= 0.90, + { + "eligible": largest["sign_eligible_rows"], + "agreement": safe_json_float(float(largest["sign_agreement"])), + "selected_over_lambda": largest["selected_over_lambda"], + "selected_over_negative_eligible": largest["selected_over_negative_rows"], + "selected_over_negative_agreement": safe_json_float( + float(largest["selected_over_sign_agreement"]) + ), + "all_negative_diagnostic_agreement": safe_json_float( + float(largest["negative_sign_agreement"]) + ), + }, + ">=90% overall and in the selected over-regularized condition", + ), + gate( + "D_hat_identity_and_nonnegativity", + all_max_identity <= 2e-10 and all_min_d_hat >= -2e-12, + {"max_identity_error": all_max_identity, "minimum_D_hat": all_min_d_hat}, + "identity error <=2e-10 and D_hat >=-2e-12", + ), + gate( + "correct_PD_df_beats_wrong_control", + float(largest["mean_xi_scaled_error"]) + 1e-5 + < float(largest["mean_wrong_xi_scaled_error"]) + and float(largest["mean_actual_regret_scaled"]) + <= float(largest["mean_wrong_actual_regret_scaled"]), + { + "correct_mean_xi_error": largest["mean_xi_scaled_error"], + "wrong_mean_xi_error": largest["mean_wrong_xi_scaled_error"], + "correct_mean_regret": largest["mean_actual_regret_scaled"], + "wrong_mean_regret": largest["mean_wrong_actual_regret_scaled"], + }, + "correct xi error at least 1e-5 lower and actual regret no larger", + ), + ] + passed = all(item["passed"] for item in gates) + summary = { + "claim": 3, + "headline": "One-shot GCV tuning is pointwise consistent", + "passed": passed, + "verdict": "Supported, conditional" if passed else "Partially supported", + "evidence_class": "fixed-penalty proportional size ladder", + "gates": gates, + "counts": { + "raw_rows": len(raw), + "usable_rows": len(usable), + "excluded_D_small": excluded, + "sizes": sorted(grouped), + }, + "scope": "Pointwise fixed penalties only; no uniform lambda-selection claim.", + } + write_csv(output_dir / "claim3_size_summary.csv", size_summaries) + write_csv(output_dir / "claim3_row_errors.csv", usable) + return summary, size_summaries + + +def build_markdown(claims: list[dict[str, Any]]) -> str: + lines = [ + "# Reproduction audit summary", + "", + "This file is generated from seed-level raw CSVs by `scripts/audit_results.py`.", + "", + "| Claim | Verdict | Evidence class |", + "|---|---|---|", + ] + for claim in claims: + lines.append( + f"| {claim['claim']} — {claim['headline']} | **{claim['verdict']}** | {claim['evidence_class']} |" + ) + for claim in claims: + lines.extend(["", f"## Claim {claim['claim']}", ""]) + for item in claim["gates"]: + mark = "PASS" if item["passed"] else "FAIL" + lines.append( + f"- **{mark} — {item['name']}**: `{json.dumps(item['value'], sort_keys=True)}`; {item['threshold']}." + ) + lines.extend(["", f"Scope: {claim['scope']}"]) + return "\n".join(lines) + "\n" + + +def parse_args() -> argparse.Namespace: + parser = argparse.ArgumentParser(description=__doc__) + parser.add_argument("--structural-dir", type=Path, required=True) + parser.add_argument("--figure4-dir", type=Path, required=True) + parser.add_argument("--size-dir", type=Path, required=True) + parser.add_argument("--output-dir", type=Path, required=True) + parser.add_argument( + "--profile", + choices=["smoke", "frozen"], + default="frozen", + help="smoke computes all gates but exits zero if files/invariants parse; frozen exits nonzero on failed claims", + ) + return parser.parse_args() + + +def main() -> int: + args = parse_args() + args.output_dir.mkdir(parents=True, exist_ok=True) + claim1, _ = audit_claim1(args.structural_dir) + claim2, _ = audit_claim2(args.figure4_dir, args.size_dir, args.output_dir) + claim3, _ = audit_claim3(args.size_dir, args.output_dir) + claims = [claim1, claim2, claim3] + payload = { + "paper": "MdHcU4C4Rm", + "submission": 22249, + "profile": args.profile, + "all_claims_passed": all(claim["passed"] for claim in claims), + "claims": claims, + } + write_json(args.output_dir / "verdicts.json", payload) + (args.output_dir / "audit_summary.md").write_text(build_markdown(claims), encoding="utf-8") + print(json.dumps(payload, indent=2, sort_keys=True), flush=True) + if args.profile == "frozen" and not payload["all_claims_passed"]: + return 2 + return 0 + + +if __name__ == "__main__": + raise SystemExit(main()) + +```` + + +````output +{ + "all_claims_passed": true, + "claims": [ + { + "claim": 1, + "counts": { + "affine_refits": 54, + "degenerate_controls": 6, + "nonstationary_rows": 81, + "over_regularized_rows": 45, + "path_rows": 81 + }, + "evidence_class": "full algebraic/numerical identity check on a conditional OOD problem", + "gates": [ + { + "detail": "54 direct mixed-label refits", + "name": "affine_refit_identity", + "passed": true, + "threshold": "max coefficient error <= 2e-10", + "value": 3.7419067816696145e-15 + }, + { + "detail": "81 D-positive path points", + "name": "closed_form_identities", + "passed": true, + "threshold": "max symmetric formula error <= 2e-9", + "value": 2.8050026209167883e-12 + }, + { + "detail": "", + "name": "strict_nonstationary_improvement", + "passed": true, + "threshold": "all normalized-slope > 1e-9 points have gain > numerical tolerance", + "value": { + "passing": 81, + "tested": 81 + } + }, + { + "detail": "", + "name": "sign_rule", + "passed": true, + "threshold": "100% sign agreement", + "value": { + "passing": 81, + "tested": 81 + } + }, + { + "detail": "", + "name": "stationary_touch", + "passed": true, + "threshold": "xi scale <= 2e-7 and gain scale <= 2e-9", + "value": { + "gain_scale": 0.0, + "lambda": 0.1313917499364803, + "xi_scale": 1.5381260057560733e-13 + } + }, + { + "detail": "", + "name": "negative_xi_beats_constrained_control", + "passed": true, + "threshold": "all over-regularized points: xi*<0, clipped xi=0, only unrestricted fit gains", + "value": { + "passing": 45, + "tested": 45 + } + }, + { + "detail": "", + "name": "D_zero_nonidentifiability_control", + "passed": true, + "threshold": "risk range and |D| <= 2e-12; optimizer never marked identifiable", + "value": { + "identifiable_count": 0, + "max_abs_D": 0.0, + "risk_range": 0.0 + } + } + ], + "headline": "Exact pointwise improvement and unconstrained sign rule", + "passed": true, + "scope": "Conditional seeded mechanism evidence; D>0 and nonstationarity are essential.", + "verdict": "Supported, conditional" + }, + { + "claim": 2, + "counts": { + "raw_seed_rows": 4650, + "size_cells": 9, + "size_raw_rows": 2700, + "theory_cells": 155, + "usable_theory_cells": 155 + }, + "evidence_class": "paper-native stochastic reproduction plus proportional size check", + "gates": [ + { + "detail": "", + "name": "median_risk_error", + "passed": true, + "threshold": "<= 5%", + "value": 0.001874180541028838 + }, + { + "detail": "", + "name": "p90_risk_error", + "passed": true, + "threshold": "<= 12%", + "value": 0.0030679950738076557 + }, + { + "detail": "", + "name": "risk_coverage", + "passed": true, + "threshold": ">= 80% within 2 SE or 3%", + "value": 1.0 + }, + { + "detail": "", + "name": "xi_sign_agreement", + "passed": true, + "threshold": ">= 95% where |xi_theory| >= 0.1", + "value": { + "eligible_cells": 153, + "rate": 1.0 + } + }, + { + "detail": "", + "name": "median_xi_scaled_error", + "passed": true, + "threshold": "<= 15%", + "value": 0.007012704615330323 + }, + { + "detail": "", + "name": "size_convergence", + "passed": true, + "threshold": "largest-size aggregate risk error < smallest-size error", + "value": { + "largest_mean_error": 0.0003859330022746915, + "largest_n": 1600, + "smallest_mean_error": 0.004397057507367464, + "smallest_n": 100 + } + }, + { + "detail": "", + "name": "fixed_point_and_positive_D", + "passed": true, + "threshold": "fixed-point residual < 1e-10 and all usable D positive", + "value": { + "max_fixed_point_residual": 1.0373923942097463e-12, + "minimum_usable_D": 0.00031817006896670886 + } + } + ], + "headline": "Deterministic equivalents align with finite-sample Figure 4 behavior", + "passed": true, + "scope": "Gaussian AR(1), fixed top-aligned signal, analytic in-distribution risk.", + "verdict": "Supported" + }, + { + "claim": 3, + "counts": { + "excluded_D_small": 0, + "raw_rows": 2700, + "sizes": [ + 100, + 800, + 1600 + ], + "usable_rows": 2700 + }, + "evidence_class": "fixed-penalty proportional size ladder", + "gates": [ + { + "detail": "", + "name": "pointwise_error_decreases", + "passed": true, + "threshold": "largest-size mean xi and risk errors < smallest-size errors", + "value": { + "largest_mean_risk_error": 0.034572977786416555, + "largest_mean_xi_error": 0.09510709330233892, + "largest_n": 1600, + "smallest_mean_risk_error": 0.13724008913476787, + "smallest_mean_xi_error": 0.3115541422413274, + "smallest_n": 100 + } + }, + { + "detail": "", + "name": "largest_size_accuracy", + "passed": true, + "threshold": "largest size: xi <=15%, risk estimate <=5%, actual regret <=2%", + "value": { + "median_actual_regret": 0.0012918376448209715, + "median_risk_error": 0.029603787516040852, + "median_xi_error": 0.07979459785841933 + } + }, + { + "detail": "", + "name": "largest_size_signs_including_negative", + "passed": true, + "threshold": ">=90% overall and in the selected over-regularized condition", + "value": { + "agreement": 0.9561042524005487, + "all_negative_diagnostic_agreement": 0.9254079254079254, + "eligible": 729, + "selected_over_lambda": 5.0, + "selected_over_negative_agreement": 1.0, + "selected_over_negative_eligible": 300 + } + }, + { + "detail": "", + "name": "D_hat_identity_and_nonnegativity", + "passed": true, + "threshold": "identity error <=2e-10 and D_hat >=-2e-12", + "value": { + "max_identity_error": 1.9845236565174673e-15, + "minimum_D_hat": 0.01431275351699921 + } + }, + { + "detail": "", + "name": "correct_PD_df_beats_wrong_control", + "passed": true, + "threshold": "correct xi error at least 1e-5 lower and actual regret no larger", + "value": { + "correct_mean_regret": 0.002458608900848219, + "correct_mean_xi_error": 0.09510709330233892, + "wrong_mean_regret": 0.20141494718631495, + "wrong_mean_xi_error": 0.9957149697977374 + } + } + ], + "headline": "One-shot GCV tuning is pointwise consistent", + "passed": true, + "scope": "Pointwise fixed penalties only; no uniform lambda-selection claim.", + "verdict": "Supported, conditional" + } + ], + "paper": "MdHcU4C4Rm", + "profile": "frozen", + "submission": 22249 +} + +```` + + +--- + +**📦 Artifact** `outputs/final_audit/claim3_row_errors.csv` · dataset · 0.6 MB + +trackio-local-path://outputs/final_audit/claim3_row_errors.csv + + +--- + +**📦 Artifact** `outputs/final_audit/claim2_figure4_aggregates.csv` · dataset · 36.7 kB + +trackio-local-path://outputs/final_audit/claim2_figure4_aggregates.csv + + +--- + +**📦 Artifact** `outputs/final_audit/claim3_size_summary.csv` · dataset · 1.3 kB + +trackio-local-path://outputs/final_audit/claim3_size_summary.csv + + +--- + +**📦 Artifact** `outputs/final_audit/claim2_size_cells.csv` · dataset · 771 B + +trackio-local-path://outputs/final_audit/claim2_size_cells.csv + + +--- + +**📦 Artifact** `outputs/final_audit/claim2_size_summary.csv` · dataset · 218 B + +trackio-local-path://outputs/final_audit/claim2_size_summary.csv + + +--- + +````bash +$ python scripts/build_release_disposition.py +```` + +exit 0 · 5.4s + + +````python title=build_release_disposition.py +#!/usr/bin/env python3 +"""Build the post-review release verdict without mutating frozen audit outputs. + +The original frozen auditor and post-v1 adjudication are retained verbatim. +This builder layers the two independent reviewers' statistical disposition on +top, reruns the reviewer diagnostic from immutable raw rows, and writes the +machine-readable verdict that public prose must follow. +""" + +from __future__ import annotations + +import hashlib +import json +import subprocess +import sys +from pathlib import Path + + +ROOT = Path(__file__).resolve().parents[1] +OUT = ROOT / "outputs" / "reviewed_final_audit" + + +def read_json(path: Path) -> dict: + return json.loads(path.read_text(encoding="utf-8")) + + +def write_json(path: Path, payload: dict) -> None: + path.write_text( + json.dumps(payload, indent=2, sort_keys=True, allow_nan=False) + "\n", + encoding="utf-8", + ) + + +def sha256(path: Path) -> str: + digest = hashlib.sha256() + with path.open("rb") as handle: + for chunk in iter(lambda: handle.read(1024 * 1024), b""): + digest.update(chunk) + return digest.hexdigest() + + +def main() -> int: + frozen_path = ROOT / "outputs" / "final_audit" / "verdicts.json" + adjudication_path = ( + ROOT + / "outputs" + / "jobs" + / "size-adjudication-v1" + / "adjudication_audit" + / "adjudication_verdict.json" + ) + reviewer_script = ROOT / "reviews" / "reviewer2_endpoint_check.py" + theory_review = ROOT / "reviews" / "CROSS_REVIEW_THEORY_AGENT.md" + code_review = ROOT / "reviews" / "CROSS_REVIEW_CODE_AGENT.md" + + frozen = read_json(frozen_path) + adjudication = read_json(adjudication_path) + completed = subprocess.run( + [sys.executable, str(reviewer_script)], + cwd=ROOT, + check=True, + capture_output=True, + text=True, + ) + diagnostic = json.loads(completed.stdout) + OUT.mkdir(parents=True, exist_ok=True) + write_json(OUT / "reviewer2_endpoint_diagnostics.json", diagnostic) + + claims = {int(item["claim"]): item for item in frozen["claims"]} + claim2 = claims[2] + diag = diagnostic["adjudication"] + signed_intervals = diagnostic["signed_cell_bias_intervals"] + all_signed_intervals_include_zero = all( + float(row["ci95"][0]) <= 0.0 <= float(row["ci95"][1]) + for row in signed_intervals + ) + + release = { + "schema_version": 1, + "paper": "MdHcU4C4Rm", + "submission": 22249, + "release_all_claims_supported": False, + "review_consensus": { + "status": "Needs revision resolved by conservative downgrade", + "reviewers": [ + "independent theory/reproduction reviewer", + "independent code/data reviewer", + ], + "agreed_disposition": ( + "Claim 2 is Partially supported: the Figure 4-scale numerical " + "comparison is supported, while the all-required size-convergence " + "mean-bias endpoint is Inconclusive." + ), + }, + "claims": [ + { + "claim": 1, + "verdict": claims[1]["verdict"], + "scope": claims[1]["scope"], + "frozen_gates_passed": True, + }, + { + "claim": 2, + "verdict": "Partially supported", + "frozen_all_required_gates_passed": False, + "components": { + "figure4_scale": { + "verdict": "Supported", + "interpretation": ( + "Numerically supports the finite-size implication in the " + "tested Figure 4 Gaussian AR(1) design; it does not prove " + "Theorem 3.1." + ), + "median_risk_error": claim2["gates"][0]["value"], + "p90_risk_error": claim2["gates"][1]["value"], + "coverage": claim2["gates"][2]["value"], + "eligible_xi_sign_agreement": claim2["gates"][3]["value"], + }, + "size_convergence_mean_bias": { + "verdict": "Inconclusive", + "observed_point_difference_100_minus_1600": diag[ + "observed_delta_100_minus_1600" + ], + "frozen_percentile_ci95": diag["frozen_percentile_ci95"], + "ordinary_basic_ci95_diagnostic": diag[ + "ordinary_basic_ci95" + ], + "all_nine_signed_cell_bias_intervals_include_zero": ( + all_signed_intervals_include_zero + ), + "null_centered_probability_ge_observed": diag[ + "null_centered_probability_ge_observed" + ], + "reason": ( + "The ordinary percentile bootstrap targets an absolute " + "mean-bias functional that is nonregular at zero; method " + "sensitivity and the heteroskedastic null-centered diagnostic " + "prevent a defensible ordering conclusion." + ), + }, + "seedwise_concentration": { + "verdict": "Supported as a diagnostic only", + "welch_ci95": [ + adjudication[ + "welch_seedwise_absolute_deviation_difference" + ]["ci95_lower"], + adjudication[ + "welch_seedwise_absolute_deviation_difference" + ]["ci95_upper"], + ], + "limitation": ( + "This estimates mean seedwise absolute deviation, not the " + "absolute error of a seed mean, so it cannot adjudicate the " + "frozen mean-bias endpoint." + ), + }, + }, + "scope": ( + "Gaussian AR(1), analytic in-distribution risk, alignment factor " + "0.9 with each realized top-subspace energy fraction recorded." + ), + }, + { + "claim": 3, + "verdict": claims[3]["verdict"], + "scope": claims[3]["scope"], + "frozen_gates_passed": True, + }, + ], + "signal_protocol": { + "alignment_factor": 0.9, + "figure4_realized_top_energy_fraction": 0.9123065949514034, + "size_realized_top_energy_fraction": { + "100": 0.9588430317140124, + "800": 0.9060299626552942, + "1600": 0.8777649727519765, + }, + "wording": ( + "alignment factor 0.9; realized top-subspace energy fraction recorded" + ), + }, + "immutability": { + "frozen_auditor_verdict_retained": claims[2]["verdict"], + "original_adjudication_verdict_retained": adjudication["disposition"], + "central_review_overrides_public_claim2_verdict": True, + }, + "source_hashes": { + str(frozen_path.relative_to(ROOT)): sha256(frozen_path), + str(adjudication_path.relative_to(ROOT)): sha256(adjudication_path), + str(reviewer_script.relative_to(ROOT)): sha256(reviewer_script), + str(theory_review.relative_to(ROOT)): sha256(theory_review), + str(code_review.relative_to(ROOT)): sha256(code_review), + }, + } + write_json(OUT / "release_verdicts.json", release) + + summary = """# Post-review release disposition + +## Outcome + +- Claim 1: **Supported, conditional**. +- Claim 2: **Partially supported**. The Figure 4-scale numerical comparison is + supported, but the all-required size-convergence mean-bias endpoint is + **Inconclusive**. +- Claim 3: **Supported, conditional** for the tested fixed penalties and + Gaussian design. + +## Why Claim 2 changed + +The frozen percentile bootstrap is exactly reproducible, but it is applied to +an absolute mean-bias functional at a near-zero kink. All nine signed cell-bias +intervals include zero; the basic interval crosses zero; and a null-centered +heteroskedastic diagnostic produces an observed-or-larger contrast with +probability 0.168. The Welch interval is retained only as evidence that +seedwise deviations concentrate with size because it estimates a different +quantity. + +The original frozen-auditor and adjudication outputs remain unchanged. Public +prose and figures must use `release_verdicts.json` as the central disposition. +""" + (OUT / "release_summary.md").write_text(summary, encoding="utf-8") + print(json.dumps(release, indent=2, sort_keys=True, allow_nan=False)) + return 0 + + +if __name__ == "__main__": + raise SystemExit(main()) + +```` + + +````output +{ + "claims": [ + { + "claim": 1, + "frozen_gates_passed": true, + "scope": "Conditional seeded mechanism evidence; D>0 and nonstationarity are essential.", + "verdict": "Supported, conditional" + }, + { + "claim": 2, + "components": { + "figure4_scale": { + "coverage": 1.0, + "eligible_xi_sign_agreement": { + "eligible_cells": 153, + "rate": 1.0 + }, + "interpretation": "Numerically supports the finite-size implication in the tested Figure 4 Gaussian AR(1) design; it does not prove Theorem 3.1.", + "median_risk_error": 0.001874180541028838, + "p90_risk_error": 0.0030679950738076557, + "verdict": "Supported" + }, + "seedwise_concentration": { + "limitation": "This estimates mean seedwise absolute deviation, not the absolute error of a seed mean, so it cannot adjudicate the frozen mean-bias endpoint.", + "verdict": "Supported as a diagnostic only", + "welch_ci95": [ + 0.03256766049929297, + 0.040508267790846035 + ] + }, + "size_convergence_mean_bias": { + "all_nine_signed_cell_bias_intervals_include_zero": true, + "frozen_percentile_ci95": [ + 0.00021468028022391842, + 0.010172406929093696 + ], + "null_centered_probability_ge_observed": 0.16802, + "observed_point_difference_100_minus_1600": 0.0040111245050931535, + "ordinary_basic_ci95_diagnostic": [ + -0.002150157918907389, + 0.007807568729962388 + ], + "reason": "The ordinary percentile bootstrap targets an absolute mean-bias functional that is nonregular at zero; method sensitivity and the heteroskedastic null-centered diagnostic prevent a defensible ordering conclusion.", + "verdict": "Inconclusive" + } + }, + "frozen_all_required_gates_passed": false, + "scope": "Gaussian AR(1), analytic in-distribution risk, alignment factor 0.9 with each realized top-subspace energy fraction recorded.", + "verdict": "Partially supported" + }, + { + "claim": 3, + "frozen_gates_passed": true, + "scope": "Pointwise fixed penalties only; no uniform lambda-selection claim.", + "verdict": "Supported, conditional" + } + ], + "immutability": { + "central_review_overrides_public_claim2_verdict": true, + "frozen_auditor_verdict_retained": "Supported", + "original_adjudication_verdict_retained": "Supported" + }, + "paper": "MdHcU4C4Rm", + "release_all_claims_supported": false, + "review_consensus": { + "agreed_disposition": "Claim 2 is Partially supported: the Figure 4-scale numerical comparison is supported, while the all-required size-convergence mean-bias endpoint is Inconclusive.", + "reviewers": [ + "independent theory/reproduction reviewer", + "independent code/data reviewer" + ], + "status": "Needs revision resolved by conservative downgrade" + }, + "schema_version": 1, + "signal_protocol": { + "alignment_factor": 0.9, + "figure4_realized_top_energy_fraction": 0.9123065949514034, + "size_realized_top_energy_fraction": { + "100": 0.9588430317140124, + "1600": 0.8777649727519765, + "800": 0.9060299626552942 + }, + "wording": "alignment factor 0.9; realized top-subspace energy fraction recorded" + }, + "source_hashes": { + "outputs/final_audit/verdicts.json": "750572fcb30d714ebed2142c09c623d10a9dc90ea3c87fd92f70c83d8f3a10fb", + "outputs/jobs/size-adjudication-v1/adjudication_audit/adjudication_verdict.json": "3f89c9316ea7e0e2470bb839a31ec4ba032fadf7df1dc8d992c02f2271b9b69b", + "reviews/CROSS_REVIEW_CODE_AGENT.md": "f85187b44511e432ef575349623986da42bf6cd62cd447211478fe6ae0ce7a6c", + "reviews/CROSS_REVIEW_THEORY_AGENT.md": "855fd4ab641243c688f3e143d6f948b88eb1750c0c9fdff1f3f3362a5f7e239c", + "reviews/reviewer2_endpoint_check.py": "b751615dac68d558c195c77368ce5f331ac457d82666a31c8bc8e231c44c41d8" + }, + "submission": 22249 +} + +```` + + +--- + +This independent reproduction supports the exact finite-sample self-distillation geometry and sign rule, conditional on D>0 and nonstationarity. It strongly supports the Figure 4-scale deterministic-equivalent comparison, but independent review leaves the required size-convergence mean-bias endpoint Inconclusive, so Claim 2 is Partially supported. One-shot GCV is supported conditionally at three fixed penalties; the tr(H²) degrees-of-freedom correction decisively beats the wrong-tr(H) control. The frozen failed and positive audits, both independent reviews, raw rows, exact Job records, and the post-review machine verdict are retained together. + +| Scope & cost | Evidence | Compute / cost | +|---|---|---| +| Exact geometry | 81 penalty points, direct refits, stationary and D=0 controls | included in main L4 Job | +| Figure 4 scale | n=400, p=200, 30 seeds, 5 SNRs, 31 penalties | NVIDIA L4 Job 6a5906e; 23.24 s entry time | +| Size / one-shot ladder | n=100,800,1600; 300 fresh seeds; 3 penalties | NVIDIA L4 Job 6a590a; 74.57 s entry time | +| Total | 7,350 retained stochastic rows plus structural controls | 97.81 s measured; conservative cost under $0.05 | + + +--- + +````html +