Repository navigation
fix(skills): a directory that cannot be listed is an error in seven more digests, file lists and checks - #1211
Conversation
…ore digests, file lists and checks (intel#1168) Path.rglob and an os.walk with no onerror skip a subdirectory that cannot be listed (mode 0o111) without an error, so the Harbor export cache key, the files the leak gate indexes, the resources of a loaded skill, the packages of `catalog formats`, the scenarios of a reach fixture, the link check of a repo-run skill arm and the output-overwrite guard of `eval leak` described a smaller tree. Each now lists with digest_entries.listed_entries or an os.walk whose onerror re-raises, so the OSError of the directory is raised: _content_key, read_skill (which documents OSError), load_skill, detect_skill_packages, scenarios_of and _uncopyable raise it, and `catalog formats` and `eval leak` turn it into an input error (exit 2). check_skill wraps it as the ValueError it documents. Entries these sites already left out (.git and an evals directory for the leak gate, vendored directories for the package list, __pycache__ for the resources) are dropped before they are listed, so an unlistable one does not raise. A dot-named or vendored directory that cannot be listed is still left out of a skill's resources, as novelty.bundle leaves it out. The result for a tree that can be listed is unchanged. The catalog scan now reports a skill with another folder that cannot be listed as an error row, where the review ran with a bundle-file-unchecked note: the two tests that pinned the note and the skill_treatment test that pinned a skill loading with such a folder pin the new outcome. Signed-off-by: Anton Volkov <antonwolfy@gmail.com>
|
✅ OpenCodeReview: Review complete: 0 finding(s) across 17 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 #1211 +/- ##
==========================================
+ Coverage 96.07% 96.25% +0.17%
==========================================
Files 496 513 +17
Lines 65209 68289 +3080
Branches 11317 11845 +528
==========================================
+ Hits 62652 65733 +3081
+ Misses 1583 1568 -15
- Partials 974 988 +14
🚀 New features to boost your workflow:
|
napetrov
left a comment
There was a problem hiding this comment.
Change class: CONTRACT (head 3983a66)
- Contract: candidate. errors dokimi/dokimi/commands/catalog.py:475; errors dokimi/dokimi/commands/leak.py:63
- Responsibility: none
- Dependency: none
- Review depth: check the changed surface: callers, docs, tests pin new behaviour
- Coverage gaps: none
The strict traversal correctly propagates listing failures from included skill content. One CLI path also traverses excluded content for an output collision check even when the command writes no files. The regression is visible in the order of the guard and the input reader. Reviewed the seven call sites and their tests from source. GitHub CI is green.
Settles the review thread on `_refuse_clobber`: with no `--out` and no lock there is no output to protect, yet the strict walk entered an unlistable `evals/` that `read_skill` leaves out and exited 2. The guard now returns before the walk when there are no outputs; with an output the walk stays strict. A test covers the stdout-only run with an unlistable excluded directory. Signed-off-by: Anton Volkov <antonwolfy@gmail.com>
@napetrov (#1211 (review)): Review body; its one finding is the thread 4699602155, fixed in 45271c1. |
|
Ready for another look at codecov has not reported on this head yet. |
vchamarthi
left a comment
There was a problem hiding this comment.
@antonwolfy, could you fix the problem I found and the small thing I've marked fix before merge (in the line comments) and answer my question below? Then push and I'll take another look.
My question before I approve:
- A
discover_skillscall now fails for the whole catalog when one skill has a folder that cannot be listed:catalog probe --catalogexits 2 and names the folder, whilecatalog scanmakes that skill an error row and goes on. Say which in the PR description.
What I checked on 45271c1:
- When I broke the changed code on purpose, the tests missed 4 of 12 breakages.
- The 364 changed tests pass, and fail on main as expected.
- The full test suite passes with main merged in (36,547 tests), apart from failures main has too.
- It merges cleanly onto main.
…ueError Settles the review points on the arm factory and external-content.md. `create_treatment` now wraps the `PermissionError` of `load_skill` (`skill:`, `skill-agent:`) and of `discover_skills` (`skill-catalog:`) in a `ValueError` that names the arm, as `check_skill` does, so the CLI refuses it instead of printing a traceback and exiting 5. Tests cover the three arm kinds. `external-content.md` no longer says a vendored folder that cannot be listed gives the `bundle-file-unchecked` note: the bundle walks skip vendored folders before they are opened, so only a hidden folder can. The changelog fragment names the arm refusal. Signed-off-by: Anton Volkov <antonwolfy@gmail.com>
@vchamarthi (#1211 (review)): The two line comments are done in 2229e53. On the question: yes, a |
napetrov
left a comment
There was a problem hiding this comment.
Change class: CONTRACT (head 2229e53)
- Contract: candidate. errors dokimi/dokimi/commands/catalog.py:475; errors dokimi/dokimi/commands/leak.py:70
- Responsibility: none
- Dependency: none
- Review depth: check the changed surface: callers, docs, tests pin new behaviour
- Coverage gaps: none
The earlier permission-denied fix is in place for all three skill arm kinds. I checked another listing failure against the merge base and found a raw filesystem error still escapes the treatment factory. The subjects run planning path translates ValueError into a CLI input error. CI passed.
vchamarthi
left a comment
There was a problem hiding this comment.
@antonwolfy, could you fix the new problem I found (in the line comments) and fix what napetrov's thread on dokimi/dokimi/treatments/factory.py:60 still points out? Then push and I'll take another look.
What I checked on 2229e53:
- When I changed the code on purpose, the tests still passed for 4 of 12 changes, and no test pins these down yet (non-blocking):
dokimi/dokimi/skills/loader.py:160(it returns None),dokimi/dokimi/skills/loader.py:163(it returns None) anddokimi/dokimi/skills/loader.py:164(the handled error is raised again). - The 367 changed tests pass, and fail on main as expected.
- The full test suite passes with main merged in (37,076 tests), apart from failures main has too.
- It merges cleanly onto main.
… a ValueError Settles the review points on the factory, the leak guard and the loader predicate of intel#1211. - `treatments.factory`: `skill:`, `skill-agent:` and `skill-catalog:` wrap any `OSError` of the listing (an I/O error, not only `PermissionError`) in the `ValueError` that names the arm, so `subjects run` refuses the spec instead of ending in a traceback; a missing SKILL.md stays a `FileNotFoundError`. The skill arm wrap moves to `_load_skill_arm` to keep `_build` under the complexity cap. - Tests: an EIO on the references directory for the three arm kinds, a missing SKILL.md, an existing `--out` in a sibling folder of a skill folder that the leak guard accepts, and `_not_listed_as_resource` answering a bool for each kind of entry. Signed-off-by: Anton Volkov <antonwolfy@gmail.com>
@napetrov (#1211 (review)): The raw filesystem error of the factory is translated now: see the reply on 4712127699 (fbc3f61). |
@vchamarthi (#1211 (review)): Both asks are answered in fbc3f61: the factory wrap (reply on 4712127699) and the sibling-output test (reply on 4712858807). For the surviving changes in |
napetrov
left a comment
There was a problem hiding this comment.
Change class: CONTRACT (head fbc3f61)
- Contract: candidate. errors dokimi/dokimi/commands/catalog.py:475; errors dokimi/dokimi/commands/leak.py:70
- Responsibility: none
- Dependency: none
- Review depth: check the changed surface: callers, docs, tests pin new behaviour
- Coverage gaps: none
The previously reported EIO case is fixed for all three arm kinds. The changed listing behavior still exposes a raw exception when a resource directory disappears during enumeration (C18). I reproduced this on head and compared the result with the merge base. The two focused suites passed all 89 tests.
…alueError _load_skill_arm re-raised every FileNotFoundError, so a resource folder removed between discovery and its listing escaped as a raw FileNotFoundError. The SKILL.md lookup now runs first and keeps its FileNotFoundError; every OSError after it is the arm's ValueError. Signed-off-by: Alexander Rybkin <alexander.rybkin@intel.com>
|
Mutation of changed lines65 mutants of the lines this PR changes, at 88ee212: 60 killed, 5 survived, 0 waived, 0 inconclusive, 0 timed out, 0 errors, 0 not run. A survivor is a change to that line that the tests covering it do not notice: add an assertion that fails on it or, if the change cannot alter behaviour, put
Warn-only: a survivor does not fail the job yet. Updated on every push; the full report is in the ci run summary. |
xaleryb
left a comment
There was a problem hiding this comment.
Approved on 88ee212. Seven more digests, file lists and checks refuse a directory they cannot list, with the same listed_entries helper and message as the readers merged before; our commit turns a skill arm folder that vanishes while listed into the arm's ValueError (the open thread). 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
Path.rgloband anos.walkwith noonerrorskip a subdirectory that cannot be listed (mode0o111, as a non-root user) without an error, so a digest, file list or check of a skill or task described a smaller tree and nothing said so (#1168, the same cause as #1103 to #1106, fixed for four sites in #1169). Onmain, with a skill directory holdingSKILL.mdand areferences/directory of two files, andchmod 111 references:references/(or the task'senvironment/) unlistable, onmainharbor_export._content_key(cache key of an exported task)0ff7dfe6ee3e21e2bd2288aa5ad8b92f, no errorleakgate.read_skill(files the leak gate indexes)['SKILL.md', 'references/a.md']['SKILL.md'], so a leak in the dropped file is not foundloader.load_skillresources['references/a.md'][]formats.detect_skill_packages(catalog formats)conformance.scenarios_ofcwd=.,cwd=sub,read=subcwd=.onlyarms._uncopyable(link check of a skill arm)links outside itfor a link in the directoryNone, the link is not checkedleak._refuse_clobber(eval leakoutput-overwrite guard)--outthat is a file of the skillThe fix taken is the first option the issue gives, applied per site: list with
digest_entries.listed_entries(or anos.walkwhoseonerrorre-raises), so theOSErrorof the directory is raised where each site already raisesOSErroror returns a digest, a key or a list, never a smaller value and never a warning. Entries a site already left out (.gitand a top-levelevalsfor the leak gate, vendored directories for the package list,__pycache__for the resources) are dropped before they are listed, so an unlistable one does not raise.The same search over every
rglobandos.walkunderdokimi/dokimi/found more places with the cause that the issue does not name, and they are not changed here: the two doc sources of the issue (a question about their contract) in #1207, the skill discovery walks in #1208, the static check walks in #1209 and other readers of a user's tree in #1210.Closes #1168
Changes
harnesses/harbor_export.py_content_key,skills/loader.pyload_skill,skills/formats.pydetect_skill_packagesandrepos/conformance.pyscenarios_oflist withlisted_entries;eval/leakgate.pyread_skilldoes too (its docstring already says it raisesOSError), withdropfor the entries it left out;repos/arms.py_uncopyablewalks with anonerrorthat re-raises.leak._refuse_clobberreturns before it lists the skill when no file is written (no--outand no lock), so a stdout-onlyeval leakis not stopped by an unlistableevals/thatread_skillleaves out; with an--outor a lock the listing stays strict.load_skillstill leaves out__pycache__, and a dot-named or vendored directory (.git,venv,node_modules) that cannot be listed, asnovelty.bundledoes since fix: a directory that cannot be listed is an error in four digests and file lists, not a smaller tree #1169; any other directory that cannot be listed raises. A listable tree gives the same resources as it does onmain.skill_treatment.check_skillwraps theOSErrorofload_skillin theValueErrorit documents (it caught onlyFileNotFoundError);catalog formatsandeval leak(_refuse_clobber) turn it into anInputError, exit 2, naming the directory. A catalog scan row for a skill with such a folder is an error row, as for any skill that does not load;repo runalready catchesOSErroraround the arm check.test_catalog_command_checks.py::test_an_unreadable_subdirectory_does_not_abort_the_scanandtest_catalog_bundle_unreferenced.py::test_an_unreadable_folder_withholds_the_claimasserted a review with abundle-file-uncheckednote for a skill with a folder that cannot be listed; the skill is now an error row and the scan goes on.test_skill_treatment.py::test_an_unreadable_subdirectory_is_not_a_loop_errorassertedcheck_skillreturned the name; it now asserts acannot load skillValueErrorthat is not a loop error. The hidden-folder note (.cache) and the vendored cases are unchanged.treatments.factorywraps anyOSErrorof the listing inload_skill(skill:,skill-agent:, in_load_skill_arm) and indiscover_skills(skill-catalog:), an I/O error as well as a permission error, in aValueErrorthat names the arm, ascheck_skilldoes, so an arm spec that names such a skill is refused (subjects runturns theValueErrorinto an input error) instead of ending in a traceback. Askill:orskill-agent:folder with noSKILL.mdstill raisesFileNotFoundError.discover_skillscall fails for the whole catalog when one skill has a folder that cannot be listed:catalog trigger-probe --catalogexits 2 and names the folder, and askill-catalog:arm is aValueError;catalog scaninstead makes that skill an error row and goes on (run on a catalog of one skill with an unlistablereferences/:trigger-probeexit 2--catalog: [Errno 13] Permission denied: .../references,catalog check --per-skillone skill in stateerror).external-content.md(thebundle-file-uncheckednote is for a hidden folder; another folder that cannot be listed makes the skill an error row) andevaluating-treatments.md(the leak gate).Risk
A skill, task or fixture tree with a directory the process cannot list is now refused where it used to be read as a smaller tree:
eval leakandcatalog formatsexit 2 with the directory named, a catalog scan reports the skill as an error row (before, a review with abundle-file-uncheckednote),repo runrefuses a skill arm, a Harbor export raisesPermissionError, andcheck_skillfails the cell before the image build. A directory with no read permission as root, or on a file system with no modes, lists exactly as it does onmain. The output for a tree that can be listed is unchanged, including the Harbor cache key, so no cached export is invalidated. The two mutants the changed-lines job left alive,FalsebecomingNonein the_not_listed_as_resourcepredicate (both falsy), are now killed bytest_not_listed_as_resource_answers_a_bool_for_each_kind_of_entry, which checks the returned bool: changing eitherreturn Falsetoreturn None(loader.py:160andloader.py:163) makes it fail.Open PRs that change the same files (#1190, #1193, #1197, #1171, #1158, #1039) change other lines: #1190 rewrites the
InputErrorandparse_frontmatterimport lines ofcommands/leak.py,commands/catalog.pyandharnesses/skill_treatment.py, which this change leaves alone (it adds its own import line inleak.pywith the unchangedexit_codesimport between the two), and the others change other hunks ofcatalog.py,external-content.mdandevaluating-treatments.md, so a merge with any of them meets no conflicting hunk.Testing
On a Linux review host, at
fbc3f619(onmain602de14):make ci-local: 38 passed, 0 failed, 15 skipped (docker and network steps, other Python versions, semgrep, matrix jobs of other workflows). 28411 tests passed, 23 skipped; changed-line coverage 100% (56 lines).test_a_skill_arm_with_a_folder_that_cannot_be_listed_is_refused_as_a_value_error(skill:andskill-agent:) andtest_a_skill_catalog_arm_with_a_folder_that_cannot_be_listed_is_refused_as_a_value_error: with theexcept PermissionErrorof both wraps changed toFileNotFoundError,3 failed, 19 passed, each failing on thePermissionErrorfromload_skillordiscover_skills.references/directory: the three new..._fails_to_list_with_an_io_error_is_a_value_errortests (skill:,skill-agent:,skill-catalog:) fail on the previous head with the rawOSError: [Errno 5] Input/output error(3 failed) and pass here; changing the wraps back toexcept PermissionErrorfails them.test_a_skill_arm_with_no_skill_md_is_still_a_file_not_found_errorfails when that case becomes aValueError.test_leak_output_guard_accepts_an_existing_output_beside_a_skill_folder: an existing--outin a sibling folder of a skill folder is accepted; withskill_root.is_file()negated, the guard lists the parent folder, refuses it and the test fails.test_not_listed_as_resource_answers_a_bool_for_each_kind_of_entrypins the three returns of_not_listed_as_resource(Falsefor a listable or non-directory entry,Truefor__pycache__and an unlistable dot directory); each ofreturn Noneat the twoFalsereturns and re-raising theOSErrorfails it.test_leak_output_guard_does_not_list_the_skill_when_no_file_is_written: with the early return replaced byif False, it fails (the guard raisesInputErroron the unlistableevals/with no output).tests/test_unlistable_sites.py(19 tests at its first commit; the next sentence is about those): onmain's code9 failed, 9 passed; the nine that fail are the unlistable-directory tests of the seven sites, ofcatalog formatsand ofcheck_skill, first onDID NOT RAISE PermissionError; the nine that pass pin a listable tree's result (the same key, files, resources, packages, scenarios) on both. The three changed existing tests give3 failed, 342 passedonmain's code.rglobor droppingonerrorat each of the seven sites, dropping eachdropclause, the dot-named and vendored carve-out, theInputErrorwraps, thecheck_skillcatch, the\0of the key) each fail the test that pins them.2229e530: 37 mutants, 35 killed, 2 survived (the twoFalsereturns of_not_listed_as_resource, killed since bytest_not_listed_as_resource_answers_a_bool_for_each_kind_of_entry; the CI job was not rerun here).make ci-local.Open questions
What a doc source (
local:andokf:) should do with a directory it cannot list: the code raisesMCPConnectionErrorfor a missing path, skips an unreadable file at debug level and warns on no files, anddocs/adding-doc-source.mdsays nothing of it, so neither settles it. Left to #1207.Revert
A plain revert restores the old behaviour: a directory that cannot be listed is left out of the listing again. Nothing is stored.
Checklist
pytestpassesruff,mypy, and schema checks passAGENTS.mdraise/exit and test names the doc, contract or issue it traces to [the twoInputErrorwraps and thecheck_skillcatch carry the cause in a comment or the message of theOSError; the tests cite More rglob/os.walk sites list or digest a directory tree and skip a subdirectory they cannot list #1168, the raises do not name an issue].github/.licenserc.yaml)