Skip to content

fix(repo): inspect names unreadable instruction files and plugin manifests (#1271) - #1328

Open
vchamarthi wants to merge 3 commits into
intel:mainfrom
vchamarthi:issue-1271-repo-inspect-misreports-unreadable-sourc
Open

vchamarthi wants to merge 3 commits into
intel:mainfrom
vchamarthi:issue-1271-repo-inspect-misreports-unreadable-sourc

Conversation

@vchamarthi

@vchamarthi vchamarthi commented Nov 27, 2026 •

Copy link
Copy Markdown
Contributor

Summary

Fixes #1271. repo inspect ended in a PermissionError traceback for AGENTS.md linked 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 (same WorkTree.resolve cause: it no longer crashes or says links to nothing for a pipe, which both can use), #1293 (overlaps: the same unsearchable-directory error in repos/source.py, not covered by this change), #959 (the walk handling is kept).

Changes

  • WorkTree.resolve catches OSError around is_dir()/is_file() and raises SourceArgumentError; a real directory reads is a directory and any other non-link that is no regular file reads is not a regular file.
  • WorkTree.files raises SourceArgumentError naming the root when it cannot be read and searched; repo inspect turns it into exit 2.
  • _read_sizes also returns why each instruction file cannot be loaded; inspect_repo adds a not loaded note to the record and a not_observed line.
  • A plugin.json or marketplace.json that is a directory is reported like a dangling link.
  • Changelog fragment and 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.
  • Every new raise SourceArgumentError in WorkTree.resolve traces to repo inspect misreports unreadable sources and unusable files #1271 (scenarios 1, 3 and 9).
  • repo inspect prints a NOT LOADED line per unusable instruction file; the git listing keeps pipes and devices; a link target that git leaves out is sized from disk; resolve uses os.stat and says is not a regular file for a link to a pipe; a link out of the tree at a manifest path no longer refuses the repository.
  • WorkTree.read_text and read_bytes refuse a pipe, socket or device; WorkTree.check_listable is called from _open_tree so every repo command refuses an unreadable root with exit 2; _content_problem opens an instruction file (or reads it in a partial clone) to name one that is empty or cannot be opened.

Risk

A WorkTree whose root fails os.access(R_OK|X_OK) now raises at files() instead of listing nothing. Unusable instruction files stay in instructions, so counts do not change; only notes and not_observed lines are new. _read_sizes is private and its only caller was updated.

Testing

The new tests in tests/test_repo_inspect_unreadable.py fail on the previous commit and pass now. tests/test_repo_inspect_cli.py, tests/test_repo_environment.py, tests/test_growth_ratchet.py and ruff check pass. A full pytest tests run 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_observed line; I took the smaller change.

  • I chose An unusable instruction file stays in instructions with a not loaded note and a not_observed line over dropping it from the list or adding a new finding rule: the issue accepts either, and 1 instruction files (1 root) is what scenario 1 expects. Is that the behaviour you want?
  • I chose A source directory that cannot be read or searched is refused with exit 2 over exit 1: the issue allows 1 or 2, and 2 is the code for bad input. Is that the behaviour you want?
  • I chose A manifest directory gets the same high-risk plugin capability 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_observed and notes are existing fields).

Checklist

See the boxes below.

  • 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
  • No ad-hoc run artifacts committed
  • New files carry the SPDX license header (or are exempt in .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
  • Tests added/updated and pytest passes: 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 had
  • ruff, 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 base
  • Docs updated (or N/A): updated: dokimi/docs/repo-evaluation-contract.md
  • Self-reviewed per "Before opening a PR" in AGENTS.md: nothing left open; mutation of changed lines ran
  • Each new raise/exit and test names the doc, contract or issue it traces to: every new error path and test names a doc, contract or issue
  • No ad-hoc run artifacts committed: 2 added file(s), none a run's output
  • New files carry the SPDX license header (or are exempt in .github/.licenserc.yaml): every new source file carries the header

Fixes #1271.

…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>
@vchamarthi
vchamarthi requested a review from a team as a code owner November 27, 2026 01:29
Copilot AI balanced review requested due to automatic review settings November 27, 2026 01:29

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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
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, safer resolve/reads) to convert OS errors into SourceArgumentError and prevent hangs on pipes/devices.
  • Extend inspection output to annotate unusable instruction files (not loaded notes + not_observed entries) 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

Comment thread dokimi/dokimi/repos/source.py Resolved
Comment thread dokimi/dokimi/repos/source.py Resolved
Comment thread dokimi/dokimi/commands/repo.py Resolved
@exai-bot

exai-bot commented Nov 27, 2026 •

Copy link
Copy Markdown

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

CI at 52b2ac1: 25 passing, 4 skipped.

Review details
  • Commit reviewed: 52b2ac1 against merge base b413290
  • Coverage: 2 files in 1 groups
  • Engine: OpenCodeReview v1.13.5-exai.4.8f73eada, us.openai.gpt-6.1-sol
  • Usage: 85k tokens (57k from cache), 25s
  • Tool calls: 12 (7 file_read, 3 code_search, 1 ci_status, 1 local_check_results)
  • small change set: 2 files

@codecov-commenter

codecov-commenter commented Nov 27, 2026 •

Copy link
Copy Markdown

⚠️ Please install the 'codecov app svg image' to ensure uploads and comments are reliably processed by Codecov.

Codecov Report

❌ Patch coverage is 80.18868% with 21 lines in your changes missing coverage. Please review.
✅ Project coverage is 96.14%. Comparing base (9bf1ce7) to head (52b2ac1).
⚠️ Report is 16 commits behind head on main.

Files with missing lines Patch % Lines
dokimi/dokimi/repos/environment/__init__.py 70.73% 11 Missing and 1 partial ⚠️
dokimi/dokimi/repos/source.py 83.33% 4 Missing and 2 partials ⚠️
dokimi/dokimi/commands/repo.py 83.33% 2 Missing and 1 partial ⚠️
❗ Your organization needs to install the Codecov GitHub app to enable full functionality.
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     
Files with missing lines Coverage Δ
dokimi/dokimi/repos/environment/risks.py 96.82% <100.00%> (+0.06%) ⬆️
dokimi/dokimi/commands/repo.py 98.75% <83.33%> (-0.92%) ⬇️
dokimi/dokimi/repos/source.py 96.01% <83.33%> (-1.05%) ⬇️
dokimi/dokimi/repos/environment/__init__.py 92.94% <70.73%> (-5.65%) ⬇️

... and 34 files with indirect coverage changes

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

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

Copy link
Copy Markdown
Contributor Author

This is ready for another look: I've pushed 1 commit on issue-1271-repo-inspect-misreports-unreadable-sourc (0d17c4b..b413290).

Changes:

  • An instruction blob that cannot be read in a partial clone is named instead of passing as loadable.

PR description updated:

  • a real directory reads is a directory and any other non-link that is no regular file reads is not a regular file

Threads and comments:

  • I answered each one in its thread: 9 fixed.

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
  • test_reading_a_directory_is_a_source_error_not_an_oserror: fails before, passes after.
  • test_a_directory_named_as_a_file_is_not_said_to_be_a_link: fails before, passes after.
  • test_text_output_names_an_instruction_file_that_is_not_loaded: fails before, passes after.
  • test_an_instruction_blob_a_partial_clone_cannot_fetch_is_named: fails before, passes after.

…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>
@vchamarthi

Copy link
Copy Markdown
Contributor Author

This is ready for another look: I've pushed 1 commit on issue-1271-repo-inspect-misreports-unreadable-sourc (b413290..52b2ac1).

Changes:

  • _manifest_dirs in risks.py catches the RuntimeError that Python before 3.13 raises on a link loop.

Threads and comments:

  • I answered each one in its thread: 1 fixed.

Not caused by this PR:

  • Fails on main too: 1 test in tests/test_repo_compare_interval.py; float rounding: delta lo is -1.7e-07 where the test expects 0.0.

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
  • A looping .claude-plugin link (with Path.resolve raising RuntimeError as it does before 3.13) does not crash inspect_repo: fails before, passes after.

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.

repo inspect misreports unreadable sources and unusable files

4 participants