From 95be2512abf7b0a0487c883d1a7cde9f640afe81 Mon Sep 17 00:00:00 2001 From: Bryan Van Deusen Date: Thu, 1 Oct 2026 13:34:08 -0400 Subject: [PATCH] fix(lessons): build the rule-candidate query with trigger_title (#4631) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit CI run 707 failed test_the_trigger_separator_is_spelled_in_exactly_one_place: rule_candidates joined the lesson's claim and trigger with an inline " — ", a second spelling of embeddings.TRIGGER_SEP (#3207). It now calls trigger_title — the same join a rule's own document title is built with, which was the point of the query shape in the first place. Co-Authored-By: Claude Opus 5.5 --- src/scribe/services/lesson_rules.py | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/src/scribe/services/lesson_rules.py b/src/scribe/services/lesson_rules.py index f8e6424..9364581 100644 --- a/src/scribe/services/lesson_rules.py +++ b/src/scribe/services/lesson_rules.py @@ -399,7 +399,7 @@ async def rule_candidates( """The rules a lesson most resembles, for the writer to judge against. Searched with the lesson's claim and its trigger — the same two halves a - rule's own document leads with (`{title} — {trigger}`), so like is + rule's own document leads with (`trigger_title`), so like is compared with like; the insight is the story and would dilute the vector. Scoped as any project read is: global rules plus the lesson's project's own. The bar is the explicit rule search's, since this is an explicit @@ -409,10 +409,11 @@ async def rule_candidates( caller can say "candidates unavailable" rather than "nothing resembles". """ from scribe.services.embeddings import ( - DEFAULT_SIMILARITY_THRESHOLD, semantic_search_rules, + DEFAULT_SIMILARITY_THRESHOLD, semantic_search_rules, trigger_title, ) - query = " — ".join(p for p in ((what or "").strip(), (when_to_apply or "").strip()) if p) + # The rule document's own title join, so like is compared with like. + query = trigger_title(what, when_to_apply) report: dict = {} found = await semantic_search_rules( user_id, query, limit=CANDIDATE_LIMIT,