Repository navigation
fix(repo): inspect names unreadable instruction files and plugin manifests (#1271) - #1328
vchamarthi wants to merge 3 commits into
Conversation
…fests (intel#1271) repo inspect ended in a PermissionError traceback for a link into an unsearchable directory or a directory without the search bit, reported a directory of mode 000 as an empty tree, and listed dangling, looping, directory, pipe, device and empty instruction files, and a plugin manifest that is a directory, without a word. raises SourceArgumentError for these, an unlistable root is refused with exit 2, and the report notes each unusable file. Fixes intel#1271 Signed-off-by: vchamarthi <123653452+vchamarthi@users.noreply.github.com>
There was a problem hiding this comment.
Warning
Copilot couldn't run its full agentic review because it didn't start before the timeout. Make sure your repository has a runner available, or add a copilot-code-review.yml file specifying one with the runs-on attribute. See the docs for more details.
Copilot review overview
7 open issues
These tests assume POSIX features and paths (os.mkfifo,/dev/zero) but are not skipped on… · New These tests assume POSIX features and paths (os.mkfifo,/dev/zero) but are not skipped on… · New These tests assume POSIX features and paths (os.mkfifo,/dev/zero) but are not skipped on… · New These tests assume POSIX features and paths (os.mkfifo,/dev/zero) but are not skipped on… · New_readablecurrently allows directories (stat.S_ISDIR) through, butPath.read_text()/… · New This error message says 'links to a directory' even whenpathitself is not a symlink (e.g., a… · New The printed line currently includes both the 'NOT LOADED' prefix and the full note text (which… · New
What changed in this PR
Improve repo inspect (and other repo commands) behavior when encountering unreadable/unsearchable roots and non-regular “instruction”/manifest paths, avoiding tracebacks and making these cases visible in output.
Changes:
- Add WorkTree guardrails (
check_listable, saferresolve/reads) to convert OS errors intoSourceArgumentErrorand prevent hangs on pipes/devices. - Extend inspection output to annotate unusable instruction files (
not loadednotes +not_observedentries) and treat manifest directories as high-risk plugin capabilities. - Add regression tests, docs contract updates, and a changelog entry for these behaviors.
| File | Description |
|---|---|
| dokimi/tests/test_repo_inspect_unreadable.py | Adds regression coverage for unreadable roots and unusable instruction/manifest paths. |
| dokimi/dokimi/repos/source.py | Adds listability check and hardens read/resolve behavior against unreadable/non-regular paths. |
| dokimi/dokimi/repos/environment/risks.py | Detects plugin manifest directories and reports them as high-risk plugin capability. |
| dokimi/dokimi/repos/environment/__init__.py | Captures “not loaded” reasons for instruction files and surfaces them via notes / not_observed. |
| dokimi/dokimi/commands/repo.py | Ensures unreadable WorkTree roots exit as input errors (2) and prints “NOT LOADED” lines. |
| dokimi/docs/repo-evaluation-contract.md | Documents the contract for records that cannot be loaded and exit code for unlistable dirs. |
| dokimi/changelog.d/20261126_120000_inspect-unreadable-sources.md | Records user-visible behavior changes for unreadable/unusable paths. |
Review effort: Lite
|
✅ OpenCodeReview: Review complete: 0 finding(s) across 2 selected item(s). CI at Review details
|
|
Codecov Report❌ Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## main #1328 +/- ##
==========================================
- Coverage 96.14% 96.14% -0.01%
==========================================
Files 498 499 +1
Lines 66028 66265 +237
Branches 11461 11513 +52
==========================================
+ Hits 63482 63709 +227
- Misses 1574 1580 +6
- Partials 972 976 +4
🚀 New features to boost your workflow:
|
- skip the pipe and /dev/zero tests where the platform has neither - read_text/read_bytes refuse a directory with a SourceArgumentError - resolve says "is a directory" for a real directory, "links to a directory" only for a link - NOT LOADED lines print the reason without a repeated prefix - an instruction file whose read fails (a partial-clone blob that cannot be fetched) gets a reason instead of passing as loadable Signed-off-by: vchamarthi <123653452+vchamarthi@users.noreply.github.com>
|
This is ready for another look: I've pushed 1 commit on Changes:
PR description updated:
Threads and comments:
What I checked on the new commit: all 4 new tests fail before the fix and pass after it; the full test suite passes with main merged in (30,632 tests), apart from 1 failure main has too. What each test shows
|
…ntel#1271) The manifest-directory probe in risks.py now treats the RuntimeError that Python before 3.13 raises on a symlink loop as not a manifest directory, so a self-linked .claude-plugin no longer crashes repo inspect. Signed-off-by: vchamarthi <123653452+vchamarthi@users.noreply.github.com>
|
This is ready for another look: I've pushed 1 commit on Changes:
Threads and comments:
Not caused by this PR:
What I checked on the new commit: the new test fails before the fix and passes after it; the full test suite passes with main merged in (30,707 tests), apart from 1 failure main has too. What each test shows
|



Summary
Fixes #1271.
repo inspectended in aPermissionErrortraceback forAGENTS.mdlinked into a chmod 000 directory and for a directory of mode 444, and reported a directory of mode 000 as an empty tree. It also listed dangling, looping, directory, pipe, device and empty instruction files, and a plugin manifest that is a directory, with no finding. Related: #1272 and #1273 (sameWorkTree.resolvecause: it no longer crashes or sayslinks to nothingfor a pipe, which both can use), #1293 (overlaps: the same unsearchable-directory error inrepos/source.py, not covered by this change), #959 (the walk handling is kept).Changes
WorkTree.resolvecatchesOSErroraroundis_dir()/is_file()and raisesSourceArgumentError; a real directory readsis a directoryand any other non-link that is no regular file readsis not a regular file.WorkTree.filesraisesSourceArgumentErrornaming the root when it cannot be read and searched;repo inspectturns it into exit 2._read_sizesalso returns why each instruction file cannot be loaded;inspect_repoadds anot loadednote to the record and anot_observedline.plugin.jsonormarketplace.jsonthat is a directory is reported like a dangling link.tests/test_repo_inspect_unreadable.py.docs/repo-evaluation-contract.md§8.1 now says what a record for a file the harness cannot load looks like and that an unlistable source directory is refused with exit 2.raise SourceArgumentErrorinWorkTree.resolvetraces to repo inspect misreports unreadable sources and unusable files #1271 (scenarios 1, 3 and 9).repo inspectprints aNOT LOADEDline per unusable instruction file; the git listing keeps pipes and devices; a link target that git leaves out is sized from disk;resolveusesos.statand saysis not a regular filefor a link to a pipe; a link out of the tree at a manifest path no longer refuses the repository.WorkTree.read_textandread_bytesrefuse a pipe, socket or device;WorkTree.check_listableis called from_open_treeso everyrepocommand refuses an unreadable root with exit 2;_content_problemopens an instruction file (or reads it in a partial clone) to name one that is empty or cannot be opened.Risk
A
WorkTreewhose root failsos.access(R_OK|X_OK)now raises atfiles()instead of listing nothing. Unusable instruction files stay ininstructions, so counts do not change; only notes andnot_observedlines are new._read_sizesis private and its only caller was updated.Testing
The new tests in
tests/test_repo_inspect_unreadable.pyfail on the previous commit and pass now.tests/test_repo_inspect_cli.py,tests/test_repo_environment.py,tests/test_growth_ratchet.pyandruff checkpass. A fullpytest testsrun stopped at its first failure,tests/test_repo_compare_interval.py::test_the_row_p_places_zero_where_large_deltas_round_p_at_zero_apart(-1.7e-07 == 0.0), after 23100 passes; it does not touch this code.Open questions
Whether an empty instruction file should be a finding with a rule id instead of a
not_observedline; I took the smaller change.instructionswith anot loadednote and anot_observedline over dropping it from the list or adding a new finding rule: the issue accepts either, and1 instruction files (1 root)is what scenario 1 expects. Is that the behaviour you want?plugincapability as a dangling link over a new capability kind: the issue asks for it to be reported the same way. Is that the behaviour you want?Revert
A plain revert; no stored record or schema changes (
not_observedandnotesare existing fields).Checklist
See the boxes below.
pytestpassesruff,mypy, and schema checks passAGENTS.mdraise/exit and test names the doc, contract or issue it traces to.github/.licenserc.yaml)Review points edit lines of recent commits:
dokimi/dokimi/repos/source.py(7e52ceb fix(repo): a directory refuses a manifest link that leaves and re-ente). Each commit's own tests still pass; none of their assertions changes except those listed above for a scenario of the issue.Checklist evidence
pytestpasses: 1 test file(s) changed; suite: 30344 passed; 1 failing test(s) fail on the base branch too: tests/test_repo_compare_interval.py::test_the_row_p_places_zero_where_large_deltas_round_p_at_zero_apart; 18 of 20 proof(s) fail before the change; 2 pin behaviour the base code already hadruff,mypy, and schema checks pass: passed: ci.yml:static / ruff check, ci.yml:typecheck / mypy, ci.yml:static / schema-check, ci.yml:static / schema_compat vs the PR basedokimi/docs/repo-evaluation-contract.mdAGENTS.md: nothing left open; mutation of changed lines ranraise/exit and test names the doc, contract or issue it traces to: every new error path and test names a doc, contract or issue.github/.licenserc.yaml): every new source file carries the headerFixes #1271.