Skip to content

fix(monorepo): find sibling-package tests and self-imports; stop crediting same-named modules (#4552, #4553, #4554, #4566, #4769) - #4611

Merged
EffortlessSteven merged 12 commits into
mainfrom
claude/project-thread-4ws691
Sep 29, 2026
Merged

EffortlessSteven merged 12 commits into
mainfrom
claude/project-thread-4ws691

Conversation

@EffortlessSteven

@EffortlessSteven EffortlessSteven commented Sep 29, 2026 •

Copy link
Copy Markdown
Member

Requested by Steven · project thread

Summary

Monorepo defects found walking real OSS workspaces (tokio-rs/tracing, vitest-dev/vitest, microsoft/autogen, pmndrs/zustand) on swarm main 02e1abf.

Swarm / Source Boundary

  • ordinary feature, analyzer, editor, docs, spec, fixture, badge, dependency, or repo-ops development for ripr-swarm

Source-of-truth Links

Governing issue or accepted claim: #4552, #4553, #4554, #4566, #4769
Acceptance delta (one sentence): In a Cargo-less monorepo, sibling-package tests that import the changed code (by path, alias or package name) are found from any package directory, and a same-named module in another package no longer supplies a discriminator.

Candidate Relationships

Candidate branch: claude/project-thread-4ws691. I searched open PRs for same_package_root, the workspace root walk, Python src-layout identity and workspace package resolution, and found no equivalent. #4502 (barrel re-exports) edits a different function in typescript/related_tests.rs.

Scope

  • cli/commands/check.rs: JS/Python workspace markers in the project-root walk.
  • analysis/language/typescript/{related_tests,static_limit,classifier}.rs: admit import-anchored cross-package relations, and anchor the constructor arm across packages.
  • analysis/language/typescript/{workspace_packages,tsconfig,mod}.rs: new workspace package resolver, consulted after tsconfig paths.
  • analysis/language/python/{related_tests,sink_alignment,python}.rs and call sites: src-layout module identity that depends on where the test lives, filled in by the diff-mode workspace pass.

Non-goals:

Support-tier Impact

  • changes a README, release, docs, CLI, JSON, editor, CI, or package claim: the docs/CONFIGURATION.md --root and resolve_tsconfig_paths rows, the docs/OUTPUT_SCHEMA.md typescript_target_unresolved producer note, and CHANGELOG.

Policy Impact

  • none

Proof

cargo test -p ripr --lib        # 6486 passed on the eaf2290 merge; TS suites 630 passed on 9c15c26
cargo xtask precommit           # exit 0 on 9c15c26

New tests:

  • project_root_walk_reaches_a_js_or_python_workspace_from_a_package, project_root_walk_ignores_markers_above_the_git_top_level (beside check from a crate subdirectory reports a complete, clean analysis while dropping the findings #4610's own root-walk tests)
  • package_local_filter_admits_cross_package_test_importing_owner_file, cross_package_constructor_requires_owner_class_import, unresolved_ownership_import_branch_with_relative_paths
  • workspace_packages unit tests: exports with a source condition, build-output mirror into src (and fail-closed when the mirror is missing), zustand self-import, main/pattern/deep paths, duplicate/divergent/escaping, two-candidate extensionless target, paths key blocks package fallback
  • unresolved_workspace_package_import_names_the_manifest
  • shared_src_layout_module_name_identifies_owner_only_from_its_project, nested_src_layout_rival_claims_tests_under_its_own_root
  • end to end: same_named_src_package_in_another_project_lends_no_exposure, six import shapes, test in a vs b

Negative experiments:

  • Forcing the ambiguity check open makes the from-module row fail.
  • Disabling the method-identity gate makes the class-method row fail.
  • Skipping re-export names makes the package-reexport row fail.

Re-walk on the fixed release binary:

Repo Before After
vitest, test/unit test importing ../../../packages/utils/src/helpers no_static_path exposed, direct_owner_call
vitest, test/unit test importing @vitest/utils/helpers no_static_path exposed, 4 related tests
autogen, run from python/packages/autogen-core root ., no_static_path root python/ ([tool.uv.workspace]), exposed
two shared.calc packages exposed via b/tests weakly_exposed
tracing, run from tracing-core Cargo walk unchanged
zustand, combine.ts change, tests import zustand/middleware no_static_path weakly_exposed, tests/middlewareTypes.test.tsx

Claim Boundary

May claim:

  • sibling-package discovery from a package directory for pnpm/npm/yarn/bun/uv workspaces;
  • TS cross-package tests that import the owner file by relative path, tsconfig alias or in-workspace package name, and a package's own tests importing it by name;
  • Python same-name src modules and packages no longer cross-credit in diff mode.

Must not claim:

Rollback

Revert the squash commit. There is no schema or config change.

Static Language Check

  • Static output avoids killed, survived, untested, proven, and adequate.

CI Economics

n/a

Engineering Check

  • No new panic, unwrap, expect, todo, or unimplemented in production code.
  • No new panic, unwrap, expect, todo, or unimplemented in tests.

Gates

  • cargo fmt --check
  • cargo xtask precommit

🤖 Generated with Claude Code

https://claude.ai/code/session_01EqbiiuYkC94scgE9rZ5K8W

…ed modules

- check: without --root, a package directory of a pnpm/npm/yarn/bun or uv
  workspace now roots at the workspace (after the Cargo walk finds none),
  bounded by the git work tree; stderr names the manifest (#4553).
- typescript: an owner-call relation anchored to the owner's own file by
  import is admitted across package roots; the package filter stays on
  name/path proximity, and typescript_target_unresolved skips admitted
  tests (#4552).
- python: a src-layout short module name two workspace files share
  identifies the owner only for a test under the owner's project root,
  so package b's test no longer makes package a's change read exposed
  (#4566).

Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01EqbiiuYkC94scgE9rZ5K8W
@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 Sep 29, 2026
@EffortlessSteven
EffortlessSteven marked this pull request as ready for review September 29, 2026 01:53
@coderabbitai

coderabbitai Bot commented Sep 29, 2026 •

Copy link
Copy Markdown

Warning

Review limit reached

Next included review available in 1 minute.

Check out review usage here.

View limit details

Limit details: You’ve used the included review currently available.

You've used all free OSS reviews for now. Wait for the free limit to reset to keep reviewing this public repository.

Learn how review limits work.

Review configuration:

⚙️ Run configuration

Configuration used: Organization UI

Review profile: ASSERTIVE

Plan: Advanced

Run ID: 57635428-09cc-4455-bc5c-2ecf10a4819b

📥 Commits

Reviewing files that changed from the base of the PR and between df1b435 and 42cc04f.

📒 Files selected for processing (18)
  • CHANGELOG.md
  • crates/ripr/src/analysis/language/python.rs
  • crates/ripr/src/analysis/language/python/boundary.rs
  • crates/ripr/src/analysis/language/python/owners_tests.rs
  • crates/ripr/src/analysis/language/python/python_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/sink_alignment.rs
  • crates/ripr/src/analysis/language/typescript/classifier.rs
  • crates/ripr/src/analysis/language/typescript/mod.rs
  • crates/ripr/src/analysis/language/typescript/related_tests.rs
  • crates/ripr/src/analysis/language/typescript/static_limit.rs
  • crates/ripr/src/analysis/language/typescript/tests.rs
  • crates/ripr/src/analysis/language/typescript/tsconfig.rs
  • crates/ripr/src/analysis/language/typescript/workspace_packages.rs
  • crates/ripr/src/cli/commands/check.rs
  • docs/CONFIGURATION.md
  • docs/OUTPUT_SCHEMA.md

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.

❤️ Share

Comment @coderabbitai help to get the list of available commands.

@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!

@chatgpt-codex-connector

chatgpt-codex-connector Bot commented Sep 29, 2026 •

Copy link
Copy Markdown

Codex Review Summary

This comment shows the latest Codex review activity on this pull request.

Review Status Commit Review trigger
📝 Code Review ✅ Completed 2026-09-29T01:59:01.840029Z 7a345fa Draft marked ready
ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review" or "@codex security review".

Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings.

@chatgpt-codex-connector chatgpt-codex-connector Bot 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.

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: 7a345faeae

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

@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 3 potential issues.

Devin Review

- typescript: a bare import of an in-workspace package
  (`@vitest/utils/helpers`) resolves through that package's package.json
  `exports` (conditions, single-`*` patterns) or `source`/`module`/`main`
  fields to an indexed workspace source, exactly one or none. Duplicate
  package names, build-output-only targets, `.d.ts` and escaping paths fail
  closed. Works with or without tsconfig paths (#4554).
- typescript (review): the constructor arm's bare class-name match stays
  inside the owner's package; a sibling-package test must construct the
  class through a same-file or resolved import binding.
- python (review): the #4566 ambiguity check now also gates package
  re-exports (`from shared import f` where two projects ship `shared`),
  `import shared.calc as calc`, class imports for method owners, and the
  class-alias token, with an end-to-end control per import shape.

Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01EqbiiuYkC94scgE9rZ5K8W
Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01EqbiiuYkC94scgE9rZ5K8W
@EffortlessSteven EffortlessSteven changed the title fix(monorepo): find sibling-package tests and stop crediting same-named modules (#4552, #4553, #4566) fix(monorepo): find sibling-package tests and stop crediting same-named modules (#4552, #4553, #4554, #4566) Sep 29, 2026
- typescript: a specifier a tsconfig `paths` key owns never falls back to
  the workspace package entry; the compiler uses `paths`, so an
  unresolvable multi-entry key stays unresolved.
- typescript: an extensionless package target that two files satisfy
  (`foo.tsx` and `foo/index.ts`) fails closed instead of taking the first
  probe.
- python: `from shared import calc` checks `shared.calc` as well as
  `shared` against the #4566 ambiguity, and method-owner identity fails
  when every strong test imports a rival project's module (class via
  submodule, `calc.Calculator()`), not only the class name.

Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01EqbiiuYkC94scgE9rZ5K8W

Copy link
Copy Markdown
Member Author

Exact-head review record for 748a21d → 5e99727. Codex and Devin only reviewed 7a345fa, so an independent read-only pass covered the new resolver and the #4566 gates.

Fixed in 5e99727:

  1. TsAliasMap::resolve fell back to the workspace package entry whenever paths failed. That included a key that matched but whose substitutions this map cannot choose between (multi-entry, tie, two files). TypeScript would use paths there. It now falls back only when no key owns the specifier. Test: paths_key_owning_specifier_blocks_package_fallback.
  2. An extensionless package target took the first probe hit (foo/index.ts over foo.tsx). Exactly one hit is now required. Test: extensionless_target_with_two_candidate_files_fails_closed.
  3. Python: from shared import calc checked only calc/shared, and method identity only counted direct class imports. shared.calc is now checked too, and a method owner loses identity when every strong test imports a rival module. The end-to-end control gains package-submodule and class-via-package-submodule rows. The latter fails with the new check disabled.

Kept as designed: when a manifest maps a subpath to both src (a source/custom condition, or source/main) and unindexed dist, ripr credits the src file. dist is that package's build of the same source. Failing closed would drop the real vitest shape ("./helpers": {"__vitest_source__": "./src/helpers.ts", "default": "./dist/helpers.js"}), which is the #4554 case. When no target is an indexed source, ripr still fails closed.

Review status by provider:

  • CodeRabbit: rate-limited, so its review is missing.
  • Gemini: out of quota, missing.
  • droid-review: queued with no run, missing.
  • Codex and Devin: no review of the current head.

cargo xtask precommit exit 0 on 5e99727; cargo test -p ripr --lib analyzer suites pass.


Generated by Claude Code

…-4ws691

# Conflicts:
#	CHANGELOG.md
#	crates/ripr/src/cli/commands/check.rs
…e self-imports (#4554, #4769)

A package that exports only published build output (zustand: "./*" ->
"./*.js", "./esm/*.mjs") now resolves through the src/ counterpart of
those targets when no target is an indexed source, so its own tests that
import it by name relate to the changed source. The mirror must name
exactly one indexed source file, or the import stays unresolved.

Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01EqbiiuYkC94scgE9rZ5K8W
…s unresolved (#4769)

Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01EqbiiuYkC94scgE9rZ5K8W
@EffortlessSteven EffortlessSteven changed the title fix(monorepo): find sibling-package tests and stop crediting same-named modules (#4552, #4553, #4554, #4566) fix(monorepo): find sibling-package tests and self-imports; stop crediting same-named modules (#4552, #4553, #4554, #4566, #4769) Sep 29, 2026
…esolved_import

Main renamed the alias-limitation producer; the merge ref failed to compile.

Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01EqbiiuYkC94scgE9rZ5K8W
Conflict in typescript/related_tests.rs: main's OwnerPackageScope (#4607)
filtered owner-call candidates by package; #4552 exempts import-anchored
owner-call arms, so that filter stays off them. The constructor arm's
cross-package check now uses OwnerPackageScope since same_package_root is
test-only on main.

Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01EqbiiuYkC94scgE9rZ5K8W
@EffortlessSteven
EffortlessSteven merged commit 50aaefe into main Sep 29, 2026
22 checks passed
@EffortlessSteven
EffortlessSteven deleted the claude/project-thread-4ws691 branch September 29, 2026 07:00
EffortlessSteven pushed a commit that referenced this pull request Sep 29, 2026
Resolve conflicts with the monorepo project-identity change (#4611):
dotted-path submodule receivers (#4560) now require the import's module
to be the owner's project module, with a package-dotted-path row in the
rival-project test.

Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01LsNnp3aRU6BbCfas4WcqfS
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.

2 participants