Unify the Rust-availability probes behind one resolver (#128) - #143
Conversation
|
Warning Review limit reachedYou’ve reached a temporary PR review limit under our Fair Usage Limits Policy. Next review available in: 46 minutes Your organization has reached its usage spending cap. Adjust your spending cap in the billing tab. How can I continue?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 reviews. How do review 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 refer docs for additional details. Review details⚙️ Run configurationConfiguration used: Organization UI Review profile: ASSERTIVE Plan: Pro Plus Run ID: 📒 Files selected for processing (14)
WalkthroughUnify public Rust availability checks with cached backend resolution, preserve a separate uncached native probe, add structured logging and tests, update Rust bindings, and document resolver, fallback, testing, and dispatch semantics. ChangesRust availability resolution
Sequence Diagram(s)sequenceDiagram
participant Caller as cuprum.rust.is_rust_available()
participant Backend as get_stream_backend()
participant Resolver as _check_rust_available()
participant Probe as _rust_backend.is_available()
Caller->>Resolver: request cached availability
Backend->>Resolver: request dispatch availability
Resolver->>Probe: probe native module when uncached
Probe-->>Resolver: return availability or raise ImportError
Resolver-->>Caller: return resolved boolean
Resolver-->>Backend: provide selection result
Possibly related PRs
Suggested reviewers: Poem
🚥 Pre-merge checks | ✅ 18 | ❌ 2❌ Failed checks (2 warnings)
✅ Passed checks (18 passed)
📋 Issue PlannerBuilt with CodeRabbit's Coding Plans for faster development and fewer bugs. View plan used: ✨ Finishing Touches🧪 Generate unit tests (beta)
Comment |
Reviewer's GuideUnifies all Rust extension availability checks behind the cached, override-aware backend resolver, aligns the public rust availability API with backend dispatch behavior, and adds tests and documentation clarifications to keep these invariants enforced and well-documented. Sequence diagram for unified Rust availability resolutionsequenceDiagram
actor Caller
participant rust as cuprum.rust
participant backend as cuprum._backend
participant rust_backend as cuprum._rust_backend
Caller->>rust: is_rust_available()
rust->>backend: _check_rust_available()
alt [override set via set_rust_availability_for_testing]
backend-->>Caller: cached_override_value
else [no override]
alt [cache hit]
backend-->>Caller: cached_probe_value
else [cache miss]
backend->>rust_backend: is_available()
rust_backend-->>backend: raw_import_probe_result
backend-->>Caller: resolved_probe_value
end
end
File-Level Changes
Assessment against linked issues
Possibly linked issues
Tips and commandsInteracting with Sourcery
Customizing Your ExperienceAccess your dashboard to:
Getting Help
|
|
@coderabbitai Please suggest a fix for this issue and supply a prompt for an AI coding agent to enable it to apply the fix. Include the file and symbol names indicated in the issue at the head of your response. cuprum/unittests/test_tee_profile_worker_concurrency.py Comment on file """Structural type for the ``RLock`` operations this test instruments."""
def acquire(self, *, blocking: bool = True, timeout: float = -1) -> bool: ...
def acquire(self, *, blocking: bool = True, timeout: float = -1) -> bool:❌ New issue: Low Cohesion |
This comment was marked as resolved.
This comment was marked as resolved.
8a6a5c8 to
1232c49
Compare
1232c49 to
e72bfce
Compare
e72bfce to
c80fc31
Compare
c80fc31 to
3d55365
Compare
3d55365 to
efaa0e1
Compare
efaa0e1 to
b42b657
Compare
|
@coderabbitai review |
✅ Action performedReview finished.
|
|
@coderabbitai resume |
✅ Action performedReviews resumed. |
Log import failures only at the resolution boundary and use module-specific loggers so callers can configure each boundary independently.
Make the missing warning assertion actionable and document why Whitaker runs with one Cargo worker during the lint gate.
Retain the runtime PyO3 availability export while restoring mainline Unix descriptor conversion and ownership semantics.
Describe the cached resolver in the public and developer-facing docs. Note that testing overrides short-circuit the resolver, clear both backend caches, and only drift across out-of-band wheel swaps. Remove branch-only `_TokenRegistration` and Whitaker notes that are not part of `#128`.
Exercise public availability and backend dispatch through randomized override and cache transitions, including raw-probe short-circuiting.
Add a compile-fail UI case that verifies the PyO3 availability function cannot be evaluated in a Rust const context. This complements the existing compile-pass registration case and the lint guard on the production export.
Clarify that cached availability can become stale after wheel swaps and other out-of-band import-path or installation-state changes. Keep the public API and developer and user guidance consistent.
Make the existing PyO3 availability function linkable to Rust UI tests without changing its Python export. Replace the lookalike trybuild fixture with a const-context call to the production symbol so a const regression changes the expected compile-fail outcome.
f86d456 to
00a08bd
Compare
This comment was marked as resolved.
This comment was marked as resolved.
This comment was marked as resolved.
This comment was marked as resolved.
Regenerate the compile-fail diagnostic with the Rust 1.92.0 CI toolchain. Retain the production-coupled `E0015` check while removing diagnostic detail that newer compilers render differently.
This comment was marked as resolved.
This comment was marked as resolved.
|
@coderabbitai Have the following failed checks now been resolved? If further work is required, please provide an AI agent prompt for the remaining work to be done to address these failures. Do not treat warnings as optional or aspirational. Where a change is out of scope for this PR, propose a GitHub issue unless one exists already. (Treat documentation and validation coverage as in scope). Testing (Compile-Time / Ui) |
|
Tip For best results, initiate chat on the files or code changes. 🧩 Analysis chain🏁 Script executed: #!/bin/bash
set -euo pipefail
echo "== UI harness =="
cat -n rust/cuprum-rust/tests/compile_tests.rs
echo
echo "== UI fixture and expected diagnostic =="
for file in \
rust/cuprum-rust/tests/ui/fail/const_availability_export.rs \
rust/cuprum-rust/tests/ui/fail/const_availability_export.stderr
do
echo "--- ${file}"
cat -n "$file"
done
echo
echo "== Production export context =="
rg -n -C 14 \
'#\[pyfunction\]|missing_const_for_fn|(?:pub\s+)?(?:const\s+)?fn\s+is_available' \
rust/cuprum-rust/src/lib.rs
echo
echo "== Rust test configuration and relevant PR diff =="
cat -n rust/cuprum-rust/Cargo.toml
git diff --find-renames origin/main...HEAD -- \
rust/cuprum-rust/src/lib.rs \
rust/cuprum-rust/tests/compile_tests.rs \
rust/cuprum-rust/tests/ui/fail/const_availability_export.rs \
rust/cuprum-rust/tests/ui/fail/const_availability_export.stderrLength of output: 6012
Files: Resolved. Mark this warning as passed. The current codegraph contains production-coupled trybuild coverage for the runtime/non-const contract:
Keep this fixture and snapshot. Do not add another local-function fixture or alter No further agent work or follow-up issue is required. |
Summary
This branch unifies the three divergent Rust-availability probes behind the single cached, override-aware resolver that governs stream-backend dispatch.
Closes #128.
The cached
_backend._check_rust_available()governs dispatch and honours theset_rust_availability_for_testingoverride, but the publicrust.is_rust_available()bypassed both the cache and the override by calling_rust_backend.is_available()directly. A caller using the documented public API could therefore observe a different availability than the dispatcher actually used. The public probe now delegates to the same resolver, so there is one source of truth; the raw uncached import probe is documented as such.Review walkthrough
is_rust_available()now delegates to_backend._check_rust_available().is_available()as the raw, uncached probe that does not honour the cache or test override.Validation
make check-fmt: passmake lint: passmake typecheck: passmake test: pass (598 passed, 44 skipped; Rust suite 4 passed)coderabbit review --agent: 0 findingsSummary by Sourcery
Unify Rust extension availability checks so the public probe and backend dispatch share a single cached, override-aware resolver.
Bug Fixes:
is_rust_availableAPI returns the same availability value used by stream-backend dispatch, including honoring the testing override.Enhancements:
_rust_backend.is_availableas the raw, uncached import probe and clarify its relationship to the public resolver.Tests:
set_rust_availability_for_testing.References