Skip to content

Conversation

@sunshowers
Copy link
Member

Time to start using a model checker on this somewhat tricky code.

Copy link

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

This PR adds Kani model checker proofs to verify the correctness of the GlobalWeight implementation, which manages weight tracking for future queues. The proofs verify critical invariants such as capacity bounds, operation symmetry, and clamping behavior.

  • Adds 5 Kani proof functions to verify GlobalWeight invariants
  • Configures Cargo.toml to recognize the kani cfg flag
  • Adds CI workflow job to run Kani verification on pull requests

Reviewed changes

Copilot reviewed 3 out of 3 changed files in this pull request and generated 1 comment.

File Description
src/global_weight.rs Adds kani_proofs module with 5 verification proofs for weight management invariants
Cargo.toml Adds lint configuration to suppress warnings for the kani cfg flag
.github/workflows/ci.yml Adds Kani verification job to CI pipeline

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

let large_weight: usize = kani::any();
kani::assume(large_weight > max);

// Both should have space (since weight gets clamped to max).
Copy link

Copilot AI Jan 4, 2026

Choose a reason for hiding this comment

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

The comment is misleading. When large_weight > max and it gets clamped to max, has_space_for checks if current <= max - max, which is current <= 0. This is only true when current == 0, not in general. The conditional check on line 122 correctly handles this, but the comment incorrectly suggests that having space is guaranteed due to clamping.

Suggested change
// Both should have space (since weight gets clamped to max).
// If there is space for the clamped weight (max), both paths should behave the same.

Copilot uses AI. Check for mistakes.
Time to start using a model checker on this somewhat tricky code.
@sunshowers sunshowers merged commit b61a1af into main Jan 4, 2026
4 checks passed
@sunshowers sunshowers deleted the kani branch January 4, 2026 22:49
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.

2 participants