From ee2dcb45a617ca3961f70b2b09d6b8496ef90357 Mon Sep 17 00:00:00 2001 From: Anton Volkov Date: Sat, 28 Nov 2026 15:21:06 +0000 Subject: [PATCH 1/5] fix(dashboard): generate refuses a results directory it cannot list (#1360) `ResultsAggregator.aggregate` found the result files with three `rglob` calls, which skip a subdirectory they cannot list (mode 0o111) without an error, so `results/sub/eval_y.json` was missing from the dashboard and nothing said so. It now lists the tree once with `listed_entries`, which raises the `OSError`, and keeps the entries the three patterns matched (`Path.match`, so a Windows run still ignores case). `dashboard generate` reports the error as an input error with exit 2, naming the directory. A tree that can be listed gives the same files in the same order of concatenation. Signed-off-by: Anton Volkov --- ...128_150000_readers-unlistable-dir-three.md | 8 +++++++ dokimi/docs/benchmarking-and-comparison.md | 4 +++- dokimi/dokimi/commands/dashboard.py | 5 +++- dokimi/dokimi/dashboard/aggregator.py | 17 ++++++++++--- dokimi/tests/test_dashboard.py | 13 ++++++++++ dokimi/tests/test_dashboard_cli.py | 24 +++++++++++++++++++ 6 files changed, 66 insertions(+), 5 deletions(-) create mode 100644 dokimi/changelog.d/20261128_150000_readers-unlistable-dir-three.md diff --git a/dokimi/changelog.d/20261128_150000_readers-unlistable-dir-three.md b/dokimi/changelog.d/20261128_150000_readers-unlistable-dir-three.md new file mode 100644 index 0000000000..92f2b0bd42 --- /dev/null +++ b/dokimi/changelog.d/20261128_150000_readers-unlistable-dir-three.md @@ -0,0 +1,8 @@ + + +### Fixed + +- **`dashboard generate` refuses a results directory with a subdirectory it cannot list** — `ResultsAggregator.aggregate` found the result files with `Path.rglob`, which skips a subdirectory it cannot list (mode `0o111`) without an error, so a `eval_*.json` file below it was missing from the dashboard and nothing said so. It now lists the tree strictly and `dashboard generate` exits 2 naming the directory. A tree that can be listed gives the same files. diff --git a/dokimi/docs/benchmarking-and-comparison.md b/dokimi/docs/benchmarking-and-comparison.md index 8a76dac0c7..000b1df47e 100644 --- a/dokimi/docs/benchmarking-and-comparison.md +++ b/dokimi/docs/benchmarking-and-comparison.md @@ -220,7 +220,9 @@ python cli.py dashboard generate \ ``` The dashboard reads evaluation artifacts and writes `reports/DASHBOARD.md` and -`reports/dashboard.json`. +`reports/dashboard.json`. A directory under `--results-dir` that cannot be listed +is an input error (exit 2): the command names it and writes nothing, rather than +leaving out the result files below it. ## Standalone pipeline commands diff --git a/dokimi/dokimi/commands/dashboard.py b/dokimi/dokimi/commands/dashboard.py index 213c3c63e3..cd34773a8b 100644 --- a/dokimi/dokimi/commands/dashboard.py +++ b/dokimi/dokimi/commands/dashboard.py @@ -22,7 +22,10 @@ def cmd_dashboard_generate(args: argparse.Namespace) -> None: print(f"Scanning results in: {results_dir}") aggregator = ResultsAggregator(results_dir) - data = aggregator.aggregate() + try: + data = aggregator.aggregate() + except OSError as exc: # a directory under the results that cannot be listed + raise InputError(f"cannot list the results in {results_dir}: {exc}") from exc if not data.products: raise InputError("No evaluation results found. Run benchmark first.") diff --git a/dokimi/dokimi/dashboard/aggregator.py b/dokimi/dokimi/dashboard/aggregator.py index c4c876d51b..38f044d836 100644 --- a/dokimi/dokimi/dashboard/aggregator.py +++ b/dokimi/dokimi/dashboard/aggregator.py @@ -84,6 +84,19 @@ def sorted_by_score(self) -> List[ProductSnapshot]: ) +def _result_files(root: Path) -> List[Path]: + """The evaluation result files under ``root``: ``eval/*.json``, then ``eval_*.json``, then + ``evaluations/*.json`` at any depth, as three ``rglob`` calls list them, except that a directory + that cannot be listed raises its OSError where ``rglob`` skips it. A ``root`` that is not a directory has none.""" + if not root.is_dir(): + return [] + from dokimi.digest_entries import listed_entries + + rels = [(path, path.relative_to(root)) for path in listed_entries(root)] + return [path for pattern in ("eval/*.json", "eval_*.json", "evaluations/*.json") + for path, rel in rels if rel.match(pattern)] + + class ResultsAggregator: """Scan a results directory and build DashboardData.""" @@ -100,9 +113,7 @@ def aggregate(self) -> DashboardData: return DashboardData(generated_at=now, products=[]) # Find all eval JSON files matching orchestrator output pattern (eval/{product}.json) - eval_files = list(self.results_dir.rglob("eval/*.json")) + \ - list(self.results_dir.rglob("eval_*.json")) + \ - list(self.results_dir.rglob("evaluations/*.json")) + eval_files = _result_files(self.results_dir) # Deduplicate seen = set() diff --git a/dokimi/tests/test_dashboard.py b/dokimi/tests/test_dashboard.py index 159034a678..6e141c6e43 100644 --- a/dokimi/tests/test_dashboard.py +++ b/dokimi/tests/test_dashboard.py @@ -12,6 +12,7 @@ ProductSnapshot, QuestionResult, ResultsAggregator, + _result_files, ) from dokimi.dashboard.markdown_renderer import render_dashboard, save_dashboard_markdown, save_dashboard_json from dokimi.eval.stats import paired_summary @@ -68,6 +69,18 @@ def test_aggregator_finds_eval_files(tmp_path): assert p.avg_delta == 20.0 +def test_the_result_files_of_a_listable_tree_are_the_three_rglobs(tmp_path): + names = ["eval/a.json", "x/eval/b.json", "eval/eval_c.json", "eval_d.json", "y/eval_e.json", "evaluations/f.json", + "z/evaluations/g.json", "eval/n/h.json", "evaluations/i.txt", "other/j.json", "eval/k.json/l", "m.json"] + for name in names: + (tmp_path / name).parent.mkdir(parents=True, exist_ok=True) + (tmp_path / name).write_text("{}", encoding="utf-8") + expected = [*tmp_path.rglob("eval/*.json"), *tmp_path.rglob("eval_*.json"), *tmp_path.rglob("evaluations/*.json")] + found = _result_files(tmp_path) + assert sorted(found) == sorted(expected) and len(found) == 9 # eval/eval_c.json is in two of the three lists + assert _result_files(tmp_path / "eval" / "a.json") == [] == _result_files(tmp_path / "absent") + + # Two pairs, a question scored in the context arm only, one in the baseline arm only. _ONE_ARM_EVALS = [ _ev("q1", "Q1?", 80, 60), _ev("q2", "Q2?", 40, 40), diff --git a/dokimi/tests/test_dashboard_cli.py b/dokimi/tests/test_dashboard_cli.py index 0b6f4b7dc1..d0b104172e 100644 --- a/dokimi/tests/test_dashboard_cli.py +++ b/dokimi/tests/test_dashboard_cli.py @@ -6,6 +6,9 @@ from __future__ import annotations import json +import os + +import pytest from tests.cli_refusal import refusal @@ -47,6 +50,27 @@ def test_generate_exits_2_with_a_message_when_the_output_dir_is_a_file(tmp_path, assert "Traceback" not in err +@pytest.mark.skipif(not hasattr(os, "geteuid") or os.geteuid() == 0, reason="root lists a mode 111 directory") +def test_generate_exits_2_naming_a_results_directory_it_cannot_list(tmp_path, capsys): + results = _results(tmp_path) + (results / "sub").mkdir() + (results / "sub" / "eval_y.json").write_text((results / "oneTBB" / "eval_results.json").read_text(encoding="utf-8"), + encoding="utf-8") + (results / "sub").chmod(0o111) + args = build_parser().parse_args( + ["dashboard", "generate", "--results-dir", str(results), "--out-dir", str(tmp_path / "out")]) + try: + with refusal() as out: + args.func(args) + finally: + (results / "sub").chmod(0o755) + + assert out.code == 2, out.err + err = capsys.readouterr().err + assert err.startswith(f"Error: cannot list the results in {results}: ") and str(results / "sub") in err + assert not (tmp_path / "out").exists() + + def test_generate_writes_a_lone_surrogate_in_a_product_name_as_a_question_mark(tmp_path): results = _results(tmp_path) eval_file = results / "oneTBB" / "eval_results.json" From 00a8c0c8b6d325f640e24f44893b2be5b764d522 Mon Sep 17 00:00:00 2001 From: Anton Volkov Date: Sat, 28 Nov 2026 15:21:14 +0000 Subject: [PATCH 2/5] fix(hits): judge and sheet refuse an eval content directory they cannot list (#1364) `_Texts.task_dir` found a task with `rglob("task.json")` over `/_eval/content`, which skips a directory it cannot list (mode 0o111), so a task below it was reported as "no directory of task ... with a task.json", which blames a missing task and not a permission. It now lists the content with `listed_entries` and filters by name (`Path.match`). A directory it cannot list raises `HitsInputError` naming the directory and the OS reason, which `repo hits judge` and `repo hits sheet` already report as an input error with exit 2 before any judge call. A content directory that does not exist, and a task that is really absent, behave as before. Signed-off-by: Anton Volkov --- ...128_150000_readers-unlistable-dir-three.md | 1 + dokimi/dokimi/repos/hits_judge.py | 12 +++-- .../tests/test_repo_hits_judge_unlistable.py | 45 +++++++++++++++++++ 3 files changed, 55 insertions(+), 3 deletions(-) create mode 100644 dokimi/tests/test_repo_hits_judge_unlistable.py diff --git a/dokimi/changelog.d/20261128_150000_readers-unlistable-dir-three.md b/dokimi/changelog.d/20261128_150000_readers-unlistable-dir-three.md index 92f2b0bd42..b75485c607 100644 --- a/dokimi/changelog.d/20261128_150000_readers-unlistable-dir-three.md +++ b/dokimi/changelog.d/20261128_150000_readers-unlistable-dir-three.md @@ -6,3 +6,4 @@ SPDX-License-Identifier: Apache-2.0 ### Fixed - **`dashboard generate` refuses a results directory with a subdirectory it cannot list** — `ResultsAggregator.aggregate` found the result files with `Path.rglob`, which skips a subdirectory it cannot list (mode `0o111`) without an error, so a `eval_*.json` file below it was missing from the dashboard and nothing said so. It now lists the tree strictly and `dashboard generate` exits 2 naming the directory. A tree that can be listed gives the same files. +- **`repo hits judge` and `repo hits sheet` refuse a batch whose exported eval content has a directory they cannot list** — the task directory was found with `Path.rglob("task.json")`, which skips a directory it cannot list, so a task below it was reported as `no directory of task ... with a task.json`, blaming a missing task. Both commands now exit 2 naming the directory and the OS reason, before any judge call. A task that is really absent is reported as before. diff --git a/dokimi/dokimi/repos/hits_judge.py b/dokimi/dokimi/repos/hits_judge.py index 3e085e9ea3..240088ac20 100644 --- a/dokimi/dokimi/repos/hits_judge.py +++ b/dokimi/dokimi/repos/hits_judge.py @@ -29,6 +29,7 @@ from dokimi import caching from dokimi.artifacts import save_artifact +from dokimi.digest_entries import listed_entries from dokimi.judged import judged_reply from dokimi.llm import LLM, Ask, Unparseable from dokimi.llm_json import extract_json_object @@ -158,9 +159,14 @@ def _once(self, kind: str, cell: str, read: Callable[[], Any]) -> Any: def task_dir(self, task: str) -> Path: """The task's directory in the batch's exported eval dir, found by its name as ``repo run`` loads it.""" if self._task_dirs is None: - self._task_dirs = defaultdict(list) - for path in sorted(self.content.rglob("task.json")): - self._task_dirs[path.parent.name].append(path.parent) + found: dict[str, list[Path]] = defaultdict(list) + try: + listed = listed_entries(self.content) if self.content.is_dir() else [] + except OSError as exc: # a directory under the content that cannot be listed: not a missing task + raise HitsInputError(f"cannot list {exc.filename}: {exc.strerror}") from exc + for path in sorted(p for p in listed if p.match("task.json")): + found[path.parent.name].append(path.parent) + self._task_dirs = found dirs = self._task_dirs.get(task, []) if len(dirs) != 1: where = "no" if not dirs else f"{len(dirs)}" diff --git a/dokimi/tests/test_repo_hits_judge_unlistable.py b/dokimi/tests/test_repo_hits_judge_unlistable.py new file mode 100644 index 0000000000..c08a1fb982 --- /dev/null +++ b/dokimi/tests/test_repo_hits_judge_unlistable.py @@ -0,0 +1,45 @@ +# Copyright (C) 2026 Intel Corporation +# SPDX-License-Identifier: Apache-2.0 + +"""`repo hits judge` and `repo hits sheet` refuse a batch whose exported eval content has a directory they cannot list. + +The task directory is found by walking ``/_eval/content``: a task under a directory that cannot be listed is +not a missing task (#1364). +""" + +from __future__ import annotations + +import errno +import os +import shutil + +import pytest + +from dokimi import llm +from dokimi.repos.hits_judge import read_pairs +from tests.test_repo_hits_judge import JUDGE, _batch, _run + + +@pytest.mark.skipif(not hasattr(os, "geteuid") or os.geteuid() == 0, reason="root lists a mode 111 directory") +@pytest.mark.parametrize("argv", [["judge", "--judge", JUDGE], ["sheet", "--out", "sheet.json"]]) +def test_a_task_under_a_directory_that_cannot_be_listed_is_refused_not_reported_missing(tmp_path, capsys, argv): + batch = _batch(tmp_path) + tasks = batch / "_eval" / "content" / "tasks" + tasks.chmod(0o111) + argv = [a if a != "sheet.json" else str(tmp_path / "sheet.json") for a in argv] + try: + with llm.use_adapter(llm.FakeAdapter()) as fake: # an unscripted call fails the test + code, out, err = _run(capsys, argv[0], str(batch), *argv[1:]) + finally: + tasks.chmod(0o755) + assert (code, out, fake.requests) == (2, "", []) + assert err.startswith(f"Error: cannot list {tasks}: {os.strerror(errno.EACCES)}"), err + assert "no directory of task" not in err + assert not (tmp_path / "sheet.json").exists() + + +def test_a_batch_with_no_exported_eval_content_reports_each_task_as_missing(tmp_path): + batch = _batch(tmp_path) + shutil.rmtree(batch / "_eval") + _, pairs = read_pairs(batch) + assert pairs and all(p.problem and "no directory of task" in p.problem for p in pairs) From 4c4e865d2b4af853210382ff10146d292af06f9e Mon Sep 17 00:00:00 2001 From: Anton Volkov Date: Sat, 28 Nov 2026 15:35:45 +0000 Subject: [PATCH 3/5] fix(eval): inspect reports a directory it cannot list instead of skipping it (#1365) `_Scan.walk` listed a directory with `iterdir()` inside `except OSError: return`, so the tasks below a directory it could not list (mode 0o111) were left out of `eval inspect` and nothing said so. On that `OSError` the walk now adds the directory as an `unknown` entry with the problem `cannot read: ` and returns, as it already does for a `task.md` it cannot read. The walk keeps its own recursion, skip rules and file cap, and the other tasks of the tree are still reported; a root that cannot be listed is the same entry. `eval inspect` still exits 0 for an `unknown` entry. Signed-off-by: Anton Volkov --- ...1128_150000_readers-unlistable-dir-three.md | 1 + dokimi/docs/coding-harnesses.md | 4 +++- dokimi/dokimi/task_formats/detect.py | 3 ++- dokimi/tests/test_task_format_detect.py | 18 ++++++++++++++++++ 4 files changed, 24 insertions(+), 2 deletions(-) diff --git a/dokimi/changelog.d/20261128_150000_readers-unlistable-dir-three.md b/dokimi/changelog.d/20261128_150000_readers-unlistable-dir-three.md index b75485c607..a66d87a830 100644 --- a/dokimi/changelog.d/20261128_150000_readers-unlistable-dir-three.md +++ b/dokimi/changelog.d/20261128_150000_readers-unlistable-dir-three.md @@ -7,3 +7,4 @@ SPDX-License-Identifier: Apache-2.0 - **`dashboard generate` refuses a results directory with a subdirectory it cannot list** — `ResultsAggregator.aggregate` found the result files with `Path.rglob`, which skips a subdirectory it cannot list (mode `0o111`) without an error, so a `eval_*.json` file below it was missing from the dashboard and nothing said so. It now lists the tree strictly and `dashboard generate` exits 2 naming the directory. A tree that can be listed gives the same files. - **`repo hits judge` and `repo hits sheet` refuse a batch whose exported eval content has a directory they cannot list** — the task directory was found with `Path.rglob("task.json")`, which skips a directory it cannot list, so a task below it was reported as `no directory of task ... with a task.json`, blaming a missing task. Both commands now exit 2 naming the directory and the OS reason, before any judge call. A task that is really absent is reported as before. +- **`eval inspect` reports a directory it cannot list instead of skipping it** — the tree scan listed a directory with `iterdir()` inside `except OSError: return`, so the tasks below a directory it could not list (mode `0o111`) were left out without a word. The directory is now an `unknown` item with a `cannot read:` problem, as a `task.md` the scan cannot read already was, and the rest of the tree is still reported. The exit code is unchanged (0). A tree that can be listed gives the same items. diff --git a/dokimi/docs/coding-harnesses.md b/dokimi/docs/coding-harnesses.md index 95b782c32b..bd1c561c7c 100644 --- a/dokimi/docs/coding-harnesses.md +++ b/dokimi/docs/coding-harnesses.md @@ -138,7 +138,9 @@ kind, item count, which parts are present or missing (instruction, environment, oracle, verifier, metadata), lint problems, and what in dokimi can consume it today. It only reads: nothing is run or converted, a Python file is scanned as text and never imported, and a file that does not parse is -a problem on its report, not an error. A path no format claims is reported as +a problem on its report, not an error. A directory of a tree it cannot list +is an `unknown` item with a `cannot read:` problem, and the rest of the tree is +still reported. A path no format claims is reported as `unknown` with its files (or keys) and likely prompt and verifier files; when two formats claim a path about equally, the report lists the other as `ambiguous` with its evidence. `--json` prints and `--out` writes the report diff --git a/dokimi/dokimi/task_formats/detect.py b/dokimi/dokimi/task_formats/detect.py index 96e991b98b..ac11d4c07b 100644 --- a/dokimi/dokimi/task_formats/detect.py +++ b/dokimi/dokimi/task_formats/detect.py @@ -129,7 +129,8 @@ def walk(self, directory: Path) -> None: return try: children = sorted(directory.iterdir()) - except OSError: + except OSError as exc: # a directory that cannot be listed: shown, not skipped + self.entries.append((directory, Report(directory, FORMAT_UNKNOWN, KIND_UNKNOWN, problems=[f"cannot read: {exc}"]))) return for child in children: if self.truncated: diff --git a/dokimi/tests/test_task_format_detect.py b/dokimi/tests/test_task_format_detect.py index bcbd3da317..86ba25d251 100644 --- a/dokimi/tests/test_task_format_detect.py +++ b/dokimi/tests/test_task_format_detect.py @@ -711,3 +711,21 @@ def test_a_task_md_a_scan_cannot_read_is_reported_and_the_scan_goes_on(tmp_path) task_md.chmod(0o644) assert (found["hb"].format, found["t"].format) == ("harbor", "unknown") assert found["t"].problems == [f"cannot read: [Errno 13] Permission denied: '{task_md}'"] + + +@pytest.mark.skipif(os.name == "nt" or (hasattr(os, "geteuid") and os.geteuid() == 0), + reason="needs POSIX permissions that bind the user (root lists a mode-111 directory)") +def test_a_directory_a_scan_cannot_list_is_reported_and_the_scan_goes_on(tmp_path, capsys): + _write(tmp_path / "ok" / "task.md", "---\nname: ok\n---\nhi\n") + _write(tmp_path / "sub" / "mytask" / "task.md", "---\nname: mytask\n---\nhi\n") + (tmp_path / "sub").chmod(0o111) + try: + found = {r.path.name: r for r in inspect_path(tmp_path)} + _run(["eval", "inspect", str(tmp_path)]) + finally: + (tmp_path / "sub").chmod(0o755) + assert (found["ok"].format, found["sub"].format, found["sub"].kind) == ("task-md", "unknown", "unknown") + assert found["sub"].problems[0].startswith("cannot read: ") and str(tmp_path / "sub") in found["sub"].problems[0] + out = capsys.readouterr().out.splitlines() + assert any(line.startswith(f"{tmp_path / 'sub'}\tunknown\tunknown") for line in out) + assert any(line.startswith(" problem: cannot read: ") for line in out) From 74fe4a43c72510fd690aa6e41ac69d10c06195a8 Mon Sep 17 00:00:00 2001 From: Anton Volkov Date: Sat, 28 Nov 2026 18:49:19 +0000 Subject: [PATCH 4/5] fix(dashboard): read an eval or evaluations symlink to a directory as rglob does Settles the exai-bot thread on aggregator.py:95: the strict listing never descends into a symlink, so a results/eval that links to a directory of snapshots lost its files, where the old rglob followed it. _result_files now lists the children of an eval or evaluations symlink to a directory (iterdir, so an unlistable target still raises), and a test compares it with the rglob lists. Signed-off-by: Anton Volkov --- ...128_150000_readers-unlistable-dir-three.md | 2 +- dokimi/dokimi/dashboard/aggregator.py | 6 +++- dokimi/tests/test_dashboard.py | 29 +++++++++++++++++++ 3 files changed, 35 insertions(+), 2 deletions(-) diff --git a/dokimi/changelog.d/20261128_150000_readers-unlistable-dir-three.md b/dokimi/changelog.d/20261128_150000_readers-unlistable-dir-three.md index a66d87a830..760b31b79a 100644 --- a/dokimi/changelog.d/20261128_150000_readers-unlistable-dir-three.md +++ b/dokimi/changelog.d/20261128_150000_readers-unlistable-dir-three.md @@ -5,6 +5,6 @@ SPDX-License-Identifier: Apache-2.0 ### Fixed -- **`dashboard generate` refuses a results directory with a subdirectory it cannot list** — `ResultsAggregator.aggregate` found the result files with `Path.rglob`, which skips a subdirectory it cannot list (mode `0o111`) without an error, so a `eval_*.json` file below it was missing from the dashboard and nothing said so. It now lists the tree strictly and `dashboard generate` exits 2 naming the directory. A tree that can be listed gives the same files. +- **`dashboard generate` refuses a results directory with a subdirectory it cannot list** — `ResultsAggregator.aggregate` found the result files with `Path.rglob`, which skips a subdirectory it cannot list (mode `0o111`) without an error, so a `eval_*.json` file below it was missing from the dashboard and nothing said so. It now lists the tree strictly and `dashboard generate` exits 2 naming the directory. A tree that can be listed gives the same files, and an `eval` or `evaluations` that is a symlink to a directory is still read through. - **`repo hits judge` and `repo hits sheet` refuse a batch whose exported eval content has a directory they cannot list** — the task directory was found with `Path.rglob("task.json")`, which skips a directory it cannot list, so a task below it was reported as `no directory of task ... with a task.json`, blaming a missing task. Both commands now exit 2 naming the directory and the OS reason, before any judge call. A task that is really absent is reported as before. - **`eval inspect` reports a directory it cannot list instead of skipping it** — the tree scan listed a directory with `iterdir()` inside `except OSError: return`, so the tasks below a directory it could not list (mode `0o111`) were left out without a word. The directory is now an `unknown` item with a `cannot read:` problem, as a `task.md` the scan cannot read already was, and the rest of the tree is still reported. The exit code is unchanged (0). A tree that can be listed gives the same items. diff --git a/dokimi/dokimi/dashboard/aggregator.py b/dokimi/dokimi/dashboard/aggregator.py index 38f044d836..489827b93c 100644 --- a/dokimi/dokimi/dashboard/aggregator.py +++ b/dokimi/dokimi/dashboard/aggregator.py @@ -87,12 +87,16 @@ def sorted_by_score(self) -> List[ProductSnapshot]: def _result_files(root: Path) -> List[Path]: """The evaluation result files under ``root``: ``eval/*.json``, then ``eval_*.json``, then ``evaluations/*.json`` at any depth, as three ``rglob`` calls list them, except that a directory - that cannot be listed raises its OSError where ``rglob`` skips it. A ``root`` that is not a directory has none.""" + that cannot be listed raises its OSError where ``rglob`` skips it. An ``eval`` or ``evaluations`` that is a symlink + to a directory is read through, as ``rglob`` names it. A ``root`` that is not a directory has none.""" if not root.is_dir(): return [] from dokimi.digest_entries import listed_entries rels = [(path, path.relative_to(root)) for path in listed_entries(root)] + for path, rel in list(rels): + if rel.name in ("eval", "evaluations") and path.is_symlink() and path.is_dir(): + rels.extend((child, rel / child.name) for child in path.iterdir()) return [path for pattern in ("eval/*.json", "eval_*.json", "evaluations/*.json") for path, rel in rels if rel.match(pattern)] diff --git a/dokimi/tests/test_dashboard.py b/dokimi/tests/test_dashboard.py index 6e141c6e43..1252ad055a 100644 --- a/dokimi/tests/test_dashboard.py +++ b/dokimi/tests/test_dashboard.py @@ -3,6 +3,7 @@ """Tests for dashboard aggregator and markdown renderer.""" import json +import os from pathlib import Path import pytest @@ -81,6 +82,34 @@ def test_the_result_files_of_a_listable_tree_are_the_three_rglobs(tmp_path): assert _result_files(tmp_path / "eval" / "a.json") == [] == _result_files(tmp_path / "absent") +def test_an_eval_or_evaluations_symlink_to_a_directory_is_read_through_as_rglob_names_it(tmp_path): + snapshots = tmp_path / "snapshots" + snapshots.mkdir() + (snapshots / "a.json").write_text("{}", encoding="utf-8") + results = tmp_path / "results" + (results / "x").mkdir(parents=True) + (results / "eval").symlink_to(snapshots, target_is_directory=True) + (results / "x" / "evaluations").symlink_to(snapshots, target_is_directory=True) + (results / "y").mkdir() + (results / "y" / "eval").symlink_to(tmp_path / "absent") # a dangling link has no files and is no error + expected = [*results.rglob("eval/*.json"), *results.rglob("evaluations/*.json")] + assert len(expected) == 2 + assert sorted(_result_files(results)) == sorted(expected) + + +@pytest.mark.skipif(not hasattr(os, "geteuid") or os.geteuid() == 0, reason="root lists a mode 111 directory") +def test_a_symlink_not_named_eval_is_not_listed(tmp_path): + closed = tmp_path / "closed" + closed.mkdir() + (tmp_path / "results").mkdir() + (tmp_path / "results" / "other").symlink_to(closed, target_is_directory=True) + closed.chmod(0o111) + try: + assert _result_files(tmp_path / "results") == [] + finally: + closed.chmod(0o755) + + # Two pairs, a question scored in the context arm only, one in the baseline arm only. _ONE_ARM_EVALS = [ _ev("q1", "Q1?", 80, 60), _ev("q2", "Q2?", 40, 40), From 7868a1d51d43f91b585fcbc0e59134ee6a7957e3 Mon Sep 17 00:00:00 2001 From: Anton Volkov Date: Sat, 28 Nov 2026 19:50:33 +0000 Subject: [PATCH 5/5] fix(dashboard): match an eval or evaluations symlink without regard to case where paths do Settles the review point that the symlink check compared the name as lowercase text, while rglob and the later Path.match are case-insensitive on Windows, so results/EVAL or results/Evaluations as a directory symlink was not read through there. The check now uses Path.match, as the patterns after it do. A test feeds Windows paths to _result_files and fails with the old comparison. Signed-off-by: Anton Volkov --- dokimi/dokimi/dashboard/aggregator.py | 2 +- dokimi/tests/test_dashboard.py | 28 ++++++++++++++++++++++++++- 2 files changed, 28 insertions(+), 2 deletions(-) diff --git a/dokimi/dokimi/dashboard/aggregator.py b/dokimi/dokimi/dashboard/aggregator.py index 489827b93c..d35afb6e67 100644 --- a/dokimi/dokimi/dashboard/aggregator.py +++ b/dokimi/dokimi/dashboard/aggregator.py @@ -95,7 +95,7 @@ def _result_files(root: Path) -> List[Path]: rels = [(path, path.relative_to(root)) for path in listed_entries(root)] for path, rel in list(rels): - if rel.name in ("eval", "evaluations") and path.is_symlink() and path.is_dir(): + if (rel.match("eval") or rel.match("evaluations")) and path.is_symlink() and path.is_dir(): rels.extend((child, rel / child.name) for child in path.iterdir()) return [path for pattern in ("eval/*.json", "eval_*.json", "evaluations/*.json") for path, rel in rels if rel.match(pattern)] diff --git a/dokimi/tests/test_dashboard.py b/dokimi/tests/test_dashboard.py index 1252ad055a..82962d31d1 100644 --- a/dokimi/tests/test_dashboard.py +++ b/dokimi/tests/test_dashboard.py @@ -4,7 +4,7 @@ """Tests for dashboard aggregator and markdown renderer.""" import json import os -from pathlib import Path +from pathlib import Path, PureWindowsPath import pytest @@ -97,6 +97,32 @@ def test_an_eval_or_evaluations_symlink_to_a_directory_is_read_through_as_rglob_ assert sorted(_result_files(results)) == sorted(expected) +class _WindowsEntry: + """A directory entry whose relative path is a Windows path, which matches names without regard to case.""" + + def __init__(self, rel, children=(), link=False): + self.name, self._rel, self._children, self._link = rel.rpartition("\\")[2], rel, children, link + + def relative_to(self, root): + return PureWindowsPath(self._rel) + + def is_symlink(self): + return self._link + + def is_dir(self): + return self._link + + def iterdir(self): + return iter(self._children) + + +def test_an_eval_symlink_is_read_through_whatever_its_case_where_names_match_without_case(tmp_path, monkeypatch): + snapshot = _WindowsEntry("a.json") + links = [_WindowsEntry("EVAL", [snapshot], link=True), _WindowsEntry("x\\Evaluations", [snapshot], link=True)] + monkeypatch.setattr("dokimi.digest_entries.listed_entries", lambda root: links) + assert _result_files(tmp_path) == [snapshot, snapshot] + + @pytest.mark.skipif(not hasattr(os, "geteuid") or os.geteuid() == 0, reason="root lists a mode 111 directory") def test_a_symlink_not_named_eval_is_not_listed(tmp_path): closed = tmp_path / "closed"