Repository navigation
Description
eval check mishandles setup_patch symlink boundaries
Summary
The schema-only check handles setup_patch symlinks inconsistently with repository path validation and task execution. Users can get a traceback during validation or a passing check for a task that repo run later refuses.
Scenarios (2)
1. eval check ends in a SourceArgumentError traceback, exit 5, for a setup_patch link that leaves the repo and re-enters it
Input: a working tree whose task has "setup_patch": "p.patch", where dev/evals/tasks/t1/p.patch is a symlink to ../../../../../<repo name>/dev/evals/real.patch. It goes up out of the repository and comes back to a real file inside it.
python cli.py eval check --schema-only --manifest dev/evals/repo-eval.yaml <repo> ends in dokimi.repos.source_errors.SourceArgumentError: path escapes the repository: dev/evals/tasks/t1/p.patch with exit 5. The call is tree.is_file(...) at repos/manifest.py:564, which reaches _walk_links in repos/links.py:97 and is not caught. <repo>@HEAD prints the tick line and exits 0 for the same commit.
Expected: a message naming the escaping patch link and exit 2, the same in both views, with no traceback.
python cli.py eval check --schema-only --manifest dev/evals/repo-eval.yaml <repo>
The attached test tests/test_patch_link_reenters_repo.py fails on 2568a420. The same code path serves review_patch.
tests/test_patch_link_reenters_repo.py
import os
import subprocess
import sys
from pathlib import Path
ROOT = Path(__file__).resolve().parents[1]
MANIFEST = """schema: repo_manifest.v1
id: toy
source: {url: "https://example.invalid/toy"}
eval_dir: dev/evals
guidance: {globs: ["**/AGENTS.md"]}
image: {dockerfile: dev/evals/Dockerfile, network: none}
entry_points: {grade: "true {run_dir}", oracle: "true {run_dir}"}
tasks: dev/evals/tasks
"""
def _git(repo: Path, *args: str) -> str:
return subprocess.run(
["git", "-c", "user.name=a", "-c", "user.email=a@b", *args],
cwd=repo, check=True, capture_output=True, text=True,
).stdout.strip()
def test_patch_link_leaving_and_reentering_repo_is_not_a_traceback(tmp_path: Path) -> None:
repo = tmp_path / "toy"
(repo / "dev/evals/tasks/t1").mkdir(parents=True)
_git(repo, "init", "-q")
(repo / "AGENTS.md").write_text("# g\n", encoding="utf-8")
(repo / "dev/evals/Dockerfile").write_text("FROM scratch\n", encoding="utf-8")
_git(repo, "add", "-A")
_git(repo, "commit", "-qm", "base")
base = _git(repo, "rev-parse", "HEAD")
(repo / "dev/evals/repo-eval.yaml").write_text(MANIFEST, encoding="utf-8")
(repo / "dev/evals/tasks/t1/task.json").write_text(
'{"id":"t1","family":"fix","base":"%s","grader":"tests","prompt":"p",'
'"setup_patch":"p.patch"}\n' % base,
encoding="utf-8",
)
(repo / "dev/evals/real.patch").write_text("--- a\n+++ b\n", encoding="utf-8")
os.symlink("../../../../../toy/dev/evals/real.patch", repo / "dev/evals/tasks/t1/p.patch")
_git(repo, "add", "-A")
_git(repo, "commit", "-qm", "x")
run = subprocess.run(
[sys.executable, "cli.py", "eval", "check", "--schema-only",
"--manifest", "dev/evals/repo-eval.yaml", str(repo)],
capture_output=True, text=True, cwd=ROOT,
)
out = run.stdout + run.stderr
assert "Traceback" not in out, out
assert run.returncode in (0, 2), outdev/evals/tasks/t1/p.patch
--- a
+++ b2. eval check accepts a setup_patch link to a file outside the task directory that repo run refuses
Input: a task with "setup_patch": "p.patch", where dev/evals/tasks/t1/p.patch is a committed symlink to ../../shared/p.patch. The target is a real file in the repository, outside the task directory.
python cli.py eval check --schema-only --manifest dev/evals/repo-eval.yaml <repo> prints the tick line for toy and exits 0, for the directory and for <repo>@HEAD. _task_file in repos/workspace.py:727 raises PrepError: task t1: p.patch is not a file in the task directory for the same link, because it requires the resolved target to sit under the task directory.
Expected: validation refuses the patch link with a message naming it and exit 2, so a passing check means the run can open the patch.
python cli.py eval check --schema-only --manifest dev/evals/repo-eval.yaml <repo>
The attached test tests/test_patch_link_outside_task_dir.py fails on 2568a420.
tests/test_patch_link_outside_task_dir.py
import subprocess
import sys
from pathlib import Path
ROOT = Path(__file__).resolve().parents[1]
MANIFEST = """schema: repo_manifest.v1
id: toy
source: {url: "https://example.invalid/toy"}
eval_dir: dev/evals
guidance: {globs: ["**/AGENTS.md"]}
image: {dockerfile: dev/evals/Dockerfile, network: none}
entry_points: {grade: "true {run_dir}", oracle: "true {run_dir}"}
tasks: dev/evals/tasks
"""
def _git(repo: Path, *args: str) -> str:
return subprocess.run(
["git", "-c", "user.name=a", "-c", "user.email=a@b", *args],
cwd=repo, capture_output=True, text=True, check=True,
).stdout.strip()
def test_patch_link_outside_task_dir_is_refused(tmp_path: Path) -> None:
repo = tmp_path / "repo"
task = repo / "dev/evals/tasks/t1"
task.mkdir(parents=True)
_git(repo, "init", "-q")
(repo / "AGENTS.md").write_text("# g\n")
(repo / "dev/evals/Dockerfile").write_text("FROM scratch\n")
_git(repo, "add", "-A")
_git(repo, "commit", "-qm", "base")
base = _git(repo, "rev-parse", "HEAD")
(repo / "dev/evals/repo-eval.yaml").write_text(MANIFEST)
(task / "task.json").write_text(
'{"id":"t1","family":"fix","base":"%s","grader":"tests","prompt":"p",'
'"setup_patch":"p.patch"}' % base
)
(repo / "dev/evals/shared").mkdir()
(repo / "dev/evals/shared/p.patch").write_text("--- a\n+++ b\n")
(task / "p.patch").symlink_to("../../shared/p.patch")
_git(repo, "add", "-A")
_git(repo, "commit", "-qm", "x")
run = subprocess.run(
[sys.executable, str(ROOT / "cli.py"), "eval", "check", "--schema-only",
"--manifest", "dev/evals/repo-eval.yaml", str(repo)],
capture_output=True, text=True, cwd=ROOT,
)
out = run.stdout + run.stderr
assert run.returncode in (1, 2), out
assert "patch" in out, outRelated
- eval check crashes or hangs on invalid task, suite and manifest inputs #975
- repo: report unsearchable directories in eval check #1293: same code
repos/manifest.py - repo validate handles escaping eval_dir links differently by source #1279: same code
repos/manifest.py - repo validate exits 5 with a traceback when task.json links to itself or to a directory, in a tree and at <dir>@rev #910: same code
repos/manifest.py(closed by fix(repo): repo validate reports a task.json link that loops or is a directory (#910) #952)
Activity
vchamarthi commentedon Nov 26, 2026
Related: #1084 and #1139 (the working-tree escape check that now raises here), #582, #1279 (the same uncaught
SourceArgumentErrorinmanifest.py), and #1277 (scenario 2: validate passes while run refuses). #975 isn't related: its fix, #1044, didn't touch the patch checks.