Skip to content

fix: route prefix and non-word-character prep topics to the AI mentor - #1460

Open
ionfwsrijan wants to merge 1 commit into
Canopus-Labs:mainfrom
ionfwsrijan:fix/1440-domain-classifier-regex
Open

fix: route prefix and non-word-character prep topics to the AI mentor#1460
ionfwsrijan wants to merge 1 commit into
Canopus-Labs:mainfrom
ionfwsrijan:fix/1440-domain-classifier-regex

Conversation

@ionfwsrijan

Copy link
Copy Markdown
Contributor

Problem

backend/utils/domainClassifier.js builds the keyword matcher as new RegExp(\b(<keywords>)\b, 'i'). Two classes of keywords could never match, so legitimate AI-mentor questions were refused as "off-topic":

  1. Partial-word keywordsscal (scalability), load balanc (load balancing), negotiat (negotiation), probab (probability), math (mathematics), quant (quantitative). The trailing \b requires a non-word char immediately after the prefix, which never happens inside a longer real word.
  2. Keywords with non-word charactersc++/c#. The trailing \b after +/# rarely matches ("What is C++?").

isPrepPilotDomain gates the model call in aiRoutes.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 \b from keywordRegex.
  • 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

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
@coderabbitai

coderabbitai Bot commented Aug 6, 2026

Copy link
Copy Markdown

Warning

Review limit reached

@ionfwsrijan, you've reached your PR review limit, so we couldn't start this review.

Next review available in: 52 minutes

Enable usage-based reviews in Billing to review now. Otherwise, wait until the next included review is available.
You're only billed for reviews past your plan's rate limits ($0.25/file).

How can I continue?

After more reviews become available, a review can be triggered using the @coderabbitai review command as a PR comment. Alternatively, push new commits to this PR.

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 configuration

Configuration used: Repository UI

Review profile: CHILL

Plan: Pro Plus

Run ID: 23bf89b5-807b-416f-b866-e77461a09834

📥 Commits

Reviewing files that changed from the base of the PR and between 8acb5b8 and 1d89905.

📒 Files selected for processing (2)
  • backend/tests/domainClassifier.prefixKeywords.unit.test.js
  • backend/utils/domainClassifier.js

Comment @coderabbitai help to get the list of available commands.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

AI mentor misclassifies core prep topics as off-topic because the keyword regex uses word boundaries with partial words

1 participant