fix: break governance↔tracing circular import on cold CLI start#445
fix: break governance↔tracing circular import on cold CLI start#445Prateeks16 wants to merge 1 commit into
Conversation
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>
🧪 PR Test Results
Python 3.12 · commit 17e62e6 |
|
Warning Review limit reached
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 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 configurationConfiguration used: Organization UI Review profile: CHILL Plan: Pro Plus Run ID: 📒 Files selected for processing (1)
✨ 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 |
Problem
Cold
python -c "import agentwatch.cli.main"(andpython -m agentwatch.cli.main --help) fails:Chain:
cli/__init__→cli/demo→tracing/collector→governance/hipaa→governance/__init__→compliance_reporter→tracing.collector(still mid-import). It only worked underpytestbecause an earlier test importsagentwatch.governancefirst, masking the cycle — so the published CLI entrypoint was broken from a cold interpreter.Fix
governance/compliance_reporter.pyusesTraceCollectoronly as a type annotation and already hasfrom __future__ import annotations, so the runtime import is unnecessary. Moved it underTYPE_CHECKING. One-line-class change, no behavior difference.Verification
The 10
test_cli_*failures that remain onmain(duplicatesession_approuting + aresult.stderrtest bug) are pre-existing and out of scope here — fixed separately in #444 (#405). They'll clear once either lands.