fix(sourcehunt): reserve a per-band minimum when cutting large-repo ranker candidates - #201
Open
tsunoda-kazuya wants to merge 1 commit into
Open
fix(sourcehunt): reserve a per-band minimum when cutting large-repo ranker candidates#201tsunoda-kazuya wants to merge 1 commit into
tsunoda-kazuya wants to merge 1 commit into
Conversation
…anker candidates On repositories above large_repo_file_threshold, _select_llm_candidates kept the head of a single global ordering. A file whose heuristic priority sits in a lower band never reached the LLM reranker even when it was the only file in its band. Reserve large_repo_band_min files per priority band before filling the remaining slots by the existing sort key; the rerank budget is unchanged. The reservation is round-robin across bands and never exceeds the limit, so an oversized band_min still keeps low-band representation while favouring stronger bands on overflow. large_repo_band_min=0 reproduces the previous head cut.
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.
Summary
RankerConfig.large_repo_band_min(default 0, opt-in) andlarge_repo_bands(default 4).band_minfrom each before filling the remaininglarge_repo_llm_file_limitslots by the existing sort key.band_min * bands > limit.band_min = 0(default) reproduces the historical head-cut behaviour byte-for-byte.Problem
On repositories above
large_repo_file_threshold,_select_llm_candidateskeeps the head of a single global ordering. A file whose heuristic priority sits in a lower band never reaches the LLM reranker even when it is the only file in its band.--target-filecovers the case where the target is already known; blind hunts still depend on this cut.Fix
_reserve_band_minimumpartitions the sorted candidate list intolarge_repo_bandspriority-quantile bands, takesband_minfrom each band in sort order, and fills the rest globally.band_min = 0, when there is only one band, when all priorities are equal, or when the input is empty.band_min * bands > limit) logs a warning naming the parameters and returns the plain head cut.Validation
uv run --frozen --extra dev pytest -q tests/test_sourcehunt_ranker.py— 42 passed; new regressions: band reservation keeps a lone low-band file,band_min=0matches head cut, overflow warns and falls back, empty input.uv run --frozen --extra dev ruff check clearwing/sourcehunt/ranker.py tests/test_sourcehunt_ranker.pygit diff --checkBackward compatibility
Default
large_repo_band_min = 0reproduces the previous selection byte-for-byte. Behaviour changes only when a user opts in withband_min >= 1. The rerank budget (large_repo_llm_file_limit) is unchanged in either case.Independent of the other 4 PRs in this batch; trivial rebase if any lands first.