fix: make importance/recency score boosts opt-in (boost-confound)#584
Conversation
Bugbot couldn't run - usage limit reachedBugbot is counted against Cursor usage for this user or team, and this run hit a usage or spend limit. A user or team admin can review and increase usage limits in the Cursor dashboard. (requestId: serverGenReqId_1dbcbe14-4e79-4b08-bce8-5cff205cda16) |
|
Warning Review limit reached
Next review available in: 30 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: Organization UI Review profile: ASSERTIVE Plan: Pro Run ID: 📒 Files selected for processing (3)
✨ Finishing Touches🧪 Generate unit tests (beta)
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
|
@codex review |
There was a problem hiding this comment.
Your trial has ended. Reactivate Greptile to resume code reviews.
|
You need to increase your spend limit or enable usage-based billing to run background agents. Go to Cursor |
There was a problem hiding this comment.
🟡 Medium
brainlayer/src/brainlayer/search_repo.py
Lines 1757 to 1758 in f53e512
When a caller explicitly passes recency_rerank=False or importance_rerank=False, the or override on lines 1771-1772 still enables the feature if the corresponding env var (BRAINLAYER_SCORE_RECENCY_DECAY or BRAINLAYER_SCORE_IMPORTANCE_BOOST) is set. This makes a per-call opt-out impossible and silently changes ranking and cache keys for those requests. Consider checking the env var only when the caller does not explicitly pass a value, e.g. default the parameter to None and apply _env_flag_enabled(...) only when it is None.
- recency_rerank: bool = False,
- importance_rerank: bool = False,
+ recency_rerank: Optional[bool] = None,
+ importance_rerank: Optional[bool] = None,🚀 Reply "fix it for me" or copy this AI Prompt for your agent:
In file @src/brainlayer/search_repo.py around lines 1757-1758:
When a caller explicitly passes `recency_rerank=False` or `importance_rerank=False`, the `or` override on lines 1771-1772 still enables the feature if the corresponding env var (`BRAINLAYER_SCORE_RECENCY_DECAY` or `BRAINLAYER_SCORE_IMPORTANCE_BOOST`) is set. This makes a per-call opt-out impossible and silently changes ranking and cache keys for those requests. Consider checking the env var only when the caller does not explicitly pass a value, e.g. default the parameter to `None` and apply `_env_flag_enabled(...)` only when it is `None`.
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: f53e512931
ℹ️ About Codex in GitHub
Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".
| Cache is module-level LRU (128 entries) with defensive copy-on-read. | ||
| """ | ||
|
|
||
| recency_rerank = recency_rerank or _env_flag_enabled("BRAINLAYER_SCORE_RECENCY_DECAY") |
There was a problem hiding this comment.
Keep decay env from enabling recency fallback
When BRAINLAYER_SCORE_RECENCY_DECAY=1 is set, this assigns recency_rerank=True, but that same flag also gates the recency-intent fallback query (if recency_rerank and recency_intent and not date_from) before scoring. In any process that enables the new score-decay control, queries containing terms like "latest" or "recent" can now inject up to 25 arbitrary recent chunks that have no lexical or vector match, instead of only applying the documented decay multiplier; this can surface unrelated memories and degrade retrieval correctness. Separate the env-controlled decay/boost gate from the candidate-supplement behavior, or only enable the fallback through the explicit rerank path.
Useful? React with 👍 / 👎.
|
Follow-up: the score-only recency-decay isolation fix that missed the merged head is carried by recovery PR #588. Env-only decay no longer enables recent-candidate fallback. |
Summary
importance_rerankandrecency_rerankkwargs working for existing callersContext
PR #565 already made the explicit rerank kwargs default-off. This follow-up finishes the handoff contract by exposing strict call-time environment controls:
BRAINLAYER_SCORE_IMPORTANCE_BOOSTBRAINLAYER_SCORE_RECENCY_DECAYAccepted enabled values are
1,true,yes, andon(case-insensitive). Unset or other values remain off.Test plan
Review note
The local CodeRabbit CLI was attempted before commit but returned the public OSS rate limit (15-minute reset), so PR-level bot review is requested below.
Note
Medium Risk
Changes relevance ranking when env flags are enabled and affects cache partitioning by rerank mode; defaults unchanged so production risk is low unless operators opt in.
Overview
Adds process-wide opt-ins for hybrid search post-RRF boosts that previously required explicit kwargs. At the start of
hybrid_search,recency_rerankandimportance_rerankare combined withBRAINLAYER_SCORE_RECENCY_DECAYandBRAINLAYER_SCORE_IMPORTANCE_BOOSTvia a new_env_flag_enabledhelper (truthy values:1,true,yes,on, case-insensitive). Explicit kwargs still work; unset env keeps default-off behavior from the prior kwargs-only contract.Effective rerank flags continue to drive boost gates and the hybrid result cache key, so env-on vs env-off queries do not share cached rankings. Tests assert isolated importance and recency effects under each env flag and clear those variables in existing default/opt-in kwargs tests. A docs plan describes this PR as task 1 of a two-PR relevance stack (weighted RRF follows separately).
Reviewed by Cursor Bugbot for commit f53e512. Bugbot is set up for automated code reviews on this repo. Configure here.
Note
Make importance and recency score boosts opt-in via environment variables in
hybrid_searchSearchMixin.hybrid_searchpreviously applied based only on kwargs; they now also require the corresponding env vars (BRAINLAYER_SCORE_RECENCY_DECAY,BRAINLAYER_SCORE_IMPORTANCE_BOOST) to be set to a truthy value._env_flag_enabledhelper in search_repo.py that parses boolean-like env vars ("1","true","yes","on", case-insensitive).📊 Macroscope summarized f53e512. 2 files reviewed, 0 issues evaluated, 0 issues filtered, 0 comments posted
🗂️ Filtered Issues
No issues evaluated.