Skip to content

Commit e9b8244

Browse files
committed
docs(internal): correct the reference-graph ranking comment
_GRAPH_HIT_SCORE said fuzzy scores are capped at 100, so a confirmed reference ranks at or above every fuzzy name match. The cap lives in _search_in_dict and bounds the config-body score. The fuzzy name score comes from _calculate_entity_score, which accumulates its bonuses with no ceiling, so a name echoing the queried entity's words can pass 100 on its own and outrank a graph hit's fixed 100. The exact-mode half of the claim holds and stays. The comment now states what fuzzy mode does, scoped to graph-ONLY hits (_merge_graph_hits leaves an already-scored record's score alone) and to the case where visibility enforcement does not scrub the record. Also name the scene caller in _individual_fetch_budgeted's deprioritize paragraph: it passes the set too, alongside automation and script.
1 parent 9fdac79 commit e9b8244

2 files changed

Lines changed: 11 additions & 5 deletions

File tree

src/ha_mcp/tools/smart_search/_fetch.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -201,7 +201,7 @@ async def _individual_fetch_budgeted(
201201
202202
``deprioritize`` moves the named ids to the BACK of the queue while
203203
keeping every id in it (relative order preserved within each group).
204-
The automation and script callers pass the ids Home Assistant's
204+
The automation, script and scene callers pass the ids Home Assistant's
205205
reference graph already confirmed reference the queried entity: their
206206
match status is settled without reading the body, so under budget
207207
pressure the budget belongs to the ids that are NOT in the set, which

src/ha_mcp/tools/smart_search/_graph.py

Lines changed: 10 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -357,10 +357,16 @@ async def fetch_related_buckets(client: Any, entity_id: str) -> GraphResult | No
357357
# Score assigned to a reference-graph hit. In the default exact mode every
358358
# surviving match scores exactly 100 (``_score_deep_match`` takes the max of
359359
# two 0-or-100 signals against a threshold of 100), so a graph hit sorts
360-
# indistinguishably from a body hit. Fuzzy scores are capped at 100 too, so
361-
# there a confirmed reference ranks at or above every fuzzy name match, which
362-
# is the intent: HA naming the reference is exact evidence, not an
363-
# approximate one.
360+
# indistinguishably from a body hit.
361+
#
362+
# Fuzzy mode is not symmetric, and no value here makes it so: the 100 cap
363+
# belongs to the config-body score (``_search_in_dict``), while the NAME score
364+
# from ``_calculate_entity_score`` accumulates without a ceiling — a name
365+
# echoing the queried entity's words can pass 100 on its own. So with
366+
# ``exact_match=False`` a graph-ONLY hit (``_merge_graph_hits`` leaves an
367+
# already-scored record's score alone) can sort below a match that merely
368+
# resembles the query, and land on a later page under a small ``limit``. It is
369+
# still counted in ``total_matches`` unless visibility enforcement scrubs it.
364370
_GRAPH_HIT_SCORE = 100
365371

366372

0 commit comments

Comments
 (0)