From 02119ac7865ee26eab571850dcff3f16bd721aa5 Mon Sep 17 00:00:00 2001 From: Claude Date: Sun, 1 Nov 2026 17:01:38 +0000 Subject: [PATCH] fix(hygiene_ci): count simulate_if_needed as the simulates lever levers_from_text flags a script as `simulates` when its text contains `should_simulate(`. The workspaces are being swept onto the one-line wrapper `util.dataset.simulate_if_needed(...)`, which does not contain that token, so swept scripts would silently lose the lever. Match both, with a test. Co-Authored-By: Claude Opus 5.5 Claude-Session: https://claude.ai/code/session_016nhQ8NyQo2s3YUk8eUrrB3 --- agents/conductors/hygiene/_hygiene_ci.py | 5 +++-- tests/test_hygiene_ci.py | 7 +++++++ 2 files changed, 10 insertions(+), 2 deletions(-) diff --git a/agents/conductors/hygiene/_hygiene_ci.py b/agents/conductors/hygiene/_hygiene_ci.py index bc1a8e2b..bdfbe916 100755 --- a/agents/conductors/hygiene/_hygiene_ci.py +++ b/agents/conductors/hygiene/_hygiene_ci.py @@ -38,7 +38,8 @@ * ``env_knob`` — the script reads an ``os.environ.get("NAME", "")`` sizing knob: a ``set:`` override in the smoke profile can shrink the run without touching the file; -* ``simulates`` — it calls ``should_simulate`` and spawns the simulator +* ``simulates`` — it calls ``should_simulate`` (or its one-line wrapper + ``simulate_if_needed``) and spawns the simulator when the dataset is absent: with the dataset cache cold the simulation is paid inside the script's own timing; * ``jax_jit`` — it JITs (``jax.jit`` / ``ENV: jax``): compile cost, paid @@ -230,7 +231,7 @@ def levers_from_text(text: str) -> list[dict]: for name, default in _ENV_KNOB.findall(text): out.append({"lever": "env_knob", "detail": f"{name} (default {default})", "action": f"set {name} lower for smoke via a profile_smoke.yaml `set:` override"}) - if "should_simulate(" in text: + if "should_simulate(" in text or "simulate_if_needed(" in text: out.append({"lever": "simulates", "detail": "runs the simulator when the dataset is absent", "action": "cold dataset cache → simulation is inside this timing; check cache_datasets"}) tokens = set() diff --git a/tests/test_hygiene_ci.py b/tests/test_hygiene_ci.py index 92f0df8f..486807c2 100644 --- a/tests/test_hygiene_ci.py +++ b/tests/test_hygiene_ci.py @@ -115,6 +115,13 @@ def test_levers_are_read_from_the_script_text(): assert "real_search" not in levers +def test_simulate_if_needed_counts_as_simulates(): + """The one-line wrapper swept into the workspaces must keep the lever.""" + text = 'al.util.dataset.simulate_if_needed(p, simulator="scripts/sim.py")\n' + levers = {l["lever"] for l in ci.levers_from_text(text)} + assert "simulates" in levers + + def test_real_output_token_releases_every_var(): levers = {l["lever"] for l in ci.levers_from_text('"""\n__Env__\nENV: real_output\n"""\n')} assert {"jax_jit", "full_datasets", "real_search"} <= levers