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
2 changes: 1 addition & 1 deletion docs/architecture/02-constraints.md
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ setting, not a choice the benchmark made. Chapter 9 records the choices.
| 5 | A deny rule matches a command's prefix, not the paths inside it | The file tools can be fenced, the shell cannot |
| 6 | The builder and the judge bill against subscriptions | A round's budget is quota, not invoice. The judge's weekly plan limit sets how fast a round is judged |
| 7 | This repository is public | The hidden suite and the raw runs live in private repositories, `braboj/tariff-hidden-suite` and `braboj/tariff-runs` |
| 8 | Scoring runs Python 3.12 | Every trial's environment is made by the scorer's own interpreter, so a round is scored under one version |
| 8 | Scoring runs Python 3.12 | Every trial's environment is made on Python 3.12, the spec's version, whatever the scorer runs under; without it the scorer refuses to score |
| 9 | A round needs about 0.5 GB free per trial: about 40 GB for round 5's 75 | Each scored trial's environment is about 290 MB |
| 10 | GitHub refuses a file over 50 MB on push | The archive refuses one too |

Expand Down
2 changes: 1 addition & 1 deletion docs/architecture/07-deployment-view.md
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ with its protocol.

| Node or store | What it is | Needed for | Without it |
| ------------- | ---------- | ---------- | ---------- |
| Python 3.12 | The interpreter the scripts run under, as `py -3.12` | Every scored trial's environment | Trials scored under another interpreter are measured with another ruler |
| Python 3.12 | Found as `py -3.12` or `python3.12` | Every scored trial's environment | The scorer refuses to score |
| Claude Code CLI | `claude` on `PATH`, logged in | Every trial and every generation | The preflight refuses the run |
| Codex CLI | `codex` on `PATH`, logged in | The rounds' judge, from round 5 | Each judging fails |
| `gh` | Logged in with access to the hidden suite | Scoring clones the suite | Scoring refuses |
Expand Down
6 changes: 6 additions & 0 deletions docs/rounds/round-5d.md
Original file line number Diff line number Diff line change
Expand Up @@ -144,6 +144,12 @@ Done with this registration:
trial, and every trial records the CLI's version; round 5d runs
`C:/efficacy/cli/claude-2.1.314.exe`, a copy of 2.1.314 kept where the
launcher's updater does not prune it
- scoring makes every environment on Python 3.12, the spec's version, and
records it on every score. Round 5c was scored on Python 3.14.8, which
refused three builds that capped `requires-python` below 3.13
- the scorer refuses a root holding scores on another Python, and the report
a round whose scores were installed on more than one, so round 5c's
`none` is re-scored on Python 3.12 before round 5d reads it

The report still gains, with a self-test:

Expand Down
48 changes: 48 additions & 0 deletions tests/efficacy/report.py
Original file line number Diff line number Diff line change
Expand Up @@ -1144,6 +1144,27 @@ def prompt_problem(root):
return None


def python_problem(trials):
"""Why the trials' scores were not all installed on one Python, or None.

A score from before the scorer recorded its Python reads as unrecorded,
so a round's old scores beside new ones are refused too."""
found = {}
for name, trial in trials.items():
for part in ("scores", "change"):
scores = trial.get(part)
if scores is None:
continue
version = scores.get("python")
minor = ".".join(version.split(".")[:2]) if version else "unrecorded"
found.setdefault(minor, name)
if len(found) < 2:
return None
return ("the trials were installed on more than one Python: %s"
% ", ".join("%s (%s, for one)" % (minor, name)
for minor, name in sorted(found.items())))


def registration_problem(root, registration, repository=REPOSITORY):
"""Why the round's registration does not predate its first trial, or
None when it landed on the main branch before that trial and is
Expand Down Expand Up @@ -3521,6 +3542,25 @@ def trial(prompt=PROMPT, outcome="completed", task="build"):
return checks


def python_checks():
"""A round is refused when its scores were installed on more than one
Python, an unrecorded one included."""
def trials(*versions):
return {"none-%d" % (index + 1): {
"scores": {} if version is None else {"python": version},
"change": None} for index, version in enumerate(versions)}
return [
("scores on one Python are read",
python_problem(trials("3.12.10", "3.12.15")) is None),
("scores all unrecorded, as an old round's are, are read",
python_problem(trials(None, None)) is None),
("scores on two Pythons are refused",
"3.14" in (python_problem(trials("3.12.10", "3.14.8")) or "")),
("an unrecorded score beside a recorded one is refused",
"unrecorded" in (python_problem(trials("3.12.10", None)) or "")),
]


def registration_checks():
"""A round is refused when its registration landed on the main branch
after its first trial, has not landed, is changed and not committed, or
Expand Down Expand Up @@ -4541,6 +4581,7 @@ def self_test(seed):
checks.extend((label, ok, ok) for label, ok in registration_checks())
checks.extend((label, ok, ok) for label, ok in spec_checks())
checks.extend((label, ok, ok) for label, ok in prompt_checks())
checks.extend((label, ok, ok) for label, ok in python_checks())
for label, ok, got in checks:
print(" %-52s %s" % (label, "ok" if ok else "FAILED, got %r"
% (got,)))
Expand Down Expand Up @@ -4620,6 +4661,13 @@ def main(argv):
print("refused: %s" % problem)
return 2

# Scores installed on two Pythons would read the interpreter as an arm's
# effect, so a round's scores have to share one.
problem = python_problem(trials)
if problem:
print("refused: %s" % problem)
return 2

# A trial that read past its workspace measures what it read, not its
# arm; the harness voids one its own scan catches, and this re-scan, under
# the current rule, leaves out any it missed.
Expand Down
192 changes: 189 additions & 3 deletions tests/efficacy/score.py
Original file line number Diff line number Diff line change
Expand Up @@ -27,10 +27,12 @@
import os
import re
import secrets
import shutil
import subprocess
import sys
import tarfile
import tempfile
import zipfile

sys.path.insert(0, os.path.dirname(os.path.dirname(os.path.abspath(__file__))))

Expand All @@ -56,6 +58,17 @@
# The package every arm is asked to produce, fixed by the specification.
PACKAGE = "tariff"

# The Python the specification names. A build may cap `requires-python` at
# it, as the spec's wording invites, so every environment scoring makes runs
# this version: on a newer scorer's Python such a build is refused at install
# and scores zero on every row after it.
SPEC_PYTHON = (3, 12)

# Where an interpreter at the spec's version is looked for when the scorer
# runs on another: the Windows launcher, then a versioned name on the path.
SPEC_PYTHON_COMMANDS = (["py", "-%d.%d" % SPEC_PYTHON],
["python%d.%d" % SPEC_PYTHON])

# The specification seeds an empty database when the application starts, and
# seeding refuses without an administrator password. Every command scoring
# runs is given one, so the boot check and the probes reach the application.
Expand Down Expand Up @@ -228,11 +241,59 @@ def extract(tarball, into, name):
return target


# Each lookup's answer, so a run of many trials asks the launcher once.
FOUND_INTERPRETERS = {}


def spec_interpreter(commands=SPEC_PYTHON_COMMANDS):
"""The path of a Python at the spec's version; a ScoreError if none is
found, since scoring on another version would grade the interpreter."""
if commands is SPEC_PYTHON_COMMANDS and sys.version_info[:2] == SPEC_PYTHON:
return sys.executable
key = tuple(tuple(command) for command in commands)
if key not in FOUND_INTERPRETERS:
FOUND_INTERPRETERS[key] = find_interpreter(commands)
if FOUND_INTERPRETERS[key] is None:
tried = ", ".join(" ".join(command) for command in commands)
raise ScoreError("no Python %d.%d was found, and scoring runs on the "
"spec's Python only; tried: %s"
% (SPEC_PYTHON[0], SPEC_PYTHON[1], tried))
return FOUND_INTERPRETERS[key]


def find_interpreter(commands):
"""The first command's interpreter that runs the spec's version, or None."""
probe = "import sys; print(sys.executable); print(*sys.version_info[:2])"
wanted = ["%d" % part for part in SPEC_PYTHON]
for command in commands:

# Windows reads the `.12` of `python3.12` as an extension and adds no
# `.exe`, so the name is resolved on the path before it is launched.
program = shutil.which(command[0])
if program is None:
continue
outcome = run([program] + list(command[1:]) + ["-c", probe],
timeout=120)
lines = outcome["stdout"].splitlines()
if (outcome["failed"] is None and outcome["status"] == 0
and len(lines) == 2 and lines[1].split() == wanted):
return lines[0].strip()
return None


def venv_version(venv):
"""The Python version a virtual environment runs, as `3.12.10`, or None."""
outcome = run([python_in(venv), "-c",
"import platform; print(platform.python_version())"],
timeout=120)
return outcome["stdout"].strip() or None


def create_venv(where):
"""A clean virtual environment for one trial."""
"""A clean virtual environment on the spec's Python."""
if os.path.exists(where):
remove_tree(where)
outcome = run([sys.executable, "-m", "venv", where], timeout=600)
outcome = run([spec_interpreter(), "-m", "venv", where], timeout=600)
if outcome["failed"] or outcome["status"] != 0:
raise ScoreError("could not create the virtual environment at %s: %s"
% (where, outcome["stderr"][:400]))
Expand Down Expand Up @@ -1108,6 +1169,7 @@ def score_trial(record, options, suite, lock):
"workspace": workspace, "templates_tree": record.get(
"templates_tree"),
"model": record.get("model"), "suite_revision": suite["revision"],
"python": venv_version(venv),
"scored_at": datetime.datetime.now().isoformat(
timespec="seconds"),
"python_files": files}
Expand Down Expand Up @@ -1247,6 +1309,7 @@ def score_change_trial(record, options, suite):
"task": "change", "workspace": workspace,
"base": record.get("base"), "model": record.get("model"),
"suite_revision": suite["revision"],
"python": venv_version(venv),
"scored_at": datetime.datetime.now().isoformat(
timespec="seconds")}
scores["install"] = install_trial(venv, workspace)
Expand Down Expand Up @@ -1736,6 +1799,94 @@ def python_files_checks(scratch):
]


def interpreter_checks(scratch, venv):
"""Every environment runs the spec's Python, so a build capped at it
installs, and a scorer that cannot find that Python refuses to score."""

# A wheel carries its `Requires-Python` in its metadata, so pip refuses
# or accepts it with no build backend and no network, the way it refused
# round 5c's three builds capped below 3.13 on Python 3.14.
capped = "%d.%d" % (SPEC_PYTHON[0], SPEC_PYTHON[1] + 1)
wheel = os.path.join(scratch, "capped_pkg-0.1-py3-none-any.whl")
info = "capped_pkg-0.1.dist-info"
with zipfile.ZipFile(wheel, "w") as archive:
archive.writestr("capped_pkg/__init__.py", "")
archive.writestr(info + "/METADATA",
"Metadata-Version: 2.1\nName: capped-pkg\n"
"Version: 0.1\nRequires-Python: >=%d.%d,<%s\n"
% (SPEC_PYTHON[0], SPEC_PYTHON[1], capped))
archive.writestr(info + "/WHEEL",
"Wheel-Version: 1.0\nGenerator: self-test\n"
"Root-Is-Purelib: true\nTag: py3-none-any\n")
archive.writestr(info + "/RECORD", "")
installed = pip(venv, "install", "--no-index", "--no-deps", wheel,
timeout=300)
try:
spec_interpreter([["no-such-python-launcher"]])
refused = False
except ScoreError:
refused = True

# A dotted name on the path, as `python3.12` is: a wrapper that hands its
# arguments to the spec's interpreter.
bin_dir = os.path.join(scratch, "dotted-bin")
os.makedirs(bin_dir)
real = spec_interpreter()
if os.name == "nt":
wrapper = os.path.join(bin_dir, "spec%d.%d.cmd" % SPEC_PYTHON)
text = '@"%s" %%*\r\n' % real
else:
wrapper = os.path.join(bin_dir, "spec%d.%d" % SPEC_PYTHON)
text = '#!/bin/sh\nexec "%s" "$@"\n' % real
with io.open(wrapper, "w", encoding="utf-8", newline="") as handle:
handle.write(text)
os.chmod(wrapper, 0o755)
path = os.environ.get("PATH", "")
os.environ["PATH"] = bin_dir + os.pathsep + path
try:
dotted = find_interpreter([["spec%d.%d" % SPEC_PYTHON]])
finally:
os.environ["PATH"] = path

# Scores kept in a root: each one on the spec's Python, one on another,
# and one from before the scorer recorded its Python.
wanted = "%d.%d.0" % SPEC_PYTHON
targets = {}
for label, versions in (("same", [wanted, wanted]),
("other", [wanted, "3.14.8"]),
("unrecorded", [wanted, None]),
("change", [wanted, wanted, "3.14.8"])):
area = os.path.join(scratch, "pythons", label)

# The third score, where there is one, is a change task's.
for index, version in enumerate(versions):
task = "scores-change" if index == 2 else "scores"
os.makedirs(os.path.join(area, task), exist_ok=True)
with io.open(os.path.join(area, task, "none-%d.json" % (index % 2 + 1)),
"w", encoding="utf-8") as handle:
json.dump({} if version is None else {"python": version},
handle)
targets[label] = python_problem(area)
return [
("a dotted interpreter name on the path is found",
dotted is not None),
("scores all on the spec's Python stand beside new ones",
targets["same"] is None),
("a score on another Python refuses the root",
"3.14" in (targets["other"] or "")),
("a score with no Python recorded refuses the root",
"unrecorded" in (targets["unrecorded"] or "")),
("a change task's score on another Python refuses the root",
"3.14" in (targets["change"] or "")),
("a scoring environment runs the spec's Python",
(venv_version(venv) or "").split(".")[:2]
== ["%d" % part for part in SPEC_PYTHON]),
("a build capped below Python %s installs" % capped,
installed["failed"] is None and installed["status"] == 0),
("no Python at the spec's version refuses to score", refused),
]


def self_test():
"""Prove the missing-vs-zero rule fires before any score is believed.

Expand All @@ -1762,7 +1913,7 @@ def self_test():
+ coverage_checks(scratch) + python_files_checks(scratch)
+ scope_checks(scratch))
venv = create_venv(os.path.join(scratch, "venv"))
checks += boot_checks(scratch, venv)
checks += boot_checks(scratch, venv) + interpreter_checks(scratch, venv)

empty = os.path.join(scratch, "empty")
os.makedirs(empty)
Expand Down Expand Up @@ -1830,6 +1981,33 @@ def graded_revisions(target):
return revisions


def python_of(scores):
"""A score's Python as `3.12`, or "unrecorded" for one scored before the
scorer recorded it."""
version = scores.get("python")
return ".".join(version.split(".")[:2]) if version else "unrecorded"


def python_problem(area):
"""Why the scores already in a scoring area cannot stand beside new ones,
or None: each, of either task, was installed on the spec's Python."""
wanted = "%d.%d" % SPEC_PYTHON
others = set()

# Both tasks' scores, since the report reads a build's beside its change
# task's and refuses the pair on two Pythons.
for task in ("scores", "scores-change"):
for file in glob.glob(os.path.join(area, task, "*.json")):
with io.open(file, encoding="utf-8") as handle:
others.add(python_of(json.load(handle)))
others.discard(wanted)
if not others:
return None
return ("%s holds scores installed on Python %s, and scoring runs on %s; "
"a run on another Python is another root"
% (area, ", ".join(sorted(others)), wanted))


def parse_args(argv):
parser = argparse.ArgumentParser(
description="Score frozen efficacy-benchmark trials.")
Expand Down Expand Up @@ -1933,6 +2111,14 @@ def score_trials(options):
lib.print_verdict(False, "0 scored, 1 refused")
return 1

# The same holds for the interpreter: a score kept from another Python
# beside new ones would compare the two Pythons, not the arms.
problem = python_problem(area)
if problem:
print("refused: %s" % problem)
lib.print_verdict(False, "0 scored, 1 refused")
return 1

scored, skipped, refused = [], [], 0
for name in sorted(wanted - set(offered)):
print("%s refused: no run record offers it for scoring" % name)
Expand Down
Loading