369 validated tasks; grader keeps large builds within the 10 GB disk (part 16)
Browse filesRe-ran the oracle with the updated verifier. The verifier now empties Lake's per-module setup files and generated C once each module is built, and deletes the build before writing its verdict, so a build that fills the disk scores 0 instead of leaving the trial without a result. 14 more tasks validated; not-validated list updated.
Files changed (46)
- tasks/product-brown/tests/grade.py+67-5
- tasks/projection-counterexample/task.toml+1-1
- tasks/projection-counterexample/tests/grade.py+67-5
- tasks/projection-moments/task.toml+1-1
- tasks/projection-moments/tests/grade.py+67-5
- tasks/projection-volume/task.toml+1-1
- tasks/projection-volume/tests/grade.py+67-5
- tasks/qac-parity/task.toml+1-1
- tasks/qac-parity/tests/grade.py+67-5
- tasks/quadric-bundles/task.toml+1-1
- tasks/quadric-bundles/tests/grade.py+67-5
- tasks/quantitative-van-der-waerden/task.toml+1-1
- tasks/quantitative-van-der-waerden/tests/grade.py+67-5
- tasks/quintic-lienard/task.toml+1-1
- tasks/quintic-lienard/tests/grade.py+67-5
- tasks/radial-density-interval/task.toml+1-1
- tasks/radial-density-interval/tests/grade.py+67-5
- tasks/radial-transition/task.toml+1-1
- tasks/radial-transition/tests/grade.py+67-5
- tasks/ramsey-five/environment/DockerfileAdded+8
- tasks/ramsey-five/environment/fetch_mathlib.shAdded+19
- tasks/ramsey-five/environment/lake-manifest.jsonAdded+116
- tasks/ramsey-five/environment/lakefile.leanAdded+12
- tasks/ramsey-five/environment/lean_setup.shAdded+126
- tasks/ramsey-five/environment/pack_submission.pyAdded+70
- tasks/ramsey-five/instruction.mdAdded+81
- tasks/ramsey-five/solution/closure.txtAdded+482
- tasks/ramsey-five/solution/reference.pyAdded+58
- tasks/ramsey-five/solution/solve.shAdded+20
- tasks/ramsey-five/task.tomlAdded+49
- tasks/ramsey-five/tests/Challenge.leanAdded+30
- tasks/ramsey-five/tests/grade.pyAdded+418
- tasks/ramsey-five/tests/task.jsonAdded+15
- tasks/ramsey-five/tests/test.shAdded+3
- tasks/randomized-mean-payoff/task.toml+1-1
- tasks/randomized-mean-payoff/tests/grade.py+67-5
- tasks/rational-hitting/task.toml+1-1
- tasks/rational-hitting/tests/grade.py+67-5
- tasks/real-l1-renorming/task.toml+1-1
- tasks/real-l1-renorming/tests/grade.py+67-5
- tasks/recursive-potentials/task.toml+1-1
- tasks/recursive-potentials/tests/grade.py+67-5
- tasks/reflexive-fixed-points/task.toml+1-1
- tasks/reflexive-fixed-points/tests/grade.py+67-5
- tasks/regular-parity/task.toml+1-1
- tasks/regular-parity/tests/grade.py+67-5
34 unmodified lines3536373839405 unmodified lines464748495051188 unmodified lines2402412422432442458 unmodified lines25425525625725825926026126226333 unmodified lines2972982993003013028 unmodified lines3113123133143153168 unmodified lines32532632732832933033133233333433533633733833934034134234334434534634734834935034 unmodified linesimport sysimport tarfileimport tempfileimport timefrom pathlib import Path5 unmodified linesGRADER = "grader"SUCCESS_LINE = "Your solution is okay!"GRADE_THREADS = "2"# Lake and Comparator wording when a build process is killed for running out of memory.OOM_MARKERS = ("Lean exited with code 137", "Child exited with 137")188 unmodified linesreturn any(m in out for m in OOM_MARKERS)def run_comparator(run: Path, timeout_sec: int, threads: str = GRADE_THREADS) -> tuple[int | None, str]:env = {"PATH": f"{toolchain_bin()}:/usr/local/bin:/usr/bin:/bin",8 unmodified lines"runuser", "-u", GRADER, "--", "env", "-i", *(f"{k}={v}" for k, v in env.items()),"lake", "env", "comparator", "config.json",]code, stdout, stderr = run_with_timeout(cmd, cwd=run, timeout_sec=timeout_sec,kill_extra=lambda: subprocess.run(["pkill", "-9", "-u", GRADER], capture_output=True),)return code, stdout + "\n--- stderr ---\n" + stderr33 unmodified linesif code is None:return 0, "timed out while building or checking the submission"tail = [l for l in out.splitlines() if l.strip() and "has local changes" not in l][-25:]if out_of_memory(out):return 0, "rejected: the build was killed, most likely out of memory (8 GB) | " + " | ".join(tail)[-3000:]return 0, "rejected: " + " | ".join(tail)[-4000:]8 unmodified linestask = json.loads((TESTS / "task.json").read_text())details: dict = {"task": task["challenge"], "started_at": time.time()}reward: int | None = Nonetry:RUN_ROOT.mkdir(mode=0o711, parents=True, exist_ok=True)deadline = time.time() + int(task["grade_timeout_sec"])8 unmodified lines# Two Lean processes in parallel can exceed 8 GB on a heavy module. Retry once with one,# in a fresh directory: the first attempt's .lake was written by the submission's own# build and must not be trusted for the challenge.run = fresh_run(task)unpack_submission(run)code, out = run_comparator(run, int(deadline - time.time()), threads="1")log += "\n\n=== retried with one Lean process after running out of memory ===\n\n" + outkill_grader()details["retried_single_thread"] = True(VERIFIER_DIR / "comparator.log").write_text(log)reward, details["reason"] = classify(code, out)details["comparator_exit"] = codeexcept Rejected as exc:reward, details["reason"] = 0, f"rejected: {exc}"except GradingError as exc:reward, details["reason"] = None, f"grading error: {exc}"finally:try:kill_grader()except GradingError as exc:reward, details["reason"] = None, f"grading error: {exc}"details["reward"] = rewarddetails["finished_at"] = time.time()(VERIFIER_DIR / "grading.json").write_text(json.dumps(details, indent=2))print(json.dumps(details, indent=2))if reward is not None:34 unmodified lines353637383940415 unmodified lines47484950515253188 unmodified lines2422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892908 unmodified lines29930030130230330430530630730830931031131231331431533 unmodified lines3493503513523533543553568 unmodified lines3653663673683693703718 unmodified lines38038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141234 unmodified linesimport sysimport tarfileimport tempfileimport threadingimport timefrom pathlib import Path5 unmodified linesGRADER = "grader"SUCCESS_LINE = "Your solution is okay!"GRADE_THREADS = "2"SCRATCH_SWEEP_SEC = 15# Lake and Comparator wording when a build process is killed for running out of memory.OOM_MARKERS = ("Lean exited with code 137", "Child exited with 137")188 unmodified linesreturn any(m in out for m in OOM_MARKERS)def out_of_disk(out: str) -> bool:return "no space left on device" in out.lower()# Run as the grader user by `empty_build_scratch`. argv: the .lake/build/ir directory.EMPTY_SCRATCH = r"""import os, sysfor dirpath, _, files in os.walk(sys.argv[1]):for name in files:if not name.endswith(".setup.json"):continuebase = os.path.join(dirpath, name[:-len(".setup.json")])try:# Lake writes X.c.hash once Lean, and leanir if the module needs it, are done with X;# both read X.setup.json, so it may only be emptied after that.if os.stat(base + ".c.hash").st_mtime < os.stat(base + ".setup.json").st_mtime:continuefor path in (base + ".setup.json", base + ".c"):if os.path.getsize(path):os.truncate(path, 0)except OSError:pass"""def empty_build_scratch(run: Path, stop: threading.Event) -> None:"""Until ``stop`` is set, empty files Lake leaves in .lake/build/ir that grading never reads.For every module Lake writes a `.setup.json` (its imports with the path of every .olean theypull in, about 5.5 MB with Mathlib) and the module compiled to C. Neither is used once themodule is built, and for proofs of 1,000-2,000 modules they filled the 10 GB disk before thebuild finished. Lake keeps the recorded hashes, so emptied files do not trigger a rebuild.This runs as the grader user, so it can touch nothing the build could not."""ir = str(run / ".lake" / "build" / "ir")while not stop.wait(SCRATCH_SWEEP_SEC):try:subprocess.run(["runuser", "-u", GRADER, "--", sys.executable, "-c", EMPTY_SCRATCH, ir],capture_output=True, timeout=600)except subprocess.TimeoutExpired:passdef run_comparator(run: Path, timeout_sec: int, threads: str = GRADE_THREADS) -> tuple[int | None, str]:env = {"PATH": f"{toolchain_bin()}:/usr/local/bin:/usr/bin:/bin",8 unmodified lines"runuser", "-u", GRADER, "--", "env", "-i", *(f"{k}={v}" for k, v in env.items()),"lake", "env", "comparator", "config.json",]stop = threading.Event()sweeper = threading.Thread(target=empty_build_scratch, args=(run, stop), daemon=True)sweeper.start()try:code, stdout, stderr = run_with_timeout(cmd, cwd=run, timeout_sec=timeout_sec,kill_extra=lambda: subprocess.run(["pkill", "-9", "-u", GRADER], capture_output=True),)finally:stop.set()sweeper.join()return code, stdout + "\n--- stderr ---\n" + stderr33 unmodified linesif code is None:return 0, "timed out while building or checking the submission"tail = [l for l in out.splitlines() if l.strip() and "has local changes" not in l][-25:]if out_of_disk(out):return 0, "rejected: the build ran out of disk space (10 GB) | " + " | ".join(tail)[-3000:]if out_of_memory(out):return 0, "rejected: the build was killed, most likely out of memory (8 GB) | " + " | ".join(tail)[-3000:]return 0, "rejected: " + " | ".join(tail)[-4000:]8 unmodified linestask = json.loads((TESTS / "task.json").read_text())details: dict = {"task": task["challenge"], "started_at": time.time()}reward: int | None = Nonelog = ""try:RUN_ROOT.mkdir(mode=0o711, parents=True, exist_ok=True)deadline = time.time() + int(task["grade_timeout_sec"])8 unmodified lines# Two Lean processes in parallel can exceed 8 GB on a heavy module. Retry once with one,# in a fresh directory: the first attempt's .lake was written by the submission's own# build and must not be trusted for the challenge.shutil.rmtree(run, ignore_errors=True)run = fresh_run(task)unpack_submission(run)code, out = run_comparator(run, int(deadline - time.time()), threads="1")log += "\n\n=== retried with one Lean process after running out of memory ===\n\n" + outkill_grader()details["retried_single_thread"] = Truereward, details["reason"] = classify(code, out)details["comparator_exit"] = codeexcept Rejected as exc:reward, details["reason"] = 0, f"rejected: {exc}"except GradingError as exc:reward, details["reason"] = None, f"grading error: {exc}"except Exception as exc:reward, details["reason"] = None, f"grading error: {type(exc).__name__}: {exc}"finally:try:kill_grader()except GradingError as exc:reward, details["reason"] = None, f"grading error: {exc}"# Free the build before writing anything. A build that filled the disk would otherwise# make these writes fail, and with no space left the sandbox cannot report that the# verifier exited, so Harbor waits until its own timeout and records no verdict.shutil.rmtree(RUN_ROOT, ignore_errors=True)details["reward"] = rewarddetails["finished_at"] = time.time()(VERIFIER_DIR / "comparator.log").write_text(log)(VERIFIER_DIR / "grading.json").write_text(json.dumps(details, indent=2))print(json.dumps(details, indent=2))if reward is not None:
22 unmodified lines2324252627282922 unmodified linesreference_lean_bytes = 131947reference_requires_packages = []oracle_result = "accepted"oracle_grade_seconds = 576difficulty = "research"[agent]22 unmodified lines2324252627282922 unmodified linesreference_lean_bytes = 131947reference_requires_packages = []oracle_result = "accepted"oracle_grade_seconds = 142difficulty = "research"[agent]
34 unmodified lines3536373839405 unmodified lines464748495051188 unmodified lines2402412422432442458 unmodified lines25425525625725825926026126226333 unmodified lines2972982993003013028 unmodified lines3113123133143153168 unmodified lines32532632732832933033133233333433533633733833934034134234334434534634734834935034 unmodified linesimport sysimport tarfileimport tempfileimport timefrom pathlib import Path5 unmodified linesGRADER = "grader"SUCCESS_LINE = "Your solution is okay!"GRADE_THREADS = "2"# Lake and Comparator wording when a build process is killed for running out of memory.OOM_MARKERS = ("Lean exited with code 137", "Child exited with 137")188 unmodified linesreturn any(m in out for m in OOM_MARKERS)def run_comparator(run: Path, timeout_sec: int, threads: str = GRADE_THREADS) -> tuple[int | None, str]:env = {"PATH": f"{toolchain_bin()}:/usr/local/bin:/usr/bin:/bin",8 unmodified lines"runuser", "-u", GRADER, "--", "env", "-i", *(f"{k}={v}" for k, v in env.items()),"lake", "env", "comparator", "config.json",]code, stdout, stderr = run_with_timeout(cmd, cwd=run, timeout_sec=timeout_sec,kill_extra=lambda: subprocess.run(["pkill", "-9", "-u", GRADER], capture_output=True),)return code, stdout + "\n--- stderr ---\n" + stderr33 unmodified linesif code is None:return 0, "timed out while building or checking the submission"tail = [l for l in out.splitlines() if l.strip() and "has local changes" not in l][-25:]if out_of_memory(out):return 0, "rejected: the build was killed, most likely out of memory (8 GB) | " + " | ".join(tail)[-3000:]return 0, "rejected: " + " | ".join(tail)[-4000:]8 unmodified linestask = json.loads((TESTS / "task.json").read_text())details: dict = {"task": task["challenge"], "started_at": time.time()}reward: int | None = Nonetry:RUN_ROOT.mkdir(mode=0o711, parents=True, exist_ok=True)deadline = time.time() + int(task["grade_timeout_sec"])8 unmodified lines# Two Lean processes in parallel can exceed 8 GB on a heavy module. Retry once with one,# in a fresh directory: the first attempt's .lake was written by the submission's own# build and must not be trusted for the challenge.run = fresh_run(task)unpack_submission(run)code, out = run_comparator(run, int(deadline - time.time()), threads="1")log += "\n\n=== retried with one Lean process after running out of memory ===\n\n" + outkill_grader()details["retried_single_thread"] = True(VERIFIER_DIR / "comparator.log").write_text(log)reward, details["reason"] = classify(code, out)details["comparator_exit"] = codeexcept Rejected as exc:reward, details["reason"] = 0, f"rejected: {exc}"except GradingError as exc:reward, details["reason"] = None, f"grading error: {exc}"finally:try:kill_grader()except GradingError as exc:reward, details["reason"] = None, f"grading error: {exc}"details["reward"] = rewarddetails["finished_at"] = time.time()(VERIFIER_DIR / "grading.json").write_text(json.dumps(details, indent=2))print(json.dumps(details, indent=2))if reward is not None:34 unmodified lines353637383940415 unmodified lines47484950515253188 unmodified lines2422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892908 unmodified lines29930030130230330430530630730830931031131231331431533 unmodified lines3493503513523533543553568 unmodified lines3653663673683693703718 unmodified lines38038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141234 unmodified linesimport sysimport tarfileimport tempfileimport threadingimport timefrom pathlib import Path5 unmodified linesGRADER = "grader"SUCCESS_LINE = "Your solution is okay!"GRADE_THREADS = "2"SCRATCH_SWEEP_SEC = 15# Lake and Comparator wording when a build process is killed for running out of memory.OOM_MARKERS = ("Lean exited with code 137", "Child exited with 137")188 unmodified linesreturn any(m in out for m in OOM_MARKERS)def out_of_disk(out: str) -> bool:return "no space left on device" in out.lower()# Run as the grader user by `empty_build_scratch`. argv: the .lake/build/ir directory.EMPTY_SCRATCH = r"""import os, sysfor dirpath, _, files in os.walk(sys.argv[1]):for name in files:if not name.endswith(".setup.json"):continuebase = os.path.join(dirpath, name[:-len(".setup.json")])try:# Lake writes X.c.hash once Lean, and leanir if the module needs it, are done with X;# both read X.setup.json, so it may only be emptied after that.if os.stat(base + ".c.hash").st_mtime < os.stat(base + ".setup.json").st_mtime:continuefor path in (base + ".setup.json", base + ".c"):if os.path.getsize(path):os.truncate(path, 0)except OSError:pass"""def empty_build_scratch(run: Path, stop: threading.Event) -> None:"""Until ``stop`` is set, empty files Lake leaves in .lake/build/ir that grading never reads.For every module Lake writes a `.setup.json` (its imports with the path of every .olean theypull in, about 5.5 MB with Mathlib) and the module compiled to C. Neither is used once themodule is built, and for proofs of 1,000-2,000 modules they filled the 10 GB disk before thebuild finished. Lake keeps the recorded hashes, so emptied files do not trigger a rebuild.This runs as the grader user, so it can touch nothing the build could not."""ir = str(run / ".lake" / "build" / "ir")while not stop.wait(SCRATCH_SWEEP_SEC):try:subprocess.run(["runuser", "-u", GRADER, "--", sys.executable, "-c", EMPTY_SCRATCH, ir],capture_output=True, timeout=600)except subprocess.TimeoutExpired:passdef run_comparator(run: Path, timeout_sec: int, threads: str = GRADE_THREADS) -> tuple[int | None, str]:env = {"PATH": f"{toolchain_bin()}:/usr/local/bin:/usr/bin:/bin",8 unmodified lines"runuser", "-u", GRADER, "--", "env", "-i", *(f"{k}={v}" for k, v in env.items()),"lake", "env", "comparator", "config.json",]stop = threading.Event()sweeper = threading.Thread(target=empty_build_scratch, args=(run, stop), daemon=True)sweeper.start()try:code, stdout, stderr = run_with_timeout(cmd, cwd=run, timeout_sec=timeout_sec,kill_extra=lambda: subprocess.run(["pkill", "-9", "-u", GRADER], capture_output=True),)finally:stop.set()sweeper.join()return code, stdout + "\n--- stderr ---\n" + stderr33 unmodified linesif code is None:return 0, "timed out while building or checking the submission"tail = [l for l in out.splitlines() if l.strip() and "has local changes" not in l][-25:]if out_of_disk(out):return 0, "rejected: the build ran out of disk space (10 GB) | " + " | ".join(tail)[-3000:]if out_of_memory(out):return 0, "rejected: the build was killed, most likely out of memory (8 GB) | " + " | ".join(tail)[-3000:]return 0, "rejected: " + " | ".join(tail)[-4000:]8 unmodified linestask = json.loads((TESTS / "task.json").read_text())details: dict = {"task": task["challenge"], "started_at": time.time()}reward: int | None = Nonelog = ""try:RUN_ROOT.mkdir(mode=0o711, parents=True, exist_ok=True)deadline = time.time() + int(task["grade_timeout_sec"])8 unmodified lines# Two Lean processes in parallel can exceed 8 GB on a heavy module. Retry once with one,# in a fresh directory: the first attempt's .lake was written by the submission's own# build and must not be trusted for the challenge.shutil.rmtree(run, ignore_errors=True)run = fresh_run(task)unpack_submission(run)code, out = run_comparator(run, int(deadline - time.time()), threads="1")log += "\n\n=== retried with one Lean process after running out of memory ===\n\n" + outkill_grader()details["retried_single_thread"] = Truereward, details["reason"] = classify(code, out)details["comparator_exit"] = codeexcept Rejected as exc:reward, details["reason"] = 0, f"rejected: {exc}"except GradingError as exc:reward, details["reason"] = None, f"grading error: {exc}"except Exception as exc:reward, details["reason"] = None, f"grading error: {type(exc).__name__}: {exc}"finally:try:kill_grader()except GradingError as exc:reward, details["reason"] = None, f"grading error: {exc}"# Free the build before writing anything. A build that filled the disk would otherwise# make these writes fail, and with no space left the sandbox cannot report that the# verifier exited, so Harbor waits until its own timeout and records no verdict.shutil.rmtree(RUN_ROOT, ignore_errors=True)details["reward"] = rewarddetails["finished_at"] = time.time()(VERIFIER_DIR / "comparator.log").write_text(log)(VERIFIER_DIR / "grading.json").write_text(json.dumps(details, indent=2))print(json.dumps(details, indent=2))if reward is not None:
22 unmodified lines2324252627282922 unmodified linesreference_lean_bytes = 515196reference_requires_packages = []oracle_result = "accepted"oracle_grade_seconds = 919difficulty = "research"[agent]22 unmodified lines2324252627282922 unmodified linesreference_lean_bytes = 515196reference_requires_packages = []oracle_result = "accepted"oracle_grade_seconds = 343difficulty = "research"[agent]
34 unmodified lines3536373839405 unmodified lines464748495051188 unmodified lines2402412422432442458 unmodified lines25425525625725825926026126226333 unmodified lines2972982993003013028 unmodified lines3113123133143153168 unmodified lines32532632732832933033133233333433533633733833934034134234334434534634734834935034 unmodified linesimport sysimport tarfileimport tempfileimport timefrom pathlib import Path5 unmodified linesGRADER = "grader"SUCCESS_LINE = "Your solution is okay!"GRADE_THREADS = "2"# Lake and Comparator wording when a build process is killed for running out of memory.OOM_MARKERS = ("Lean exited with code 137", "Child exited with 137")188 unmodified linesreturn any(m in out for m in OOM_MARKERS)def run_comparator(run: Path, timeout_sec: int, threads: str = GRADE_THREADS) -> tuple[int | None, str]:env = {"PATH": f"{toolchain_bin()}:/usr/local/bin:/usr/bin:/bin",8 unmodified lines"runuser", "-u", GRADER, "--", "env", "-i", *(f"{k}={v}" for k, v in env.items()),"lake", "env", "comparator", "config.json",]code, stdout, stderr = run_with_timeout(cmd, cwd=run, timeout_sec=timeout_sec,kill_extra=lambda: subprocess.run(["pkill", "-9", "-u", GRADER], capture_output=True),)return code, stdout + "\n--- stderr ---\n" + stderr33 unmodified linesif code is None:return 0, "timed out while building or checking the submission"tail = [l for l in out.splitlines() if l.strip() and "has local changes" not in l][-25:]if out_of_memory(out):return 0, "rejected: the build was killed, most likely out of memory (8 GB) | " + " | ".join(tail)[-3000:]return 0, "rejected: " + " | ".join(tail)[-4000:]8 unmodified linestask = json.loads((TESTS / "task.json").read_text())details: dict = {"task": task["challenge"], "started_at": time.time()}reward: int | None = Nonetry:RUN_ROOT.mkdir(mode=0o711, parents=True, exist_ok=True)deadline = time.time() + int(task["grade_timeout_sec"])8 unmodified lines# Two Lean processes in parallel can exceed 8 GB on a heavy module. Retry once with one,# in a fresh directory: the first attempt's .lake was written by the submission's own# build and must not be trusted for the challenge.run = fresh_run(task)unpack_submission(run)code, out = run_comparator(run, int(deadline - time.time()), threads="1")log += "\n\n=== retried with one Lean process after running out of memory ===\n\n" + outkill_grader()details["retried_single_thread"] = True(VERIFIER_DIR / "comparator.log").write_text(log)reward, details["reason"] = classify(code, out)details["comparator_exit"] = codeexcept Rejected as exc:reward, details["reason"] = 0, f"rejected: {exc}"except GradingError as exc:reward, details["reason"] = None, f"grading error: {exc}"finally:try:kill_grader()except GradingError as exc:reward, details["reason"] = None, f"grading error: {exc}"details["reward"] = rewarddetails["finished_at"] = time.time()(VERIFIER_DIR / "grading.json").write_text(json.dumps(details, indent=2))print(json.dumps(details, indent=2))if reward is not None:34 unmodified lines353637383940415 unmodified lines47484950515253188 unmodified lines2422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892908 unmodified lines29930030130230330430530630730830931031131231331431533 unmodified lines3493503513523533543553568 unmodified lines3653663673683693703718 unmodified lines38038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141234 unmodified linesimport sysimport tarfileimport tempfileimport threadingimport timefrom pathlib import Path5 unmodified linesGRADER = "grader"SUCCESS_LINE = "Your solution is okay!"GRADE_THREADS = "2"SCRATCH_SWEEP_SEC = 15# Lake and Comparator wording when a build process is killed for running out of memory.OOM_MARKERS = ("Lean exited with code 137", "Child exited with 137")188 unmodified linesreturn any(m in out for m in OOM_MARKERS)def out_of_disk(out: str) -> bool:return "no space left on device" in out.lower()# Run as the grader user by `empty_build_scratch`. argv: the .lake/build/ir directory.EMPTY_SCRATCH = r"""import os, sysfor dirpath, _, files in os.walk(sys.argv[1]):for name in files:if not name.endswith(".setup.json"):continuebase = os.path.join(dirpath, name[:-len(".setup.json")])try:# Lake writes X.c.hash once Lean, and leanir if the module needs it, are done with X;# both read X.setup.json, so it may only be emptied after that.if os.stat(base + ".c.hash").st_mtime < os.stat(base + ".setup.json").st_mtime:continuefor path in (base + ".setup.json", base + ".c"):if os.path.getsize(path):os.truncate(path, 0)except OSError:pass"""def empty_build_scratch(run: Path, stop: threading.Event) -> None:"""Until ``stop`` is set, empty files Lake leaves in .lake/build/ir that grading never reads.For every module Lake writes a `.setup.json` (its imports with the path of every .olean theypull in, about 5.5 MB with Mathlib) and the module compiled to C. Neither is used once themodule is built, and for proofs of 1,000-2,000 modules they filled the 10 GB disk before thebuild finished. Lake keeps the recorded hashes, so emptied files do not trigger a rebuild.This runs as the grader user, so it can touch nothing the build could not."""ir = str(run / ".lake" / "build" / "ir")while not stop.wait(SCRATCH_SWEEP_SEC):try:subprocess.run(["runuser", "-u", GRADER, "--", sys.executable, "-c", EMPTY_SCRATCH, ir],capture_output=True, timeout=600)except subprocess.TimeoutExpired:passdef run_comparator(run: Path, timeout_sec: int, threads: str = GRADE_THREADS) -> tuple[int | None, str]:env = {"PATH": f"{toolchain_bin()}:/usr/local/bin:/usr/bin:/bin",8 unmodified lines"runuser", "-u", GRADER, "--", "env", "-i", *(f"{k}={v}" for k, v in env.items()),"lake", "env", "comparator", "config.json",]stop = threading.Event()sweeper = threading.Thread(target=empty_build_scratch, args=(run, stop), daemon=True)sweeper.start()try:code, stdout, stderr = run_with_timeout(cmd, cwd=run, timeout_sec=timeout_sec,kill_extra=lambda: subprocess.run(["pkill", "-9", "-u", GRADER], capture_output=True),)finally:stop.set()sweeper.join()return code, stdout + "\n--- stderr ---\n" + stderr33 unmodified linesif code is None:return 0, "timed out while building or checking the submission"tail = [l for l in out.splitlines() if l.strip() and "has local changes" not in l][-25:]if out_of_disk(out):return 0, "rejected: the build ran out of disk space (10 GB) | " + " | ".join(tail)[-3000:]if out_of_memory(out):return 0, "rejected: the build was killed, most likely out of memory (8 GB) | " + " | ".join(tail)[-3000:]return 0, "rejected: " + " | ".join(tail)[-4000:]8 unmodified linestask = json.loads((TESTS / "task.json").read_text())details: dict = {"task": task["challenge"], "started_at": time.time()}reward: int | None = Nonelog = ""try:RUN_ROOT.mkdir(mode=0o711, parents=True, exist_ok=True)deadline = time.time() + int(task["grade_timeout_sec"])8 unmodified lines# Two Lean processes in parallel can exceed 8 GB on a heavy module. Retry once with one,# in a fresh directory: the first attempt's .lake was written by the submission's own# build and must not be trusted for the challenge.shutil.rmtree(run, ignore_errors=True)run = fresh_run(task)unpack_submission(run)code, out = run_comparator(run, int(deadline - time.time()), threads="1")log += "\n\n=== retried with one Lean process after running out of memory ===\n\n" + outkill_grader()details["retried_single_thread"] = Truereward, details["reason"] = classify(code, out)details["comparator_exit"] = codeexcept Rejected as exc:reward, details["reason"] = 0, f"rejected: {exc}"except GradingError as exc:reward, details["reason"] = None, f"grading error: {exc}"except Exception as exc:reward, details["reason"] = None, f"grading error: {type(exc).__name__}: {exc}"finally:try:kill_grader()except GradingError as exc:reward, details["reason"] = None, f"grading error: {exc}"# Free the build before writing anything. A build that filled the disk would otherwise# make these writes fail, and with no space left the sandbox cannot report that the# verifier exited, so Harbor waits until its own timeout and records no verdict.shutil.rmtree(RUN_ROOT, ignore_errors=True)details["reward"] = rewarddetails["finished_at"] = time.time()(VERIFIER_DIR / "comparator.log").write_text(log)(VERIFIER_DIR / "grading.json").write_text(json.dumps(details, indent=2))print(json.dumps(details, indent=2))if reward is not None:
22 unmodified lines2324252627282922 unmodified linesreference_lean_bytes = 128826reference_requires_packages = []oracle_result = "accepted"oracle_grade_seconds = 601difficulty = "research"[agent]22 unmodified lines2324252627282922 unmodified linesreference_lean_bytes = 128826reference_requires_packages = []oracle_result = "accepted"oracle_grade_seconds = 182difficulty = "research"[agent]
34 unmodified lines3536373839405 unmodified lines464748495051188 unmodified lines2402412422432442458 unmodified lines25425525625725825926026126226333 unmodified lines2972982993003013028 unmodified lines3113123133143153168 unmodified lines32532632732832933033133233333433533633733833934034134234334434534634734834935034 unmodified linesimport sysimport tarfileimport tempfileimport timefrom pathlib import Path5 unmodified linesGRADER = "grader"SUCCESS_LINE = "Your solution is okay!"GRADE_THREADS = "2"# Lake and Comparator wording when a build process is killed for running out of memory.OOM_MARKERS = ("Lean exited with code 137", "Child exited with 137")188 unmodified linesreturn any(m in out for m in OOM_MARKERS)def run_comparator(run: Path, timeout_sec: int, threads: str = GRADE_THREADS) -> tuple[int | None, str]:env = {"PATH": f"{toolchain_bin()}:/usr/local/bin:/usr/bin:/bin",8 unmodified lines"runuser", "-u", GRADER, "--", "env", "-i", *(f"{k}={v}" for k, v in env.items()),"lake", "env", "comparator", "config.json",]code, stdout, stderr = run_with_timeout(cmd, cwd=run, timeout_sec=timeout_sec,kill_extra=lambda: subprocess.run(["pkill", "-9", "-u", GRADER], capture_output=True),)return code, stdout + "\n--- stderr ---\n" + stderr33 unmodified linesif code is None:return 0, "timed out while building or checking the submission"tail = [l for l in out.splitlines() if l.strip() and "has local changes" not in l][-25:]if out_of_memory(out):return 0, "rejected: the build was killed, most likely out of memory (8 GB) | " + " | ".join(tail)[-3000:]return 0, "rejected: " + " | ".join(tail)[-4000:]8 unmodified linestask = json.loads((TESTS / "task.json").read_text())details: dict = {"task": task["challenge"], "started_at": time.time()}reward: int | None = Nonetry:RUN_ROOT.mkdir(mode=0o711, parents=True, exist_ok=True)deadline = time.time() + int(task["grade_timeout_sec"])8 unmodified lines# Two Lean processes in parallel can exceed 8 GB on a heavy module. Retry once with one,# in a fresh directory: the first attempt's .lake was written by the submission's own# build and must not be trusted for the challenge.run = fresh_run(task)unpack_submission(run)code, out = run_comparator(run, int(deadline - time.time()), threads="1")log += "\n\n=== retried with one Lean process after running out of memory ===\n\n" + outkill_grader()details["retried_single_thread"] = True(VERIFIER_DIR / "comparator.log").write_text(log)reward, details["reason"] = classify(code, out)details["comparator_exit"] = codeexcept Rejected as exc:reward, details["reason"] = 0, f"rejected: {exc}"except GradingError as exc:reward, details["reason"] = None, f"grading error: {exc}"finally:try:kill_grader()except GradingError as exc:reward, details["reason"] = None, f"grading error: {exc}"details["reward"] = rewarddetails["finished_at"] = time.time()(VERIFIER_DIR / "grading.json").write_text(json.dumps(details, indent=2))print(json.dumps(details, indent=2))if reward is not None:34 unmodified lines353637383940415 unmodified lines47484950515253188 unmodified lines2422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892908 unmodified lines29930030130230330430530630730830931031131231331431533 unmodified lines3493503513523533543553568 unmodified lines3653663673683693703718 unmodified lines38038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141234 unmodified linesimport sysimport tarfileimport tempfileimport threadingimport timefrom pathlib import Path5 unmodified linesGRADER = "grader"SUCCESS_LINE = "Your solution is okay!"GRADE_THREADS = "2"SCRATCH_SWEEP_SEC = 15# Lake and Comparator wording when a build process is killed for running out of memory.OOM_MARKERS = ("Lean exited with code 137", "Child exited with 137")188 unmodified linesreturn any(m in out for m in OOM_MARKERS)def out_of_disk(out: str) -> bool:return "no space left on device" in out.lower()# Run as the grader user by `empty_build_scratch`. argv: the .lake/build/ir directory.EMPTY_SCRATCH = r"""import os, sysfor dirpath, _, files in os.walk(sys.argv[1]):for name in files:if not name.endswith(".setup.json"):continuebase = os.path.join(dirpath, name[:-len(".setup.json")])try:# Lake writes X.c.hash once Lean, and leanir if the module needs it, are done with X;# both read X.setup.json, so it may only be emptied after that.if os.stat(base + ".c.hash").st_mtime < os.stat(base + ".setup.json").st_mtime:continuefor path in (base + ".setup.json", base + ".c"):if os.path.getsize(path):os.truncate(path, 0)except OSError:pass"""def empty_build_scratch(run: Path, stop: threading.Event) -> None:"""Until ``stop`` is set, empty files Lake leaves in .lake/build/ir that grading never reads.For every module Lake writes a `.setup.json` (its imports with the path of every .olean theypull in, about 5.5 MB with Mathlib) and the module compiled to C. Neither is used once themodule is built, and for proofs of 1,000-2,000 modules they filled the 10 GB disk before thebuild finished. Lake keeps the recorded hashes, so emptied files do not trigger a rebuild.This runs as the grader user, so it can touch nothing the build could not."""ir = str(run / ".lake" / "build" / "ir")while not stop.wait(SCRATCH_SWEEP_SEC):try:subprocess.run(["runuser", "-u", GRADER, "--", sys.executable, "-c", EMPTY_SCRATCH, ir],capture_output=True, timeout=600)except subprocess.TimeoutExpired:passdef run_comparator(run: Path, timeout_sec: int, threads: str = GRADE_THREADS) -> tuple[int | None, str]:env = {"PATH": f"{toolchain_bin()}:/usr/local/bin:/usr/bin:/bin",8 unmodified lines"runuser", "-u", GRADER, "--", "env", "-i", *(f"{k}={v}" for k, v in env.items()),"lake", "env", "comparator", "config.json",]stop = threading.Event()sweeper = threading.Thread(target=empty_build_scratch, args=(run, stop), daemon=True)sweeper.start()try:code, stdout, stderr = run_with_timeout(cmd, cwd=run, timeout_sec=timeout_sec,kill_extra=lambda: subprocess.run(["pkill", "-9", "-u", GRADER], capture_output=True),)finally:stop.set()sweeper.join()return code, stdout + "\n--- stderr ---\n" + stderr33 unmodified linesif code is None:return 0, "timed out while building or checking the submission"tail = [l for l in out.splitlines() if l.strip() and "has local changes" not in l][-25:]if out_of_disk(out):return 0, "rejected: the build ran out of disk space (10 GB) | " + " | ".join(tail)[-3000:]if out_of_memory(out):return 0, "rejected: the build was killed, most likely out of memory (8 GB) | " + " | ".join(tail)[-3000:]return 0, "rejected: " + " | ".join(tail)[-4000:]8 unmodified linestask = json.loads((TESTS / "task.json").read_text())details: dict = {"task": task["challenge"], "started_at": time.time()}reward: int | None = Nonelog = ""try:RUN_ROOT.mkdir(mode=0o711, parents=True, exist_ok=True)deadline = time.time() + int(task["grade_timeout_sec"])8 unmodified lines# Two Lean processes in parallel can exceed 8 GB on a heavy module. Retry once with one,# in a fresh directory: the first attempt's .lake was written by the submission's own# build and must not be trusted for the challenge.shutil.rmtree(run, ignore_errors=True)run = fresh_run(task)unpack_submission(run)code, out = run_comparator(run, int(deadline - time.time()), threads="1")log += "\n\n=== retried with one Lean process after running out of memory ===\n\n" + outkill_grader()details["retried_single_thread"] = Truereward, details["reason"] = classify(code, out)details["comparator_exit"] = codeexcept Rejected as exc:reward, details["reason"] = 0, f"rejected: {exc}"except GradingError as exc:reward, details["reason"] = None, f"grading error: {exc}"except Exception as exc:reward, details["reason"] = None, f"grading error: {type(exc).__name__}: {exc}"finally:try:kill_grader()except GradingError as exc:reward, details["reason"] = None, f"grading error: {exc}"# Free the build before writing anything. A build that filled the disk would otherwise# make these writes fail, and with no space left the sandbox cannot report that the# verifier exited, so Harbor waits until its own timeout and records no verdict.shutil.rmtree(RUN_ROOT, ignore_errors=True)details["reward"] = rewarddetails["finished_at"] = time.time()(VERIFIER_DIR / "comparator.log").write_text(log)(VERIFIER_DIR / "grading.json").write_text(json.dumps(details, indent=2))print(json.dumps(details, indent=2))if reward is not None:
22 unmodified lines2324252627282922 unmodified linesreference_lean_bytes = 152586reference_requires_packages = []oracle_result = "accepted"oracle_grade_seconds = 693difficulty = "research"[agent]22 unmodified lines2324252627282922 unmodified linesreference_lean_bytes = 152586reference_requires_packages = []oracle_result = "accepted"oracle_grade_seconds = 171difficulty = "research"[agent]
34 unmodified lines3536373839405 unmodified lines464748495051188 unmodified lines2402412422432442458 unmodified lines25425525625725825926026126226333 unmodified lines2972982993003013028 unmodified lines3113123133143153168 unmodified lines32532632732832933033133233333433533633733833934034134234334434534634734834935034 unmodified linesimport sysimport tarfileimport tempfileimport timefrom pathlib import Path5 unmodified linesGRADER = "grader"SUCCESS_LINE = "Your solution is okay!"GRADE_THREADS = "2"# Lake and Comparator wording when a build process is killed for running out of memory.OOM_MARKERS = ("Lean exited with code 137", "Child exited with 137")188 unmodified linesreturn any(m in out for m in OOM_MARKERS)def run_comparator(run: Path, timeout_sec: int, threads: str = GRADE_THREADS) -> tuple[int | None, str]:env = {"PATH": f"{toolchain_bin()}:/usr/local/bin:/usr/bin:/bin",8 unmodified lines"runuser", "-u", GRADER, "--", "env", "-i", *(f"{k}={v}" for k, v in env.items()),"lake", "env", "comparator", "config.json",]code, stdout, stderr = run_with_timeout(cmd, cwd=run, timeout_sec=timeout_sec,kill_extra=lambda: subprocess.run(["pkill", "-9", "-u", GRADER], capture_output=True),)return code, stdout + "\n--- stderr ---\n" + stderr33 unmodified linesif code is None:return 0, "timed out while building or checking the submission"tail = [l for l in out.splitlines() if l.strip() and "has local changes" not in l][-25:]if out_of_memory(out):return 0, "rejected: the build was killed, most likely out of memory (8 GB) | " + " | ".join(tail)[-3000:]return 0, "rejected: " + " | ".join(tail)[-4000:]8 unmodified linestask = json.loads((TESTS / "task.json").read_text())details: dict = {"task": task["challenge"], "started_at": time.time()}reward: int | None = Nonetry:RUN_ROOT.mkdir(mode=0o711, parents=True, exist_ok=True)deadline = time.time() + int(task["grade_timeout_sec"])8 unmodified lines# Two Lean processes in parallel can exceed 8 GB on a heavy module. Retry once with one,# in a fresh directory: the first attempt's .lake was written by the submission's own# build and must not be trusted for the challenge.run = fresh_run(task)unpack_submission(run)code, out = run_comparator(run, int(deadline - time.time()), threads="1")log += "\n\n=== retried with one Lean process after running out of memory ===\n\n" + outkill_grader()details["retried_single_thread"] = True(VERIFIER_DIR / "comparator.log").write_text(log)reward, details["reason"] = classify(code, out)details["comparator_exit"] = codeexcept Rejected as exc:reward, details["reason"] = 0, f"rejected: {exc}"except GradingError as exc:reward, details["reason"] = None, f"grading error: {exc}"finally:try:kill_grader()except GradingError as exc:reward, details["reason"] = None, f"grading error: {exc}"details["reward"] = rewarddetails["finished_at"] = time.time()(VERIFIER_DIR / "grading.json").write_text(json.dumps(details, indent=2))print(json.dumps(details, indent=2))if reward is not None:34 unmodified lines353637383940415 unmodified lines47484950515253188 unmodified lines2422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892908 unmodified lines29930030130230330430530630730830931031131231331431533 unmodified lines3493503513523533543553568 unmodified lines3653663673683693703718 unmodified lines38038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141234 unmodified linesimport sysimport tarfileimport tempfileimport threadingimport timefrom pathlib import Path5 unmodified linesGRADER = "grader"SUCCESS_LINE = "Your solution is okay!"GRADE_THREADS = "2"SCRATCH_SWEEP_SEC = 15# Lake and Comparator wording when a build process is killed for running out of memory.OOM_MARKERS = ("Lean exited with code 137", "Child exited with 137")188 unmodified linesreturn any(m in out for m in OOM_MARKERS)def out_of_disk(out: str) -> bool:return "no space left on device" in out.lower()# Run as the grader user by `empty_build_scratch`. argv: the .lake/build/ir directory.EMPTY_SCRATCH = r"""import os, sysfor dirpath, _, files in os.walk(sys.argv[1]):for name in files:if not name.endswith(".setup.json"):continuebase = os.path.join(dirpath, name[:-len(".setup.json")])try:# Lake writes X.c.hash once Lean, and leanir if the module needs it, are done with X;# both read X.setup.json, so it may only be emptied after that.if os.stat(base + ".c.hash").st_mtime < os.stat(base + ".setup.json").st_mtime:continuefor path in (base + ".setup.json", base + ".c"):if os.path.getsize(path):os.truncate(path, 0)except OSError:pass"""def empty_build_scratch(run: Path, stop: threading.Event) -> None:"""Until ``stop`` is set, empty files Lake leaves in .lake/build/ir that grading never reads.For every module Lake writes a `.setup.json` (its imports with the path of every .olean theypull in, about 5.5 MB with Mathlib) and the module compiled to C. Neither is used once themodule is built, and for proofs of 1,000-2,000 modules they filled the 10 GB disk before thebuild finished. Lake keeps the recorded hashes, so emptied files do not trigger a rebuild.This runs as the grader user, so it can touch nothing the build could not."""ir = str(run / ".lake" / "build" / "ir")while not stop.wait(SCRATCH_SWEEP_SEC):try:subprocess.run(["runuser", "-u", GRADER, "--", sys.executable, "-c", EMPTY_SCRATCH, ir],capture_output=True, timeout=600)except subprocess.TimeoutExpired:passdef run_comparator(run: Path, timeout_sec: int, threads: str = GRADE_THREADS) -> tuple[int | None, str]:env = {"PATH": f"{toolchain_bin()}:/usr/local/bin:/usr/bin:/bin",8 unmodified lines"runuser", "-u", GRADER, "--", "env", "-i", *(f"{k}={v}" for k, v in env.items()),"lake", "env", "comparator", "config.json",]stop = threading.Event()sweeper = threading.Thread(target=empty_build_scratch, args=(run, stop), daemon=True)sweeper.start()try:code, stdout, stderr = run_with_timeout(cmd, cwd=run, timeout_sec=timeout_sec,kill_extra=lambda: subprocess.run(["pkill", "-9", "-u", GRADER], capture_output=True),)finally:stop.set()sweeper.join()return code, stdout + "\n--- stderr ---\n" + stderr33 unmodified linesif code is None:return 0, "timed out while building or checking the submission"tail = [l for l in out.splitlines() if l.strip() and "has local changes" not in l][-25:]if out_of_disk(out):return 0, "rejected: the build ran out of disk space (10 GB) | " + " | ".join(tail)[-3000:]if out_of_memory(out):return 0, "rejected: the build was killed, most likely out of memory (8 GB) | " + " | ".join(tail)[-3000:]return 0, "rejected: " + " | ".join(tail)[-4000:]8 unmodified linestask = json.loads((TESTS / "task.json").read_text())details: dict = {"task": task["challenge"], "started_at": time.time()}reward: int | None = Nonelog = ""try:RUN_ROOT.mkdir(mode=0o711, parents=True, exist_ok=True)deadline = time.time() + int(task["grade_timeout_sec"])8 unmodified lines# Two Lean processes in parallel can exceed 8 GB on a heavy module. Retry once with one,# in a fresh directory: the first attempt's .lake was written by the submission's own# build and must not be trusted for the challenge.shutil.rmtree(run, ignore_errors=True)run = fresh_run(task)unpack_submission(run)code, out = run_comparator(run, int(deadline - time.time()), threads="1")log += "\n\n=== retried with one Lean process after running out of memory ===\n\n" + outkill_grader()details["retried_single_thread"] = Truereward, details["reason"] = classify(code, out)details["comparator_exit"] = codeexcept Rejected as exc:reward, details["reason"] = 0, f"rejected: {exc}"except GradingError as exc:reward, details["reason"] = None, f"grading error: {exc}"except Exception as exc:reward, details["reason"] = None, f"grading error: {type(exc).__name__}: {exc}"finally:try:kill_grader()except GradingError as exc:reward, details["reason"] = None, f"grading error: {exc}"# Free the build before writing anything. A build that filled the disk would otherwise# make these writes fail, and with no space left the sandbox cannot report that the# verifier exited, so Harbor waits until its own timeout and records no verdict.shutil.rmtree(RUN_ROOT, ignore_errors=True)details["reward"] = rewarddetails["finished_at"] = time.time()(VERIFIER_DIR / "comparator.log").write_text(log)(VERIFIER_DIR / "grading.json").write_text(json.dumps(details, indent=2))print(json.dumps(details, indent=2))if reward is not None:
22 unmodified lines2324252627282922 unmodified linesreference_lean_bytes = 604021reference_requires_packages = []oracle_result = "accepted"oracle_grade_seconds = 886difficulty = "research"[agent]22 unmodified lines2324252627282922 unmodified linesreference_lean_bytes = 604021reference_requires_packages = []oracle_result = "accepted"oracle_grade_seconds = 408difficulty = "research"[agent]
34 unmodified lines3536373839405 unmodified lines464748495051188 unmodified lines2402412422432442458 unmodified lines25425525625725825926026126226333 unmodified lines2972982993003013028 unmodified lines3113123133143153168 unmodified lines32532632732832933033133233333433533633733833934034134234334434534634734834935034 unmodified linesimport sysimport tarfileimport tempfileimport timefrom pathlib import Path5 unmodified linesGRADER = "grader"SUCCESS_LINE = "Your solution is okay!"GRADE_THREADS = "2"# Lake and Comparator wording when a build process is killed for running out of memory.OOM_MARKERS = ("Lean exited with code 137", "Child exited with 137")188 unmodified linesreturn any(m in out for m in OOM_MARKERS)def run_comparator(run: Path, timeout_sec: int, threads: str = GRADE_THREADS) -> tuple[int | None, str]:env = {"PATH": f"{toolchain_bin()}:/usr/local/bin:/usr/bin:/bin",8 unmodified lines"runuser", "-u", GRADER, "--", "env", "-i", *(f"{k}={v}" for k, v in env.items()),"lake", "env", "comparator", "config.json",]code, stdout, stderr = run_with_timeout(cmd, cwd=run, timeout_sec=timeout_sec,kill_extra=lambda: subprocess.run(["pkill", "-9", "-u", GRADER], capture_output=True),)return code, stdout + "\n--- stderr ---\n" + stderr33 unmodified linesif code is None:return 0, "timed out while building or checking the submission"tail = [l for l in out.splitlines() if l.strip() and "has local changes" not in l][-25:]if out_of_memory(out):return 0, "rejected: the build was killed, most likely out of memory (8 GB) | " + " | ".join(tail)[-3000:]return 0, "rejected: " + " | ".join(tail)[-4000:]8 unmodified linestask = json.loads((TESTS / "task.json").read_text())details: dict = {"task": task["challenge"], "started_at": time.time()}reward: int | None = Nonetry:RUN_ROOT.mkdir(mode=0o711, parents=True, exist_ok=True)deadline = time.time() + int(task["grade_timeout_sec"])8 unmodified lines# Two Lean processes in parallel can exceed 8 GB on a heavy module. Retry once with one,# in a fresh directory: the first attempt's .lake was written by the submission's own# build and must not be trusted for the challenge.run = fresh_run(task)unpack_submission(run)code, out = run_comparator(run, int(deadline - time.time()), threads="1")log += "\n\n=== retried with one Lean process after running out of memory ===\n\n" + outkill_grader()details["retried_single_thread"] = True(VERIFIER_DIR / "comparator.log").write_text(log)reward, details["reason"] = classify(code, out)details["comparator_exit"] = codeexcept Rejected as exc:reward, details["reason"] = 0, f"rejected: {exc}"except GradingError as exc:reward, details["reason"] = None, f"grading error: {exc}"finally:try:kill_grader()except GradingError as exc:reward, details["reason"] = None, f"grading error: {exc}"details["reward"] = rewarddetails["finished_at"] = time.time()(VERIFIER_DIR / "grading.json").write_text(json.dumps(details, indent=2))print(json.dumps(details, indent=2))if reward is not None:34 unmodified lines353637383940415 unmodified lines47484950515253188 unmodified lines2422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892908 unmodified lines29930030130230330430530630730830931031131231331431533 unmodified lines3493503513523533543553568 unmodified lines3653663673683693703718 unmodified lines38038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141234 unmodified linesimport sysimport tarfileimport tempfileimport threadingimport timefrom pathlib import Path5 unmodified linesGRADER = "grader"SUCCESS_LINE = "Your solution is okay!"GRADE_THREADS = "2"SCRATCH_SWEEP_SEC = 15# Lake and Comparator wording when a build process is killed for running out of memory.OOM_MARKERS = ("Lean exited with code 137", "Child exited with 137")188 unmodified linesreturn any(m in out for m in OOM_MARKERS)def out_of_disk(out: str) -> bool:return "no space left on device" in out.lower()# Run as the grader user by `empty_build_scratch`. argv: the .lake/build/ir directory.EMPTY_SCRATCH = r"""import os, sysfor dirpath, _, files in os.walk(sys.argv[1]):for name in files:if not name.endswith(".setup.json"):continuebase = os.path.join(dirpath, name[:-len(".setup.json")])try:# Lake writes X.c.hash once Lean, and leanir if the module needs it, are done with X;# both read X.setup.json, so it may only be emptied after that.if os.stat(base + ".c.hash").st_mtime < os.stat(base + ".setup.json").st_mtime:continuefor path in (base + ".setup.json", base + ".c"):if os.path.getsize(path):os.truncate(path, 0)except OSError:pass"""def empty_build_scratch(run: Path, stop: threading.Event) -> None:"""Until ``stop`` is set, empty files Lake leaves in .lake/build/ir that grading never reads.For every module Lake writes a `.setup.json` (its imports with the path of every .olean theypull in, about 5.5 MB with Mathlib) and the module compiled to C. Neither is used once themodule is built, and for proofs of 1,000-2,000 modules they filled the 10 GB disk before thebuild finished. Lake keeps the recorded hashes, so emptied files do not trigger a rebuild.This runs as the grader user, so it can touch nothing the build could not."""ir = str(run / ".lake" / "build" / "ir")while not stop.wait(SCRATCH_SWEEP_SEC):try:subprocess.run(["runuser", "-u", GRADER, "--", sys.executable, "-c", EMPTY_SCRATCH, ir],capture_output=True, timeout=600)except subprocess.TimeoutExpired:passdef run_comparator(run: Path, timeout_sec: int, threads: str = GRADE_THREADS) -> tuple[int | None, str]:env = {"PATH": f"{toolchain_bin()}:/usr/local/bin:/usr/bin:/bin",8 unmodified lines"runuser", "-u", GRADER, "--", "env", "-i", *(f"{k}={v}" for k, v in env.items()),"lake", "env", "comparator", "config.json",]stop = threading.Event()sweeper = threading.Thread(target=empty_build_scratch, args=(run, stop), daemon=True)sweeper.start()try:code, stdout, stderr = run_with_timeout(cmd, cwd=run, timeout_sec=timeout_sec,kill_extra=lambda: subprocess.run(["pkill", "-9", "-u", GRADER], capture_output=True),)finally:stop.set()sweeper.join()return code, stdout + "\n--- stderr ---\n" + stderr33 unmodified linesif code is None:return 0, "timed out while building or checking the submission"tail = [l for l in out.splitlines() if l.strip() and "has local changes" not in l][-25:]if out_of_disk(out):return 0, "rejected: the build ran out of disk space (10 GB) | " + " | ".join(tail)[-3000:]if out_of_memory(out):return 0, "rejected: the build was killed, most likely out of memory (8 GB) | " + " | ".join(tail)[-3000:]return 0, "rejected: " + " | ".join(tail)[-4000:]8 unmodified linestask = json.loads((TESTS / "task.json").read_text())details: dict = {"task": task["challenge"], "started_at": time.time()}reward: int | None = Nonelog = ""try:RUN_ROOT.mkdir(mode=0o711, parents=True, exist_ok=True)deadline = time.time() + int(task["grade_timeout_sec"])8 unmodified lines# Two Lean processes in parallel can exceed 8 GB on a heavy module. Retry once with one,# in a fresh directory: the first attempt's .lake was written by the submission's own# build and must not be trusted for the challenge.shutil.rmtree(run, ignore_errors=True)run = fresh_run(task)unpack_submission(run)code, out = run_comparator(run, int(deadline - time.time()), threads="1")log += "\n\n=== retried with one Lean process after running out of memory ===\n\n" + outkill_grader()details["retried_single_thread"] = Truereward, details["reason"] = classify(code, out)details["comparator_exit"] = codeexcept Rejected as exc:reward, details["reason"] = 0, f"rejected: {exc}"except GradingError as exc:reward, details["reason"] = None, f"grading error: {exc}"except Exception as exc:reward, details["reason"] = None, f"grading error: {type(exc).__name__}: {exc}"finally:try:kill_grader()except GradingError as exc:reward, details["reason"] = None, f"grading error: {exc}"# Free the build before writing anything. A build that filled the disk would otherwise# make these writes fail, and with no space left the sandbox cannot report that the# verifier exited, so Harbor waits until its own timeout and records no verdict.shutil.rmtree(RUN_ROOT, ignore_errors=True)details["reward"] = rewarddetails["finished_at"] = time.time()(VERIFIER_DIR / "comparator.log").write_text(log)(VERIFIER_DIR / "grading.json").write_text(json.dumps(details, indent=2))print(json.dumps(details, indent=2))if reward is not None:
22 unmodified lines2324252627282922 unmodified linesreference_lean_bytes = 643306reference_requires_packages = []oracle_result = "accepted"oracle_grade_seconds = 811difficulty = "research"[agent]22 unmodified lines2324252627282922 unmodified linesreference_lean_bytes = 643306reference_requires_packages = []oracle_result = "accepted"oracle_grade_seconds = 170difficulty = "research"[agent]
34 unmodified lines3536373839405 unmodified lines464748495051188 unmodified lines2402412422432442458 unmodified lines25425525625725825926026126226333 unmodified lines2972982993003013028 unmodified lines3113123133143153168 unmodified lines32532632732832933033133233333433533633733833934034134234334434534634734834935034 unmodified linesimport sysimport tarfileimport tempfileimport timefrom pathlib import Path5 unmodified linesGRADER = "grader"SUCCESS_LINE = "Your solution is okay!"GRADE_THREADS = "2"# Lake and Comparator wording when a build process is killed for running out of memory.OOM_MARKERS = ("Lean exited with code 137", "Child exited with 137")188 unmodified linesreturn any(m in out for m in OOM_MARKERS)def run_comparator(run: Path, timeout_sec: int, threads: str = GRADE_THREADS) -> tuple[int | None, str]:env = {"PATH": f"{toolchain_bin()}:/usr/local/bin:/usr/bin:/bin",8 unmodified lines"runuser", "-u", GRADER, "--", "env", "-i", *(f"{k}={v}" for k, v in env.items()),"lake", "env", "comparator", "config.json",]code, stdout, stderr = run_with_timeout(cmd, cwd=run, timeout_sec=timeout_sec,kill_extra=lambda: subprocess.run(["pkill", "-9", "-u", GRADER], capture_output=True),)return code, stdout + "\n--- stderr ---\n" + stderr33 unmodified linesif code is None:return 0, "timed out while building or checking the submission"tail = [l for l in out.splitlines() if l.strip() and "has local changes" not in l][-25:]if out_of_memory(out):return 0, "rejected: the build was killed, most likely out of memory (8 GB) | " + " | ".join(tail)[-3000:]return 0, "rejected: " + " | ".join(tail)[-4000:]8 unmodified linestask = json.loads((TESTS / "task.json").read_text())details: dict = {"task": task["challenge"], "started_at": time.time()}reward: int | None = Nonetry:RUN_ROOT.mkdir(mode=0o711, parents=True, exist_ok=True)deadline = time.time() + int(task["grade_timeout_sec"])8 unmodified lines# Two Lean processes in parallel can exceed 8 GB on a heavy module. Retry once with one,# in a fresh directory: the first attempt's .lake was written by the submission's own# build and must not be trusted for the challenge.run = fresh_run(task)unpack_submission(run)code, out = run_comparator(run, int(deadline - time.time()), threads="1")log += "\n\n=== retried with one Lean process after running out of memory ===\n\n" + outkill_grader()details["retried_single_thread"] = True(VERIFIER_DIR / "comparator.log").write_text(log)reward, details["reason"] = classify(code, out)details["comparator_exit"] = codeexcept Rejected as exc:reward, details["reason"] = 0, f"rejected: {exc}"except GradingError as exc:reward, details["reason"] = None, f"grading error: {exc}"finally:try:kill_grader()except GradingError as exc:reward, details["reason"] = None, f"grading error: {exc}"details["reward"] = rewarddetails["finished_at"] = time.time()(VERIFIER_DIR / "grading.json").write_text(json.dumps(details, indent=2))print(json.dumps(details, indent=2))if reward is not None:34 unmodified lines353637383940415 unmodified lines47484950515253188 unmodified lines2422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892908 unmodified lines29930030130230330430530630730830931031131231331431533 unmodified lines3493503513523533543553568 unmodified lines3653663673683693703718 unmodified lines38038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141234 unmodified linesimport sysimport tarfileimport tempfileimport threadingimport timefrom pathlib import Path5 unmodified linesGRADER = "grader"SUCCESS_LINE = "Your solution is okay!"GRADE_THREADS = "2"SCRATCH_SWEEP_SEC = 15# Lake and Comparator wording when a build process is killed for running out of memory.OOM_MARKERS = ("Lean exited with code 137", "Child exited with 137")188 unmodified linesreturn any(m in out for m in OOM_MARKERS)def out_of_disk(out: str) -> bool:return "no space left on device" in out.lower()# Run as the grader user by `empty_build_scratch`. argv: the .lake/build/ir directory.EMPTY_SCRATCH = r"""import os, sysfor dirpath, _, files in os.walk(sys.argv[1]):for name in files:if not name.endswith(".setup.json"):continuebase = os.path.join(dirpath, name[:-len(".setup.json")])try:# Lake writes X.c.hash once Lean, and leanir if the module needs it, are done with X;# both read X.setup.json, so it may only be emptied after that.if os.stat(base + ".c.hash").st_mtime < os.stat(base + ".setup.json").st_mtime:continuefor path in (base + ".setup.json", base + ".c"):if os.path.getsize(path):os.truncate(path, 0)except OSError:pass"""def empty_build_scratch(run: Path, stop: threading.Event) -> None:"""Until ``stop`` is set, empty files Lake leaves in .lake/build/ir that grading never reads.For every module Lake writes a `.setup.json` (its imports with the path of every .olean theypull in, about 5.5 MB with Mathlib) and the module compiled to C. Neither is used once themodule is built, and for proofs of 1,000-2,000 modules they filled the 10 GB disk before thebuild finished. Lake keeps the recorded hashes, so emptied files do not trigger a rebuild.This runs as the grader user, so it can touch nothing the build could not."""ir = str(run / ".lake" / "build" / "ir")while not stop.wait(SCRATCH_SWEEP_SEC):try:subprocess.run(["runuser", "-u", GRADER, "--", sys.executable, "-c", EMPTY_SCRATCH, ir],capture_output=True, timeout=600)except subprocess.TimeoutExpired:passdef run_comparator(run: Path, timeout_sec: int, threads: str = GRADE_THREADS) -> tuple[int | None, str]:env = {"PATH": f"{toolchain_bin()}:/usr/local/bin:/usr/bin:/bin",8 unmodified lines"runuser", "-u", GRADER, "--", "env", "-i", *(f"{k}={v}" for k, v in env.items()),"lake", "env", "comparator", "config.json",]stop = threading.Event()sweeper = threading.Thread(target=empty_build_scratch, args=(run, stop), daemon=True)sweeper.start()try:code, stdout, stderr = run_with_timeout(cmd, cwd=run, timeout_sec=timeout_sec,kill_extra=lambda: subprocess.run(["pkill", "-9", "-u", GRADER], capture_output=True),)finally:stop.set()sweeper.join()return code, stdout + "\n--- stderr ---\n" + stderr33 unmodified linesif code is None:return 0, "timed out while building or checking the submission"tail = [l for l in out.splitlines() if l.strip() and "has local changes" not in l][-25:]if out_of_disk(out):return 0, "rejected: the build ran out of disk space (10 GB) | " + " | ".join(tail)[-3000:]if out_of_memory(out):return 0, "rejected: the build was killed, most likely out of memory (8 GB) | " + " | ".join(tail)[-3000:]return 0, "rejected: " + " | ".join(tail)[-4000:]8 unmodified linestask = json.loads((TESTS / "task.json").read_text())details: dict = {"task": task["challenge"], "started_at": time.time()}reward: int | None = Nonelog = ""try:RUN_ROOT.mkdir(mode=0o711, parents=True, exist_ok=True)deadline = time.time() + int(task["grade_timeout_sec"])8 unmodified lines# Two Lean processes in parallel can exceed 8 GB on a heavy module. Retry once with one,# in a fresh directory: the first attempt's .lake was written by the submission's own# build and must not be trusted for the challenge.shutil.rmtree(run, ignore_errors=True)run = fresh_run(task)unpack_submission(run)code, out = run_comparator(run, int(deadline - time.time()), threads="1")log += "\n\n=== retried with one Lean process after running out of memory ===\n\n" + outkill_grader()details["retried_single_thread"] = Truereward, details["reason"] = classify(code, out)details["comparator_exit"] = codeexcept Rejected as exc:reward, details["reason"] = 0, f"rejected: {exc}"except GradingError as exc:reward, details["reason"] = None, f"grading error: {exc}"except Exception as exc:reward, details["reason"] = None, f"grading error: {type(exc).__name__}: {exc}"finally:try:kill_grader()except GradingError as exc:reward, details["reason"] = None, f"grading error: {exc}"# Free the build before writing anything. A build that filled the disk would otherwise# make these writes fail, and with no space left the sandbox cannot report that the# verifier exited, so Harbor waits until its own timeout and records no verdict.shutil.rmtree(RUN_ROOT, ignore_errors=True)details["reward"] = rewarddetails["finished_at"] = time.time()(VERIFIER_DIR / "comparator.log").write_text(log)(VERIFIER_DIR / "grading.json").write_text(json.dumps(details, indent=2))print(json.dumps(details, indent=2))if reward is not None:
22 unmodified lines2324252627282922 unmodified linesreference_lean_bytes = 816084reference_requires_packages = []oracle_result = "accepted"oracle_grade_seconds = 1484difficulty = "research"[agent]22 unmodified lines2324252627282922 unmodified linesreference_lean_bytes = 816084reference_requires_packages = []oracle_result = "accepted"oracle_grade_seconds = 829difficulty = "research"[agent]
34 unmodified lines3536373839405 unmodified lines464748495051188 unmodified lines2402412422432442458 unmodified lines25425525625725825926026126226333 unmodified lines2972982993003013028 unmodified lines3113123133143153168 unmodified lines32532632732832933033133233333433533633733833934034134234334434534634734834935034 unmodified linesimport sysimport tarfileimport tempfileimport timefrom pathlib import Path5 unmodified linesGRADER = "grader"SUCCESS_LINE = "Your solution is okay!"GRADE_THREADS = "2"# Lake and Comparator wording when a build process is killed for running out of memory.OOM_MARKERS = ("Lean exited with code 137", "Child exited with 137")188 unmodified linesreturn any(m in out for m in OOM_MARKERS)def run_comparator(run: Path, timeout_sec: int, threads: str = GRADE_THREADS) -> tuple[int | None, str]:env = {"PATH": f"{toolchain_bin()}:/usr/local/bin:/usr/bin:/bin",8 unmodified lines"runuser", "-u", GRADER, "--", "env", "-i", *(f"{k}={v}" for k, v in env.items()),"lake", "env", "comparator", "config.json",]code, stdout, stderr = run_with_timeout(cmd, cwd=run, timeout_sec=timeout_sec,kill_extra=lambda: subprocess.run(["pkill", "-9", "-u", GRADER], capture_output=True),)return code, stdout + "\n--- stderr ---\n" + stderr33 unmodified linesif code is None:return 0, "timed out while building or checking the submission"tail = [l for l in out.splitlines() if l.strip() and "has local changes" not in l][-25:]if out_of_memory(out):return 0, "rejected: the build was killed, most likely out of memory (8 GB) | " + " | ".join(tail)[-3000:]return 0, "rejected: " + " | ".join(tail)[-4000:]8 unmodified linestask = json.loads((TESTS / "task.json").read_text())details: dict = {"task": task["challenge"], "started_at": time.time()}reward: int | None = Nonetry:RUN_ROOT.mkdir(mode=0o711, parents=True, exist_ok=True)deadline = time.time() + int(task["grade_timeout_sec"])8 unmodified lines# Two Lean processes in parallel can exceed 8 GB on a heavy module. Retry once with one,# in a fresh directory: the first attempt's .lake was written by the submission's own# build and must not be trusted for the challenge.run = fresh_run(task)unpack_submission(run)code, out = run_comparator(run, int(deadline - time.time()), threads="1")log += "\n\n=== retried with one Lean process after running out of memory ===\n\n" + outkill_grader()details["retried_single_thread"] = True(VERIFIER_DIR / "comparator.log").write_text(log)reward, details["reason"] = classify(code, out)details["comparator_exit"] = codeexcept Rejected as exc:reward, details["reason"] = 0, f"rejected: {exc}"except GradingError as exc:reward, details["reason"] = None, f"grading error: {exc}"finally:try:kill_grader()except GradingError as exc:reward, details["reason"] = None, f"grading error: {exc}"details["reward"] = rewarddetails["finished_at"] = time.time()(VERIFIER_DIR / "grading.json").write_text(json.dumps(details, indent=2))print(json.dumps(details, indent=2))if reward is not None:34 unmodified lines353637383940415 unmodified lines47484950515253188 unmodified lines2422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892908 unmodified lines29930030130230330430530630730830931031131231331431533 unmodified lines3493503513523533543553568 unmodified lines3653663673683693703718 unmodified lines38038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141234 unmodified linesimport sysimport tarfileimport tempfileimport threadingimport timefrom pathlib import Path5 unmodified linesGRADER = "grader"SUCCESS_LINE = "Your solution is okay!"GRADE_THREADS = "2"SCRATCH_SWEEP_SEC = 15# Lake and Comparator wording when a build process is killed for running out of memory.OOM_MARKERS = ("Lean exited with code 137", "Child exited with 137")188 unmodified linesreturn any(m in out for m in OOM_MARKERS)def out_of_disk(out: str) -> bool:return "no space left on device" in out.lower()# Run as the grader user by `empty_build_scratch`. argv: the .lake/build/ir directory.EMPTY_SCRATCH = r"""import os, sysfor dirpath, _, files in os.walk(sys.argv[1]):for name in files:if not name.endswith(".setup.json"):continuebase = os.path.join(dirpath, name[:-len(".setup.json")])try:# Lake writes X.c.hash once Lean, and leanir if the module needs it, are done with X;# both read X.setup.json, so it may only be emptied after that.if os.stat(base + ".c.hash").st_mtime < os.stat(base + ".setup.json").st_mtime:continuefor path in (base + ".setup.json", base + ".c"):if os.path.getsize(path):os.truncate(path, 0)except OSError:pass"""def empty_build_scratch(run: Path, stop: threading.Event) -> None:"""Until ``stop`` is set, empty files Lake leaves in .lake/build/ir that grading never reads.For every module Lake writes a `.setup.json` (its imports with the path of every .olean theypull in, about 5.5 MB with Mathlib) and the module compiled to C. Neither is used once themodule is built, and for proofs of 1,000-2,000 modules they filled the 10 GB disk before thebuild finished. Lake keeps the recorded hashes, so emptied files do not trigger a rebuild.This runs as the grader user, so it can touch nothing the build could not."""ir = str(run / ".lake" / "build" / "ir")while not stop.wait(SCRATCH_SWEEP_SEC):try:subprocess.run(["runuser", "-u", GRADER, "--", sys.executable, "-c", EMPTY_SCRATCH, ir],capture_output=True, timeout=600)except subprocess.TimeoutExpired:passdef run_comparator(run: Path, timeout_sec: int, threads: str = GRADE_THREADS) -> tuple[int | None, str]:env = {"PATH": f"{toolchain_bin()}:/usr/local/bin:/usr/bin:/bin",8 unmodified lines"runuser", "-u", GRADER, "--", "env", "-i", *(f"{k}={v}" for k, v in env.items()),"lake", "env", "comparator", "config.json",]stop = threading.Event()sweeper = threading.Thread(target=empty_build_scratch, args=(run, stop), daemon=True)sweeper.start()try:code, stdout, stderr = run_with_timeout(cmd, cwd=run, timeout_sec=timeout_sec,kill_extra=lambda: subprocess.run(["pkill", "-9", "-u", GRADER], capture_output=True),)finally:stop.set()sweeper.join()return code, stdout + "\n--- stderr ---\n" + stderr33 unmodified linesif code is None:return 0, "timed out while building or checking the submission"tail = [l for l in out.splitlines() if l.strip() and "has local changes" not in l][-25:]if out_of_disk(out):return 0, "rejected: the build ran out of disk space (10 GB) | " + " | ".join(tail)[-3000:]if out_of_memory(out):return 0, "rejected: the build was killed, most likely out of memory (8 GB) | " + " | ".join(tail)[-3000:]return 0, "rejected: " + " | ".join(tail)[-4000:]8 unmodified linestask = json.loads((TESTS / "task.json").read_text())details: dict = {"task": task["challenge"], "started_at": time.time()}reward: int | None = Nonelog = ""try:RUN_ROOT.mkdir(mode=0o711, parents=True, exist_ok=True)deadline = time.time() + int(task["grade_timeout_sec"])8 unmodified lines# Two Lean processes in parallel can exceed 8 GB on a heavy module. Retry once with one,# in a fresh directory: the first attempt's .lake was written by the submission's own# build and must not be trusted for the challenge.shutil.rmtree(run, ignore_errors=True)run = fresh_run(task)unpack_submission(run)code, out = run_comparator(run, int(deadline - time.time()), threads="1")log += "\n\n=== retried with one Lean process after running out of memory ===\n\n" + outkill_grader()details["retried_single_thread"] = Truereward, details["reason"] = classify(code, out)details["comparator_exit"] = codeexcept Rejected as exc:reward, details["reason"] = 0, f"rejected: {exc}"except GradingError as exc:reward, details["reason"] = None, f"grading error: {exc}"except Exception as exc:reward, details["reason"] = None, f"grading error: {type(exc).__name__}: {exc}"finally:try:kill_grader()except GradingError as exc:reward, details["reason"] = None, f"grading error: {exc}"# Free the build before writing anything. A build that filled the disk would otherwise# make these writes fail, and with no space left the sandbox cannot report that the# verifier exited, so Harbor waits until its own timeout and records no verdict.shutil.rmtree(RUN_ROOT, ignore_errors=True)details["reward"] = rewarddetails["finished_at"] = time.time()(VERIFIER_DIR / "comparator.log").write_text(log)(VERIFIER_DIR / "grading.json").write_text(json.dumps(details, indent=2))print(json.dumps(details, indent=2))if reward is not None:
22 unmodified lines2324252627282922 unmodified linesreference_lean_bytes = 698440reference_requires_packages = []oracle_result = "accepted"oracle_grade_seconds = 1163difficulty = "research"[agent]22 unmodified lines2324252627282922 unmodified linesreference_lean_bytes = 698440reference_requires_packages = []oracle_result = "accepted"oracle_grade_seconds = 678difficulty = "research"[agent]
34 unmodified lines3536373839405 unmodified lines464748495051188 unmodified lines2402412422432442458 unmodified lines25425525625725825926026126226333 unmodified lines2972982993003013028 unmodified lines3113123133143153168 unmodified lines32532632732832933033133233333433533633733833934034134234334434534634734834935034 unmodified linesimport sysimport tarfileimport tempfileimport timefrom pathlib import Path5 unmodified linesGRADER = "grader"SUCCESS_LINE = "Your solution is okay!"GRADE_THREADS = "2"# Lake and Comparator wording when a build process is killed for running out of memory.OOM_MARKERS = ("Lean exited with code 137", "Child exited with 137")188 unmodified linesreturn any(m in out for m in OOM_MARKERS)def run_comparator(run: Path, timeout_sec: int, threads: str = GRADE_THREADS) -> tuple[int | None, str]:env = {"PATH": f"{toolchain_bin()}:/usr/local/bin:/usr/bin:/bin",8 unmodified lines"runuser", "-u", GRADER, "--", "env", "-i", *(f"{k}={v}" for k, v in env.items()),"lake", "env", "comparator", "config.json",]code, stdout, stderr = run_with_timeout(cmd, cwd=run, timeout_sec=timeout_sec,kill_extra=lambda: subprocess.run(["pkill", "-9", "-u", GRADER], capture_output=True),)return code, stdout + "\n--- stderr ---\n" + stderr33 unmodified linesif code is None:return 0, "timed out while building or checking the submission"tail = [l for l in out.splitlines() if l.strip() and "has local changes" not in l][-25:]if out_of_memory(out):return 0, "rejected: the build was killed, most likely out of memory (8 GB) | " + " | ".join(tail)[-3000:]return 0, "rejected: " + " | ".join(tail)[-4000:]8 unmodified linestask = json.loads((TESTS / "task.json").read_text())details: dict = {"task": task["challenge"], "started_at": time.time()}reward: int | None = Nonetry:RUN_ROOT.mkdir(mode=0o711, parents=True, exist_ok=True)deadline = time.time() + int(task["grade_timeout_sec"])8 unmodified lines# Two Lean processes in parallel can exceed 8 GB on a heavy module. Retry once with one,# in a fresh directory: the first attempt's .lake was written by the submission's own# build and must not be trusted for the challenge.run = fresh_run(task)unpack_submission(run)code, out = run_comparator(run, int(deadline - time.time()), threads="1")log += "\n\n=== retried with one Lean process after running out of memory ===\n\n" + outkill_grader()details["retried_single_thread"] = True(VERIFIER_DIR / "comparator.log").write_text(log)reward, details["reason"] = classify(code, out)details["comparator_exit"] = codeexcept Rejected as exc:reward, details["reason"] = 0, f"rejected: {exc}"except GradingError as exc:reward, details["reason"] = None, f"grading error: {exc}"finally:try:kill_grader()except GradingError as exc:reward, details["reason"] = None, f"grading error: {exc}"details["reward"] = rewarddetails["finished_at"] = time.time()(VERIFIER_DIR / "grading.json").write_text(json.dumps(details, indent=2))print(json.dumps(details, indent=2))if reward is not None:34 unmodified lines353637383940415 unmodified lines47484950515253188 unmodified lines2422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892908 unmodified lines29930030130230330430530630730830931031131231331431533 unmodified lines3493503513523533543553568 unmodified lines3653663673683693703718 unmodified lines38038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141234 unmodified linesimport sysimport tarfileimport tempfileimport threadingimport timefrom pathlib import Path5 unmodified linesGRADER = "grader"SUCCESS_LINE = "Your solution is okay!"GRADE_THREADS = "2"SCRATCH_SWEEP_SEC = 15# Lake and Comparator wording when a build process is killed for running out of memory.OOM_MARKERS = ("Lean exited with code 137", "Child exited with 137")188 unmodified linesreturn any(m in out for m in OOM_MARKERS)def out_of_disk(out: str) -> bool:return "no space left on device" in out.lower()# Run as the grader user by `empty_build_scratch`. argv: the .lake/build/ir directory.EMPTY_SCRATCH = r"""import os, sysfor dirpath, _, files in os.walk(sys.argv[1]):for name in files:if not name.endswith(".setup.json"):continuebase = os.path.join(dirpath, name[:-len(".setup.json")])try:# Lake writes X.c.hash once Lean, and leanir if the module needs it, are done with X;# both read X.setup.json, so it may only be emptied after that.if os.stat(base + ".c.hash").st_mtime < os.stat(base + ".setup.json").st_mtime:continuefor path in (base + ".setup.json", base + ".c"):if os.path.getsize(path):os.truncate(path, 0)except OSError:pass"""def empty_build_scratch(run: Path, stop: threading.Event) -> None:"""Until ``stop`` is set, empty files Lake leaves in .lake/build/ir that grading never reads.For every module Lake writes a `.setup.json` (its imports with the path of every .olean theypull in, about 5.5 MB with Mathlib) and the module compiled to C. Neither is used once themodule is built, and for proofs of 1,000-2,000 modules they filled the 10 GB disk before thebuild finished. Lake keeps the recorded hashes, so emptied files do not trigger a rebuild.This runs as the grader user, so it can touch nothing the build could not."""ir = str(run / ".lake" / "build" / "ir")while not stop.wait(SCRATCH_SWEEP_SEC):try:subprocess.run(["runuser", "-u", GRADER, "--", sys.executable, "-c", EMPTY_SCRATCH, ir],capture_output=True, timeout=600)except subprocess.TimeoutExpired:passdef run_comparator(run: Path, timeout_sec: int, threads: str = GRADE_THREADS) -> tuple[int | None, str]:env = {"PATH": f"{toolchain_bin()}:/usr/local/bin:/usr/bin:/bin",8 unmodified lines"runuser", "-u", GRADER, "--", "env", "-i", *(f"{k}={v}" for k, v in env.items()),"lake", "env", "comparator", "config.json",]stop = threading.Event()sweeper = threading.Thread(target=empty_build_scratch, args=(run, stop), daemon=True)sweeper.start()try:code, stdout, stderr = run_with_timeout(cmd, cwd=run, timeout_sec=timeout_sec,kill_extra=lambda: subprocess.run(["pkill", "-9", "-u", GRADER], capture_output=True),)finally:stop.set()sweeper.join()return code, stdout + "\n--- stderr ---\n" + stderr33 unmodified linesif code is None:return 0, "timed out while building or checking the submission"tail = [l for l in out.splitlines() if l.strip() and "has local changes" not in l][-25:]if out_of_disk(out):return 0, "rejected: the build ran out of disk space (10 GB) | " + " | ".join(tail)[-3000:]if out_of_memory(out):return 0, "rejected: the build was killed, most likely out of memory (8 GB) | " + " | ".join(tail)[-3000:]return 0, "rejected: " + " | ".join(tail)[-4000:]8 unmodified linestask = json.loads((TESTS / "task.json").read_text())details: dict = {"task": task["challenge"], "started_at": time.time()}reward: int | None = Nonelog = ""try:RUN_ROOT.mkdir(mode=0o711, parents=True, exist_ok=True)deadline = time.time() + int(task["grade_timeout_sec"])8 unmodified lines# Two Lean processes in parallel can exceed 8 GB on a heavy module. Retry once with one,# in a fresh directory: the first attempt's .lake was written by the submission's own# build and must not be trusted for the challenge.shutil.rmtree(run, ignore_errors=True)run = fresh_run(task)unpack_submission(run)code, out = run_comparator(run, int(deadline - time.time()), threads="1")log += "\n\n=== retried with one Lean process after running out of memory ===\n\n" + outkill_grader()details["retried_single_thread"] = Truereward, details["reason"] = classify(code, out)details["comparator_exit"] = codeexcept Rejected as exc:reward, details["reason"] = 0, f"rejected: {exc}"except GradingError as exc:reward, details["reason"] = None, f"grading error: {exc}"except Exception as exc:reward, details["reason"] = None, f"grading error: {type(exc).__name__}: {exc}"finally:try:kill_grader()except GradingError as exc:reward, details["reason"] = None, f"grading error: {exc}"# Free the build before writing anything. A build that filled the disk would otherwise# make these writes fail, and with no space left the sandbox cannot report that the# verifier exited, so Harbor waits until its own timeout and records no verdict.shutil.rmtree(RUN_ROOT, ignore_errors=True)details["reward"] = rewarddetails["finished_at"] = time.time()(VERIFIER_DIR / "comparator.log").write_text(log)(VERIFIER_DIR / "grading.json").write_text(json.dumps(details, indent=2))print(json.dumps(details, indent=2))if reward is not None:
22 unmodified lines2324252627282922 unmodified linesreference_lean_bytes = 693070reference_requires_packages = []oracle_result = "accepted"oracle_grade_seconds = 1222difficulty = "research"[agent]22 unmodified lines2324252627282922 unmodified linesreference_lean_bytes = 693070reference_requires_packages = []oracle_result = "accepted"oracle_grade_seconds = 888difficulty = "research"[agent]
34 unmodified lines3536373839405 unmodified lines464748495051188 unmodified lines2402412422432442458 unmodified lines25425525625725825926026126226333 unmodified lines2972982993003013028 unmodified lines3113123133143153168 unmodified lines32532632732832933033133233333433533633733833934034134234334434534634734834935034 unmodified linesimport sysimport tarfileimport tempfileimport timefrom pathlib import Path5 unmodified linesGRADER = "grader"SUCCESS_LINE = "Your solution is okay!"GRADE_THREADS = "2"# Lake and Comparator wording when a build process is killed for running out of memory.OOM_MARKERS = ("Lean exited with code 137", "Child exited with 137")188 unmodified linesreturn any(m in out for m in OOM_MARKERS)def run_comparator(run: Path, timeout_sec: int, threads: str = GRADE_THREADS) -> tuple[int | None, str]:env = {"PATH": f"{toolchain_bin()}:/usr/local/bin:/usr/bin:/bin",8 unmodified lines"runuser", "-u", GRADER, "--", "env", "-i", *(f"{k}={v}" for k, v in env.items()),"lake", "env", "comparator", "config.json",]code, stdout, stderr = run_with_timeout(cmd, cwd=run, timeout_sec=timeout_sec,kill_extra=lambda: subprocess.run(["pkill", "-9", "-u", GRADER], capture_output=True),)return code, stdout + "\n--- stderr ---\n" + stderr33 unmodified linesif code is None:return 0, "timed out while building or checking the submission"tail = [l for l in out.splitlines() if l.strip() and "has local changes" not in l][-25:]if out_of_memory(out):return 0, "rejected: the build was killed, most likely out of memory (8 GB) | " + " | ".join(tail)[-3000:]return 0, "rejected: " + " | ".join(tail)[-4000:]8 unmodified linestask = json.loads((TESTS / "task.json").read_text())details: dict = {"task": task["challenge"], "started_at": time.time()}reward: int | None = Nonetry:RUN_ROOT.mkdir(mode=0o711, parents=True, exist_ok=True)deadline = time.time() + int(task["grade_timeout_sec"])8 unmodified lines# Two Lean processes in parallel can exceed 8 GB on a heavy module. Retry once with one,# in a fresh directory: the first attempt's .lake was written by the submission's own# build and must not be trusted for the challenge.run = fresh_run(task)unpack_submission(run)code, out = run_comparator(run, int(deadline - time.time()), threads="1")log += "\n\n=== retried with one Lean process after running out of memory ===\n\n" + outkill_grader()details["retried_single_thread"] = True(VERIFIER_DIR / "comparator.log").write_text(log)reward, details["reason"] = classify(code, out)details["comparator_exit"] = codeexcept Rejected as exc:reward, details["reason"] = 0, f"rejected: {exc}"except GradingError as exc:reward, details["reason"] = None, f"grading error: {exc}"finally:try:kill_grader()except GradingError as exc:reward, details["reason"] = None, f"grading error: {exc}"details["reward"] = rewarddetails["finished_at"] = time.time()(VERIFIER_DIR / "grading.json").write_text(json.dumps(details, indent=2))print(json.dumps(details, indent=2))if reward is not None:34 unmodified lines353637383940415 unmodified lines47484950515253188 unmodified lines2422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892908 unmodified lines29930030130230330430530630730830931031131231331431533 unmodified lines3493503513523533543553568 unmodified lines3653663673683693703718 unmodified lines38038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141234 unmodified linesimport sysimport tarfileimport tempfileimport threadingimport timefrom pathlib import Path5 unmodified linesGRADER = "grader"SUCCESS_LINE = "Your solution is okay!"GRADE_THREADS = "2"SCRATCH_SWEEP_SEC = 15# Lake and Comparator wording when a build process is killed for running out of memory.OOM_MARKERS = ("Lean exited with code 137", "Child exited with 137")188 unmodified linesreturn any(m in out for m in OOM_MARKERS)def out_of_disk(out: str) -> bool:return "no space left on device" in out.lower()# Run as the grader user by `empty_build_scratch`. argv: the .lake/build/ir directory.EMPTY_SCRATCH = r"""import os, sysfor dirpath, _, files in os.walk(sys.argv[1]):for name in files:if not name.endswith(".setup.json"):continuebase = os.path.join(dirpath, name[:-len(".setup.json")])try:# Lake writes X.c.hash once Lean, and leanir if the module needs it, are done with X;# both read X.setup.json, so it may only be emptied after that.if os.stat(base + ".c.hash").st_mtime < os.stat(base + ".setup.json").st_mtime:continuefor path in (base + ".setup.json", base + ".c"):if os.path.getsize(path):os.truncate(path, 0)except OSError:pass"""def empty_build_scratch(run: Path, stop: threading.Event) -> None:"""Until ``stop`` is set, empty files Lake leaves in .lake/build/ir that grading never reads.For every module Lake writes a `.setup.json` (its imports with the path of every .olean theypull in, about 5.5 MB with Mathlib) and the module compiled to C. Neither is used once themodule is built, and for proofs of 1,000-2,000 modules they filled the 10 GB disk before thebuild finished. Lake keeps the recorded hashes, so emptied files do not trigger a rebuild.This runs as the grader user, so it can touch nothing the build could not."""ir = str(run / ".lake" / "build" / "ir")while not stop.wait(SCRATCH_SWEEP_SEC):try:subprocess.run(["runuser", "-u", GRADER, "--", sys.executable, "-c", EMPTY_SCRATCH, ir],capture_output=True, timeout=600)except subprocess.TimeoutExpired:passdef run_comparator(run: Path, timeout_sec: int, threads: str = GRADE_THREADS) -> tuple[int | None, str]:env = {"PATH": f"{toolchain_bin()}:/usr/local/bin:/usr/bin:/bin",8 unmodified lines"runuser", "-u", GRADER, "--", "env", "-i", *(f"{k}={v}" for k, v in env.items()),"lake", "env", "comparator", "config.json",]stop = threading.Event()sweeper = threading.Thread(target=empty_build_scratch, args=(run, stop), daemon=True)sweeper.start()try:code, stdout, stderr = run_with_timeout(cmd, cwd=run, timeout_sec=timeout_sec,kill_extra=lambda: subprocess.run(["pkill", "-9", "-u", GRADER], capture_output=True),)finally:stop.set()sweeper.join()return code, stdout + "\n--- stderr ---\n" + stderr33 unmodified linesif code is None:return 0, "timed out while building or checking the submission"tail = [l for l in out.splitlines() if l.strip() and "has local changes" not in l][-25:]if out_of_disk(out):return 0, "rejected: the build ran out of disk space (10 GB) | " + " | ".join(tail)[-3000:]if out_of_memory(out):return 0, "rejected: the build was killed, most likely out of memory (8 GB) | " + " | ".join(tail)[-3000:]return 0, "rejected: " + " | ".join(tail)[-4000:]8 unmodified linestask = json.loads((TESTS / "task.json").read_text())details: dict = {"task": task["challenge"], "started_at": time.time()}reward: int | None = Nonelog = ""try:RUN_ROOT.mkdir(mode=0o711, parents=True, exist_ok=True)deadline = time.time() + int(task["grade_timeout_sec"])8 unmodified lines# Two Lean processes in parallel can exceed 8 GB on a heavy module. Retry once with one,# in a fresh directory: the first attempt's .lake was written by the submission's own# build and must not be trusted for the challenge.shutil.rmtree(run, ignore_errors=True)run = fresh_run(task)unpack_submission(run)code, out = run_comparator(run, int(deadline - time.time()), threads="1")log += "\n\n=== retried with one Lean process after running out of memory ===\n\n" + outkill_grader()details["retried_single_thread"] = Truereward, details["reason"] = classify(code, out)details["comparator_exit"] = codeexcept Rejected as exc:reward, details["reason"] = 0, f"rejected: {exc}"except GradingError as exc:reward, details["reason"] = None, f"grading error: {exc}"except Exception as exc:reward, details["reason"] = None, f"grading error: {type(exc).__name__}: {exc}"finally:try:kill_grader()except GradingError as exc:reward, details["reason"] = None, f"grading error: {exc}"# Free the build before writing anything. A build that filled the disk would otherwise# make these writes fail, and with no space left the sandbox cannot report that the# verifier exited, so Harbor waits until its own timeout and records no verdict.shutil.rmtree(RUN_ROOT, ignore_errors=True)details["reward"] = rewarddetails["finished_at"] = time.time()(VERIFIER_DIR / "comparator.log").write_text(log)(VERIFIER_DIR / "grading.json").write_text(json.dumps(details, indent=2))print(json.dumps(details, indent=2))if reward is not None:
12345678# Shared by every openai/math task (agent and separate verifier). See lean_setup.sh.FROM ubuntu:24.04ENV ELAN_HOME=/opt/elan \ PATH=/opt/elan/bin:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin \ LANG=C.UTF-8COPY lean_setup.sh fetch_mathlib.sh lakefile.lean lake-manifest.json pack_submission.py /opt/build/RUN bash /opt/build/lean_setup.shWORKDIR /workspace12345678910111213141516171819#!/usr/bin/env bash# Unpack Mathlib's prebuilt cache in batches and truncate the files that importing Mathlib never# reads (generated C and .ilean editor indexes), keeping their .hash files so Lake still sees every# module as built. Lean + full Mathlib otherwise needs ~11 GB, more than a 10 GB sandbox disk.set -euo pipefailcd /opt/lean-envtrim() { find .lake/packages -path '*/.lake/build/*' \( -name '*.c' -o -name '*.ilean' \) -size +0 -exec truncate -s 0 {} + rm -rf "${HOME:-/root}/.cache/mathlib"}for dir in .lake/packages/mathlib/Mathlib/*/; do name=$(basename "$dir") echo "== Mathlib/$name" lake exe cache get ".lake/packages/mathlib/Mathlib/$name" >/dev/null trim df -h / | tail -1donelake exe cache gettrim123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116{ "version": "1.2.0", "packagesDir": ".lake/packages", "packages": [ { "url": "https://github.com/leanprover-community/mathlib4.git", "type": "git", "subDir": null, "scope": "", "rev": "d13f23b723b8a846827a245b89c10fc7d3f11612", "name": "mathlib", "manifestFile": "lake-manifest.json", "inputRev": "d13f23b723b8a846827a245b89c10fc7d3f11612", "inherited": false, "configFile": "lakefile.lean" }, { "url": "https://github.com/leanprover-community/plausible", "type": "git", "subDir": null, "scope": "leanprover-community", "rev": "118aa17ee84656b8bd727fef7c458ee8c833385c", "name": "plausible", "manifestFile": "lake-manifest.json", "inputRev": "main", "inherited": true, "configFile": "lakefile.toml" }, { "url": "https://github.com/leanprover-community/LeanSearchClient", "type": "git", "subDir": null, "scope": "leanprover-community", "rev": "ddf04cf3949fa556442341e87d47f9f6e6074707", "name": "LeanSearchClient", "manifestFile": "lake-manifest.json", "inputRev": "main", "inherited": true, "configFile": "lakefile.toml" }, { "url": "https://github.com/leanprover-community/import-graph", "type": "git", "subDir": null, "scope": "leanprover-community", "rev": "e928b72544873815af278d38681b31c0293588e3", "name": "importGraph", "manifestFile": "lake-manifest.json", "inputRev": "main", "inherited": true, "configFile": "lakefile.toml" }, { "url": "https://github.com/leanprover-community/ProofWidgets4", "type": "git", "subDir": null, "scope": "leanprover-community", "rev": "106ff4fafc74ef4ac99d81dbf3ab399118f497a5", "name": "proofwidgets", "manifestFile": "lake-manifest.json", "inputRev": "main", "inherited": true, "configFile": "lakefile.lean" }, { "url": "https://github.com/leanprover-community/aesop", "type": "git", "subDir": null, "scope": "leanprover-community", "rev": "355695d523e41d0554926416cba2a2b3544fbbc9", "name": "aesop", "manifestFile": "lake-manifest.json", "inputRev": "master", "inherited": true, "configFile": "lakefile.toml" }, { "url": "https://github.com/leanprover-community/quote4", "type": "git", "subDir": null, "scope": "leanprover-community", "rev": "6a489d9af5d0c47e5b259e2e8bcdfc1811b5a259", "name": "Qq", "manifestFile": "lake-manifest.json", "inputRev": "master", "inherited": true, "configFile": "lakefile.toml" }, { "url": "https://github.com/leanprover-community/batteries", "type": "git", "subDir": null, "scope": "leanprover-community", "rev": "f2effa3d803fda822b1f97b806c47cf2adfbcbc2", "name": "batteries", "manifestFile": "lake-manifest.json", "inputRev": "main", "inherited": true, "configFile": "lakefile.toml" }, { "url": "https://github.com/leanprover/lean4-cli", "type": "git", "subDir": null, "scope": "leanprover", "rev": "e92c9f15fdfacc8536f31cfb3b7ad26c3c8cd204", "name": "Cli", "manifestFile": "lake-manifest.json", "inputRev": "v4.34.0", "inherited": true, "configFile": "lakefile.toml" } ], "name": "openai_math", "lakeDir": ".lake"}123456789101112import Lakeopen Lake DSL
-- Mathlib at the commit openai/math pins. Agents write `Submission.lean` and `Submission/**.lean`.package openai_math where leanOptions := #[⟨`autoImplicit, false⟩]
require mathlib from git "https://github.com/leanprover-community/mathlib4.git" @ "d13f23b723b8a846827a245b89c10fc7d3f11612"
-- `Submission` and every `Submission.*` module it imports.lean_lib Submission123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126#!/usr/bin/env bash# Builds the image shared by every openai/math task, for both the agent and the separate verifier:# - Lean v4.34.1 and Mathlib d13f23b, the versions openai/math pins (Mathlib only, no OAI library)# - Comparator, lean4export and landrun, used only by the verifier's grade.py# - every challenge statement, at /opt/openai-math/challenges/<Name>.lean# - /workspace, a Lake project where the agent writes Submission.lean# All revisions are pinned. The openai/math library (the reference proofs) is never installed.set -euxo pipefailexport DEBIAN_FRONTEND=noninteractive
LEAN_TOOLCHAIN=leanprover/lean4:v4.34.1OPENAI_MATH_REV=adc7f1241b42e322a6451854ab7e4b4c146bf78aCOMPARATOR_REV=d03acab154d269c06e60e4de7e4cc85deebff94b # "bump toolchain to v4.34.0"; built with v4.34.1LANDRUN_REV=811cfff51ceaf3d9843708aa6d22e9b84ccac8b4GO_VERSION=1.24.7
apt-get update -qqapt-get install -y -qq --no-install-recommends git curl ca-certificates build-essential xz-utils \ zstd python3 procps iproute2 iptables tmux >/dev/nullrm -rf /var/lib/apt/lists/*git config --system --add safe.directory '*'
export ELAN_HOME=/opt/elan PATH=/opt/elan/bin:$PATHcurl -sSfL https://raw.githubusercontent.com/leanprover/elan/master/elan-init.sh \ | sh -s -- -y --default-toolchain "$LEAN_TOOLCHAIN" --no-modify-path
# --- Verifier tools, built before Mathlib so the build trees are gone before the big download ---curl -sSfL "https://go.dev/dl/go${GO_VERSION}.linux-amd64.tar.gz" | tar -C /tmp -xzGOBIN=/usr/local/bin GOPATH=/tmp/gopath GOCACHE=/tmp/gocache \ /tmp/go/bin/go install "github.com/zouuup/landrun/cmd/landrun@${LANDRUN_REV}"rm -rf /tmp/go /tmp/gopath /tmp/gocache
git clone -q https://github.com/leanprover/comparator.git /tmp/comparator( cd /tmp/comparator git checkout -q "$COMPARATOR_REV" # Comparator passes only PATH/HOME/LEAN_ABORT_ON_PANIC into its landrun sandbox. Also pass # LEAN_NUM_THREADS: Lean sees every host CPU (64) rather than the sandbox's 4, so without it Lake # starts one Mathlib-loaded `lean` per module and an 8 GB sandbox runs out of memory. It bounds # parallelism only and does not affect what is checked. sed -i 's/envPass := #\["PATH", "HOME", "LEAN_ABORT_ON_PANIC"\]/envPass := #["PATH", "HOME", "LEAN_ABORT_ON_PANIC", "LEAN_NUM_THREADS"]/; s/envPass := #\["PATH", "HOME", "LEAN_PATH", "LEAN_ABORT_ON_PANIC"\]/envPass := #["PATH", "HOME", "LEAN_PATH", "LEAN_ABORT_ON_PANIC", "LEAN_NUM_THREADS"]/' Main.lean test "$(grep -c '"LEAN_NUM_THREADS"' Main.lean)" -eq 2 echo "$LEAN_TOOLCHAIN" > lean-toolchain lake build lean4export comparator install -m 0755 .lake/build/bin/comparator /usr/local/bin/comparator install -m 0755 .lake/packages/lean4export/.lake/build/bin/lean4export /usr/local/bin/lean4export)rm -rf /tmp/comparator
# --- Lean project with Mathlib ---# Packages are shallow clones at the manifest revisions, so Lake sees the right HEAD and never fetches.mkdir -p /opt/lean-env/.lake/packagescd /opt/lean-envecho "$LEAN_TOOLCHAIN" > lean-toolchaincp /opt/build/lakefile.lean /opt/build/lake-manifest.json .python3 - <<'PY'import json, subprocessfor p in json.load(open("lake-manifest.json"))["packages"]: d = f".lake/packages/{p['name']}" subprocess.run(["git", "init", "-q", d], check=True) subprocess.run(["git", "-C", d, "remote", "add", "origin", p["url"]], check=True) subprocess.run(["git", "-C", d, "fetch", "-q", "--depth", "1", "origin", p["rev"]], check=True) subprocess.run(["git", "-C", d, "checkout", "-q", "FETCH_HEAD"], check=True)PY# Linking native executables (Comparator above, Mathlib's cache tool here) is the only use of the# static libraries, LLVM and gcc; `lean` and `lake build` of a library need none of them. Dropping# them before the Mathlib download keeps the build, and the image, under Daytona's 10 GB disk.lake exe cache --help >/dev/null 2>&1 || truefind /opt/elan/toolchains/*/lib -name '*.a' -deleterm -f /opt/elan/toolchains/*/lib/libLLVM* /opt/elan/toolchains/*/lib/libclang-cpp*apt-get purge -y -qq $(dpkg-query -W -f '${binary:Package}\n' build-essential 'gcc-13*' 'g++-13*' \ 'cpp-13*' 'libstdc++-13-dev*' 'libgcc-13-dev*' 2>/dev/null) >/dev/null || trueapt-get autoremove -y -qq >/dev/null || truebash /opt/build/fetch_mathlib.shrm -f /opt/lean-env/.lake/packages/mathlib/.lake/build/bin/cache
# --- Challenge statements (public; the reference proofs are not fetched) ---git init -q /tmp/oai && cd /tmp/oaigit remote add origin https://github.com/openai/math.gitgit config core.sparseCheckout trueecho "lean/ComparatorChallenges/" > .git/info/sparse-checkoutgit fetch -q --depth 1 --filter=blob:none origin "$OPENAI_MATH_REV"git checkout -q FETCH_HEADmkdir -p /opt/openai-math/challengescp lean/ComparatorChallenges/*.lean /opt/openai-math/challenges/cd / && rm -rf /tmp/oaiinstall -m 0755 /opt/build/pack_submission.py /opt/openai-math/pack_submission.py
# --- Agent workspace and the verifier's unprivileged user ---mkdir -p /workspace/.lakecp /opt/lean-env/lakefile.lean /opt/lean-env/lake-manifest.json /opt/lean-env/lean-toolchain /workspace/ln -s /opt/lean-env/.lake/packages /workspace/.lake/packagesuseradd --uid 2000 --create-home --shell /usr/sbin/nologin gradermkdir -p /var/lib/oai-grade && chmod 0711 /var/lib/oai-grade
# Smoke test. The first build may rebuild a few dependency modules the cache lacks (they persist in# the image); a second build must compile nothing but Submission, or agents would pay for it.cd /workspaceprintf 'import Mathlib\n\nexample : (2 : ℕ) + 2 = 4 := by norm_num\n' > Submission.leanlake build Submission 2>&1 | grep -E 'Built|error' | grep -v 'Built Submission' | head -20 || trueecho '-- second build' >> Submission.leanlake build Submission 2>&1 | tee /tmp/smoke.logif grep 'Built' /tmp/smoke.log | grep -qv 'Built Submission'; then echo "the prebuilt Mathlib is incomplete: a second build still compiled dependencies" >&2; exit 1firm -rf Submission.lean .lake/build /tmp/smoke.log
# Mathlib's cache tool unpacks files as 0600. The verifier builds as the unprivileged `grader` user,# so everything must be world-readable (and stays root-owned, so not writable).chmod -R a+rX /opt/elan /opt/lean-env /opt/openai-math# Same smoke test as `grader`, in a scratch project like the one grade.py lays out.smoke=$(mktemp -d /var/lib/oai-grade/smoke.XXXX)cp /opt/lean-env/lakefile.lean /opt/lean-env/lake-manifest.json /opt/lean-env/lean-toolchain "$smoke/"mkdir "$smoke/.lake" && ln -s /opt/lean-env/.lake/packages "$smoke/.lake/packages"printf 'import Mathlib\n\nexample : (2 : ℕ) + 2 = 4 := by norm_num\n' > "$smoke/Submission.lean"chmod 0755 "$smoke" && chown grader "$smoke/.lake"(cd "$smoke" && runuser -u grader -- env -i PATH="$(echo /opt/elan/toolchains/*/bin):/usr/bin:/bin" HOME="$smoke" \ lake build Submission) 2>&1 | tee /tmp/smoke.logif grep 'Built' /tmp/smoke.log | grep -qv 'Built Submission' || ! grep -q 'Build completed successfully' /tmp/smoke.log; then echo "the grader user cannot build against the prebuilt Mathlib" >&2; exit 1firm -rf "$smoke" /tmp/smoke.log
rm -rf /opt/build /root/.cachedf -h / | tail -1du -sh /opt/elan /opt/lean-env12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970#!/usr/bin/env python3"""Pack the agent's proof into one file for the verifier.
Harbor runs this as a [[verifier.collect]] hook in the agent's sandbox after the agent finishes.It clears /logs/artifacts and writes /logs/artifacts/submission.tar holding only regular`Submission.lean` and `Submission/**.lean` files. Symlinks and other entries are skipped, neverfollowed, so only one plain file crosses to the verifier sandbox.
The agent's sandbox is untrusted, so the verifier re-checks every entry of the archive. This steponly keeps the transfer small and free of links."""
from __future__ import annotations
import osimport shutilimport statimport tarfilefrom pathlib import Path
WORKSPACE = Path("/workspace")OUT_DIR = Path("/logs/artifacts")MAX_TOTAL_BYTES = 768 << 20
def clear(directory: Path) -> None: directory.mkdir(parents=True, exist_ok=True) for entry in directory.iterdir(): if entry.is_dir() and not entry.is_symlink(): shutil.rmtree(entry) else: entry.unlink()
def regular(path: Path) -> bool: try: return stat.S_ISREG(path.lstat().st_mode) except OSError: return False
def main() -> None: clear(OUT_DIR) tmp = OUT_DIR / "submission.tar.part" total = 0 with tarfile.open(tmp, "w", format=tarfile.PAX_FORMAT) as tar: root = WORKSPACE / "Submission.lean" if regular(root): total += root.lstat().st_size if total > MAX_TOTAL_BYTES: raise SystemExit("submission exceeds the size limit") tar.add(root, arcname="Submission.lean", recursive=False) tree = WORKSPACE / "Submission" if tree.is_dir() and not tree.is_symlink(): for dirpath, dirnames, filenames in os.walk(tree, followlinks=False): dirnames[:] = [d for d in dirnames if not (Path(dirpath) / d).is_symlink()] for name in sorted(filenames): path = Path(dirpath) / name if not name.endswith(".lean") or not regular(path): continue total += path.lstat().st_size if total > MAX_TOTAL_BYTES: raise SystemExit("submission exceeds the size limit") tar.add(path, arcname=str(path.relative_to(WORKSPACE)), recursive=False) tmp.rename(OUT_DIR / "submission.tar") print(f"packed {total} bytes")
if __name__ == "__main__": main()123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081# openai/math challenge `RamseyFive` (family 170)
Prove the following result from OpenAI's [openai/math](https://github.com/openai/math) release inLean 4, with a proof the Lean kernel accepts.
Context: this statement belongs to family 170 of the release, *Sharp logarithmic exponents for off-diagonal Ramsey numbers*(Combinatorics). The family as a whole: For every fixed integer $s\ge5$, proves $r(s,t)=t^{s-1}/(\log t)^{s-2+o(1)}$ as $t\to\infty$, determining the logarithmic exponent and matching the classical upper bound at that scale. Here $r(s,t)$ is the least number of vertices forcing an $s$-clique or a $t$-vertex independent set.
The challenge is `RamseyFive`, also at `/opt/openai-math/challenges/RamseyFive.lean`:
```leanimport Mathlib
namespace OAI
namespace SharpRamseyFive
def RamseyProperty (s t n : ℕ) : Prop := ∀ G : SimpleGraph (Fin n), (∃ A : Finset (Fin n), G.IsNClique s A) ∨ (∃ B : Finset (Fin n), G.IsNIndepSet t B)
noncomputable def ramsey (s t : ℕ) : ℕ := sInf {n : ℕ | RamseyProperty s t n}
def SharpBounds : Prop := ∃ C : ℝ, 0 < C ∧ ∀ ε : ℝ, 0 < ε → ∃ t₀ : ℕ, ∀ t : ℕ, t₀ ≤ t → (t : ℝ) ^ 4 / Real.rpow (Real.log t) (3 + ε) ≤ (ramsey 5 t : ℝ) ∧ (ramsey 5 t : ℝ) ≤ C * (t : ℝ) ^ 4 / (Real.log t) ^ 3
def SharpExponent : Prop := Filter.Tendsto (fun t : ℕ => (4 * Real.log (t : ℝ) - Real.log (ramsey 5 t : ℝ)) / Real.log (Real.log (t : ℝ))) Filter.atTop (nhds (3 : ℝ))
theorem main : SharpBounds ∧ SharpExponent := by sorry
end SharpRamseyFive
end OAI```
## What to submit
Write `/workspace/Submission.lean`. Start from a copy of the challenge:
```bashcp /opt/openai-math/challenges/RamseyFive.lean /workspace/Submission.lean```
then replace every `sorry` with a proof. The file is graded on three things:
- **Same statements.** The theorem `OAI.SharpRamseyFive.main` must keep exactly the statement shown above: same names, namespaces, binders and types. Every definition the statements use must stay exactly as written. Change nothing except the proofs.- **Standard axioms only.** Proofs may use only `propext`, `Quot.sound` and `Classical.choice`. `sorry`, `admit`, new `axiom`s and `native_decide` (it introduces an axiom of its own) are rejected.- **Keep the challenge's declarations as they are.** Put new lemmas and instances *after* the definitions the statements use, or in a separate `Submission/*.lean` module. A declaration added before them can change how they elaborate, and then they no longer match the challenge.- **Kernel-checked.** The proofs are re-checked by the Lean kernel, not just the elaborator.
Long proofs can be split into modules under `/workspace/Submission/` (module names`Submission.Foo`, `Submission.Foo.Bar`) imported from `Submission.lean`. Only `.lean` files atthose two paths are graded.
## Environment
- Lean `v4.34.1` and Mathlib at commit `d13f23b` are installed and prebuilt; `/workspace` is a Lake project.- The sandbox has 4 CPUs and 8 GB of memory; `LEAN_NUM_THREADS=3` keeps `lake build` to three parallel jobs. Check your work with `cd /workspace && lake build Submission`. Add `#print axioms <name>` to see which axioms a proof uses.- There is no internet access. OpenAI's own proofs are not installed.
## Grading
When you finish, `Submission.lean` and `Submission/**.lean` are copied to a fresh machine andchecked with [Comparator](https://github.com/leanprover/comparator), the Lean FRO's proof checker.The reward is 1 if Comparator accepts the proof and 0 otherwise. A partial proof scores 0.123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482OAI.Combinatorics.RamseyFive.Bounds.DensityUpperOAI.Combinatorics.RamseyFive.Bounds.PrimeConstructionOAI.Combinatorics.RamseyFive.Bounds.PrimeStreamOAI.Combinatorics.RamseyFive.Bounds.RamseyPropertyRelatedOAI.Combinatorics.RamseyFive.Bounds.UpperSetOAI.Combinatorics.RamseyFive.Decoding.BestOAI.Combinatorics.RamseyFive.Decoding.BetaOAI.Combinatorics.RamseyFive.Decoding.CoordinateMapOAI.Combinatorics.RamseyFive.Decoding.DimensionTwoProcedureOAI.Combinatorics.RamseyFive.Decoding.FinsetEquivPositionsOAI.Combinatorics.RamseyFive.Decoding.FreshPublicValidationOAI.Combinatorics.RamseyFive.Decoding.FreshValidationOAI.Combinatorics.RamseyFive.Decoding.HighRoundNumbersOAI.Combinatorics.RamseyFive.Decoding.HighSampleDecoderOAI.Combinatorics.RamseyFive.Decoding.LargeTrainingCellOAI.Combinatorics.RamseyFive.Decoding.LargeValueCountOAI.Combinatorics.RamseyFive.Decoding.MetadataCodecOAI.Combinatorics.RamseyFive.Decoding.MetadataScalarsOAI.Combinatorics.RamseyFive.Decoding.NonpairsOAI.Combinatorics.RamseyFive.Decoding.OffFiberPairsOAI.Combinatorics.RamseyFive.Decoding.PairExpBoundOAI.Combinatorics.RamseyFive.Decoding.PairPointsOAI.Combinatorics.RamseyFive.Decoding.PeelMessageOAI.Combinatorics.RamseyFive.Decoding.ProducedCapExclusionOAI.Combinatorics.RamseyFive.Decoding.PublicTrainingOAI.Combinatorics.RamseyFive.Decoding.ReverseCapOAI.Combinatorics.RamseyFive.Decoding.ReverseParametersOAI.Combinatorics.RamseyFive.Decoding.RichCentersOAI.Combinatorics.RamseyFive.Decoding.RichCentersCardOAI.Combinatorics.RamseyFive.Decoding.ScalarConditionsOAI.Combinatorics.RamseyFive.Decoding.SumDiagonalOAI.Combinatorics.RamseyFive.Decoding.SwapOAI.Combinatorics.RamseyFive.Decoding.ThresholdOAI.Combinatorics.RamseyFive.Decoding.TrainingOAI.Combinatorics.RamseyFive.Decoding.TwoPeelMessageOAI.Combinatorics.RamseyFive.Decoding.UniversalFreshOAI.Combinatorics.RamseyFive.Decoding.UniversalReverseOAI.Combinatorics.RamseyFive.Entropy.AllWindowCostOAI.Combinatorics.RamseyFive.Entropy.BandCoreRanksOAI.Combinatorics.RamseyFive.Entropy.BaseAlphabetCostOAI.Combinatorics.RamseyFive.Entropy.BaseFiniteCostOAI.Combinatorics.RamseyFive.Entropy.BaseMessageCostOAI.Combinatorics.RamseyFive.Entropy.BlockRevealOAI.Combinatorics.RamseyFive.Entropy.BlockSelectedOAI.Combinatorics.RamseyFive.Entropy.CapDecoderOAI.Combinatorics.RamseyFive.Entropy.ChronologicalCapDominationOAI.Combinatorics.RamseyFive.Entropy.ClassExtractionOAI.Combinatorics.RamseyFive.Entropy.ClassSelectionOAI.Combinatorics.RamseyFive.Entropy.ClippedWeightOAI.Combinatorics.RamseyFive.Entropy.CollisionSamplingOAI.Combinatorics.RamseyFive.Entropy.ConditionPullbackOAI.Combinatorics.RamseyFive.Entropy.ConditionalSamplingOAI.Combinatorics.RamseyFive.Entropy.ContextDescriptionOAI.Combinatorics.RamseyFive.Entropy.CountedExtractionOAI.Combinatorics.RamseyFive.Entropy.DegreeCountFourOAI.Combinatorics.RamseyFive.Entropy.DeletionNumericsOAI.Combinatorics.RamseyFive.Entropy.DescriptionCleanOAI.Combinatorics.RamseyFive.Entropy.DimensionThreePairsOAI.Combinatorics.RamseyFive.Entropy.EmptyWeightOAI.Combinatorics.RamseyFive.Entropy.EntropyCrossEntropyOAI.Combinatorics.RamseyFive.Entropy.EventMassOAI.Combinatorics.RamseyFive.Entropy.EventWeightOAI.Combinatorics.RamseyFive.Entropy.EventuallyHighPolyCostOAI.Combinatorics.RamseyFive.Entropy.EvictionDriftOAI.Combinatorics.RamseyFive.Entropy.FinalMarkingOAI.Combinatorics.RamseyFive.Entropy.FinalValidationBudgetOAI.Combinatorics.RamseyFive.Entropy.FiniteGrowthOAI.Combinatorics.RamseyFive.Entropy.FiniteKernelsOAI.Combinatorics.RamseyFive.Entropy.FiniteNodeCostOAI.Combinatorics.RamseyFive.Entropy.FiniteNodeProcessOAI.Combinatorics.RamseyFive.Entropy.FinitePiLawOAI.Combinatorics.RamseyFive.Entropy.FlagAlphabetLogsOAI.Combinatorics.RamseyFive.Entropy.FreshProcessOAI.Combinatorics.RamseyFive.Entropy.FreshPublicFamilyOAI.Combinatorics.RamseyFive.Entropy.GenericFreshCostOAI.Combinatorics.RamseyFive.Entropy.GoodEndpointsOAI.Combinatorics.RamseyFive.Entropy.GoodIndexThresholdOAI.Combinatorics.RamseyFive.Entropy.GoodPairScoresOAI.Combinatorics.RamseyFive.Entropy.GoodRepresentativeOAI.Combinatorics.RamseyFive.Entropy.GuardedNodeCostOAI.Combinatorics.RamseyFive.Entropy.GuardedNodeOriginalOAI.Combinatorics.RamseyFive.Entropy.HighOAI.Combinatorics.RamseyFive.Entropy.HighBudgetPolyOAI.Combinatorics.RamseyFive.Entropy.HighEndpointCutoffsOAI.Combinatorics.RamseyFive.Entropy.HighEntropyNumericsOAI.Combinatorics.RamseyFive.Entropy.HighExceptionsOAI.Combinatorics.RamseyFive.Entropy.HighMomentBudgetOAI.Combinatorics.RamseyFive.Entropy.HistoryOAI.Combinatorics.RamseyFive.Entropy.HistoryCylinderOAI.Combinatorics.RamseyFive.Entropy.HitsOAI.Combinatorics.RamseyFive.Entropy.IIDLowerTailOAI.Combinatorics.RamseyFive.Entropy.IndependentLawOAI.Combinatorics.RamseyFive.Entropy.IndependentSamplingOAI.Combinatorics.RamseyFive.Entropy.IndependentTargetLossOAI.Combinatorics.RamseyFive.Entropy.IndexMulOAI.Combinatorics.RamseyFive.Entropy.IteratedBudgetsOAI.Combinatorics.RamseyFive.Entropy.LawOAI.Combinatorics.RamseyFive.Entropy.LevelCellSubsetOAI.Combinatorics.RamseyFive.Entropy.LevelDensityOAI.Combinatorics.RamseyFive.Entropy.LevelTreeTrimsOAI.Combinatorics.RamseyFive.Entropy.LocalNodeLawOAI.Combinatorics.RamseyFive.Entropy.LogContractionDropOAI.Combinatorics.RamseyFive.Entropy.LogSumOAI.Combinatorics.RamseyFive.Entropy.LowBudgetPolyOAI.Combinatorics.RamseyFive.Entropy.LowMomentBudgetOAI.Combinatorics.RamseyFive.Entropy.MapOAI.Combinatorics.RamseyFive.Entropy.MapFstOAI.Combinatorics.RamseyFive.Entropy.MarkedActualBudgetOAI.Combinatorics.RamseyFive.Entropy.MarkingBudgetOAI.Combinatorics.RamseyFive.Entropy.MarkingNumericsOAI.Combinatorics.RamseyFive.Entropy.MeanTreeFailureOAI.Combinatorics.RamseyFive.Entropy.MessageCountingOAI.Combinatorics.RamseyFive.Entropy.MessageWeightsOAI.Combinatorics.RamseyFive.Entropy.MetadataAlphabetOAI.Combinatorics.RamseyFive.Entropy.MetadataBudgetOAI.Combinatorics.RamseyFive.Entropy.MomentWeightedCoverOAI.Combinatorics.RamseyFive.Entropy.MultiplicityBudgetsOAI.Combinatorics.RamseyFive.Entropy.OptionCompositionOAI.Combinatorics.RamseyFive.Entropy.OptionEventBoundsOAI.Combinatorics.RamseyFive.Entropy.OrderedExtractionOAI.Combinatorics.RamseyFive.Entropy.OrderedReciprocalLawOAI.Combinatorics.RamseyFive.Entropy.OrderedRetentionOAI.Combinatorics.RamseyFive.Entropy.OrderedWindowVariationOAI.Combinatorics.RamseyFive.Entropy.OrientedFiniteCostOAI.Combinatorics.RamseyFive.Entropy.OrientedTreeCostOAI.Combinatorics.RamseyFive.Entropy.OriginalHistoryPrivateOAI.Combinatorics.RamseyFive.Entropy.OriginalLevelLawOAI.Combinatorics.RamseyFive.Entropy.OriginalMarginalLawOAI.Combinatorics.RamseyFive.Entropy.OriginalUniformWeightedScoreMomentOAI.Combinatorics.RamseyFive.Entropy.PairsOAI.Combinatorics.RamseyFive.Entropy.PermissibleLevelsOAI.Combinatorics.RamseyFive.Entropy.PreRoundDeletionOAI.Combinatorics.RamseyFive.Entropy.PreparedWindowsOAI.Combinatorics.RamseyFive.Entropy.PrimitiveMessageWeightsOAI.Combinatorics.RamseyFive.Entropy.ProductHistoryOAI.Combinatorics.RamseyFive.Entropy.PublicCompositionOAI.Combinatorics.RamseyFive.Entropy.ReadyFailureOAI.Combinatorics.RamseyFive.Entropy.ReciprocalCodeNumericsOAI.Combinatorics.RamseyFive.Entropy.ReciprocalLossBudgetOAI.Combinatorics.RamseyFive.Entropy.ReciprocalSupportsOAI.Combinatorics.RamseyFive.Entropy.RectangleOAI.Combinatorics.RamseyFive.Entropy.RecursivePlaneOAI.Combinatorics.RamseyFive.Entropy.RelationMassCrossedOAI.Combinatorics.RamseyFive.Entropy.RepairOAI.Combinatorics.RamseyFive.Entropy.RepresentativeSetOAI.Combinatorics.RamseyFive.Entropy.RetainedCountersOAI.Combinatorics.RamseyFive.Entropy.RevealDomainsOAI.Combinatorics.RamseyFive.Entropy.RevealMarginalDeficitOAI.Combinatorics.RamseyFive.Entropy.ReverseMessageCostOAI.Combinatorics.RamseyFive.Entropy.ScoreFiniteCostOAI.Combinatorics.RamseyFive.Entropy.SelectedRestrictionOAI.Combinatorics.RamseyFive.Entropy.SequentialLawOAI.Combinatorics.RamseyFive.Entropy.SmallFiniteCostOAI.Combinatorics.RamseyFive.Entropy.SplitLawOAI.Combinatorics.RamseyFive.Entropy.StageNumericsOAI.Combinatorics.RamseyFive.Entropy.SubsetDeficitOAI.Combinatorics.RamseyFive.Entropy.SubsetEncodingOAI.Combinatorics.RamseyFive.Entropy.SubsetMixtureOAI.Combinatorics.RamseyFive.Entropy.SwapOAI.Combinatorics.RamseyFive.Entropy.TailOAI.Combinatorics.RamseyFive.Entropy.TargetAverageOAI.Combinatorics.RamseyFive.Entropy.TargetLossOAI.Combinatorics.RamseyFive.Entropy.ThreeHeaderOAI.Combinatorics.RamseyFive.Entropy.TreeOmissionBoundOAI.Combinatorics.RamseyFive.Entropy.TreeWeightsOAI.Combinatorics.RamseyFive.Entropy.TwoCapCostOAI.Combinatorics.RamseyFive.Entropy.UniformCutoffOAI.Combinatorics.RamseyFive.Entropy.UniformHistoryOAI.Combinatorics.RamseyFive.Entropy.UnionMarkingOAI.Combinatorics.RamseyFive.Entropy.UniversalFreshCostOAI.Combinatorics.RamseyFive.Entropy.UnusedRepresentativeOAI.Combinatorics.RamseyFive.Entropy.ValidationBudgetWideOAI.Combinatorics.RamseyFive.Entropy.VariableTreeCostOAI.Combinatorics.RamseyFive.Entropy.WeightedLowHitsOAI.Combinatorics.RamseyFive.Entropy.WindowBudgetNumericsOAI.Combinatorics.RamseyFive.Entropy.WindowLossAggregationOAI.Combinatorics.RamseyFive.Entropy.WindowPosteriorOAI.Combinatorics.RamseyFive.Entropy.WindowReadinessOAI.Combinatorics.RamseyFive.Entropy.WindowTargetInputsOAI.Combinatorics.RamseyFive.Entropy.WindowVariationOAI.Combinatorics.RamseyFive.Geometry.AbsModifiedPointScoreOAI.Combinatorics.RamseyFive.Geometry.AmbientOriginalDominationOAI.Combinatorics.RamseyFive.Geometry.AmbientPairPublicOAI.Combinatorics.RamseyFive.Geometry.AmbientPivotPotentialOAI.Combinatorics.RamseyFive.Geometry.BaseCapturedLawOAI.Combinatorics.RamseyFive.Geometry.BaseFinitePublicOAI.Combinatorics.RamseyFive.Geometry.BasePublicFamilyOAI.Combinatorics.RamseyFive.Geometry.BaseSmallLawOAI.Combinatorics.RamseyFive.Geometry.CapturedGlobalRadialMomentOAI.Combinatorics.RamseyFive.Geometry.CardFilterContainmentOAI.Combinatorics.RamseyFive.Geometry.CardIndexedOAI.Combinatorics.RamseyFive.Geometry.CardMulOAI.Combinatorics.RamseyFive.Geometry.CenterOAI.Combinatorics.RamseyFive.Geometry.CommonNeighborDichotomyOAI.Combinatorics.RamseyFive.Geometry.CompressionRecurrenceOAI.Combinatorics.RamseyFive.Geometry.ConcretePivotOAI.Combinatorics.RamseyFive.Geometry.CoreGeometryOAI.Combinatorics.RamseyFive.Geometry.CoresOAI.Combinatorics.RamseyFive.Geometry.DegreeStrengthCountOAI.Combinatorics.RamseyFive.Geometry.DimensionFourHighIntegralsOAI.Combinatorics.RamseyFive.Geometry.DimensionFourHighLawOAI.Combinatorics.RamseyFive.Geometry.DimensionFourHighProtocolOAI.Combinatorics.RamseyFive.Geometry.DimensionFourHighPublicOAI.Combinatorics.RamseyFive.Geometry.DimensionFourLowAmbientOAI.Combinatorics.RamseyFive.Geometry.DimensionFourLowLawOAI.Combinatorics.RamseyFive.Geometry.DimensionFourLowProcedureOAI.Combinatorics.RamseyFive.Geometry.DimensionFourLowTrainingOAI.Combinatorics.RamseyFive.Geometry.DimensionFourLowValidationOAI.Combinatorics.RamseyFive.Geometry.DimensionThreeProcedureOAI.Combinatorics.RamseyFive.Geometry.DimensionThreePublicOAI.Combinatorics.RamseyFive.Geometry.DimensionThreeTailsOAI.Combinatorics.RamseyFive.Geometry.DimensionTwoOAI.Combinatorics.RamseyFive.Geometry.DimensionTwoOrientedOAI.Combinatorics.RamseyFive.Geometry.DimensionTwoPublicOAI.Combinatorics.RamseyFive.Geometry.DimensionalScaleOAI.Combinatorics.RamseyFive.Geometry.DyadCountOAI.Combinatorics.RamseyFive.Geometry.EmptyVariableTreeOAI.Combinatorics.RamseyFive.Geometry.ExceptionalCentersOAI.Combinatorics.RamseyFive.Geometry.FailureOAI.Combinatorics.RamseyFive.Geometry.FiniteFamilyOAI.Combinatorics.RamseyFive.Geometry.FiniteNodeOAI.Combinatorics.RamseyFive.Geometry.FiniteTreeFailureOAI.Combinatorics.RamseyFive.Geometry.FinrankSpanImageOAI.Combinatorics.RamseyFive.Geometry.FlagGraphOAI.Combinatorics.RamseyFive.Geometry.FlatAtlasOAI.Combinatorics.RamseyFive.Geometry.FlatPointsOAI.Combinatorics.RamseyFive.Geometry.FlatSectionOAI.Combinatorics.RamseyFive.Geometry.FourFinitePredictorOAI.Combinatorics.RamseyFive.Geometry.FourHeaderOAI.Combinatorics.RamseyFive.Geometry.FourSelectedOAI.Combinatorics.RamseyFive.Geometry.GeneralReversedCodeOAI.Combinatorics.RamseyFive.Geometry.GeometricRestrictionOAI.Combinatorics.RamseyFive.Geometry.GeometryScaleOrientedLowerOAI.Combinatorics.RamseyFive.Geometry.GoodCoreRanksOAI.Combinatorics.RamseyFive.Geometry.GuardedNodeOAI.Combinatorics.RamseyFive.Geometry.GuardedNodeEncoderOAI.Combinatorics.RamseyFive.Geometry.GuardedNodeSentOAI.Combinatorics.RamseyFive.Geometry.HighGeometryClosureOAI.Combinatorics.RamseyFive.Geometry.HighPairVarianceOAI.Combinatorics.RamseyFive.Geometry.HighPeelExceptionsOAI.Combinatorics.RamseyFive.Geometry.HighPolyConstantOAI.Combinatorics.RamseyFive.Geometry.HighSampleGrowthOAI.Combinatorics.RamseyFive.Geometry.HyperplaneHighOAI.Combinatorics.RamseyFive.Geometry.IncidencesDegreesOAI.Combinatorics.RamseyFive.Geometry.LargeCellsOAI.Combinatorics.RamseyFive.Geometry.LevelTargetBoundsOAI.Combinatorics.RamseyFive.Geometry.LinearFormOAI.Combinatorics.RamseyFive.Geometry.LocalLinesOAI.Combinatorics.RamseyFive.Geometry.LowConflictSubsetsOAI.Combinatorics.RamseyFive.Geometry.MassHyperplaneOAI.Combinatorics.RamseyFive.Geometry.MemPairRankOAI.Combinatorics.RamseyFive.Geometry.ModifiedRadialScheduleOAI.Combinatorics.RamseyFive.Geometry.MomentCutoffPolynomialTailOAI.Combinatorics.RamseyFive.Geometry.MomentOrderOAI.Combinatorics.RamseyFive.Geometry.MomentPolynomialTailOAI.Combinatorics.RamseyFive.Geometry.OrderedTargetRetentionOAI.Combinatorics.RamseyFive.Geometry.OrientedNodeCapsOAI.Combinatorics.RamseyFive.Geometry.OrientedNodeProcessOAI.Combinatorics.RamseyFive.Geometry.OrientedPivotTreeOAI.Combinatorics.RamseyFive.Geometry.OrientedTreeDomainsOAI.Combinatorics.RamseyFive.Geometry.OrientedTreePotentialOAI.Combinatorics.RamseyFive.Geometry.OriginalAmbientDominationOAI.Combinatorics.RamseyFive.Geometry.OriginalReadinessOAI.Combinatorics.RamseyFive.Geometry.OutsideOAI.Combinatorics.RamseyFive.Geometry.OutsideCardOAI.Combinatorics.RamseyFive.Geometry.OutsidePairCardOAI.Combinatorics.RamseyFive.Geometry.OverlapDyadsOAI.Combinatorics.RamseyFive.Geometry.OwnQueryOAI.Combinatorics.RamseyFive.Geometry.PeelingOAI.Combinatorics.RamseyFive.Geometry.PeelingGeometryOAI.Combinatorics.RamseyFive.Geometry.PencilCountOAI.Combinatorics.RamseyFive.Geometry.PencilLineSumOAI.Combinatorics.RamseyFive.Geometry.PlaneAnchorOAI.Combinatorics.RamseyFive.Geometry.PlaneBranchOAI.Combinatorics.RamseyFive.Geometry.PlaneCommonNeighborsOAI.Combinatorics.RamseyFive.Geometry.PlaneExceptionScalarsOAI.Combinatorics.RamseyFive.Geometry.PlaneExceptionsOAI.Combinatorics.RamseyFive.Geometry.PlanePublicDefsOAI.Combinatorics.RamseyFive.Geometry.PlaneStrongExceptionsOAI.Combinatorics.RamseyFive.Geometry.PointStrengthOAI.Combinatorics.RamseyFive.Geometry.PowerValidationOAI.Combinatorics.RamseyFive.Geometry.PredictorReverseCapOAI.Combinatorics.RamseyFive.Geometry.ProducedPairOriginalOAI.Combinatorics.RamseyFive.Geometry.ProjectiveEquivOAI.Combinatorics.RamseyFive.Geometry.ProjectiveExpectedLevelLossOAI.Combinatorics.RamseyFive.Geometry.ProjectiveHighCapturedMomentOAI.Combinatorics.RamseyFive.Geometry.ProjectiveLinePairPackingOAI.Combinatorics.RamseyFive.Geometry.PublicDecoderOAI.Combinatorics.RamseyFive.Geometry.QOAI.Combinatorics.RamseyFive.Geometry.RadialAlternativesOAI.Combinatorics.RamseyFive.Geometry.RadialLabelOAI.Combinatorics.RamseyFive.Geometry.RadialOffExceptionOAI.Combinatorics.RamseyFive.Geometry.ReadyRefinementOAI.Combinatorics.RamseyFive.Geometry.RectangleTransportOAI.Combinatorics.RamseyFive.Geometry.ReverseAfterCaptureOAI.Combinatorics.RamseyFive.Geometry.ReversedBasePublicOAI.Combinatorics.RamseyFive.Geometry.RichHyperplaneVarianceOAI.Combinatorics.RamseyFive.Geometry.RowPowerTailOAI.Combinatorics.RamseyFive.Geometry.SampledPointsOAI.Combinatorics.RamseyFive.Geometry.ScoreDegreeLowNormalizedOAI.Combinatorics.RamseyFive.Geometry.ScorePairCapturedNormalizedOAI.Combinatorics.RamseyFive.Geometry.ScoredMessageOAI.Combinatorics.RamseyFive.Geometry.SplitEquivOAI.Combinatorics.RamseyFive.Geometry.StreamGeometryOAI.Combinatorics.RamseyFive.Geometry.SubspacePointsEquivOAI.Combinatorics.RamseyFive.Geometry.SurvivorRankOAI.Combinatorics.RamseyFive.Geometry.TargetCapsOAI.Combinatorics.RamseyFive.Geometry.TargetCoherenceOAI.Combinatorics.RamseyFive.Geometry.TargetRetentionOAI.Combinatorics.RamseyFive.Geometry.ThreeBranchOAI.Combinatorics.RamseyFive.Geometry.ThreeCoordinateCertifiedOAI.Combinatorics.RamseyFive.Geometry.ThreeFiniteOrientedOAI.Combinatorics.RamseyFive.Geometry.ThreeFinitePredictorOAI.Combinatorics.RamseyFive.Geometry.ThreeLocalOAI.Combinatorics.RamseyFive.Geometry.ThreeOrientedOAI.Combinatorics.RamseyFive.Geometry.ThreePublicOAI.Combinatorics.RamseyFive.Geometry.ThreePublicDefsOAI.Combinatorics.RamseyFive.Geometry.ThreeSelectedOAI.Combinatorics.RamseyFive.Geometry.TrainingLineCardOAI.Combinatorics.RamseyFive.Geometry.TreeFailureOAI.Combinatorics.RamseyFive.Geometry.TreeShapeOAI.Combinatorics.RamseyFive.Geometry.TreeTrimsOAI.Combinatorics.RamseyFive.Geometry.TwoAmbientCapsOAI.Combinatorics.RamseyFive.Geometry.TwoFinitePublicOAI.Combinatorics.RamseyFive.Geometry.TwoPublicOAI.Combinatorics.RamseyFive.Geometry.TwoPublicCapsOAI.Combinatorics.RamseyFive.Geometry.UniformHighTailOAI.Combinatorics.RamseyFive.Geometry.ValidationOriginalTailWideOAI.Combinatorics.RamseyFive.Iteration.CellScoreProcedureOAI.Combinatorics.RamseyFive.Iteration.CodedWindowStageOAI.Combinatorics.RamseyFive.Iteration.EventuallyRichScaleOAI.Combinatorics.RamseyFive.Iteration.ForwardPreparedStageOAI.Combinatorics.RamseyFive.Iteration.HighWindowStageOAI.Combinatorics.RamseyFive.Iteration.InitialPolarOAI.Combinatorics.RamseyFive.Iteration.PolarIterationOAI.Combinatorics.RamseyFive.Iteration.PreparedDispatchOAI.Combinatorics.RamseyFive.Iteration.RestrictionScaleOAI.Combinatorics.RamseyFive.Iteration.ScaleOAI.Combinatorics.RamseyFive.Iteration.ScaleAgainstBOAI.Combinatorics.RamseyFive.Iteration.StageCutsOAI.Combinatorics.RamseyFive.Iteration.StageStateOAI.Combinatorics.RamseyFive.Iteration.TerminalStreamOAI.Combinatorics.RamseyFive.Iteration.WindowStageOAI.Combinatorics.RamseyFive.MainOAI.Combinatorics.RamseyFive.Marking.AllHistoryWindowLossOAI.Combinatorics.RamseyFive.Marking.AllWindowBoundsOAI.Combinatorics.RamseyFive.Marking.BandEndpointsOAI.Combinatorics.RamseyFive.Marking.ChooseLevelOAI.Combinatorics.RamseyFive.Marking.ClassPreparedOAI.Combinatorics.RamseyFive.Marking.ClassifiedStreamOAI.Combinatorics.RamseyFive.Marking.CollisionsOAI.Combinatorics.RamseyFive.Marking.CompressionStageOAI.Combinatorics.RamseyFive.Marking.DomainTransportOAI.Combinatorics.RamseyFive.Marking.GoodWindowVariationOAI.Combinatorics.RamseyFive.Marking.HighChosenRoundOAI.Combinatorics.RamseyFive.Marking.HighDomainEndpointsOAI.Combinatorics.RamseyFive.Marking.HighDomainPreRoundOAI.Combinatorics.RamseyFive.Marking.HighFourPreRoundOAI.Combinatorics.RamseyFive.Marking.HighFourStageOAI.Combinatorics.RamseyFive.Marking.HighLowConflictOAI.Combinatorics.RamseyFive.Marking.HighNumericsOAI.Combinatorics.RamseyFive.Marking.HighSampleRetentionOAI.Combinatorics.RamseyFive.Marking.MarkedStreamExtractionOAI.Combinatorics.RamseyFive.Marking.MarkingClassDomainsOAI.Combinatorics.RamseyFive.Marking.MarkingClassesOAI.Combinatorics.RamseyFive.Marking.MarkingEndpointsOAI.Combinatorics.RamseyFive.Marking.OrderedHighConflictOAI.Combinatorics.RamseyFive.Marking.ReciprocalBandsOAI.Combinatorics.RamseyFive.Marking.ReciprocalDomainCapsOAI.Combinatorics.RamseyFive.Marking.ReciprocalDropNumericsOAI.Combinatorics.RamseyFive.Marking.ReciprocalGoodReferenceOAI.Combinatorics.RamseyFive.Marking.ReciprocalLevelProducerOAI.Combinatorics.RamseyFive.Marking.ReciprocalLowConflictOAI.Combinatorics.RamseyFive.Marking.ReciprocalNumericsOAI.Combinatorics.RamseyFive.Marking.ReciprocalRoundNumericsOAI.Combinatorics.RamseyFive.Marking.ReciprocalSharpRoundOAI.Combinatorics.RamseyFive.Marking.ReciprocalStageArithmeticOAI.Combinatorics.RamseyFive.Marking.ReverseMissOAI.Combinatorics.RamseyFive.Marking.ScanChoiceOAI.Combinatorics.RamseyFive.Marking.ScanRecordOAI.Combinatorics.RamseyFive.Marking.ScanRecordPresentOAI.Combinatorics.RamseyFive.Marking.StateOAI.Combinatorics.RamseyFive.Marking.SurvivingWindowCodeOAI.Combinatorics.RamseyFive.Marking.TwoScanOAI.Combinatorics.RamseyFive.Marking.TwoScanContextOAI.Combinatorics.RamseyFive.Marking.WindowCapsOAI.Combinatorics.RamseyFive.Marking.WindowCodeDomainsOAI.Combinatorics.RamseyFive.Marking.WindowDeletionCountOAI.Combinatorics.RamseyFive.Marking.WindowLevelsOAI.Combinatorics.RamseyFive.Marking.WindowReciprocalScoresOAI.Combinatorics.RamseyFive.Marking.WindowSmallFailureOAI.Combinatorics.RamseyFive.Marking.WindowTargetRetentionOAI.Combinatorics.RamseyFive.ModelOAI.Combinatorics.RamseyFive.Probability.AbsScoreTermOAI.Combinatorics.RamseyFive.Probability.AggregateOAI.Combinatorics.RamseyFive.Probability.AllEmptyIndicatorOAI.Combinatorics.RamseyFive.Probability.AmbientPublicTestOAI.Combinatorics.RamseyFive.Probability.CapNumericsOAI.Combinatorics.RamseyFive.Probability.CellMassOAI.Combinatorics.RamseyFive.Probability.DimensionFourLowIntegralsOAI.Combinatorics.RamseyFive.Probability.DimensionFourStrongOAI.Combinatorics.RamseyFive.Probability.DimensionThreeSmallAmbientOAI.Combinatorics.RamseyFive.Probability.DimensionTwoIntegralsOAI.Combinatorics.RamseyFive.Probability.EmptyTestsManySmallOAI.Combinatorics.RamseyFive.Probability.FailureCountOAI.Combinatorics.RamseyFive.Probability.HighOrSmallOAI.Combinatorics.RamseyFive.Probability.IntegralForcedHitsOAI.Combinatorics.RamseyFive.Probability.MeasurePreservingSplitScheduleOAI.Combinatorics.RamseyFive.Probability.MeasurePublicTableOAI.Combinatorics.RamseyFive.Probability.MomentTailRatioOAI.Combinatorics.RamseyFive.Probability.NormalizedPairHighOAI.Combinatorics.RamseyFive.Probability.OwnFractionOAI.Combinatorics.RamseyFive.Probability.PencilFactorOAI.Combinatorics.RamseyFive.Probability.PoissonLikelihoodOAI.Combinatorics.RamseyFive.Probability.PoissonProposalOAI.Combinatorics.RamseyFive.Probability.PositiveTailMomentOAI.Combinatorics.RamseyFive.Probability.PublicCapLawOAI.Combinatorics.RamseyFive.Probability.QBOAI.Combinatorics.RamseyFive.Probability.SamplingDegreeOAI.Combinatorics.RamseyFive.Probability.SumPoissonPowOAI.Combinatorics.RamseyFive.Probability.TypicalScoreAggregateOAI.Combinatorics.RamseyFive.Probability.UniformTailsOAI.Combinatorics.RamseyFive.Streams.DependentPrivateStreamOAI.Combinatorics.RamseyFive.Streams.HighActualExtractionOAI.Combinatorics.RamseyFive.Streams.HighSampleContradictionOAI.Combinatorics.RamseyFive.Streams.HighThreePreparedOAI.Combinatorics.RamseyFive.Streams.MiddleStreamOAI.Combinatorics.RamseyFive.Streams.PermutationCylinderOAI.Combinatorics.RamseyFive.Streams.PreparedStreamOAI.Combinatorics.RamseyFive.Streams.SelectedExtractionOAI.Combinatorics.RamseyFive.Streams.SelectedLengthOAI.Combinatorics.RamseyFive.Streams.SelectedTupleOAI.Combinatorics.RamseyFive.Trees.AmbientEvictionOAI.Combinatorics.RamseyFive.Trees.EncodedTreePotentialOAI.Combinatorics.RamseyFive.Trees.FiniteNodeSentOAI.Combinatorics.RamseyFive.Trees.HistoryPrivateStreamOAI.Combinatorics.RamseyFive.Trees.IntegerWindowsOAI.Combinatorics.RamseyFive.Trees.PivotPotentialOAI.Combinatorics.RamseyFive.Trees.PivotTreeOAI.Combinatorics.RamseyFive.Trees.ReachedFailureOAI.Combinatorics.RamseyFive.Trees.SurvivingWindowsOAI.Combinatorics.RamseyFive.Trees.TargetTrimsOAI.Combinatorics.RamseyFive.Trees.TreeDecoderOAI.Combinatorics.RamseyFive.Trees.TreeExposureOAI.Combinatorics.RamseyFive.Trees.TreeLawOAI.Combinatorics.RamseyFive.Trees.TreeObservationRelationsOAI.Combinatorics.RamseyFive.Trees.TreeOmissionLawOAI.Combinatorics.RamseyFive.Trees.TreeOrderOAI.Combinatorics.RamseyFive.Trees.TreeOriginalTrimsOAI.Combinatorics.RamseyFive.Trees.WindowsOAI.Combinatorics.SharpRamsey.Bounds.SamplingParameterOAI.Combinatorics.SharpRamsey.Bounds.SumFiberCenterOAI.Combinatorics.SharpRamsey.Bounds.UpperOAI.Combinatorics.SharpRamsey.Construction.FiniteStreamTailOAI.Combinatorics.SharpRamsey.Entropy.AnchorEventsRealizedOAI.Combinatorics.SharpRamsey.Entropy.CompleteProgramWeightOAI.Combinatorics.SharpRamsey.Entropy.ComponentLabelWitnessOAI.Combinatorics.SharpRamsey.Entropy.ExternalMassOAI.Combinatorics.SharpRamsey.Entropy.ForcedHitsOAI.Combinatorics.SharpRamsey.Entropy.HighMomentsOAI.Combinatorics.SharpRamsey.Entropy.IntegralTypicalScoreSqOAI.Combinatorics.SharpRamsey.Entropy.LabelledFilterCardOAI.Combinatorics.SharpRamsey.Entropy.LargeCardOAI.Combinatorics.SharpRamsey.Entropy.MakePairOAI.Combinatorics.SharpRamsey.Entropy.NewEventsOAI.Combinatorics.SharpRamsey.Entropy.PatchNotMemOAI.Combinatorics.SharpRamsey.Entropy.PoissonLawOAI.Combinatorics.SharpRamsey.Entropy.ShiftKernelSumOAI.Combinatorics.SharpRamsey.Entropy.SinglesUniqueOAI.Combinatorics.SharpRamsey.Entropy.TruncatedTupleIntegrableOAI.Combinatorics.SharpRamsey.Entropy.TwoAnchorCrossCostOAI.Combinatorics.SharpRamsey.Entropy.WitnessListOAI.Combinatorics.SharpRamsey.Geometry.CardOAI.Combinatorics.SharpRamsey.Geometry.HessianTangentOAI.Combinatorics.SharpRamsey.Geometry.RichLinesOAI.Combinatorics.SharpRamsey.Geometry.ScaledTangentDotOAI.Combinatorics.SharpRamsey.Geometry.SpanPairLineOAI.Combinatorics.SharpRamsey.Geometry.TotalDegreeCombinationOAI.Combinatorics.SharpRamsey.Geometry.TripleOAI.Combinatorics.SharpRamsey.Geometry.VectorMapOAI.Combinatorics.SharpRamsey.Geometry.WeightOAI.Combinatorics.SharpRamsey.Model12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758#!/usr/bin/env python3"""Place openai/math's reference proof as a submission (used by the oracle's solve.sh).
Standalone: the adapter copies this file into every task's solution/ directory.
reference.py <openai-math lean dir> <closure.txt> <solution module> <workspace>
Each module in closure.txt (``OAI.A.B``) is copied from ``<lean>/OAI/A/B.lean`` to``<workspace>/Submission/OAI/A/B.lean`` with ``import OAI.X`` rewritten to``import Submission.OAI.X``; ``Submission.lean`` imports the solution module. Declaration namesare namespaces, not module paths, so the theorems keep the names the challenge expects."""
from __future__ import annotations
import reimport sysfrom pathlib import Path
_IMPORT = re.compile(r"^(\s*(?:public\s+|private\s+)?(?:meta\s+)?import\s+(?:all\s+)?)(OAI(?:\.|\s|$))")_HEADER_LINE = re.compile(r"^\s*(?:module\b|prelude\b|--|$)")
def rename_imports(text: str) -> str: """Rewrite ``import OAI...`` to ``import Submission.OAI...`` in the import header only.""" out, in_header, in_comment = [], True, False for line in text.splitlines(keepends=True): if in_header: stripped = line.strip() if in_comment: in_comment = "-/" not in stripped elif stripped.startswith("/-"): in_comment = "-/" not in stripped[2:] elif _IMPORT.match(line): line = _IMPORT.sub(lambda m: m.group(1) + "Submission." + m.group(2), line, count=1) elif not _HEADER_LINE.match(line) and not re.match(r"^\s*(?:public\s+|private\s+)?(?:meta\s+)?import\s", line): in_header = False out.append(line) return "".join(out)
def module_path(root: Path, module: str) -> Path: return root.joinpath(*module.split(".")).with_suffix(".lean")
def place(lean_dir: Path, modules: list[str], solution_module: str, workspace: Path) -> None: for module in modules: dst = module_path(workspace / "Submission", module) dst.parent.mkdir(parents=True, exist_ok=True) dst.write_text(rename_imports(module_path(lean_dir, module).read_text(encoding="utf-8")), encoding="utf-8") (workspace / "Submission.lean").write_text(f"import Submission.{solution_module}\n", encoding="utf-8")
if __name__ == "__main__": lean_dir, closure_txt, solution_module, workspace = sys.argv[1:5] modules = [m.strip() for m in Path(closure_txt).read_text().splitlines() if m.strip()] place(Path(lean_dir), modules, solution_module, Path(workspace)) print(f"placed {len(modules)} reference modules for {solution_module}")1234567891011121314151617181920#!/usr/bin/env bash# Oracle: submit openai/math's own proof of RamseyFive, i.e. module OAI.Combinatorics.RamseyFive.Main and the# 482 OAI modules it imports, placed under Submission/ (see reference.py).set -euo pipefailif [ -f /solution/reference.tar.gz ]; then tar -xzf /solution/reference.tar.gz -C /workspaceelse # Fetch only those files at the pinned commit. The task blocks the network while the agent runs, # so run the oracle with `harbor run ... --allow-agent-host github.com`. tmp=$(mktemp -d) git -C "$tmp" init -q git -C "$tmp" remote add origin https://github.com/openai/math.git git -C "$tmp" config core.sparseCheckout true sed -e 's#\.#/#g' -e 's#^#/lean/#' -e 's#$#.lean#' /solution/closure.txt > "$tmp/.git/info/sparse-checkout" git -C "$tmp" fetch -q --depth 1 --filter=blob:none origin adc7f1241b42e322a6451854ab7e4b4c146bf78a git -C "$tmp" checkout -q FETCH_HEAD python3 /solution/reference.py "$tmp/lean" /solution/closure.txt OAI.Combinatorics.RamseyFive.Main /workspace rm -rf "$tmp"fiecho "placed the reference proof of RamseyFive"12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849schema_version = "1.4"
[task]name = "openai-math/ramsey-five"version = "1.0.0"description = "Prove RamseyFive (openai/math family 170: Sharp logarithmic exponents for off-diagonal Ramsey numbers) in Lean 4 with Mathlib; graded by Comparator in a separate sandbox."keywords = ["lean4", "mathlib", "theorem-proving", "openai-math", "combinatorics"]
[metadata]source = "https://github.com/openai/math"source_commit = "adc7f1241b42e322a6451854ab7e4b4c146bf78a"source_license = "Apache-2.0"source_notice = "tests/Challenge.lean is lean/ComparatorChallenges/RamseyFive.lean from openai/math, (c) OpenAI, unchanged; see NOTICE at the dataset root"challenge = "RamseyFive"family = "170"family_title = "Sharp logarithmic exponents for off-diagonal Ramsey numbers"subject = "Combinatorics"theorems = ["OAI.SharpRamseyFive.main"]definition_holes = []fixed_definitions = []reference_module = "OAI.Combinatorics.RamseyFive.Main"reference_modules = 482reference_lean_bytes = 3634776reference_requires_packages = []oracle_result = "accepted"oracle_grade_seconds = 2034difficulty = "research"
[agent]timeout_sec = 14400network_mode = "no-network"
[environment]build_timeout_sec = 5400cpus = 4memory_mb = 8192storage_mb = 10240workdir = "/workspace"# Lean sees all host CPUs rather than the sandbox's 4; this bounds `lake build` to 3 parallel jobs.env = { LEAN_NUM_THREADS = "3" }
[verifier]timeout_sec = 14971environment_mode = "separate"network_mode = "no-network"
[[verifier.collect]]command = "python3 /opt/openai-math/pack_submission.py"timeout_sec = 300123456789101112131415161718192021222324252627282930import Mathlib
namespace OAI
namespace SharpRamseyFive
def RamseyProperty (s t n : ℕ) : Prop := ∀ G : SimpleGraph (Fin n), (∃ A : Finset (Fin n), G.IsNClique s A) ∨ (∃ B : Finset (Fin n), G.IsNIndepSet t B)
noncomputable def ramsey (s t : ℕ) : ℕ := sInf {n : ℕ | RamseyProperty s t n}
def SharpBounds : Prop := ∃ C : ℝ, 0 < C ∧ ∀ ε : ℝ, 0 < ε → ∃ t₀ : ℕ, ∀ t : ℕ, t₀ ≤ t → (t : ℝ) ^ 4 / Real.rpow (Real.log t) (3 + ε) ≤ (ramsey 5 t : ℝ) ∧ (ramsey 5 t : ℝ) ≤ C * (t : ℝ) ^ 4 / (Real.log t) ^ 3
def SharpExponent : Prop := Filter.Tendsto (fun t : ℕ => (4 * Real.log (t : ℝ) - Real.log (ramsey 5 t : ℝ)) / Real.log (Real.log (t : ℝ))) Filter.atTop (nhds (3 : ℝ))
theorem main : SharpBounds ∧ SharpExponent := by sorry
end SharpRamseyFive
end OAI123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418#!/usr/bin/env python3"""Grade one openai/math challenge with Comparator.
This runs as root in a separate verifier sandbox that never executed agent code. The only input theagent controls is /logs/artifacts/submission.tar. Everything else comes from /tests (this task'strusted challenge and Comparator config) and from the image.
Steps: 1. Unpack submission.tar, accepting only regular `Submission.lean` / `Submission/**.lean` files. 2. Lay out a fresh Lake project: the trusted lakefile, Challenge.lean from /tests, the submission, and the image's prebuilt Mathlib (root-owned, read-only to the grader). 3. Run `lake env comparator config.json` as the unprivileged `grader` user, with no network. Comparator builds Challenge and Submission inside landrun, checks that every listed theorem has exactly the challenge's statement, that only the permitted axioms are used, and replays the proof through the Lean kernel. 4. Kill everything the grader started, then write the verdict.
reward.txt is 1 only when Comparator prints its success line and exits 0. A rejected ornon-compiling submission scores 0. A broken grading setup (the trusted Challenge fails to build,the network block cannot be installed) writes no reward, so Harbor reports an error instead of ascore."""
from __future__ import annotations
import jsonimport osimport pwdimport reimport shutilimport signalimport socketimport statimport subprocessimport sysimport tarfileimport tempfileimport threadingimport timefrom pathlib import Path
TESTS = Path("/tests")VERIFIER_DIR = Path("/logs/verifier")SUBMISSION_TAR = Path("/logs/artifacts/submission.tar")LEAN_ENV = Path("/opt/lean-env")RUN_ROOT = Path("/var/lib/oai-grade")GRADER = "grader"SUCCESS_LINE = "Your solution is okay!"GRADE_THREADS = "2"SCRATCH_SWEEP_SEC = 15# Lake and Comparator wording when a build process is killed for running out of memory.OOM_MARKERS = ("Lean exited with code 137", "Child exited with 137")
MAX_FILES = 20_000MAX_FILE_BYTES = 64 << 20MAX_TOTAL_BYTES = 768 << 20# Submission.lean, or Submission/A/B.lean where each component is a Lean identifier: it starts with# a letter or `_` and continues with letters, digits (subscripts like `₁` included), `_`, `'`, `!`, `?`.# Unicode is allowed because Lean identifiers allow it (openai/math has a module named `Kappa₁`)._COMPONENT = r"[^\W\d][\w'!?]*"MEMBER = re.compile(rf"^Submission(?:/{_COMPONENT})*\.lean$")MEMBER_DIR = re.compile(rf"^Submission(?:/{_COMPONENT})*/?$")
LAKEFILE = """import Lakeopen Lake DSL
package openai_math where leanOptions := #[⟨`autoImplicit, false⟩]
require mathlib from git "https://github.com/leanprover-community/mathlib4.git" @ "d13f23b723b8a846827a245b89c10fc7d3f11612"
lean_lib Challenge
-- `Submission` and every `Submission.*` module it imports.lean_lib Submission"""
class Rejected(Exception): """The submission is invalid: reward 0."""
class GradingError(Exception): """The grading setup is broken: no reward, so the trial shows as errored."""
def toolchain_bin() -> Path: bins = sorted(Path("/opt/elan/toolchains").glob("*/bin")) if len(bins) != 1: raise GradingError(f"expected one Lean toolchain, found {bins}") return bins[0]
def unpack_submission(dest: Path) -> dict: """Copy the submission's .lean files into ``dest``; reject anything else.""" try: st = SUBMISSION_TAR.lstat() except FileNotFoundError: raise Rejected("no submission: /workspace/Submission.lean was not found after the agent finished") if not SUBMISSION_TAR.is_file() or SUBMISSION_TAR.is_symlink() or st.st_size > MAX_TOTAL_BYTES + (64 << 20): raise Rejected("submission archive is not a regular file of acceptable size")
files, total = [], 0 try: with tarfile.open(SUBMISSION_TAR, "r:") as tar: for count, member in enumerate(tar): if count > MAX_FILES * 2: raise Rejected(f"submission has more than {MAX_FILES} entries") name = member.name.removeprefix("./") if member.isdir(): if not MEMBER_DIR.match(name): raise Rejected(f"unexpected directory in submission: {name!r}") continue if not member.isreg(): raise Rejected(f"only regular .lean files are accepted, got {name!r}") if not MEMBER.match(name): raise Rejected(f"unexpected file in submission: {name!r} (only Submission.lean and Submission/**.lean)") if member.size > MAX_FILE_BYTES: raise Rejected(f"{name} is larger than {MAX_FILE_BYTES >> 20} MB") total += member.size if total > MAX_TOTAL_BYTES or len(files) >= MAX_FILES: raise Rejected("submission is too large") data = tar.extractfile(member).read(MAX_FILE_BYTES + 1) try: data.decode("utf-8") except UnicodeDecodeError: raise Rejected(f"{name} is not valid UTF-8") target = dest / name if target.exists(): raise Rejected(f"duplicate entry {name!r}") target.parent.mkdir(parents=True, exist_ok=True) target.write_bytes(data) target.chmod(0o644) files.append(name) except tarfile.TarError as exc: raise Rejected(f"submission archive is unreadable: {exc}") if "Submission.lean" not in files: raise Rejected("no submission: /workspace/Submission.lean was not found after the agent finished") for d in (dest / "Submission",): if d.exists(): for p in [d, *d.rglob("*")]: if p.is_dir(): p.chmod(0o755) return {"files": len(files), "bytes": total}
def write_project(run: Path, config: dict) -> None: (run / "lakefile.lean").write_text(LAKEFILE) shutil.copy(LEAN_ENV / "lake-manifest.json", run / "lake-manifest.json") shutil.copy(LEAN_ENV / "lean-toolchain", run / "lean-toolchain") shutil.copy(TESTS / "Challenge.lean", run / "Challenge.lean") comparator_config = { "challenge_module": "Challenge", "solution_module": "Submission", "theorem_names": config["theorem_names"], "definition_names": config["definition_names"], "permitted_axioms": config["permitted_axioms"], "enable_nanoda": False, } (run / "config.json").write_text(json.dumps(comparator_config, indent=2)) lake = run / ".lake" lake.mkdir() (lake / "packages").symlink_to(LEAN_ENV / ".lake" / "packages") for p in run.iterdir(): if p.name != ".lake": os.chmod(p, 0o644 if p.is_file() else 0o755, follow_symlinks=False) uid = pwd.getpwnam(GRADER).pw_uid os.chown(lake, uid, uid) os.chmod(run, 0o755)
def fresh_run(task: dict) -> Path: """A new, empty Lake project for one grading attempt.""" run = Path(tempfile.mkdtemp(prefix="run.", dir=RUN_ROOT)) write_project(run, task["comparator"]) return run
def ensure_readable(roots: tuple[str, ...] = ("/opt/elan", str(LEAN_ENV))) -> int: """Make the prebuilt toolchain and packages readable by the grader (never writable).
The image already does this; this only repairs an image built without it. It must touch nothing that is already right: these files live in the image's lower overlay layer, and a `chmod` on one copies it whole into the sandbox's writable layer. A blanket `chmod -R` took 535 s and used 8.7 GB of the 10 GB working disk. This walk only reads metadata (lstat). Returns the number of entries changed. """ changed = 0 for root in roots: for dirpath, dirnames, filenames in os.walk(root, followlinks=False): for name in [*dirnames, *filenames]: path = os.path.join(dirpath, name) st = os.lstat(path) if stat.S_ISDIR(st.st_mode): want = (st.st_mode | 0o555) & ~0o022 elif stat.S_ISREG(st.st_mode): want = (st.st_mode | 0o444) & ~0o022 else: continue if stat.S_IMODE(st.st_mode) != stat.S_IMODE(want): os.chmod(path, stat.S_IMODE(want)) changed += 1 return changed
def block_grader_network() -> None: """Reject every socket the grader user opens, loopback included.
landrun already denies TCP to the sandboxed build. This rule also covers the grader's own processes outside landrun and services listening inside the sandbox. """ uid = str(pwd.getpwnam(GRADER).pw_uid) for tool in ("iptables", "ip6tables"): rule = ["OUTPUT", "-m", "owner", "--uid-owner", uid, "-j", "REJECT"] if subprocess.run([tool, "-C", *rule], capture_output=True).returncode == 0: continue res = subprocess.run([tool, "-I", *rule], capture_output=True, text=True) if res.returncode != 0: raise GradingError(f"cannot install the {tool} rule for {GRADER}: {res.stderr.strip()}") probe = subprocess.run( ["runuser", "-u", GRADER, "--", sys.executable, "-c", "import socket,sys\n" "s=socket.socket(); s.settimeout(3)\n" "sys.exit(0 if s.connect_ex(('127.0.0.1', 2280)) == 0 else 1)"], capture_output=True, ) if probe.returncode == 0: raise GradingError("the grader user can still open loopback connections")
def kill_grader() -> None: for _ in range(20): subprocess.run(["pkill", "-9", "-u", GRADER], capture_output=True) if subprocess.run(["pgrep", "-u", GRADER], capture_output=True).returncode != 0: return time.sleep(0.5) raise GradingError("could not stop the grader's processes")
def out_of_memory(out: str) -> bool: return any(m in out for m in OOM_MARKERS)
def out_of_disk(out: str) -> bool: return "no space left on device" in out.lower()
# Run as the grader user by `empty_build_scratch`. argv: the .lake/build/ir directory.EMPTY_SCRATCH = r"""import os, sysfor dirpath, _, files in os.walk(sys.argv[1]): for name in files: if not name.endswith(".setup.json"): continue base = os.path.join(dirpath, name[:-len(".setup.json")]) try: # Lake writes X.c.hash once Lean, and leanir if the module needs it, are done with X; # both read X.setup.json, so it may only be emptied after that. if os.stat(base + ".c.hash").st_mtime < os.stat(base + ".setup.json").st_mtime: continue for path in (base + ".setup.json", base + ".c"): if os.path.getsize(path): os.truncate(path, 0) except OSError: pass"""
def empty_build_scratch(run: Path, stop: threading.Event) -> None: """Until ``stop`` is set, empty files Lake leaves in .lake/build/ir that grading never reads.
For every module Lake writes a `.setup.json` (its imports with the path of every .olean they pull in, about 5.5 MB with Mathlib) and the module compiled to C. Neither is used once the module is built, and for proofs of 1,000-2,000 modules they filled the 10 GB disk before the build finished. Lake keeps the recorded hashes, so emptied files do not trigger a rebuild. This runs as the grader user, so it can touch nothing the build could not. """ ir = str(run / ".lake" / "build" / "ir") while not stop.wait(SCRATCH_SWEEP_SEC): try: subprocess.run(["runuser", "-u", GRADER, "--", sys.executable, "-c", EMPTY_SCRATCH, ir], capture_output=True, timeout=600) except subprocess.TimeoutExpired: pass
def run_comparator(run: Path, timeout_sec: int, threads: str = GRADE_THREADS) -> tuple[int | None, str]: env = { "PATH": f"{toolchain_bin()}:/usr/local/bin:/usr/bin:/bin", "HOME": str(run), "LANG": "C.UTF-8", "LEAN_ABORT_ON_PANIC": "1", # Lean sees every host CPU, not the sandbox's 4; bound Lake's parallel builds so a large # proof fits in 8 GB. Needs the image's Comparator, which passes this into landrun. "LEAN_NUM_THREADS": threads, } cmd = [ "runuser", "-u", GRADER, "--", "env", "-i", *(f"{k}={v}" for k, v in env.items()), "lake", "env", "comparator", "config.json", ] stop = threading.Event() sweeper = threading.Thread(target=empty_build_scratch, args=(run, stop), daemon=True) sweeper.start() try: code, stdout, stderr = run_with_timeout( cmd, cwd=run, timeout_sec=timeout_sec, kill_extra=lambda: subprocess.run(["pkill", "-9", "-u", GRADER], capture_output=True), ) finally: stop.set() sweeper.join() return code, stdout + "\n--- stderr ---\n" + stderr
def run_with_timeout(cmd: list[str], cwd: Path, timeout_sec: int, kill_extra=None) -> tuple[int | None, str, str]: """Run ``cmd``; on timeout kill its whole process tree and return code None.
`timeout(1)` only signals its direct child, so Lean processes started by Lake under landrun kept the output pipe open and the grader waited past Harbor's own limit. Here the command gets its own session; on timeout its process group is killed, and ``kill_extra`` (every process of the grader user) catches anything that left the group. """ proc = subprocess.Popen(cmd, cwd=cwd, stdout=subprocess.PIPE, stderr=subprocess.PIPE, text=True, errors="replace", start_new_session=True) try: stdout, stderr = proc.communicate(timeout=timeout_sec) return proc.returncode, stdout, stderr except subprocess.TimeoutExpired: try: os.killpg(proc.pid, signal.SIGKILL) except ProcessLookupError: pass if kill_extra: kill_extra() stdout, stderr = proc.communicate() return None, stdout, stderr
def classify(code: int | None, out: str) -> tuple[int | None, str]: """Map Comparator's result to (reward, reason). reward None means a grading error.""" if code == 0 and SUCCESS_LINE in out: return 1, "accepted: statements match, only permitted axioms, kernel replay passed" if "Building Submission" not in out: # Comparator stopped before it touched the submission: the trusted challenge or the # toolchain is broken (or too slow), which says nothing about the agent's proof. return None, ("timed out before the submission was built" if code is None else "the trusted Challenge failed to build or export") if code is None: return 0, "timed out while building or checking the submission" tail = [l for l in out.splitlines() if l.strip() and "has local changes" not in l][-25:] if out_of_disk(out): return 0, "rejected: the build ran out of disk space (10 GB) | " + " | ".join(tail)[-3000:] if out_of_memory(out): return 0, "rejected: the build was killed, most likely out of memory (8 GB) | " + " | ".join(tail)[-3000:] return 0, "rejected: " + " | ".join(tail)[-4000:]
def main() -> int: VERIFIER_DIR.mkdir(parents=True, exist_ok=True) os.chmod(VERIFIER_DIR, 0o755) for name in ("reward.txt", "reward.json"): (VERIFIER_DIR / name).unlink(missing_ok=True)
task = json.loads((TESTS / "task.json").read_text()) details: dict = {"task": task["challenge"], "started_at": time.time()} reward: int | None = None log = "" try: RUN_ROOT.mkdir(mode=0o711, parents=True, exist_ok=True) deadline = time.time() + int(task["grade_timeout_sec"]) run = fresh_run(task) details["permission_fixes"] = ensure_readable() block_grader_network() details["submission"] = unpack_submission(run) code, out = run_comparator(run, int(deadline - time.time())) log = out kill_grader() if code not in (0, None) and out_of_memory(out) and deadline - time.time() > 60: # Two Lean processes in parallel can exceed 8 GB on a heavy module. Retry once with one, # in a fresh directory: the first attempt's .lake was written by the submission's own # build and must not be trusted for the challenge. shutil.rmtree(run, ignore_errors=True) run = fresh_run(task) unpack_submission(run) code, out = run_comparator(run, int(deadline - time.time()), threads="1") log += "\n\n=== retried with one Lean process after running out of memory ===\n\n" + out kill_grader() details["retried_single_thread"] = True reward, details["reason"] = classify(code, out) details["comparator_exit"] = code except Rejected as exc: reward, details["reason"] = 0, f"rejected: {exc}" except GradingError as exc: reward, details["reason"] = None, f"grading error: {exc}" except Exception as exc: reward, details["reason"] = None, f"grading error: {type(exc).__name__}: {exc}" finally: try: kill_grader() except GradingError as exc: reward, details["reason"] = None, f"grading error: {exc}" # Free the build before writing anything. A build that filled the disk would otherwise # make these writes fail, and with no space left the sandbox cannot report that the # verifier exited, so Harbor waits until its own timeout and records no verdict. shutil.rmtree(RUN_ROOT, ignore_errors=True) details["reward"] = reward details["finished_at"] = time.time() (VERIFIER_DIR / "comparator.log").write_text(log) (VERIFIER_DIR / "grading.json").write_text(json.dumps(details, indent=2)) print(json.dumps(details, indent=2)) if reward is not None: (VERIFIER_DIR / "reward.txt").write_text(f"{reward}\n") return 0
if __name__ == "__main__": sys.exit(main())123456789101112131415{ "challenge": "RamseyFive", "comparator": { "theorem_names": [ "OAI.SharpRamseyFive.main" ], "definition_names": [], "permitted_axioms": [ "propext", "Quot.sound", "Classical.choice" ] }, "grade_timeout_sec": 14071}123#!/usr/bin/env bash# Runs in the separate verifier sandbox, which never ran agent code. See grade.py.exec python3 /tests/grade.py22 unmodified lines2324252627282922 unmodified linesreference_lean_bytes = 1301045reference_requires_packages = []oracle_result = "accepted"oracle_grade_seconds = 1082difficulty = "research"[agent]22 unmodified lines2324252627282922 unmodified linesreference_lean_bytes = 1301045reference_requires_packages = []oracle_result = "accepted"oracle_grade_seconds = 809difficulty = "research"[agent]
34 unmodified lines3536373839405 unmodified lines464748495051188 unmodified lines2402412422432442458 unmodified lines25425525625725825926026126226333 unmodified lines2972982993003013028 unmodified lines3113123133143153168 unmodified lines32532632732832933033133233333433533633733833934034134234334434534634734834935034 unmodified linesimport sysimport tarfileimport tempfileimport timefrom pathlib import Path5 unmodified linesGRADER = "grader"SUCCESS_LINE = "Your solution is okay!"GRADE_THREADS = "2"# Lake and Comparator wording when a build process is killed for running out of memory.OOM_MARKERS = ("Lean exited with code 137", "Child exited with 137")188 unmodified linesreturn any(m in out for m in OOM_MARKERS)def run_comparator(run: Path, timeout_sec: int, threads: str = GRADE_THREADS) -> tuple[int | None, str]:env = {"PATH": f"{toolchain_bin()}:/usr/local/bin:/usr/bin:/bin",8 unmodified lines"runuser", "-u", GRADER, "--", "env", "-i", *(f"{k}={v}" for k, v in env.items()),"lake", "env", "comparator", "config.json",]code, stdout, stderr = run_with_timeout(cmd, cwd=run, timeout_sec=timeout_sec,kill_extra=lambda: subprocess.run(["pkill", "-9", "-u", GRADER], capture_output=True),)return code, stdout + "\n--- stderr ---\n" + stderr33 unmodified linesif code is None:return 0, "timed out while building or checking the submission"tail = [l for l in out.splitlines() if l.strip() and "has local changes" not in l][-25:]if out_of_memory(out):return 0, "rejected: the build was killed, most likely out of memory (8 GB) | " + " | ".join(tail)[-3000:]return 0, "rejected: " + " | ".join(tail)[-4000:]8 unmodified linestask = json.loads((TESTS / "task.json").read_text())details: dict = {"task": task["challenge"], "started_at": time.time()}reward: int | None = Nonetry:RUN_ROOT.mkdir(mode=0o711, parents=True, exist_ok=True)deadline = time.time() + int(task["grade_timeout_sec"])8 unmodified lines# Two Lean processes in parallel can exceed 8 GB on a heavy module. Retry once with one,# in a fresh directory: the first attempt's .lake was written by the submission's own# build and must not be trusted for the challenge.run = fresh_run(task)unpack_submission(run)code, out = run_comparator(run, int(deadline - time.time()), threads="1")log += "\n\n=== retried with one Lean process after running out of memory ===\n\n" + outkill_grader()details["retried_single_thread"] = True(VERIFIER_DIR / "comparator.log").write_text(log)reward, details["reason"] = classify(code, out)details["comparator_exit"] = codeexcept Rejected as exc:reward, details["reason"] = 0, f"rejected: {exc}"except GradingError as exc:reward, details["reason"] = None, f"grading error: {exc}"finally:try:kill_grader()except GradingError as exc:reward, details["reason"] = None, f"grading error: {exc}"details["reward"] = rewarddetails["finished_at"] = time.time()(VERIFIER_DIR / "grading.json").write_text(json.dumps(details, indent=2))print(json.dumps(details, indent=2))if reward is not None:34 unmodified lines353637383940415 unmodified lines47484950515253188 unmodified lines2422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892908 unmodified lines29930030130230330430530630730830931031131231331431533 unmodified lines3493503513523533543553568 unmodified lines3653663673683693703718 unmodified lines38038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141234 unmodified linesimport sysimport tarfileimport tempfileimport threadingimport timefrom pathlib import Path5 unmodified linesGRADER = "grader"SUCCESS_LINE = "Your solution is okay!"GRADE_THREADS = "2"SCRATCH_SWEEP_SEC = 15# Lake and Comparator wording when a build process is killed for running out of memory.OOM_MARKERS = ("Lean exited with code 137", "Child exited with 137")188 unmodified linesreturn any(m in out for m in OOM_MARKERS)def out_of_disk(out: str) -> bool:return "no space left on device" in out.lower()# Run as the grader user by `empty_build_scratch`. argv: the .lake/build/ir directory.EMPTY_SCRATCH = r"""import os, sysfor dirpath, _, files in os.walk(sys.argv[1]):for name in files:if not name.endswith(".setup.json"):continuebase = os.path.join(dirpath, name[:-len(".setup.json")])try:# Lake writes X.c.hash once Lean, and leanir if the module needs it, are done with X;# both read X.setup.json, so it may only be emptied after that.if os.stat(base + ".c.hash").st_mtime < os.stat(base + ".setup.json").st_mtime:continuefor path in (base + ".setup.json", base + ".c"):if os.path.getsize(path):os.truncate(path, 0)except OSError:pass"""def empty_build_scratch(run: Path, stop: threading.Event) -> None:"""Until ``stop`` is set, empty files Lake leaves in .lake/build/ir that grading never reads.For every module Lake writes a `.setup.json` (its imports with the path of every .olean theypull in, about 5.5 MB with Mathlib) and the module compiled to C. Neither is used once themodule is built, and for proofs of 1,000-2,000 modules they filled the 10 GB disk before thebuild finished. Lake keeps the recorded hashes, so emptied files do not trigger a rebuild.This runs as the grader user, so it can touch nothing the build could not."""ir = str(run / ".lake" / "build" / "ir")while not stop.wait(SCRATCH_SWEEP_SEC):try:subprocess.run(["runuser", "-u", GRADER, "--", sys.executable, "-c", EMPTY_SCRATCH, ir],capture_output=True, timeout=600)except subprocess.TimeoutExpired:passdef run_comparator(run: Path, timeout_sec: int, threads: str = GRADE_THREADS) -> tuple[int | None, str]:env = {"PATH": f"{toolchain_bin()}:/usr/local/bin:/usr/bin:/bin",8 unmodified lines"runuser", "-u", GRADER, "--", "env", "-i", *(f"{k}={v}" for k, v in env.items()),"lake", "env", "comparator", "config.json",]stop = threading.Event()sweeper = threading.Thread(target=empty_build_scratch, args=(run, stop), daemon=True)sweeper.start()try:code, stdout, stderr = run_with_timeout(cmd, cwd=run, timeout_sec=timeout_sec,kill_extra=lambda: subprocess.run(["pkill", "-9", "-u", GRADER], capture_output=True),)finally:stop.set()sweeper.join()return code, stdout + "\n--- stderr ---\n" + stderr33 unmodified linesif code is None:return 0, "timed out while building or checking the submission"tail = [l for l in out.splitlines() if l.strip() and "has local changes" not in l][-25:]if out_of_disk(out):return 0, "rejected: the build ran out of disk space (10 GB) | " + " | ".join(tail)[-3000:]if out_of_memory(out):return 0, "rejected: the build was killed, most likely out of memory (8 GB) | " + " | ".join(tail)[-3000:]return 0, "rejected: " + " | ".join(tail)[-4000:]8 unmodified linestask = json.loads((TESTS / "task.json").read_text())details: dict = {"task": task["challenge"], "started_at": time.time()}reward: int | None = Nonelog = ""try:RUN_ROOT.mkdir(mode=0o711, parents=True, exist_ok=True)deadline = time.time() + int(task["grade_timeout_sec"])8 unmodified lines# Two Lean processes in parallel can exceed 8 GB on a heavy module. Retry once with one,# in a fresh directory: the first attempt's .lake was written by the submission's own# build and must not be trusted for the challenge.shutil.rmtree(run, ignore_errors=True)run = fresh_run(task)unpack_submission(run)code, out = run_comparator(run, int(deadline - time.time()), threads="1")log += "\n\n=== retried with one Lean process after running out of memory ===\n\n" + outkill_grader()details["retried_single_thread"] = Truereward, details["reason"] = classify(code, out)details["comparator_exit"] = codeexcept Rejected as exc:reward, details["reason"] = 0, f"rejected: {exc}"except GradingError as exc:reward, details["reason"] = None, f"grading error: {exc}"except Exception as exc:reward, details["reason"] = None, f"grading error: {type(exc).__name__}: {exc}"finally:try:kill_grader()except GradingError as exc:reward, details["reason"] = None, f"grading error: {exc}"# Free the build before writing anything. A build that filled the disk would otherwise# make these writes fail, and with no space left the sandbox cannot report that the# verifier exited, so Harbor waits until its own timeout and records no verdict.shutil.rmtree(RUN_ROOT, ignore_errors=True)details["reward"] = rewarddetails["finished_at"] = time.time()(VERIFIER_DIR / "comparator.log").write_text(log)(VERIFIER_DIR / "grading.json").write_text(json.dumps(details, indent=2))print(json.dumps(details, indent=2))if reward is not None:
22 unmodified lines2324252627282922 unmodified linesreference_lean_bytes = 700555reference_requires_packages = []oracle_result = "accepted"oracle_grade_seconds = 666difficulty = "research"[agent]22 unmodified lines2324252627282922 unmodified linesreference_lean_bytes = 700555reference_requires_packages = []oracle_result = "accepted"oracle_grade_seconds = 472difficulty = "research"[agent]
34 unmodified lines3536373839405 unmodified lines464748495051188 unmodified lines2402412422432442458 unmodified lines25425525625725825926026126226333 unmodified lines2972982993003013028 unmodified lines3113123133143153168 unmodified lines32532632732832933033133233333433533633733833934034134234334434534634734834935034 unmodified linesimport sysimport tarfileimport tempfileimport timefrom pathlib import Path5 unmodified linesGRADER = "grader"SUCCESS_LINE = "Your solution is okay!"GRADE_THREADS = "2"# Lake and Comparator wording when a build process is killed for running out of memory.OOM_MARKERS = ("Lean exited with code 137", "Child exited with 137")188 unmodified linesreturn any(m in out for m in OOM_MARKERS)def run_comparator(run: Path, timeout_sec: int, threads: str = GRADE_THREADS) -> tuple[int | None, str]:env = {"PATH": f"{toolchain_bin()}:/usr/local/bin:/usr/bin:/bin",8 unmodified lines"runuser", "-u", GRADER, "--", "env", "-i", *(f"{k}={v}" for k, v in env.items()),"lake", "env", "comparator", "config.json",]code, stdout, stderr = run_with_timeout(cmd, cwd=run, timeout_sec=timeout_sec,kill_extra=lambda: subprocess.run(["pkill", "-9", "-u", GRADER], capture_output=True),)return code, stdout + "\n--- stderr ---\n" + stderr33 unmodified linesif code is None:return 0, "timed out while building or checking the submission"tail = [l for l in out.splitlines() if l.strip() and "has local changes" not in l][-25:]if out_of_memory(out):return 0, "rejected: the build was killed, most likely out of memory (8 GB) | " + " | ".join(tail)[-3000:]return 0, "rejected: " + " | ".join(tail)[-4000:]8 unmodified linestask = json.loads((TESTS / "task.json").read_text())details: dict = {"task": task["challenge"], "started_at": time.time()}reward: int | None = Nonetry:RUN_ROOT.mkdir(mode=0o711, parents=True, exist_ok=True)deadline = time.time() + int(task["grade_timeout_sec"])8 unmodified lines# Two Lean processes in parallel can exceed 8 GB on a heavy module. Retry once with one,# in a fresh directory: the first attempt's .lake was written by the submission's own# build and must not be trusted for the challenge.run = fresh_run(task)unpack_submission(run)code, out = run_comparator(run, int(deadline - time.time()), threads="1")log += "\n\n=== retried with one Lean process after running out of memory ===\n\n" + outkill_grader()details["retried_single_thread"] = True(VERIFIER_DIR / "comparator.log").write_text(log)reward, details["reason"] = classify(code, out)details["comparator_exit"] = codeexcept Rejected as exc:reward, details["reason"] = 0, f"rejected: {exc}"except GradingError as exc:reward, details["reason"] = None, f"grading error: {exc}"finally:try:kill_grader()except GradingError as exc:reward, details["reason"] = None, f"grading error: {exc}"details["reward"] = rewarddetails["finished_at"] = time.time()(VERIFIER_DIR / "grading.json").write_text(json.dumps(details, indent=2))print(json.dumps(details, indent=2))if reward is not None:34 unmodified lines353637383940415 unmodified lines47484950515253188 unmodified lines2422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892908 unmodified lines29930030130230330430530630730830931031131231331431533 unmodified lines3493503513523533543553568 unmodified lines3653663673683693703718 unmodified lines38038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141234 unmodified linesimport sysimport tarfileimport tempfileimport threadingimport timefrom pathlib import Path5 unmodified linesGRADER = "grader"SUCCESS_LINE = "Your solution is okay!"GRADE_THREADS = "2"SCRATCH_SWEEP_SEC = 15# Lake and Comparator wording when a build process is killed for running out of memory.OOM_MARKERS = ("Lean exited with code 137", "Child exited with 137")188 unmodified linesreturn any(m in out for m in OOM_MARKERS)def out_of_disk(out: str) -> bool:return "no space left on device" in out.lower()# Run as the grader user by `empty_build_scratch`. argv: the .lake/build/ir directory.EMPTY_SCRATCH = r"""import os, sysfor dirpath, _, files in os.walk(sys.argv[1]):for name in files:if not name.endswith(".setup.json"):continuebase = os.path.join(dirpath, name[:-len(".setup.json")])try:# Lake writes X.c.hash once Lean, and leanir if the module needs it, are done with X;# both read X.setup.json, so it may only be emptied after that.if os.stat(base + ".c.hash").st_mtime < os.stat(base + ".setup.json").st_mtime:continuefor path in (base + ".setup.json", base + ".c"):if os.path.getsize(path):os.truncate(path, 0)except OSError:pass"""def empty_build_scratch(run: Path, stop: threading.Event) -> None:"""Until ``stop`` is set, empty files Lake leaves in .lake/build/ir that grading never reads.For every module Lake writes a `.setup.json` (its imports with the path of every .olean theypull in, about 5.5 MB with Mathlib) and the module compiled to C. Neither is used once themodule is built, and for proofs of 1,000-2,000 modules they filled the 10 GB disk before thebuild finished. Lake keeps the recorded hashes, so emptied files do not trigger a rebuild.This runs as the grader user, so it can touch nothing the build could not."""ir = str(run / ".lake" / "build" / "ir")while not stop.wait(SCRATCH_SWEEP_SEC):try:subprocess.run(["runuser", "-u", GRADER, "--", sys.executable, "-c", EMPTY_SCRATCH, ir],capture_output=True, timeout=600)except subprocess.TimeoutExpired:passdef run_comparator(run: Path, timeout_sec: int, threads: str = GRADE_THREADS) -> tuple[int | None, str]:env = {"PATH": f"{toolchain_bin()}:/usr/local/bin:/usr/bin:/bin",8 unmodified lines"runuser", "-u", GRADER, "--", "env", "-i", *(f"{k}={v}" for k, v in env.items()),"lake", "env", "comparator", "config.json",]stop = threading.Event()sweeper = threading.Thread(target=empty_build_scratch, args=(run, stop), daemon=True)sweeper.start()try:code, stdout, stderr = run_with_timeout(cmd, cwd=run, timeout_sec=timeout_sec,kill_extra=lambda: subprocess.run(["pkill", "-9", "-u", GRADER], capture_output=True),)finally:stop.set()sweeper.join()return code, stdout + "\n--- stderr ---\n" + stderr33 unmodified linesif code is None:return 0, "timed out while building or checking the submission"tail = [l for l in out.splitlines() if l.strip() and "has local changes" not in l][-25:]if out_of_disk(out):return 0, "rejected: the build ran out of disk space (10 GB) | " + " | ".join(tail)[-3000:]if out_of_memory(out):return 0, "rejected: the build was killed, most likely out of memory (8 GB) | " + " | ".join(tail)[-3000:]return 0, "rejected: " + " | ".join(tail)[-4000:]8 unmodified linestask = json.loads((TESTS / "task.json").read_text())details: dict = {"task": task["challenge"], "started_at": time.time()}reward: int | None = Nonelog = ""try:RUN_ROOT.mkdir(mode=0o711, parents=True, exist_ok=True)deadline = time.time() + int(task["grade_timeout_sec"])8 unmodified lines# Two Lean processes in parallel can exceed 8 GB on a heavy module. Retry once with one,# in a fresh directory: the first attempt's .lake was written by the submission's own# build and must not be trusted for the challenge.shutil.rmtree(run, ignore_errors=True)run = fresh_run(task)unpack_submission(run)code, out = run_comparator(run, int(deadline - time.time()), threads="1")log += "\n\n=== retried with one Lean process after running out of memory ===\n\n" + outkill_grader()details["retried_single_thread"] = Truereward, details["reason"] = classify(code, out)details["comparator_exit"] = codeexcept Rejected as exc:reward, details["reason"] = 0, f"rejected: {exc}"except GradingError as exc:reward, details["reason"] = None, f"grading error: {exc}"except Exception as exc:reward, details["reason"] = None, f"grading error: {type(exc).__name__}: {exc}"finally:try:kill_grader()except GradingError as exc:reward, details["reason"] = None, f"grading error: {exc}"# Free the build before writing anything. A build that filled the disk would otherwise# make these writes fail, and with no space left the sandbox cannot report that the# verifier exited, so Harbor waits until its own timeout and records no verdict.shutil.rmtree(RUN_ROOT, ignore_errors=True)details["reward"] = rewarddetails["finished_at"] = time.time()(VERIFIER_DIR / "comparator.log").write_text(log)(VERIFIER_DIR / "grading.json").write_text(json.dumps(details, indent=2))print(json.dumps(details, indent=2))if reward is not None:
22 unmodified lines2324252627282922 unmodified linesreference_lean_bytes = 179835reference_requires_packages = []oracle_result = "accepted"oracle_grade_seconds = 304difficulty = "research"[agent]22 unmodified lines2324252627282922 unmodified linesreference_lean_bytes = 179835reference_requires_packages = []oracle_result = "accepted"oracle_grade_seconds = 172difficulty = "research"[agent]
34 unmodified lines3536373839405 unmodified lines464748495051188 unmodified lines2402412422432442458 unmodified lines25425525625725825926026126226333 unmodified lines2972982993003013028 unmodified lines3113123133143153168 unmodified lines32532632732832933033133233333433533633733833934034134234334434534634734834935034 unmodified linesimport sysimport tarfileimport tempfileimport timefrom pathlib import Path5 unmodified linesGRADER = "grader"SUCCESS_LINE = "Your solution is okay!"GRADE_THREADS = "2"# Lake and Comparator wording when a build process is killed for running out of memory.OOM_MARKERS = ("Lean exited with code 137", "Child exited with 137")188 unmodified linesreturn any(m in out for m in OOM_MARKERS)def run_comparator(run: Path, timeout_sec: int, threads: str = GRADE_THREADS) -> tuple[int | None, str]:env = {"PATH": f"{toolchain_bin()}:/usr/local/bin:/usr/bin:/bin",8 unmodified lines"runuser", "-u", GRADER, "--", "env", "-i", *(f"{k}={v}" for k, v in env.items()),"lake", "env", "comparator", "config.json",]code, stdout, stderr = run_with_timeout(cmd, cwd=run, timeout_sec=timeout_sec,kill_extra=lambda: subprocess.run(["pkill", "-9", "-u", GRADER], capture_output=True),)return code, stdout + "\n--- stderr ---\n" + stderr33 unmodified linesif code is None:return 0, "timed out while building or checking the submission"tail = [l for l in out.splitlines() if l.strip() and "has local changes" not in l][-25:]if out_of_memory(out):return 0, "rejected: the build was killed, most likely out of memory (8 GB) | " + " | ".join(tail)[-3000:]return 0, "rejected: " + " | ".join(tail)[-4000:]8 unmodified linestask = json.loads((TESTS / "task.json").read_text())details: dict = {"task": task["challenge"], "started_at": time.time()}reward: int | None = Nonetry:RUN_ROOT.mkdir(mode=0o711, parents=True, exist_ok=True)deadline = time.time() + int(task["grade_timeout_sec"])8 unmodified lines# Two Lean processes in parallel can exceed 8 GB on a heavy module. Retry once with one,# in a fresh directory: the first attempt's .lake was written by the submission's own# build and must not be trusted for the challenge.run = fresh_run(task)unpack_submission(run)code, out = run_comparator(run, int(deadline - time.time()), threads="1")log += "\n\n=== retried with one Lean process after running out of memory ===\n\n" + outkill_grader()details["retried_single_thread"] = True(VERIFIER_DIR / "comparator.log").write_text(log)reward, details["reason"] = classify(code, out)details["comparator_exit"] = codeexcept Rejected as exc:reward, details["reason"] = 0, f"rejected: {exc}"except GradingError as exc:reward, details["reason"] = None, f"grading error: {exc}"finally:try:kill_grader()except GradingError as exc:reward, details["reason"] = None, f"grading error: {exc}"details["reward"] = rewarddetails["finished_at"] = time.time()(VERIFIER_DIR / "grading.json").write_text(json.dumps(details, indent=2))print(json.dumps(details, indent=2))if reward is not None:34 unmodified lines353637383940415 unmodified lines47484950515253188 unmodified lines2422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892908 unmodified lines29930030130230330430530630730830931031131231331431533 unmodified lines3493503513523533543553568 unmodified lines3653663673683693703718 unmodified lines38038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141234 unmodified linesimport sysimport tarfileimport tempfileimport threadingimport timefrom pathlib import Path5 unmodified linesGRADER = "grader"SUCCESS_LINE = "Your solution is okay!"GRADE_THREADS = "2"SCRATCH_SWEEP_SEC = 15# Lake and Comparator wording when a build process is killed for running out of memory.OOM_MARKERS = ("Lean exited with code 137", "Child exited with 137")188 unmodified linesreturn any(m in out for m in OOM_MARKERS)def out_of_disk(out: str) -> bool:return "no space left on device" in out.lower()# Run as the grader user by `empty_build_scratch`. argv: the .lake/build/ir directory.EMPTY_SCRATCH = r"""import os, sysfor dirpath, _, files in os.walk(sys.argv[1]):for name in files:if not name.endswith(".setup.json"):continuebase = os.path.join(dirpath, name[:-len(".setup.json")])try:# Lake writes X.c.hash once Lean, and leanir if the module needs it, are done with X;# both read X.setup.json, so it may only be emptied after that.if os.stat(base + ".c.hash").st_mtime < os.stat(base + ".setup.json").st_mtime:continuefor path in (base + ".setup.json", base + ".c"):if os.path.getsize(path):os.truncate(path, 0)except OSError:pass"""def empty_build_scratch(run: Path, stop: threading.Event) -> None:"""Until ``stop`` is set, empty files Lake leaves in .lake/build/ir that grading never reads.For every module Lake writes a `.setup.json` (its imports with the path of every .olean theypull in, about 5.5 MB with Mathlib) and the module compiled to C. Neither is used once themodule is built, and for proofs of 1,000-2,000 modules they filled the 10 GB disk before thebuild finished. Lake keeps the recorded hashes, so emptied files do not trigger a rebuild.This runs as the grader user, so it can touch nothing the build could not."""ir = str(run / ".lake" / "build" / "ir")while not stop.wait(SCRATCH_SWEEP_SEC):try:subprocess.run(["runuser", "-u", GRADER, "--", sys.executable, "-c", EMPTY_SCRATCH, ir],capture_output=True, timeout=600)except subprocess.TimeoutExpired:passdef run_comparator(run: Path, timeout_sec: int, threads: str = GRADE_THREADS) -> tuple[int | None, str]:env = {"PATH": f"{toolchain_bin()}:/usr/local/bin:/usr/bin:/bin",8 unmodified lines"runuser", "-u", GRADER, "--", "env", "-i", *(f"{k}={v}" for k, v in env.items()),"lake", "env", "comparator", "config.json",]stop = threading.Event()sweeper = threading.Thread(target=empty_build_scratch, args=(run, stop), daemon=True)sweeper.start()try:code, stdout, stderr = run_with_timeout(cmd, cwd=run, timeout_sec=timeout_sec,kill_extra=lambda: subprocess.run(["pkill", "-9", "-u", GRADER], capture_output=True),)finally:stop.set()sweeper.join()return code, stdout + "\n--- stderr ---\n" + stderr33 unmodified linesif code is None:return 0, "timed out while building or checking the submission"tail = [l for l in out.splitlines() if l.strip() and "has local changes" not in l][-25:]if out_of_disk(out):return 0, "rejected: the build ran out of disk space (10 GB) | " + " | ".join(tail)[-3000:]if out_of_memory(out):return 0, "rejected: the build was killed, most likely out of memory (8 GB) | " + " | ".join(tail)[-3000:]return 0, "rejected: " + " | ".join(tail)[-4000:]8 unmodified linestask = json.loads((TESTS / "task.json").read_text())details: dict = {"task": task["challenge"], "started_at": time.time()}reward: int | None = Nonelog = ""try:RUN_ROOT.mkdir(mode=0o711, parents=True, exist_ok=True)deadline = time.time() + int(task["grade_timeout_sec"])8 unmodified lines# Two Lean processes in parallel can exceed 8 GB on a heavy module. Retry once with one,# in a fresh directory: the first attempt's .lake was written by the submission's own# build and must not be trusted for the challenge.shutil.rmtree(run, ignore_errors=True)run = fresh_run(task)unpack_submission(run)code, out = run_comparator(run, int(deadline - time.time()), threads="1")log += "\n\n=== retried with one Lean process after running out of memory ===\n\n" + outkill_grader()details["retried_single_thread"] = Truereward, details["reason"] = classify(code, out)details["comparator_exit"] = codeexcept Rejected as exc:reward, details["reason"] = 0, f"rejected: {exc}"except GradingError as exc:reward, details["reason"] = None, f"grading error: {exc}"except Exception as exc:reward, details["reason"] = None, f"grading error: {type(exc).__name__}: {exc}"finally:try:kill_grader()except GradingError as exc:reward, details["reason"] = None, f"grading error: {exc}"# Free the build before writing anything. A build that filled the disk would otherwise# make these writes fail, and with no space left the sandbox cannot report that the# verifier exited, so Harbor waits until its own timeout and records no verdict.shutil.rmtree(RUN_ROOT, ignore_errors=True)details["reward"] = rewarddetails["finished_at"] = time.time()(VERIFIER_DIR / "comparator.log").write_text(log)(VERIFIER_DIR / "grading.json").write_text(json.dumps(details, indent=2))print(json.dumps(details, indent=2))if reward is not None:
22 unmodified lines2324252627282922 unmodified linesreference_lean_bytes = 445768reference_requires_packages = []oracle_result = "accepted"oracle_grade_seconds = 617difficulty = "research"[agent]22 unmodified lines2324252627282922 unmodified linesreference_lean_bytes = 445768reference_requires_packages = []oracle_result = "accepted"oracle_grade_seconds = 218difficulty = "research"[agent]
34 unmodified lines3536373839405 unmodified lines464748495051188 unmodified lines2402412422432442458 unmodified lines25425525625725825926026126226333 unmodified lines2972982993003013028 unmodified lines3113123133143153168 unmodified lines32532632732832933033133233333433533633733833934034134234334434534634734834935034 unmodified linesimport sysimport tarfileimport tempfileimport timefrom pathlib import Path5 unmodified linesGRADER = "grader"SUCCESS_LINE = "Your solution is okay!"GRADE_THREADS = "2"# Lake and Comparator wording when a build process is killed for running out of memory.OOM_MARKERS = ("Lean exited with code 137", "Child exited with 137")188 unmodified linesreturn any(m in out for m in OOM_MARKERS)def run_comparator(run: Path, timeout_sec: int, threads: str = GRADE_THREADS) -> tuple[int | None, str]:env = {"PATH": f"{toolchain_bin()}:/usr/local/bin:/usr/bin:/bin",8 unmodified lines"runuser", "-u", GRADER, "--", "env", "-i", *(f"{k}={v}" for k, v in env.items()),"lake", "env", "comparator", "config.json",]code, stdout, stderr = run_with_timeout(cmd, cwd=run, timeout_sec=timeout_sec,kill_extra=lambda: subprocess.run(["pkill", "-9", "-u", GRADER], capture_output=True),)return code, stdout + "\n--- stderr ---\n" + stderr33 unmodified linesif code is None:return 0, "timed out while building or checking the submission"tail = [l for l in out.splitlines() if l.strip() and "has local changes" not in l][-25:]if out_of_memory(out):return 0, "rejected: the build was killed, most likely out of memory (8 GB) | " + " | ".join(tail)[-3000:]return 0, "rejected: " + " | ".join(tail)[-4000:]8 unmodified linestask = json.loads((TESTS / "task.json").read_text())details: dict = {"task": task["challenge"], "started_at": time.time()}reward: int | None = Nonetry:RUN_ROOT.mkdir(mode=0o711, parents=True, exist_ok=True)deadline = time.time() + int(task["grade_timeout_sec"])8 unmodified lines# Two Lean processes in parallel can exceed 8 GB on a heavy module. Retry once with one,# in a fresh directory: the first attempt's .lake was written by the submission's own# build and must not be trusted for the challenge.run = fresh_run(task)unpack_submission(run)code, out = run_comparator(run, int(deadline - time.time()), threads="1")log += "\n\n=== retried with one Lean process after running out of memory ===\n\n" + outkill_grader()details["retried_single_thread"] = True(VERIFIER_DIR / "comparator.log").write_text(log)reward, details["reason"] = classify(code, out)details["comparator_exit"] = codeexcept Rejected as exc:reward, details["reason"] = 0, f"rejected: {exc}"except GradingError as exc:reward, details["reason"] = None, f"grading error: {exc}"finally:try:kill_grader()except GradingError as exc:reward, details["reason"] = None, f"grading error: {exc}"details["reward"] = rewarddetails["finished_at"] = time.time()(VERIFIER_DIR / "grading.json").write_text(json.dumps(details, indent=2))print(json.dumps(details, indent=2))if reward is not None:34 unmodified lines353637383940415 unmodified lines47484950515253188 unmodified lines2422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892908 unmodified lines29930030130230330430530630730830931031131231331431533 unmodified lines3493503513523533543553568 unmodified lines3653663673683693703718 unmodified lines38038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141234 unmodified linesimport sysimport tarfileimport tempfileimport threadingimport timefrom pathlib import Path5 unmodified linesGRADER = "grader"SUCCESS_LINE = "Your solution is okay!"GRADE_THREADS = "2"SCRATCH_SWEEP_SEC = 15# Lake and Comparator wording when a build process is killed for running out of memory.OOM_MARKERS = ("Lean exited with code 137", "Child exited with 137")188 unmodified linesreturn any(m in out for m in OOM_MARKERS)def out_of_disk(out: str) -> bool:return "no space left on device" in out.lower()# Run as the grader user by `empty_build_scratch`. argv: the .lake/build/ir directory.EMPTY_SCRATCH = r"""import os, sysfor dirpath, _, files in os.walk(sys.argv[1]):for name in files:if not name.endswith(".setup.json"):continuebase = os.path.join(dirpath, name[:-len(".setup.json")])try:# Lake writes X.c.hash once Lean, and leanir if the module needs it, are done with X;# both read X.setup.json, so it may only be emptied after that.if os.stat(base + ".c.hash").st_mtime < os.stat(base + ".setup.json").st_mtime:continuefor path in (base + ".setup.json", base + ".c"):if os.path.getsize(path):os.truncate(path, 0)except OSError:pass"""def empty_build_scratch(run: Path, stop: threading.Event) -> None:"""Until ``stop`` is set, empty files Lake leaves in .lake/build/ir that grading never reads.For every module Lake writes a `.setup.json` (its imports with the path of every .olean theypull in, about 5.5 MB with Mathlib) and the module compiled to C. Neither is used once themodule is built, and for proofs of 1,000-2,000 modules they filled the 10 GB disk before thebuild finished. Lake keeps the recorded hashes, so emptied files do not trigger a rebuild.This runs as the grader user, so it can touch nothing the build could not."""ir = str(run / ".lake" / "build" / "ir")while not stop.wait(SCRATCH_SWEEP_SEC):try:subprocess.run(["runuser", "-u", GRADER, "--", sys.executable, "-c", EMPTY_SCRATCH, ir],capture_output=True, timeout=600)except subprocess.TimeoutExpired:passdef run_comparator(run: Path, timeout_sec: int, threads: str = GRADE_THREADS) -> tuple[int | None, str]:env = {"PATH": f"{toolchain_bin()}:/usr/local/bin:/usr/bin:/bin",8 unmodified lines"runuser", "-u", GRADER, "--", "env", "-i", *(f"{k}={v}" for k, v in env.items()),"lake", "env", "comparator", "config.json",]stop = threading.Event()sweeper = threading.Thread(target=empty_build_scratch, args=(run, stop), daemon=True)sweeper.start()try:code, stdout, stderr = run_with_timeout(cmd, cwd=run, timeout_sec=timeout_sec,kill_extra=lambda: subprocess.run(["pkill", "-9", "-u", GRADER], capture_output=True),)finally:stop.set()sweeper.join()return code, stdout + "\n--- stderr ---\n" + stderr33 unmodified linesif code is None:return 0, "timed out while building or checking the submission"tail = [l for l in out.splitlines() if l.strip() and "has local changes" not in l][-25:]if out_of_disk(out):return 0, "rejected: the build ran out of disk space (10 GB) | " + " | ".join(tail)[-3000:]if out_of_memory(out):return 0, "rejected: the build was killed, most likely out of memory (8 GB) | " + " | ".join(tail)[-3000:]return 0, "rejected: " + " | ".join(tail)[-4000:]8 unmodified linestask = json.loads((TESTS / "task.json").read_text())details: dict = {"task": task["challenge"], "started_at": time.time()}reward: int | None = Nonelog = ""try:RUN_ROOT.mkdir(mode=0o711, parents=True, exist_ok=True)deadline = time.time() + int(task["grade_timeout_sec"])8 unmodified lines# Two Lean processes in parallel can exceed 8 GB on a heavy module. Retry once with one,# in a fresh directory: the first attempt's .lake was written by the submission's own# build and must not be trusted for the challenge.shutil.rmtree(run, ignore_errors=True)run = fresh_run(task)unpack_submission(run)code, out = run_comparator(run, int(deadline - time.time()), threads="1")log += "\n\n=== retried with one Lean process after running out of memory ===\n\n" + outkill_grader()details["retried_single_thread"] = Truereward, details["reason"] = classify(code, out)details["comparator_exit"] = codeexcept Rejected as exc:reward, details["reason"] = 0, f"rejected: {exc}"except GradingError as exc:reward, details["reason"] = None, f"grading error: {exc}"except Exception as exc:reward, details["reason"] = None, f"grading error: {type(exc).__name__}: {exc}"finally:try:kill_grader()except GradingError as exc:reward, details["reason"] = None, f"grading error: {exc}"# Free the build before writing anything. A build that filled the disk would otherwise# make these writes fail, and with no space left the sandbox cannot report that the# verifier exited, so Harbor waits until its own timeout and records no verdict.shutil.rmtree(RUN_ROOT, ignore_errors=True)details["reward"] = rewarddetails["finished_at"] = time.time()(VERIFIER_DIR / "comparator.log").write_text(log)(VERIFIER_DIR / "grading.json").write_text(json.dumps(details, indent=2))print(json.dumps(details, indent=2))if reward is not None:
22 unmodified lines2324252627282922 unmodified linesreference_lean_bytes = 480875reference_requires_packages = []oracle_result = "accepted"oracle_grade_seconds = 664difficulty = "research"[agent]22 unmodified lines2324252627282922 unmodified linesreference_lean_bytes = 480875reference_requires_packages = []oracle_result = "accepted"oracle_grade_seconds = 221difficulty = "research"[agent]
34 unmodified lines3536373839405 unmodified lines464748495051188 unmodified lines2402412422432442458 unmodified lines25425525625725825926026126226333 unmodified lines2972982993003013028 unmodified lines3113123133143153168 unmodified lines32532632732832933033133233333433533633733833934034134234334434534634734834935034 unmodified linesimport sysimport tarfileimport tempfileimport timefrom pathlib import Path5 unmodified linesGRADER = "grader"SUCCESS_LINE = "Your solution is okay!"GRADE_THREADS = "2"# Lake and Comparator wording when a build process is killed for running out of memory.OOM_MARKERS = ("Lean exited with code 137", "Child exited with 137")188 unmodified linesreturn any(m in out for m in OOM_MARKERS)def run_comparator(run: Path, timeout_sec: int, threads: str = GRADE_THREADS) -> tuple[int | None, str]:env = {"PATH": f"{toolchain_bin()}:/usr/local/bin:/usr/bin:/bin",8 unmodified lines"runuser", "-u", GRADER, "--", "env", "-i", *(f"{k}={v}" for k, v in env.items()),"lake", "env", "comparator", "config.json",]code, stdout, stderr = run_with_timeout(cmd, cwd=run, timeout_sec=timeout_sec,kill_extra=lambda: subprocess.run(["pkill", "-9", "-u", GRADER], capture_output=True),)return code, stdout + "\n--- stderr ---\n" + stderr33 unmodified linesif code is None:return 0, "timed out while building or checking the submission"tail = [l for l in out.splitlines() if l.strip() and "has local changes" not in l][-25:]if out_of_memory(out):return 0, "rejected: the build was killed, most likely out of memory (8 GB) | " + " | ".join(tail)[-3000:]return 0, "rejected: " + " | ".join(tail)[-4000:]8 unmodified linestask = json.loads((TESTS / "task.json").read_text())details: dict = {"task": task["challenge"], "started_at": time.time()}reward: int | None = Nonetry:RUN_ROOT.mkdir(mode=0o711, parents=True, exist_ok=True)deadline = time.time() + int(task["grade_timeout_sec"])8 unmodified lines# Two Lean processes in parallel can exceed 8 GB on a heavy module. Retry once with one,# in a fresh directory: the first attempt's .lake was written by the submission's own# build and must not be trusted for the challenge.run = fresh_run(task)unpack_submission(run)code, out = run_comparator(run, int(deadline - time.time()), threads="1")log += "\n\n=== retried with one Lean process after running out of memory ===\n\n" + outkill_grader()details["retried_single_thread"] = True(VERIFIER_DIR / "comparator.log").write_text(log)reward, details["reason"] = classify(code, out)details["comparator_exit"] = codeexcept Rejected as exc:reward, details["reason"] = 0, f"rejected: {exc}"except GradingError as exc:reward, details["reason"] = None, f"grading error: {exc}"finally:try:kill_grader()except GradingError as exc:reward, details["reason"] = None, f"grading error: {exc}"details["reward"] = rewarddetails["finished_at"] = time.time()(VERIFIER_DIR / "grading.json").write_text(json.dumps(details, indent=2))print(json.dumps(details, indent=2))if reward is not None:34 unmodified lines353637383940415 unmodified lines47484950515253188 unmodified lines2422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892908 unmodified lines29930030130230330430530630730830931031131231331431533 unmodified lines3493503513523533543553568 unmodified lines3653663673683693703718 unmodified lines38038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141234 unmodified linesimport sysimport tarfileimport tempfileimport threadingimport timefrom pathlib import Path5 unmodified linesGRADER = "grader"SUCCESS_LINE = "Your solution is okay!"GRADE_THREADS = "2"SCRATCH_SWEEP_SEC = 15# Lake and Comparator wording when a build process is killed for running out of memory.OOM_MARKERS = ("Lean exited with code 137", "Child exited with 137")188 unmodified linesreturn any(m in out for m in OOM_MARKERS)def out_of_disk(out: str) -> bool:return "no space left on device" in out.lower()# Run as the grader user by `empty_build_scratch`. argv: the .lake/build/ir directory.EMPTY_SCRATCH = r"""import os, sysfor dirpath, _, files in os.walk(sys.argv[1]):for name in files:if not name.endswith(".setup.json"):continuebase = os.path.join(dirpath, name[:-len(".setup.json")])try:# Lake writes X.c.hash once Lean, and leanir if the module needs it, are done with X;# both read X.setup.json, so it may only be emptied after that.if os.stat(base + ".c.hash").st_mtime < os.stat(base + ".setup.json").st_mtime:continuefor path in (base + ".setup.json", base + ".c"):if os.path.getsize(path):os.truncate(path, 0)except OSError:pass"""def empty_build_scratch(run: Path, stop: threading.Event) -> None:"""Until ``stop`` is set, empty files Lake leaves in .lake/build/ir that grading never reads.For every module Lake writes a `.setup.json` (its imports with the path of every .olean theypull in, about 5.5 MB with Mathlib) and the module compiled to C. Neither is used once themodule is built, and for proofs of 1,000-2,000 modules they filled the 10 GB disk before thebuild finished. Lake keeps the recorded hashes, so emptied files do not trigger a rebuild.This runs as the grader user, so it can touch nothing the build could not."""ir = str(run / ".lake" / "build" / "ir")while not stop.wait(SCRATCH_SWEEP_SEC):try:subprocess.run(["runuser", "-u", GRADER, "--", sys.executable, "-c", EMPTY_SCRATCH, ir],capture_output=True, timeout=600)except subprocess.TimeoutExpired:passdef run_comparator(run: Path, timeout_sec: int, threads: str = GRADE_THREADS) -> tuple[int | None, str]:env = {"PATH": f"{toolchain_bin()}:/usr/local/bin:/usr/bin:/bin",8 unmodified lines"runuser", "-u", GRADER, "--", "env", "-i", *(f"{k}={v}" for k, v in env.items()),"lake", "env", "comparator", "config.json",]stop = threading.Event()sweeper = threading.Thread(target=empty_build_scratch, args=(run, stop), daemon=True)sweeper.start()try:code, stdout, stderr = run_with_timeout(cmd, cwd=run, timeout_sec=timeout_sec,kill_extra=lambda: subprocess.run(["pkill", "-9", "-u", GRADER], capture_output=True),)finally:stop.set()sweeper.join()return code, stdout + "\n--- stderr ---\n" + stderr33 unmodified linesif code is None:return 0, "timed out while building or checking the submission"tail = [l for l in out.splitlines() if l.strip() and "has local changes" not in l][-25:]if out_of_disk(out):return 0, "rejected: the build ran out of disk space (10 GB) | " + " | ".join(tail)[-3000:]if out_of_memory(out):return 0, "rejected: the build was killed, most likely out of memory (8 GB) | " + " | ".join(tail)[-3000:]return 0, "rejected: " + " | ".join(tail)[-4000:]8 unmodified linestask = json.loads((TESTS / "task.json").read_text())details: dict = {"task": task["challenge"], "started_at": time.time()}reward: int | None = Nonelog = ""try:RUN_ROOT.mkdir(mode=0o711, parents=True, exist_ok=True)deadline = time.time() + int(task["grade_timeout_sec"])8 unmodified lines# Two Lean processes in parallel can exceed 8 GB on a heavy module. Retry once with one,# in a fresh directory: the first attempt's .lake was written by the submission's own# build and must not be trusted for the challenge.shutil.rmtree(run, ignore_errors=True)run = fresh_run(task)unpack_submission(run)code, out = run_comparator(run, int(deadline - time.time()), threads="1")log += "\n\n=== retried with one Lean process after running out of memory ===\n\n" + outkill_grader()details["retried_single_thread"] = Truereward, details["reason"] = classify(code, out)details["comparator_exit"] = codeexcept Rejected as exc:reward, details["reason"] = 0, f"rejected: {exc}"except GradingError as exc:reward, details["reason"] = None, f"grading error: {exc}"except Exception as exc:reward, details["reason"] = None, f"grading error: {type(exc).__name__}: {exc}"finally:try:kill_grader()except GradingError as exc:reward, details["reason"] = None, f"grading error: {exc}"# Free the build before writing anything. A build that filled the disk would otherwise# make these writes fail, and with no space left the sandbox cannot report that the# verifier exited, so Harbor waits until its own timeout and records no verdict.shutil.rmtree(RUN_ROOT, ignore_errors=True)details["reward"] = rewarddetails["finished_at"] = time.time()(VERIFIER_DIR / "comparator.log").write_text(log)(VERIFIER_DIR / "grading.json").write_text(json.dumps(details, indent=2))print(json.dumps(details, indent=2))if reward is not None:
22 unmodified lines2324252627282922 unmodified linesreference_lean_bytes = 154244reference_requires_packages = []oracle_result = "accepted"oracle_grade_seconds = 623difficulty = "research"[agent]22 unmodified lines2324252627282922 unmodified linesreference_lean_bytes = 154244reference_requires_packages = []oracle_result = "accepted"oracle_grade_seconds = 185difficulty = "research"[agent]
34 unmodified lines3536373839405 unmodified lines464748495051188 unmodified lines2402412422432442458 unmodified lines25425525625725825926026126226333 unmodified lines2972982993003013028 unmodified lines3113123133143153168 unmodified lines32532632732832933033133233333433533633733833934034134234334434534634734834935034 unmodified linesimport sysimport tarfileimport tempfileimport timefrom pathlib import Path5 unmodified linesGRADER = "grader"SUCCESS_LINE = "Your solution is okay!"GRADE_THREADS = "2"# Lake and Comparator wording when a build process is killed for running out of memory.OOM_MARKERS = ("Lean exited with code 137", "Child exited with 137")188 unmodified linesreturn any(m in out for m in OOM_MARKERS)def run_comparator(run: Path, timeout_sec: int, threads: str = GRADE_THREADS) -> tuple[int | None, str]:env = {"PATH": f"{toolchain_bin()}:/usr/local/bin:/usr/bin:/bin",8 unmodified lines"runuser", "-u", GRADER, "--", "env", "-i", *(f"{k}={v}" for k, v in env.items()),"lake", "env", "comparator", "config.json",]code, stdout, stderr = run_with_timeout(cmd, cwd=run, timeout_sec=timeout_sec,kill_extra=lambda: subprocess.run(["pkill", "-9", "-u", GRADER], capture_output=True),)return code, stdout + "\n--- stderr ---\n" + stderr33 unmodified linesif code is None:return 0, "timed out while building or checking the submission"tail = [l for l in out.splitlines() if l.strip() and "has local changes" not in l][-25:]if out_of_memory(out):return 0, "rejected: the build was killed, most likely out of memory (8 GB) | " + " | ".join(tail)[-3000:]return 0, "rejected: " + " | ".join(tail)[-4000:]8 unmodified linestask = json.loads((TESTS / "task.json").read_text())details: dict = {"task": task["challenge"], "started_at": time.time()}reward: int | None = Nonetry:RUN_ROOT.mkdir(mode=0o711, parents=True, exist_ok=True)deadline = time.time() + int(task["grade_timeout_sec"])8 unmodified lines# Two Lean processes in parallel can exceed 8 GB on a heavy module. Retry once with one,# in a fresh directory: the first attempt's .lake was written by the submission's own# build and must not be trusted for the challenge.run = fresh_run(task)unpack_submission(run)code, out = run_comparator(run, int(deadline - time.time()), threads="1")log += "\n\n=== retried with one Lean process after running out of memory ===\n\n" + outkill_grader()details["retried_single_thread"] = True(VERIFIER_DIR / "comparator.log").write_text(log)reward, details["reason"] = classify(code, out)details["comparator_exit"] = codeexcept Rejected as exc:reward, details["reason"] = 0, f"rejected: {exc}"except GradingError as exc:reward, details["reason"] = None, f"grading error: {exc}"finally:try:kill_grader()except GradingError as exc:reward, details["reason"] = None, f"grading error: {exc}"details["reward"] = rewarddetails["finished_at"] = time.time()(VERIFIER_DIR / "grading.json").write_text(json.dumps(details, indent=2))print(json.dumps(details, indent=2))if reward is not None:34 unmodified lines353637383940415 unmodified lines47484950515253188 unmodified lines2422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892908 unmodified lines29930030130230330430530630730830931031131231331431533 unmodified lines3493503513523533543553568 unmodified lines3653663673683693703718 unmodified lines38038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141234 unmodified linesimport sysimport tarfileimport tempfileimport threadingimport timefrom pathlib import Path5 unmodified linesGRADER = "grader"SUCCESS_LINE = "Your solution is okay!"GRADE_THREADS = "2"SCRATCH_SWEEP_SEC = 15# Lake and Comparator wording when a build process is killed for running out of memory.OOM_MARKERS = ("Lean exited with code 137", "Child exited with 137")188 unmodified linesreturn any(m in out for m in OOM_MARKERS)def out_of_disk(out: str) -> bool:return "no space left on device" in out.lower()# Run as the grader user by `empty_build_scratch`. argv: the .lake/build/ir directory.EMPTY_SCRATCH = r"""import os, sysfor dirpath, _, files in os.walk(sys.argv[1]):for name in files:if not name.endswith(".setup.json"):continuebase = os.path.join(dirpath, name[:-len(".setup.json")])try:# Lake writes X.c.hash once Lean, and leanir if the module needs it, are done with X;# both read X.setup.json, so it may only be emptied after that.if os.stat(base + ".c.hash").st_mtime < os.stat(base + ".setup.json").st_mtime:continuefor path in (base + ".setup.json", base + ".c"):if os.path.getsize(path):os.truncate(path, 0)except OSError:pass"""def empty_build_scratch(run: Path, stop: threading.Event) -> None:"""Until ``stop`` is set, empty files Lake leaves in .lake/build/ir that grading never reads.For every module Lake writes a `.setup.json` (its imports with the path of every .olean theypull in, about 5.5 MB with Mathlib) and the module compiled to C. Neither is used once themodule is built, and for proofs of 1,000-2,000 modules they filled the 10 GB disk before thebuild finished. Lake keeps the recorded hashes, so emptied files do not trigger a rebuild.This runs as the grader user, so it can touch nothing the build could not."""ir = str(run / ".lake" / "build" / "ir")while not stop.wait(SCRATCH_SWEEP_SEC):try:subprocess.run(["runuser", "-u", GRADER, "--", sys.executable, "-c", EMPTY_SCRATCH, ir],capture_output=True, timeout=600)except subprocess.TimeoutExpired:passdef run_comparator(run: Path, timeout_sec: int, threads: str = GRADE_THREADS) -> tuple[int | None, str]:env = {"PATH": f"{toolchain_bin()}:/usr/local/bin:/usr/bin:/bin",8 unmodified lines"runuser", "-u", GRADER, "--", "env", "-i", *(f"{k}={v}" for k, v in env.items()),"lake", "env", "comparator", "config.json",]stop = threading.Event()sweeper = threading.Thread(target=empty_build_scratch, args=(run, stop), daemon=True)sweeper.start()try:code, stdout, stderr = run_with_timeout(cmd, cwd=run, timeout_sec=timeout_sec,kill_extra=lambda: subprocess.run(["pkill", "-9", "-u", GRADER], capture_output=True),)finally:stop.set()sweeper.join()return code, stdout + "\n--- stderr ---\n" + stderr33 unmodified linesif code is None:return 0, "timed out while building or checking the submission"tail = [l for l in out.splitlines() if l.strip() and "has local changes" not in l][-25:]if out_of_disk(out):return 0, "rejected: the build ran out of disk space (10 GB) | " + " | ".join(tail)[-3000:]if out_of_memory(out):return 0, "rejected: the build was killed, most likely out of memory (8 GB) | " + " | ".join(tail)[-3000:]return 0, "rejected: " + " | ".join(tail)[-4000:]8 unmodified linestask = json.loads((TESTS / "task.json").read_text())details: dict = {"task": task["challenge"], "started_at": time.time()}reward: int | None = Nonelog = ""try:RUN_ROOT.mkdir(mode=0o711, parents=True, exist_ok=True)deadline = time.time() + int(task["grade_timeout_sec"])8 unmodified lines# Two Lean processes in parallel can exceed 8 GB on a heavy module. Retry once with one,# in a fresh directory: the first attempt's .lake was written by the submission's own# build and must not be trusted for the challenge.shutil.rmtree(run, ignore_errors=True)run = fresh_run(task)unpack_submission(run)code, out = run_comparator(run, int(deadline - time.time()), threads="1")log += "\n\n=== retried with one Lean process after running out of memory ===\n\n" + outkill_grader()details["retried_single_thread"] = Truereward, details["reason"] = classify(code, out)details["comparator_exit"] = codeexcept Rejected as exc:reward, details["reason"] = 0, f"rejected: {exc}"except GradingError as exc:reward, details["reason"] = None, f"grading error: {exc}"except Exception as exc:reward, details["reason"] = None, f"grading error: {type(exc).__name__}: {exc}"finally:try:kill_grader()except GradingError as exc:reward, details["reason"] = None, f"grading error: {exc}"# Free the build before writing anything. A build that filled the disk would otherwise# make these writes fail, and with no space left the sandbox cannot report that the# verifier exited, so Harbor waits until its own timeout and records no verdict.shutil.rmtree(RUN_ROOT, ignore_errors=True)details["reward"] = rewarddetails["finished_at"] = time.time()(VERIFIER_DIR / "comparator.log").write_text(log)(VERIFIER_DIR / "grading.json").write_text(json.dumps(details, indent=2))print(json.dumps(details, indent=2))if reward is not None:
tasks/product-brown/tests/grade.py+67-5
tasks/projection-counterexample/task.toml+1-1
tasks/projection-counterexample/tests/grade.py+67-5
tasks/projection-moments/task.toml+1-1
tasks/projection-moments/tests/grade.py+67-5
tasks/projection-volume/task.toml+1-1
tasks/projection-volume/tests/grade.py+67-5
tasks/qac-parity/task.toml+1-1
tasks/qac-parity/tests/grade.py+67-5
tasks/quadric-bundles/task.toml+1-1
tasks/quadric-bundles/tests/grade.py+67-5
tasks/quantitative-van-der-waerden/task.toml+1-1
tasks/quantitative-van-der-waerden/tests/grade.py+67-5
tasks/quintic-lienard/task.toml+1-1
tasks/quintic-lienard/tests/grade.py+67-5
tasks/radial-density-interval/task.toml+1-1
tasks/radial-density-interval/tests/grade.py+67-5
tasks/radial-transition/task.toml+1-1
tasks/radial-transition/tests/grade.py+67-5
tasks/ramsey-five/environment/DockerfileAdded+8
tasks/ramsey-five/environment/fetch_mathlib.shAdded+19
tasks/ramsey-five/environment/lake-manifest.jsonAdded+116
tasks/ramsey-five/environment/lakefile.leanAdded+12
tasks/ramsey-five/environment/lean_setup.shAdded+126
tasks/ramsey-five/environment/pack_submission.pyAdded+70
tasks/ramsey-five/instruction.mdAdded+81
tasks/ramsey-five/solution/closure.txtAdded+482
tasks/ramsey-five/solution/reference.pyAdded+58
tasks/ramsey-five/solution/solve.shAdded+20
tasks/ramsey-five/task.tomlAdded+49
tasks/ramsey-five/tests/Challenge.leanAdded+30
tasks/ramsey-five/tests/grade.pyAdded+418
tasks/ramsey-five/tests/task.jsonAdded+15
tasks/ramsey-five/tests/test.shAdded+3
tasks/randomized-mean-payoff/task.toml+1-1
tasks/randomized-mean-payoff/tests/grade.py+67-5
tasks/rational-hitting/task.toml+1-1
tasks/rational-hitting/tests/grade.py+67-5
tasks/real-l1-renorming/task.toml+1-1
tasks/real-l1-renorming/tests/grade.py+67-5
tasks/recursive-potentials/task.toml+1-1
tasks/recursive-potentials/tests/grade.py+67-5
tasks/reflexive-fixed-points/task.toml+1-1
tasks/reflexive-fixed-points/tests/grade.py+67-5
tasks/regular-parity/task.toml+1-1
tasks/regular-parity/tests/grade.py+67-5