Repository navigation
fix(repos): a task, batch or authoring directory that cannot be listed is an error, not an empty result - #1639
antonwolfy wants to merge 2 commits into
Conversation
…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>
There was a problem hiding this comment.
🟡 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
|
Codecov Report✅ All modified and coverable lines are covered by tests. 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
🚀 New features to boost your workflow:
|
|
✅ OpenCodeReview: Review complete: 0 finding(s) across 15 selected item(s). CI at Review details
|
Mutation of changed linesAt 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
Not the whole picture:
Warning only: a missed break does not fail the job. Updated on every push; the full report is in the ci run summary. |
… 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
left a comment
There was a problem hiding this comment.
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")} |
There was a problem hiding this comment.
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") |
There was a problem hiding this comment.
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
left a comment
There was a problem hiding this comment.
@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 rundoes 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 reachesload_tasksfrom a working-tree directory, or takerepo runout of the tasks-directory sentence indokimi/changelog.d/20261204_100000_repo-eval-readers-unlistable.mdand indokimi/docs/repo-evaluation-contract.md.
Optional, non-blocking (1)
dokimi/dokimi/repos/runner.py:736: A new batch directory at mode0o111with no_evalyet:repo runprints[Errno 13] Permission denied: '<batch>/_eval', not thecannot list <batch>message that the changelog fragment and the contract give forrepo 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.
| except OSError as exc: | ||
| raise CellFileError(f"cannot list {batch_dir}: {exc.strerror or exc}") from exc |
There was a problem hiding this comment.
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.
| 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.

Summary
Four readers of the repository evaluation expand a
*/<file>pattern under a directory the user names withPath.glob, which gives nothing for a directory a non-root process cannot list (mode0o111). Onmaineach of them reads such a directory as empty:0o111onmainworkspace.load_taskstasks/t1/task.json['t1']PrepError: no task under ev/tasks (no */task.json): nothing to check or run(blames a missing task)report.load_cellscell1/meta.json(a started cell)([], ['cell1'])([], []): the missing cell is not reportedreport.load_unsupportedcell2/unsupported.json[]batch_ledger.check_batch_executionscell1/result.jsonof executionother, run{'mine'}ExecutionMismatchNone: the cells of another execution are not seen, so the batch is resumed or reported with them mixed inreplay.authoring.tasks_by_prauthoring_pr5/task.json{5: 'authoring_pr5'}{}: the pull request is authored againThe fix is the one #1510 took for the sibling globs of #1389: list the one directory and turn its
OSErrorinto 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'soracleand thedokimi:commandgrader's artifact glob).Closes #1507
Changes
digest_entries.children_holding(directory, pattern, filename):directory/<child>/filenamefor each child thatpatternmatches and that holds the file, sorted, asglob(pattern + "/" + filename)gives them (aresult.jsonthat 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 itsOSError. It is built onchildren_matching, so a missing directory has no entries.pack_filesis not used because it keeps regular files only, which would turn aresult.jsonthat is a directory from acannot readerror into a silently missing cell.children_holdingprobes each hit withlstat(), notstat(), so a dangling or loopingcell1/result.jsonlink is a hit, as it was forglob, and reaches the reader, which refuses it withcannot read <file>(exit 2) instead of the cell being left out. A child that is itself a link loop is no hit, as forglob.tests/test_children_holding.pycovers each skip and raise branch.repos/report.pyload_cellslists themeta.jsoncells before it checks_eval/plan.json: on Python before 3.14Path.is_fileraises a barePermissionErrorfor a batch directory that cannot be searched, so the listing, which names the directory, now comes first on every Python. Therepo report,repo compareandrepo hits sheetbatch_dirrows oftests/data/cli_fault_allowlist.txtare deleted, andALLOWLIST_ROWS(48 to 45) andALLOWLIST_DIGESTare updated, astest_the_allowlist_only_shrinksasks.repos/workspace.pyload_tasks: lists the tasks with it; anOSErroris aPrepErrorcannot list <tasks dir>: Permission denied. A missingtasksdirectory keepsno task under ....repos/report.pyload_cellsandload_unsupported: themeta.json,result.jsonandunsupported.jsonlookups go through_cell_files, which raisesCellFileErrorcannot list <batch dir>: Permission denied.repo reportandrepo compareturn that into exit 2 as they do for any unreadable cell file.repos/batch_ledger.pycheck_batch_executionsonly: anOSErroris anExecutionMismatchcannot list <batch dir>: Permission denied; its cells cannot be checked against this run's execution, sorepo runrefuses before any cell runs.repos/replay/authoring.pytasks_by_pr(and sotask_of_pr): anOSErroris aPrepErrorcannot list <out dir>: Permission denied.eval tasks generate --from prsand--from historyreport it as they report their other unusable inputs (✗ <reason>, exit 1).docs/repo-evaluation-contract.md: the batch-directory and tasks-directory refusals in therepo runcell paragraph, and the--out-dirrefusal in the list ofeval tasks generateexit-1 causes.tests/unlistable_dir.py: theunlistable(path)context manager (mode0o111, skipped when the process can still list it), used by the four new tests.Risk
A task, batch or
--out-dirdirectory at mode0o111that was read as empty is now refused with a message that names it. A cell directory inside a batch that cannot be searched (mode0o000) used to be skipped byglob; 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 rewritesload_tasksinrepos/workspace.py, the function whosetasks_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 (itsOSErroras thePrepErrorabove).repo runandeval tasks generaterefuse with exit 1, as they do for their other unusable inputs;repo reportandrepo compareexit 2.Testing
On a Linux review host, at
4223ccfa(onmain01ff2d6):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 istest / Run tests: 35416 passed, 1 failed, 28 skipped. The one failure,tests/test_import_architecture.py::test_package_uses_the_new_modules(dokimi.runs.resolveimportsdokimi.utils), fails the same way onmain, in a file this PR does not touch. Changed-line coverage and the changed-line mutation step pass.0o111): wrong result onmain, the error above here.main's code:test_repo_task_required_keys.py(1 failed:cannot list <tasks dir>: Permission deniedis not inno 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).OSErrorswallowed, in each of the four readers,globback in each of the four readers, a missing directory raising, a child without the file raising,repo reportexiting 1,eval tasks generateexiting 2, the authoring index taking every directory instead ofauthoring_*).tests/test_children_holding.py(4 tests of the function, 2 ofrepo reporton a dangling and a loopingresult.json, 1 of a batch directory at mode0o000): all fail on the previous head,stat()back inchildren_holdingfails 2 of them (a dangling or looping link is dropped), and the old order inload_cellsfails the mode0o000one (PermissionErrorfromis_fileon Python 3.13).tests/test_cli_fault_contract.pypasses with the three rows deleted.fix/unlistable-root-readers,fix/unlistable-skill-docs,fix/rmtree-unlistableonmain4024f25:pytest -n auto35800 passed, 28 skipped,mypyclean,ruff checkclean.Open questions
None.
Revert
A plain revert restores the old behaviour (an unlistable directory read as empty). Nothing is stored.
Checklist
pytestpasses [tests added; the full run has one failure,test_package_uses_the_new_modules, which also fails onmain]ruff,mypy, and schema checks passAGENTS.mdraise/exit and test names the doc, contract or issue it traces to.github/.licenserc.yaml)