Skip to content

fix(graph-rs): run pagerank iteration counts past u32::MAX like Python - #3441

Merged
vitali87 merged 7 commits into
mainfrom
claude/pagerank-iteration-count
Oct 29, 2026
Merged

vitali87 merged 7 commits into
mainfrom
claude/pagerank-iteration-count

Conversation

@vitali87

@vitali87 vitali87 commented Oct 24, 2026 •

Copy link
Copy Markdown
Owner

Summary

  • pagerank in cgr_graph_rs converted its iteration count with v.max(0) as u32, so a count above u32::MAX wrapped: CALL pagerank.get(4294967297, 0.85, 1e-12) ran one iteration on the Rust path, while the Python reference (for _ in range(iterations)) runs until the ranks converge. The two paths returned different ranks.
  • The count is now a u64. max(0) stays, so a negative count still runs no iteration, as range() of a negative number does.
  • Bumps cgr-graph-rs to 0.1.4 (main is at 0.1.3 since perf(indexer): compute interface fingerprints in Rust on the tree bridge #3495), in rust/cgr_graph_rs/pyproject.toml, rust/cgr_graph_rs/Cargo.toml, rust/cgr_graph_rs/Cargo.lock, the requirement in pyproject.toml and uv.lock, so the fixed library reaches users. The wheel names in test_rust_extension_packaging.py follow the new version.

Demo

No user-visible change: the Rust and Python procedures now agree on iteration counts above u32::MAX.

Type of Change

  • Bug fix

Related Issues

None.

Test Plan

  • New tests added (rust/cgr_graph_rs/tests/algorithms.rs):
    • pagerank_runs_an_iteration_count_past_u32_max: a count of 2^32 + 1 gives the same ranks as a count of 1000 (both converge at a tolerance of 1e-12). Fails before the fix: the ranks after one iteration (0.25, 0.356, 0.25, 0.144).
    • pagerank_runs_no_iteration_for_a_negative_count (negative test): a count of -5 leaves the ranks uniform. Fails if max(0) is removed from the new conversion, because -5 then casts to a huge count.
  • cargo test --release --manifest-path rust/cgr_graph_rs/Cargo.toml on f18a299 (main merged in): all pass (54 unit, 9 in algorithms.rs).
  • The Python suites the Rust Graph Core job runs, with the 0.1.4 extension installed, plus test_rust_extension_packaging.py and test_native_interface.py: 708 passed.
  • uv lock --check, ruff check, ruff format --check, scripts/generate_rust_licenses.py --check, and the "Crate version bumped with its code" comparison (0.1.3 on main, 0.1.4 here): clean.

Checklist

  • PR title follows Conventional Commits format
  • A breaking change has ! in the title and its release notes in changes/breaking/<PR number>.md
  • All pre-commit checks pass (make pre-commit)
  • No hardcoded strings in non-config/non-constants files
  • No # type: ignore, cast(), Any, or object type hints
  • New comments and docstrings explain why, not what

Summary by CodeRabbit

  • Bug Fixes
    • PageRank now preserves positive iteration counts above the 32-bit limit instead of truncating them.
    • Negative iteration counts produce uniform rank values across the graph.
  • Release
    • Updated the Rust graph package to version 0.1.4 and raised the minimum supported package version to 0.1.4. Package metadata and published distribution listings now reflect the updated version.

pagerank converted its iteration count with `v.max(0) as u32`, so a
count above u32::MAX wrapped: CALL pagerank.get(4294967297) ran one
iteration on the Rust path, while the Python reference's range() runs
until the ranks converge. Count in u64, keeping max(0) so that a
negative count still runs no iteration.
@greptile-apps

This comment has been minimized.

@chatgpt-codex-connector

chatgpt-codex-connector Bot commented Oct 24, 2026 •

Copy link
Copy Markdown

Codex Review Summary

This comment shows the latest Codex review activity on this pull request.

Review Status Commit Review trigger
📝 Code Review ✅ Completed 2026-10-24T20:59:29.711937Z 99563ff PR opened
ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review" or "@codex security review".

Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings.

@coderabbitai

coderabbitai Bot commented Oct 24, 2026 •

Copy link
Copy Markdown

Review in Change Stack →

Note

Reviews paused

It looks like this branch is under active development. To avoid overwhelming you with review comments due to an influx of new commits, CodeRabbit has automatically paused this review. You can configure this behavior by changing the reviews.auto_review.auto_pause_after_reviewed_commits setting.

Use the following commands to manage reviews:

  • @coderabbitai resume to resume automatic reviews.
  • @coderabbitai review to trigger a single review.

Use the checkboxes below for quick actions:

  • ▶️ Resume reviews
  • 🔍 Trigger review

No actionable comments were generated in the recent review.

Recent review info
Run configuration
Commits

Reviewing files that changed from the base of the PR and between d8c6141 and f18a299.

Files ignored due to path filters: 2
  • rust/cgr_graph_rs/Cargo.lock is excluded by !**/*.lock
  • uv.lock is excluded by !**/*.lock
Files selected for processing: 4
  • codebase_rag/tests/test_rust_extension_packaging.py
  • pyproject.toml
  • rust/cgr_graph_rs/Cargo.toml
  • rust/cgr_graph_rs/pyproject.toml

Included review availability: This review used your included allowance. Your plan provides up to 8 included reviews per hour; 7 remain after this review.

Walkthrough

PageRank’s default and parsed nonnegative iteration counts now use u64. Tests cover a value above u32::MAX and a negative iteration count. Package metadata, the dependency minimum, and packaging test expectations now use version 0.1.4.

Changes: PageRank iteration counts

Layer / File(s) Summary
Iteration count handling and validation
rust/cgr_graph_rs/src/lib.rs, rust/cgr_graph_rs/tests/algorithms.rs
The default and parsed nonnegative iteration counts use u64. Tests compare results for (1 << 32) + 1 and 1000 iterations, and check uniform ranks for a negative count.
Package version alignment
rust/cgr_graph_rs/Cargo.toml, rust/cgr_graph_rs/pyproject.toml, pyproject.toml, codebase_rag/tests/test_rust_extension_packaging.py
The Rust package versions and minimum cgr-graph-rs dependency version change to 0.1.4. Packaging tests expect the six platform wheels and source archive at version 0.1.4.

Priority: Low

Estimated code review effort: 2 (Simple) | ~8 minutes

Change: Bug fix

Suggested labels: bug

Suggested reviewers: claude

Merge Risk: Minimal · up to f18a2

No concrete merge-blocking defect or unresolved active risk is established by the reviewed changes.

Pre-merge checks: Passed 4
Check name Status Explanation
Description check Passed The description includes all required sections, explains the PageRank fix, documents the version updates, and lists tests. The unchecked full pre-commit item is non-critical because individual validat…
Title check Passed The title is concise, specific, and accurately describes the PageRank iteration-count fix. It also follows Conventional Commits format.
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.
Full details: Description check

Explanation

The description includes all required sections, explains the PageRank fix, documents the version updates, and lists tests. The unchecked full pre-commit item is non-critical because individual validation checks are listed as clean.

Finishing Touches
📝 Generate docstrings
  • Commit to this branch
  • Create a new PR
🧪 Generate unit tests (beta)
  • Commit to this branch
  • Create a new PR
  • Autofix · Keep fixing CodeRabbit findings and required CI, and resolving merge conflicts

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.

@greptile-apps

greptile-apps Bot commented Oct 24, 2026 •

Copy link
Copy Markdown
Contributor

RetriggerView in GreptileConfidence Score: 5/5

[Medium impact] The PR appears safe to merge.

Summary

PageRank now preserves iteration counts above u32::MAX instead of wrapping them.

  • Rust PageRank now keeps iteration counts above the 32-bit limit.

Reviews (2) · Last reviewed commit: "chore(graph-rs): bump cgr-graph-rs to 0...." · Reviewed by Greptile

vitali87 and others added 6 commits October 25, 2026 03:18
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01NVdycfDFvbqaoyHWVWHJ1N
The version bump set cgr-graph-rs to 0.1.1 in rust/cgr_graph_rs/pyproject.toml
and in the requirement floor, but left the crate's own Cargo.toml (and its
Cargo.lock entry) at 0.1.0, so test_the_crate_has_one_version failed with
'0.1.0' == '0.1.1'. Both manifests now carry 0.1.1.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01NVdycfDFvbqaoyHWVWHJ1N
Main reached 0.1.3 with #3495, so the pagerank fix needs a version above
it for publish.yml to ship the changed library.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01ChfULvr1gXZn6MQXr4xNFS
@sonarqubecloud

Copy link
Copy Markdown

Copy link
Copy Markdown
Owner Author

@greptile review


Generated by Claude Code

@vitali87
vitali87 merged commit ea2d5cd into main Oct 29, 2026
67 of 70 checks passed
@vitali87
vitali87 deleted the claude/pagerank-iteration-count branch October 29, 2026 18:38
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

Status: Done

Development

Successfully merging this pull request may close these issues.

2 participants