fix: route prefix and non-word-character prep topics to the AI mentor - #1460
fix: route prefix and non-word-character prep topics to the AI mentor#1460ionfwsrijan wants to merge 1 commit into
Conversation
The keyword regex used word boundaries on both ends, so prefix keywords (scal, load balanc, negotiat, probab, math, quant) and keywords containing non-word characters (c++, c#) never matched. 'Explain probability', 'What is load balancing?', 'Explain C++ pointers', etc. were misclassified as off-topic and refused. Anchor keywords as prefixes by dropping the trailing word boundary. Closes Canopus-Labs#1440
|
Warning Review limit reached
Next review available in: 52 minutes Enable usage-based reviews in Billing to review now. Otherwise, wait until the next included review is available. How can I continue?After more reviews become available, a review can be triggered using the To avoid repeated limits, reduce automatic review volume by pausing incremental auto-reviews earlier, using label-based review opt-in, excluding WIP or generated PR titles, or requesting reviews manually when the PR is ready. If your team needs uninterrupted high-volume reviews, an organization admin can enable usage-based reviews. How do review limits work?CodeRabbit enforces per-developer PR review limits for each organization. Most developers receive the normal plan review availability. For paid Pro and Pro+ PR reviews, CodeRabbit uses adaptive limits for sustained high-volume activity. When a developer's recent PR review activity reaches the 95th percentile or higher among CodeRabbit users, additional reviews become available more gradually as earlier reviews age out of the rolling window. Please refer docs for additional details. Review details⚙️ Run configurationConfiguration used: Repository UI Review profile: CHILL Plan: Pro Plus Run ID: 📒 Files selected for processing (2)
Comment |
Problem
backend/utils/domainClassifier.jsbuilds the keyword matcher asnew RegExp(\b(<keywords>)\b, 'i'). Two classes of keywords could never match, so legitimate AI-mentor questions were refused as "off-topic":scal(scalability),load balanc(load balancing),negotiat(negotiation),probab(probability),math(mathematics),quant(quantitative). The trailing\brequires a non-word char immediately after the prefix, which never happens inside a longer real word.c++/c#. The trailing\bafter+/#rarely matches ("What is C++?").isPrepPilotDomaingates the model call inaiRoutes.js, so these prompts got the canned refusal instead of an answer.Fix
Anchored keywords as prefixes: keep the leading word boundary, drop the trailing
\b.\b(probab|scal|...|c\+\+|c\#)now matches "probability", "scaling", "C++", "C#", etc. A few extra matches (e.g. "google" →go) are acceptable for an AI-mentor router.Files changed
backend/utils/domainClassifier.js— dropped trailing\bfromkeywordRegex.backend/tests/domainClassifier.prefixKeywords.unit.test.js— tests routing probability/load balancing/scaling/C++/C#/negotiation/mathematics to the mentor and still rejecting clearly off-topic prompts.Testing
npx vitest run tests/domainClassifier.prefixKeywords.unit.test.js— 13/13 passing.Closes #1440