fix(deps): Treat sibling shadows as unresolved in degenerate single-dir roots - #26
Merged
Conversation
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
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.
Summary
Aligns bare-target classification with the
Unresolvedcontract introduced in #18: a same-dir namesake is ambiguous, not evidence of locality — in every tree shape.Two-tier rule (crates/ctxctl/src/deps.rs)
.gitancestor found): a bare-target hit at the project root is decisive — module layouts root there — so it isLocal. Files merely beside the analyzed file stay ambiguous (Unresolved). Behavior byte-identical to before..gitancestor anywhere): the fallback root equals the analyzed file's own directory, so a "root" hit is just a same-dir namesake. It now yieldsUnresolvedinstead of being guessedLocal.Explicit relative imports (
from .x import y,./x,../x) bypass both tiers and remainLocal— their target path is visible from the file itself. Root selection itself is unchanged (file dir stays a legitimate fallback root for standalone-file usage).Evidence
Before this change: analyzing
main.py(import os) sitting next to anos.pyin a directory without any.gitancestor classifiedosaslocal— becauseproject_root()fell back to the file's own dir and the root probe then probed right beside it, contradicting the never-a-guess contract at deps.rs:113.Tests
deps_degenerate_dir_sibling_shadow_is_unresolved_not_local— red first (waslocal), now green.deps_degenerate_dir_relative_import_stays_local— explicit relative imports stay local in degenerate trees.deps_sibling_shadow_of_bare_import_is_unresolved_not_local(.git above analyzed subdir) still passes.deps_go_local_via_project_root_probe,java_outline_symbol_and_deps_local_probe,csharp_deps_local_probe) that relied on the degenerate probe expectinglocal: added a.gitmarker so they genuinely exercise tier-1 rooted anchoring, preserving their purpose under the new rule.Gates
cargo fmt --check,cargo clippy --all-features -- -D warnings,cargo test(13/13 binaries, incl. 98 cli tests) — all green.