Repository navigation
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
Conversation
…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>
|
✅ OpenCodeReview: Review complete: 0 finding(s) across 9 selected item(s). CI at Review details
|
|
Codecov Report✅ All modified and coverable lines are covered by tests. 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
🚀 New features to boost your workflow:
|
…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
left a comment
There was a problem hiding this comment.
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.
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. Onmain, with a directorysubthat is then made unlistable:mainAgentWorkspace.state(#1361)work/t.txt,work/sub/a.txt, thenchmod 111 work/sub['sub/a.txt', 't.txt']listable,['t.txt']unlistable; the host solve compares the state before and after the agent runstypecheck._reachable(#1362)top.py,sub/m.py, thenchmod 111 sub[('.', ('top.py',)), ('sub', ('m.py',))]listable,[('.', ('top.py',))]unlistable: a stub or a silencing comment undersubis never seentypecheck.oracle(#1362)reference/sub, thenchmod 111 reference/subValueError: reference/sub/link is a symbolic link; the reference is copied without linkslistable;shutil.Error: [(..., "[Errno 13] Permission denied: '.../reference/sub'")]unlistable, since the link check passedHeldGuidance._walk(#1363)topand a linksub/l, thenchmod 111 sub(['sub/l', 'top'], ['.', 'sub'])listable,(['top'], ['.', 'sub'])unlistable: the alias throughsub/lis not followed andsubis still recordedThe fix for #1361 takes the first of the issue's two options:
stateraises theOSError, 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 theOSErrorof the directory too (os.walkwith anonerrorthat raises); see Changes for the error each caller sees.Closes #1361
Closes #1362
Closes #1363
The same cause in
select_docsis tracked in #1383, in the glob expansion of a user's--arm, session and--header/--librarypatterns in #1384, and the work tree an unlistable directory leaves behind aftercleanupin #1385. The same cause indetect_skill_packagesis fixed by #1211.Changes
AgentWorkspace.state(harnesses/agent_sandbox.py) walks with anonerrorthat raises. The newAgentWorkspace.edited_since(before)returns whether the tree changed and the error of a listing that failed (thenTrue).harnesses/docker_solver.py,_solve_claude) reads the state after the run throughedited_since, saves the solver stream and the cost withrecord_solver, and then raises the error. The existing handler inrunrecords it:metrics.errorisPermissionError: [Errno 13] Permission denied: '.../work/sub',returncode1, 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).state():docker_solver.pybefore the agent runs (before = workspace.state(); an unlistable work tree there is an error before anything is spent) and after it (throughedited_since). Nothing else calls it; the in-container solve does not read the state.typecheck._reachable(repos/graders/typecheck.py) walks with anonerrorthat raises. A dot directory it prunes (.venv,.git) is removed fromdirnamesbefore the walk descends, so an unlistable one raises nothing.main.gradereports the exception as it does any other: the run is not graded (passis null, the error is ingrade.json).typecheck.oraclewalksreference/withos.walkand anonerrorthat raises aValueErrornaming 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 usedokimi.digest_entries.listed_entries: the graders run aspython3 -I -B /eval/graders/main.pyin the image without dokimi and are stdlib-only.HeldGuidance._walk(repos/held_guidance.py) walks with anonerrorthat raises, so thePermissionErrornames the directory. Its callers:run_cellthroughheld_guidance()(runner.py:262), whose caller records anOSErroras the cell's error (infra: true);security._cell_resolver, read underscan_batch, whose command reports anOSErroras a usage error (exit 2).reach.pyandsecurity.pyare not edited.docs/repo-evaluation-contract.md, the typecheck grader'sreference/paragraph) says what the oracle and the grade do with a directory they cannot list.reference/paragraph of the contract whoseValueErrorit checks.Risk
chmod 111orchmod 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 securityreads 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 ownheld_guidance()runs before the agent starts.reach.py:557buildsHeldGuidanceof the workspace it prepares from a git tree before the agent runs; its caller (commands/repo_reach.py:200) does not catch anOSError. A git tree has no mode0o111directory and I found no input that makes it unlistable there, so that path is not changed or covered.reference/directory is aValueErrorwhere ashutil.Errorwas 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.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/skillsparagraph near line 488). This PR changes only the typecheck grader'sreference/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.0o111directory.Testing
On Linux, at
57a802c6(onmain52f9de6):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.main; each new test fails onmain's code (test_agent_sandbox.py: 2 failed, the firstDID NOT RAISE PermissionError;test_repo_typecheck_grader.py: 2 failed, 1 passed, the oracle test with theshutil.Error;test_repo_run_guidance.py: 1 failed,DID NOT RAISE PermissionError) and passes here. The passing one onmainguards that an unlistable.venvstays no error.onerrorinstate, in_reachable, in the oracle's walk and inHeldGuidance._walk; the solver no longer raising the error; the solver raising before the cost is saved;edited_sincereturningFalseon a failed listing; the oracle raising anOSErrorinstead of aValueError; the root-directory wording dropped;_reachablenot pruning dot directories;statethat stops at the top level;_reachablethat yields no file; the oracle that skips its link check;HeldGuidancethat skips the links under a subdirectory.fix/unlistable-input-readersonmain52f9de6:pytest -n auto30834 passed, 27 skipped,mypyclean,ruff checkclean.0o111directory).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
pytestpassesruff,mypy, and schema checks passAGENTS.mdraise/exit and test names the doc, contract or issue it traces to.github/.licenserc.yaml)