From 62810fbccad0105a5ef8f4ff7bd0a9f6fd548402 Mon Sep 17 00:00:00 2001 From: Etienne Filhol Date: Wed, 2 Dec 2026 01:45:17 +0100 Subject: [PATCH 1/3] feat(catalogue): add ClawMark, run as its own OpenClaw --- .../benchmarks/clawmark/benchmark.json | 227 ++++++++++++ .../catalogue/benchmarks/clawmark/driver.py | 285 +++++++++++++++ .../clawmark/env/accounts.Dockerfile | 1 + .../catalogue/benchmarks/clawmark/proofs.json | 25 ++ .../catalogue/benchmarks/clawmark/runner.py | 117 ++++++ .../benchmarks/clawmark/standard.json | 346 ++++++++++++++++++ .../clawmark/upstream-settings.json | 198 ++++++++++ app/nullius/standard/cli.py | 4 +- app/nullius/standard/contract/definitions.py | 15 +- app/nullius/standard/contract/match.py | 2 + app/nullius/standard/pages/recipe.py | 6 +- app/static/builder/command-builder-core.js | 6 +- app/static/catalogue/marks.svg | 4 + app/tests/test_catalog.py | 2 +- app/tests/test_clawmark_driver.py | 116 ++++++ app/tests/test_standard_definitions.py | 18 + app/tests/test_standard_setups.py | 5 +- app/ui_tests/test_builder_where.py | 5 +- app/ui_tests/test_catalogue_routes.py | 2 +- app/web/builder.py | 2 +- docs/standard.md | 4 +- 21 files changed, 1369 insertions(+), 21 deletions(-) create mode 100644 app/nullius/catalogue/benchmarks/clawmark/benchmark.json create mode 100644 app/nullius/catalogue/benchmarks/clawmark/driver.py create mode 100644 app/nullius/catalogue/benchmarks/clawmark/env/accounts.Dockerfile create mode 100644 app/nullius/catalogue/benchmarks/clawmark/proofs.json create mode 100644 app/nullius/catalogue/benchmarks/clawmark/runner.py create mode 100644 app/nullius/catalogue/benchmarks/clawmark/standard.json create mode 100644 app/nullius/catalogue/benchmarks/clawmark/upstream-settings.json create mode 100644 app/tests/test_clawmark_driver.py diff --git a/app/nullius/catalogue/benchmarks/clawmark/benchmark.json b/app/nullius/catalogue/benchmarks/clawmark/benchmark.json new file mode 100644 index 000000000..ff654297e --- /dev/null +++ b/app/nullius/catalogue/benchmarks/clawmark/benchmark.json @@ -0,0 +1,227 @@ +{ + "key": "clawmark", + "title": "ClawMark", + "category": "General assistance", + "domain": "Office work over several days, across files, mail, calendar, Notion and Sheets.", + "scoring": "Rule checkers", + "harness": [ + "standard" + ], + "origin": "official", + "good_to_know": [ + "Partial credit: each task scores 0 to 1 by its checkers' weights; the score is the mean.", + "The leaderboard averages 3 attempts per task: set 3 attempts to compare.", + "96 tasks need a Notion workspace and 87 a Google account. Use accounts made for this: the agent gets the Notion agent key and the Google credentials, which open the whole Drive.", + "Set the accounts up as in ClawMark's docs/credentials-setup.md; the Notion pages are named ClawMark Source Hub and ClawMark Eval Hub. The Notion browser login is not needed.", + "Tasks with accounts run one at a time on a machine. Run them on one machine only: they find pages and sheets by name.", + "The first run on a machine builds a Docker image and downloads about 7 GB of Whisper models.", + "For non-commercial use (CC BY-NC 4.0)." + ], + "upstream_limitations": [ + "4 product management tasks (1, 3, 5, 7) have checkers that read Office files with packages ClawMark does not install: they find nothing in them.", + "The container image installs mcporter, the Notion server, caldav, Whisper and PyMuPDF at their latest versions: an image built later can differ.", + "An agent that does nothing scores 0.06 on the 3 tasks without accounts: some checkers pass when a file or a draft is left unchanged.", + "Google credentials of an app left in Testing, as its guide says, expire after 7 days: make them again.", + "OpenClaw 2026.3.31 asks Claude for thinking with a fixed budget. Claude models that take only adaptive thinking, claude-haiku-5-5 among them, refuse it, and OpenClaw then runs with thinking off." + ], + "limitations": [ + "Only ClawMark's own OpenClaw runs it; no other agent yet.", + "Only the 3 tasks without accounts have been run here: the 97 others need accounts Nullius has not tested with.", + "A model served only over the Responses API does not run." + ], + "datasets": [ + { + "key": "no_accounts", + "title": "No accounts", + "tasks": 3, + "official": "https://github.com/evolvent-ai/ClawMark", + "source": "GitHub", + "registry": "", + "hub": "", + "verifier": "Each task's own checkers, after each day and at the end.", + "notes": "CC BY-NC 4.0." + }, + { + "key": "no_google", + "title": "No Google account", + "tasks": 13, + "official": "https://github.com/evolvent-ai/ClawMark", + "source": "GitHub", + "registry": "", + "hub": "", + "verifier": "Each task's own checkers, after each day and at the end.", + "notes": "CC BY-NC 4.0." + }, + { + "key": "all", + "title": "All tasks", + "tasks": 100, + "official": "https://github.com/evolvent-ai/ClawMark", + "source": "GitHub", + "registry": "", + "hub": "", + "verifier": "Each task's own checkers, after each day and at the end.", + "notes": "CC BY-NC 4.0." + }, + { + "key": "clinical_assistant", + "title": "Clinical assistant", + "tasks": 4, + "official": "https://github.com/evolvent-ai/ClawMark", + "source": "GitHub", + "registry": "", + "hub": "", + "verifier": "Each task's own checkers, after each day and at the end.", + "notes": "CC BY-NC 4.0." + }, + { + "key": "content_operation", + "title": "Content operation", + "tasks": 12, + "official": "https://github.com/evolvent-ai/ClawMark", + "source": "GitHub", + "registry": "", + "hub": "", + "verifier": "Each task's own checkers, after each day and at the end.", + "notes": "CC BY-NC 4.0." + }, + { + "key": "ecommerce", + "title": "E-commerce", + "tasks": 9, + "official": "https://github.com/evolvent-ai/ClawMark", + "source": "GitHub", + "registry": "", + "hub": "", + "verifier": "Each task's own checkers, after each day and at the end.", + "notes": "CC BY-NC 4.0." + }, + { + "key": "eda", + "title": "EDA", + "tasks": 1, + "official": "https://github.com/evolvent-ai/ClawMark", + "source": "GitHub", + "registry": "", + "hub": "", + "verifier": "Each task's own checkers, after each day and at the end.", + "notes": "CC BY-NC 4.0." + }, + { + "key": "executive_assistant", + "title": "Executive assistant", + "tasks": 7, + "official": "https://github.com/evolvent-ai/ClawMark", + "source": "GitHub", + "registry": "", + "hub": "", + "verifier": "Each task's own checkers, after each day and at the end.", + "notes": "CC BY-NC 4.0." + }, + { + "key": "hr", + "title": "HR", + "tasks": 11, + "official": "https://github.com/evolvent-ai/ClawMark", + "source": "GitHub", + "registry": "", + "hub": "", + "verifier": "Each task's own checkers, after each day and at the end.", + "notes": "CC BY-NC 4.0." + }, + { + "key": "insurance", + "title": "Insurance", + "tasks": 7, + "official": "https://github.com/evolvent-ai/ClawMark", + "source": "GitHub", + "registry": "", + "hub": "", + "verifier": "Each task's own checkers, after each day and at the end.", + "notes": "CC BY-NC 4.0." + }, + { + "key": "investment_analyst", + "title": "Investment analyst", + "tasks": 6, + "official": "https://github.com/evolvent-ai/ClawMark", + "source": "GitHub", + "registry": "", + "hub": "", + "verifier": "Each task's own checkers, after each day and at the end.", + "notes": "CC BY-NC 4.0." + }, + { + "key": "journalist", + "title": "Journalist", + "tasks": 8, + "official": "https://github.com/evolvent-ai/ClawMark", + "source": "GitHub", + "registry": "", + "hub": "", + "verifier": "Each task's own checkers, after each day and at the end.", + "notes": "CC BY-NC 4.0." + }, + { + "key": "legal_assistant", + "title": "Legal assistant", + "tasks": 6, + "official": "https://github.com/evolvent-ai/ClawMark", + "source": "GitHub", + "registry": "", + "hub": "", + "verifier": "Each task's own checkers, after each day and at the end.", + "notes": "CC BY-NC 4.0." + }, + { + "key": "pm", + "title": "Product management", + "tasks": 8, + "official": "https://github.com/evolvent-ai/ClawMark", + "source": "GitHub", + "registry": "", + "hub": "", + "verifier": "Each task's own checkers, after each day and at the end.", + "notes": "CC BY-NC 4.0." + }, + { + "key": "real_estate", + "title": "Real estate", + "tasks": 6, + "official": "https://github.com/evolvent-ai/ClawMark", + "source": "GitHub", + "registry": "", + "hub": "", + "verifier": "Each task's own checkers, after each day and at the end.", + "notes": "CC BY-NC 4.0." + }, + { + "key": "research_assistant", + "title": "Research assistant", + "tasks": 15, + "official": "https://github.com/evolvent-ai/ClawMark", + "source": "GitHub", + "registry": "", + "hub": "", + "verifier": "Each task's own checkers, after each day and at the end.", + "notes": "CC BY-NC 4.0." + } + ], + "task_count": 100, + "citation": "@misc{meng2026clawmarklivingworldbenchmarkmultiturn,\n title={ClawMark: A Living-World Benchmark for Multi-Turn, Multi-Day, Multimodal Coworker Agents}, \n author={Fanqing Meng and Lingxiao Du and Zijian Wu and Guanzheng Chen and Xiangyan Liu and Jiaqi Liao and Chonghe Jiang and Zhenglin Wan and Jiawei Gu and Pengfei Zhou and Rui Huang and Ziqi Zhao and Shengyuan Ding and Ailing Yu and Bo Peng and Bowei Xia and Hao Sun and Haotian Liang and Ji Xie and Jiajun Chen and Jiajun Song and Liu Yang and Ming Xu and Qionglin Qiu and Runhao Fu and Shengfang Zhai and Shijian Wang and Tengfei Ma and Tianyi Wu and Weiyang Jin and Yan Wang and Yang Dai and Yao Lai and Youwei Shu and Yue Liu and Yunzhuo Hao and Yuwei Niu and Jinkai Huang and Jiayuan Zhuo and Zhennan Shen and Linyu Wu and Hannah Yao and Charles Chen and Cihang Xie and Yuyin Zhou and Jiaheng Zhang and Zeyu Zheng and Mengkang Hu and Michael Qizhe Shieh},\n year={2026},\n eprint={2604.23781},\n archivePrefix={arXiv},\n primaryClass={cs.CV},\n url={https://arxiv.org/abs/2604.23781}, \n}", + "citation_source": "https://arxiv.org/abs/2604.23781", + "evidence": [ + { + "label": "Checks passed", + "path": "checks_passed" + }, + { + "label": "Checks failed", + "path": "checks_failed" + }, + { + "label": "Checks that raised", + "path": "checks_raised" + } + ] +} diff --git a/app/nullius/catalogue/benchmarks/clawmark/driver.py b/app/nullius/catalogue/benchmarks/clawmark/driver.py new file mode 100644 index 000000000..081a39a76 --- /dev/null +++ b/app/nullius/catalogue/benchmarks/clawmark/driver.py @@ -0,0 +1,285 @@ +"""ClawMark's driver for the Nullius standard (JSON lines on stdin and stdout). + +Each unit is one task run by ClawMark's own CLI at the tested commit +($NULLIUS_UPSTREAM), in a process of its own (runner.py): its loader, stages, +services, OpenClaw container and checkers. + +units - the dataset's tasks as domain__taskN, by the upstream's loader +setup - the task's PROMPT, for the null control +answer - the Original setup: `clawmark --task`, its model calls through the unit's relay +score - the upstream's result.json; for the null control, its run by runner.py with no agent. + A task the framework could not run to its end is the score's error, never a 0 + +A task with a Notion or Google account runs alone on this machine, as the +upstream's own loop runs them: the accounts' pages and sheets go by name.""" +import contextlib +import fcntl +import glob +import hashlib +import json +import os +import pwd +import queue +import re +import signal +import subprocess +import sys +import tempfile +import threading +import time +from pathlib import Path + +UP = os.environ["NULLIUS_UPSTREAM"] +RUNNER = sys.argv[1] +sys.path.insert(0, os.path.join(UP, "src")) +TASKS = os.path.join(UP, "tasks") +DOCKER = os.path.join(UP, "docker") +RESULTS = "results" +LOG = "clawmark.log" +# the compose file's images, by digest: it names radicale with no version, so its newest at import +RADICALE = "tomsquest/docker-radicale@sha256:665b9016dcee945d3ba3fa1825c9baa9337b2ede6a10eb62c347ebeac6b62ff0" +GREENMAIL = "greenmail/standalone@sha256:d556b8c7df01ba04a0e0f67dacab2c5f75a61207a51774e0654c179b83a671e1" +LOCKS = os.path.join(tempfile.gettempdir(), f"nullius-clawmark-{os.getuid()}") +ACCOUNTS = {"notion": ("NOTION_ADMIN_KEY", "NOTION_AGENT_KEY"), "google_sheets": ("GOOGLE_CREDENTIALS_PATH",)} +PAGES = {"NOTION_SOURCE_PAGE": "ClawMark Source Hub", "NOTION_EVAL_PAGE": "ClawMark Eval Hub"} +KEPT = ("PATH", "HOME", "USER", "LANG", "LC_ALL", "TMPDIR", "DOCKER_HOST", "DOCKER_CONTEXT", "DOCKER_CONFIG", "XDG_RUNTIME_DIR", + "http_proxy", "https_proxy", "no_proxy", "HTTP_PROXY", "HTTPS_PROXY", "NO_PROXY") +# a driver's HOME is not the user's, whose ~/.docker holds the compose plugin +os.environ.setdefault("DOCKER_CONFIG", os.path.join(pwd.getpwuid(os.getuid()).pw_dir, ".docker")) +STOP_SECONDS = 180 +CHECKER_RAISED = re.compile(r"Checker '([^']+)' raised: ") + + +class EnvironmentSetupError(RuntimeError): + pass + + +class VerifierError(RuntimeError): + pass + + +class CancelledError(RuntimeError): + pass + + +LINES, CLOSED = queue.Queue(), threading.Event() + + +def _read(): + for line in sys.stdin: + LINES.put(line) + CLOSED.set() + LINES.put(None) + + +def _task(unit): + from clawmark.task_loader import load_task_py + return load_task_py(Path(TASKS, *unit.split("__"))) + + +def units(dataset=None, setup=None): + from clawmark.task_loader import discover_task_dirs + name = os.environ.get("NULLIUS_DATASET_ID") or dataset + domains = sorted(d for d in os.listdir(TASKS) if os.path.isdir(os.path.join(TASKS, d))) + if name in domains: + domains = [name] + out = [f"{d}__{t.name}" for d in domains for t in discover_task_dirs(Path(TASKS, d))] + without = {"no_accounts": set(ACCOUNTS), "no_google": {"google_sheets"}}.get(name) + if without: + out = [u for u in out if not without & set(_task(u).environments)] + return {"units": out} + + +def setup(unit, dir, **_): + return {"prompt": _task(unit).prompt} + + +def _docker(*args, seconds=120): + try: + return subprocess.run(["docker", *args], capture_output=True, text=True, timeout=seconds) + except (OSError, subprocess.TimeoutExpired) as e: + raise EnvironmentSetupError(f"docker {args[0]}: {type(e).__name__}") from None + + +@contextlib.contextmanager +def _locked(name, until=None): + os.makedirs(LOCKS, mode=0o700, exist_ok=True) + with open(os.path.join(LOCKS, name + ".lck"), "a") as f: + while True: + try: + fcntl.flock(f, fcntl.LOCK_EX | fcntl.LOCK_NB) + break + except BlockingIOError: + if CLOSED.wait(1): + raise CancelledError("the run was stopped before the task started") + if until and time.time() > until: + raise EnvironmentSetupError("the unit's time ran out while another task held what it waits for") + yield f + + +def _image(): + """The upstream's main image, from its own Dockerfile, built once on this machine.""" + with open(os.path.join(DOCKER, "Dockerfile"), "rb") as f: + tag = "nullius/clawmark-main:" + hashlib.sha256(f.read()).hexdigest()[:12] + if _docker("image", "inspect", tag).returncode: + with _locked("image"): + if _docker("image", "inspect", tag).returncode: + print(f"building {tag}: the upstream's Dockerfile, about 7 GB of Whisper models among it", file=sys.stderr, flush=True) + p = subprocess.Popen(["docker", "build", "-t", tag, "-f", os.path.join(DOCKER, "Dockerfile"), DOCKER], + stdin=subprocess.DEVNULL, stdout=sys.stderr, stderr=sys.stderr) + while p.poll() is None: + if CLOSED.wait(1): + p.terminate() + raise CancelledError("the run was stopped while the image was built") + if p.returncode: + raise EnvironmentSetupError(f"the upstream's image did not build (docker build exited {p.returncode}): see the driver's log") + return tag + + +def _compose(dir, image): + """The upstream's compose file, with its images pinned and the relay's host name.""" + path = os.path.join(dir, "compose.yaml") + override = os.path.join(dir, "compose.override.yaml") + with open(override, "w") as f: + json.dump({"services": {"main": {"image": image, "extra_hosts": ["host.docker.internal:host-gateway"]}, + "radicale": {"image": RADICALE}, "greenmail": {"image": GREENMAIL}}}, f) + with open(path, "w") as f: + json.dump({"include": [{"path": [os.path.join(DOCKER, "docker-compose.yaml"), override]}]}, f) + return path + + +def _account_env(environments): + """What the task's accounts need, and nothing of an account it does not use.""" + out, missing = {}, [] + for env, names in ACCOUNTS.items(): + if env in environments: + out.update({n: os.environ.get(n, "") for n in names}) + missing += [n for n in names if not os.environ.get(n)] + if missing: + raise EnvironmentSetupError("the task needs " + ", ".join(missing).replace("GOOGLE_CREDENTIALS_PATH", "GOOGLE_CREDENTIALS") + + ": set them in Settings") + if "notion" in environments: + out.update(PAGES) + return out + + +def _hidden(env): + """The credentials an agent could have repeated in what the unit keeps.""" + out = [env[n] for n in ACCOUNTS["notion"] if env.get(n)] + if env.get("GOOGLE_CREDENTIALS_PATH"): + with contextlib.suppress(OSError, ValueError, AttributeError): + with open(env["GOOGLE_CREDENTIALS_PATH"], encoding="utf-8") as f: + google = json.load(f) + out += [google[k] for k in ("token", "refresh_token", "client_secret") if google.get(k)] + return [s.encode() for s in out] + + +def _redact(dir, secrets): + for path in glob.iglob(os.path.join(glob.escape(dir), "**"), recursive=True) if secrets else (): + if os.path.isfile(path) and not os.path.islink(path): + with contextlib.suppress(OSError): + with open(path, "rb") as f: + data = f.read() + clean = data + for s in secrets: + clean = clean.replace(s, b"[redacted]") + if clean != data: + with open(path, "wb") as f: + f.write(clean) + + +def _fresh(dir): + os.makedirs(dir, exist_ok=True) + ns = time.time_ns() + for name in (RESULTS, LOG): + if os.path.lexists(os.path.join(dir, name)): + os.replace(os.path.join(dir, name), os.path.join(dir, f"{name}.{ns}")) + + +def _run(unit, dir, env, until, *flags): + """runner.py on the unit, in a session of its own: it cleans up once its stdin closes, however this driver ends.""" + _fresh(dir) + environments = _task(unit).environments + accounts = _account_env(environments) + with contextlib.ExitStack() as held: + compose = _compose(dir, _image()) + if any(e in ACCOUNTS for e in environments): + held.enter_context(_locked("accounts", until)) + full = {**{k: v for k, v in os.environ.items() if k in KEPT}, **accounts, **env, "PYTHONUNBUFFERED": "1", + "PYTHONPATH": os.path.join(UP, "src")} + with open(os.path.join(dir, LOG), "w") as log: + p = subprocess.Popen([sys.executable, RUNNER, compose, *flags, "--task", os.path.join(TASKS, *unit.split("__")), + "--results-dir", RESULTS, "--compose-file", compose], + cwd=dir, env=full, stdin=subprocess.PIPE, stdout=log, stderr=subprocess.STDOUT, start_new_session=True) + why = None + while p.poll() is None: + if CLOSED.wait(1) or time.time() > until: + why = "the run was stopped" if CLOSED.is_set() else "the unit's time ran out" + p.stdin.close() + try: + p.wait(STOP_SECONDS) + except subprocess.TimeoutExpired: + os.killpg(p.pid, signal.SIGKILL) + p.wait() + break + _redact(dir, _hidden(accounts)) + if why: + raise (CancelledError if CLOSED.is_set() else EnvironmentSetupError)(why) + if p.returncode: + raise EnvironmentSetupError(f"clawmark exited {p.returncode}: see the unit's {LOG}") + + +def _turn_seconds(): + with open(os.path.join(os.path.dirname(os.path.abspath(RUNNER)), "standard.json"), encoding="utf-8") as f: + d = json.load(f) + return d["setups"]["original"]["turn_seconds"], d["limits"]["score_seconds"] + + +def answer(unit, dir, setup, model, base_url, key, **_): + if setup != "original": + raise RuntimeError(f"unknown setup {setup}") + until = time.time() + _turn_seconds()[0] - STOP_SECONDS - 30 + api = os.environ.get("NULLIUS_OPTION_API_FORMAT", "anthropic") + base = base_url if api == "openrouter" else base_url.removesuffix("/v1") + inputs = os.environ.get("NULLIUS_OPTION_MODEL_INPUTS", "text_image").split("_") + _run(unit, dir, {"ANTHROPIC_API_KEY": key, "ANTHROPIC_API_BASE": base, "MODEL": model, "API_FORMAT": api}, until, + "--model-inputs", *inputs) + return {"answer": "", "model": model} + + +def score(unit, dir, setup=None, answer=None, **_): + if setup is None: + until = time.time() + _turn_seconds()[1] - STOP_SECONDS - 30 + _run(unit, dir, {"ANTHROPIC_API_KEY": "none", "MODEL": "none"}, until, "--nop") + found = glob.glob(os.path.join(glob.escape(dir), RESULTS, "**", "result.json"), recursive=True) + if len(found) != 1: + raise VerifierError(f"no result.json: see the unit's {LOG}") + with open(found[0], encoding="utf-8") as f: + result = json.load(f) + # the upstream scores what ran before a framework failure over the checks it reached: not the task's score + broken = next((s for s in result["stages"] if not s["success"] and s["verification_score"] < 0), None) + if broken: + stage = "the task" if broken["id"] == "FRAMEWORK_ERROR" else broken["id"] + raise EnvironmentSetupError(f"ClawMark could not run {stage}: {broken['error'][:300]}") + with open(os.path.join(dir, LOG), encoding="utf-8", errors="replace") as f: + raised = sorted(set(CHECKER_RAISED.findall(f.read()))) + rubric = result["rubric"] + return {"reward": result["score"], + "detail": {"checks_passed": f"{sum(r['passed'] for r in rubric)} of {len(rubric)}", + "checks_failed": [r["id"] for r in rubric if not r["passed"]], + "checks_raised": raised, + "stages": {s["id"]: s["verification_score"] for s in result["stages"] if s["verification"]}, + "agent_errors": {s["id"]: s["error"][-300:] for s in result["stages"] if not s["success"]}}} + + +if __name__ == "__main__": + HANDLERS = {"units": units, "setup": setup, "answer": answer, "score": score} + threading.Thread(target=_read, daemon=True).start() + while (line := LINES.get()) is not None: + try: + req = json.loads(line) + with contextlib.redirect_stdout(sys.stderr): + out = HANDLERS[req.pop("op")](**req) + except Exception as e: + out = {"error": f"{type(e).__name__}: {e}"} + print(json.dumps(out), flush=True) diff --git a/app/nullius/catalogue/benchmarks/clawmark/env/accounts.Dockerfile b/app/nullius/catalogue/benchmarks/clawmark/env/accounts.Dockerfile new file mode 100644 index 000000000..dc577dda0 --- /dev/null +++ b/app/nullius/catalogue/benchmarks/clawmark/env/accounts.Dockerfile @@ -0,0 +1 @@ +# Nullius's base image unchanged: ClawMark's own image runs OpenClaw. The accounts' credentials go to the driver, never into the image. diff --git a/app/nullius/catalogue/benchmarks/clawmark/proofs.json b/app/nullius/catalogue/benchmarks/clawmark/proofs.json new file mode 100644 index 000000000..d2103e64c --- /dev/null +++ b/app/nullius/catalogue/benchmarks/clawmark/proofs.json @@ -0,0 +1,25 @@ +{ + "schema": "nullius.proofs/v1", + "kind": "benchmark", + "key": "clawmark", + "versions": { + "": { + "proven": { + "no_accounts": { + "units": { + "units": 3, + "passed": "3 ids, the same twice, unique" + }, + "nop": { + "passed": "0/3", + "value": 0.0557, + "expect": { + "at_most": 0.1 + }, + "units": 3 + } + } + } + } + } +} diff --git a/app/nullius/catalogue/benchmarks/clawmark/runner.py b/app/nullius/catalogue/benchmarks/clawmark/runner.py new file mode 100644 index 000000000..a73e77012 --- /dev/null +++ b/app/nullius/catalogue/benchmarks/clawmark/runner.py @@ -0,0 +1,117 @@ +"""One task by ClawMark's own CLI, in a process the driver can stop. + + runner.py COMPOSE_FILE [--nop] clawmark's arguments + +--nop: the null control, the upstream's orchestrator with an agent that does +nothing. The unit's relay listens on this machine's loopback: a forwarder on +the Docker bridge's gateway makes it host.docker.internal for OpenClaw's +container. Once stdin closes, the task is interrupted, so the upstream's own +cleanup runs; what is left of its containers is then removed.""" +import os +import signal +import socket +import subprocess +import sys +import threading +from urllib.parse import urlsplit, urlunsplit + +CLEANUP_SECONDS = 120 + + +def _pump(a, b): + try: + while data := a.recv(65536): + b.sendall(data) + b.shutdown(socket.SHUT_WR) + except OSError: + for s in (a, b): + try: + s.shutdown(socket.SHUT_RDWR) + except OSError: + pass + + +def _accept(server, target): + while True: + a, _ = server.accept() + try: + b = socket.create_connection(target) + except OSError: + a.close() + continue + pumps = [threading.Thread(target=_pump, args=x, daemon=True) for x in ((a, b), (b, a))] + for t in pumps: + t.start() + threading.Thread(target=lambda ts, ss: ([t.join() for t in ts], [s.close() for s in ss]), + args=(pumps, (a, b)), daemon=True).start() + + +def _reachable(url): + """``url`` as a container reaches it.""" + u = urlsplit(url) + if u.hostname not in ("127.0.0.1", "localhost"): + return url + port = u.port + gateway = subprocess.run(["docker", "network", "inspect", "bridge", "-f", "{{(index .IPAM.Config 0).Gateway}}"], + capture_output=True, text=True).stdout.strip() + try: + server = socket.create_server((gateway, 0)) if gateway else None + except OSError: # Docker Desktop: the name reaches this machine's loopback itself + server = None + if server: + port = server.getsockname()[1] + threading.Thread(target=_accept, args=(server, (u.hostname, u.port)), daemon=True).start() + return urlunsplit((u.scheme, f"host.docker.internal:{port}", u.path, u.query, u.fragment)) + + +def _remove(compose): + """The containers and networks of the compose project whose file is this unit's.""" + ids = subprocess.run(["docker", "ps", "-aq", "--filter", "label=com.docker.compose.project.config_files=" + compose], + capture_output=True, text=True).stdout.split() + if not ids: + return + projects = set(subprocess.run(["docker", "inspect", "-f", '{{index .Config.Labels "com.docker.compose.project"}}', *ids], + capture_output=True, text=True).stdout.split()) + subprocess.run(["docker", "rm", "-f", "-v", *ids], capture_output=True) + for p in projects: + nets = subprocess.run(["docker", "network", "ls", "-q", "--filter", "label=com.docker.compose.project=" + p], + capture_output=True, text=True).stdout.split() + if nets: + subprocess.run(["docker", "network", "rm", *nets], capture_output=True) + + +def _watch(compose): + while os.read(0, 4096): + pass + os.kill(os.getpid(), signal.SIGINT) + threading.Event().wait(CLEANUP_SECONDS) + _remove(compose) + os._exit(1) + + +def main(): + compose, args = sys.argv[1], sys.argv[2:] + threading.Thread(target=_watch, args=(compose,), daemon=True).start() + from clawmark import main as cli + if args[:1] == ["--nop"]: + args = args[1:] + from clawmark.sandbox.base import ExecResult + + class NoAgent(cli.Orchestrator): + async def _send_to_agent(self, **_): + return ExecResult(stdout="", stderr="", return_code=0) + + cli.Orchestrator = NoAgent + else: + os.environ["ANTHROPIC_API_BASE"] = _reachable(os.environ["ANTHROPIC_API_BASE"]) + sys.argv = ["clawmark", *args] + try: + cli.main() + except KeyboardInterrupt: + sys.exit(130) + finally: + _remove(compose) + + +if __name__ == "__main__": + main() diff --git a/app/nullius/catalogue/benchmarks/clawmark/standard.json b/app/nullius/catalogue/benchmarks/clawmark/standard.json new file mode 100644 index 000000000..8a2388a6d --- /dev/null +++ b/app/nullius/catalogue/benchmarks/clawmark/standard.json @@ -0,0 +1,346 @@ +{ + "schema": "nullius.benchmark/v1", + "key": "clawmark", + "label": "ClawMark", + "summary": "Each task is one to five working days of an office job: files, mail, calendar, Notion and Sheets change between days, and the task's own checkers score each day.", + "family": "agent", + "needs": [], + "upstream": { + "repository": "https://github.com/evolvent-ai/ClawMark", + "tested": "d1b641b3171e584e69a3763c269069f32a13b574", + "tested_date": "2026-11-25", + "license": "CC-BY-NC-4.0" + }, + "driver": { + "command": [ + "{install}/.venv/bin/python", + "{here}/driver.py", + "{here}/runner.py" + ], + "install": { + "python": "3.12", + "pip": [ + "annotated-types==0.7.0", + "anyio==4.12.1", + "caldav==3.1.0", + "certifi==2026.2.25", + "cffi==2.0.0", + "charset-normalizer==3.4.6", + "click==8.3.1", + "cryptography==46.0.5", + "dnspython==2.8.0", + "google-api-core==2.30.0", + "google-api-python-client==2.193.0", + "google-auth-httplib2==0.3.0", + "google-auth==2.49.1", + "googleapis-common-protos==1.73.0", + "greenlet==3.3.2", + "h11==0.16.0", + "httpcore==1.0.9", + "httplib2==0.31.2", + "httpx==0.28.1", + "icalendar-searcher==1.0.5", + "icalendar==7.0.3", + "idna==3.11", + "jh2==5.0.10", + "lxml==6.0.2", + "markdown-it-py==4.0.0", + "mdurl==0.1.2", + "niquests==3.18.2", + "playwright==1.58.0", + "proto-plus==1.27.1", + "protobuf==6.33.6", + "pyasn1-modules==0.4.2", + "pyasn1==0.6.3", + "pycparser==3.0", + "pydantic-core==2.41.5", + "pydantic==2.12.5", + "pyee==13.0.1", + "pygments==2.19.2", + "pyparsing==3.3.2", + "python-dateutil==2.9.0.post0", + "python-dotenv==1.2.2", + "pyyaml==6.0.3", + "qh3==1.7.0", + "recurring-ical-events==3.8.1", + "requests==2.32.5", + "rich==14.3.3", + "six==1.17.0", + "typing-extensions==4.15.0", + "typing-inspection==0.4.2", + "tzdata==2025.3", + "uritemplate==4.2.0", + "urllib3-future==2.17.903", + "urllib3==2.6.3", + "wassima==2.0.5", + "x-wr-timezone==2.0.1" + ] + } + }, + "datasets": [ + { + "id": "no_accounts", + "label": "No accounts", + "summary": "The 3 tasks that need no Notion or Google account.", + "units": 3 + }, + { + "id": "no_google", + "label": "No Google account", + "summary": "The 13 tasks that need no Google account; 10 need Notion.", + "units": 13, + "environment": "notion" + }, + { + "id": "all", + "label": "All tasks", + "summary": "The 100 tasks of the leaderboard: Notion and Google accounts.", + "units": 100, + "environment": "accounts" + }, + { + "id": "clinical_assistant", + "label": "Clinical assistant", + "summary": "The upstream's tasks/clinical_assistant.", + "units": 4, + "environment": "accounts" + }, + { + "id": "content_operation", + "label": "Content operation", + "summary": "The upstream's tasks/content_operation.", + "units": 12, + "environment": "accounts" + }, + { + "id": "ecommerce", + "label": "E-commerce", + "summary": "The upstream's tasks/ecommerce.", + "units": 9, + "environment": "accounts" + }, + { + "id": "eda", + "label": "EDA", + "summary": "The upstream's tasks/eda.", + "units": 1 + }, + { + "id": "executive_assistant", + "label": "Executive assistant", + "summary": "The upstream's tasks/executive_assistant.", + "units": 7, + "environment": "accounts" + }, + { + "id": "hr", + "label": "HR", + "summary": "The upstream's tasks/hr.", + "units": 11, + "environment": "accounts" + }, + { + "id": "insurance", + "label": "Insurance", + "summary": "The upstream's tasks/insurance.", + "units": 7, + "environment": "accounts" + }, + { + "id": "investment_analyst", + "label": "Investment analyst", + "summary": "The upstream's tasks/investment_analyst.", + "units": 6, + "environment": "accounts" + }, + { + "id": "journalist", + "label": "Journalist", + "summary": "The upstream's tasks/journalist.", + "units": 8, + "environment": "accounts" + }, + { + "id": "legal_assistant", + "label": "Legal assistant", + "summary": "The upstream's tasks/legal_assistant.", + "units": 6, + "environment": "accounts" + }, + { + "id": "pm", + "label": "Product management", + "summary": "The upstream's tasks/pm.", + "units": 8, + "environment": "accounts" + }, + { + "id": "real_estate", + "label": "Real estate", + "summary": "The upstream's tasks/real_estate.", + "units": 6, + "environment": "accounts" + }, + { + "id": "research_assistant", + "label": "Research assistant", + "summary": "The upstream's tasks/research_assistant.", + "units": 15, + "environment": "accounts" + } + ], + "units": { + "noun": "task", + "nouns": "tasks" + }, + "environments": { + "notion": { + "summary": "A Notion workspace.", + "dockerfile": "env/accounts.Dockerfile", + "local_ok": true, + "needs_secrets": [ + { + "name": "NOTION_ADMIN_KEY", + "to": "driver", + "summary": "The ClawMark Admin integration's secret of a Notion workspace made for this." + }, + { + "name": "NOTION_AGENT_KEY", + "to": "driver", + "summary": "The ClawMark Agent integration's secret; the agent gets it." + } + ] + }, + "accounts": { + "summary": "A Notion workspace and a Google account.", + "dockerfile": "env/accounts.Dockerfile", + "local_ok": true, + "needs_secrets": [ + { + "name": "NOTION_ADMIN_KEY", + "to": "driver", + "summary": "The ClawMark Admin integration's secret of a Notion workspace made for this." + }, + { + "name": "NOTION_AGENT_KEY", + "to": "driver", + "summary": "The ClawMark Agent integration's secret; the agent gets it." + }, + { + "name": "GOOGLE_CREDENTIALS", + "to": "driver", + "kind": "file", + "env": "GOOGLE_CREDENTIALS_PATH", + "summary": "The google_credentials.json that ClawMark's scripts/google_auth.py writes, of an account made for this; the agent gets it." + } + ] + } + }, + "score": { + "kind": "score", + "says": "ClawMark's own score in result.json: the weight of the task's checkers that passed, over all of them, 0 to 1; the upstream's score is the mean" + }, + "limits": { + "score_seconds": 14400, + "call_seconds": 2100 + }, + "setups": { + "original": { + "summary": "ClawMark's own CLI: OpenClaw 2026.3.31 in the upstream's container, with its skills and prompts.", + "reference_agent": "OpenClaw", + "providers": { + "anthropic": "", + "openrouter": "", + "custom": "" + }, + "apis": [ + "messages", + "chat" + ], + "turn_seconds": 43200, + "paper": "the ClawMark leaderboard (README): the mean score over 100 tasks" + } + }, + "options": { + "api_format": { + "label": "API format", + "summary": "The protocol OpenClaw calls the model with (API_FORMAT).", + "values": [ + "anthropic", + "openrouter" + ], + "names": { + "anthropic": "Anthropic Messages", + "openrouter": "OpenAI Chat Completions" + }, + "default": "anthropic", + "setups": [ + "original" + ], + "about": { + "anthropic": "upstream default", + "openrouter": "for models served over chat completions only; not with the Anthropic provider" + } + }, + "model_inputs": { + "label": "Model inputs", + "summary": "What OpenClaw may send the model (--model-inputs).", + "values": [ + "text_image", + "text" + ], + "names": { + "text_image": "Text and images", + "text": "Text only" + }, + "default": "text_image", + "setups": [ + "original" + ], + "about": { + "text_image": "upstream default", + "text": "for models that take no images" + } + }, + "sandbox": { + "label": "Containers", + "step": "where", + "summary": "Where each task's containers run.", + "values": [ + "docker" + ], + "names": { + "docker": "Docker" + }, + "default": "docker", + "setups": [ + "original" + ], + "needs": { + "docker": { + "host": [ + "docker" + ] + } + } + } + }, + "host": { + "docker": { + "label": "Docker", + "summary": "Docker without sudo, with Compose 2.20 or later.", + "check": [ + "docker" + ] + } + }, + "controls": { + "nop": { + "source": "nullius", + "from": "ClawMark's orchestrator with an agent that does nothing; every stage is checked.", + "expect": { + "at_most": 0.1 + } + } + } +} diff --git a/app/nullius/catalogue/benchmarks/clawmark/upstream-settings.json b/app/nullius/catalogue/benchmarks/clawmark/upstream-settings.json new file mode 100644 index 000000000..6c5deda29 --- /dev/null +++ b/app/nullius/catalogue/benchmarks/clawmark/upstream-settings.json @@ -0,0 +1,198 @@ +[ + { + "entry": "clawmark (src/clawmark/main.py)", + "setting": "--task", + "values": "a task folder", + "default": "none", + "nullius": "fixed:the unit's task - one unit is one task" + }, + { + "entry": "clawmark (src/clawmark/main.py)", + "setting": "--tasks-dir", + "values": "a folder of task folders", + "default": "tasks", + "nullius": "dataset:all" + }, + { + "entry": "clawmark (src/clawmark/main.py)", + "setting": "--compose-file", + "values": "a compose file", + "default": "docker/docker-compose.yaml", + "nullius": "fixed:a file that includes the upstream's - its images pinned by digest, and host.docker.internal for the relay" + }, + { + "entry": "clawmark (src/clawmark/main.py)", + "setting": "--results-dir", + "values": "a folder", + "default": "results", + "nullius": "fixed:the unit's folder - the trial keeps it" + }, + { + "entry": "clawmark (src/clawmark/main.py)", + "setting": "--dry-run", + "values": "on, off", + "default": "off", + "nullius": "not offered - it exercises the framework with no containers and no agent" + }, + { + "entry": "clawmark (src/clawmark/main.py)", + "setting": "--openclaw-config", + "values": "a YAML file", + "default": "configs/openclaw.yaml", + "nullius": "fixed:configs/openclaw.yaml - the upstream's default" + }, + { + "entry": "clawmark (src/clawmark/main.py)", + "setting": "--model-inputs", + "values": "text, image", + "default": "text image", + "nullius": "option:model_inputs" + }, + { + "entry": "clawmark (src/clawmark/main.py)", + "setting": "ANTHROPIC_API_KEY", + "values": "a key", + "default": "none", + "nullius": "fixed:the relay's placeholder - the key stays in the relay" + }, + { + "entry": "clawmark (src/clawmark/main.py)", + "setting": "ANTHROPIC_API_BASE", + "values": "an endpoint", + "default": "https://api.anthropic.com", + "nullius": "fixed:the unit's relay - every model call goes through it" + }, + { + "entry": "clawmark (src/clawmark/main.py)", + "setting": "MODEL", + "values": "a model", + "default": "claude-sonnet-4-5-20250929", + "nullius": "setup:original" + }, + { + "entry": "clawmark (src/clawmark/main.py)", + "setting": "API_FORMAT", + "values": "anthropic, openrouter", + "default": "anthropic", + "nullius": "option:api_format" + }, + { + "entry": "clawmark (src/clawmark/main.py)", + "setting": "attempts per task", + "values": "a number", + "default": "1; the leaderboard averages 3", + "nullius": "not offered - no flag upstream: the run's own Attempts" + }, + { + "entry": "src/clawmark/orchestrator.py", + "setting": "contextWindow", + "values": "tokens", + "default": "200000", + "nullius": "fixed:200000 - hard-coded" + }, + { + "entry": "src/clawmark/orchestrator.py", + "setting": "maxTokens", + "values": "tokens", + "default": "16384", + "nullius": "fixed:16384 - hard-coded" + }, + { + "entry": "src/clawmark/orchestrator.py", + "setting": "reasoning", + "values": "true, false", + "default": "true", + "nullius": "fixed:true - hard-coded" + }, + { + "entry": "src/clawmark/orchestrator.py", + "setting": "stage timeout", + "values": "seconds", + "default": "7200", + "nullius": "fixed:7200 - hard-coded in task_loader.py, whatever METADATA says" + }, + { + "entry": "src/clawmark/orchestrator.py", + "setting": "tool call ID sanitization", + "values": "patched, as shipped", + "default": "patched with API_FORMAT=openrouter", + "nullius": "fixed:the upstream's - it follows the API format" + }, + { + "entry": "src/clawmark/orchestrator.py", + "setting": "skills", + "values": "the folders of skills/", + "default": "all four", + "nullius": "fixed:all four - hard-coded" + }, + { + "entry": "configs/openclaw.yaml", + "setting": "thinkingDefault", + "values": "an OpenClaw thinking level", + "default": "high", + "nullius": "fixed:high - the upstream's config" + }, + { + "entry": "configs/openclaw.yaml", + "setting": "llm.idleTimeoutSeconds", + "values": "seconds", + "default": "1800", + "nullius": "fixed:1800 - the upstream's config" + }, + { + "entry": "configs/openclaw.yaml", + "setting": "tools.exec.security", + "values": "an OpenClaw level", + "default": "full", + "nullius": "fixed:full - the upstream's config; the container is the sandbox" + }, + { + "entry": "src/clawmark/state/notion", + "setting": "NOTION_ADMIN_KEY, NOTION_AGENT_KEY", + "values": "integration secrets", + "default": "none", + "nullius": "fixed:the user's - credentials set in Settings" + }, + { + "entry": "src/clawmark/state/notion", + "setting": "NOTION_SOURCE_PAGE, NOTION_EVAL_PAGE", + "values": "page titles", + "default": "ClawMark Source Hub, ClawMark Eval Hub", + "nullius": "fixed:ClawMark Source Hub, ClawMark Eval Hub - the documented titles" + }, + { + "entry": "src/clawmark/state/notion", + "setting": "NOTION_STATE_FILE, NOTION_PLAYWRIGHT_HEADLESS", + "values": "a file; true, false", + "default": "notion_state.json, true", + "nullius": "not offered - only copy_page reads them, and no task calls it" + }, + { + "entry": "src/clawmark/state/google_sheets", + "setting": "GOOGLE_CREDENTIALS_PATH", + "values": "a file", + "default": "configs/google_credentials.json", + "nullius": "fixed:the user's - a credential set in Settings" + }, + { + "entry": "src/clawmark/state/email", + "setting": "EMAIL_IMAP_*, EMAIL_SMTP_*, EMAIL_USE_*", + "values": "a mail server", + "default": "the task's GreenMail", + "nullius": "fixed:the task's GreenMail - its ports override them" + }, + { + "entry": "src/clawmark/state/calendar", + "setting": "CALDAV_URL, CALDAV_USERNAME", + "values": "a CalDAV server", + "default": "the task's Radicale, benchmark", + "nullius": "fixed:the task's Radicale, benchmark - its defaults" + }, + { + "entry": "docker/docker-compose.yaml", + "setting": "http_proxy, https_proxy, no_proxy", + "values": "proxies", + "default": "unset", + "nullius": "fixed:this machine's - passed through" + } +] diff --git a/app/nullius/standard/cli.py b/app/nullius/standard/cli.py index 52a76db0d..953a3b69e 100644 --- a/app/nullius/standard/cli.py +++ b/app/nullius/standard/cli.py @@ -193,7 +193,7 @@ def cmd_list(a): print(definitions.KINDS[kind]["dir"] + ":") for d in got[kind]: side = d.get("needs") if kind == "benchmark" else d.get("offers") - print(f" {d.get('_ref') or d['key']:<18} {('needs ' if kind == 'benchmark' else 'offers ') + ', '.join(side or []) or 'nothing proven yet'}" + print(f" {d.get('_ref') or d['key']:<18} {'Original only' if kind == 'benchmark' and not side else ('needs ' if kind == 'benchmark' else 'offers ') + ', '.join(side or [])}" + (f" · {definitions.origin_of(d).capitalize()}" if kind != "capability" else "")) up = d.get("upstream") or {} if up.get("repository"): @@ -265,7 +265,7 @@ def cmd_fit(a): b = definitions.get("benchmark", a.benchmark) if not b: sys.exit(f"no benchmark {a.benchmark!r}") - print(f"{b['label']} ({b['family']} benchmark) needs: " + ", ".join(b["needs"])) + print(f"{b['label']} ({b['family']} benchmark) needs: " + (", ".join(b["needs"]) or "no port: it runs only as its Original setup")) for p in b["needs"]: print(f" {p}: {ports.PORTS[p]['summary']}") have = definitions.port_skills(p) diff --git a/app/nullius/standard/contract/definitions.py b/app/nullius/standard/contract/definitions.py index b46b623fc..a4588c63f 100644 --- a/app/nullius/standard/contract/definitions.py +++ b/app/nullius/standard/contract/definitions.py @@ -1244,7 +1244,7 @@ def _setups(s) -> List[str]: bad.append(f"{w}.summary: what runs, in a sentence") allowed = {"summary"} if k == "original": - allowed |= {"models", "default", "served_as", "providers", "side_models", "units", "turn_seconds", "paper", "comparable", "reference_agent"} + allowed |= {"models", "default", "served_as", "providers", "side_models", "units", "turn_seconds", "paper", "comparable", "reference_agent", "apis"} if "reference_agent" in x and (not isinstance(x["reference_agent"], str) or not x["reference_agent"].strip()): bad.append(f"{w}.reference_agent: the upstream agent's display name") models = x.get("models") @@ -1266,8 +1266,11 @@ def _setups(s) -> List[str]: if not isinstance(sa, dict) or not all(m in models + side and isinstance(v, str) and _MODEL_NAME.match(v) for m, v in sa.items()): bad.append(f"{w}.served_as: {{one of its models: the name the provider serves it as}}") pv = x.get("providers") - if not isinstance(pv, dict) or not pv or not all(p in ("openrouter", "openai", "custom") and isinstance(v, str) for p, v in pv.items()): - bad.append(f"{w}.providers: {{openrouter|openai|custom: the prefix its models' names carry there}}") + if not isinstance(pv, dict) or not pv or not all(p in ("openrouter", "openai", "anthropic", "custom") and isinstance(v, str) for p, v in pv.items()): + bad.append(f"{w}.providers: {{openrouter|openai|anthropic|custom: the prefix its models' names carry there}}") + ap = x.get("apis", ["chat"]) + if not isinstance(ap, list) or not ap or any(a not in APIS for a in ap): + bad.append(f"{w}.apis: some of {APIS}, what its code speaks (default chat)") u = x.get("units") if u is not None and (not isinstance(u, dict) or not all(isinstance(u.get(f), str) and u[f] for f in ("noun", "nouns"))): bad.append(f"{w}.units: {{noun, nouns}}, what one of its units is") @@ -1393,7 +1396,7 @@ def setup(bench: dict, which: str, model: str = "", provider: str = "", agent: s return None, f"the model setup needs a model: the one to put in {orig['default']}'s place" asked, sent = (mine["models"][0] if mine else x["runs_as"]), model # its own agent asks its own first model units = orig.get("units") or bench.get("units") or {"noun": "unit", "nouns": "units"} - return {**({"agent": mine["key"]} if mine else {}), "model": {"side_models": side}, "key": which, "label": f"{bench['label']} {setup_label(bench, which).lower()}", + return {**({"agent": mine["key"]} if mine else {}), "model": {"side_models": side, "apis": list(orig.get("apis") or ["chat"])}, "key": which, "label": f"{bench['label']} {setup_label(bench, which).lower()}", "summary": x["summary"], "asked": asked, "sent": sent, "units": units, "comparable": which == "original" and comparable(x, model), "turn_seconds": orig.get("turn_seconds"), "upstream": {}, "_kind": "upstream", "_ref": which, "_here": bench.get("_here", "")}, "" @@ -1573,8 +1576,8 @@ def problems(d: dict, kind: str) -> List[str]: bad.append(f"family: one of {FAMILIES}") needs = d.get("needs") bad += _ports("needs", needs, d.get("family")) - if isinstance(needs, list) and not needs: - bad.append("needs: at least one port") + if needs == [] and "original" not in (d.get("setups") or {}): + bad.append("needs: at least one port, or an original setup to run as") bad += _host(d) bad += _files(d) bad += _bench_options(d) diff --git a/app/nullius/standard/contract/match.py b/app/nullius/standard/contract/match.py index 6f43d683d..0a3ffa792 100644 --- a/app/nullius/standard/contract/match.py +++ b/app/nullius/standard/contract/match.py @@ -40,6 +40,8 @@ def fit(bench: dict, other: dict) -> List[str]: return [f"{name} is the reference agent of {', '.join(only)}, and runs no other benchmark"] if "driver" in (other.get("start") or {}): # its benchmark's driver runs it: no port to prove return [] + if not bench.get("needs"): + return [f"{bench['label']} runs only as its Original setup"] why = [] for p in bench.get("needs") or []: on = str((proven.get(p) or {}).get("version") or "") diff --git a/app/nullius/standard/pages/recipe.py b/app/nullius/standard/pages/recipe.py index af163bfb3..e81f0cc70 100644 --- a/app/nullius/standard/pages/recipe.py +++ b/app/nullius/standard/pages/recipe.py @@ -175,7 +175,7 @@ def _bench_page(b: dict) -> dict: "controls": controls, # One Original procedure, with separate reference-participant and paper-model metadata. "setups": [{"key": k, "label": definitions.setup_label(b, k), "summary": x["summary"], - "reference_agent": x.get("reference_agent", ""), "turn_seconds": x.get("turn_seconds"), + "reference_agent": x.get("reference_agent", ""), "turn_seconds": x.get("turn_seconds"), "apis": list(x.get("apis") or ["chat"]), "comparable": k == "original" and b["setups"]["original"].get("comparable", True) is not False, "units": (b["setups"]["original"].get("units") or b.get("units") or {}), **({"models": definitions.paper_models(x), "default": x["default"], "providers": list(x["providers"]), "sent": {p: {m: pre + (x.get("served_as") or {}).get(m, m) for m in definitions.paper_models(x)} @@ -595,7 +595,7 @@ def add(step, message, shown=False, field=None, unset=False): if provider not in PROVIDERS: add("model", CHOOSE_PROVIDER) # what each part asks of the provider, as the builder reads it (command-builder-core.js, consumersOf): an agent its - # apis, a setup chat; a judged benchmark's judge chat + # apis, a setup its own (chat by default); a judged benchmark's judge chat for pk in picks if provider in PROVIDERS else (): apis = None if pk["control"] else (pk["o"].get("model") or {}).get("apis") or ["chat"] if apis and provider not in providers.offered(apis): @@ -924,7 +924,7 @@ def row(p: dict) -> list: return [STEP["agent"], "Participant", label] proven = ", ".join(f"{q} {r.get('passed', '')}".strip() for q, r in (o.get("proven") or {}).items() if q in b["needs"]) return [STEP["agent"], "Agent" if side == "agent" else "Capability", f"{o['label']} · {protocol(o)} · proven {proven}"] - out["review"] = [[STEP["benchmark"], "Benchmark", f"{b['label']} · needs {', '.join(b['needs'])}"], + out["review"] = [[STEP["benchmark"], "Benchmark", b["label"] + (f" · needs {', '.join(b['needs'])}" if b["needs"] else "")], [STEP["runner"], "Runner", "Nullius"], [STEP["dataset"], "Datasets" if many else "Dataset", ", ".join(f"{x.get('label') or x['id']}" + (f" · {x['units']} {bench_nouns}" if x.get("units") else "") for x in dss)], diff --git a/app/static/builder/command-builder-core.js b/app/static/builder/command-builder-core.js index d3fa7ce7d..31a2ee75a 100644 --- a/app/static/builder/command-builder-core.js +++ b/app/static/builder/command-builder-core.js @@ -318,12 +318,12 @@ const needsOf = c => endpointOf(c) ? 'MODEL_' + endpointOf(c) + '_API_URL' : PROVIDER_NEEDS[c] || PROVIDER_NEEDS.custom; const available = () => ((schema.credentials || {}).available || []).filter(p => PROVIDERS.includes(kindOf(p))); const firstAvailable = (offered, otherwise) => available().find(p => offered.includes(p)) || otherwise; - // What each part of a run that calls the model speaks: a Harbor run and a benchmark's own scripts or judge - // chat, an agent of the standard its definition's apis. A provider is offered when it may serve every part. + // What each part of a run that calls the model speaks: a Harbor run and a benchmark's judge chat, its own + // scripts their setup's apis, an agent of the standard its definition's apis. A provider is offered when it may serve every part. function consumersOf(r) { if (!isStandard(r)) return [['chat']]; const b = standardBench(r), all = standard().agents.concat(standard().capabilities); - const out = chosenOf(r).filter(k => !((b && b.controls) || []).some(c => c.key === k)).map(k => (all.find(o => o.key === k) || {}).apis || ['chat']); + const out = chosenOf(r).filter(k => !((b && b.controls) || []).some(c => c.key === k)).map(k => (all.find(o => o.key === k) || ((b && b.setups) || []).find(x => x.key === k) || {}).apis || ['chat']); if (b && b.judged) out.push(['chat']); return out.length ? out : [['chat']]; } diff --git a/app/static/catalogue/marks.svg b/app/static/catalogue/marks.svg index dce84e25b..9b7ff5aa3 100644 --- a/app/static/catalogue/marks.svg +++ b/app/static/catalogue/marks.svg @@ -33,6 +33,10 @@ + + + + diff --git a/app/tests/test_catalog.py b/app/tests/test_catalog.py index fd792c27f..0fb6041fd 100644 --- a/app/tests/test_catalog.py +++ b/app/tests/test_catalog.py @@ -33,7 +33,7 @@ def test_shipped_catalogue_is_consistent(self): self.assertEqual(titles, sorted(titles, key=catalog.sort_key)) # what has a usable route is listed, whoever made it and whether or not it has run listed = {x.key for x in cat.listed_benchmarks} - self.assertEqual(sorted(listed), ["gaia", "gsm8k", "humaneval", "locomo", "longmemeval", "open-telco", "osworld1", "osworld2", "swe-bench-verified", "tau3-bench", "terminal-bench"]) + self.assertEqual(sorted(listed), ["clawmark", "gaia", "gsm8k", "humaneval", "locomo", "longmemeval", "open-telco", "osworld1", "osworld2", "swe-bench-verified", "tau3-bench", "terminal-bench"]) self.assertEqual((cat.benchmark("longmemeval").origin, cat.benchmark("longmemeval").label), ("official", "Official")) self.assertEqual(cat.benchmark("tau3-bench").label, "Official") # τ³ files as "t3…", before "te…": a reader looking under T finds it diff --git a/app/tests/test_clawmark_driver.py b/app/tests/test_clawmark_driver.py new file mode 100644 index 000000000..f83595997 --- /dev/null +++ b/app/tests/test_clawmark_driver.py @@ -0,0 +1,116 @@ +"""ClawMark's driver: a task its framework could not run is no score, a credential stays out of what a trial +keeps, and a stopped unit leaves neither its runner nor its containers. A fake ``docker`` on PATH stands in.""" +from __future__ import annotations + +import importlib.util +import json +import os +import subprocess +import sys +import tempfile +import time +import unittest +from unittest import mock + +HERE = os.path.join(os.path.dirname(os.path.dirname(os.path.abspath(__file__))), + "nullius", "catalogue", "benchmarks", "clawmark") + + +def load(up): + spec = importlib.util.spec_from_file_location("clawmark_driver", os.path.join(HERE, "driver.py")) + module = importlib.util.module_from_spec(spec) + with mock.patch.object(sys, "argv", ["driver.py", os.path.join(HERE, "runner.py")]), \ + mock.patch.object(sys, "path", list(sys.path)), mock.patch.dict(os.environ, NULLIUS_UPSTREAM=up): + spec.loader.exec_module(module) + return module + + +def stage(id, success=True, error="", checks=()): + v = [{"id": c, "passed": p, "weight": 1.0} for c, p in checks] + return {"id": id, "success": success, "error": error, "verification": v, + "verification_score": sum(x["passed"] for x in v) / len(v) if v else -1.0} + + +class Score(unittest.TestCase): + def setUp(self): + tmp = tempfile.TemporaryDirectory() + self.addCleanup(tmp.cleanup) + self.dir = tmp.name + self.driver = load(tmp.name) + + def scored(self, *stages, score=0.5, log=""): + out = os.path.join(self.dir, "results", "m", "t") + os.makedirs(out) + rubric = [v for s in stages for v in s["verification"]] + with open(os.path.join(out, "result.json"), "w") as f: + json.dump({"task_id": "t", "score": score, "stages": list(stages), "rubric": rubric}, f) + with open(os.path.join(self.dir, "clawmark.log"), "w") as f: + f.write(log) + return self.driver.score(unit="eda__task1", dir=self.dir, setup="original") + + def test_the_upstreams_score_with_its_checks(self): + got = self.scored(stage("stage0", checks=[("A", True), ("B", False)]), + log="12:00:00 ERROR clawmark: Checker 'B' raised: no sheet\n") + self.assertEqual(got["reward"], 0.5) + self.assertEqual((got["detail"]["checks_passed"], got["detail"]["checks_failed"], got["detail"]["checks_raised"]), + ("1 of 2", ["B"], ["B"])) + + def test_an_agents_failed_stage_is_scored(self): + got = self.scored(stage("stage0", success=False, error="the agent exited 1", checks=[("A", False)]), score=0.0) + self.assertEqual(got["reward"], 0.0) + + def test_a_stage_the_framework_could_not_run_is_no_score(self): + with self.assertRaisesRegex(Exception, "could not run stage1: Notion API"): + self.scored(stage("stage0", checks=[("A", True)]), stage("stage1", success=False, error="Notion API error 401"), score=1.0) + + def test_no_result_is_no_score(self): + with self.assertRaisesRegex(Exception, "no result.json"): + self.driver.score(unit="eda__task1", dir=self.dir, setup="original") + + def test_a_credential_the_agent_repeated_is_not_kept(self): + google = os.path.join(self.dir, "google.json") + with open(google, "w") as f: + json.dump({"refresh_token": "made-up-refresh"}, f) + kept = os.path.join(self.dir, "results") + os.makedirs(kept) + with open(os.path.join(kept, "messages.jsonl"), "w") as f: + f.write("made-up-notion made-up-refresh words") + self.driver._redact(kept, self.driver._hidden({"NOTION_AGENT_KEY": "made-up-notion", "GOOGLE_CREDENTIALS_PATH": google})) + with open(os.path.join(kept, "messages.jsonl")) as f: + self.assertEqual(f.read(), "[redacted] [redacted] words") + + +class Stop(unittest.TestCase): + def test_the_runner_ends_once_its_driver_is_gone_and_removes_the_units_containers(self): + with tempfile.TemporaryDirectory() as d: + os.makedirs(os.path.join(d, "clawmark", "sandbox")) + open(os.path.join(d, "clawmark", "__init__.py"), "w").close() + with open(os.path.join(d, "clawmark", "main.py"), "w") as f: + f.write("import asyncio, sys\n" + "async def run():\n" + " try:\n print('started', flush=True)\n await asyncio.sleep(60)\n" + " finally:\n print('cleaned up', flush=True)\n" + "def main():\n asyncio.run(run())\n") + fake = os.path.join(d, "docker") + with open(fake, "w") as f: + f.write(f'#!/bin/sh\necho "$*" >> {d}/asked\n[ "$1" = ps ] && echo cid1\n[ "$1" = inspect ] && echo proj\nexit 0\n') + os.chmod(fake, 0o755) + env = dict(os.environ, PATH=d + os.pathsep + os.environ["PATH"], PYTHONPATH=d, ANTHROPIC_API_BASE="https://example.org") + p = subprocess.Popen([sys.executable, os.path.join(HERE, "runner.py"), "/unit/compose.yaml"], env=env, + stdin=subprocess.PIPE, stdout=subprocess.PIPE, text=True, start_new_session=True) + self.addCleanup(p.kill) + self.assertEqual(p.stdout.readline(), "started\n") + t0 = time.time() + p.stdin.close() + self.assertEqual(p.stdout.read(), "cleaned up\n") + self.assertEqual(p.wait(30), 130) + p.stdout.close() + self.assertLess(time.time() - t0, 30) + with open(os.path.join(d, "asked")) as f: + asked = f.read() + self.assertIn("label=com.docker.compose.project.config_files=/unit/compose.yaml", asked) + self.assertIn("rm -f -v cid1", asked) + + +if __name__ == "__main__": + unittest.main() diff --git a/app/tests/test_standard_definitions.py b/app/tests/test_standard_definitions.py index 6d44e5f00..762966e79 100644 --- a/app/tests/test_standard_definitions.py +++ b/app/tests/test_standard_definitions.py @@ -121,6 +121,24 @@ def test_an_example_is_marked_true_or_false_on_an_agent_or_a_feature(self): def test_unknown_port_is_named_and_one_of_the_other_family_refused(self): self.bad(BENCH, "benchmark", lambda d: d["needs"].append("agent.telepathy/v1"), "'agent.telepathy/v1' is not a port") self.bad(BENCH, "benchmark", lambda d: d["needs"].append("cap.memory/v1"), "not the agent") + self.bad(BENCH, "benchmark", lambda d: d.update(needs=[]), "needs: at least one port, or an original setup") + alone = dict(BENCH, needs=[], setups={"original": {"summary": "Its own agent.", "providers": {"openrouter": ""}}}) + self.assertEqual(definitions.problems(alone, "benchmark"), []) + self.assertEqual(match.fit(alone, loaded(AGENT, "agent")), ["Toy runs only as its Original setup"]) + self.assertEqual(match.fit(alone, {"_kind": "upstream", "key": "original"}), []) + + def test_an_original_setup_says_what_it_speaks(self): + from nullius.standard.runner import run + bench = dict(BENCH, setups={"original": {"summary": "Its own agent.", "providers": {"anthropic": ""}}}) + orig, _ = definitions.setup(bench, "original", "m", "anthropic") + with self.assertRaises(run.Refused): # chat by default, which Anthropic does not serve + run.key_header("anthropic", orig, {}) + bench["setups"]["original"]["apis"] = ["messages", "chat"] + self.assertEqual(definitions.problems(bench, "benchmark"), []) + orig, _ = definitions.setup(bench, "original", "m", "anthropic") + self.assertEqual(run.key_header("anthropic", orig, {}), "x-api-key") + self.bad(BENCH, "benchmark", lambda d: d.update(setups={"original": {"summary": "x", "providers": {"openrouter": ""}, "apis": ["fax"]}}), + "setups.original.apis: some of") def test_shell_in_a_command_is_refused(self): self.bad(BENCH, "benchmark", lambda d: d["driver"].update(command=["sh", "-c", "rm -rf ~"]), "is not a plain word") diff --git a/app/tests/test_standard_setups.py b/app/tests/test_standard_setups.py index 1557fe0d5..3b3a4437c 100644 --- a/app/tests/test_standard_setups.py +++ b/app/tests/test_standard_setups.py @@ -294,9 +294,12 @@ def compiled(self, **kw): r.update(**kw) return recipe.compile(r) - def test_a_setup_and_a_judge_need_a_provider_that_serves_chat(self): + def test_a_setup_and_a_judge_need_a_provider_that_serves_what_they_speak(self): said = [e["message"] for e in self.compiled(others=["original"], provider="anthropic", model="claude-x")["errors"]] self.assertIn("Anthropic does not serve what LoCoMo original speaks: choose another provider.", said) + said = [e["message"] for e in self.compiled(others=["original"], benchmark="clawmark", datasets=["no_accounts"], + provider="anthropic", model="claude-x")["errors"]] # its setup speaks messages + self.assertFalse([m for m in said if "does not serve" in m], said) said = [e["message"] for e in self.compiled(others=["nop"], benchmark="longmemeval", datasets=["longmemeval_s"], provider="anthropic")["errors"]] self.assertIn("Anthropic does not serve what LongMemEval's judge speaks: choose another provider.", said) diff --git a/app/ui_tests/test_builder_where.py b/app/ui_tests/test_builder_where.py index 00fbb0355..e1fd48460 100644 --- a/app/ui_tests/test_builder_where.py +++ b/app/ui_tests/test_builder_where.py @@ -87,7 +87,7 @@ def test_a_benchmark_booting_its_own_vms_asks_no_isolation_and_refuses_a_size_to self.assertNotIn("cannot run in a Boat VM", nop["osworld1 boat"]) self.assertNotIn("cannot run in a Boat VM", nop["osworld2 boat"]) # an agent's run still asks the yes to running as you: its process is on the machine, only the desktop in a VM - agent = self.draw(None, "r.others=[C.standardOthers(r).find(o=>!o.setup&&!o.control&&!o.why.length).key];")["osworld1 local"] + agent = self.draw(None, "r.others=[(C.standardOthers(r).find(o=>!o.setup&&!o.control&&!o.why.length)||{key:'original'}).key];")["osworld1 local"] self.assertIn("data-std-unsandboxed", agent) self.assertNotRegex(agent, r"data-std-unsandboxed[^>]*checked") # never ticked for the person self.assertIn('class="nb-field nb-consent">]*data-std-backend="container"[^>]*>', html).group(0) self.assertIn('title="Not on this machine: docker is not installed"', tile) self.assertEqual(html.count("Not on this machine"), 1) + if name.split()[0] == "clawmark": # its original starts the task's containers itself + self.assertIn('title="Docker cannot be provided in a container: choose local processes."', here[name]) + continue self.assertNotIn("disabled", re.search(r'