Skip to content

fix(repo): scan leaves the manifest a pinned commit holds out of the identifier check (#1530) - #1614

Merged
napetrov merged 3 commits into
intel:mainfrom
antonwolfy:fix/pinned-manifest-identifier
Dec 6, 2026
Merged

napetrov merged 3 commits into
intel:mainfrom
antonwolfy:fix/pinned-manifest-identifier

Conversation

@antonwolfy

@antonwolfy antonwolfy commented Dec 4, 2026 •

Copy link
Copy Markdown
Contributor

Summary

repo scan <dir>@<rev> --manifest-file <dir>/<path> read the manifest's own text as code in the identifier check. A work tree skips it, a pinned commit did not: _manifest_file_in_tree returned () for a tree with no file system root, so the manifest's tree path was not left out of Scan.words(). A name only the manifest holds (repo_manifest, from schema: repo_manifest.v1) then resolved a claim in AGENTS.md.

Run on main over a repository whose only manifest is at the named path and whose AGENTS.md names repo_manifest, the status of the AGENTS.md identifier claim:

Form Work tree <dir> Pinned <dir>@<sha> on main
--manifest .github/dokimi/repo.yaml unresolved_identifier unresolved_identifier (already correct: scan_repo excludes manifest.path)
--manifest config/eval.yaml --manifest-file <dir>/config/eval.yaml unresolved_identifier ok (wrong)
--manifest config/eval.yaml (no --manifest-file) not applicable unresolved_identifier

So only the --manifest-file form fails; the issue's first form already works at this head. The fix is the issue's: exclude the tree path of the manifest the commit holds, mapped through the tree's own listing.

Closes #1530

Changes

  • _manifest_file_in_tree (dokimi/dokimi/commands/repo.py) hands a tree without root to a new _pinned_manifest_file. It takes the typed --manifest-file path relative to the checkout the commit was named by (git_dir, as typed, with git_dir resolved, and relative to any directory of the typed path's prefix that is the same directory as git_dir on disk, so a link to the checkout works whichever side names it), keeps it only when the commit's own tree.files() lists it, and adds the target tree.resolve gives for a link in the commit, as the work-tree code does for a link on disk. The path is also resolved with the commit's own link walk, so a .. in the typed path (<dir>/config/../config/eval.yaml), also after a link in the commit, names the file as a checkout would. The manifest's file system path is not read. A --manifest-file outside the checkout or one the commit does not list stays (). The work-tree branch is unchanged.
  • dokimi/docs/repo-evaluation-contract.md (identifier check): the sentence that said a pinned <dir>@<rev> reads its manifest as code when --manifest-file names it now says what the code does.
  • dokimi/tests/test_repo_scan_own_files.py: the test that pinned the old behaviour (test_a_pinned_commit_skips_its_manifest_without_manifest_file_and_reads_it_as_code_with_the_flag) is renamed and asserts unresolved_identifier for the flag too. New tests: a nested manifest path (and AGENTS.md's own claim still counts, with the work tree as the same result), no --manifest, a link in the commit, a checkout named through a link, a manifest typed through a link to a checkout named by its real path, a .. in the path, a .. after a link in the commit, and a link that leaves the commit (the file is then not skipped).
  • Changelog fragment (Fixed).

Risk

repo scan <dir>@<rev> --manifest-file <dir>/<path> now reports unresolved_identifier where it reported ok for a name only the manifest holds, which is what the work tree reports. A name the manifest shares with real code still resolves from that code. Exit codes and error messages are unchanged.

Open PR #1328 changes dokimi/dokimi/commands/repo.py too (in cmd_repo_inspect and a new _inspected helper) and merges cleanly with this branch; the open PRs that touch dokimi/docs/repo-evaluation-contract.md merge cleanly as well.

Limit of this fix: a remote pinned source has a cache clone as its git_dir, so a --manifest-file there excludes nothing and the manifest is still read as code. The work-tree behaviour is unchanged: a manifest file inside the tree is left out as before, one outside the tree excludes nothing, and a pinned local checkout now matches it.

Testing

On a Linux review host, at 49c299e0 (on main 01ff2d6):

  • make ci-local: 37 passed, 1 failed, 16 skipped (steps with a job condition, matrix, tool or network not available locally). Test run: 35411 passed, 1 failed, 28 skipped. The failure is tests/test_import_architecture.py::test_package_uses_the_new_modules (dokimi.runs.resolve imports dokimi.utils), which fails on this branch's base (01ff2d6) and is fixed on current main by the merged fix(runs): import InputError from dokimi.files, not dokimi.utils #1609; this PR does not touch it.
  • --manifest-file <alias>/config/nested/eval.yaml with <alias> a link to the checkout and the commit named by its real path (<dir>@<sha>) gives unresolved_identifier; at 2a52834a it gave ok. The new test fails on 2a52834a's code (1 failed, 23 passed) and, as a mutant, with the link-prefix bases removed (1 failed, 23 passed).
  • Repro on main's code: --manifest config/eval.yaml --manifest-file <dir>/config/eval.yaml on <dir>@<sha> gives ok; on this branch unresolved_identifier, as the work tree does.
  • On main's code tests/test_repo_scan_own_files.py gives 5 failed, 15 passed, first on assert 'ok' == 'unresolved_identifier'; here 23 passed.
  • Two more mutants for the .. spelling: resolving the path with posixpath.normpath instead of the commit's walk fails 3 tests (the .. after a link, the link that leaves the commit, the link in the commit); not resolving it at all fails 3 (the plain .., the .. after a link, the link in the commit).
  • Four mutants (no link target, no resolved checkout path, pinned branch returns (), work-tree branch returns ()) each fail at least one of the new or changed tests.
  • Merged together with fix/manifest-glob-braces on main 0eeae5f: pytest -n auto 35684 passed, 28 skipped, mypy clean, ruff check clean.
  • Not run: the other Python versions (3.11, 3.12, 3.14) and a Windows path.

Open questions

None.

Revert

A plain revert restores the old behaviour (a pinned manifest named by --manifest-file read as code). Nothing is stored.

Checklist

  • Tests added/updated and pytest passes (tests added; the full run has one failure, test_package_uses_the_new_modules, which fails on the base and is fixed on current main by the merged fix(runs): import InputError from dokimi.files, not dokimi.utils #1609)
  • 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)

…identifier check (intel#1530)

With `repo scan <dir>@<rev> --manifest-file <dir>/<path>` the manifest's own text was read as code: `_manifest_file_in_tree` returned nothing for a tree without a file system root, so the manifest path was not excluded from the words of the identifier check, and a name only the manifest holds (`repo_manifest` from `schema: repo_manifest.v1`) turned an `AGENTS.md` claim `ok`. The same scan of the work tree reports `unresolved_identifier`. Without `--manifest-file`, `--manifest <path>` already excluded the path of a pinned tree.

For a pinned tree the file named by `--manifest-file` is now mapped through the checkout the commit was named by and the commit's own listing: the path the commit lists, and the target of a link there, are left out; a file the commit does not list leaves nothing out. The manifest's file system path is not read. The contract doc and a changelog fragment say so, and the test that pinned the old behaviour now pins the new one.

Test-narrowed: test_a_pinned_commit_skips_its_manifest_without_manifest_file_and_reads_it_as_code_with_the_flag pinned the bug (a pinned manifest named by --manifest-file read as code); it is renamed and now asserts the fix.
Signed-off-by: Anton Volkov <antonwolfy@gmail.com>
@antonwolfy
antonwolfy requested a review from a team as a code owner December 4, 2026 15:30
@antonwolfy antonwolfy self-assigned this Dec 4, 2026
Copilot AI balanced review requested due to automatic review settings December 4, 2026 15:30

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.

🟡 Changes recommended

Manifest paths containing .. are checked before resolution, leaving manifest-only claims incorrectly marked ok instead of unresolved_identifier.

1 open issue
What changed in this PR

1 new finding.

This PR aligns local pinned-commit scans with work-tree scans by excluding manifests named through --manifest-file from identifier checks.

Changes:

  • Maps manifest paths and symlink targets through the pinned commit.
  • Adds regression coverage for nested paths and symlinks.
  • Updates the contract and changelog.
File Description
dokimi/​tests/​test_repo_scan_own_files.py Tests pinned-manifest exclusions.
dokimi/​dokimi/​commands/​repo.py Adds commit-aware manifest path mapping.
dokimi/​docs/​repo-evaluation-contract.md Documents the revised exclusion behavior.
dokimi/​changelog.d/​20261204_120000_pinned-manifest-file-own-file.md Records the identifier-check fix.

Review effort: Balanced

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

exai-bot commented Dec 4, 2026 •

Copy link
Copy Markdown

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

CI at 49c299e: 26 passing, 4 skipped.

Test notes (2)
  • dokimi/dokimi/commands/repo.py:392: With return False changed to return True, the tests still pass: dokimi/tests/test_repo_scan_own_files.py. If this condition matters, a test should pin it.
  • dokimi/dokimi/commands/repo.py:392: With return False changed to return None, the tests still pass: dokimi/tests/test_repo_scan_own_files.py. If this condition matters, a test should pin it.
Review details
  • Commit reviewed: 49c299e against merge base 2a52834
  • Coverage: 2 files in 1 groups
  • Engine: OpenCodeReview v1.13.5-exai.4.8f73eada, us.openai.gpt-6.1-sol
  • Usage: 89k tokens (60k from cache), 25s
  • Tool calls: 12 (7 file_read, 3 code_search, 1 local_check_results, 1 pr_threads)
  • small change set: 2 files

@github-actions

github-actions Bot commented Dec 4, 2026 •

Copy link
Copy Markdown

Mutation of changed lines

⚠️ Not a clean result: some breaks or tests were left out

At 49c299e: 0 caught · 0 missed

This is not a clean result:

  • 14 changed lines were not mutated

Warning only: a missed break does not fail the job. Updated on every push; the full report is in the ci run summary.

@codecov-commenter

codecov-commenter commented Dec 4, 2026 •

Copy link
Copy Markdown

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

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 96.45%. Comparing base (01ff2d6) to head (49c299e).
⚠️ Report is 9 commits behind head on main.
❗ Your organization needs to install the Codecov GitHub app to enable full functionality.

Additional details and impacted files
@@            Coverage Diff             @@
##             main    #1614      +/-   ##
==========================================
- Coverage   96.46%   96.45%   -0.02%     
==========================================
  Files         561      566       +5     
  Lines       74345    75010     +665     
  Branches    12840    12953     +113     
==========================================
+ Hits        71716    72349     +633     
- Misses       1609     1632      +23     
- Partials     1020     1029       +9     
Files with missing lines Coverage Δ
dokimi/dokimi/commands/repo.py 98.47% <100.00%> (-1.53%) ⬇️

... and 51 files with indirect coverage changes

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

…the identifier check

Review point on intel#1614: `repo scan ROOT@SHA --manifest-file ROOT/config/../config/eval.yaml` left a manifest-only claim as `ok`, because the typed path kept its `..` and failed the listing check before the commit's own link walk could resolve it.

The path under the checkout is now also resolved with the commit's walk (`tree.resolve`), which follows links and `..` as a checkout does, and the resolved path joins the listed ones. The separate pass over link targets is folded into it, and the unreachable `git_dir is None` guard is removed. Tests cover a plain `..`, a `..` after a link in the commit, and a link that leaves the commit.

Signed-off-by: Anton Volkov <antonwolfy@gmail.com>
Comment thread dokimi/dokimi/commands/repo.py Resolved
…out is left out of the identifier check

Settles the review thread on _pinned_manifest_file: with the commit named by its real path (ROOT@SHA) and --manifest-file typed through a link to the checkout (ALIAS/config/nested/eval.yaml), the typed path was not under either spelling of git_dir, so nothing was left out and the manifest was read as code.

The directories of the typed path's prefix that are the same directory as the checkout on disk now count as bases too; the suffix is still looked up in the commit's own listing.

Signed-off-by: Anton Volkov <antonwolfy@gmail.com>

@napetrov napetrov left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Change class: CONTRACT (head 49c299e)

  • Contract: candidate. errors dokimi/dokimi/commands/repo.py:374
  • Responsibility: none
  • Dependency: none
  • Review depth: check the changed surface: callers, docs, tests pin new behaviour
  • Coverage gaps: none

No new blocking findings on 49c299e0.

Reviewed the diff, edge cases and prior threads. Focused tests: 24 passed on head and 16 passed on merge base. The full local suite was outside coverage.

@napetrov napetrov left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Checked manifest exclusion for both worktrees and pinned commits, focused tests, and required CI. Coverage includes the two repository forms in the reviewed fixtures.

@vchamarthi vchamarthi left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Approving 49c299e.
Still open: when I changed the code on purpose, the tests still passed for 4 of 12 changes, and no test pins these down yet (non-blocking): dokimi/dokimi/commands/repo.py:374 (the handled error is raised again), dokimi/dokimi/commands/repo.py:380 (the handled error is raised again), dokimi/dokimi/commands/repo.py:391 (the handled error is raised again) and 1 more.
What I checked: the 24 changed tests pass, and fail on main as expected; the full test suite passes with main merged in (36,528 tests), apart from failures main has too; it merges cleanly onto main.

@napetrov
napetrov merged commit 5990509 into intel:main Dec 6, 2026
30 checks passed
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 scan: a pinned <dir>@<rev> reads its manifest as code in the identifier check

6 participants