Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion app/nullius/catalogue/agents/mini-swe-agent/agent.json
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,7 @@
},
"only_for": [
"swe-bench-verified",
"swe-bench-multilingual"
"swe-bench-multilingual",
"swe-bench-pro"
]
}
91 changes: 91 additions & 0 deletions app/nullius/catalogue/benchmarks/swe-bench-pro/benchmark.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,91 @@
{
"key": "swe-bench-pro",
"title": "SWE-bench Pro",
"category": "Coding",
"domain": "Software engineering: change a real repository as a pull request describes, so its hidden tests pass.",
"scoring": "Tests",
"harness": [
"standard"
],
"origin": "official",
"good_to_know": [
"Agents work with no internet and their web tools off, as the authors' locked protocol requires. Its commands use high reasoning effort: set the same to compare.",
"Each task gives the agent 50 minutes. A task cut there is still scored on what the agent changed, except with mini-swe-agent.",
"V2 scores do not compare with v1 numbers: 89 tasks were dropped, 529 statements rewritten and the tests revised.",
"Harbor's hub (scale-ai/swe-bench-pro) and registry (swebenchpro@1.0) hold the 731 v1 tasks; V2 on Harbor needs flags the builder cannot pass.",
"Each task's container gets 1 CPU and 4 GB of memory. The images are 0.5 to 6.5 GB each to download, 544 GB for all 642, and more once unpacked."
],
"upstream_limitations": [
"The images are linux/amd64 only.",
"The authors flag one timing-sensitive test, in ansible 40ade1f8, a HARD-51 task.",
"The authors' capture of the agent's diff compares the repository with HEAD: it misses what an agent commits and includes files an image left untracked."
],
"limitations": [
"The tests run in the container the agent worked in. The authors' authoritative score re-grades the agent's diff on a fresh image; Nullius keeps the diff as verifier/model.patch and does not re-grade.",
"mini-swe-agent runs mini's own config with no cost limit, where the protocol's file adds high effort, a named model class and its own error template; a task cut at 50 minutes is its timeout and not scored, where the protocol grades its diff.",
"The tests reach the internet through an HTTP and HTTPS proxy to public addresses, where the protocol gives them open access.",
"Tasks of element-web, navidrome, openlibrary, teleport, tutanota, vuls and webclients have not been run through Nullius."
],
"datasets": [
{
"key": "swe-bench-pro-v2",
"title": "V2",
"tasks": 642,
"official": "https://github.com/scaleapi/SWE-bench_Pro-os",
"registry": "",
"hub": "",
"verifier": "The task's own tests, run after the agent stops: every fail-to-pass and pass-to-pass test must pass.",
"notes": "The validated public split, the authors' default: 642 tasks from 11 repositories.",
"source": "GitHub"
},
{
"key": "swe-bench-pro-hard51",
"title": "HARD-51",
"tasks": 51,
"official": "https://github.com/scaleapi/SWE-bench_Pro-os",
"registry": "",
"hub": "",
"verifier": "The task's own tests, run after the agent stops: every fail-to-pass and pass-to-pass test must pass.",
"notes": "The V2 tasks that at least two of five model families failed under the authors' protocol, minus three later found ambiguous: 51 tasks.",
"source": "GitHub"
}
],
"task_count": 642,
"records": [
{
"label": "Captured diff",
"path": "verifier/model.patch"
},
{
"label": "Test results",
"path": "verifier/output.json"
},
{
"label": "Test command output",
"path": "verifier/run-script-stdout.txt"
},
{
"label": "Test command errors",
"path": "verifier/run-script-stderr.txt"
}
],
"citation": "@article{deng2025swebenchpro,\n title={SWE-Bench Pro: Can AI Agents Solve Long-Horizon Software Engineering Tasks?},\n author={Deng, Xiang and Da, Jeff and Pan, Edwin and Sun, Yannis Yiming and Wu, Chen Bo Calvin and Bhutani, Sanyam and others},\n journal={arXiv preprint arXiv:2509.16941},\n year={2025}\n}",
"citation_source": "https://github.com/scaleapi/SWE-bench_Pro-os/blob/v2.0.0/v2/README.md",
"evidence": [
{
"label": "Why",
"path": "why"
},
{
"label": "Timed out",
"path": "timed_out",
"unless": [
"no"
]
},
{
"label": "Test output",
"path": "output"
}
]
}
173 changes: 173 additions & 0 deletions app/nullius/catalogue/benchmarks/swe-bench-pro/driver.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,173 @@
"""SWE-bench Pro V2's driver for the Nullius standard (JSON lines on stdin and stdout).

Each task is a folder of the upstream at its pinned commit, ``v2/tasks/<instance>``, in Harbor's
layout: ``instruction.md`` (the prompt), ``task.toml`` (its limits), ``environment/Dockerfile``
(``FROM`` the authors' prebuilt image), ``tests/`` (``test.sh``, which writes
``/logs/verifier/reward.txt``) and ``solution/`` (``solve.sh``, which applies the authors'
reference patch).

units - V2: every task the release's checksum list names; HARD-51: the ids of its list, in
the list's order
describe - the instruction as the task's text, the first line of its pull request description
as its title, and its repository (from the instance id) as a category
setup - the instruction as the prompt, verbatim; the task's own image (``image``: the
authors' prebuilt image, pulled by the digest its tag had when pinned here,
``images.json``, with the memory and CPUs its task.toml asks for); its own agent
timeout (``agent_seconds``, task.toml's agent.timeout_sec); and its check
(``verify``): once the agent has ended and what it left running is stopped,
``tests/`` is copied to ``/tests`` and the check runs in the task's container: the
locked protocol's own capture of the agent's diff (``v2/tooling``: the repository
against HEAD, kept as ``model.patch``), a reward file left before the tests
removed, as Harbor's verifier does, then ``test.sh``, with the way out task.toml
gives the verifier, its results collected from ``/logs/verifier``. The tests reach
the container only then; nothing is written into the workspace.
score - the reward test.sh wrote, read from what the check collected
oracle - the reference control: ``solution/`` copied to ``/solution`` and ``solve.sh`` run in
the task's container, as the agent would have worked

The driver never runs docker: the run does each step in the unit's container.
"""
import ast
import json
import os
import re
import sys
import tomllib

HERE = os.path.dirname(os.path.abspath(__file__))
TASKS = "v2/tasks" # the release's task folders, in the upstream
HARD51 = "swe-bench-pro-hard51" # the dataset whose file is an id list; the other's is the checksum list
LOGS = "/logs/verifier" # where test.sh writes its reward and its parsed results
CAPTURED = "/logs/agent/model.patch" # where the protocol's capture writes the agent's diff

# The authors' prebuilt image of each task (task.toml's environment.docker_image,
# ghcr.io/scaleapi/swe-bench_pro-v2:<instance>) with the digest its tag had when pinned here, as
# <name>:<tag>@sha256:<digest>: `cli pins` asks the registry what each tag names now.
with open(os.path.join(HERE, "images.json")) as f:
IMAGES = json.load(f)

_capture = None


def pull(reference):
"""A pin as ``image.pull`` takes it: by its digest alone. Its tag, the instance id, may hold capitals, which
the standard's reference does not allow, and the digest names the image without it."""
name, _, digest = reference.rpartition("@")
repo, colon, tag = name.rpartition(":")
return (repo if colon and "/" not in tag else name) + "@" + digest


def capture() -> str:
"""The locked protocol's capture of the agent's diff, as its agents run it once the agent has ended and before
the verifier: ``_CAPTURE`` of ``v2/tooling/locked_claude_code.py``, read from the upstream's source without
importing it (the module imports Harbor, which a driver that runs no Harbor does not have)."""
global _capture
if _capture is None:
with open(os.path.join(os.environ["NULLIUS_UPSTREAM"], "v2", "tooling", "locked_claude_code.py")) as f:
tree = ast.parse(f.read())
found = [ast.literal_eval(n.value) for n in tree.body
if isinstance(n, ast.Assign) and any(getattr(t, "id", "") == "_CAPTURE" for t in n.targets)]
if len(found) != 1 or not isinstance(found[0], str):
raise ValueError("v2/tooling/locked_claude_code.py: one _CAPTURE command was expected")
_capture = found[0]
return _capture


def task(unit):
"""The task's folder in the upstream and its task.toml."""
if unit not in IMAGES:
raise ValueError(f"{unit} is not a task of this benchmark's datasets")
here = os.path.join(os.environ["NULLIUS_UPSTREAM"], TASKS, unit)
with open(os.path.join(here, "task.toml"), "rb") as f:
return here, tomllib.load(f)


def ids(dataset):
"""The dataset's instance ids, from its file: HARD-51's list, one id a line; else the release's checksum
list (a digest and a path under v2/ a line), every task that has a task.toml."""
with open(os.environ["NULLIUS_DATASET"]) as f:
lines = [line.strip() for line in f if line.strip()]
if dataset == HARD51:
return lines
paths = (line.split(None, 1)[1].split("/") for line in lines)
return sorted(p[1] for p in paths if len(p) == 3 and p[0] == "tasks" and p[2] == "task.toml")


def units(dataset, **_):
return {"units": ids(dataset)}


def title(text):
"""A task's title for a listing: the first line of its pull request description that says something,
without its Markdown marks and a leading "Title:" or "Problem statement" (a line that is only that label is
passed over), up to a heading written on the same line."""
for line in text.split("<pr_description>", 1)[-1].splitlines():
line = re.sub(r"^(?:(?:issue\s+)?tit+le|problem\s+statement)\b[\s:*]*", "", line.strip().strip("#*\"' "), flags=re.I)
line = re.split(r"\s(?:#{2,}|\*\*)\s", line, maxsplit=1)[0].strip("#*\"' ")
if line:
return line
return ""


def describe(dataset, **_):
out = {}
for unit in ids(dataset):
here, _t = task(unit)
with open(os.path.join(here, "instruction.md")) as f:
text = f.read()
repo = re.match(r"instance_(.+?)__(.+)-[0-9a-f]{40}", unit)
out[unit] = {"title": title(text), "text": text.strip(),
"categories": {"repo": "/".join(repo.groups()) if repo else None}}
return {"units": out}


def setup(unit, dir):
here, t = task(unit)
with open(os.path.join(here, "instruction.md")) as f:
prompt = f.read()
env, verifier = t.get("environment") or {}, t.get("verifier") or {}
image = {"pull": pull(IMAGES[unit])}
if env.get("memory_mb"):
image["memory_mb"] = env["memory_mb"]
if env.get("cpus"):
image["cpus"] = env["cpus"]
agent = (t.get("agent") or {}).get("timeout_sec")
# the capture first, then test.sh whatever the capture did; a reward left before the tests is removed, as
# Harbor's verifier removes both files before it runs a task's tests: only what test.sh writes is read
check = (f"{capture()}; cp {CAPTURED} {LOGS}/model.patch; rm -f -- {LOGS}/reward.txt {LOGS}/reward.json; "
"exec bash /tests/test.sh")
return {"prompt": prompt, "environment": "task", "image": image,
**({"agent_seconds": int(agent)} if agent else {}), # the task's own budget, not the run's
"verify": {"copy": {f"{TASKS}/{unit}/tests": "/tests"}, "run": ["bash", "-c", check], "collect": LOGS,
"seconds": verifier.get("timeout_sec") or 3000,
"network": verifier.get("network_mode") == "public"}}


def score(unit, dir, transcript, answer, verified=None):
if not verified:
return {"reward": 0.0, "passed": False, "detail": {"why": "the task's check did not run"}}
detail = {"exit": verified.get("exit"), "timed_out": verified.get("timed_out"),
"output": (verified.get("output") or "")[-3000:]}
try:
with open(os.path.join(verified["dir"], "reward.txt")) as f:
reward = float(f.read().strip() or 0)
except (OSError, ValueError):
detail["why"] = "test.sh wrote no reward"
reward = 0.0
return {"reward": 1.0 if reward >= 1.0 else 0.0, "passed": reward >= 1.0, "detail": detail}


def oracle(unit, dir):
here, t = task(unit)
return {"answer": "", "solve": {"copy": {f"{TASKS}/{unit}/solution": "/solution"}, "run": ["bash", "/solution/solve.sh"],
"seconds": (t.get("agent") or {}).get("timeout_sec") or 900}}


HANDLERS = {"units": units, "describe": describe, "setup": setup, "score": score, "oracle": oracle}
for line in sys.stdin:
try:
req = json.loads(line)
out = HANDLERS[req.pop("op")](**req)
except Exception as e:
out = {"error": f"{type(e).__name__}: {e}"}
print(json.dumps(out), flush=True)
Loading
Loading