Repository navigation
Description
Summary
Nested guidance discovery counts unusable links as instruction files. The resulting inventory overstates the guidance available from both a working tree and a committed revision.
Scenarios (1)
1. repo inspect counts a nested sub/AGENTS.md symlink loop as an instruction file and raises no finding
Input: a git repo with a regular root AGENTS.md and sub/AGENTS.md as a symlink to itself (ln -s AGENTS.md sub/AGENTS.md inside sub/), or as a two-link loop (sub/AGENTS.md -> sub/B.md -> sub/AGENTS.md). Same result for the plain directory and for <dir>@HEAD.
repo inspect prints 2 instruction files (1 root), 0 check surfaces, risk low and exits 0. The findings are only checks.test.missing and checks.lint.missing; nothing names sub/AGENTS.md. repo scan on the same fixture says guidance file not scanned: sub/AGENTS.md: too many levels of symbolic links and marks the scan incomplete.
Expected: the looping file is not counted, or a finding or note names sub/AGENTS.md and the loop, as repo scan does.
cd sub && ln -s AGENTS.md AGENTS.md # in a repo with a root AGENTS.md
python cli.py repo inspect <repo>
Tests are attached as tests/test_inspect_nested_guidance_loop.py (self-link, tree and @HEAD) and tests/test_inspect_nested_two_link_loop.py (two-link loop). Both fail on 9bf1ce70.
tests/test_inspect_nested_guidance_loop.py
import subprocess
import sys
from pathlib import Path
ROOT = Path(__file__).resolve().parents[1]
def _build(tmp_path: Path) -> Path:
repo = tmp_path / "fixture"
(repo / "sub").mkdir(parents=True)
ident = ["-c", "user.email=a@b", "-c", "user.name=n"]
subprocess.run(["git", "init", "-q", "."], cwd=repo, check=True)
(repo / "AGENTS.md").write_text("# rules\n", encoding="utf-8")
(repo / "sub" / "AGENTS.md").symlink_to("AGENTS.md")
subprocess.run(["git", "add", "-A"], cwd=repo, check=True)
subprocess.run(["git", *ident, "commit", "-qm", "x"], cwd=repo, check=True)
return repo
def _check(source: str) -> None:
run = subprocess.run(
[sys.executable, "cli.py", "repo", "inspect", source],
capture_output=True, text=True, cwd=ROOT,
)
out = run.stdout + run.stderr
assert "Traceback" not in out, out
counted_loop_file = "2 instruction files" in out
mentions = any(w in out for w in ("sub/AGENTS.md", "symbolic", "too many levels"))
assert not counted_loop_file or mentions, out
def test_inspect_working_tree(tmp_path: Path) -> None:
_check(str(_build(tmp_path)))
def test_inspect_at_head(tmp_path: Path) -> None:
_check(str(_build(tmp_path)) + "@HEAD")tests/test_inspect_nested_two_link_loop.py
import subprocess
import sys
from pathlib import Path
ROOT = Path(__file__).resolve().parents[1]
def _build(repo: Path) -> None:
(repo / "sub").mkdir(parents=True)
(repo / "AGENTS.md").write_text("# rules\n", encoding="utf-8")
(repo / "sub" / "AGENTS.md").symlink_to("B.md")
(repo / "sub" / "B.md").symlink_to("AGENTS.md")
git = ["git", "-c", "user.email=a@b", "-c", "user.name=n"]
subprocess.run(["git", "init", "-q", "."], cwd=repo, check=True)
subprocess.run(["git", "add", "-A"], cwd=repo, check=True)
subprocess.run([*git, "commit", "-qm", "x"], cwd=repo, check=True)
def test_inspect_nested_two_link_loop(tmp_path: Path) -> None:
repo = tmp_path / "twoloop"
repo.mkdir()
_build(repo)
for source in (str(repo), str(repo) + "@HEAD"):
run = subprocess.run([sys.executable, str(ROOT / "cli.py"), "repo", "inspect", source],
capture_output=True, text=True, cwd=ROOT)
out = run.stdout + run.stderr
assert "Traceback" not in out, out
assert run.returncode == 0, out
assert "2 instruction files" not in out or "sub/" in out, outRelated
- repo inspect misreports unreadable sources and unusable files #1271
- repo scan mishandles guidance links with invalid or non-UTF-8 targets #1272: same command
dokimi repo inspectanddokimi repo scan - Eval check misreports guidance matches and patch paths under submodules #1304: same command
dokimi repo scan - repo reach misidentifies and selects non-regular guidance files #1273: same command
dokimi repo inspect - repo budget crashes when a tracked file is under an unsearchable directory #959: same command
dokimi repo inspect(closed by fix(repo): repo budget skips a tracked file under an unsearchable directory (#959) #1028)
Activity