Feat/verification import cycle detection#198
Conversation
TestSuiteGate.verify ran pytest via a hard-coded python3 interpreter with cwd set to file_path.parent. For nested files this misses the repo's pyproject.toml / pytest.ini / conftest.py and may use a different interpreter/venv than the host process, causing false positives or undiscovered tests and CI-vs-local mismatch. - Run pytest via sys.executable instead of python3. - Set cwd to the resolved project root (project_root or file dir). - Prepend the project root to PYTHONPATH for layouts that rely on it. - Add tests asserting the interpreter, cwd, and PYTHONPATH. Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
Implement Step 4 of ImportIntegrityVerifier, completing the deferred cycle-detection TODO, alongside two earlier verification improvements. Import cycle detection: transforms could previously introduce circular imports that pass syntax and resolvability checks yet break at runtime. ImportIntegrityVerifier now accepts a project_root and builds a bounded project-wide import graph; on a transform it diffs the changed module's import edges and reports cycles the transform introduces (pre-existing cycles are left untouched) with a clear blocking_reason such as "pkg.a -> pkg.b -> pkg.a". Both absolute and relative imports are handled; only first-party modules become graph edges. Guardrails keep it cheap: a 2000-file cap, a 5s time budget, a per-instance graph cache, and skip-lists for vendored directories; when any limit is hit or no project_root is given, the check is skipped rather than blocking. Complexity limits are documented in the class docstring. Also included: machine-readable JSON verification output via to_json_dict() helpers, a format_verification_result_json() formatter, and a `refactron verify` CLI command with --json; and an optional run-all mode (short_circuit flag plus --all-checks) that runs the full check pipeline so every failure category surfaces in a single run. Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
|
Warning Rate limit exceeded
You’ve run out of usage credits. Purchase more in the billing tab. ⌛ How to resolve this issue?After the wait time has elapsed, a review can be triggered using the We recommend that you space out your commits to avoid hitting the rate limit. 🚦 How do rate limits work?CodeRabbit enforces hourly rate limits for each developer per organization. Our paid plans have higher rate limits than the trial, open-source and free plans. In all cases, we re-allow further reviews after a brief timeout. Please see our FAQ for further information. ℹ️ Review info⚙️ Run configurationConfiguration used: defaults Review profile: CHILL Plan: Pro Run ID: 📒 Files selected for processing (11)
✨ Finishing Touches🧪 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 |
solve #191
This change implements Step 4 of ImportIntegrityVerifier — project-wide import-cycle detection — completing a long-deferred TODO. Previously a transform could introduce a circular import that still passed the syntax and resolvability checks yet broke at runtime, which undermined confidence in autofix and --verify. ImportIntegrityVerifier now accepts a project_root and builds a bounded, project-wide import graph; on each transform it diffs the changed module's import edges and reports any cycle the transform introduces —pre-existing cycles are deliberately left alone — with a clear blocking_reason such as pkg.a -> pkg.b -> pkg.a. Both absolute and relative imports are resolved, and only first-party modules become graph edges so stdlib and third-party imports are ignored. Several guardrails keep the check cheap and safe: a 2000-file scan cap, a 5-second time budget, a per-instance graph cache, and skip-lists for vendored directories such as venv and pycache; whenever a limit is hit or no project_root is supplied, cycle detection is silently skipped rather than blocking a transform, and the outcome is recorded in details["cycle_check"]. Complexity limits are documented in the class docstring, and new unit tests using minimal fake packages confirm that an introduced cycle is blocked with a clear reason, a non-cyclic transform passes, a pre-existing cycle is not blocked, and the check degrades gracefully when project_root is missing or the file lies outside it. The commit also carries two earlier verification improvements: machine-readable JSON output (to_json_dict() helpers, a format_verification_result_json() formatter, and a refactron verify CLI command with --json), and an optional run-all mode (short_circuit flag plus an --all-checks CLI flag) that runs the full check pipeline so every failure category surfaces in a single run.