Add CTT paper artifact audit tests
Browse files
workspace/tests/test_ctt_paper_artifact_audit.py
ADDED
|
@@ -0,0 +1,59 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
from __future__ import annotations
|
| 2 |
+
|
| 3 |
+
import json
|
| 4 |
+
from pathlib import Path
|
| 5 |
+
|
| 6 |
+
from scripts import audit_ctt_paper_artifacts
|
| 7 |
+
|
| 8 |
+
|
| 9 |
+
def test_forbidden_scan_flags_q_phi_but_not_outcome_q_i() -> None:
|
| 10 |
+
clean = "The outcome vector is y_i=[s_i,p_i,c_i,v_i,q_i,e_i,r_i]."
|
| 11 |
+
dirty = "The main learned generator is q_phi(delta a | o,l)."
|
| 12 |
+
|
| 13 |
+
assert audit_ctt_paper_artifacts._forbidden_findings(clean) == []
|
| 14 |
+
findings = audit_ctt_paper_artifacts._forbidden_findings(dirty)
|
| 15 |
+
assert findings
|
| 16 |
+
assert findings[0]["name"] == "generic_q_phi_generator"
|
| 17 |
+
|
| 18 |
+
|
| 19 |
+
def test_minimal_paper_audit_exports_json_and_tex(tmp_path: Path) -> None:
|
| 20 |
+
repo = tmp_path
|
| 21 |
+
paper_dir = repo / "latex"
|
| 22 |
+
run_dir = repo / "runs" / "ctt_example"
|
| 23 |
+
paper_dir.mkdir(parents=True)
|
| 24 |
+
run_dir.mkdir(parents=True)
|
| 25 |
+
(run_dir / "table.tex").write_text("% table\n")
|
| 26 |
+
(run_dir / "metrics.json").write_text("{}\n")
|
| 27 |
+
(run_dir / "command.txt").write_text("python run.py\n")
|
| 28 |
+
(run_dir / "git_hash.txt").write_text("abc\n")
|
| 29 |
+
(run_dir / "data_hash.txt").write_text("data\n")
|
| 30 |
+
(run_dir / "split_hash.txt").write_text("split\n")
|
| 31 |
+
paper = paper_dir / "main.tex"
|
| 32 |
+
paper.write_text(
|
| 33 |
+
r"""
|
| 34 |
+
\title{Causal Tangent Transport}
|
| 35 |
+
Causal Tangent Transport uses $T_{\phi}(z_s,z_t,\xi_s^+)$.
|
| 36 |
+
OutcomePTR and PPTC are separate. SupportGap and SelectorGap are reported.
|
| 37 |
+
\input{../runs/ctt_example/table}
|
| 38 |
+
"""
|
| 39 |
+
)
|
| 40 |
+
|
| 41 |
+
assert (
|
| 42 |
+
audit_ctt_paper_artifacts.main(
|
| 43 |
+
[
|
| 44 |
+
"--repo-root",
|
| 45 |
+
str(repo),
|
| 46 |
+
"--paper",
|
| 47 |
+
"latex/main.tex",
|
| 48 |
+
"--out-dir",
|
| 49 |
+
"runs/paper_ctt_audit",
|
| 50 |
+
"--skip-implementation-checks",
|
| 51 |
+
]
|
| 52 |
+
)
|
| 53 |
+
== 0
|
| 54 |
+
)
|
| 55 |
+
|
| 56 |
+
payload = json.loads((repo / "runs" / "paper_ctt_audit" / "audit.json").read_text())
|
| 57 |
+
assert payload["summary"]["status"] == "pass"
|
| 58 |
+
assert payload["paper_inputs"]["num_missing"] == 0
|
| 59 |
+
assert (repo / "runs" / "paper_ctt_audit" / "table.tex").exists()
|