"""Opt-in nonoptimizing API preflight. A skipped test is not physical evidence.""" import json import os import subprocess from pathlib import Path import pytest ROOT = Path(__file__).resolve().parents[1] @pytest.mark.skipif(os.environ.get("SIM_RESIDUAL_LEARNING_API_TESTS") != "1", reason="requires explicit supervised nonlearning PhysX API probe") def test_contact_cycle_sim_learning_runtime(tmp_path): env = os.environ.copy() env.pop("CONDA_PREFIX", None) env.pop("VIRTUAL_ENV", None) env["PYTHONPATH"] = str(ROOT / "source/SkillFactory") env["PYTHONDONTWRITEBYTECODE"] = "1" process = subprocess.run([ "/usr/bin/python3", str(ROOT / "scripts/supervise_sim.py"), "--timeout", "240", "--log", str(tmp_path / "console.log"), "--report", str(tmp_path / "supervisor.json"), "--", env.get("ISAACLAB_LAUNCHER", "/home/cen/IsaacLab/isaaclab.sh"), "-p", str(ROOT / "scripts/verify_cycle_sim_learning_runtime.py"), "--output", str(tmp_path / "probe"), "--headless", ], cwd=ROOT, env=env, capture_output=True, text=True, timeout=280) assert process.returncode == 0, process.stdout[-4000:] + process.stderr[-4000:] report = json.loads((tmp_path / "probe/result.json").read_text()) supervisor = json.loads((tmp_path / "supervisor.json").read_text()) assert report["passed"] and supervisor["passed"] and supervisor["cleanup"]["clean"] assert not supervisor["critical_log_lines"] assert report["optimizer_steps"] == report["training_transitions"] == 0 assert report["nonoptimizing_api_transitions"] == 512 assert report["model_sha256_before"] == report["model_sha256_after"] assert not report["accepted_skill"] and not report["functional_claim"] assert not report["failure_term_disabled"] and report["acquisition_deadline_s"] == .2 for name in ("timeout", "true_failure"): fixture = report["fixtures"][name] assert all(fixture["checks"].values()) assert fixture["logprob_max_abs_error"] < 2e-4 assert fixture["max_actual_residual_rad"] <= .050001