From 647d4e70a87d133d535d97c77b856c6194831d1c Mon Sep 17 00:00:00 2001 From: Etienne Filhol Date: Wed, 2 Dec 2026 02:06:01 +0100 Subject: [PATCH] feat(standard): tell a benchmark's driver the run's provider --- app/nullius/standard/runner/run.py | 4 ++-- app/tests/test_standard_controls.py | 22 ++++++++++++++++++++++ docs/standard.md | 2 +- 3 files changed, 25 insertions(+), 3 deletions(-) diff --git a/app/nullius/standard/runner/run.py b/app/nullius/standard/runner/run.py index fb9612307..004fb05ca 100644 --- a/app/nullius/standard/runner/run.py +++ b/app/nullius/standard/runner/run.py @@ -1202,7 +1202,7 @@ def driver(self) -> jsonl.Proc: os.makedirs(cwd, exist_ok=True) env = {"HOME": home, "NULLIUS_UPSTREAM": self.up or "", "NULLIUS_DATASET": self.data or "", "NULLIUS_DATASET_ID": self.ds["id"], "NULLIUS_VERSION": str(self.bench.get("_version") or ""), - **option_env(self.bench_options), **self.question_env(), **data_env(), **self.file_env, **self.embeddings_env(), **self.driver_secrets()} + "NULLIUS_PROVIDER": getattr(self, "provider", "") or "", **option_env(self.bench_options), **self.question_env(), **data_env(), **self.file_env, **self.embeddings_env(), **self.driver_secrets()} files = [h["path"] for s in definitions.secrets_of(self.bench) if s.get("to") == "driver" and s.get("kind") == "file" for h in [self.licences.get(s["name"])] if h] + list(self.file_env.values()) @@ -1220,7 +1220,7 @@ def driver(self) -> jsonl.Proc: env = base_env(os.path.join(self.job_dir, ".work", "driver-home"), {**extra, "NULLIUS_UPSTREAM": self.up or "", "NULLIUS_DATASET": self.data or "", "NULLIUS_DATASET_ID": self.ds["id"], "PYTHONPATH": driver_path(), "PYTHONDONTWRITEBYTECODE": "1", - "NULLIUS_VERSION": str(self.bench.get("_version") or ""), + "NULLIUS_VERSION": str(self.bench.get("_version") or ""), "NULLIUS_PROVIDER": getattr(self, "provider", "") or "", **({container.CHECK_IMAGE: self.image, **container.check_env()} if self.image else {}), **option_env(getattr(self, "bench_options", {})), **self.question_env(), **data_env(), **self.file_env, **self.embeddings_env(), **self.driver_secrets(), **limits.environment(getattr(self, "constraints", {}))}) diff --git a/app/tests/test_standard_controls.py b/app/tests/test_standard_controls.py index 9db96271a..e9a2fd787 100644 --- a/app/tests/test_standard_controls.py +++ b/app/tests/test_standard_controls.py @@ -823,6 +823,28 @@ def test_the_page_carries_each_datasets_controls_and_whether_proven(self): self.assertEqual(c["fits"]["fakebench"], {"fake": [], "nop": [], "oracle": []}) +class DriverKnowsTheProvider(unittest.TestCase): + """The driver is told the run's provider, for an upstream that sends differently by provider.""" + def test_the_driver_reads_the_runs_provider(self): + tmp = tempfile.mkdtemp() + self.addCleanup(shutil.rmtree, tmp, True) + here = os.path.join(tmp, "said") + os.makedirs(here) + with open(os.path.join(here, "driver.py"), "w") as f: + f.write('import os\nfrom nullius.standard.protocols.jsonl import serve\n' + 'def score(unit, dir, transcript, answer, verified=None):\n' + ' return {"reward": {"openai": 0.25, "openrouter": 0.75}.get(os.environ.get("NULLIUS_PROVIDER"), 0.0), "detail": {}}\n' + 'serve({"units": lambda dataset: {"units": ["a"]}, "setup": lambda unit, dir: {"prompt": "hi"}, "score": score})\n') + b = dict(definitions.get("benchmark", "fakebench", FIX), _here=here, controls=CONTROLS, + driver={"command": ["python3", "{here}/driver.py"]}) + for provider in ("openai", "openrouter"): + with self.subTest(provider): + job_dir = run.run(b, definitions.control(b, "nop"), model="", provider=provider, + jobs_root=os.path.join(tmp, provider), env={}, say=lambda s: None) + name = next(t for t in os.listdir(job_dir) if "__u" in t) + with open(os.path.join(job_dir, name, "result.json")) as f: + self.assertEqual(json.load(f)["verifier_result"]["rewards"]["reward"], {"openai": 0.25, "openrouter": 0.75}[provider]) + class ProofDriverCredentials(unittest.TestCase): def test_units_receive_saved_or_handed_driver_credentials_only(self): from nullius import secrets diff --git a/docs/standard.md b/docs/standard.md index 024fecb88..49becfc69 100644 --- a/docs/standard.md +++ b/docs/standard.md @@ -420,7 +420,7 @@ its local proof records, saved runs and credentials remain. Proofs the bundled e 1. **Scaffold it.** `cli new benchmark KEY` (`--family module --port cap.memory/v1` for a Module benchmark) writes `benchmarks//standard.json` and `driver.py` under your user catalogue (`nullius paths`). 2. **Pin the data.** `upstream.repository` and `upstream.tested`, a full commit: the latest release tag's (`upstream.tag`; an annotated tag's commit is the `^{}` line of `git ls-remote --tags`), a default-branch commit only without a release. Each dataset: its `path` in the upstream or its `url` at a revision, its `sha256` and `units`; optional `subset_of`, the id of a list cut from none that holds every unit of this one. Installs and upstreams go under `STANDARD_DIR` (`~/.local/share/nullius/standard` on Linux by default), downloaded datasets under its `datasets/` or `STANDARD_DATA_DIR`. 3. **Choose the needs.** The fewest ports: `agent.workspace/v1` for files, `agent.search/v1` for search and source retrieval, `agent.tools/v1` for MCP tools, `agent.conversation/v1` if a user speaks more than once; a skill the units cannot be done without goes in `needs_skills`. -4. **Write the driver.** It answers the [ops below](#driver-ops); the dataset file is `$NULLIUS_DATASET` (empty for a dataset with no `path` or `url`), the upstream `$NULLIUS_UPSTREAM`, the version `$NULLIUS_VERSION`. Keep the tests out of the workspace until `score`; prints go to stderr. +4. **Write the driver.** It answers the [ops below](#driver-ops); the dataset file is `$NULLIUS_DATASET` (empty for a dataset with no `path` or `url`), the upstream `$NULLIUS_UPSTREAM`, the version `$NULLIUS_VERSION`, the run's provider `$NULLIUS_PROVIDER` (`openrouter`, `openai`, `anthropic`, `custom`), for an upstream that sends differently by provider. Keep the tests out of the workspace until `score`; prints go to stderr. 5. **Its own options**, when the upstream offers a choice a run should make ([below](#benchmark-options)). 6. **Add the catalogue entry.** `benchmark.json` beside it, with `standard` in `harness`. A contribution to the bundled catalogue also adds its mark in `app/static/catalogue/marks.svg`. 7. **Declare its controls** ([Controls and proofs](#controls-and-proofs)).