Skip to content

fix(run-trees): a directory of a run's tree that cannot be listed is an error in three readers, not a smaller tree - #1386

Merged
xaleryb merged 5 commits into
intel:mainfrom
antonwolfy:fix/unlistable-run-trees
Nov 29, 2026
Merged

xaleryb merged 5 commits into
intel:mainfrom
antonwolfy:fix/unlistable-run-trees

Conversation

@antonwolfy

Copy link
Copy Markdown
Contributor

Summary

Four sites in three readers of a run's workspace or reference tree skip a directory they cannot list (mode 0o111, a non-root user) without an error, so a later check reads a smaller tree and nothing says so. On main, with a directory sub that is then made unlistable:

Reader Input Output on main
AgentWorkspace.state (#1361) work/t.txt, work/sub/a.txt, then chmod 111 work/sub keys of the state: ['sub/a.txt', 't.txt'] listable, ['t.txt'] unlistable; the host solve compares the state before and after the agent runs
typecheck._reachable (#1362) top.py, sub/m.py, then chmod 111 sub [('.', ('top.py',)), ('sub', ('m.py',))] listable, [('.', ('top.py',))] unlistable: a stub or a silencing comment under sub is never seen
typecheck.oracle (#1362) a link in reference/sub, then chmod 111 reference/sub ValueError: reference/sub/link is a symbolic link; the reference is copied without links listable; shutil.Error: [(..., "[Errno 13] Permission denied: '.../reference/sub'")] unlistable, since the link check passed
HeldGuidance._walk (#1363) top and a link sub/l, then chmod 111 sub (['sub/l', 'top'], ['.', 'sub']) listable, (['top'], ['.', 'sub']) unlistable: the alias through sub/l is not followed and sub is still recorded

The fix for #1361 takes the first of the issue's two options: state raises the OSError, and the host solve reports it as the cell's error. A state that cannot be listed is not a state, so the solver does not score a run on a smaller one. The other option, listed_entries, would raise out of the solver as a crash. #1362 and #1363 raise the OSError of the directory too (os.walk with an onerror that raises); see Changes for the error each caller sees.

Closes #1361
Closes #1362
Closes #1363

The same cause in select_docs is tracked in #1383, in the glob expansion of a user's --arm, session and --header/--library patterns in #1384, and the work tree an unlistable directory leaves behind after cleanup in #1385. The same cause in detect_skill_packages is fixed by #1211.

Changes

  • AgentWorkspace.state (harnesses/agent_sandbox.py) walks with an onerror that raises. The new AgentWorkspace.edited_since(before) returns whether the tree changed and the error of a listing that failed (then True).
  • The host solve (harnesses/docker_solver.py, _solve_claude) reads the state after the run through edited_since, saves the solver stream and the cost with record_solver, and then raises the error. The existing handler in run records it: metrics.error is PermissionError: [Errno 13] Permission denied: '.../work/sub', returncode 1, no reward, and the cost stays in the metrics. The state of a tree that can be listed is the same set of keys and values as before (every file, dot directories included).
  • Callers of state(): docker_solver.py before the agent runs (before = workspace.state(); an unlistable work tree there is an error before anything is spent) and after it (through edited_since). Nothing else calls it; the in-container solve does not read the state.
  • typecheck._reachable (repos/graders/typecheck.py) walks with an onerror that raises. A dot directory it prunes (.venv, .git) is removed from dirnames before the walk descends, so an unlistable one raises nothing. main.grade reports the exception as it does any other: the run is not graded (pass is null, the error is in grade.json).
  • typecheck.oracle walks reference/ with os.walk and an onerror that raises a ValueError naming the directory (reference/sub cannot be listed: Permission denied), the type its refusal of a link has, so the callers (graders/main.py:oracle, hidden_tests.oracle) see the exit path they already have, and nothing is copied. It does not use dokimi.digest_entries.listed_entries: the graders run as python3 -I -B /eval/graders/main.py in the image without dokimi and are stdlib-only.
  • HeldGuidance._walk (repos/held_guidance.py) walks with an onerror that raises, so the PermissionError names the directory. Its callers: run_cell through held_guidance() (runner.py:262), whose caller records an OSError as the cell's error (infra: true); security._cell_resolver, read under scan_batch, whose command reports an OSError as a usage error (exit 2). reach.py and security.py are not edited.
  • The contract (docs/repo-evaluation-contract.md, the typecheck grader's reference/ paragraph) says what the oracle and the grade do with a directory they cannot list.
  • Each new test's docstring names its issue (AgentWorkspace.state omits files under a directory it cannot list, so a changed-files diff misses them #1361, the typecheck grader reads a smaller workspace, and its oracle copy fails with a shutil error, when a directory cannot be listed #1362, HeldGuidance._walk drops the links under a directory it cannot list from its link table #1363); the oracle's names the reference/ paragraph of the contract whose ValueError it checks.
  • Changelog fragment (Fixed), one for the three sites.

Risk

  • A run whose agent makes a directory of its work tree unlistable (chmod 111 or chmod 000) is now an error of the cell, not a scored run, also when the agent did it on purpose: the state after the run is unknown, so the run cannot be told from one that left the files alone. The solver stream and the cost are kept.
  • repo security reads the held-guidance links of a cell's workspace as the agent left it. A cell whose agent made a directory unlistable now stops the scan with a usage error (exit 2) naming the directory, where it used to read the links of the rest. The runner's own held_guidance() runs before the agent starts.
  • reach.py:557 builds HeldGuidance of the workspace it prepares from a git tree before the agent runs; its caller (commands/repo_reach.py:200) does not catch an OSError. A git tree has no mode 0o111 directory and I found no input that makes it unlistable there, so that path is not changed or covered.
  • The oracle's refusal of an unlistable reference/ directory is a ValueError where a shutil.Error was raised before, and for a reference whose links all sit in listable directories nothing changes. The grade of a workspace with an unlistable directory is not graded, where it used to be graded on a smaller workspace.
  • Open PRs that change docs/repo-evaluation-contract.md: fix(readers): refuse a directory that cannot be listed in six readers of a user's tree (#1210) #1366 changes the paragraph on a skill's target directory (a .claude/skills paragraph near line 488). This PR changes only the typecheck grader's reference/ paragraph near line 955, so a merge with fix(readers): refuse a directory that cannot be listed in six readers of a user's tree (#1210) #1366 meets no conflict. fix(repo): inspect names unreadable instruction files and plugin manifests (#1271) #1328 changes the paragraph on the report's guidance records near line 2332 and fix(eval): test current Dokimi guidance #1194 the paragraph on where the grader code is mounted near line 879, so a merge with either meets no conflict.
  • The tests skip when the process is root, which lists a mode 0o111 directory.

Testing

On Linux, at 57a802c6 (on main 52f9de6):

  • make ci-local: 38 passed, 0 failed, 16 skipped (docker-only steps, the other Python versions, conda-forge, semgrep, the steps that need a PR number). 30826 tests passed, 27 skipped; changed-line coverage 100% (28 lines); mutation of changed lines: 19 of 19 killed.
  • The repros of the table, run as a non-root user: they fail on main; each new test fails on main's code (test_agent_sandbox.py: 2 failed, the first DID NOT RAISE PermissionError; test_repo_typecheck_grader.py: 2 failed, 1 passed, the oracle test with the shutil.Error; test_repo_run_guidance.py: 1 failed, DID NOT RAISE PermissionError) and passes here. The passing one on main guards that an unlistable .venv stays no error.
  • Mutants, each failing a new test: no onerror in state, in _reachable, in the oracle's walk and in HeldGuidance._walk; the solver no longer raising the error; the solver raising before the cost is saved; edited_since returning False on a failed listing; the oracle raising an OSError instead of a ValueError; the root-directory wording dropped; _reachable not pruning dot directories; state that stops at the top level; _reachable that yields no file; the oracle that skips its link check; HeldGuidance that skips the links under a subdirectory.
  • Merged together with fix/unlistable-input-readers on main 52f9de6: pytest -n auto 30834 passed, 27 skipped, mypy clean, ruff check clean.
  • Not run: the matrix legs on Python 3.11, 3.12 and 3.14; the docker steps; the new tests as root (they skip there, since root lists a mode 0o111 directory).

Open questions

None.

Revert

A plain revert restores the old behaviour: the three readers skip a directory they cannot list again. 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)

…l#1361)

AgentWorkspace.state walked the agent's work tree with os.walk and no onerror, which skips a directory it cannot list. A file the agent wrote under a directory it then made unlistable (mode 0o111) was missing from the state after the run, and the solver compared that smaller state with the one before the run.

state now re-raises the OSError of a directory it cannot list. The new AgentWorkspace.edited_since returns that error instead of raising it, so the host solve saves the solver stream and the cost first and then raises it; the existing handler records it as the cell's error (metrics.error, returncode 1, no reward) and the run is not scored. The state of a tree that can be listed is unchanged.

Signed-off-by: Anton Volkov <antonwolfy@gmail.com>
The typecheck grader listed two trees with no error for a directory it could not list. _reachable walked the graded workspace with os.walk and no onerror, so a stub or a silencing comment under such a directory was never checked. The oracle listed reference/ with rglob, which skips such a directory, so a symbolic link inside it passed the link check and shutil.copytree then failed with a shutil.Error instead of the ValueError the callers expect.

_reachable now raises the OSError of a directory it walks and cannot list; main.grade reports it as a run that is not graded, as it does for any exception of a grade. A dot directory it prunes is still not walked, so an unlistable .venv is no error. The oracle walks reference/ with os.walk (stdlib only: the grader runs in the image without dokimi) and raises a ValueError naming the directory, the same type as its refusal of a link. The contract names both.

Signed-off-by: Anton Volkov <antonwolfy@gmail.com>
intel#1363)

HeldGuidance._walk walked the workspace with os.walk and no onerror. A link inside a directory it could not list (mode 0o111) was missing from the link table, so the alias through it was not followed, while the directory itself was still recorded as listed.

_walk now raises the OSError of a directory it cannot list, which names the directory and the reason. held_guidance runs in run_cell, whose caller records an OSError as the cell's error; security's _cell_resolver is read under scan_batch, whose caller reports an OSError as an unreadable input. The links of a workspace that can be listed are unchanged.

Signed-off-by: Anton Volkov <antonwolfy@gmail.com>
… to (intel#1361, intel#1362, intel#1363)

The six tests added for an unlistable directory of a run's tree now carry a one-line docstring naming their issue; the oracle's test also names the reference/ paragraph of docs/repo-evaluation-contract.md whose ValueError it checks. No code changes.

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

exai-bot commented Nov 28, 2026 •

Copy link
Copy Markdown

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

CI at 3dd83ff: 25 passing, 4 skipped.

Review details
  • Commit reviewed: 3dd83ff against merge base 52f9de6
  • Coverage: 9 files in 3 groups
  • Engine: OpenCodeReview v1.13.5-exai.4.8f73eada, us.openai.gpt-6.1-sol
  • Usage: 330k tokens (210k from cache), 24s
  • Tool calls: 28 (15 file_read, 4 code_search, 3 local_check_results, 2 ci_status, 2 file_read_diff, 1 pr_comments, 1 pr_threads)
  • Unlistable run-tree handling in sandbox harnesses: 4 files
  • Repository guidance and evaluation contract: 3 files
  • Typecheck grader robustness and tests: 2 files

@codecov-commenter

codecov-commenter commented Nov 28, 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.22%. Comparing base (52f9de6) to head (3dd83ff).
⚠️ Report is 14 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    #1386      +/-   ##
==========================================
- Coverage   96.22%   96.22%   -0.01%     
==========================================
  Files         509      511       +2     
  Lines       67762    68088     +326     
  Branches    11766    11822      +56     
==========================================
+ Hits        65203    65515     +312     
- Misses       1576     1581       +5     
- Partials      983      992       +9     
Files with missing lines Coverage Δ
dokimi/dokimi/harnesses/agent_sandbox.py 98.10% <100.00%> (+0.75%) ⬆️
dokimi/dokimi/harnesses/docker_solver.py 98.32% <100.00%> (+0.49%) ⬆️
dokimi/dokimi/repos/graders/typecheck.py 97.22% <100.00%> (+0.07%) ⬆️
dokimi/dokimi/repos/held_guidance.py 100.00% <100.00%> (ø)

... and 17 files with indirect coverage changes

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

…smaller tree

A directory that keeps r but loses x (mode 0o644) lists, but its entries
cannot be stat'd: state() skipped them under `except OSError` and
HeldGuidance._walk read them as no link through os.path.islink. Both now
raise; a file gone since the listing is still skipped by state().

Signed-off-by: Alexander Rybkin <alexander.rybkin@intel.com>
@xaleryb

xaleryb commented Nov 29, 2026

Copy link
Copy Markdown
Contributor
  • Ran: head merged with main 8e978ac as a non-root user, with directories at modes 111, 000, 644 and 444. Full suite, ruff, mypy, bandit and docs check on the merged tree.
  • A directory that keeps r but loses x (chmod 644 sub) -> AgentWorkspace.edited_since(before) returns (False, None) after the agent wrote sub/new.txt, and HeldGuidance returns links == [] for sub/l -> expected a PermissionError, as mode 111 gives. os.lstat fails under except OSError: continue, and os.path.islink reads EACCES as no link.
  • Commit to push: 3dd83ff3f. state now skips only FileNotFoundError, and _walk uses stat.S_ISLNK(os.lstat(...)). It adds a 0o644 case to both new tests (red without the fix) and extends the changelog fragment.
  • Left for the author: nothing else.

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

Approved on 3dd83ff. A run-tree directory that cannot be listed is an error in the three readers instead of a smaller tree; our commit covers a directory that keeps r but loses x (chmod 644), which was still skipped. Full suite and gates are green on the head merged with main. Windows smoke had not started (the hosted Windows queue was stuck); every other check passed.

@xaleryb
xaleryb merged commit c8ee1b7 into intel:main Nov 29, 2026
29 checks passed
@antonwolfy
antonwolfy deleted the fix/unlistable-run-trees branch November 29, 2026 10:28
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

4 participants