Skip to content

fix(deps): Treat sibling shadows as unresolved in degenerate single-dir roots - #26

Merged
Xuepoo merged 1 commit into
mainfrom
carryctx/ctx-0049
Aug 24, 2026
Merged

fix(deps): Treat sibling shadows as unresolved in degenerate single-dir roots#26
Xuepoo merged 1 commit into
mainfrom
carryctx/ctx-0049

Conversation

@Xuepoo

@Xuepoo Xuepoo commented Aug 24, 2026

Copy link
Copy Markdown
Owner

Summary

Aligns bare-target classification with the Unresolved contract 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)

  1. Inside a repository (.git ancestor found): a bare-target hit at the project root is decisive — module layouts root there — so it is Local. Files merely beside the analyzed file stay ambiguous (Unresolved). Behavior byte-identical to before.
  2. Degenerate standalone case (no .git ancestor anywhere): the fallback root equals the analyzed file's own directory, so a "root" hit is just a same-dir namesake. It now yields Unresolved instead of being guessed Local.

Explicit relative imports (from .x import y, ./x, ../x) bypass both tiers and remain Local — 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 an os.py in a directory without any .git ancestor classified os as local — because project_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

  • Added deps_degenerate_dir_sibling_shadow_is_unresolved_not_local — red first (was local), now green.
  • Added deps_degenerate_dir_relative_import_stays_local — explicit relative imports stay local in degenerate trees.
  • Verified existing deps_sibling_shadow_of_bare_import_is_unresolved_not_local (.git above analyzed subdir) still passes.
  • Updated three language-probe fixtures (deps_go_local_via_project_root_probe, java_outline_symbol_and_deps_local_probe, csharp_deps_local_probe) that relied on the degenerate probe expecting local: added a .git marker 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.

@Xuepoo
Xuepoo merged commit 372819b into main Aug 24, 2026
12 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.

1 participant