Skip to content

[codex] remove ordered-float from core rank transform#99

Merged
project-navi-bot merged 3 commits into
mainfrom
codex/remove-ordered-float
May 28, 2026
Merged

[codex] remove ordered-float from core rank transform#99
project-navi-bot merged 3 commits into
mainfrom
codex/remove-ordered-float

Conversation

@Fieldnote-Echo
Copy link
Copy Markdown
Owner

@Fieldnote-Echo Fieldnote-Echo commented May 28, 2026

Summary

  • Replace OrderedFloat sort keys in the rank transform with an internal finite-f32 comparator that preserves ascending-index tie breaks.
  • Remove ordered-float from the core crate manifest and lockfiles, including the excluded fuzz lockfile.
  • Add rank-transform coverage for duplicate finite values and signed-zero tie behavior.

Credit

  • Discovery credit: @dleighsystem identified the opportunity to remove ordered-float from the core dependency tree.

Impact

No public API change. Valid finite inputs keep the same rank output semantics, including -0.0 / +0.0 comparing equal and tying by original coordinate index. Non-finite inputs still fail through the existing assert_all_finite contract before sorting.

Validation

  • cargo fmt --all --check
  • cargo clippy --all-targets --all-features -- -D warnings
  • cargo test --all-features
  • cargo tree -p ordvec --edges normal

Copy link
Copy Markdown

@gemini-code-assist gemini-code-assist Bot left a comment

Choose a reason for hiding this comment

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

Code Review

This pull request removes the ordered-float dependency and replaces its usage in rank_transform with a custom, deterministic tie-breaking comparator cmp_finite_f32_then_index that uses coordinate indices to break ties. It also adds unit tests to verify correct tie-breaking behavior. The reviewer suggested replacing .expect(...) with .unwrap_or(...) in the comparator to eliminate a panic branch, allowing the compiler to better optimize the hot sorting path.

Comment thread src/util.rs
Signed-off-by: Nelson Spence <nelson@projectnavi.ai>
@Fieldnote-Echo Fieldnote-Echo force-pushed the codex/remove-ordered-float branch from 25bf5a0 to ba3e117 Compare May 28, 2026 15:54
@Fieldnote-Echo Fieldnote-Echo marked this pull request as ready for review May 28, 2026 15:54
@Fieldnote-Echo Fieldnote-Echo requested a review from Copilot May 28, 2026 15:54
@qodo-code-review
Copy link
Copy Markdown

Review Summary by Qodo

Remove ordered-float dependency, use internal comparator

✨ Enhancement 🐞 Bug fix

Grey Divider

Walkthroughs

Description
• Replace OrderedFloat dependency with internal finite-f32 comparator
• Implement cmp_finite_f32_then_index for deterministic tie-breaking by index
• Remove ordered-float from dependencies and deny allowlist
• Add test coverage for duplicate values and signed-zero tie behavior
Diagram
flowchart LR
  A["rank_transform functions"] -->|"replace OrderedFloat"| B["cmp_finite_f32_then_index"]
  B -->|"sort by value then index"| C["deterministic rank output"]
  D["Cargo.toml"] -->|"remove dependency"| E["ordered-float removed"]
  F["Tests"] -->|"add coverage"| G["duplicate values & signed zeros"]

Loading

Grey Divider

File Changes

1. src/rank.rs ✨ Enhancement +28/-5

Replace OrderedFloat with internal comparator

• Remove ordered_float::OrderedFloat import and replace with internal comparator
• Update rank_transform and rank_transform_into to use sort_unstable_by with
 cmp_finite_f32_then_index
• Add two new test cases: duplicate_values_tie_by_original_index and
 signed_zeroes_tie_by_original_index
• Update documentation to clarify tie-breaking by ascending index

src/rank.rs


2. src/util.rs ✨ Enhancement +15/-0

Add finite f32 comparator with index tie-breaking

• Add new cmp_finite_f32_then_index function that compares finite f32 values with index-based
 tie-breaking
• Function uses partial_cmp with panic on non-finite values and then_with for deterministic
 ordering
• Marked as pub(crate) and #[inline] for internal use across modules

src/util.rs


3. Cargo.toml Dependencies +0/-1

Remove ordered-float dependency

• Remove ordered-float = "5" from dependencies section

Cargo.toml


View more (1)
4. deny.toml 📝 Documentation +1/-1

Update license allowlist comment

• Update license comment to remove ordered-float from the list of dependencies
• Simplify the dependency list in the comment

deny.toml


Grey Divider

Qodo Logo

@qodo-code-review
Copy link
Copy Markdown

qodo-code-review Bot commented May 28, 2026

Code Review by Qodo

🐞 Bugs (0) 📘 Rule violations (0) 📎 Requirement gaps (0)

Grey Divider


Remediation recommended

1. Stale dependency docs ✓ Resolved 🐞 Bug ⚙ Maintainability
Description
This PR removes ordered-float from the crate, but docs still claim the rank primitives use
ordered_float, which is now incorrect and can mislead dependency audits and readers.
Code

Cargo.toml[33]

Evidence
ordered-float was removed from the crate dependencies, but the design doc still explicitly lists
ordered_float as a dependency for rank primitives.

Cargo.toml[31-36]
docs/RANK_MODES.md[494-503]
src/rank.rs[24-48]

Agent prompt
The issue below was found during a code review. Follow the provided context and guidance below and implement a solution

### Issue description
The documentation still states that rank primitives depend on `ordered_float`, but this PR removes `ordered-float` and replaces it with an internal finite-`f32` comparator.

### Issue Context
Keeping docs accurate matters for users assessing dependency footprint/build times and for maintainers.

### Fix Focus Areas
- docs/RANK_MODES.md[494-503]

### Suggested change
Edit the “No heavy dependencies” bullet to remove `ordered_float` and describe the new reality (e.g., only `rayon`, plus internal comparator for finite `f32`).

ⓘ Copy this prompt and use it to remediate the issue with your preferred AI generation tools


Grey Divider

Qodo Logo

@codecov
Copy link
Copy Markdown

codecov Bot commented May 28, 2026

Codecov Report

✅ All modified and coverable lines are covered by tests.

📢 Thoughts on this report? Let us know!

Copy link
Copy Markdown

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull request overview

Removes the ordered-float dependency from the core crate by introducing an internal cmp_finite_f32_then_index comparator used by rank_transform and rank_transform_into. The new comparator preserves prior tie-break semantics (ascending original index) and relies on the existing assert_all_finite contract upstream. Lockfiles, manifest, and deny.toml comment are updated; two new unit tests cover duplicate-value and signed-zero tie cases.

Changes:

  • Add cmp_finite_f32_then_index helper in src/util.rs and switch rank_transform/rank_transform_into to sort_unstable_by with the new comparator.
  • Drop ordered-float from Cargo.toml, Cargo.lock, and fuzz/Cargo.lock; update the license comment in deny.toml.
  • Add duplicate_values_tie_by_original_index and signed_zeroes_tie_by_original_index unit tests in src/rank.rs.

Reviewed changes

Copilot reviewed 4 out of 6 changed files in this pull request and generated no comments.

Show a summary per file
File Description
src/util.rs Adds internal finite-f32 comparator with index tiebreak.
src/rank.rs Replaces OrderedFloat sort key with new comparator; doc tweak and added tie tests.
Cargo.toml Removes ordered-float dependency.
Cargo.lock Drops ordered-float entry from core crate deps.
fuzz/Cargo.lock Drops ordered-float, num-traits, autocfg entries (no longer needed).
deny.toml Updates license-summary comment to drop removed crates.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Signed-off-by: Nelson Spence <nelson@projectnavi.ai>
Copy link
Copy Markdown
Owner Author

Bot review disposition for the remaining top-level finding:

  • Qodo stale dependency docs: valid, low risk / small effort. Fixed in a84c2a7 by updating docs/RANK_MODES.md so the dependency summary no longer says rank primitives use ordered_float.

Validation after the docs fix:

  • cargo fmt --all --check
  • cargo test --all-features rank::tests::duplicate_values_tie_by_original_index
  • rg -n "ordered_float|ordered-float|OrderedFloat" docs src Cargo.toml returned no matches.

@project-navi-bot project-navi-bot merged commit 6bdf670 into main May 28, 2026
32 checks passed
@project-navi-bot project-navi-bot deleted the codex/remove-ordered-float branch May 28, 2026 17:12
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.

3 participants