Skip to content

fix: a directory that cannot be listed is an error in four digests and file lists, not a smaller tree - #1169

Merged
antonwolfy merged 10 commits into
intel:mainfrom
antonwolfy:fix/unlistable-subdirectory
Nov 24, 2026
Merged

antonwolfy merged 10 commits into
intel:mainfrom
antonwolfy:fix/unlistable-subdirectory

Conversation

@antonwolfy

@antonwolfy antonwolfy commented Nov 23, 2026 •

Copy link
Copy Markdown
Contributor

Summary

Four places walked a directory with Path.rglob, which skips a subdirectory it cannot list (mode 0o111, as a non-root user) without an error, so a digest or a file list silently described a smaller tree. #1107 fixed the same bug in the scorecard's directory-ref digest. A skill directory with SKILL.md and references/a.md, then chmod 0o111 references, on main:

Site Before the chmod After the chmod, on main
#1103 skill_dir_digest (catalog scan skill_sha256) a digest another digest, no error
#1104 tree_sha256 (batch skill pins, skill records of a run) a digest another digest, no error
#1105 fixtures_digest (the reach matrix's fixtures_digest) a digest another digest, no error
#1106 load_bundle(f"skill:{d}", include_resources=True).files ['SKILL.md', 'references/a.md'] ['SKILL.md'], no error, other measured_digest

Now each raises PermissionError naming the directory, except the catalog scan, whose skill_dir_digest already returns None on an OSError: the row gets skill_sha256: null.

Options taken: #1103 passes strict=True to tree_digest, as the issue says. #1104, #1105 and #1106 share one helper, digest_entries.listed_entries, built on the strict walk tree_digest already has, instead of four copies of an os.walk with an onerror (a clone for scripts/check_duplicates.py). It lists what rglob("*") lists (directories included, a symlink as itself and never followed). #1106 takes the re-raise rather than an unreadable excluded entry: nothing in load_bundle surfaces an unreadable directory, and an excluded entry would still leave the measured_digest of a smaller skill. scorecard.py is left alone (#804 changes it).

A catalog scan with --resume did not rescan a skill whose digest is now null: _load_prior compared row["skill_sha256"] == selected[key], and None == None. It now keeps a prior row only when the current digest is not None. Other rglob/os.walk sites with the same cause (a digest key of a task, the skill reader of the leak gate, a skill's resources, scenarios_of) are tracked in #1168. tests/test_growth_ratchet.py already fails on main (commands/novelty.py is 801 lines): #1151.

Closes #1103
Closes #1104
Closes #1105
Closes #1106
Closes #1167

Changes

  • catalog scan: skill_sha256 omits a subdirectory it cannot list #1103: skill_dir_digest (commands/catalog_scan.py) passes strict=True; docs/catalog-jsonl.md says skill_sha256 is null when the directory or a subdirectory cannot be read. Test: tests/test_catalog_scan_unlistable.py.
  • repos/arms.tree_sha256 omits a subdirectory it cannot list #1104: digest_entries.listed_entries (new, in digest_entries.py, importable from every layer that needs it; utils.py is at its 800-line cap) and tree_sha256 (repos/arms.py) uses it; the sort by path and the path + b"\0", sha256-of-bytes fields are unchanged. Callers batch_ledger.pin_skills, workspace._install_skills and guidance_arms do not catch the error: repo run catches OSError and prints ✗ [Errno 13] Permission denied: '<skill>/<dir>', exit 1, before any cell starts (pin_skills runs before the containers). Test: tests/test_repo_arms_unlistable.py.
  • repos/conformance.fixtures_digest omits a subdirectory it cannot list #1105: fixtures_digest (repos/conformance.py) uses listed_entries; the order by relative POSIX path, the L/F tags and the length-prefixed parts are unchanged, and a link to a directory and a dangling link are hashed by their target. docs/reach-matrix.md says so. The existing walk-order test (tests/test_reach_conformance.py) reversed rglob, which the function no longer calls, so it reverses listed_entries. Test: tests/test_reach_fixtures_unlistable.py.
  • novelty load_bundle drops the files of a subdirectory it cannot list #1106: load_bundle (novelty/bundle.py) lists with listed_entries, which takes a drop predicate: a dot-named entry and a real directory named in SKIP_DIR_NAMES (.git, venv, ...) are not listed, so one that cannot be listed does not raise, as rglob skipped it before. A file named build is still read. Test: tests/test_novelty_bundle_unlistable.py.
  • catalog scan --resume keeps a row whose skill_sha256 is null, so a skill with an unlistable subdirectory is never rescanned #1167: _load_prior (commands/catalog_scan.py) keeps a prior row only when the current skill_sha256 is not None, so --resume rescans a skill whose digest is null. Test: tests/test_catalog_scan_unlistable.py.
  • tests/test_repo_arms_unlistable.py writes its SKILL.md fixture with write_bytes, so the expected digest holds on Windows, where write_text translates the newline.
  • tests/test_novelty_bundle_unlistable.py gains a test that a symlink named venv is excluded as a symlink (bundle.excluded == [("venv", "symlink")]), which pins the not path.is_symlink() clause of _not_content_dir.
  • Changelog fragments (Fixed), one per issue, and one each for the resume and the pruned directories. The catalog scan: skill_sha256 omits a subdirectory it cannot list #1103 fragment says only that skill_sha256 is null.

Risk

A directory that cannot be listed under a skill pinned by repo run, under the reach fixtures, or under a skill given to load_bundle (the novelty commands) now stops the command with the PermissionError, where it digested or loaded a smaller tree; a dot-named directory or one named in SKIP_DIR_NAMES under a skill is not listed by load_bundle, so it never raises. A catalog scan row for such a skill has skill_sha256: null where it had a digest of the smaller tree. load_bundle raises for an unlistable references directory also with include_resources=False: the bundle then holds only SKILL.md, but resource_words_on_disk counts the words of the files on disk whether they are included or not (a listable skill with 2 words in references/a.md reports 2 with include_resources=False), so the listing is part of the result. The three digests (skill_dir_digest, tree_sha256, fixtures_digest) hash every entry of the tree, .git and venv included, so an unlistable one under a skill makes skill_dir_digest return None and tree_sha256 raise; they do not prune the directories load_bundle skips, since a listable .git containing one file changes tree_sha256 and fixtures_digest too (run on both). The digest of a tree that can be listed is unchanged (pinned by an existing test and a new one for each site). listed_entries raises on a root that does not exist where rglob yielded nothing; all four callers have a root that exists.

Open PRs #1138 and #845 also change commands/catalog_scan.py and docs/catalog-jsonl.md. This PR edits the tree_digest(...) call in skill_dir_digest, the condition line in _load_prior and the skill_sha256 row of the docs table; #1138 also changes that _load_prior line, so whichever merges second resolves a one-line conflict there. #845's hunks (the rates tally and the rates row) are on other lines.

Testing

On a Linux review host, at 0798807b (on main a9d73a2):

  • make ci-local, at this tip: 35 passed, 3 failed, 15 skipped; 27045 tests passed, 1 failed. The test failure is tests/test_growth_ratchet.py::test_no_file_or_function_grew_past_its_baseline, which main fails too (commands/novelty.py is 801 lines on main, none of the change's files; tracked in novelty.py is 801 lines on main, so test_growth_ratchet fails #1151). The other two failed rows are package-smoke / Install the wheel (Could not find a version that satisfies the requirement litellm>=1.108.4: the host has no network) and the smoke test that needs that wheel. A first build run also hit a 60 s timeout in tests/test_repo_typecheck_grader.py, which the change does not touch: that file alone passes (108 passed) and the later full runs passed it. Skipped: the matrix legs on other Pythons, docker, semgrep, conda-forge, fuzz, deploy jobs.
  • Scan commits (gitleaks) passed in make ci-local at this tip.
  • On main's code the four new test files fail: test_catalog_scan_unlistable.py 1 failed, 1 passed; test_repo_arms_unlistable.py 3 failed, 2 passed (given a rglob listed_entries); test_reach_fixtures_unlistable.py 3 failed, 1 passed; test_novelty_bundle_unlistable.py 2 failed, 1 passed. The tests of a listable tree pass on both.
  • Mutants, each failing the test it targets: strict dropped in skill_dir_digest; exclude dropped there; the \0 dropped from tree_sha256; a non-strict listed_entries (8 tests of the three sites); listed_entries dropping symlinks; fixtures_digest skipping a link to a directory; load_bundle dropping its last entry; the sort of fixtures_digest removed (fails the walk-order test); load_bundle not passing its drop predicate (6 failed: an unlistable .git, venv or node_modules raises); the predicate dropping a file named build (fails test_a_file_named_like_a_skipped_directory_is_still_read); the is not None check of _load_prior removed (fails the resume test); the SKILL.md fixture of test_repo_arms_unlistable.py written with CRLF line ends (fails the digest test); the AGENTS.md fixture of test_reach_fixtures_unlistable.py written as b"x\r\n" (fails test_a_link_to_a_directory_and_a_dangling_link_are_hashed_by_their_target, as Windows' newline translation would have with write_text); _not_content_dir without its not path.is_symlink() clause (fails test_a_symlink_named_like_a_skipped_directory_is_excluded_as_a_symlink).
  • tests/test_catalog_scan_unlistable.py on main's code: the resume test with a null digest fails (kept row), as does the unlistable-subdirectory test.
  • Not run: the other Python versions (3.11, 3.12, 3.14), the tests as root (the new tests skip there: root lists a 0o111 directory), and Windows.

Open questions

None.

Revert

A plain revert restores the old behaviour (a digest of a smaller tree). Nothing is stored by this change; a catalog JSONL written meanwhile keeps its skill_sha256: null rows.

Checklist

  • Tests added/updated and pytest passes [not ticked as a full pass: test_growth_ratchet.py fails on main as well, over commands/novelty.py; the other 27044 pass]
  • 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)

…annot be listed (intel#1103)

skill_dir_digest called tree_digest without strict, so its rglob walk skipped a subdirectory it could not list (mode 0o111) without an error and the row's skill_sha256 was the digest of a smaller tree.

It now passes strict=True: the OSError makes the function return None, so the row has no skill_sha256. The digest of a listable tree is unchanged. A test pins both, and docs/catalog-jsonl.md says the field is null for a directory that cannot be read.

Signed-off-by: Anton Volkov <antonwolfy@gmail.com>
… be listed (intel#1104)

tree_sha256 walked with rglob, which skips a subdirectory it cannot list (mode 0o111) without an error, so the skill pins of a batch and the skill records of a run were the digest of a smaller tree.

A new digest_entries.listed_entries lists what rglob("*") lists (directories included, a symlink as itself and never followed) from the strict walk tree_digest already has, and raises the OSError of a directory it cannot list. tree_sha256 uses it and keeps the sort by path and the hashed fields, so the digest of a listable tree is unchanged (pinned by an existing test and a new one).

Signed-off-by: Anton Volkov <antonwolfy@gmail.com>
…nnot be listed (intel#1105)

fixtures_digest walked with rglob, which skips a directory it cannot list (mode 0o111) without an error, so the reach matrix carried the digest of a smaller fixture tree.

It now walks with digest_entries.listed_entries, which raises the OSError. The order (relative POSIX path), the L/F tags and the length-prefixed parts are kept, and a link to a directory or a dangling link is still hashed by its target. The existing walk-order test reverses listed_entries instead of rglob, which the function no longer calls.

Signed-off-by: Anton Volkov <antonwolfy@gmail.com>
…not be listed (intel#1106)

load_bundle listed a skill's files with rglob, which skips a subdirectory it cannot list (mode 0o111) without an error, so the bundle, its measured_digest and resource_words_on_disk described a smaller skill and the dropped files were not recorded as excluded.

It now lists with digest_entries.listed_entries, which raises the OSError of the directory. The order of the files, the roles and the offsets of a listable skill are unchanged.

Signed-off-by: Anton Volkov <antonwolfy@gmail.com>
…ntel#1103)

The changelog fragment and the test module docstring said `--resume` reviews a skill whose subdirectory cannot be listed again, but `_load_prior` keeps a prior row whose `skill_sha256` is null. They now say only that `skill_sha256` is null for such a skill.

Signed-off-by: Anton Volkov <antonwolfy@gmail.com>
@codecov-commenter

codecov-commenter commented Nov 23, 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.05%. Comparing base (a9d73a2) to head (0798807).
⚠️ Report is 13 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    #1169      +/-   ##
==========================================
- Coverage   96.09%   96.05%   -0.04%     
==========================================
  Files         471      475       +4     
  Lines       62270    62919     +649     
  Branches    10784    10890     +106     
==========================================
+ Hits        59837    60438     +601     
- Misses       1501     1531      +30     
- Partials      932      950      +18     
Files with missing lines Coverage Δ
dokimi/dokimi/commands/catalog_scan.py 96.45% <100.00%> (ø)
dokimi/dokimi/digest_entries.py 73.68% <100.00%> (+1.46%) ⬆️
dokimi/dokimi/novelty/bundle.py 94.40% <100.00%> (-0.75%) ⬇️
dokimi/dokimi/repos/arms.py 96.17% <100.00%> (+0.01%) ⬆️
dokimi/dokimi/repos/conformance.py 99.21% <100.00%> (+<0.01%) ⬆️

... and 25 files with indirect coverage changes

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

@exai-bot

exai-bot commented Nov 23, 2026 •

Copy link
Copy Markdown

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

CI at 0798807: 25 passing, 4 skipped.

Test notes (2)
  • dokimi/tests/test_novelty_bundle_unlistable.py: dokimi/tests/test_novelty_bundle_unlistable.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.
  • dokimi/tests/test_reach_fixtures_unlistable.py: dokimi/tests/test_reach_fixtures_unlistable.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: 0798807 against merge base aa8991f
  • Coverage: 1 files in 1 groups
  • Engine: OpenCodeReview v1.13.5-exai.4.8f73eada, us.openai.gpt-6.1-sol
  • Usage: 77k tokens (58k from cache), 27s
  • Tool calls: 7 (4 file_read, 3 code_search)
  • dokimi/tests/test_novelty_bundle_unlistable.py: 1 file

Comment thread dokimi/dokimi/commands/catalog_scan.py Resolved
Comment thread dokimi/dokimi/novelty/bundle.py Resolved
Settles the review thread on catalog_scan.py: a prior row with skill_sha256 null was kept when the current digest was null too (None == None), so a skill with an unlistable subdirectory kept its old findings after SKILL.md changed. _load_prior now keeps a row only when the current digest is not None. Closes intel#1167.

Signed-off-by: Anton Volkov <antonwolfy@gmail.com>
… content

Settles the review thread on bundle.py: listed_entries takes a drop predicate and load_bundle passes one for dot-named entries and real directories named in SKIP_DIR_NAMES, so an unlistable .git or venv is pruned before descent and does not raise.

Signed-off-by: Anton Volkov <antonwolfy@gmail.com>
Settles the review thread on test_repo_arms_unlistable.py: write_text translates the newline to CRLF on Windows, so the expected digest of b"skill\n" would not match.

Signed-off-by: Anton Volkov <antonwolfy@gmail.com>
The symlink-digest test pins the digest of b"Fx\n" and b"Fy\n", but write_text translates the newline to CRLF on Windows, so the file bytes differ from the pinned ones. The fixtures are now written with write_bytes, as the other pinned reach digest test does.

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

Copy link
Copy Markdown
Contributor Author

Review points answered at aa8991f; CI is green.

codecov has not reported on this head yet.

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

🟡 Not approved yet · reviewed aa8991f

Next: @antonwolfy: settle 2 open questions (below). 1 nit optional.

Blocking

  • Open question for @antonwolfy: In entry-point-only mode (include_resources=False), load_bundle raises PermissionError for an unlistable references directory, though the bundle holds only SKILL.md. State in docs/skill-novelty.md or the PR description that entry-point-only mode also refuses, or skip the listing when include_resources is false.
  • Open question for @antonwolfy: An unlistable .git or venv under a skill makes skill_dir_digest return None and tree_sha256 raise, while load_bundle ignores that directory. Decide whether skill digests (the catalog skill_sha256, the batch and run skill pins) skip the non-content directories as load_bundle does, and state the choice in docs/catalog-jsonl.md or the PR description.

Verified on aa8991f: ✅ changed tests: 107 passed, fail on main · ✅ full suite with main merged in: 29158 passed · ✅ merges onto main · ✅ 4 broken variants of the changed code: 4 caught by the tests · 2 mutations tried · 7 edge inputs tried

9 checks behind it, each with its evidence
Area What holds How
Listable digests The changed tests pass on the head and pin that a listable tree digests as before: tree_sha256, fixtures_digest, skill_dir_digest, and the file order and words of load_bundle for a listable skill tests on the head
Unlistable subdirectory tree_sha256 and fixtures_digest raise PermissionError for an unlistable root, subdirectory or nested directory, load_bundle raises it for an unlistable references directory, and skill_dir_digest returns None; the changed tests pass on the head and pin these tests on the head, edge input (unlistable)
Strict catalog digest Making skill_dir_digest return None unconditionally fails two of the four catalog tests on the head broke the code, tests caught it, edge input (unlistable)
Resume null digest A prior row with skill_sha256 null is not kept when the current digest is also null, so --resume rescans that skill ran it, edge input (none)
Non-ascii names A non-ASCII file references/ßé.md is bundled, and a dot-named, non-ASCII directory references/.ß that cannot be listed does not raise ran it, edge input (text)
Dangling link A dangling symlink under a skill does not change tree_sha256 ran it, edge input (paths)
Empty directory An empty directory digests as the sha256 of no bytes in both tree_sha256 and fixtures_digest ran it, edge input (collections)
Full ci The whole local CI run with main merged in passes, and no test fails on main as well full suite, main merged in
Merge The head merges onto current main with no conflict merge onto main

@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 aa8991f)

  • Contract: changed. defaults dokimi/dokimi/digest_entries.py:17; api dokimi/dokimi/digest_entries.py:listed_entries
  • Responsibility: none
  • Dependency: none
  • Review depth: check the changed surface: callers, docs, tests pin new behaviour
  • Coverage gaps: none

The four walks now surface an unlistable directory through the documented error or null digest. A null digest forces a rescan. Novelty prunes ignored directories before entering them and keeps its previous symlink policy. The outstanding test suggestion is nonblocking. T1 T5

Coverage included catalog resume, novelty exclusions, fixture hashes and arm pins using real POSIX permission changes. Windows behavior was reviewed statically. Focused tests on Python 3.13: 107 passed in 2.13s.

…s a symlink

Settles the review nit on tests/test_novelty_bundle_unlistable.py: removing the `not path.is_symlink()` clause of `_not_content_dir` left every test green and dropped a symlink named `venv` from `bundle.excluded`. The new test pins `("venv", "symlink")` in `excluded`.

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

Copy link
Copy Markdown
Contributor Author

(commented) 🟡 Not approved yet · reviewed aa8991f

@vchamarthi (#1169 (review)): Both open questions are answered in the PR description (Risk section), no code change. Entry-point-only mode: resource_words_on_disk counts the words of the files on disk whether they are included or not (a skill with 2 words in references/a.md reports 2 with include_resources=False), so the listing is part of that mode's result and an unlistable references raises there too; the test test_a_subdirectory_that_cannot_be_listed_raises runs both modes. Skill digests: they hash every entry, .git and venv included (a .git with one file changes tree_sha256 and fixtures_digest, run on both), so an unlistable one makes skill_dir_digest return None and tree_sha256 raise; they do not skip the directories load_bundle skips, and docs/catalog-jsonl.md already says skill_sha256 is null when a subdirectory cannot be read.

@antonwolfy

Copy link
Copy Markdown
Contributor Author

(approved) ### Change class: CONTRACT (head aa8991f)

@napetrov (#1169 (review)): Approval; no change asked. The nonblocking test suggestion (T5) is the symlink-named-venv test added in 0798807.

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

Labels

None yet

Projects

None yet

5 participants