Repository navigation
fix: a directory that cannot be listed is an error in four digests and file lists, not a smaller tree - #1169
Conversation
…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 Report✅ All modified and coverable lines are covered by tests. 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
🚀 New features to boost your workflow:
|
|
✅ OpenCodeReview: Review complete: 0 finding(s) across 1 selected item(s). CI at Test notes (2)
Review details
|
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>
|
Review points answered at codecov has not reported on this head yet. |
vchamarthi
left a comment
There was a problem hiding this comment.
🟡 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_bundleraisesPermissionErrorfor an unlistablereferencesdirectory, though the bundle holds onlySKILL.md. State indocs/skill-novelty.mdor the PR description that entry-point-only mode also refuses, or skip the listing wheninclude_resourcesis false. - Open question for @antonwolfy: An unlistable
.gitorvenvunder a skill makesskill_dir_digestreturn None andtree_sha256raise, whileload_bundleignores that directory. Decide whether skill digests (the catalogskill_sha256, the batch and run skill pins) skip the non-content directories asload_bundledoes, and state the choice indocs/catalog-jsonl.mdor 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
left a comment
There was a problem hiding this comment.
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>
@vchamarthi (#1169 (review)): Both open questions are answered in the PR description (Risk section), no code change. Entry-point-only mode: |
@napetrov (#1169 (review)): Approval; no change asked. The nonblocking test suggestion (T5) is the symlink-named- |
Summary
Four places walked a directory with
Path.rglob, which skips a subdirectory it cannot list (mode0o111, 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 withSKILL.mdandreferences/a.md, thenchmod 0o111 references, onmain:mainskill_dir_digest(catalog scanskill_sha256)tree_sha256(batch skill pins, skill records of a run)fixtures_digest(the reach matrix'sfixtures_digest)load_bundle(f"skill:{d}", include_resources=True).files['SKILL.md', 'references/a.md']['SKILL.md'], no error, othermeasured_digestNow each raises
PermissionErrornaming the directory, except the catalog scan, whoseskill_dir_digestalready returns None on anOSError: the row getsskill_sha256: null.Options taken: #1103 passes
strict=Truetotree_digest, as the issue says. #1104, #1105 and #1106 share one helper,digest_entries.listed_entries, built on the strict walktree_digestalready has, instead of four copies of anos.walkwith anonerror(a clone forscripts/check_duplicates.py). It lists whatrglob("*")lists (directories included, a symlink as itself and never followed). #1106 takes the re-raise rather than anunreadableexcluded entry: nothing inload_bundlesurfaces an unreadable directory, and an excluded entry would still leave themeasured_digestof a smaller skill.scorecard.pyis left alone (#804 changes it).A catalog scan with
--resumedid not rescan a skill whose digest is now null:_load_priorcomparedrow["skill_sha256"] == selected[key], andNone == None. It now keeps a prior row only when the current digest is not None. Otherrglob/os.walksites with the same cause (a digest key of a task, the skill reader of the leak gate, a skill'sresources,scenarios_of) are tracked in #1168.tests/test_growth_ratchet.pyalready fails onmain(commands/novelty.pyis 801 lines): #1151.Closes #1103
Closes #1104
Closes #1105
Closes #1106
Closes #1167
Changes
skill_dir_digest(commands/catalog_scan.py) passesstrict=True;docs/catalog-jsonl.mdsaysskill_sha256is null when the directory or a subdirectory cannot be read. Test:tests/test_catalog_scan_unlistable.py.digest_entries.listed_entries(new, indigest_entries.py, importable from every layer that needs it;utils.pyis at its 800-line cap) andtree_sha256(repos/arms.py) uses it; the sort by path and thepath + b"\0", sha256-of-bytes fields are unchanged. Callersbatch_ledger.pin_skills,workspace._install_skillsandguidance_armsdo not catch the error:repo runcatchesOSErrorand prints✗ [Errno 13] Permission denied: '<skill>/<dir>', exit 1, before any cell starts (pin_skillsruns before the containers). Test:tests/test_repo_arms_unlistable.py.fixtures_digest(repos/conformance.py) useslisted_entries; the order by relative POSIX path, theL/Ftags 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.mdsays so. The existing walk-order test (tests/test_reach_conformance.py) reversedrglob, which the function no longer calls, so it reverseslisted_entries. Test:tests/test_reach_fixtures_unlistable.py.load_bundle(novelty/bundle.py) lists withlisted_entries, which takes adroppredicate: a dot-named entry and a real directory named inSKIP_DIR_NAMES(.git,venv, ...) are not listed, so one that cannot be listed does not raise, asrglobskipped it before. A file namedbuildis still read. Test:tests/test_novelty_bundle_unlistable.py._load_prior(commands/catalog_scan.py) keeps a prior row only when the currentskill_sha256is not None, so--resumerescans a skill whose digest is null. Test:tests/test_catalog_scan_unlistable.py.tests/test_repo_arms_unlistable.pywrites itsSKILL.mdfixture withwrite_bytes, so the expected digest holds on Windows, wherewrite_texttranslates the newline.tests/test_novelty_bundle_unlistable.pygains a test that a symlink namedvenvis excluded as asymlink(bundle.excluded == [("venv", "symlink")]), which pins thenot path.is_symlink()clause of_not_content_dir.skill_sha256is null.Risk
A directory that cannot be listed under a skill pinned by
repo run, under the reach fixtures, or under a skill given toload_bundle(the novelty commands) now stops the command with thePermissionError, where it digested or loaded a smaller tree; a dot-named directory or one named inSKIP_DIR_NAMESunder a skill is not listed byload_bundle, so it never raises. A catalog scan row for such a skill hasskill_sha256: nullwhere it had a digest of the smaller tree.load_bundleraises for an unlistablereferencesdirectory also withinclude_resources=False: the bundle then holds onlySKILL.md, butresource_words_on_diskcounts the words of the files on disk whether they are included or not (a listable skill with 2 words inreferences/a.mdreports 2 withinclude_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,.gitandvenvincluded, so an unlistable one under a skill makesskill_dir_digestreturn None andtree_sha256raise; they do not prune the directoriesload_bundleskips, since a listable.gitcontaining one file changestree_sha256andfixtures_digesttoo (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_entriesraises on a root that does not exist whererglobyielded nothing; all four callers have a root that exists.Open PRs #1138 and #845 also change
commands/catalog_scan.pyanddocs/catalog-jsonl.md. This PR edits thetree_digest(...)call inskill_dir_digest, the condition line in_load_priorand theskill_sha256row of the docs table; #1138 also changes that_load_priorline, so whichever merges second resolves a one-line conflict there. #845's hunks (the rates tally and theratesrow) are on other lines.Testing
On a Linux review host, at
0798807b(onmaina9d73a2):make ci-local, at this tip: 35 passed, 3 failed, 15 skipped; 27045 tests passed, 1 failed. The test failure istests/test_growth_ratchet.py::test_no_file_or_function_grew_past_its_baseline, whichmainfails too (commands/novelty.pyis 801 lines onmain, 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 arepackage-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 intests/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 inmake ci-localat this tip.main's code the four new test files fail:test_catalog_scan_unlistable.py1 failed, 1 passed;test_repo_arms_unlistable.py3 failed, 2 passed (given argloblisted_entries);test_reach_fixtures_unlistable.py3 failed, 1 passed;test_novelty_bundle_unlistable.py2 failed, 1 passed. The tests of a listable tree pass on both.skill_dir_digest;excludedropped there; the\0dropped fromtree_sha256; a non-strictlisted_entries(8 tests of the three sites);listed_entriesdropping symlinks;fixtures_digestskipping a link to a directory;load_bundledropping its last entry; the sort offixtures_digestremoved (fails the walk-order test);load_bundlenot passing itsdroppredicate (6 failed: an unlistable.git,venvornode_modulesraises); the predicate dropping a file namedbuild(failstest_a_file_named_like_a_skipped_directory_is_still_read); theis not Nonecheck of_load_priorremoved (fails the resume test); theSKILL.mdfixture oftest_repo_arms_unlistable.pywritten with CRLF line ends (fails the digest test); theAGENTS.mdfixture oftest_reach_fixtures_unlistable.pywritten asb"x\r\n"(failstest_a_link_to_a_directory_and_a_dangling_link_are_hashed_by_their_target, as Windows' newline translation would have withwrite_text);_not_content_dirwithout itsnot path.is_symlink()clause (failstest_a_symlink_named_like_a_skipped_directory_is_excluded_as_a_symlink).tests/test_catalog_scan_unlistable.pyonmain's code: the resume test with a null digest fails (kept row), as does the unlistable-subdirectory test.0o111directory), 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: nullrows.Checklist
pytestpasses [not ticked as a full pass:test_growth_ratchet.pyfails onmainas well, overcommands/novelty.py; the other 27044 pass]ruff,mypy, and schema checks passAGENTS.mdraise/exit and test names the doc, contract or issue it traces to.github/.licenserc.yaml)