Repository navigation
fix(repo): repo budget skips a tracked file under an unsearchable directory (#959) - #1028
Conversation
…ectory (intel#959) WorkTree.files() let PermissionError out of Path.is_file for a path git lists under a directory with mode 000, so repo budget ended in a traceback. A path that cannot be looked at is now left out of the listing, with a warning on stderr naming it. Fixes intel#959 Signed-off-by: vchamarthi <123653452+vchamarthi@users.noreply.github.com>
|
Codecov Report❌ Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## main #1028 +/- ##
==========================================
- Coverage 96.09% 96.06% -0.03%
==========================================
Files 462 463 +1
Lines 60884 61000 +116
Branches 10525 10541 +16
==========================================
+ Hits 58505 58600 +95
- Misses 1474 1485 +11
- Partials 905 915 +10
🚀 New features to boost your workflow:
|
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
4 open issues
exc.strerroris locale-dependent (and can vary by platform), but the PR description/tests treat… · New The tests restore permissions to0o755, which assumes the directory’s original mode. This can be… · New The inline comment on line 47 is inaccurate:tree.skippedcan include any listed path that can’t… · New The inline comment on line 47 is inaccurate:tree.skippedcan include any listed path that can’t… · New
What changed in this PR
Fixes repo budget <dir> crashing on unreadable (chmod 000) directories in git worktrees by skipping un-stat’able listed paths, surfacing them as warnings, and treating affected scans as incomplete.
Changes:
- Add
WorkTree.skippedtracking and_is_entry()based onos.lstat()to avoidPath.is_file()/is_symlink()permission pitfalls. - Propagate skipped-path warnings into
repo budgetwarnings and intorepo scanincomplete-scan reporting. - Add regression tests and a changelog entry for the unreadable-directory scenario.
| File | Description |
|---|---|
| dokimi/tests/test_repo_budget_unreadable_dir.py | Adds regression coverage for unreadable directory entries and warning/exit-code behavior. |
| dokimi/dokimi/repos/source.py | Implements WorkTree.skipped and safe entry detection via os.lstat() with OSError handling. |
| dokimi/dokimi/repos/budget.py | Includes tree.skipped in budget warnings so --fail-on-warning gates correctly. |
| dokimi/dokimi/commands/repo_scan.py | Treats skipped paths as “not-counted” warnings for written manifests by forcing a listing. |
| dokimi/changelog.d/20261119_100000_budget-unsearchable-dir.md | Documents the fixed crash and the new warning/exit behavior. |
Review effort: Lite
…ntel#959) Every path the listing could not look at made the scan incomplete, so a data file under an unsearchable directory failed --fail-on-fail. The contract names only guidance the scan would check. Signed-off-by: vchamarthi <123653452+vchamarthi@users.noreply.github.com>
|
OpenCodeReview: Commit c469cb9 was not reviewed. This PR has reached its review limit (6 reviews). CI at `c469cb9`: 5 still running, 20 passing, 2 skipped
To review this commit: re-request review from exai-bot in the Reviewers list. <details><summary>Last review (7d56c99): 2 medium</summary> Open threads from the bot: 0 </details> |
…intel#959) - match the skipped path itself, not the text before the first ": ", so `team: docs/AGENTS.md` is found - read `also_scan` entries as globs, as `guidance_files` does - count a skipped `CLAUDE.local.md` (profile guidance name) and a skipped Bazel build input as reasons the scan is incomplete - name `Permission denied` from the errno, not the locale's `strerror` - tests restore the directory's own mode Signed-off-by: vchamarthi <venkata.sai.gireesh.chamarthi@intel.com>
|
🟢 Ready for re-review · 1 commit on Next: a re-review of the new head. Changes
PR description updated
Threads and comments
Verified on the new head: ✅ 5/5 tests fail before the fix, pass after · What each test shows
|
vlad-perevezentsev
left a comment
There was a problem hiding this comment.
Review at ef52f11. The crash is fixed: repo budget and repo scan no longer raise on a tracked file under an unsearchable directory, and the gate fails on skipped guidance. But the new silent skip now reaches callers that ignore skipped, and a few cases still pass or fail the gate wrongly. Details are in the line comments.
Agreed with @exai-bot on the @ import under an unsearchable directory: repo scan --fail-on-fail still exits 0 there.
What I ran, at ef52f11:
make ci-local --offline: 23,732 passed, 0 failed, 72 skipped; every step passed.repo scan --fail-on-fail --jsonon small git and plain-directory trees withchmod 000subdirectories: an@import (exit 0), a vendoredBUILDwithout Bazel (exit 1), nestedAGENTS.mdin a plain directory (exit 0) and under git (exit 1).workspace._exportof aWorkTreewith an unsearchable directory: the export misses its files without an error.
Checked, no issues
- Warning text:
Permission deniedcomes fromerrno, not the locale; the:in a path is handled byskipped_paths. - Earlier threads: the
CLAUDE.local.md,also_scanglob and colon-in-path fixes hold, each with a test. - Docs and changelog: the contract and the
Fixedfragment say what changed; the new test file has the SPDX header.
…ntel#959) Fixes review points on intel#1028: - an @ import of Markdown under an unsearchable directory makes the default scan incomplete - a skipped Bazel build input counts only when the Bazel adapter is on - os.walk records a directory it could not list, as git trees do - an unmerged path is named once in skipped - the workspace export raises PrepError instead of copying a partial tree Fixes review points on intel#1028: - an @ import of Markdown under an unsearchable directory makes the default scan incomplete - a skipped Bazel build input counts only when the Bazel adapter is on - os.walk records a directory it could not list, as git trees do - an unmerged path is named once in skipped - the workspace export raises PrepError instead of copying a partial tree Signed-off-by: vchamarthi <123653452+vchamarthi@users.noreply.github.com>
|
🟢 Ready for re-review · 1 commit on Next: @vlad-perevezentsev: re-review the new head. Changes
PR description updated
Threads and comments
Verified on the new head: ✅ 5/5 tests fail before the fix, pass after · ✅ full suite with main merged in: 24333 passed, 1 failure that main has too · ✅ second reader: 1 raised, all fixed What each test shows
|
…-crashes-when-a Signed-off-by: vchamarthi <123653452+vchamarthi@users.noreply.github.com>
…ts (intel#959) An @ import through a linked directory to a skipped Markdown file now makes the default scan incomplete, and a skipped path that is not guidance stays in the scan report's warnings without becoming an incomplete reason. The tests and changelog fragment use main's --fail-on warn|fail. Signed-off-by: vchamarthi <123653452+vchamarthi@users.noreply.github.com>
|
🟢 Ready for re-review · 2 commits on Next: a re-review of the new head. Threads and comments
Not this PR's
Verified on the new head: ✅ 2/2 tests fail before the fix, pass after · ✅ full suite with main merged in: 24347 passed, 1 failure that main has too · ✅ second reader: nothing raised · What each test shows
|
napetrov
left a comment
There was a problem hiding this comment.
Change class: CONTRACT (head 77889ee)
- Contract: candidate. errors dokimi/dokimi/commands/repo_scan.py:109; errors dokimi/dokimi/repos/workspace.py:323
- Responsibility: none
- Dependency: none
- Review depth: check the changed surface: callers, docs, tests pin new behaviour
- Coverage gaps: none
Two existing blocking findings remain open. The budget now names skipped entries. The default scan can still call itself complete when imported Markdown is hidden behind either a direct file symlink to an inaccessible target or a directory symlink to the repository root. _link_routes drops errors while resolving the former and builds the wrong prefix for the latter. Both of the failing CI jobs report a runner shutdown. T16, T17
Focused tests on 77889eefc: 26 passed in 2.04s. CI on head 77889ee: 2 failing Actions jobs; merge base 6ebda00 is behind base tip 36075a0.
) A skipped Markdown file imported through a file link, a chain of file links, an absolute link inside the repository, a file link over a directory link, a directory named ..docs, or a link to the root (self -> .) was not matched to the skipped path, so the default scan passed the gate. Follow unresolvable links component by component and map the root link's paths. Signed-off-by: vchamarthi <123653452+vchamarthi@users.noreply.github.com>
|
Ready for re-review, @napetrov: 1 commit on Changes:
Threads and comments:
Checked on the new head: 6 of 6 tests fail before the fix and pass after; full suite with main merged in: 24550 passed, 1 failure that main has too. What each test shows
|
…tors (intel#959) A Markdown import through a link whose absolute target has '.' or '//' components, or whose target uses backslashes or a \\?\ prefix, was not routed to the skipped file, so the scan was not marked incomplete. Signed-off-by: vchamarthi <123653452+vchamarthi@users.noreply.github.com>
|
Ready for re-review: 1 commit on Threads and comments:
Checked on the new head:
What each test shows
|
Signed-off-by: vchamarthi <123653452+vchamarthi@users.noreply.github.com>
|
Ready for re-review: 1 commit on Not the PR's:
Checked on the new head:
What each test shows
|
napetrov
left a comment
There was a problem hiding this comment.
Change class: CONTRACT (head 9e5f356)
- Contract: candidate. errors dokimi/dokimi/commands/repo_scan.py:113; errors dokimi/dokimi/commands/repo_scan.py:158
- Responsibility: none
- Dependency: none
- Review depth: check the changed surface: callers, docs, tests pin new behaviour
- Coverage gaps: none
The earlier approval at 7d56c99 missed this case. An absolute Markdown import through a directory symlink followed by .. can still pass --fail-on fail with incomplete: false. The direct-file and repository-root link cases from the previous review now pass. I also reproduced the growth failure against the current main tip: merging takes workspace.py from 797 to 804 lines, above the 800-line limit. The standalone head has 796 lines in workspace.py; its local growth test instead flags the unchanged novelty.py. T16 T17 T20
Coverage on 9e5f356c0 included budget warnings and exit codes, scan completeness, workspace export and the earlier symlink cases. Focused tests on Python 3.13 returned 1 failed, 162 passed, 1 skipped in 7.37s. The Windows cases used simulated native paths.
Signed-off-by: vchamarthi <123653452+vchamarthi@users.noreply.github.com>
…ace.py Moves the skipped-path refusal of `_export` into `repos/export_skips.py`, so `workspace.py` is back under the 800-line cap (growth ratchet). An absolute link `<repo>/jump/../d/context.md` was cut with `posixpath.relpath`, which folds `jump/..` before `jump` is followed. The root prefix is now cut as text, so the components are resolved in filesystem order and a skipped Markdown import behind them makes the scan incomplete. `git grep <pattern> <revision> -- <file>` shows lines of an older blob, so `searched_files` no longer returns the workspace file for it. Signed-off-by: vchamarthi <123653452+vchamarthi@users.noreply.github.com>
|
Ready for re-review, @napetrov: 2 commits on Changes:
Threads and comments:
Not the PR's:
Checked on the new head: 3 of 3 tests fail before the fix and pass after; full suite with main merged in: 32873 passed, 1 failure that main has too. What each test shows
|


Summary
Fixes #959.
repo budget <dir>on a git working tree with a tracked file under a chmod 000 directory ended inPermissionErrorfromPath.is_fileinWorkTree.files(). The path is now skipped, named in the budget'swarnings, and the table is printed.Changes
WorkTree._is_entryindokimi/dokimi/repos/source.pychecks the path withos.lstatand catchesOSError;WorkTree.skippedlists what it dropped.budget()indokimi/dokimi/repos/budget.pyaddsskippedtowarnings, so--fail-on-warninggates on it.dokimi/tests/test_repo_budget_unreadable_dir.pyand a changelog fragment.<path>: Permission denied; the file and anything it leads to are not counted, the wordingrepo scantakes as an incomplete scan._loaded_with_defaultindokimi/dokimi/commands/repo_scan.pyreturnstree.skippedas the not-counted warnings for a written manifest too.Risk
A tracked file under an unreadable directory is left out of the budget and named in
warnings;--fail-on-warningnow exits 1 for such a tree. Theos.walkbranch offiles()andis_file/is_dirare unchanged.repo scan --fail-on-failexits 1 for such a tree when the skipped path is one the scan would check (a guidance oralso_scanglob, a rule, a guidance name or a Markdown import in the default scan, a directory that could not be listed, a Bazel build input when the Bazel adapter is on); any other skipped path is only a warning.Testing
python -m pytest -q -p no:cacheprovider tests/test_repo_budget_unreadable_dir.py tests/test_repo_budget.py tests/test_growth_ratchet.pypasses. The new test fails on main withPermissionError.python -m ruff checkon the changed files passes.Open questions
None
Revert
Revert the commit. Nothing is stored.
Checklist
pytestpassesruff,mypy, and schema checks passAGENTS.mdraise/exit and test names the doc, contract or issue it traces to.github/.licenserc.yaml)Checklist evidence
pytestpasses: 1 test file(s) changed; suite: 23811 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; 7 proof(s) fail before the changeruff,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 baseschemas/repo_budget.v1.jsonalready sayswarningscovers unreadable files, and the code now does what it says.AGENTS.md: second reader: 2 round(s), 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 #959.
Fixes #906 (supersedes #953).