fix: determinism in file order#103
Merged
Merged
Conversation
Codecov Report✅ All modified and coverable lines are covered by tests.
🚀 New features to boost your workflow:
|
stephantul
commented
May 17, 2026
| ignored = [] | ||
| extensions_as_patterns = [f"!*{ext}" for ext in extensions] | ||
| ignored.extend(extensions_as_patterns) | ||
| ignored.extend(_DEFAULT_IGNORED_DIRS) |
Contributor
Author
There was a problem hiding this comment.
This was also a possible source of errors, although I think it actually wasn't causing an issue.
stephantul
commented
May 17, 2026
| ] | ||
|
|
||
| for item in directory.iterdir(): | ||
| for item in sorted(directory.iterdir()): |
Contributor
Author
There was a problem hiding this comment.
idem, this could result in issues, so just to rule it out, we sort here.
stephantul
commented
May 17, 2026
| spec = _load_ignore_for_dir(directory) | ||
| if spec is not None: | ||
| active_specs = [ | ||
| inherited_specs = [ |
Contributor
Author
There was a problem hiding this comment.
this is done like this to avoid an in-place edit of inherited_specs.
stephantul
commented
May 17, 2026
| # Sort by the file path and start line to | ||
| # counteract randomness introduces by hashing. | ||
| all_candidates = sorted( | ||
| {*normalized_semantic, *normalized_bm25}, |
Contributor
Author
There was a problem hiding this comment.
this is the actual bugfix
Pringled
approved these changes
May 18, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
This PR fixes a low-key determinism bug. Due to python's HASHSEED behavior, it was possible that two chunks from the same file with the same score would get a different tie break. Because of the way we calculate boosting, this would result in different rankings, and slightly different NDCG@10 scors.
The fix is just sorting the chunks, leading to a stable key which does not rely on a specific hash seed.