fix(retrieval): reject months/weeks/years quantity phrases in version extraction - #249
Open
detail-app[bot] wants to merge 1 commit into
Conversation
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.
Detail bug report: View on Detail
Bug
QueryVersionExtractor.extractVersionNumbersparses learner queries for Java release versions. TheEXPLICIT_QUANTITY_SUFFIX_PATTERN(added incacf649) rejectsJava <N> <unit> of practicequantity phrases, but its noun list enumerated onlydays/hours/minutes/seconds/times/lineand omitted the most common time units —months,weeks,years. A phrase likeswitched to Java 6 months agowas misread as a request for Java 6, leaking the spurious token["6"]into every consumer:"6"resolved nearest-higher).dev-javatutorial supplement was dropped, narrowing retrieved supplements to Java 21 API-only.requestedVersions="6"/adjacent-same-familyheader was injected for Java docs, byte-for-byte identical to the designed out-of-range path.Fix
Add
weeks?|months?|years?toEXPLICIT_QUANTITY_SUFFIX_PATTERNinQueryVersionExtractor— a one-line alternation extension; no production call-site changes.Known trade-off (unchanged in kind, not a regression-in-kind): the new nouns inherit the same word-hyphen false-positive class
days?already exhibits —Java 25 year-ahead roadmap/month-release cadence/week-long sprintnow also suppress25, matching the pre-existingJava 25 day-release cadencebehavior. A more selective suffix pattern would narrow rejection for the existing entries too and is out of scope here.Closes #245
Testing
QueryVersionExtractorTest): extended the quantity-noun loop to coverweek/weeks/month/months/year/years; addedrejectsTemporalQuantityPhrasingsWhereJavaPrecedesTheDigits(the bug-case canary:switched to Java 6 months ago,Java 5 years of experience,been on Java 8 months, … → all[]); addedextractsReleaseRequestsAdjacentToNonQuantitySuffixWordsto guard the\bboundary soJava 25 monthly/yearly/weekly …still extract25(prevents over-suppression of adverbial forms)../gradlew test,spotlessCheck, PMD, SpotBugs, and the full pre-push gatemake format && make lint && make build && make test(1169 JVM tests across 140 classes, 0 failures; 14 shell contract scripts pass). To unblockmake lintI installed the two missing tools the Makefile requires (ast-grepvia npm,rubyvia apt).RetrievalService,ChatService, andGuidedLearningServicewith only downstream search/LLM mocks, but not committed as tests — the fix is in a pure utility whose return value pins the contract, and existingdays-based consumer tests already exercise these paths): confirmed the chat path resolvesswitched to Java 6 months agoto the configured-default Java 25 scope (not Java 21), the guided-learning path keeps the lesson'sdev-java+java/java25-completedoc-set, and the chat header path emits norequestedVersions="6"/adjacent-same-familyheader.https://api.llm-gateway.iocloudhost.net/v1) and a pre-indexed corpus, neither available in this environment. I started Qdrant 1.18.3 and walked the boot through to the embedding-gateway call, which rejected the dummy key with401 Invalid API Key. The bug-relevant behavior (version parsing and scope resolution) runs before any Qdrant search or LLM call and is covered by the unit tests above.Automatic Fixes PRs can be configured here.