@@ -92,6 +92,41 @@ def test_book_policy_override_wins_both_ways():
9292 assert resolve_closed_book ("browsecomp" , True ) is True # --no-web
9393
9494
95+ async def test_runner_does_not_invert_the_web_flags (
96+ tmp_path : Path , monkeypatch : pytest .MonkeyPatch
97+ ) -> None :
98+ """``--no-web`` must reach ``resolve_closed_book`` as closed-book, and vice versa.
99+
100+ ``resolve_closed_book`` is polarity-correct on its own, so its unit tests
101+ above stay green even when the runner hands it an un-negated *open-book*
102+ flag. That is exactly how the flags shipped inverted, so the regression has
103+ to be pinned on the handoff inside ``run_eval``.
104+ """
105+ import argparse
106+
107+ from benchmarks .public import sandbox_profiles
108+ from benchmarks .public .runner import run_subprocess
109+
110+ class _Stop (Exception ):
111+ """Sentinel: end the run once the override has been observed."""
112+
113+ seen : list [bool | None ] = []
114+
115+ def _spy (benchmark : str , override : bool | None = None ) -> bool :
116+ seen .append (override )
117+ raise _Stop
118+
119+ monkeypatch .setattr (sandbox_profiles , "resolve_closed_book" , _spy )
120+
121+ for web in (True , False , None ):
122+ args = argparse .Namespace (benchmark = "browsecomp" , pipeline = None , web = web )
123+ with pytest .raises (_Stop ):
124+ await run_subprocess .run_eval (args , out_dir = tmp_path , seed = 0 )
125+
126+ # --web is open-book, --no-web is closed-book, no flag defers to the benchmark.
127+ assert seen == [False , True , None ]
128+
129+
95130class _FakeResourceManager :
96131 """Minimal stand-in exposing only what the tool resolvers touch."""
97132
0 commit comments