Repository navigation
Description
Input: a repository whose .agent-eval/tasks/t1/task.json is a symlink to itself (ln -s task.json), or to a directory inside the repository (ln -s ../../../sub). Both shapes fail the same way as a working tree and as <dir>@HEAD with the link committed.
On 1d900496, python cli.py repo validate <dir> ends in OSError: [Errno 40] Too many levels of symbolic links for the loop and IsADirectoryError: [Errno 21] Is a directory for the directory link, both raised from tree.read_text(where) at repos/manifest.py:527. With <dir>@HEAD the loop gives SourceArgumentError: too many levels of symbolic links: .agent-eval/tasks/t1/task.json and the directory link gives SourceArgumentError: .agent-eval/tasks/t1/task.json links to a directory: sub, raised from repos/source.py:306 and repos/source.py:317. All four exit 5.
Expected: an error: line naming task.json and exit 1, as for a task.json that is not valid JSON. _check_task catches only json.JSONDecodeError and UnicodeDecodeError around that read. One added except (OSError, SourceError) clause there turns all four into cannot read task.json: ... with exit 1.
cd .agent-eval/tasks/t1 && ln -s task.json task.json && cd - && python cli.py repo validate .
The link needs a valid .agent-eval/repo-eval.yaml beside it; commit the link and use .@HEAD for the rev case. A parametrized test over loop and directory link, tree and @HEAD, is attached as tests/test_repo_validate_task_links.py. All four cases fail on 1d900496.
tests/test_repo_validate_task_links.py
import os
import subprocess
import sys
from pathlib import Path
import pytest
ROOT = Path(__file__).resolve().parents[1]
MANIFEST = """schema: repo_manifest.v1
id: toy
source: {url: "https://example.invalid/toy"}
eval_dir: .agent-eval
image: {dockerfile: .agent-eval/Dockerfile}
entry_points: {grade: "true", oracle: "true"}
tasks: .agent-eval/tasks
guidance: {globs: ["**/AGENTS.md"]}
"""
def _git(repo: Path, *args: str) -> None:
subprocess.run(["git", "-c", "user.email=a@b.c", "-c", "user.name=n", *args],
cwd=repo, check=True, capture_output=True)
@pytest.mark.parametrize("rev", [False, True])
@pytest.mark.parametrize("shape", ["loop", "dirlink"])
def test_task_json_link_is_reported_not_crashed(tmp_path: Path, shape: str, rev: bool) -> None:
repo = tmp_path / "repo"
task_dir = repo / ".agent-eval" / "tasks" / "t1"
task_dir.mkdir(parents=True)
(repo / "sub").mkdir()
(repo / ".agent-eval" / "repo-eval.yaml").write_text(MANIFEST, encoding="utf-8")
(repo / ".agent-eval" / "Dockerfile").write_text("FROM scratch\n", encoding="utf-8")
(repo / "README.md").write_text("x\n", encoding="utf-8")
(repo / "sub" / "f.txt").write_text("y\n", encoding="utf-8")
_git(repo, "init", "-q", ".")
_git(repo, "add", "-A")
_git(repo, "commit", "-qm", "one")
os.symlink("task.json" if shape == "loop" else "../../../sub", task_dir / "task.json")
_git(repo, "add", "-A")
_git(repo, "commit", "-qm", "two")
src = str(repo) + ("@HEAD" if rev else "")
run = subprocess.run([sys.executable, "cli.py", "repo", "validate", src],
capture_output=True, text=True, cwd=ROOT)
out = run.stderr + run.stdout
assert run.returncode == 1, out
assert "Traceback" not in out, out
assert "task.json" in out, out
Activity
docs(repo): say how repo validate reports an unreadable task.json (in…
fix(repo): repo validate reports a task.json link past an absent dire…
test(repo): pin that an unopenable task.json is reported, not raised (i…
fix(repo): repo validate reports a task.json link that loops or is a …