test: select matched MRT DFG pilot with separate provenance

This commit is contained in:
TRON committed 2026-10-18 03:49:21 -07:00
1 parent 3ea131e92c
commit 2abc48f0d8
4 files changed
+290 -27

No files matched your search

+59 -7
View File
@@ -13,7 +13,11 @@ h, periodic = r.helpers(r.DEFAULT_SOURCE)
def test_source_pin():
assert r.verify_source(r.DEFAULT_SOURCE)["commit"].startswith("cd3a657")
historical = json.loads((r.HERE / "data/refined_dfg/source_manifest.json").read_text())
assert historical["commit"].startswith("cd3a657")
assert r.verify_source(r.DEFAULT_SOURCE, "MRT")["commit"].startswith("3ea131e")
with unittest.TestCase().assertRaisesRegex(RuntimeError, "Source mismatch"):
r.verify_source(r.DEFAULT_SOURCE, "SRT")
def test_matched_units_and_planes():
@@ -135,16 +139,17 @@ def test_axis_specific_sampling_phase():
def test_full_requires_completed_pilot():
with unittest.TestCase().assertRaisesRegex(ValueError, "pilot-results"):
r.verify_pilot(None, r.verify_source(r.DEFAULT_SOURCE))
r.verify_pilot(None, r.verify_source(r.DEFAULT_SOURCE, "MRT"))
def pilot_fixture(path):
"""Synthetic contract fixture only; never a physical result or run receipt."""
manifest = r.verify_source(r.DEFAULT_SOURCE)
manifest = r.verify_source(r.DEFAULT_SOURCE, "MRT")
(path / "plan.json").write_text(
json.dumps(
dict(
source_manifest=manifest,
collision="MRT",
bounds_root_edge=list(r.BOUNDS),
runner_sha256=r.runner_hash(),
)
@@ -177,6 +182,7 @@ def pilot_fixture(path):
json.dumps(
dict(
case=case,
collision="MRT",
mode="pilot",
status="pilot_complete",
healthy=True,
@@ -192,6 +198,7 @@ def pilot_fixture(path):
json.dumps(
dict(
case=case,
collision="MRT",
mode="pilot",
step=interval,
runner_sha256=r.runner_hash(),
@@ -208,7 +215,7 @@ def test_pilot_validation_and_calibration():
with TemporaryDirectory() as tmp:
path = Path(tmp)
manifest = pilot_fixture(path)
assert r.verify_pilot(path, manifest) == 3606.0
assert r.verify_pilot(path, manifest, "MRT") == 3606.0
def test_reject_malformed_pilot_receipts():
@@ -238,7 +245,7 @@ def test_reject_malformed_pilot_receipts():
mutate(bad)
receipt.write_text(json.dumps(bad))
with unittest.TestCase().assertRaises(ValueError):
r.verify_pilot(path, manifest)
r.verify_pilot(path, manifest, "MRT")
# Exact reviewer regression: previously accepted NaN endpoint.
receipt.write_text(
json.dumps(
@@ -250,11 +257,11 @@ def test_reject_malformed_pilot_receipts():
)
)
with unittest.TestCase().assertRaises(ValueError):
r.verify_pilot(path, manifest)
r.verify_pilot(path, manifest, "MRT")
receipt.write_text(json.dumps(valid))
(path / "uniform/ready.json").write_text("{}")
with unittest.TestCase().assertRaises(ValueError):
r.verify_pilot(path, manifest)
r.verify_pilot(path, manifest, "MRT")
def test_strict_finite_json_and_deadline():
@@ -283,6 +290,51 @@ def test_pressure_probes_actual_body_mask():
assert h.pressure_probes(np.ones(pair.fine_shape), fluid, p)["dp"] == 0.0
def test_matched_mrt_selection():
for diameter in (40, 80):
srt, sbody, sp = r.config(h, diameter)
mrt, mbody, mp = r.config(h, diameter, "MRT")
assert mrt["method"]["collision"] == "MRT"
mrt["method"]["collision"] = "SRT"
assert mrt == srt and mbody == sbody and mp == sp
srt_plan, mrt_plan = r.plan(h), r.plan(h, "MRT")
for key in ("root", "uniform", "bounds_root_edge", "finest_dx_m", "finest_dt_s"):
assert srt_plan[key] == mrt_plan[key]
assert "q2/6/8" in mrt_plan["outlet"] and "all nine" in srt_plan["outlet"]
cfg, pair, _, host = r.host_geometry(r.DEFAULT_SOURCE, h, "MRT")
assert cfg.collision == "MRT" and pair.fine_shape == (240, 568)
assert len(host.boundary_cells) > 0
def test_reject_collision_receipts():
from tempfile import TemporaryDirectory
for rel in ("plan.json", "uniform/summary.json", "refined/summary.json",
"uniform/ready.json", "refined/ready.json"):
for invalid in ("SRT", None):
with TemporaryDirectory() as tmp:
path = Path(tmp)
manifest = pilot_fixture(path)
receipt = path / rel
record = json.loads(receipt.read_text())
if invalid is None:
record.pop("collision")
else:
record["collision"] = invalid
receipt.write_text(json.dumps(record))
with unittest.TestCase().assertRaises(ValueError):
r.verify_pilot(path, manifest, "MRT")
def test_record_actual_checkout_separately():
from source_provenance import checkout_provenance
actual = checkout_provenance(r.DEFAULT_SOURCE)
assert len(actual["checkout_revision"]) == 40
assert isinstance(actual["checkout_dirty"], bool)
assert r.verify_source(r.DEFAULT_SOURCE, "MRT")["production_origin_commit"].startswith("3ea131e")
if __name__ == "__main__":
suite = unittest.TestSuite(
unittest.FunctionTestCase(fn)