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 @@ -15,7 +15,7 @@ setting, not a choice the benchmark made. Chapter 9 records the choices.
| 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 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 |
| 9 | A round's scoring area needs about 60 MB per trial, plus 0.5 GB for the trial being scored: about 5 GB for round 5's 75 | Each trial's environment, about 290 MB, is dropped once its scores are read; its tree stays until the round is archived |
| 10 | GitHub refuses a file over 50 MB on push | The archive refuses one too |

## 2.2 Organisational constraints
Expand Down
4 changes: 2 additions & 2 deletions docs/architecture/05-building-block-view.md
Original file line number Diff line number Diff line change
Expand Up @@ -68,10 +68,10 @@ are still read.
| Path | Holds |
| ---- | ----- |
| The hidden suite's clone | At the one revision the root is graded under |
| `scoring/<trial>/tree/`, `venv/` | Each trial's extracted tree and clean environment |
| `scoring/<trial>/tree/` | Each trial's extracted tree, until the round is archived; its clean environment goes once it is scored |
| `tool-lock.txt` | The tool versions every trial is measured with |
| `scores/`, `scores-change/` | One score per build trial and per change task |
| `security/`, `security-scores/` | Each trial's probe environment, and its readings |
| `security/`, `security-scores/` | Each trial's probe files, and its readings; the probe environment goes once it is read |
| `judge/` | Each blind bundle, its judgings and the unblinding map |
| `archived.json` | The stamp a verified archive writes, with the hash of every file the report reads |
| `<tool>.running` | A claim that one run of that tool is working here |
Expand Down
10 changes: 8 additions & 2 deletions docs/architecture/07-deployment-view.md
Original file line number Diff line number Diff line change
Expand Up @@ -44,8 +44,14 @@ Round 3's root held 5.5 GB after both tasks. Each scored trial's
environment is about 290 MB.
<!-- /measured -->

Round 5's 75 build trials want about 40 GB free on the root's drive; a
K = 3 round of five arms and both tasks wanted about 15 GB. A full disk stops
<!-- measured: 2026-11-01 -->
Round 5c's run root held 11.4 GB, and its scoring area 26.5 GB: 21.8 GB of
environments, 4.3 GB of extracted trees.
<!-- /measured -->

Scoring drops each trial's environment once its scores are read, and the
archive drops the trees, so round 5's 75 build trials want about 17 GB free on
the root's drive: the root and about 5 GB beside it. A full disk stops
a trial or a scoring with `No space left on device`, and that trial is not a
result.

Expand Down
69 changes: 68 additions & 1 deletion tests/efficacy/archive.py
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,9 @@

import lib # noqa: E402
from harness import (TrialError, assert_outside_repository, # noqa: E402
project_folder, remove_tree, scoring_area, write_run)
claim_path, claim_refusal_check, project_folder,
read_claim, remove_tree, running_as, scoring_area,
write_run)

MANIFEST = "ARCHIVE.json"
STAMP = "archived.json"
Expand Down Expand Up @@ -328,6 +330,40 @@ def stamp(root, into):
"readings": readings_digest(root)})


# The tools that read and write a scoring area while they run, each under a
# claim of its own.
AREA_TOOLS = ("score.py", "security.py", "judge.py")


def live_run_problem(root):
"""Why the round's scoring area is in use by a live run, or None."""
area = scoring_area(root)
for tool in AREA_TOOLS:
holder = read_claim(claim_path(area, tool))
if holder is not None and running_as(holder["pid"], tool):
return ("a %s run is live against %s: pid %d, started %s"
% (tool, area, holder["pid"], holder.get("started")))
return None


def drop_trees(root):
"""Delete the scoring area's extracted trees and any environment left
beside them; return how many folders went."""

# The judge and the security reading read a trial's tree, and both are
# done once the round is archived: a later reading would change what the
# stamp holds, and a re-score extracts the tree again from its tarball.
area = scoring_area(root)
folders = []
for part in ("scoring", "scoring-change"):
for kind in ("tree", "venv"):
folders += glob.glob(os.path.join(area, part, "*", kind))
folders += glob.glob(os.path.join(area, "security", "*", "venv"))
for folder in folders:
remove_tree(folder)
return len(folders)


def plant_tarball(path, name, extra=()):
"""A frozen workspace holding code, a venv, caches and a git dir."""
entries = {"src/pkg/__init__.py": b"VALUE = 1\n",
Expand Down Expand Up @@ -498,6 +534,24 @@ def self_test():
stamp_problem(root) is not None))
stamp(root, into)
checks.append(("a stamped round has none", stamp_problem(root) is None))

# What scoring leaves: a trial's tree and environment, a change task's,
# and a security reading's environment.
area = scoring_area(root)
leftovers = [os.path.join(area, "scoring", "none-1", "tree"),
os.path.join(area, "scoring", "none-1", "venv"),
os.path.join(area, "scoring-change", "none-1", "tree"),
os.path.join(area, "security", "full-1", "venv")]
for folder in leftovers:
os.makedirs(folder, exist_ok=True)
with io.open(os.path.join(folder, "left.txt"), "w") as handle:
handle.write("x")
dropped = drop_trees(root)
checks.append(("an archived round drops its trees and environments",
dropped == len(leftovers)
and not any(os.path.exists(folder) for folder in leftovers)))
checks.append(("its readings stand, so the stamp still holds",
stamp_problem(root) is None))
score = os.path.join(scoring_area(root), "scores", "none-1.json")
dump_json(score, dict(load_json(score), planted=True))
checks.append(("a reading changed after the stamp is a problem",
Expand All @@ -509,6 +563,11 @@ def self_test():
report.main(["--root", root, "--out-dir", out]) == 0
and bool(os.listdir(out))))

for tool in AREA_TOOLS:
checks.append(claim_refusal_check(
tool, main, root, "--into",
os.path.join(scratch, "runs", "live-" + tool)))

for label, target in (("a non-empty target is refused", into),
("a target inside this repository is refused",
os.path.join(lib.ROOT, "tmp", "archive-probe"))):
Expand Down Expand Up @@ -577,6 +636,12 @@ def main(argv):
if not options.root:
print("--root is required")
return 2

# A round still being scored, read or judged is not done, and the
# drop after the archive would delete what that run is reading.
problem = live_run_problem(options.root)
if problem:
raise TrialError(problem)
import report
seed = (options.seed if options.seed is not None
else report.parse_args([]).seed)
Expand All @@ -598,6 +663,8 @@ def main(argv):
lib.print_verdict(False, "archive not verified; no stamp written")
return 1
stamp(options.root, source)
print("Dropped %d tree and environment folder(s) from the scoring area"
% drop_trees(options.root))
lib.print_verdict(True, "archive verified; %s stamped"
% os.path.join(scoring_area(options.root), STAMP))
return 0
Expand Down
14 changes: 14 additions & 0 deletions tests/efficacy/score.py
Original file line number Diff line number Diff line change
Expand Up @@ -300,6 +300,14 @@ def create_venv(where):
return where


def drop_venv(venv):
"""Delete a trial's environment once its scores are read off it."""

# About 290 MB a trial, and nothing reads it again: a later reading
# makes its own from the trial's tree and the run's lock.
remove_tree(venv)


def pip(venv, *args, **kwargs):
"""Run pip inside a trial's environment."""
timeout = kwargs.pop("timeout", 1800)
Expand Down Expand Up @@ -1246,6 +1254,7 @@ def score_trial(record, options, suite, lock):
scores["cost"] = cost(record)

scores["flagged"] = metric_flags(scores)
drop_venv(venv)
return scores


Expand Down Expand Up @@ -1332,6 +1341,7 @@ def score_change_trial(record, options, suite):
"commit"))
scores["cost"] = cost(record)
scores["flagged"] = metric_flags(scores)
drop_venv(venv)
return scores


Expand Down Expand Up @@ -1912,6 +1922,10 @@ def self_test():
+ claim_checks(scratch) + security_checks(scratch)
+ coverage_checks(scratch) + python_files_checks(scratch)
+ scope_checks(scratch))
dropped = create_venv(os.path.join(scratch, "dropped"))
drop_venv(dropped)
checks.append(("a scored trial's environment is dropped",
not os.path.exists(dropped)))
venv = create_venv(os.path.join(scratch, "venv"))
checks += boot_checks(scratch, venv) + interpreter_checks(scratch, venv)

Expand Down
30 changes: 29 additions & 1 deletion tests/efficacy/security.py
Original file line number Diff line number Diff line change
Expand Up @@ -1051,6 +1051,17 @@ def read_trial(area, name, scores_file, auditor, auditor_reason):
where = os.path.join(area, "security", name)
os.makedirs(where, exist_ok=True)
venv = create_venv(os.path.join(where, "venv"))
try:
return read_installed(venv, tree, where, result, auditor,
auditor_reason)
finally:

# About 290 MB a trial, and nothing reads it again.
remove_tree(venv)


def read_installed(venv, tree, where, result, auditor, auditor_reason):
"""The install, runtime and dependency checks of one trial, in `venv`."""
installed = pip(venv, "install", tree, cwd=where)
if installed["failed"] or installed["status"] != 0:
reason = ("the trial did not install: %s"
Expand Down Expand Up @@ -1531,14 +1542,31 @@ def claim_self_checks(scratch):
and not os.path.exists(os.path.join(area, "security")))]


def leftover_self_checks(scratch):
"""A reading leaves no environment behind, even one whose trial did not
install."""
area = os.path.join(scratch, "leftover")
tree = os.path.join(area, "tree")
os.makedirs(tree)
scores_file = os.path.join(area, "none-1.json")
with io.open(scores_file, "w", encoding="utf-8") as handle:
json.dump({"workspace": tree, "discovery": {"roots": []}}, handle)
result = read_trial(area, "none-1", scores_file, None, "not planted")
return [("a reading's environment is gone once it is read",
"probes" in result
and not os.path.exists(os.path.join(area, "security", "none-1",
"venv")))]


def self_test():
"""Prove each check counts what it names, records missing as missing,
and that a live run refuses a second."""
scratch = os.path.join(tempfile.gettempdir(), "efficacy-security-self-test")
remove_tree(scratch)
os.makedirs(scratch)
checks = (static_self_checks(scratch) + runtime_self_checks(scratch)
+ audit_self_checks() + claim_self_checks(scratch))
+ audit_self_checks() + claim_self_checks(scratch)
+ leftover_self_checks(scratch))
for label, ok in checks:
print(" %-52s %s" % (label, "ok" if ok else "FAILED"))
remove_tree(scratch)
Expand Down
Loading