Skip to content

fix: remove clippy allows - #66

Merged
bobrykov merged 5 commits into
masterfrom
fix/remove-clippy-allow
Aug 3, 2026
Merged

fix: remove clippy allows#66
bobrykov merged 5 commits into
masterfrom
fix/remove-clippy-allow

Conversation

@bobrykov

@bobrykov bobrykov commented Aug 3, 2026

Copy link
Copy Markdown
Contributor

No description provided.

@bobrykov

bobrykov commented Aug 3, 2026

Copy link
Copy Markdown
Contributor Author

@CodeRabbit review

@coderabbitai

coderabbitai Bot commented Aug 3, 2026

Copy link
Copy Markdown
Contributor
✅ Action performed

Review finished.

Note: CodeRabbit is an incremental review system and does not re-review already reviewed commits. This command is applicable only when automatic reviews are paused.

@coderabbitai

coderabbitai Bot commented Aug 3, 2026

Copy link
Copy Markdown
Contributor

Review Change Stack

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro Plus

Run ID: d2c4c1e3-c460-46b0-b9c1-94a4ef134f80

📥 Commits

Reviewing files that changed from the base of the PR and between b8d1f72 and 2a26663.

📒 Files selected for processing (1)
  • src/numeric.rs
🚧 Files skipped from review as they are similar to previous changes (1)
  • src/numeric.rs

📝 Walkthrough

Walkthrough

The 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.

Changes

Streaming state and numeric contracts

Layer / File(s) Summary
Shared ratio helpers and integrations
src/lib.rs, src/numeric.rs, src/detection/convergence.rs, src/memory/builtin.rs, src/compact/types.rs, src/tool/health.rs
The crate adds generic unit_ratio support for u64 and usize inputs. Similarity, query overlap, context utilization, and tool health calculations now use it. Tests cover scaling, zero denominators, large values, and ranking.
OpenAI lane state tracking
src/provider/openai.rs
StreamEmitter now tracks text and reasoning lanes with PartLane states. Lane switching and finish handling close active lanes. Tests cover initial closure, reopening after finish, and reasoning-only streams.
Gemini lane and terminal state tracking
src/provider/gemini.rs
StreamEmitter now uses PartLane and TerminalStage for lane switches, finish handling, duplicate suppression, and late finish reasons. Tests cover initial state and terminal ordering.
Callback and lint contract corrections
src/engine/bare.rs, src/engine/bare/dispatch.rs, src/middleware/tool_call.rs, src/presets.rs, CHANGELOG.md
The engine uses a private TextStreamer alias. Tool methods use explicit &'static str return types. Obsolete Clippy allowances were removed, and the changelog records the corrections.

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
Loading

Possibly related PRs

🚥 Pre-merge checks | ✅ 4
✅ Passed checks (4 passed)
Check name Status Explanation
Title check ✅ Passed The title accurately describes the removal of obsolete Clippy allowances, which is a real part of the changeset but not its only major change.
Docstring Coverage ✅ Passed Docstring coverage is 100.00% which is sufficient. The required threshold is 50.00%.
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.
✨ Finishing Touches
📝 Generate docstrings
  • Create stacked PR
  • Commit on current branch
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch fix/remove-clippy-allow

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.

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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 win

Reset text/thinking to PartLane::Closed in process_finish.

process_finish checks matches!(self.text, PartLane::Open) and matches!(self.thinking, PartLane::Open) at Line 1439 and Line 1443, then pushes PartStop, but it never sets self.text or self.thinking back to PartLane::Closed. Every other lane-close site in this file resets the state before or while pushing PartStop (see process_delta at Line 1334 and Line 1337, and Line 1354 and Line 1357). The equivalent Gemini implementation in src/provider/gemini.rs also resets state in its finish-reason handler (extract_finish_reason, Lines 1127-1128 and 1131-1132) and in handle_function_call (Lines 1068-1069 and 1072-1073).

self.finished guards re-entry into process_finish itself, but process_delta has no such guard. If a chunk carrying delta content arrives after a finish_reason chunk (duplicate, malformed, or proxy-replayed chunk), process_delta reads the stale PartLane::Open state and skips emitting a new PartStart, so it forwards an IndexedDelta for a part index that was already closed with PartStop. This violates the PartStart/PartStop lifecycle documented in StreamEvent (a PartStop must be followed by a PartStart before 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 win

Gate TextStreamer behind streaming.

TextStreamer is compiled for builds without streaming, 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 win

Move TextStreamer behind the public module boundary.

BareLoop::set_text_streamer and BareLoop::with_text_streamer are public via pub use bare::*, but TextStreamer is a private alias. This exposes an unreachably named type and is likely rejected by private_interfaces under the project’s -D warnings config. If it is part of public API, make TextStreamer public and re-export it; otherwise, use Arc<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 win

Add 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 below 1.0, such as 0.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

📥 Commits

Reviewing files that changed from the base of the PR and between e6a04a6 and 60799a2.

📒 Files selected for processing (10)
  • CHANGELOG.md
  • src/detection/convergence.rs
  • src/engine/bare.rs
  • src/engine/bare/dispatch.rs
  • src/memory/builtin.rs
  • src/middleware/tool_call.rs
  • src/presets.rs
  • src/provider/anthropic.rs
  • src/provider/gemini.rs
  • src/provider/openai.rs
💤 Files with no reviewable changes (2)
  • src/presets.rs
  • src/provider/anthropic.rs

Comment thread src/detection/convergence.rs Outdated

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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

📥 Commits

Reviewing files that changed from the base of the PR and between 60799a2 and dc16419.

📒 Files selected for processing (9)
  • src/compact/types.rs
  • src/detection/convergence.rs
  • src/engine/bare.rs
  • src/lib.rs
  • src/memory/builtin.rs
  • src/numeric.rs
  • src/provider/gemini.rs
  • src/provider/openai.rs
  • src/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

Comment thread src/numeric.rs Outdated
Comment thread src/numeric.rs Outdated

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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

📥 Commits

Reviewing files that changed from the base of the PR and between dc16419 and b8d1f72.

📒 Files selected for processing (6)
  • CHANGELOG.md
  • src/compact/types.rs
  • src/detection/convergence.rs
  • src/memory/builtin.rs
  • src/numeric.rs
  • src/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

Comment thread src/numeric.rs
@bobrykov
bobrykov merged commit 9b97ca4 into master Aug 3, 2026
7 checks passed
@bobrykov
bobrykov deleted the fix/remove-clippy-allow branch August 4, 2026 05:23
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant