Skip to content

fix(runs): export names a directory of the run it cannot list in its left-out note (#1618) - #1655

Merged
antonwolfy merged 1 commit into
intel:mainfrom
antonwolfy:fix/runs-export-unlistable
Dec 5, 2026
Merged

antonwolfy merged 1 commit into
intel:mainfrom
antonwolfy:fix/runs-export-unlistable

Conversation

@antonwolfy

Copy link
Copy Markdown
Contributor

Summary

#1618 names two sites that skip a directory they cannot list (mode 000 or 111, non-root user) and give a smaller result with no error or note. This PR fixes runs export: _unlisted in runs/bundle.py walked the run directory with os.walk and no onerror, so a subdirectory it could not list was skipped and the note left out: N file(s) in the run directory that run.json does not list was not printed for the files in it. On main, with nightly-7/extra/f.txt listable, stderr has left out: 1 file in the run directory that run.json does not list (first: nightly-7/extra/f.txt); after chmod 000 nightly-7/extra that line is gone, the export exits 0 with the same 4 files, and nothing says a directory was not read. Now stderr has left out: 1 directory in the run directory that cannot be listed (first: nightly-7/extra).

The other site, tasks run --harness command (_find_reward), is fixed by the open #1635, not here: this PR does not touch harnesses/command.py. #1618 closes with this PR while that half lands with #1635.

Fix option taken: the walk records the directories it cannot list (onerror) and the left-out note gets a line for them, as the issue's second option says. The first line (files) is unchanged.

Closes #1618

Changes

  • runs/bundle.py: _unlisted walks with an onerror that records each directory it could not list, as a path under the root like the other Collected paths; collect returns them, sorted, in the new Collected.unreadable.
  • commands/runs_bundle.py: cmd_runs_export prints left out: N directory|directories in the run directory that cannot be listed (first: ...) on stderr after the file line, when there is any.
  • docs/runs.md: the runs export bullet names the new line.
  • tests/test_runs_export_unlistable.py (new file, since tests/test_runs_bundle.py is at 984 lines and the growth cap is 1000): one directory (bundle bytes equal the listable run's), two directories (plural, Collected.unreadable), and a listable run printing no such line.
  • Changelog fragment (Fixed).

Risk

None for a run directory with no unlistable directory: the output is unchanged. For one with such a directory, stderr gains one line; the exit code (0), the bundle's bytes and its bundle.json are unchanged and no schema changes. A run directory that itself cannot be listed does not reach this walk: the runs scan cannot read its run.json entry, and export refuses with exit 2 (no artifact under the runs root ... has the run_id ...; 1 entry under the root could not be read), as on main.

Testing

On Linux, at d35d8c24 (on main 4deffc0):

  • make ci-local: 38 passed, 0 failed, 16 skipped. Skipped steps are those that need a real runner, docker, semgrep, micromamba or a PR number.
  • The new tests on main's code (with Collected.unreadable given as [] there): 2 failed, 1 passed; the first failure is assert [] == ['left out: 1 directory in the run directory that cannot be listed (first: nightly-7/extra)']. The third test is a guard that a listable run prints no such line.
  • Mutants, each fails the new tests: dropping onerror fails the one- and two-directory tests; naming the run directory instead of the unlistable one fails both; always directory fails the plural assertion; returning the run directory when none is unlistable fails the no-line test and the one-directory test.
  • Not run: Python 3.11, 3.12 and 3.14 (only one interpreter here).
  • Merged together with fix/encoding-rule on main 4deffc0: pytest -n auto 35924 passed, 28 skipped, mypy clean, ruff check clean.

Open questions

None.

Revert

A plain revert restores the old behaviour (no note for an unlistable directory). Nothing is stored.

Checklist

  • Tests added/updated and pytest passes
  • 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)

…left-out note (intel#1618)

`runs export` names the files of the run directory that run.json does not list by walking it with `os.walk` and no `onerror`, so a subdirectory it could not list (mode 111, non-root) was skipped and the note `left out: N file(s) in the run directory ...` was not printed for the files in it. The export exited 0 with the same bundle and nothing said a directory was not read.

`_unlisted` now records each directory the walk cannot list, as a path under the root like the other `Collected` paths, and `collect` returns them in a new `Collected.unreadable`. `runs export` prints `left out: N directory|directories in the run directory that cannot be listed (first: ...)` on stderr after the file line. The bundle, its bundle.json, the exit code and the output for a run directory with no unlistable directory are unchanged. A run directory that itself cannot be listed never reaches the walk: the runs scan already refuses that export with exit 2.

The `tasks run --harness command` half of intel#1618 is fixed by the open change to `harnesses/command.py` and is not touched here.

Signed-off-by: Anton Volkov <antonwolfy@gmail.com>
@antonwolfy
antonwolfy requested a review from a team as a code owner December 5, 2026 13:18
Copilot AI balanced review requested due to automatic review settings December 5, 2026 13:18
@antonwolfy antonwolfy self-assigned this Dec 5, 2026
@antonwolfy antonwolfy added the testing-strategy Part of #1595: checks for the bug classes behind our fix series, their sweeps and research label Dec 5, 2026

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.

🟢 Approval recommended

No active review issues block approval of the unlistable-directory diagnostic change.

No open issues 🎉

What changed in this PR

0 new findings; nothing to fix.

This PR fixes the runs export portion of #1618 by reporting directories it cannot list, without changing bundle contents or exit codes.

Changes:

  • Collects unlistable directory paths and reports them on stderr.
  • Adds regression tests for singular, plural, and fully listable cases.
  • Documents the new diagnostic.
File Description
dokimi/​tests/​test_runs_export_unlistable.py Tests diagnostics and unchanged bundle bytes.
dokimi/​dokimi/​runs/​bundle.py Records and sorts unlistable directory paths.
dokimi/​dokimi/​commands/​runs_bundle.py Prints the directory warning.
dokimi/​docs/​runs.md Documents the warning.
dokimi/​changelog.d/​20261205_100000_runs-export-unlistable-dir.md Records the export fix.

Review effort: Balanced

@exai-bot

exai-bot commented Dec 5, 2026 •

Copy link
Copy Markdown

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

CI at d35d8c2: 18 passing, 9 skipped.

Test notes (2)
  • dokimi/dokimi/commands/runs_bundle.py:50: With print(f"left out: {n} {'directory' if n == 1 else 'directories'} in the run directory that cannot be " f"listed (first: {plain(found.unreadable[0].as_posix())})", file=sys.stderr) changed to pass, the tests still pass: dokimi/tests/test_runs_bundle.py, dokimi/tests/test_runs_export_unlistable.py. If this condition matters, a test should pin it.
  • dokimi/dokimi/runs/bundle.py:341: With skipped.append(prefix / Path(str(exc.filename)).relative_to(directory)) changed to pass, the tests still pass: dokimi/tests/test_runs_export_unlistable.py. If this condition matters, a test should pin it.
Review details
  • Commit reviewed: d35d8c2 against merge base 4deffc0
  • Coverage: 5 files in 1 groups
  • Engine: OpenCodeReview v1.13.5-exai.4.8f73eada, us.openai.gpt-6.1-sol
  • Usage: 91k tokens (43k from cache), 24s
  • Tool calls: 10 (6 file_read, 1 ci_status, 1 code_search, 1 local_check_results, 1 pr_comments)
  • Runs export handling for unlistable directories, with tests and documentation: 5 files

@codecov-commenter

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.48%. Comparing base (4deffc0) to head (d35d8c2).
❗ Your organization needs to install the Codecov GitHub app to enable full functionality.

Additional details and impacted files
@@            Coverage Diff             @@
##             main    #1655      +/-   ##
==========================================
- Coverage   96.49%   96.48%   -0.01%     
==========================================
  Files         569      569              
  Lines       75249    75257       +8     
  Branches    12980    12981       +1     
==========================================
+ Hits        72613    72614       +1     
- Misses       1611     1614       +3     
- Partials     1025     1029       +4     
Files with missing lines Coverage Δ
dokimi/dokimi/commands/runs_bundle.py 98.27% <100.00%> (+0.04%) ⬆️
dokimi/dokimi/runs/bundle.py 92.00% <100.00%> (+0.11%) ⬆️

... and 7 files with indirect coverage changes

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

@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.

Approving d35d8c2.
What I checked: the 3 changed tests pass, and fail on main as expected; the full test suite passes with main merged in (35,965 tests), apart from failures main has too; it merges cleanly onto main; when I changed the code on purpose, the tests caught all 5 changes.

@antonwolfy
antonwolfy merged commit 843f2ad into intel:main Dec 5, 2026
34 checks passed
@antonwolfy
antonwolfy deleted the fix/runs-export-unlistable branch December 5, 2026 17:14
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

testing-strategy Part of #1595: checks for the bug classes behind our fix series, their sweeps and research

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Command harness and runs export: a directory they cannot list hides the reward file or the left-out note

5 participants