"""Benchmark task directories (provided at run time; hidden material never lives in the public repository). /task.json id, version, set ("dev" | "validation" | "test"), family, prompt language-neutral statement (file, relative) languages {lang: {"workspace": dir, "test": command}} `workspace` is copied fresh into every run; `test` is the public test command, counted as a test run limits tool_calls, total_tokens, wall_seconds, command_timeout, output_chars (defaults below) concurrency bool (schedule exploration gate, protocol ยง13) """ import os from . import util DEFAULT_LIMITS = {"tool_calls": 150, "total_tokens": 3_000_000, "wall_seconds": 3600, "command_timeout": 300, "output_chars": 20_000} class Task: def __init__(self, path): self.dir = os.path.realpath(path) spec = util.read_json(os.path.join(self.dir, "task.json")) for key in ("id", "version", "prompt", "languages"): if key not in spec: raise SystemExit(f"{path}/task.json: missing {key!r}") self.spec = spec self.id = spec["id"] self.version = str(spec["version"]) self.set = spec.get("set", "dev") with open(os.path.join(self.dir, spec["prompt"]), encoding="utf-8") as f: self.prompt = f.read() self.limits = dict(DEFAULT_LIMITS, **spec.get("limits", {})) def language(self, name): if name not in self.spec["languages"]: raise SystemExit(f"task {self.id} has no variant for language {name!r}") lang = self.spec["languages"][name] return {"workspace": os.path.join(self.dir, lang["workspace"]), "test": lang.get("test")} def hash(self): """Hash of the public task material (statement and starter workspaces).""" return util.sha256_path(self.dir)