Repository navigation
fix: a directory that cannot be listed is an error in four digests and file lists, not a smaller tree #1169
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
antonwolfy
merged 10 commits into
intel:main
from
antonwolfy:fix/unlistable-subdirectory
Nov 24, 2026
Merged
Changes from all commits
Commits
Show all changes
10 commits
Select commit
Hold shift + click to select a range
a6d670a
fix(catalog): skill_sha256 is null when a subdirectory of the skill c…
antonwolfy 5a34cbb
fix(repo): tree_sha256 raises when a subdirectory of the skill cannot…
antonwolfy f364041
fix(repo): fixtures_digest raises when a directory of the fixtures ca…
antonwolfy 995059b
fix(novelty): load_bundle raises when a subdirectory of the skill can…
antonwolfy f14e8de
docs(catalog): the skill_sha256 fragment claims only a null digest (#…
antonwolfy 20992fa
fix(catalog): --resume rescans a skill whose digest is null
antonwolfy f29f71c
fix(novelty): load_bundle does not list a directory that is not skill…
antonwolfy e018f9c
test(repo): the tree_sha256 fixture writes SKILL.md as bytes
antonwolfy aa8991f
test(reach): the fixtures_digest fixtures are written as bytes
antonwolfy 0798807
test(novelty): a symlink named like a skipped directory is excluded a…
antonwolfy File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
8 changes: 8 additions & 0 deletions
8
dokimi/changelog.d/20261123_130000_catalog-scan-unlistable-subdir.md
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,8 @@ | ||
| <!-- | ||
| Copyright (C) 2026 Intel Corporation | ||
| SPDX-License-Identifier: Apache-2.0 | ||
| --> | ||
|
|
||
| ### Fixed | ||
|
|
||
| - **A catalog scan row has no `skill_sha256` when a subdirectory of the skill cannot be listed** — `skill_dir_digest` walked with `Path.rglob`, which skips a subdirectory it cannot list (mode `0o111`) without an error, so the row carried a digest of a smaller tree. The walk is now strict: `skill_sha256` is `null`. The digest of a tree that can be listed is unchanged. |
8 changes: 8 additions & 0 deletions
8
dokimi/changelog.d/20261123_130100_arms-tree-sha256-unlistable-subdir.md
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,8 @@ | ||
| <!-- | ||
| Copyright (C) 2026 Intel Corporation | ||
| SPDX-License-Identifier: Apache-2.0 | ||
| --> | ||
|
|
||
| ### Fixed | ||
|
|
||
| - **The skill digests of a repo arms run raise when a subdirectory cannot be listed** — `tree_sha256` (the skill pins of a batch, the skill records of a run) walked with `Path.rglob`, which skips a subdirectory it cannot list (mode `0o111`) without an error, so it digested a smaller tree. It now raises `PermissionError` naming the directory. The digest of a tree that can be listed is unchanged. |
8 changes: 8 additions & 0 deletions
8
dokimi/changelog.d/20261123_130200_reach-fixtures-digest-unlistable-subdir.md
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,8 @@ | ||
| <!-- | ||
| Copyright (C) 2026 Intel Corporation | ||
| SPDX-License-Identifier: Apache-2.0 | ||
| --> | ||
|
|
||
| ### Fixed | ||
|
|
||
| - **The reach matrix's `fixtures_digest` raises when a directory of the fixtures cannot be listed** — it walked with `Path.rglob`, which skips a directory it cannot list (mode `0o111`) without an error, so the matrix carried the digest of a smaller fixture tree. It now raises `PermissionError` naming the directory. The digest of a tree that can be listed is unchanged, and a link (to a directory too, or dangling) is still hashed by its target. |
8 changes: 8 additions & 0 deletions
8
dokimi/changelog.d/20261123_130300_novelty-bundle-unlistable-subdir.md
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,8 @@ | ||
| <!-- | ||
| Copyright (C) 2026 Intel Corporation | ||
| SPDX-License-Identifier: Apache-2.0 | ||
| --> | ||
|
|
||
| ### Fixed | ||
|
|
||
| - **A novelty bundle raises when a subdirectory of the skill cannot be listed** — `load_bundle` listed the skill's files with `Path.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 raises `PermissionError` naming the directory. A skill that can be listed loads as before. |
8 changes: 8 additions & 0 deletions
8
dokimi/changelog.d/20261123_140000_catalog-resume-null-digest.md
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,8 @@ | ||
| <!-- | ||
| Copyright (C) 2026 Intel Corporation | ||
| SPDX-License-Identifier: Apache-2.0 | ||
| --> | ||
|
|
||
| ### Fixed | ||
|
|
||
| - **`catalog scan --resume` rescans a skill whose digest is null** — a prior row with `skill_sha256: null` was kept when the skill's digest is null now too (`None == None`), so a skill with an unlistable subdirectory kept its old findings after `SKILL.md` changed. It is rescanned. |
8 changes: 8 additions & 0 deletions
8
dokimi/changelog.d/20261123_140100_novelty-bundle-skips-non-content-dirs.md
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,8 @@ | ||
| <!-- | ||
| Copyright (C) 2026 Intel Corporation | ||
| SPDX-License-Identifier: Apache-2.0 | ||
| --> | ||
|
|
||
| ### Fixed | ||
|
|
||
| - **A novelty bundle does not list a directory that is not skill content** — `load_bundle` lists a skill's files strictly, and skips a dot-named directory or one named in `SKIP_DIR_NAMES` (`.git`, `venv`, ...) before it is listed, so one of those that cannot be listed does not stop the skill from loading. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,65 @@ | ||
| # Copyright (C) 2026 Intel Corporation | ||
| # SPDX-License-Identifier: Apache-2.0 | ||
|
|
||
| """#1103: ``skill_dir_digest`` is None for a skill directory with a subdirectory it cannot list, not a digest of a smaller tree. | ||
|
|
||
| ``skill_sha256`` of a catalog row is None then. | ||
| """ | ||
|
|
||
| from __future__ import annotations | ||
|
|
||
| import json | ||
| import os | ||
| from pathlib import Path | ||
| from types import SimpleNamespace | ||
|
|
||
| import pytest | ||
|
|
||
| from dokimi import __version__ | ||
| from dokimi.commands.catalog_scan import _load_prior, skill_dir_digest | ||
| from dokimi.utils import tree_digest | ||
|
|
||
|
|
||
| def _skill(tmp_path: Path) -> Path: | ||
| skill = tmp_path / "skill" | ||
| (skill / "sub").mkdir(parents=True) | ||
| (skill / "SKILL.md").write_text("---\nname: skill\ndescription: d\n---\nbody\n", encoding="utf-8") | ||
| (skill / "sub" / "b.txt").write_text("b", encoding="utf-8") | ||
| return skill | ||
|
|
||
|
|
||
| def _entry(skill: Path) -> SimpleNamespace: | ||
| return SimpleNamespace(loaded=False, skill=None, path=skill) | ||
|
|
||
|
|
||
| @pytest.mark.skipif(not hasattr(os, "geteuid") or os.geteuid() == 0, reason="root lists a mode 111 directory") | ||
| def test_a_skill_with_a_subdirectory_that_cannot_be_listed_has_no_digest(tmp_path: Path): | ||
| skill = _skill(tmp_path) | ||
| complete = skill_dir_digest(_entry(skill)) | ||
| assert complete is not None | ||
| (skill / "sub").chmod(0o111) | ||
| try: | ||
| assert skill_dir_digest(_entry(skill)) is None | ||
| finally: | ||
| (skill / "sub").chmod(0o700) | ||
| assert skill_dir_digest(_entry(skill)) == complete | ||
|
|
||
|
|
||
| @pytest.mark.parametrize(("digest", "kept"), [(None, False), ("abc", True)]) | ||
| def test_resume_keeps_a_prior_row_only_when_its_digest_is_a_digest(tmp_path: Path, digest: str | None, kept: bool): | ||
| row = {"name": "skill", "relpath": "skill", "state": "ok", "error": None, "findings": [], "content_sha256": None, | ||
| "skill_sha256": digest, "listing_chars": 1, "listing_name": "skill", "ignored": [], | ||
| "dokimi_version": __version__} | ||
| jsonl = tmp_path / "scan.jsonl" | ||
| jsonl.write_text(json.dumps(row) + "\n", encoding="utf-8") | ||
| rows, dirty = _load_prior(jsonl, {"skill": digest}, frozenset()) | ||
| assert (rows == [row], dirty) == (kept, not kept) | ||
|
|
||
|
|
||
| def test_a_listable_skill_digests_as_the_non_strict_walk_did(tmp_path: Path): | ||
| skill = _skill(tmp_path) | ||
| (skill / "eval").mkdir() | ||
| (skill / "eval" / "out.jsonl").write_text("{}", encoding="utf-8") | ||
| out = (skill / "eval" / "out.jsonl").resolve() | ||
| assert skill_dir_digest(_entry(skill), [out]) == tree_digest(skill, exclude=["eval/out.jsonl"], tracked={}) | ||
| assert skill_dir_digest(_entry(skill)) == tree_digest(skill, tracked={}) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,72 @@ | ||
| # Copyright (C) 2026 Intel Corporation | ||
| # SPDX-License-Identifier: Apache-2.0 | ||
|
|
||
| """#1106: ``load_bundle`` raises for a skill subdirectory it cannot list, not a bundle of a smaller skill.""" | ||
|
|
||
| from __future__ import annotations | ||
|
|
||
| import os | ||
| from pathlib import Path | ||
|
|
||
| import pytest | ||
|
|
||
| from dokimi.novelty.bundle import load_bundle | ||
|
|
||
|
|
||
| def _skill(tmp_path: Path) -> Path: | ||
| skill = tmp_path / "skill" | ||
| (skill / "references").mkdir(parents=True) | ||
| (skill / "SKILL.md").write_text("---\nname: skill\ndescription: d\n---\nUse the references.\n", encoding="utf-8") | ||
| (skill / "references" / "a.md").write_text("alpha beta gamma\n", encoding="utf-8") | ||
| return skill | ||
|
|
||
|
|
||
| @pytest.mark.skipif(not hasattr(os, "geteuid") or os.geteuid() == 0, reason="root lists a mode 111 directory") | ||
| @pytest.mark.parametrize("include_resources", [True, False]) | ||
| def test_a_subdirectory_that_cannot_be_listed_raises(tmp_path: Path, include_resources: bool): | ||
| skill = _skill(tmp_path) | ||
| (skill / "references").chmod(0o111) | ||
| try: | ||
| with pytest.raises(PermissionError, match="references"): | ||
| load_bundle(f"skill:{skill}", include_resources=include_resources) | ||
| finally: | ||
| (skill / "references").chmod(0o700) | ||
| assert [f.path for f in load_bundle(f"skill:{skill}", include_resources=True).files] == ["SKILL.md", "references/a.md"] | ||
|
|
||
|
|
||
| @pytest.mark.skipif(not hasattr(os, "geteuid") or os.geteuid() == 0, reason="root lists a mode 111 directory") | ||
| @pytest.mark.parametrize("name", [".git", "venv", "node_modules"]) | ||
| @pytest.mark.parametrize("include_resources", [True, False]) | ||
| def test_a_directory_that_is_not_content_is_not_listed(tmp_path: Path, name: str, include_resources: bool): | ||
| skill = _skill(tmp_path) | ||
| (skill / name).mkdir() | ||
| (skill / name).chmod(0o111) | ||
| try: | ||
| bundle = load_bundle(f"skill:{skill}", include_resources=include_resources) | ||
| finally: | ||
| (skill / name).chmod(0o700) | ||
| assert [f.path for f in bundle.files] == (["SKILL.md", "references/a.md"] if include_resources else ["SKILL.md"]) | ||
|
|
||
|
|
||
| def test_a_file_named_like_a_skipped_directory_is_still_read(tmp_path: Path): | ||
| skill = _skill(tmp_path) | ||
| (skill / "references" / "build").write_text("one two\n", encoding="utf-8") | ||
| assert [f.path for f in load_bundle(f"skill:{skill}", include_resources=True).files] == [ | ||
| "SKILL.md", "references/a.md", "references/build"] | ||
|
|
||
|
|
||
| def test_a_listable_skill_keeps_its_files_digest_and_words_on_disk(tmp_path: Path): | ||
| skill = _skill(tmp_path) | ||
| (skill / "references" / "deeper").mkdir() | ||
| (skill / "references" / "deeper" / "b.md").write_text("delta\n", encoding="utf-8") | ||
| bundle = load_bundle(f"skill:{skill}", include_resources=True) | ||
| assert [(f.path, f.role) for f in bundle.files] == [ | ||
| ("SKILL.md", "entry_point"), ("references/a.md", "reference"), ("references/deeper/b.md", "reference")] | ||
| assert bundle.resource_words_on_disk == 4 | ||
|
antonwolfy marked this conversation as resolved.
Resolved
|
||
|
|
||
|
|
||
| def test_a_symlink_named_like_a_skipped_directory_is_excluded_as_a_symlink(tmp_path: Path): | ||
| skill = _skill(tmp_path) | ||
| (skill / "venv").symlink_to("references") | ||
| bundle = load_bundle(f"skill:{skill}", include_resources=True) | ||
| assert [(row["path"], row["reason"]) for row in bundle.excluded] == [("venv", "symlink")] | ||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,53 @@ | ||
| # Copyright (C) 2026 Intel Corporation | ||
| # SPDX-License-Identifier: Apache-2.0 | ||
|
|
||
| """#1105: ``fixtures_digest`` raises for a directory it cannot list, not a digest of a smaller fixture tree. | ||
|
|
||
| The digest is the matrix's ``fixtures_digest`` (docs/reach-matrix.md): matrices with different digests are not merged. | ||
| """ | ||
|
|
||
| from __future__ import annotations | ||
|
|
||
| import hashlib | ||
| import os | ||
| from pathlib import Path | ||
|
|
||
| import pytest | ||
|
|
||
| from dokimi.repos import conformance as cf | ||
|
|
||
|
|
||
| def _tree(tmp_path: Path) -> Path: | ||
| tree = tmp_path / "t" | ||
| (tree / "case" / "sub").mkdir(parents=True) | ||
| (tree / "case" / "AGENTS.md").write_bytes(b"x\n") | ||
| (tree / "case" / "sub" / "CLAUDE.md").write_bytes(b"y\n") | ||
| return tree | ||
|
|
||
|
|
||
| @pytest.mark.skipif(not hasattr(os, "geteuid") or os.geteuid() == 0, reason="root lists a mode 111 directory") | ||
| @pytest.mark.parametrize("parts", [(), ("case",), ("case", "sub")]) # the fixtures root, a case, a directory below a listable one | ||
| def test_a_directory_that_cannot_be_listed_raises(tmp_path: Path, parts: tuple[str, ...]): | ||
| tree = _tree(tmp_path) | ||
| unlistable = tree.joinpath(*parts) | ||
| complete = cf.fixtures_digest(tree) | ||
| unlistable.chmod(0o111) | ||
| try: | ||
| with pytest.raises(PermissionError, match=unlistable.name): | ||
| cf.fixtures_digest(tree) | ||
| finally: | ||
| unlistable.chmod(0o700) | ||
| assert cf.fixtures_digest(tree) == complete | ||
|
|
||
|
|
||
| def test_a_link_to_a_directory_and_a_dangling_link_are_hashed_by_their_target(tmp_path: Path): | ||
| tree = _tree(tmp_path) | ||
| try: | ||
| os.symlink("case", tree / "dirlink", target_is_directory=True) | ||
| os.symlink("nowhere", tree / "dangling") | ||
| except (OSError, NotImplementedError): | ||
| pytest.skip("symlinks are not available") | ||
| parts = (b"case/AGENTS.md", b"Fx\n", b"case/sub/CLAUDE.md", b"Fy\n", # sorted by relative path: the link to a directory is not entered | ||
| b"dangling", b"Lnowhere", b"dirlink", b"Lcase") | ||
| expected = hashlib.sha256(b"".join(len(part).to_bytes(8, "big") + part for part in parts)).hexdigest() | ||
| assert cf.fixtures_digest(tree) == expected |
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.