fix: remove clippy allows - #66
Conversation
|
@CodeRabbit review |
✅ Action performedReview finished.
|
|
No actionable comments were generated in the recent review. 🎉 ℹ️ Recent review info⚙️ Run configurationConfiguration used: Organization UI Review profile: CHILL Plan: Pro Plus Run ID: 📒 Files selected for processing (1)
🚧 Files skipped from review as they are similar to previous changes (1)
📝 WalkthroughWalkthroughThe changes add shared integer-to-float ratio calculations, replace provider streaming booleans with explicit state enums, restore a private callback alias, remove obsolete lint allowances, and add regression coverage. ChangesStreaming state and numeric contracts
Sequence Diagram(s)sequenceDiagram
participant ProviderStream
participant StreamEmitter
participant StreamEvents
ProviderStream->>StreamEmitter: receive text, thinking, tool, or finish signal
StreamEmitter->>StreamEmitter: transition PartLane or TerminalStage
StreamEmitter->>StreamEvents: emit lane and terminal events
Possibly related PRs
🚥 Pre-merge checks | ✅ 4✅ Passed checks (4 passed)
✨ Finishing Touches📝 Generate docstrings
🧪 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.
Actionable comments posted: 1
Caution
Some comments are outside the diff and can’t be posted inline due to platform limitations.
⚠️ Outside diff range comments (1)
src/provider/openai.rs (1)
1433-1457: 🎯 Functional Correctness | 🟠 Major | ⚡ Quick winReset
text/thinkingtoPartLane::Closedinprocess_finish.
process_finishchecksmatches!(self.text, PartLane::Open)andmatches!(self.thinking, PartLane::Open)at Line 1439 and Line 1443, then pushesPartStop, but it never setsself.textorself.thinkingback toPartLane::Closed. Every other lane-close site in this file resets the state before or while pushingPartStop(seeprocess_deltaat Line 1334 and Line 1337, and Line 1354 and Line 1357). The equivalent Gemini implementation insrc/provider/gemini.rsalso resets state in its finish-reason handler (extract_finish_reason, Lines 1127-1128 and 1131-1132) and inhandle_function_call(Lines 1068-1069 and 1072-1073).
self.finishedguards re-entry intoprocess_finishitself, butprocess_deltahas no such guard. If a chunk carrying delta content arrives after afinish_reasonchunk (duplicate, malformed, or proxy-replayed chunk),process_deltareads the stalePartLane::Openstate and skips emitting a newPartStart, so it forwards anIndexedDeltafor a part index that was already closed withPartStop. This violates thePartStart/PartStoplifecycle documented inStreamEvent(aPartStopmust be followed by aPartStartbefore more deltas for that part).🐛 Proposed fix to reset lane state in process_finish
- if matches!(self.text, PartLane::Open) { + if matches!(self.text, PartLane::Open) { + self.text = PartLane::Closed; self.push(StreamEvent::PartStop); } - if matches!(self.thinking, PartLane::Open) { + if matches!(self.thinking, PartLane::Open) { + self.thinking = PartLane::Closed; self.push(StreamEvent::PartStop); }🤖 Prompt for 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. In `@src/provider/openai.rs` around lines 1433 - 1457, Update process_finish to set self.text and self.thinking to PartLane::Closed whenever their lanes are open, while preserving the existing PartStop emissions. This ensures subsequent process_delta calls reopen lanes and emit PartStart before forwarding additional deltas.
🧹 Nitpick comments (3)
src/engine/bare.rs (2)
109-119: 📐 Maintainability & Code Quality | 🔵 Trivial | ⚡ Quick winGate
TextStreamerbehindstreaming.
TextStreameris compiled for builds withoutstreaming, while the private field, setters, and tests that reference it are feature-gated. Add#[cfg(feature = "streaming")]before the alias to remove unused code in no-streaming builds.Suggested fix
+#[cfg(feature = "streaming")] /// Shared callback invoked once per text delta during streaming. type TextStreamer = Arc<dyn Fn(&str) + Send + Sync>;🤖 Prompt for 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. In `@src/engine/bare.rs` around lines 109 - 119, Gate the TextStreamer type alias with #[cfg(feature = "streaming")] so it is only compiled when streaming support is enabled, matching the feature gates on BareLoop’s field, setters, and tests that use it.
109-119: 📐 Maintainability & Code Quality | 🔵 Trivial | ⚡ Quick winMove
TextStreamerbehind the public module boundary.
BareLoop::set_text_streamerandBareLoop::with_text_streamerare public viapub use bare::*, butTextStreameris a private alias. This exposes an unreachably named type and is likely rejected byprivate_interfacesunder the project’s-D warningsconfig. If it is part of public API, makeTextStreamerpublic and re-export it; otherwise, useArc<dyn Fn(&str) + Send + Sync>directly in both public methods.🤖 Prompt for 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. In `@src/engine/bare.rs` around lines 109 - 119, Make the callback type used by the public BareLoop::set_text_streamer and BareLoop::with_text_streamer API reachable: either mark TextStreamer public and re-export it through the bare module’s public exports, or replace the alias in both method signatures with Arc<dyn Fn(&str) + Send + Sync>. Keep the existing callback bounds and behavior unchanged.src/detection/convergence.rs (1)
859-865: 🎯 Functional Correctness | 🔵 Trivial | ⚡ Quick winAdd a regression test for large counts.
The current test uses only tiny sets. Add a case where both counts exceed
u16::MAX, but the intersection is smaller than the union. Assert that the result remains below1.0, such as0.5.🤖 Prompt for 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. In `@src/detection/convergence.rs` around lines 859 - 865, Add a large-count regression case to compute_similarity_result_unchanged_after_cast_fix using inputs whose counts both exceed u16::MAX while their intersection is smaller than their union. Assert that ConvergenceDetector::compute_similarity returns the expected fractional result below 1.0, such as 0.5, while preserving the existing identical and disjoint assertions.
🤖 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 `@src/detection/convergence.rs`:
- Around line 823-825: Use a shared scale for the intersection/union conversion
in the convergence ratio so independently saturated values cannot produce 1.0;
update the logic near the ratio calculation in src/detection/convergence.rs
(823-825). Add a regression case in src/detection/convergence.rs (859-865)
covering counts above u16::MAX with a known partial ratio. Apply the same
ratio-preserving conversion to word_matches and query_words.len() in
src/memory/builtin.rs (257-260).
---
Outside diff comments:
In `@src/provider/openai.rs`:
- Around line 1433-1457: Update process_finish to set self.text and
self.thinking to PartLane::Closed whenever their lanes are open, while
preserving the existing PartStop emissions. This ensures subsequent
process_delta calls reopen lanes and emit PartStart before forwarding additional
deltas.
---
Nitpick comments:
In `@src/detection/convergence.rs`:
- Around line 859-865: Add a large-count regression case to
compute_similarity_result_unchanged_after_cast_fix using inputs whose counts
both exceed u16::MAX while their intersection is smaller than their union.
Assert that ConvergenceDetector::compute_similarity returns the expected
fractional result below 1.0, such as 0.5, while preserving the existing
identical and disjoint assertions.
In `@src/engine/bare.rs`:
- Around line 109-119: Gate the TextStreamer type alias with #[cfg(feature =
"streaming")] so it is only compiled when streaming support is enabled, matching
the feature gates on BareLoop’s field, setters, and tests that use it.
- Around line 109-119: Make the callback type used by the public
BareLoop::set_text_streamer and BareLoop::with_text_streamer API reachable:
either mark TextStreamer public and re-export it through the bare module’s
public exports, or replace the alias in both method signatures with Arc<dyn
Fn(&str) + Send + Sync>. Keep the existing callback bounds and behavior
unchanged.
🪄 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: Organization UI
Review profile: CHILL
Plan: Pro Plus
Run ID: 89da7661-2dc1-4799-87c4-992c1cf2b99f
📒 Files selected for processing (10)
CHANGELOG.mdsrc/detection/convergence.rssrc/engine/bare.rssrc/engine/bare/dispatch.rssrc/memory/builtin.rssrc/middleware/tool_call.rssrc/presets.rssrc/provider/anthropic.rssrc/provider/gemini.rssrc/provider/openai.rs
💤 Files with no reviewable changes (2)
- src/presets.rs
- src/provider/anthropic.rs
There was a problem hiding this comment.
Actionable comments posted: 2
🤖 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 `@src/numeric.rs`:
- Around line 44-49: Update the ratio calculation around scale_to_u16 so
numerator is converted without integer division that can floor a positive value
to zero; preserve a strictly positive floating-point result whenever numerator >
0 and denominator is positive, while retaining the existing bounded conversion
behavior for large values.
- Around line 22-28: Update unit_ratio_f64 to avoid independently saturating
numerator and denominator: when either operand exceeds u32::MAX, scale both by
one shared divisor before converting them to u32 so their ratio is preserved,
while retaining the zero-denominator behavior. Ensure
ContextOverflow::utilization continues to produce ratios above and below 1.0 for
overflowed inputs, and add tests covering both cases.
🪄 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: Organization UI
Review profile: CHILL
Plan: Pro Plus
Run ID: 11f6c9d0-1b8a-412e-a1f0-4b947feb60f9
📒 Files selected for processing (9)
src/compact/types.rssrc/detection/convergence.rssrc/engine/bare.rssrc/lib.rssrc/memory/builtin.rssrc/numeric.rssrc/provider/gemini.rssrc/provider/openai.rssrc/tool/health.rs
🚧 Files skipped from review as they are similar to previous changes (4)
- src/detection/convergence.rs
- src/provider/gemini.rs
- src/provider/openai.rs
- src/engine/bare.rs
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 `@src/numeric.rs`:
- Around line 182-234: Update unit_ratio to clamp denominator_scaled to T::ONE
when the original denominator is positive but scaling floors it to zero,
mirroring the existing numerator_scaled clamp. Add a regression test alongside
the unit_ratio boundary tests using a large numerator and small nonzero
denominator, and assert the result is finite.
🪄 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: Organization UI
Review profile: CHILL
Plan: Pro Plus
Run ID: 842feb5f-0352-4e31-b444-2d6c1f489cb2
📒 Files selected for processing (6)
CHANGELOG.mdsrc/compact/types.rssrc/detection/convergence.rssrc/memory/builtin.rssrc/numeric.rssrc/tool/health.rs
🚧 Files skipped from review as they are similar to previous changes (4)
- CHANGELOG.md
- src/detection/convergence.rs
- src/memory/builtin.rs
- src/tool/health.rs
No description provided.