Skip to content

fix: break governance↔tracing circular import on cold CLI start#445

Open
Prateeks16 wants to merge 1 commit into
sreerevanth:mainfrom
Prateeks16:fix/cli-circular-import
Open

fix: break governance↔tracing circular import on cold CLI start#445
Prateeks16 wants to merge 1 commit into
sreerevanth:mainfrom
Prateeks16:fix/cli-circular-import

Conversation

@Prateeks16

@Prateeks16 Prateeks16 commented Jun 19, 2026

Copy link
Copy Markdown
Contributor

Problem

Cold python -c "import agentwatch.cli.main" (and python -m agentwatch.cli.main --help) fails:

ImportError: cannot import name 'TraceCollector' from partially initialized module
'agentwatch.tracing.collector' (most likely due to a circular import)

Chain: cli/__init__cli/demotracing/collectorgovernance/hipaagovernance/__init__compliance_reportertracing.collector (still mid-import). It only worked under pytest because an earlier test imports agentwatch.governance first, masking the cycle — so the published CLI entrypoint was broken from a cold interpreter.

Fix

governance/compliance_reporter.py uses TraceCollector only as a type annotation and already has from __future__ import annotations, so the runtime import is unnecessary. Moved it under TYPE_CHECKING. One-line-class change, no behavior difference.

Verification

python -c "import agentwatch.cli.main"          # now succeeds cold
python -m agentwatch.cli.main --help            # works
pytest tests/                                    # 491 passed, no new failures

The 10 test_cli_* failures that remain on main (duplicate session_app routing + a result.stderr test bug) are pre-existing and out of scope here — fixed separately in #444 (#405). They'll clear once either lands.

Cold `python -c "import agentwatch.cli.main"` failed with a circular import:
cli -> tracing.collector -> governance.hipaa -> governance/__init__ ->
compliance_reporter -> tracing.collector (mid-import). It only worked under
the test suite because an earlier test imported governance first.

compliance_reporter only uses TraceCollector as a type annotation and already
has `from __future__ import annotations`, so move the import under
TYPE_CHECKING. Runtime cycle gone, annotation preserved.

Verified: `python -c "import agentwatch.cli.main"` succeeds cold; full suite
unchanged (pre-existing CLI session_app/stderr failures are out of scope,
fixed separately in sreerevanth#405).

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
Copilot AI review requested due to automatic review settings June 19, 2026 17:24

Copilot AI 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.

Copilot was unable to review this pull request because the user who requested the review has reached their quota limit.

@github-actions

Copy link
Copy Markdown

🧪 PR Test Results

Check Result
Tests (pytest tests/) ❌ failure
Lint (ruff check .) ✅ success
Coverage (agentwatch) 72.70%

Python 3.12 · commit 17e62e6

@coderabbitai

coderabbitai Bot commented Jun 19, 2026

Copy link
Copy Markdown
Contributor

Warning

Review limit reached

@Prateeks16, we couldn't start this review because you've reached your PR review rate limit.

More reviews will be available in 21 minutes and 18 seconds. Learn how PR review limits work.

Your organization has used up its prepaid credits, and credit purchases are no longer available. Enable the review add-on in the billing tab to keep reviews running — you're only billed for reviews past your plan's rate limits ($0.25/file).

⌛ How to resolve this issue?

After more reviews become available, a review can be triggered using the @coderabbitai review command as a PR comment. Alternatively, push new commits to this PR.

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 refill rate.

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, the refill rate gradually slows as usage increases. The highest same-day bursts are limited more strictly.

Please see our Fair Usage Limits Policy for further information.

ℹ️ Review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro Plus

Run ID: 5007fb1e-0a40-4e64-a439-d43a51d3e714

📥 Commits

Reviewing files that changed from the base of the PR and between e3012c5 and 17e62e6.

📒 Files selected for processing (1)
  • agentwatch/governance/compliance_reporter.py
✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests

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 and usage tips.

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.

3 participants