Skip to content

[Util] Fix cached priority ordering after insertion - #538

Open
CaelmBleidd wants to merge 1 commit into
mainfrom
caelmbleidd/fix-priority-cache-order
Open

CaelmBleidd wants to merge 1 commit into
mainfrom
caelmbleidd/fix-priority-cache-order

Conversation

@CaelmBleidd

Copy link
Copy Markdown
Member

After peek() caches the best element, DeterministicPriorityCollection.add() compares a new priority in the wrong direction. A worse element can replace the cached best, while a better element remains behind it. This affects deterministic weighted path selectors when states are added after selection.

Reverse that comparison so the cached element follows the same ordering as the underlying priority queue. Four regression tests cover better and worse insertions with natural and reverse comparators, and verify that the displaced element remains available.

Validation:

  • All four regression tests fail before the fix and pass after it.
  • :usvm-util:check: 60 passed.
  • :usvm-core:check: 253 passed, one existing skipped test.
  • :usvm-sample-language:check: 12 passed.

This is independent of #526 and does not change public APIs.

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