fix(sourcehunt): make n-day filter and reveng reconstruction batch sizes configurable - #204
Open
tsunoda-kazuya wants to merge 1 commit into
Open
Conversation
Fixed batch sizes (10 CVEs for n-day filter, 8 functions for reveng reconstructor) overflow small local-model context windows and silently drop trailing items past the model's output budget. Expose the batch size on HuntTuning (nday_filter_batch_size=10, reveng_batch_size=8), thread it through NdayPipeline and RevengPipeline, and add matching --nday-filter-batch-size and --reveng-batch-size CLI flags so callers running against smaller local models can shrink it; per-item evaluation means quality is unchanged. Defaults are preserved. Also reject batch_size <= 0 explicitly in NdayFilter and RevengReconstructor: batch_size=0 previously raised an obscure range() ValueError, and batch_size=-1 silently dropped every input.
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
FILTER_BATCH_SIZE(10) andRECONSTRUCTION_BATCH_SIZE(8) from module constants toHuntTuningfields with matching CLI flags (--nday-filter-batch-size,--reveng-batch-size).batch_size <= 0with a clearValueErrorinstead of silently dropping input.Problem
Both stages send fixed-size candidate batches to the model. On smaller local models with tight context, the batch can exceed the usable window and candidates at the tail are dropped without an error. Per-item scoring makes the batch size a pure context-fit knob, but it cannot be changed without editing source.
Fix
HuntTuning.nday_filter_batch_size: int = 10,HuntTuning.reveng_batch_size: int = 8.NdayFilter.__init__(self, llm, batch_size=FILTER_BATCH_SIZE),RevengReconstructor.__init__(self, llm, batch_size=None)(falls back toself.BATCH_SIZEclass attr for subclass compatibility).NdayPipelineandRevengPipelineaccept the batch size and pass it through to the wrapped classes.SourceHuntConfigconstruction.__init__s rejectbatch_size <= 0withValueError("batch_size must be >= 1, got {N}")— previously0raised an uncaughtrange(...) step must not be zeromid-iteration and negatives silently produced an empty loop that dropped all candidates.Validation
uv run --frozen --extra dev pytest -q tests/test_nday.py tests/test_reveng.py tests/test_sourcehunt_config.py— 69 passed; new regressions: default batch preserved (10 items -> 1 call for filter, 8 for reveng), custombatch_size=3splits into 4 calls,batch_size=0/-1raise, config-driven threading verified fromHuntTuning.uv run --frozen --extra dev ruff check clearwing/sourcehunt/nday_filter.py clearwing/sourcehunt/reveng_reconstructor.py clearwing/sourcehunt/nday.py clearwing/sourcehunt/reveng.py clearwing/sourcehunt/config.py clearwing/ui/commands/sourcehunt.pygit diff --checkBackward compatibility
Defaults reproduce the previous constants exactly.
RevengReconstructor.BATCH_SIZEclass attribute is retained so subclasses that override it continue to work (resolved at__init__time).Independent of the other 4 PRs in this batch; trivial rebase if any lands first.