Repository navigation
fix(readers): memory lint, trace subagents and the BenchFlow, Harbor and command cells name a directory they cannot list - #1635
Conversation
…ntel#1506) read_claude_memory found the topic files with root.glob("*.md"), which gives nothing for a directory without list permission (mode 111). The store then linted as one with no topic files, while the MEMORY.md index was still read, so memory lint reported its entries as dead links instead of saying the directory cannot be listed. The topic files are now listed with digest_entries.children_matching, and its OSError becomes MemoryStoreError("<root>: cannot list the memory directory: <reason>"), worded like the archive's error. memory lint turns it into its usual input error (exit 2). A missing or non-directory root keeps its "not a directory" error. Signed-off-by: Anton Volkov <antonwolfy@gmail.com>
…error, not no subagents (intel#1508) subagent_files found the transcripts of a session with (dir / "subagents").glob("*.jsonl"), which gives nothing for a directory without list permission (mode 111). read_session_tree then folded in no subagent, and their tool calls were missing from the session the trace commands read, with no word about it. The directory is now listed with digest_entries.children_matching, and its OSError raises SessionError("cannot read <dir>: <reason>"), as read_session does for the log itself. A missing subagents directory still means no subagents. read_session_tree keeps the parent's events and records the error on the session, as it does for a subagent transcript it cannot read, so trace prefilter warns and reports the status as partial. The folded-transcript pass of trace prefilter skips such a session and leaves the report to read_session_tree, so no traceback reaches the user. Signed-off-by: Anton Volkov <antonwolfy@gmail.com>
…cell's error, not a run with no rollout (intel#1509) rollout_dirs, rollout_results and read_harbor_job found the rollouts with jobs_dir.glob("*/*__*"), glob("*/*/result.json") and glob("*/result.json"), which give nothing for a jobs directory or a job directory without list permission (mode 111). The cell was reported without a result, and read_harbor_job blamed a missing result ("harbor: no Harbor result.json (exit 0)"). Each level is now listed with digest_entries.children_matching, in the new harnesses/rollouts.py (rollout_dirs and rollout_results are still importable from benchflow). A missing jobs directory still has no rollout. An unlistable one raises its OSError, which names the directory; the BenchFlow cell reports it as "benchflow: cannot list <dir>: <reason>" and read_harbor_job as "harbor: cannot list <dir>: <reason>", with no reward. The cleanup after a BenchFlow timeout goes on without removing containers, since the cell's error names the directory. The same cause in the command harness: _find_reward and _has_reward_file looked for reward.txt and reward.json with output_dir.rglob, which skips a directory it cannot list. A reward file in one was missed and the exit code was read as the reward (a reward.txt holding 0 under an unlistable directory scored 1.0 for exit 0). The files are now found with listed_entries, and the cell gets "solver_error: no verdict: cannot list <dir>: <reason>". Signed-off-by: Anton Volkov <antonwolfy@gmail.com>
There was a problem hiding this comment.
🟡 Changes recommended
Windows reward-file matching can incorrectly pass failed commands, and BenchFlow timeouts hide directory-listing failures that explain why containers may remain.
2 open issues
What changed in this PR
3 findings.
This PR makes dokimi’s memory, trace, and harness readers report directory-listing failures instead of silently treating unreadable directories as empty.
Changes:
- Replace silent glob searches with strict directory listings and reader-specific errors.
- Preserve parent-session events when subagent discovery fails.
- Add regression tests, document error behavior, and lower growth baselines after extraction.
| File | Description |
|---|---|
| dokimi/tests/test_session_subagents_unlistable.py | Tests subagent errors and retained parent events. |
| dokimi/tests/test_rollout_readers_unlistable.py | Tests rollout and reward listing failures. |
| dokimi/tests/test_memory_store_unlistable.py | Tests memory errors and exit code 2. |
| dokimi/scripts/growth_baseline.json | Lowers size and complexity baselines. |
| dokimi/dokimi/memory/store.py | Reports unlistable memory directories. |
| dokimi/dokimi/harnesses/rollouts.py | Centralizes strict rollout discovery. |
| dokimi/dokimi/harnesses/command.py | Reports Harbor and reward discovery failures. |
| dokimi/dokimi/harnesses/benchflow.py | Uses shared rollout discovery and error handling. |
| dokimi/dokimi/context/session_log.py | Records subagent listing errors. |
| dokimi/dokimi/commands/context.py | Handles errors during transcript deduplication. |
| dokimi/docs/session-prefilter.md | Documents partial-session behavior. |
| dokimi/docs/memory.md | Documents directory-listing input errors. |
| dokimi/changelog.d/20261204_120000_unlistable-root-readers.md | Summarizes reader fixes. |
Review effort: Balanced
|
✅ OpenCodeReview: Review complete: 0 finding(s) across 13 selected item(s). CI at Test notes (3)
Review details
|
|
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## main #1635 +/- ##
==========================================
- Coverage 96.46% 96.44% -0.02%
==========================================
Files 561 586 +25
Lines 74345 76670 +2325
Branches 12840 13176 +336
==========================================
+ Hits 71716 73944 +2228
- Misses 1609 1672 +63
- Partials 1020 1054 +34
🚀 New features to boost your workflow:
|
napetrov
left a comment
There was a problem hiding this comment.
Change class: CONTRACT (head 19fb83f)
- Contract: changed. errors dokimi/dokimi/context/session_log.py:97; dispatch dokimi/dokimi/harnesses/command.py:260
- Responsibility: none
- Dependency: none
- Review depth: check the changed surface: callers, docs, tests pin new behaviour
- Coverage gaps: none
Open issues to resolve on 19fb83fd.
- Windows reward lookup now compares names case-sensitively. An uppercase reward file can be missed and success inferred from the exit code. Earlier finding
Reviewed the diff, edge cases and prior threads. Focused tests: 21 passed on head. Windows behavior was reviewed statically. The full local suite was outside coverage.
…chFlow error and match reward files by the platform's name rules A BenchFlow timeout set metrics.error to the outer-budget message and dropped the jobs directory the rollout lookup could not list, so nothing explained why containers may remain; the listing error now follows the timeout error after "; ". The command cell's reward lookup compared file names case-sensitively, so REWARD.TXT on Windows, which rglob found, was missed and the exit code read as the reward. Names are now compared with os.path.normcase and the reward file is parsed by its canonical name, so REWARD.JSON reaches the JSON parser. Signed-off-by: Anton Volkov <antonwolfy@gmail.com>
@napetrov (#1635 (review)): The one open item is the Windows reward-name thread (4806852723), fixed in 032345a; its reply has the detail. |
… guard, so an unsearchable ancestor is no verdict Review points 4807801100 and 4807801107. `_reward_files` guarded the listing with `Path.is_dir()`, which answers False for a path it cannot stat because of permissions on Python 3.14; the cell then found no reward file and read exit 0 as reward 1.0. It now lists the directory and treats only a missing or non-directory output dir as having no reward files, so any other OSError reaches `_command_verdict` as the no-verdict diagnostic. The reward-name test now sets the POSIX name comparison before its first assertions, so it also holds where the platform's own comparison is `ntpath.normcase`. Signed-off-by: Anton Volkov <antonwolfy@gmail.com>
napetrov
left a comment
There was a problem hiding this comment.
Change class: CONTRACT (head d306e4c)
- Contract: changed. errors dokimi/dokimi/context/session_log.py:97; dispatch dokimi/dokimi/harnesses/command.py:261
- Responsibility: none
- Dependency: none
- Review depth: check the changed surface: callers, docs, tests pin new behaviour
- Coverage gaps: none
1 blocking, 0 minor.
Memory, trace, BenchFlow, Harbor and command reward readers now surface directory listing failures. A disappearing directory can still mask an explicit failing reward.
CI on head d306e4c: 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 25 passed in 1.57s.
vchamarthi
left a comment
There was a problem hiding this comment.
@antonwolfy, could you fix the problem I found and the 3 small things I've marked fix before merge (in the line comments) and fix what napetrov's thread on dokimi/dokimi/harnesses/command.py:498 still points out? Then push and I'll take another look.
Optional, non-blocking (1)
dokimi/dokimi/harnesses/rollouts.py:39:rollout_resultssorts by thestatof eachresult.jsonit finds, and a dangling link raisesFileNotFoundError(main has it too).
What I checked on d306e4c:
- When I changed the code on purpose, the tests still passed for 5 of 12 changes, and no test pins these down yet (non-blocking):
dokimi/dokimi/harnesses/command.py:257(the handled error is raised again),dokimi/dokimi/harnesses/rollouts.py:24(the handled error is raised again) anddokimi/dokimi/harnesses/rollouts.py:53(the handled error is raised again). - The 25 changed tests pass, and fail on main as expected.
- The full test suite passes with main merged in (36,527 tests), apart from failures main has too.
- It merges cleanly onto main.
A command cell's output walk treated any missing path as an absent output dir, so a subdirectory that disappeared mid-walk dropped a reward already found and the exit code became the reward. Only the output dir itself being absent is empty now; a vanished child raises and the cell reports `cannot list <dir>`. A reward file that is listed but cannot be read now reports `cannot read <file>: <reason>`, not `cannot list`. After a BenchFlow timeout, a job directory that cannot be listed no longer ends the whole container cleanup: the rollouts under the other job directories are still removed. The subagents fixture holds a non-transcript file, so a `*` pattern is caught, and the changelog states what the old memory lint did with an unlistable directory (an empty store with no findings). Signed-off-by: Anton Volkov <antonwolfy@gmail.com>
@napetrov (#1635 (review)): The blocking point is the thread on |
@vchamarthi (#1635 (review)): The three fix-before-merge threads ( |
|
Ready for another look at Declined, with the evidence in the reply:
Follow-up issues opened:
|

Summary
Three readers found their files with
Path.glob, which gives nothing for a directory without list permission (mode0o111, as a non-root user), so the directory read as empty. This is the cause of #1168 and #1389; #1389's fix (digest_entries.children_matching, which raises theOSErrorwhereglobgives nothing) is applied to the three that were left. Onmain, with the same input at mode0o111against a listable one:mainMEMORY.mdanda.mdread_claude_memory(...).entriesis[](listable:['a.md']);memory lintprints0 entries (0 archived), index 2 lines / 27 bytes: 0 fail, 0 warn, 0 noteand exits 0s.jsonlbesides/subagents/a.jsonlsubagent_files(Path('s.jsonl'))is[](listable:['a.jsonl']), soread_session_treefolds in no subagent and no word is saidj1/t__abc/result.json, jobs dir orj1unlistablerollout_dirsandrollout_resultsgive[](listable:['t__abc'],['result.json']);read_harbor_job(jobs, 0)givesharbor: no Harbor result.json (exit 0); a BenchFlow cell givesno BenchFlow result.json (exit 0)The issue text says
memory lintreports the index entries as dead links; at this head it does not (a stat of a known name works, so the entries resolve) and it reports a clean store, which is the wrong answer in the same way.The same search turned up one more site with this cause in
harnesses/command.py, a file this PR already changes:_find_rewardand_has_reward_filelook forreward.txtandreward.jsonunder a command cell's output dir withrglob. Without/sub/deep/reward.txtholding0andout/subat0o111,_exit_code_reward(0, out)gives1.0onmain: the cell passes on its exit code, with the reward file it wrote ignored. It is fixed here and pinned in the third commit.Each issue takes the fix it proposes: list the one directory with
children_matching, and turn itsOSErrorinto the reader's own error. A missing directory keeps its meaning (no entries,not a directoryfor the memory root).Closes #1506
Closes #1508
Closes #1509
Other sites with the same cause, found by the search and left out of this PR: #1625 (agent run trace in a container output), #1626 (the pilot replay's
runs/folder), #1627 (the subjects run's cell and plugin-delta artifacts) and #1628 (the repo graders' workspace artifact, oracle and mutant patch directories). The failingtest_package_uses_the_new_modulesonmainis #1629. Sites that list a directory withiterdir()raisePermissionErrorinstead of reading it as empty; of those,coverage.py(#1630),eval tasks list(#1631), the taskenvironment/upload (#1632) andrepo reach(#1633) end in a traceback, andruns import(#1634) in the wrong exit code.Changes
memory/store.py(read_claude_memory): the topic files are listed withchildren_matching(root, "*.md"); itsOSErrorisMemoryStoreError("<root>: cannot list the memory directory: <reason>"), worded like the archive's error, andmemory lintends with its usual input error (exit 2).docs/memory.mdsays so.context/session_log.py(subagent_files,read_session_tree): thesubagentsdirectory is listed withchildren_matching; anOSErrorraisesSessionError("cannot read <dir>: <reason>"), asread_sessiondoes for the log. A missing directory still means no subagents.read_session_treekeeps the parent session's events and records the error on the session, as it does for an unreadable subagent transcript, sotrace prefilterwarns on stderr and reportspartial(exit 0) instead of dropping the session.commands/context.py(_read_sessions) skips such a session in its pass that finds the subagent transcripts to fold, so no traceback reaches the user.docs/session-prefilter.mdsays so.harnesses/rollouts.py(new;rollout_dirsandrollout_resultsmoved here frombenchflow.py, still importable from it, plusharbor_results,result_files,look_for_rollouts,cannot_list): each level (jobs dir, then each job dir) is listed withchildren_matching. A missing jobs dir has no rollout; an unlistable one raises itsOSError, which names the directory. The BenchFlow cell reports it asmetrics.errorbenchflow: cannot list <dir>: <reason>, with no reward andn_attempts0;read_harbor_jobasharbor: cannot list <dir>: <reason>. The cleanup after a BenchFlow timeout (remove_rollout_containers) falls back to a glob when it cannot list a jobs or job dir, so it removes no containers when the jobs dir cannot be listed and still removes those under the job dirs that can be listed when another one cannot; a timed-out cell'smetrics.errorthen carries the listing error after the timeout error, so the cell's error names the directory. The move keepsbenchflow.pyunder its growth baseline, which is lowered (873 to 860 lines).harnesses/command.py:_find_rewardand_has_reward_filefind the reward files withlisted_entries(called on the output dir itself, with nois_dir()guard, sincePath.is_dir()answers False for a path behind a directory that cannot be searched on Python 3.14; only a missing or non-directory output dir has no reward files), comparing names withos.path.normcase;_command_verdict(the verdict code ofrun, extracted) givessolver_error: no verdict: cannot list <dir>: <reason>for a directory it cannot list, where the cell used to pass or fail on its exit code. A directory that vanishes while the output dir is walked is the same error (only the output dir itself being absent is empty), so a reward file already found is not dropped for the exit code, and a reward file that is listed but cannot be read givessolver_error: no verdict: cannot read <file>: <reason>.CommandHarness.run's complexity baseline is lowered (15 to 14).tests/test_memory_store_unlistable.py,tests/test_session_subagents_unlistable.pyandtests/test_rollout_readers_unlistable.py, one per issue, each skipping when the process can still list a mode0o111directory (root).Risk
A memory directory, a session's
subagentsdirectory, a jobs or job directory and a command cell's output tree that cannot be listed now give an error where they gave a smaller result.memory linton such a directory exits 2 where it exited 0 or 1. A command cell with a reward file under an unlistable directory is an errored cell (solver_error, kept out of the pass rate) where it was scored on its exit code; a BenchFlow or Harbor cell with an unlistable jobs or job directory still has no reward and is still an errored cell, with a message that names the directory. A readable tree gives the same result as before, in the same order.trace prefilteron a session whosesubagentsdirectory cannot be listed now exits 0 with a warning andstatuspartial, where it exited 0 with no word.Testing
On a Linux review host, at
e017dec2(onmain01ff2d6):make ci-local: 36 passed, 2 failed, 16 skipped (docker-only external catalog smoke, the steps that need a pull request, a Claude Code install, micromamba, semgrep, the Python matrix legs and the other workflows' jobs). The failures areci.yml:test / Run tests: 35438 tests passed, 28 skipped, 1 failed,tests/test_import_architecture.py::test_package_uses_the_new_modules(dokimi.runs.resolveimportsdokimi.utils), which fails the same way onmainwithout this change (dokimi.runs.resolve imports dokimi.utils, which test_package_uses_the_new_modules refuses #1629); andpip-audit.yml:pip-audit, which lists 30 advisories onfilelock4.2.4 from the lock (fix versions 4.3.0 and 4.2.12), a package this PR does not touch (Drop the filelock override once a litellm release allows filelock 4 #383 tracks the filelock pin). Changed-line coverage 100% (100 lines); the mutation job killed 66 of 66 mutants.main, the three new test files fail 2 of 3, 3 of 4 and 7 of 14 tests (DID NOT RAISE MemoryStoreError,DID NOT RAISE SessionError,DID NOT RAISE PermissionErrorfirst); here they pass.OSError, a message that names the wrong directory, a dropped guard for a missing directory, a reward file filter flipped) each fail the new test that pins them. Five more each fail one test: treating a subdirectory that vanishes mid-walk as an absent output dir (test_a_command_cell_whose_output_subdirectory_vanishes_mid_walk_has_no_verdict), letting a reward file's read error escape or dropping its reason fallback (test_a_command_cell_with_an_unreadable_reward_file_says_it_cannot_read_it,test_a_read_error_with_no_reason_text_is_worded_by_the_error_itself), no fallback glob in the cleanup after a timeout (test_a_cleanup_after_a_timeout_removes_the_rollouts_of_the_job_directories_it_can_list), and listing every file insubagentsinstead of*.jsonl(test_subagent_files_list_the_transcripts_and_refuse_a_directory_they_cannot_list, with anotes.txtbeside the transcript).benchflow: bench killed after <n>s (outer budget); benchflow: cannot list <jobs dir>: Permission denied. A reward file is matched byos.path.normcaseof its name and read by that canonical name, soREWARD.TXTandREWARD.JSONcount where the platform compares names case-insensitively (the test feedsntpath.normcase; on Linux they stay unmatched, asrglobhas it). Dropping the list error from the timeout message, or thenormcaseof the file name, failstest_a_benchflow_timeout_keeps_the_directory_it_could_not_list_in_its_errorandtest_a_reward_file_is_found_by_the_platforms_name_comparison_and_read_by_its_canonical_namerespectively. The reward-name test pinsposixpath.normcasebefore its first assertions, so it holds where the platform's own comparison isntpath.normcase; without the pin and withntpath.normcaseas the default it fails.Path.is_dirpatched to answer as Python 3.14 does (os.path.isdir),out/reward.txtholding0under a mode0o600parent givessolver_error: no verdict: cannot list <out>: Permission denied; with theis_dir()guard back,test_a_command_cell_whose_output_dir_sits_behind_an_unsearchable_directory_has_no_verdictfails with reward1.0. A file as the output dir has no reward files.fix/unlistable-repo-eval-readers,fix/unlistable-skill-docs,fix/rmtree-unlistableonmain4024f25:pytest -n auto35800 passed, 28 skipped,mypyclean,ruff checkclean.0o111directory).Open questions
None.
Revert
A plain revert restores the globs: the three readers read an unlistable directory as empty again, and
rollout_dirsandrollout_resultsare back inbenchflow.py. Nothing is stored.Checklist
pytestpasses (the full run has one failure,test_package_uses_the_new_modules, which fails onmaintoo)ruff,mypy, and schema checks passAGENTS.mdraise/exit and test names the doc, contract or issue it traces to.github/.licenserc.yaml)