Skip to content

fix(repos): a task, batch or authoring directory that cannot be listed is an error, not an empty result - #1639

Open
antonwolfy wants to merge 2 commits into
intel:mainfrom
antonwolfy:fix/unlistable-repo-eval-readers
Open

antonwolfy wants to merge 2 commits into
intel:mainfrom
antonwolfy:fix/unlistable-repo-eval-readers

Conversation

@antonwolfy

@antonwolfy antonwolfy commented Dec 5, 2026 •

Copy link
Copy Markdown
Contributor

Summary

Four readers of the repository evaluation expand a */<file> pattern under a directory the user names with Path.glob, which gives nothing for a directory a non-root process cannot list (mode 0o111). On main each of them reads such a directory as empty:

Reader Input Listable Directory at 0o111 on main
workspace.load_tasks tasks/t1/task.json ['t1'] PrepError: no task under ev/tasks (no */task.json): nothing to check or run (blames a missing task)
report.load_cells cell1/meta.json (a started cell) ([], ['cell1']) ([], []): the missing cell is not reported
report.load_unsupported cell2/unsupported.json one unsupported cell []
batch_ledger.check_batch_executions cell1/result.json of execution other, run {'mine'} raises ExecutionMismatch returns None: the cells of another execution are not seen, so the batch is resumed or reported with them mixed in
replay.authoring.tasks_by_pr authoring_pr5/task.json {5: 'authoring_pr5'} {}: the pull request is authored again

The fix is the one #1510 took for the sibling globs of #1389: list the one directory and turn its OSError into the command's own error naming the directory. A missing directory keeps its meaning (no entries).

#1628 tracks three more readers with the same cause that the issue does not name (_mutant_patches, the mutation grader's oracle and the dokimi:command grader's artifact glob).

Closes #1507

Changes

  • digest_entries.children_holding(directory, pattern, filename): directory/<child>/filename for each child that pattern matches and that holds the file, sorted, as glob(pattern + "/" + filename) gives them (a result.json that is a directory is still a hit, as before), except that a directory that cannot be listed, or a child that cannot be searched, raises its OSError. It is built on children_matching, so a missing directory has no entries. pack_files is not used because it keeps regular files only, which would turn a result.json that is a directory from a cannot read error into a silently missing cell.
  • children_holding probes each hit with lstat(), not stat(), so a dangling or looping cell1/result.json link is a hit, as it was for glob, and reaches the reader, which refuses it with cannot read <file> (exit 2) instead of the cell being left out. A child that is itself a link loop is no hit, as for glob. tests/test_children_holding.py covers each skip and raise branch.
  • repos/report.py load_cells lists the meta.json cells before it checks _eval/plan.json: on Python before 3.14 Path.is_file raises a bare PermissionError for a batch directory that cannot be searched, so the listing, which names the directory, now comes first on every Python. The repo report, repo compare and repo hits sheet batch_dir rows of tests/data/cli_fault_allowlist.txt are deleted, and ALLOWLIST_ROWS (48 to 45) and ALLOWLIST_DIGEST are updated, as test_the_allowlist_only_shrinks asks.
  • repos/workspace.py load_tasks: lists the tasks with it; an OSError is a PrepError cannot list <tasks dir>: Permission denied. A missing tasks directory keeps no task under ....
  • repos/report.py load_cells and load_unsupported: the meta.json, result.json and unsupported.json lookups go through _cell_files, which raises CellFileError cannot list <batch dir>: Permission denied. repo report and repo compare turn that into exit 2 as they do for any unreadable cell file.
  • repos/batch_ledger.py check_batch_executions only: an OSError is an ExecutionMismatch cannot list <batch dir>: Permission denied; its cells cannot be checked against this run's execution, so repo run refuses before any cell runs.
  • repos/replay/authoring.py tasks_by_pr (and so task_of_pr): an OSError is a PrepError cannot list <out dir>: Permission denied. eval tasks generate --from prs and --from history report it as they report their other unusable inputs (✗ <reason>, exit 1).
  • docs/repo-evaluation-contract.md: the batch-directory and tasks-directory refusals in the repo run cell paragraph, and the --out-dir refusal in the list of eval tasks generate exit-1 causes.
  • tests/unlistable_dir.py: the unlistable(path) context manager (mode 0o111, skipped when the process can still list it), used by the four new tests.
  • Changelog fragment (Fixed).

Risk

A task, batch or --out-dir directory at mode 0o111 that was read as empty is now refused with a message that names it. A cell directory inside a batch that cannot be searched (mode 0o000) used to be skipped by glob; it now refuses the whole batch with the same message, since its cells cannot be told from none. Listable and missing directories behave as before. Open PR #1610 rewrites load_tasks in repos/workspace.py, the function whose tasks_dir.glob("*/task.json") line this PR changes, so the two conflict textually there; whichever merges second rebases, and this PR's part is that one listing (its OSError as the PrepError above). repo run and eval tasks generate refuse with exit 1, as they do for their other unusable inputs; repo report and repo compare exit 2.

Testing

On a Linux review host, at 4223ccfa (on main 01ff2d6):

  • make ci-local: 37 passed, 1 failed, 16 skipped (the skips are steps that need GitHub, a runner, micromamba, semgrep or the other jobs' outputs). The failing step is test / Run tests: 35416 passed, 1 failed, 28 skipped. The one failure, tests/test_import_architecture.py::test_package_uses_the_new_modules (dokimi.runs.resolve imports dokimi.utils), fails the same way on main, in a file this PR does not touch. Changed-line coverage and the changed-line mutation step pass.
  • The repro of each reader of the table above (a directory at 0o111): wrong result on main, the error above here.
  • The four new tests fail on main's code: test_repo_task_required_keys.py (1 failed: cannot list <tasks dir>: Permission denied is not in no task under ev/tasks ...), test_repo_overlay.py (1 failed: DID NOT RAISE ExecutionMismatch), test_repo_report_unreadable_cell.py (1 failed: DID NOT RAISE CellFileError), test_repo_authoring.py (1 failed: DID NOT RAISE PrepError).
  • Mutants: 17 breaks of the changed code, one per copy, each fails the test that pins it (a message without the directory, and an OSError swallowed, in each of the four readers, glob back in each of the four readers, a missing directory raising, a child without the file raising, repo report exiting 1, eval tasks generate exiting 2, the authoring index taking every directory instead of authoring_*).
  • tests/test_children_holding.py (4 tests of the function, 2 of repo report on a dangling and a looping result.json, 1 of a batch directory at mode 0o000): all fail on the previous head, stat() back in children_holding fails 2 of them (a dangling or looping link is dropped), and the old order in load_cells fails the mode 0o000 one (PermissionError from is_file on Python 3.13). tests/test_cli_fault_contract.py passes with the three rows deleted.
  • Merged together with fix/unlistable-root-readers, fix/unlistable-skill-docs, fix/rmtree-unlistable on main 4024f25: pytest -n auto 35800 passed, 28 skipped, mypy clean, ruff check clean.
  • Not run: the other Python versions (3.11, 3.12, 3.14) and CI's merge commit.

Open questions

None.

Revert

A plain revert restores the old behaviour (an unlistable directory read as empty). Nothing is stored.

Checklist

  • Tests added/updated and pytest passes [tests added; the full run has one failure, test_package_uses_the_new_modules, which also fails on main]
  • ruff, mypy, and schema checks pass
  • Docs updated (or N/A) — see the docs-drift checklist in CONTRIBUTING.md
  • Self-reviewed per "Before opening a PR" in AGENTS.md
  • Each new raise/exit and test names the doc, contract or issue it traces to
  • No ad-hoc run artifacts committed
  • New files carry the SPDX license header (or are exempt in .github/.licenserc.yaml)

…d is an error, not an empty result (intel#1507)

Four readers expanded a `*/<file>` pattern under a directory with `Path.glob`, which gives nothing for a directory at mode 0o111: `load_tasks` blamed a missing task (`no task under eval/tasks`), `load_cells` and `load_unsupported` reported no missing or unsupported cell, `check_batch_executions` returned without seeing the cells of another execution, and `tasks_by_pr` returned `{}` so a pull request was authored again.

Each now lists the one directory with the new `digest_entries.children_holding` (`children_matching` plus a stat of the file in each child) and turns the `OSError` into the command's own error naming the directory: `PrepError` for `load_tasks` and `tasks_by_pr`, `CellFileError` for the report (`repo report` and `repo compare` exit 2), `ExecutionMismatch` for the batch check. A missing directory still has no entries, and a `result.json` or `task.json` that is a directory is still found, as `glob` found it.

Signed-off-by: Anton Volkov <antonwolfy@gmail.com>
@antonwolfy
antonwolfy requested a review from a team as a code owner December 5, 2026 00:20
@antonwolfy antonwolfy self-assigned this Dec 5, 2026
Copilot AI balanced review requested due to automatic review settings December 5, 2026 00:20

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🟡 Changes recommended

Using stat() silently omits dangling or self-looping symlink entries, bypassing expected CellFileError handling; use lstat() and add regression coverage.

1 open issue
What changed in this PR

1 new finding.

This PR makes repository-evaluation readers report inaccessible directories instead of treating them as empty, addressing #1507.

Changes:

  • Adds a shared directory-listing helper and reader-specific errors.
  • Adds permission-error regression tests while preserving missing-directory behavior.
  • Documents the refusals and command exit codes.
File Description
dokimi/​tests/​unlistable_dir.py Shared permission-test helper.
dokimi/​tests/​test_repo_task_required_keys.py Tests inaccessible task directories.
dokimi/​tests/​test_repo_report_unreadable_cell.py Tests batch listing errors and exit 2.
dokimi/​tests/​test_repo_overlay.py Tests execution-check listing refusal.
dokimi/​tests/​test_repo_authoring.py Tests authoring-directory refusal.
dokimi/​dokimi/​repos/​workspace.py Converts task listing failures to input errors.
dokimi/​dokimi/​repos/​report.py Centralizes strict cell-file discovery.
dokimi/​dokimi/​repos/​replay/​authoring.py Rejects inaccessible authoring directories.
dokimi/​dokimi/​repos/​batch_ledger.py Refuses unverifiable batch executions.
dokimi/​dokimi/​digest_entries.py Adds shared child-entry discovery.
dokimi/​docs/​repo-evaluation-contract.md Documents directory refusals.
dokimi/​changelog.d/​20261204_100000_repo-eval-readers-unlistable.md Records reader fixes and exit behavior.

Review effort: Balanced

Comment thread dokimi/dokimi/digest_entries.py Resolved
@codecov-commenter

codecov-commenter commented Dec 5, 2026 •

Copy link
Copy Markdown

⚠️ Please install the 'codecov app svg image' to ensure uploads and comments are reliably processed by Codecov.

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 96.49%. Comparing base (01ff2d6) to head (4223ccf).
⚠️ Report is 19 commits behind head on main.
❗ Your organization needs to install the Codecov GitHub app to enable full functionality.

Additional details and impacted files
@@            Coverage Diff             @@
##             main    #1639      +/-   ##
==========================================
+ Coverage   96.46%   96.49%   +0.02%     
==========================================
  Files         561      569       +8     
  Lines       74345    75283     +938     
  Branches    12840    12982     +142     
==========================================
+ Hits        71716    72642     +926     
- Misses       1609     1613       +4     
- Partials     1020     1028       +8     
Files with missing lines Coverage Δ
dokimi/dokimi/digest_entries.py 85.91% <100.00%> (+3.15%) ⬆️
dokimi/dokimi/repos/batch_ledger.py 100.00% <100.00%> (ø)
dokimi/dokimi/repos/replay/authoring.py 97.41% <100.00%> (+0.10%) ⬆️
dokimi/dokimi/repos/report.py 97.91% <100.00%> (+0.03%) ⬆️
dokimi/dokimi/repos/workspace.py 94.08% <100.00%> (+0.04%) ⬆️

... and 77 files with indirect coverage changes

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

@exai-bot

exai-bot commented Dec 5, 2026 •

Copy link
Copy Markdown

✅ OpenCodeReview: Review complete: 0 finding(s) across 15 selected item(s).

CI at 4223ccf: 26 passing, 4 skipped.

Review details
  • Commit reviewed: 4223ccf against merge base 01ff2d6
  • Coverage: 15 files in 3 groups
  • Engine: OpenCodeReview v1.13.5-exai.4.8f73eada, us.openai.gpt-6.1-sol
  • Usage: 340k tokens (207k from cache), 52s
  • Tool calls: 47 (30 file_read, 6 code_search, 3 ci_status, 3 file_read_diff, 3 local_check_results, 2 ci_log_search)
  • Repository readers and regression tests for unlistable directories: 8 files
  • Digest child handling and unlistable-directory test support: 3 files
  • Evaluation contract, changelog, and CLI fault expectations: 4 files

@github-actions

github-actions Bot commented Dec 5, 2026 •

Copy link
Copy Markdown

Mutation of changed lines

⚠️ Tests miss 1 of 25 small breaks of the lines this PR changes, and the check was not complete

At 4223ccf: 21 caught · 1 missed · 3 inconclusive

Each row is a small deliberate break (a mutant) of a line this PR changes that every test reaching that line still passes. Add a test that fails on it or, if it cannot change behaviour, put # mutation-ok[<operator>]: <reason> at the end of the line or alone on the line above.

Where Operator Change no test notices Tests reaching the line
dokimi/dokimi/repos/replay/authoring.py:111 drop-clause exc.strerror or exc → (exc.strerror) 1

Not the whole picture:

  • 7 candidate test files were not run
  • 1 changed line was not mutated

Warning only: a missed break does not fail the job. Updated on every push; the full report is in the ci run summary.

Comment thread dokimi/dokimi/repos/report.py Resolved
… report names an unlistable batch first

Settles the review of intel#1639: children_holding probed each hit with stat(), which follows the final link, so a dangling or looping cell1/result.json was left out where the glob it replaced returned it and the reader raised CellFileError. It now uses lstat(), so such a link reaches the reader; tests cover a dangling and a looping leaf link and each skip and raise branch of the function.

Also settles the failed fault-contract check: load_cells asked plan.json is_file() before listing, which raises PermissionError on Python before 3.14 for a batch directory that cannot be searched, so the `repo report | batch_dir | unreadable` row only became stale on 3.14. The listing now comes first and names the directory on every Python; the three rows it makes stale (repo report, repo compare and repo hits sheet, batch directory unreadable) are deleted and ALLOWLIST_ROWS and ALLOWLIST_DIGEST are updated.

Signed-off-by: Anton Volkov <antonwolfy@gmail.com>

@napetrov napetrov left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Change class: CONTRACT (head 4223ccf)

  • Contract: changed. errors dokimi/dokimi/repos/batch_ledger.py:171; errors dokimi/dokimi/repos/replay/authoring.py:111
  • Responsibility: none
  • Dependency: none
  • Review depth: check the changed surface: callers, docs, tests pin new behaviour
  • Coverage gaps: none

1 blocking, 1 minor.

Repo evaluation readers now refuse unlistable directories. The shared listing helper probes children outside explicit task selection and cells scheduled for replacement.

The paired merge with #1610 conflicts in workspace.load_tasks. Apply both the task containment and permission semantics when resolving it.

CI on head 4223ccf: 0 failing Actions jobs; merge base 01ff2d6 is behind base tip 5225c2a.

Compared the change and input edges against the merge base and checked existing threads and GitHub Actions. Runtime checks used focused Linux tests and local fixtures. Focused tests on the head: head 201 passed in 29.06s.

tasks_dir = content_dir / PurePosixPath(tasks).relative_to(eval_dir)
found = {p.parent.name: p for p in sorted(tasks_dir.glob("*/task.json"))}
try:
found = {p.parent.name: p for p in children_holding(tasks_dir, "*", "task.json")}

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

blocking: An inaccessible sibling blocks an explicitly selected task

dokimi/dokimi/repos/workspace.py:269 children_holding stats every task candidate before ids is applied.

How to check: With one valid selected task and a sibling directory at mode 000, base loads the selected task and head refuses the tasks directory with PrepError.
Expected: Preserve explicit selection by checking only the selected task entries after listing the tasks root.

found: set[str] = set()
for path in sorted(batch_dir.glob("*/result.json")):
try:
results = children_holding(batch_dir, "*", "result.json")

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

nit: A cell due for replacement can fail the identity check

dokimi/dokimi/repos/batch_ledger.py:169 The replacing filter runs after the new helper has probed all result paths.

How to check: With a mode-000 cell in replacing, base permits the identity check and head raises ExecutionMismatch before it checks replacing.
Expected: Apply the replacing filter before probing a cell’s result.json, so the identity check covers cells the run will keep.

@vchamarthi vchamarthi left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@antonwolfy, could you fix the problem I found (in the line comments), fix what napetrov's thread on dokimi/dokimi/repos/workspace.py:269 and napetrov's thread on dokimi/dokimi/repos/batch_ledger.py:169 still point out and answer my question below? Then push and I'll take another look.

My question before I approve:

  • repo run does not read a tasks directory from the working tree: it exports the eval directory from the git tree (dokimi/dokimi/commands/repo_run.py:92). Name the input that reaches load_tasks from a working-tree directory, or take repo run out of the tasks-directory sentence in dokimi/changelog.d/20261204_100000_repo-eval-readers-unlistable.md and in dokimi/docs/repo-evaluation-contract.md.
Optional, non-blocking (1)
  • dokimi/dokimi/repos/runner.py:736: A new batch directory at mode 0o111 with no _eval yet: repo run prints [Errno 13] Permission denied: '<batch>/_eval', not the cannot list <batch> message that the changelog fragment and the contract give for repo run (main has it too).

What I checked on 4223ccf:

  • When I changed the code on purpose, the tests still passed for 1 of 6 changes, and no test pins this one down yet (non-blocking): dokimi/dokimi/digest_entries.py:54 (the handled error is raised again).
  • The 360 changed tests pass, and fail on main as expected.
  • The full test suite passes with main merged in (43,209 tests), apart from failures main has too.
  • It merges cleanly onto main.

Comment on lines +210 to +211
except OSError as exc:
raise CellFileError(f"cannot list {batch_dir}: {exc.strerror or exc}") from exc

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Must fix (blocking): A cell at mode 0o000 in a batch that lists fine makes load_cells report cannot list <batch dir>, which names the wrong directory.
Input: a batch directory that lists fine, with cell1/meta.json and cell2 at mode 0o000.
Got: The latest commit raises cannot list <batch>: Permission denied, because _cell_files gives the batch directory's name to the OSError of cell2.

Also at: dokimi/dokimi/repos/batch_ledger.py:171, dokimi/dokimi/repos/workspace.py:271, dokimi/dokimi/repos/replay/authoring.py:111.

I tested this suggestion: it fixes the problem, and the tests still pass.

Suggested change
except OSError as exc:
raise CellFileError(f"cannot list {batch_dir}: {exc.strerror or exc}") from exc
except OSError as exc:
named = batch_dir if Path(exc.filename) == batch_dir else Path(exc.filename).parent
raise CellFileError(f"cannot list {named}: {exc.strerror or exc}") from exc
Details

Main returns ([], ["cell1"]). I'd expect the message to name the entry that could not be searched, and to keep cannot list <batch dir> for a batch that cannot be listed.

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

repo eval readers: a task, batch or authoring directory that cannot be listed reads as empty

6 participants