Skip to content

fix(skills): a directory that cannot be listed is an error in seven more digests, file lists and checks - #1211

Open
antonwolfy wants to merge 3 commits into
intel:mainfrom
antonwolfy:fix/unlistable-dir-sites
Open

antonwolfy wants to merge 3 commits into
intel:mainfrom
antonwolfy:fix/unlistable-dir-sites

Conversation

@antonwolfy

@antonwolfy antonwolfy commented Nov 25, 2026 •

Copy link
Copy Markdown
Contributor

Summary

Path.rglob and an os.walk with no onerror skip a subdirectory that cannot be listed (mode 0o111, 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). On main, with a skill directory holding SKILL.md and a references/ directory of two files, and chmod 111 references:

Site Listable references/ (or the task's environment/) unlistable, on main
harbor_export._content_key (cache key of an exported task) 0ff7dfe6ee3e21e2 bd2288aa5ad8b92f, no error
leakgate.read_skill (files the leak gate indexes) ['SKILL.md', 'references/a.md'] ['SKILL.md'], so a leak in the dropped file is not found
loader.load_skill resources ['references/a.md'] []
formats.detect_skill_packages (catalog formats) a skill and a plugin manifest the skill only
conformance.scenarios_of cwd=., cwd=sub, read=sub cwd=. only
arms._uncopyable (link check of a skill arm) links outside it for a link in the directory None, the link is not checked
leak._refuse_clobber (eval leak output-overwrite guard) refuses an --out that is a file of the skill does not refuse it

The fix taken is the first option the issue gives, applied per site: list with digest_entries.listed_entries (or an os.walk whose onerror re-raises), so the OSError of the directory is raised where each site already raises OSError or returns a digest, a key or a list, never a smaller value and never a warning. Entries a site already left out (.git and a top-level evals 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.

The same search over every rglob and os.walk under dokimi/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.py load_skill, skills/formats.py detect_skill_packages and repos/conformance.py scenarios_of list with listed_entries; eval/leakgate.py read_skill does too (its docstring already says it raises OSError), with drop for the entries it left out; repos/arms.py _uncopyable walks with an onerror that re-raises.
  • leak._refuse_clobber returns before it lists the skill when no file is written (no --out and no lock), so a stdout-only eval leak is not stopped by an unlistable evals/ that read_skill leaves out; with an --out or a lock the listing stays strict.
  • load_skill still leaves out __pycache__, and a dot-named or vendored directory (.git, venv, node_modules) that cannot be listed, as novelty.bundle does 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 before.
  • Callers: skill_treatment.check_skill wraps the OSError of load_skill in the ValueError it documents (it caught only FileNotFoundError); catalog formats and eval leak (_refuse_clobber) turn it into an InputError, 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 run already catches OSError around the arm check.
  • Existing tests changed to pin the new outcome: test_catalog_command_checks.py::test_an_unreadable_subdirectory_does_not_abort_the_scan and test_catalog_bundle_unreferenced.py::test_an_unreadable_folder_withholds_the_claim asserted a review with a bundle-file-unchecked note 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_error asserted check_skill returned the name; it now asserts a cannot load skill ValueError that is not a loop error. The hidden-folder note (.cache) and the vendored cases are unchanged.
  • treatments.factory._build 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 an arm spec that names such a skill is refused instead of ending in a traceback.
  • A discover_skills call fails for the whole catalog when one skill has a folder that cannot be listed: catalog trigger-probe --catalog exits 2 and names the folder, and a skill-catalog: arm is a ValueError; catalog scan instead makes that skill an error row and goes on (run on a catalog of one skill with an unlistable references/: trigger-probe exit 2 --catalog: [Errno 13] Permission denied: .../references, catalog check --per-skill one skill in state error).
  • Docs: external-content.md (the bundle-file-unchecked note is for a hidden folder; another folder that cannot be listed makes the skill an error row) and evaluating-treatments.md (the leak gate).
  • Changelog fragment (Fixed).

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 leak and catalog formats exit 2 with the directory named, a catalog scan reports the skill as an error row (before, a review with a bundle-file-unchecked note), repo run refuses a skill arm, a Harbor export raises PermissionError, and check_skill fails the cell before the image build. A directory with no read permission as root, or on a file system with no modes, lists as before. The output for a tree that can be listed is unchanged, including the Harbor cache key, so no cached export is invalidated. The two surviving mutants of the changed-lines job are False becoming None in the _not_listed_as_resource predicate, which both are falsy: equivalent.

Open PRs that change the same files (#1190, #1193, #1197, #1171, #1158, #1039) change other lines: #1190 rewrites the InputError and parse_frontmatter import lines of commands/leak.py, commands/catalog.py and harnesses/skill_treatment.py, which this change leaves alone (it adds its own import line in leak.py with the unchanged exit_codes import between the two), and the others change other hunks of catalog.py, external-content.md and evaluating-treatments.md, so a merge with any of them meets no conflicting hunk.

Testing

On a Linux review host, at 2229e530 (on main 602de14):

  • make ci-local: 38 passed, 0 failed, 15 skipped (docker and network steps, other Python versions, semgrep, matrix jobs of other workflows). 28404 tests passed, 23 skipped; changed-line coverage 100% (50 lines).
  • New tests test_a_skill_arm_with_a_folder_that_cannot_be_listed_is_refused_as_a_value_error (skill: and skill-agent:) and test_a_skill_catalog_arm_with_a_folder_that_cannot_be_listed_is_refused_as_a_value_error: with the except PermissionError of both wraps changed to FileNotFoundError, 3 failed, 19 passed, each failing on the PermissionError from load_skill or discover_skills.
  • test_leak_output_guard_does_not_list_the_skill_when_no_file_is_written: with the early return replaced by if False, it fails (the guard raises InputError on the unlistable evals/ with no output).
  • New tests/test_unlistable_sites.py (19 tests): on main's code 9 failed, 9 passed; the nine that fail are the unlistable-directory tests of the seven sites, of catalog formats and of check_skill, first on DID 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 give 3 failed, 342 passed on main's code.
  • Mutants: 17 changes (restoring rglob or dropping onerror at each of the seven sites, dropping each drop clause, the dot-named and vendored carve-out, the InputError wraps, the check_skill catch, the \0 of the key) each fail the test that pins them.
  • Mutation of changed lines (CI job): 37 mutants, 35 killed, 2 survived (equivalent, above).
  • Not run: the other Python versions (3.11, 3.12, 3.14), Windows (the tests skip when the process lists a mode 111 directory), the docker and network steps of make ci-local.

Open questions

What a doc source (local: and okf:) should do with a directory it cannot list: the code raises MCPConnectionError for a missing path, skips an unreadable file at debug level and warns on no files, and docs/adding-doc-source.md says 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

  • 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 [the two InputError wraps and the check_skill catch carry the cause in a comment or the message of the OSError; 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]
  • No ad-hoc run artifacts committed
  • New files carry the SPDX license header (or are exempt in .github/.licenserc.yaml)

…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>
@exai-bot

exai-bot commented Nov 25, 2026 •

Copy link
Copy Markdown

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

CI at 2229e53: 25 passing, 4 skipped.

Test notes (1)
  • dokimi/tests/test_unlistable_sites.py: dokimi/tests/test_unlistable_sites.py passes at the head and also at the merge base, where the code this pull request changes is still as it was. No test in it fails without the change, so none of them would notice if the change were undone.
Review details
  • Commit reviewed: 2229e53 against merge base 602de14
  • Coverage: 17 files in 4 groups
  • Engine: OpenCodeReview v1.13.5-exai.4.8f73eada, us.openai.gpt-6.1-sol
  • Usage: 549k tokens (397k from cache), 36s
  • Tool calls: 56 (38 file_read, 9 code_search, 3 file_read_diff, 3 local_check_results, 2 ci_status, 1 file_find)
  • Unlistable skill sites: loading, formats, documentation, and tests: 5 files
  • Repository catalog and conformance checks: 5 files
  • Leak evaluation and treatment evaluation documentation: 3 files
  • Treatment creation, harness integration, and tests: 4 files

@codecov-commenter

codecov-commenter commented Nov 25, 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.13%. Comparing base (602de14) to head (2229e53).
⚠️ Report is 34 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    #1211      +/-   ##
==========================================
+ Coverage   96.07%   96.13%   +0.05%     
==========================================
  Files         496      498       +2     
  Lines       65209    66035     +826     
  Branches    11317    11463     +146     
==========================================
+ Hits        62652    63480     +828     
+ Misses       1583     1579       -4     
- Partials      974      976       +2     
Files with missing lines Coverage Δ
dokimi/dokimi/commands/catalog.py 99.09% <100.00%> (+<0.01%) ⬆️
dokimi/dokimi/commands/leak.py 100.00% <100.00%> (ø)
dokimi/dokimi/eval/leakgate.py 99.05% <100.00%> (+<0.01%) ⬆️
dokimi/dokimi/harnesses/harbor_export.py 91.37% <100.00%> (+0.07%) ⬆️
dokimi/dokimi/harnesses/skill_treatment.py 96.44% <100.00%> (ø)
dokimi/dokimi/repos/arms.py 96.22% <100.00%> (+0.03%) ⬆️
dokimi/dokimi/repos/conformance.py 99.21% <100.00%> (ø)
dokimi/dokimi/skills/formats.py 94.59% <100.00%> (+1.65%) ⬆️
dokimi/dokimi/skills/loader.py 100.00% <100.00%> (ø)
dokimi/dokimi/treatments/factory.py 100.00% <100.00%> (ø)

... and 78 files with indirect coverage changes

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

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

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.

Comment thread dokimi/dokimi/commands/leak.py Resolved
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>
@antonwolfy

Copy link
Copy Markdown
Contributor Author

(commented) ### Change class: CONTRACT (head 3983a66)

@napetrov (#1211 (review)): Review body; its one finding is the thread 4699602155, fixed in 45271c1.

@antonwolfy

Copy link
Copy Markdown
Contributor Author

Ready for another look at 45271c1; CI is green.

codecov has not reported on this head yet.

@antonwolfy
antonwolfy requested a review from napetrov November 25, 2026 20:43

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

@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_skills call now fails for the whole catalog when one skill has a folder that cannot be listed: catalog probe --catalog exits 2 and names the folder, while catalog scan makes 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.

Comment thread dokimi/dokimi/skills/loader.py Resolved
Comment thread dokimi/docs/external-content.md Resolved
…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>
@antonwolfy

Copy link
Copy Markdown
Contributor Author

(commented) @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.

@vchamarthi (#1211 (review)): The two line comments are done in 2229e53. On the question: yes, a discover_skills call fails for the whole catalog. I ran a catalog of one skill with an unlistable references/: catalog trigger-probe --catalog exits 2 with --catalog: [Errno 13] Permission denied: .../references, a skill-catalog: arm is now a ValueError, and catalog check --per-skill makes that skill one error row and goes on. The PR description now says so.

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

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.

skill = load_skill(part.arg)
try:
skill = load_skill(part.arg)
except PermissionError as exc:

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.

blocking: Could both factory branches translate directory listing failures consistently? I simulated an I/O error (EIO) only while listing a skill’s references directory. Both skill: and skill-catalog: leaked raw OSError on this commit; on the merge base both arms constructed. The new strict listing is intended, but subjects run only translates ValueError in _run_plan, so this case escapes as a traceback. Please translate the listing error into an arm-specific validation error while preserving the existing behavior for a missing SKILL.md, and cover a non-permission listing failure.

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

@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) and dokimi/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.

if not outputs:
return # nothing is written, so the walk below would only list what read_skill leaves out
skill_root = Path(args.skill)
if skill_root.is_file():

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.

Must fix (blocking): With a skill folder as --skill, an existing --out file in a sibling folder is refused as an input, and no test catches that.
Input: --skill is a skill folder, and --out is an existing file, other/leak.json, in a sibling folder.
Got: The guard accepts it now, which is what I'd expect, since it is not an input of the run.

Suggestion: Add that case to tests/test_unlistable_sites.py beside test_leak_output_guard_refuses_when_it_cannot_list_the_skill.

I tested this patch: it fixes the problem, and the tests still pass.

Patch
--- a/dokimi/tests/test_unlistable_sites.py
+++ b/dokimi/tests/test_unlistable_sites.py
@@ -189,3 +189,9 @@
         _refuse_clobber(_clobber_args(skill, skill / "references" / "a.md"), None)
     with unlistable(skill / "references"), pytest.raises(InputError, match="references"):
         _refuse_clobber(_clobber_args(skill, elsewhere), None)
+
+
+def test_leak_output_guard_accepts_an_existing_output_beside_a_skill_folder(tmp_path: Path):
+    skill = _skill(tmp_path)
+    other = _write(tmp_path / "other", {"leak.json": "{}"})
+    _refuse_clobber(_clobber_args(skill, other / "leak.json"), None)
Details

If I change if skill_root.is_file(): to if not (skill_root.is_file()):, the guard lists the parent folder, refuses other/leak.json as an input, and every test in the changed files still passes. The assert that would catch it: with other/leak.json present, _refuse_clobber(_clobber_args(skill, other / "leak.json"), None) must not raise.

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

More rglob/os.walk sites list or digest a directory tree and skip a subdirectory they cannot list

5 participants