Run flat terrain scenario in budget report

Co-authored-by: Codex <codex@openai.com>
This commit is contained in:
2026-11-03 10:42:16 +03:00
parent 3afebae6bd
commit bf8551e1a8
2 changed files with 32 additions and 7 deletions
+14 -4
View File
@@ -157,6 +157,10 @@ def test_wasm():
cwd=ROOT / "airdef-mod", env=build_env)
BUDGET_SCENARIO = "tests/budgets/wasm_flat_budget.toml"
BUDGET_ASSERTED_SHA256 = "bcc0359289ab20ab3de608bcc130f72d2cf88f9f6fbc470d7b6846e9db5d11df"
def test_budgets():
"""Run the opt-in heavy scenario and always write a machine-readable report."""
report_path = Path(os.environ.get("AIRDEF_BUDGET_REPORT") or
@@ -164,13 +168,15 @@ def test_budgets():
report = {
"schema": 1,
"command": "test-budgets",
"scenario": "tests/budgets/wasm_budget.toml",
"scenario": BUDGET_SCENARIO,
"scenario_render_world": "flat at y=64",
"status": "failed",
"exit_code": None,
"scenario_counts": {"scripts": 1, "steps": None, "raid_requests": None,
"raid_units_requested": None, "air_defense_units": None,
"layout_unit_limit": None, "frames": None, "ticks": None,
"accepted_raids_observed": None, "peak_airborne_observed": None},
"accepted_raids_asserted": None, "snapshot_airborne_asserted": None,
"snapshot_tick": None, "peak_airborne_observed": None},
"runtime_limits": {"source": "horizon/crates/horizon-mods/src/runtime.rs",
"metering": "source_configured; measured_per_scenario: unavailable"},
}
@@ -205,7 +211,7 @@ def test_budgets():
lock_text = (ROOT / "horizon" / "Cargo.lock").read_text()
wasmtime = re.search(r'\[\[package\]\]\s*name = "wasmtime"\s*version = "([^"]+)"', lock_text)
report["wasmtime_version"] = wasmtime.group(1) if wasmtime else None
fixture = ROOT / "airdef-mod" / "tests" / "budgets" / "wasm_budget.toml"
fixture = ROOT / "airdef-mod" / BUDGET_SCENARIO
fixture_text = fixture.read_text()
counts = report["scenario_counts"]
counts["steps"] = len(re.findall(r"(?m)^\[\[step\]\]$", fixture_text))
@@ -238,7 +244,6 @@ def test_budgets():
", ".join(k for k, ok in identity_checks.items() if not ok))
build_env = dict(os.environ)
build_env["PATH"] = str(Path(cargo()).parent) + os.pathsep + build_env.get("PATH", "")
fixture = ROOT / "airdef-mod" / "tests" / "budgets" / "wasm_budget.toml"
with tempfile.TemporaryDirectory(prefix="airdef-wasm-budget-") as temp:
isolated = Path(temp)
(isolated / "tests").mkdir()
@@ -252,6 +257,11 @@ def test_budgets():
report["exit_code"] = result.returncode
report["status"] = "passed" if result.returncode == 0 else "failed"
report["output"] = result.stdout[-12000:]
# These assertions belong to this exact fixture, not to arbitrary edited scripts.
if result.returncode == 0 and report["scenario_sha256"] == BUDGET_ASSERTED_SHA256:
counts["accepted_raids_asserted"] = 2
counts["snapshot_airborne_asserted"] = 184
counts["snapshot_tick"] = 2102
except Exception as exc:
report["error"] = f"{type(exc).__name__}: {exc}"
except SystemExit as exc: