Skip to content

fix(python): resolve project-relative module names of nested projects (#13675) - #13698

Merged
EffortlessSteven merged 13 commits into
mainfrom
claude/project-thread-hzxvi0
Nov 8, 2026
Merged

EffortlessSteven merged 13 commits into
mainfrom
claude/project-thread-hzxvi0

Conversation

@EffortlessSteven

@EffortlessSteven EffortlessSteven commented Nov 8, 2026 •

Copy link
Copy Markdown
Member

Requested by Steven Zimmerman · project thread

Summary

In a monorepo where each package is its own Python project (svc/b/pyproject.toml) and tests import modules by their project-relative name (from core import limit), ripr never matched the import to svc/b/core.py. Owner module paths were repository-relative only (svc.b.core), so a strong test read weak with "could not confirm".

The Python adapter now records each owner's project-relative names. The project root is the nearest non-root ancestor holding pyproject.toml, setup.py, setup.cfg, pytest.ini or tox.ini. These names go through the existing #4566 ambiguity record (AmbiguousSrcModule), so a project-relative name identifies the owner only for tests under that project root. A sibling project's same-named core still gets no credit. Project names reach import identity only through owner_import_modules_for(owner, test_file), which applies that root check. Suffix and package-prefix matchers keep the repository-relative owner_module_paths.

Governing issue or accepted claim: #13675
Acceptance delta (one sentence): A strong test in a nested Python project that imports its module by project-relative name reads exposed, and a sibling project's same-named module does not credit it.

Layout matrix (all at repo root, strong test, before this change)

These layouts already read exposed with the correct related test:

  • src layout, flat package, namespace package
  • tests colocated in src and in a flat package
  • *_test.py, nested tests/unit, tests/__init__.py, package-internal pkg/tests
  • relative imports
  • poetry from="src", hatch, setuptools where=["lib"], uv workspace, pytest pythonpath=["lib"]

The nested-project case was the only attribution gap I found. Nested-root auto-detection and doctor hints are #13618, which another candidate is handling.

Review

There were two independent fresh-context review rounds; see the review record comment. Round 1 found 3 false-credit paths (suffix matching, client-app prefixes, module_contains_owner), and all three are fixed. Round 2 was clean. Non-blocking follow-up: #13706.

Proof (head d54e0f3)

  • layout_tests.rs passes 7/7:
    • own-project credit, including import pkg; pkg.core.limit();
    • no credit to a sibling project, for both flat and package attribute imports;
    • an unmarked nested directory claims nothing;
    • a test outside the project with no rival gets no credit;
    • rival-definition withholding holds for both the suffix match (other.core) and the exact match (x/src/core.py).
  • With the production call removed, the own-project test fails.
  • cargo test -p ripr --lib analysis::language::python: 1964 passed, 0 failed.
  • Native binary on a real-shaped repro: a change in svc/b went from weak ("could not confirm") to exposed.
  • cargo xtask precommit: Status pass.

🤖 Generated with Claude Code

https://claude.ai/code/session_01UNUoLVHnMQXBm6voKj1B8e

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01UNUoLVHnMQXBm6voKj1B8e
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01UNUoLVHnMQXBm6voKj1B8e
@gemini-code-assist

Copy link
Copy Markdown

Warning

You have reached your daily quota limit. Please wait up to 24 hours and I will start processing your requests again!

@EffortlessSteven EffortlessSteven self-assigned this Nov 8, 2026
@coderabbitai

coderabbitai Bot commented Nov 8, 2026 •

Copy link
Copy Markdown

Warning

Review limit reached

Enable usage-based reviews in Billing to review now. Otherwise, wait until the next included review is available.
You're only billed for reviews past your plan's rate limits ($0.25/file).

  • Ask an admin to enable usage-based reviews

Open in CodeRabbit

Reviews can continue after your included limit without a manual trigger. An admin must approve usage-based billing.

Next included review available in 23 minutes.

Check out review usage here.

View limit details

Limit details: You’ve used the included review currently available. Your 152 included PR review attempts over the past 7 days set your current allowance at 1 review per hour.

Learn how review limits work.

Review configuration:

Run configuration

  • Source mode: Auto
  • Repository: Unavailable
  • Branch: Unavailable
  • File: No configuration file from this repository applied
  • Commit: Unavailable
  • Layers: Organization UI
  • Review profile: ASSERTIVE
  • Plan: Essentials
  • Run ID: c60121aa-87de-4ec5-8573-712ef745476a
Commits

Reviewing files that changed from the base of the PR and between ab93e28 and 2d89c19.

Files selected for processing: 7

  • changelog.d/python-nested-project-module-names-13675.md
  • crates/ripr/src/analysis/language/python.rs
  • crates/ripr/src/analysis/language/python/layout_tests.rs
  • crates/ripr/src/analysis/language/python/reexport_tests.rs
  • crates/ripr/src/analysis/language/python/related_tests.rs
  • crates/ripr/src/analysis/language/python/related_tests/project_names.rs
  • docs/specs/RIPR-SPEC-0028-python-preview-static-facts.md
  • Autofix · Keep fixing CodeRabbit findings and required CI, and resolving merge conflicts

…project

Independent review found three sites that matched short project names
without the project-root check (rival-definition suffix matching, client
app package prefixes, module_contains_owner). Those sites keep the
repository-relative owner paths; project names reach import identity only
through owner_import_modules_for, which applies the root check.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01UNUoLVHnMQXBm6voKj1B8e
…rival clause

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01UNUoLVHnMQXBm6voKj1B8e

Copy link
Copy Markdown
Member Author

Independent review record (fresh-context reviewers, no stake in the implementation).

Round 1 (head 94b7cb1): 3 blocking findings, all fixed in 7dc5d39.

  1. bare_name_bound_to_other_module suffix matching. Running it over project names let other.core count as "may be the owner's" for an owner whose project name is core, which lifted the rival-definition withholding.
  2. client_app_identity package-prefix fallbacks had no root check: from pkg import app in a sibling project could read Own.
  3. module_contains_owner takes no test file, so short project names could match anywhere.

Repair: those sites keep the repository-relative owner_module_paths. Project-relative names reach import identity only through owner_import_modules_for(owner, test_file), which applies module_name_identifies_owner_for (test must be under the owner's project root). The exact-match ambiguous clause in bare_name_bound_to_other_module is gated the same way. Src-layout and re-export entries keep their old meaning.

Round 2 (head 7dc5d39): no blocking findings. The reviewer checked every reader of ambiguous_src_modules and found each one either root-gated or able only to remove credit. Pre-existing src-layout and re-export behavior is unchanged. Recommended tests added in d54e0f3: a test outside the project with no rival, and a rival module whose name equals the owner's project name. The package-attribute test now asserts both the own-project and sibling-project outcomes.

Non-blocking follow-up filed as #13706: a test-local helper svc/a/tests/core.py can shadow the project module under prepend mode.

Local proof on d54e0f3: layout_tests 7/7 pass. The Python lib suite passed 1964/0 on 7dc5d39 (the d54 delta is test-only). cargo xtask precommit is running.


Generated by Claude Code

Copy link
Copy Markdown
Member Author

SOURCE_REVIEW_READY

Head: d54e0f34fa646d5aff400adf4bde2229aa7151cb. Independent fresh-context review: round 1 had 3 blocking findings, fixed in 7dc5d39. Round 2 was clean at 7dc5d39. The d54e0f3 delta is test-only and adds the tests round 2 recommended. Details are in the review record comment above.

Local proof on this head: cargo xtask precommit reports Status: pass. Goldens and schema-producer were skipped because no output surface or schema changed. layout_tests passed 7/7, and the Python lib suite passed 1964/0. The first precommit attempt lost its rustc to an OOM SIGKILL, which is an infrastructure failure. The rerun with one build job passed.

Hosted qualification is requested next via merge-ready.


Generated by Claude Code

@EffortlessSteven
EffortlessSteven marked this pull request as ready for review November 8, 2026 13:08
@gemini-code-assist

Copy link
Copy Markdown

Warning

You have reached your daily quota limit. Please wait up to 24 hours and I will start processing your requests again!

@devin-ai-integration devin-ai-integration Bot 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.

Devin Review found 5 potential issues.

Devin Review

@EffortlessSteven EffortlessSteven left a comment

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

SOURCE_REVIEW_READY for the current head d54e0f3

Two independent fresh-context review rounds ran on this candidate; the PR conversation has the full record. Round 1 findings (three false-credit paths) were repaired in 7dc5d39, and round 2 at 7dc5d39 found nothing further. d54e0f3 adds only the tests round 2 recommended. Local precommit status: pass. Hosted qualification follows.


Generated by Claude Code

@github-actions

github-actions Bot commented Nov 8, 2026 •

Copy link
Copy Markdown
Contributor

ripr static exposure check

Commit 2d89c19c82b5 · run · advisory, static evidence only (not a mutation run).

#ripr agent static-advisory base=ab93e28c665bdc75242bc33f4db3a21854126f04 findings=85 gaps=14 infection_unknown=7 no_static_path=13 propagation_unknown=5 reachable_unrevealed=14 static_unknown=38 weakly_exposed=8
reachable_unrevealed|crates/ripr/src/analysis/language/python/related_tests/project_names.rs:43|dir = current.parent();|missing=No statically established oracle: assertion execution or macro binding is unesta…|test=t1|id=probe:crates_ripr_src_analysis_language_python_related_tests_project_names.rs:call_deletion:195ec249
reachable_unrevealed|crates/ripr/src/analysis/language/python/related_tests/project_names.rs:41|return Some(current.to_path_buf())|missing=No statically established oracle: assertion execution or macro binding is unesta…|test=t2|id=probe:crates_ripr_src_analysis_language_python_related_tests_project_names.rs:return_value:76816ae9
reachable_unrevealed|crates/ripr/src/analysis/language/python/related_tests/project_names.rs:54|let Ok(relative) = file.strip_prefix(root) else {|missing=No statically established oracle: assertion execution or macro binding is unesta…|test=t3|id=probe:crates_ripr_src_analysis_language_python_related_tests_project_names.rs:return_value:5709dc31
reachable_unrevealed|crates/ripr/src/analysis/language/python/related_tests/project_names.rs:57|let Some(full) = owner_module_paths(relative).into_iter().next() else {|missing=No statically established oracle: assertion execution or macro binding is unesta…|test=t4|id=probe:crates_ripr_src_analysis_language_python_related_tests_project_names.rs:return_value:b5a1d880
reachable_unrevealed|crates/ripr/src/analysis/language/python/related_tests/project_names.rs:88|let mut has_marker = \|dir: &Path\| {|missing=let mut has_marker = \|dir: &Path\| {|test=t5|id=probe:crates_ripr_src_analysis_language_python_related_tests_project_names.rs:field_construction:cd5ca600
reachable_unrevealed|crates/ripr/src/analysis/language/python/related_tests/project_names.rs:89|*marker_cache.entry(dir.to_path_buf()).or_insert_with(\|\| {|missing=No statically established oracle: assertion execution or macro binding is unesta…|test=t6|id=probe:crates_ripr_src_analysis_language_python_related_tests_project_names.rs:call_deletion:a95cd555
t1=crates/ripr/src/analysis/new_test_target/preflight_tests.rs:170 a_broken_member_manifest_refuses_instead_of_falling_to_the_parent unknown miss=assertion_admission_unproven
t2=crates/ripr/src/app/repair_attempt/mod.rs:8605 after_phase_window_reports_an_a_b_a_swap_as_not_current relational_check `if !current { return Err("a quiet window at the manifest head must be current".t…` miss=no_call_path
t3=crates/ripr/src/lsp/backend.rs:11392 absolute_join_keeps_absolute_paths_and_joins_relative_paths relational_check `if !already_absolute.is_absolute() { return Err(format!( "expected temp_dir-deri…` miss=no_call_path
t4=crates/ripr/src/analysis/classify/owner_pin/tests.rs:11262 a_crate_relative_path_in_another_target_is_not_the_owners_crate unknown miss=assertion_admission_unproven
t5=crates/ripr/src/cli/commands/agent.rs:5855 agent_brief_files_reject_parent_dir_escape relational_check `assert!( message.to_string().contains("must stay under root"), "unexpected error…` miss=no_call_path
t6=crates/ripr/src/analysis/language/typescript/tests/class_entry_tests.rs:353 a_direct_call_of_the_helper_wins_over_the_entry unknown miss=assertion_inert
+8 more gaps not shown; `--format json` lists all
limits=infection_unknown:7,no_static_path:13,propagation_unknown:5,static_unknown:38,weakly_exposed:8
next=ripr explain --root . --base ab93e28c665bdc75242bc33f4db3a21854126f04 --committed --mode draft --format agent probe:crates_ripr_src_analysis_language_python_related_tests_project_names.rs:call_deletion:195ec249
verify=refused|outcome=complete_with_findings|findings=85|exposed=0|reason=gaps_remain

Took 78s.

…name collision

A project's lib/core.py is lib.core, not core, and pkg.py beside
pkg/__init__.py leaves the shared name identifying neither. Spec 0028
records the project-relative identity rule.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01UNUoLVHnMQXBm6voKj1B8e
…roots only

The 3f59e15 lib filter missed a lone lib/core.py directly under the
project; the new test with no top-level core.py fails without this.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01UNUoLVHnMQXBm6voKj1B8e

EffortlessSteven commented Nov 8, 2026 •

Copy link
Copy Markdown
Member Author

Review record, continued.

Devin raised 2 real false-credit edges: a nested lib/ module, and pkg.py beside pkg/__init__.py. Both are fixed in 3f59e15, and spec 0028 is updated. The 2 missed-credit notes (repo-scan mode and nested re-exports) are tracked in #13737.

Round 3 (fresh-context reviewer, head 3f59e15) found two blocking problems:

  • The lib/ filter missed a lone lib/core.py.
  • The test for it did not discriminate, because it passed through the collision skip.

Both are fixed in 80793d9. Project-relative names are now built from the full relative path plus src/ roots only. A new test with no top-level core.py fails on 3f59e15 and passes on 80793d9.

Round 3 re-check (head 80793d9) came back clean. The reviewer traced these shapes: lib/core.py, lib/x/core.py, lib/src/pkg/core.py, lib.py, pkg/__init__.py, src/__init__.py, src/pkg/core.py.

The pre-existing src-layout short-name collision it noted is filed as #13745.

Local proof on 80793d9: layout_tests passes 10/10, and the Python lib suite passes 1969/0. check-spec-format passes. Precommit is running.


Generated by Claude Code

@github-actions

github-actions Bot commented Nov 8, 2026

Copy link
Copy Markdown
Contributor

merge-ready is set, but no qualification run exists for head 80793d98: it was pushed after the label was applied, or the label event was dropped. Remove and re-apply merge-ready to request it again.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01UNUoLVHnMQXBm6voKj1B8e
@github-actions

github-actions Bot commented Nov 8, 2026

Copy link
Copy Markdown
Contributor

merge-ready is set, but no qualification run exists for head 52b9f238: it was pushed after the label was applied, or the label event was dropped. Remove and re-apply merge-ready to request it again.

@EffortlessSteven EffortlessSteven left a comment

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

SOURCE_REVIEW_READY for the current head 52b9f23

Three independent fresh-context review rounds and the Devin findings were each repaired with discriminating tests. The round 3 re-check at 80793d9 was clean, and 52b9f23 only applies a clippy contains rewrite. Local precommit status: pass. The review record and follow-up issues are in the PR conversation. Hosted qualification follows.


Generated by Claude Code

…fixture fix)

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01UNUoLVHnMQXBm6voKj1B8e

@EffortlessSteven EffortlessSteven left a comment

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

SOURCE_REVIEW_READY for the current head e1f739c

The earlier hosted run failed check-fixture-contracts on fixtures/module_reach_control_qualified, a Rust fixture this PR does not touch. Main fixed it in #13773. e1f739c is a merge of current main with no conflicts, so the source delta is unchanged from the reviewed 52b9f23. After the merge, check-fixture-contracts passes locally and layout_tests passes 10/10.


Generated by Claude Code

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01UNUoLVHnMQXBm6voKj1B8e
main went red when #13667 (ripr completions) and #13731 (CLI reference
freshness test) landed independently; the reference lacked the new
command. Regenerated with RIPR_BLESS_CLI_REFERENCE=1.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01UNUoLVHnMQXBm6voKj1B8e

Copy link
Copy Markdown
Member Author

CI note: on e1f739c, Rust-only feature lane failed on cli_reference_doc::cli_reference_matches_the_binary, which is not this PR's code. Main has been red on this test since #13667 (ripr completions) and #13731 (the CLI reference freshness test) landed independently: docs/CLI_REFERENCE.md lacks the completions entry. #13778 fixed an earlier staleness, but this one remains on current main, and I found no open fix PR.

9dc9c0e merges current main and regenerates the reference with RIPR_BLESS_CLI_REFERENCE=1. The regenerated diff is +30 lines, all of them the completions row and section. cli_reference_doc passes 2/2 locally. That keeps this PR green and repairs main when it lands. If another fix reaches main first, the merge is trivial.


Generated by Claude Code

@EffortlessSteven EffortlessSteven left a comment

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

SOURCE_REVIEW_READY for the current head 9dc9c0e

The Python source delta is unchanged from the reviewed 52b9f23. This head adds two things: a clean merge of current main, and a regenerated docs/CLI_REFERENCE.md. The regeneration adds only the ripr completions row and section, produced by the repository's own bless command, and repairs the stale reference on main. cli_reference_doc and layout_tests pass locally.


Generated by Claude Code

@github-actions

github-actions Bot commented Nov 8, 2026

Copy link
Copy Markdown
Contributor

merge-ready is set, but this PR conflicts with main (head 9dc9c0e1), so GitHub creates no test-merge ref and no qualification run can start. Merge main into the branch and resolve the conflicts, then remove and re-apply merge-ready.

Resolves conflicts with #13745 (src short-name plain-module rival): both
the shadowing rule and the nested-project names are kept, and project
names record shadowed: false since same-project collisions already
identify neither. The new code moves to related_tests/project_names.rs
so the PR-evidence scoped check does not have to re-analyze a large
diff in the 4k-line related_tests.rs.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01UNUoLVHnMQXBm6voKj1B8e

Copy link
Copy Markdown
Member Author

CI note for 9dc9c0e: Ripr Rust Small failed because the PR-evidence ripr check hit its 3600s timeout. Every other check was green.

Cause. The slowdown came from the diff, not the binary. I reproduced it locally against the same base with the PR's debug binary:

Diff checked Result
Full PR diff still running at 1200s
related_tests.rs part alone still running at 400s
layout_tests.rs part alone 88s
python.rs and reexport_tests.rs parts 245s

Passing PRs finish this step in about 4 to 8 minutes. The new code sat inside the ~4.2k-line related_tests.rs, and the scoped check stalls on that edit.

Fix, in aef162e:

  • Merged main and resolved the conflicts with python: a src-layout short name is credited even when a same-named top-level module sits in the same project #13745 in related_tests.rs and RIPR-SPEC-0028. Both rules are kept. Project-relative names record shadowed: false, because same-project collisions already identify neither module.
  • Moved the project-name code into the child module related_tests/project_names.rs. It is byte-identical apart from pub(in crate::analysis::language::python) visibility and the new field.
  • The PR diff to related_tests.rs is now 18 lines: the module declaration, the re-export, and the three call sites.

Proof on aef162e:

  • The local scoped check on the full PR diff finishes in 307s, exit 0.
  • cargo test -p ripr --lib analysis::language::python: 1977 passed, 0 failed.
  • cargo xtask precommit: pass.

A scoped check that takes over an hour on a 160-line edit to a large file is a ripr performance problem in its own right. I'll file it separately.


Generated by Claude Code

@EffortlessSteven EffortlessSteven left a comment

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

SOURCE_REVIEW_READY for the current head aef162e

What was inspected for the delta since 9dc9c0e:

  • The merge of main and the conflict resolution with #13745. Both the plain-module shadowing rule and the nested-project names are kept. Project names set shadowed: false, because a same-project collision is already skipped before the entry is recorded.
  • The move into related_tests/project_names.rs. Diffing the moved code against the original shows only the visibility change and the new field.
  • The bare_name_bound_to_other_module clause for shadowed src short names. Those names are owner paths, so the clause is unchanged from main.
  • Proof: 1977 Python adapter tests pass, precommit passes, and the local scoped PR-evidence check finishes in 307s.

The two earlier fresh-context review rounds still cover the logic, which is unchanged.


Generated by Claude Code

Copy link
Copy Markdown
Member Author

paste-ubuntu-latest fails on aef162e with E0004 at crates/ripr/src/output/format.rs:450: &OutputFormat::MissedTxt is not covered.

That match comes from main through the missed-txt format change; this PR does not touch output/. The fix is already open as #13848 (cover missed-txt in is_json_request), so I'm not porting a duplicate here. The required Ripr Rust Small Result check is unaffected unless it reports otherwise.


Generated by Claude Code

@github-actions github-actions Bot 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.

Decision

  • Needs focused proof failure resolved before upstream.

Test proof

  • Focused HEAD proof failed (exit 101): cargo test --locked --package ripr --test agent_command_journey. This is a current failure, not a red/green witness.

@EffortlessSteven EffortlessSteven left a comment

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

SOURCE_REVIEW_READY for the current head 2d89c19

The only change since aef162e is a clean merge of main, which brings in the MissedTxt compile fix from #13848. No files of this PR conflicted.

  • The lib compiles.
  • cargo test -p ripr --lib analysis::language::python: 1990 passed, 0 failed.

Generated by Claude Code

@EffortlessSteven
EffortlessSteven merged commit c40e5d6 into main Nov 8, 2026
75 of 76 checks passed
@EffortlessSteven
EffortlessSteven deleted the claude/project-thread-hzxvi0 branch November 8, 2026 22:11
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants