Repository navigation
Extract shared thread-analysis vocabulary into pr_threads.py (#600 §5) - #695
Conversation
First de-braiding step toward collapsing review_feedback_loop.py: the pure, side-effect-free thread predicates that BOTH the review-state projector (concerns A/B/C) and the looker/attestation subsystem (concern D) reason over move into a single shared module. The call-site audit confirms the split — _thread_is_bot_only / _thread_resolution_disposition / _count_committable_ suggestion_threads / _thread_authors / _thread_has_attested_look / _author_is_bot / _thread_has_committable_suggestion / _thread_resolved_by and their constants are used across both concerns, so they're shared-lib (#600 §5 "imported by both, duplicated by neither"), not thread-witness-only. The attestation/looker-queue builders stay for the concern-D extraction that lands next. The engine imports the names back, so its surface and every test reference is unchanged; the test loader puts .github/scripts on sys.path (production runs the script directly, which already does). No behavior change: the functions moved verbatim, doctrine comments intact. Engine suite 100/100, ruff clean. Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01MU1zvEUacde5fmYpMvK8aK
|
You have reached your Codex usage limits for code reviews. You can see your limits in the Codex usage dashboard. |
Qodo reviews are paused for this user.Troubleshooting steps vary by plan Learn more → On a Teams plan? Using GitHub Enterprise Server, GitLab Self-Managed, or Bitbucket Data Center? |
Reviewer's GuideExtracts shared, pure thread-analysis helpers and constants from the review engine into a new pr_threads module, then wires the engine and its tests to consume that module without changing behavior or control flow. File-Level Changes
Tips and commandsInteracting with Sourcery
Customizing Your ExperienceAccess your dashboard to:
Getting Help
|
|
Warning Review limit reached
More reviews will be available in 51 minutes and 22 seconds. Learn how PR review limits work. To continue reviewing without waiting, enable usage-based billing in the billing tab. ⌛ How to resolve this issue?After more reviews become available, a review can be triggered using the To avoid repeated limits, reduce automatic review volume by pausing incremental auto-reviews earlier, using label-based review opt-in, excluding WIP or generated PR titles, or requesting reviews manually when the PR is ready. If your team needs uninterrupted high-volume reviews, an organization admin can enable usage-based credits. 🚦 How do rate limits work?CodeRabbit enforces per-developer PR review limits for each organization. Most developers receive the normal plan review availability. For paid Pro and Pro+ PR reviews, CodeRabbit uses adaptive limits for sustained high-volume activity. When a developer's recent PR review activity reaches the 95th percentile or higher among CodeRabbit users, additional reviews become available more gradually as earlier reviews age out of the rolling window. Please see our Fair Usage Limits Policy for further information. ℹ️ Review info⚙️ Run configurationConfiguration used: Path: .coderabbit.yaml Review profile: CHILL Plan: Pro Plus Run ID: 📒 Files selected for processing (3)
📝 WalkthroughWalkthroughA new ChangesThread-analysis extraction into pr_threads
Estimated code review effort🎯 2 (Simple) | ⏱️ ~10 minutes Possibly related PRs
Poem
🚥 Pre-merge checks | ✅ 4 | ❌ 1❌ Failed checks (1 warning)
✅ Passed checks (4 passed)
✨ 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 |
There was a problem hiding this comment.
Hey - I've found 1 issue, and left some high level feedback:
- Consider switching the
pr_threadsimports inreview_feedback_loop.pyto a relative import (e.g.from . import pr_threads) so the module relationship is explicit and you don’t need tests to mutatesys.pathfor sibling resolution. - Given
pr_threadsis intended as a shared library, you may want to drop the leading underscores on its functions/constants that are part of the shared vocabulary or explicitly define an__all__to clarify what is considered public vs engine-internal.
Prompt for AI Agents
Please address the comments from this code review:
## Overall Comments
- Consider switching the `pr_threads` imports in `review_feedback_loop.py` to a relative import (e.g. `from . import pr_threads`) so the module relationship is explicit and you don’t need tests to mutate `sys.path` for sibling resolution.
- Given `pr_threads` is intended as a shared library, you may want to drop the leading underscores on its functions/constants that are part of the shared vocabulary or explicitly define an `__all__` to clarify what is considered public vs engine-internal.
## Individual Comments
### Comment 1
<location path="tests/test_review_feedback_loop.py" line_range="17-22" />
<code_context>
def _load_review_feedback_loop_module():
project_root = Path(__file__).resolve().parents[1]
- script_path = project_root / ".github" / "scripts" / "review_feedback_loop.py"
+ scripts_dir = project_root / ".github" / "scripts"
+ # The engine now imports its shared thread-analysis lib (pr_threads) as a
+ # sibling module; loading it by file path needs the scripts dir importable.
+ # Production runs the script directly, which already has this on sys.path[0].
+ if str(scripts_dir) not in sys.path:
+ sys.path.insert(0, str(scripts_dir))
+ script_path = scripts_dir / "review_feedback_loop.py"
spec = importlib.util.spec_from_file_location("review_feedback_loop_test_module", script_path)
</code_context>
<issue_to_address>
**suggestion (testing):** Avoid permanently mutating sys.path in tests, or scope the change to reduce cross-test coupling
This helper adds `.github/scripts` to `sys.path` for the entire test run, creating global state that can unexpectedly affect other tests (e.g., ones that depend on `sys.path` ordering or on that directory not being present). Please limit the scope of this change—for example, save and restore `sys.path` around the import or use a context manager to temporarily adjust `sys.path` while loading the module—to keep the loader self-contained and avoid cross-test interference.
Suggested implementation:
```python
def _load_review_feedback_loop_module():
project_root = Path(__file__).resolve().parents[1]
scripts_dir = project_root / ".github" / "scripts"
# The engine now imports its shared thread-analysis lib (pr_threads) as a
# sibling module; loading it by file path needs the scripts dir importable.
# Production runs the script directly, which already has this on sys.path[0].
original_sys_path = list(sys.path)
try:
if str(scripts_dir) not in sys.path:
sys.path.insert(0, str(scripts_dir))
script_path = scripts_dir / "review_feedback_loop.py"
spec = importlib.util.spec_from_file_location("review_feedback_loop_test_module", script_path)
module = importlib.util.module_from_spec(spec)
assert spec.loader is not None
finally:
# Restore sys.path so tests don't retain this mutation globally
sys.path = original_sys_path
```
If there are further lines in `_load_review_feedback_loop_module` that execute the spec loader (e.g., `spec.loader.exec_module(module)` or `return module`), they should be indented to live inside the `try:` block so that all imports that rely on the temporary `sys.path` adjustment occur before it is restored.
</issue_to_address>Help me be more useful! Please click 👍 or 👎 on each comment and I'll use the feedback to improve your reviews.
- review_feedback_loop: re-export _author_is_bot / _thread_has_committable_ suggestion via `import pr_threads` + assignment instead of `import … as …`, so static analysis (github-code-quality) registers a concrete use rather than flagging the re-export as an unused import. Surface unchanged. - test loader: scope the .github/scripts sys.path insertion to the exec and restore it in a finally, so the test run's global sys.path isn't left mutated (per Sourcery). The import binds during exec; pr_threads stays in sys.modules. Engine suite 100/100, ruff clean. No behavior change. Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01MU1zvEUacde5fmYpMvK8aK
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 @.github/scripts/review_feedback_loop.py:
- Around line 40-56: Re-export the moved regex constants from
review_feedback_loop.py so the module surface stays backward compatible. Update
the import block that already re-exports pr_threads symbols to also import
LOOK_ATTESTATION_RE and SUGGESTION_BLOCK_RE from pr_threads, alongside the
existing helpers like _author_is_bot and _thread_has_committable_suggestion.
This keeps callers and tests that still import those constants from
review_feedback_loop.py working without changing the new ownership in
pr_threads.py.
🪄 Autofix (Beta)
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: Path: .coderabbit.yaml
Review profile: CHILL
Plan: Pro Plus
Run ID: 18db90e7-cc6d-4595-b336-9c170cb22314
📒 Files selected for processing (3)
.github/scripts/pr_threads.py.github/scripts/review_feedback_loop.pytests/test_review_feedback_loop.py
github-code-quality flagged the re-export of _author_is_bot / _thread_has_committable_suggestion every way it was spelled (unused import, then unused global + mixed import style) — correctly: the engine reaches them only transitively via _thread_resolution_disposition, so re-exporting them keeps unused names on its surface. Stop pretending the engine owns them: import only the 8 names the engine actually uses, and test the two relocated predicates against pr_threads (their real home), via sys.modules after the engine's load. Also adds the one missing docstring (_thread_authors) so the new shared module is fully documented. Engine suite 100/100, ruff clean. No behavior change. CodeRabbit's separate suggestion to re-export LOOK_ATTESTATION_RE / SUGGESTION_BLOCK_RE is declined: a repo-wide grep finds no caller importing those constants from review_feedback_loop, so re-exporting would only add the unused-import warnings this commit removes. Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01MU1zvEUacde5fmYpMvK8aK
AGENT PR TEMPLATE
Agent: Claude
Date: 2026-06-29
Branch: claude/extract-pr-threads-vocab-u8hlk0
Changes Made
.github/scripts/pr_threads.py— the pure, side-effect-free thread-analysis vocabulary both engine concerns reason over:_author_is_bot,_thread_is_bot_only,_thread_resolved_by,_thread_has_attested_look,_thread_has_committable_suggestion,_thread_resolution_disposition,_count_committable_suggestion_threads,_thread_authors, plus their constants (LOOK_ATTESTATION_RE,SUGGESTION_BLOCK_RE,ATTESTATION_DECISIONS,BARE_RESOLVABLE_DISPOSITIONS). Moved verbatim, doctrine comments intact..github/scripts/review_feedback_loop.py— deletes that block (net −140 lines) and imports the names back, so the engine's surface is unchanged. The 8 names its control flow still uses are plain imports;_author_is_bot/_thread_has_committable_suggestion(reached now only transitively, but referenced by tests) are explicit re-exports.tests/test_review_feedback_loop.py— the by-path loader now puts.github/scriptsonsys.pathso the engine's new sibling import resolves under test (production runs the script directly, which already does).Related Work
_fetch_pr, thread walking, … imported by both, duplicated by neither" — this is its load-bearing first member. A call-site audit (not a guess) established the boundary: these predicates are used by both review-state (concern B/C) and the looker (concern D), so they're shared-lib, not thread-witness-only. The attestation/looker-queue builders are concern-D output and move with the thread-witness extraction that lands next.gh_clishared primitive) — same "atomized shared lib" direction, independent file. Branched off cleanmain; the moved region is untouched by Retire the engine's protected-path veto; defer to the CODEOWNERS hard gate (K1/K2) #689/fix(ci): remove merge_group trigger from PULLMAN Cloud Run deploy #691, so no conflict.Blockers
Verification
tests/test_review_feedback_loop.py).ruffclean;py_compileOK.branch_garden_report,issue_reconciler[needs a realghbinary — passes in CI],uv_dependency_submission,workflow_security_invariants). Verified they fail identically on cleanmainwith this change stashed out — they are not introduced here.Checklist:
main, verified)Risk Level:
Labels to apply:
agent:claude-codeReady for Logan to review and merge.
Generated by Claude Code
Summary by Sourcery
Extract shared review thread-analysis helpers into a new shared module and update the engine and tests to consume it without changing behavior.
Enhancements:
Tests:
Summary by CodeRabbit