fix: give an inline mod under a trait or impl body a consistent qn (#1018) - #1166
Conversation
…ross its node and DEFINES edges (#1018)
|
Important Review skippedNo new commits to review since the last review. ⚙️ Run configurationConfiguration used: defaults Review profile: CHILL Plan: Pro Plus Run ID: You can disable this status message by setting the Use the checkbox below for a quick retry:
📝 WalkthroughWalkthroughRust parser resolution now preserves trait and impl scopes for inline modules and nested items. Regression tests verify consistent module qualified names and ChangesRust inline module qualified-name consistency
Estimated code review effort: 3 (Moderate) | ~20 minutes Possibly related PRs
🚥 Pre-merge checks | ✅ 5✅ Passed checks (5 passed)
✨ Finishing Touches📝 Generate docstrings
🧪 Generate unit tests (beta)
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
There was a problem hiding this comment.
Actionable comments posted: 1
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.
Inline comments:
In `@codebase_rag/parsers/class_ingest/mixin.py`:
- Around line 1751-1756: Update the parent qualified-name construction in the
module-ingestion logic around rs_utils.build_module_path so nested inline
modules retain the enclosing trait or impl scope. Resolve the nearest enclosing
Module using its scoped qualified name rather than joining unscoped module
names, preserving valid DEFINES edges for cases such as foo.T.outer.inner. Add
regression coverage for nested modules inside traits and impls.
🪄 Autofix
Fix all unresolved CodeRabbit comments on this PR:
- Push a commit to this branch (recommended)
- Create a new PR with the fixes
ℹ️ Review info
⚙️ Run configuration
Configuration used: defaults
Review profile: CHILL
Plan: Pro Plus
Run ID: 3e4ecd95-4bce-4b9c-8d20-f34e72eb6d75
📒 Files selected for processing (4)
codebase_rag/parsers/class_ingest/identity.pycodebase_rag/parsers/class_ingest/mixin.pycodebase_rag/parsers/function_ingest.pycodebase_rag/tests/test_rust_crate_path_trait_linking.py
Greptile SummaryThe previously reported P1 nested inline-module containment defect is fixed. The focused Rust regression test passed, and an end-to-end graph update confirmed that Confidence Score: 5/5No blocking failure remains; the containment relationship is correctly preserved for nested inline modules in trait scope. There are no accepted P0 or P1 findings. The reported P1 was disproved by the targeted regression and an end-to-end graph update exercising the same nested trait-body module shape. Reviews (2): Last reviewed commit: "fix: point a nested inline mod's DEFINES..." | Re-trigger Greptile |
|
@coderabbitai I've pushed a fix for the nested inline-mod parent qn and added a regression test. Please re-review. |
|
|
|
@greptileai Fixed the nested inline-module containment (P1) and added a regression test. Please re-review. |
|



Closes #1018.
The bug
An inline
moddeclared inside a trait or impl body (e.g. in a const initializer) produced three qns that disagreed, sograph_auditreported an orphan Module node and dangling DEFINES edges:foo.T.inner(trait) /foo.inner(impl — impl target dropped)foo.inner(class/trait scope dropped)foo.T.inner.g/foo.S.inner.g(scope kept)So
foo.T.innerhad no outgoing DEFINES (orphan),foo.inner -> ...gdangled, and(Module foo.T) -> ...referenced a trait node as if it were a module.Fix — make node, containment, and items agree
Three aligned changes so the inline mod, its enclosing-module DEFINES, and its items all key the same way:
build_nested_qualified_name_for_class, opt-ininclude_impl_targets): a mod underimpl Snow keysfoo.S.inner, matching the items inside it (foo.S.inner.g), exactly as a mod undertrait Talready keyedfoo.T.inner. Class/struct qns keep the old default, so the change is scoped to the inline-module caller._determine_function_parent): derived from the item’s OWN qn (func_qn.rsplit) instead of a mods-only re-walk that dropped the class scope, so it always matches the item and its Module node._process_inline_modules): the nearest enclosing MODULE (via a mods-only walk), not the qn’s rsplit prefix — a mod under a trait/impl has a class node (not a module) as that prefix, which would dangle.Tests
test_inline_mod_in_a_trait_body_...andtest_inline_mod_in_an_impl_body_...(both new): assert the Module node exists at the expected qn and both DEFINES edges (module -> inline mod,inline mod -> its fn) are present and consistent. The conftest graph-audit (which raised the original violations) now passes for both fixtures.Summary by CodeRabbit
Bug Fixes
Tests