Skip to content

fix(augment): BM25 floor for the rescue's FTS fallback (#2092) - #2105

Open
sloemo01 wants to merge 1 commit into
repowise-dev:mainfrom
sloemo01:fix/augment-rescue-fts-floor
Open

fix(augment): BM25 floor for the rescue's FTS fallback (#2092)#2105
sloemo01 wants to merge 1 commit into
repowise-dev:mainfrom
sloemo01:fix/augment-rescue-fts-floor

Conversation

@sloemo01

@sloemo01 sloemo01 commented Sep 3, 2026

Copy link
Copy Markdown
Contributor

What

Fixes #2092. The zero-result grep rescue's FTS fallback returned the first row without checking its relevance score, so a multi-token pattern where only one common token matched produced a confident "Wiki suggests ..." line for an unrelated file (repro: bluetooth codec negotiation fallback riding on "fallback" at BM25 3.45).

Root cause

_rescue in augment_cmd/search.py returned the first FTS row pointing at a code page with no score check. Weak matches cluster ~3; genuine ones score 2-3x higher (observed 3.45 vs 8.70), so the fallback leg had no quality gate while the symbol path held an exact-match bar.

Changes

  • Added _RESCUE_FTS_MIN_SCORE = 6.0 — below the floor, silence beats a confident wrong suggestion.

Tests

  • Below-floor silent, above-floor fires — sabotage-verified (below-floor test fails without the fix).

Note: test_plugin_content is red on main itself (v0.47.0 release bug, unrelated to this PR).

…2092)

A multi-token pattern where only one common token matches still returns
FTS rows at score ~3, so the zero-result rescue emitted a confident
'Wiki suggests ...' line for an unrelated file (repro: 'bluetooth codec
negotiation fallback' riding on 'fallback' at 3.45). Genuinely related
pages score 2-3x higher. Below the 6.0 floor, silence beats a confident
wrong suggestion.

Tests: below-floor silent, above-floor fires — sabotage-verified.
@RaghavChamadiya

Copy link
Copy Markdown
Member

Flagging this before anyone merges it on green CI, because the direction is one I already ruled out on #2092.

An absolute BM25 floor cannot be a single constant across both backends. SQLite negates the FTS5 rank and it is unbounded (search.py:685); PostgreSQL uses ts_rank, which is 0-1 (search.py:774). A _RESCUE_FTS_MIN_SCORE tuned on SQLite silently kills the rescue fallback on every Postgres install, including hosted, and it fails closed: no error, just no results, which is the failure mode the rescue exists to prevent.

What #2092 needs is token coverage, not a score threshold, reusing the _pattern_terms guard already at search.py:132. That is dialect-independent by construction.

There is also a claim question. #2092 is held for @punk-dev-robot, who has the local before-and-after measurements and asked for it first; @Aman-goel-04 asked on 3 September and was declined for the same reason. Please check the issue thread before opening a PR against an assigned issue, and if you want the token-coverage version, say so on #2092 and let punk-dev-robot answer.

Closing nothing here, and I am not going to close it over my head, but I am not merging this shape. Not in today's release either way.

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.

augment: grep-rescue FTS fallback fires on weak matches — add relevance floor

2 participants