369 validated tasks; grader keeps large builds within the 10 GB disk (part 4)
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 (33)
- tasks/clique-free-log/tests/grade.py+67-5
- tasks/coboundary-expanders/task.toml+1-1
- tasks/coboundary-expanders/tests/grade.py+67-5
- tasks/common-bases-fpras/task.toml+1-1
- tasks/common-bases-fpras/tests/grade.py+67-5
- tasks/commuting-derivations/task.toml+1-1
- tasks/commuting-derivations/tests/grade.py+67-5
- tasks/compact-banach/task.toml+1-1
- tasks/compact-banach/tests/grade.py+67-5
- tasks/complete-crossing/task.toml+1-1
- tasks/complete-crossing/tests/grade.py+67-5
- tasks/complete-crouzeix/task.toml+1-1
- tasks/complete-crouzeix/tests/grade.py+67-5
- tasks/complex-cancellation/task.toml+1-1
- tasks/complex-cancellation/tests/grade.py+67-5
- tasks/conductivity/task.toml+1-1
- tasks/conductivity/tests/grade.py+67-5
- tasks/conjugate-points/task.toml+1-1
- tasks/conjugate-points/tests/grade.py+67-5
- tasks/contingency-tables/task.toml+1-1
- tasks/contingency-tables/tests/grade.py+67-5
- tasks/continuous-circle-weight/task.toml+1-1
- tasks/continuous-circle-weight/tests/grade.py+67-5
- tasks/continuum-transition/task.toml+1-1
- tasks/continuum-transition/tests/grade.py+67-5
- tasks/coordinate-sweeps/task.toml+1-1
- tasks/coordinate-sweeps/tests/grade.py+67-5
- tasks/coordinate-trace/task.toml+1-1
- tasks/coordinate-trace/tests/grade.py+67-5
- tasks/cotype/task.toml+1-1
- tasks/cotype/tests/grade.py+67-5
- tasks/coulomb-counterexample/task.toml+1-1
- tasks/coulomb-counterexample/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 = 1459141reference_requires_packages = []oracle_result = "accepted"oracle_grade_seconds = 1082difficulty = "research"[agent]22 unmodified lines2324252627282922 unmodified linesreference_lean_bytes = 1459141reference_requires_packages = []oracle_result = "accepted"oracle_grade_seconds = 437difficulty = "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 = 1336009reference_requires_packages = []oracle_result = "accepted"oracle_grade_seconds = 950difficulty = "research"[agent]22 unmodified lines2324252627282922 unmodified linesreference_lean_bytes = 1336009reference_requires_packages = []oracle_result = "accepted"oracle_grade_seconds = 347difficulty = "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 = 135211reference_requires_packages = []oracle_result = "accepted"oracle_grade_seconds = 426difficulty = "research"[agent]22 unmodified lines2324252627282922 unmodified linesreference_lean_bytes = 135211reference_requires_packages = []oracle_result = "accepted"oracle_grade_seconds = 81difficulty = "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 = 207061reference_requires_packages = []oracle_result = "accepted"oracle_grade_seconds = 1439difficulty = "research"[agent]22 unmodified lines2324252627282922 unmodified linesreference_lean_bytes = 207061reference_requires_packages = []oracle_result = "accepted"oracle_grade_seconds = 303difficulty = "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 = 1464297reference_requires_packages = []oracle_result = "accepted"oracle_grade_seconds = 800difficulty = "research"[agent]22 unmodified lines2324252627282922 unmodified linesreference_lean_bytes = 1464297reference_requires_packages = []oracle_result = "accepted"oracle_grade_seconds = 344difficulty = "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 = 652138reference_requires_packages = []oracle_result = "accepted"oracle_grade_seconds = 1153difficulty = "research"[agent]22 unmodified lines2324252627282922 unmodified linesreference_lean_bytes = 652138reference_requires_packages = []oracle_result = "accepted"oracle_grade_seconds = 546difficulty = "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 = 242585reference_requires_packages = []oracle_result = "accepted"oracle_grade_seconds = 971difficulty = "research"[agent]22 unmodified lines2324252627282922 unmodified linesreference_lean_bytes = 242585reference_requires_packages = []oracle_result = "accepted"oracle_grade_seconds = 355difficulty = "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 = 3618863reference_requires_packages = []oracle_result = "accepted"oracle_grade_seconds = 1871difficulty = "research"[agent]22 unmodified lines2324252627282922 unmodified linesreference_lean_bytes = 3618863reference_requires_packages = []oracle_result = "accepted"oracle_grade_seconds = 1793difficulty = "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 = 1279256reference_requires_packages = []oracle_result = "accepted"oracle_grade_seconds = 1609difficulty = "research"[agent]22 unmodified lines2324252627282922 unmodified linesreference_lean_bytes = 1279256reference_requires_packages = []oracle_result = "accepted"oracle_grade_seconds = 595difficulty = "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 = 9098638reference_requires_packages = []oracle_result = "accepted"oracle_grade_seconds = 3243difficulty = "research"[agent]22 unmodified lines2324252627282922 unmodified linesreference_lean_bytes = 9098638reference_requires_packages = []oracle_result = "accepted"oracle_grade_seconds = 3262difficulty = "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 = 908147reference_requires_packages = []oracle_result = "accepted"oracle_grade_seconds = 1217difficulty = "research"[agent]22 unmodified lines2324252627282922 unmodified linesreference_lean_bytes = 908147reference_requires_packages = []oracle_result = "accepted"oracle_grade_seconds = 530difficulty = "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 = 697604reference_requires_packages = []oracle_result = "accepted"oracle_grade_seconds = 1607difficulty = "research"[agent]22 unmodified lines2324252627282922 unmodified linesreference_lean_bytes = 697604reference_requires_packages = []oracle_result = "accepted"oracle_grade_seconds = 942difficulty = "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 = 1085561reference_requires_packages = []oracle_result = "accepted"oracle_grade_seconds = 1051difficulty = "research"[agent]22 unmodified lines2324252627282922 unmodified linesreference_lean_bytes = 1085561reference_requires_packages = []oracle_result = "accepted"oracle_grade_seconds = 383difficulty = "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 = 974102reference_requires_packages = []oracle_result = "accepted"oracle_grade_seconds = 1254difficulty = "research"[agent]22 unmodified lines2324252627282922 unmodified linesreference_lean_bytes = 974102reference_requires_packages = []oracle_result = "accepted"oracle_grade_seconds = 427difficulty = "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 = 503929reference_requires_packages = []oracle_result = "accepted"oracle_grade_seconds = 1088difficulty = "research"[agent]22 unmodified lines2324252627282922 unmodified linesreference_lean_bytes = 503929reference_requires_packages = []oracle_result = "accepted"oracle_grade_seconds = 444difficulty = "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 = 467629reference_requires_packages = []oracle_result = "accepted"oracle_grade_seconds = 891difficulty = "research"[agent]22 unmodified lines2324252627282922 unmodified linesreference_lean_bytes = 467629reference_requires_packages = []oracle_result = "accepted"oracle_grade_seconds = 349difficulty = "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/clique-free-log/tests/grade.py+67-5
tasks/coboundary-expanders/task.toml+1-1
tasks/coboundary-expanders/tests/grade.py+67-5
tasks/common-bases-fpras/task.toml+1-1
tasks/common-bases-fpras/tests/grade.py+67-5
tasks/commuting-derivations/task.toml+1-1
tasks/commuting-derivations/tests/grade.py+67-5
tasks/compact-banach/task.toml+1-1
tasks/compact-banach/tests/grade.py+67-5
tasks/complete-crossing/task.toml+1-1
tasks/complete-crossing/tests/grade.py+67-5
tasks/complete-crouzeix/task.toml+1-1
tasks/complete-crouzeix/tests/grade.py+67-5
tasks/complex-cancellation/task.toml+1-1
tasks/complex-cancellation/tests/grade.py+67-5
tasks/conductivity/task.toml+1-1
tasks/conductivity/tests/grade.py+67-5
tasks/conjugate-points/task.toml+1-1
tasks/conjugate-points/tests/grade.py+67-5
tasks/contingency-tables/task.toml+1-1
tasks/contingency-tables/tests/grade.py+67-5
tasks/continuous-circle-weight/task.toml+1-1
tasks/continuous-circle-weight/tests/grade.py+67-5
tasks/continuum-transition/task.toml+1-1
tasks/continuum-transition/tests/grade.py+67-5
tasks/coordinate-sweeps/task.toml+1-1
tasks/coordinate-sweeps/tests/grade.py+67-5
tasks/coordinate-trace/task.toml+1-1
tasks/coordinate-trace/tests/grade.py+67-5
tasks/cotype/task.toml+1-1
tasks/cotype/tests/grade.py+67-5
tasks/coulomb-counterexample/task.toml+1-1
tasks/coulomb-counterexample/tests/grade.py+67-5