Lessons point at rules (milestone 440 steps 1–2) + the away-from-home usage readout #189

Merged
bvandeusen merged 5 commits from dev into main 2026-10-01 13:48:01 -04:00
Showing only changes of commit 95be2512ab - Show all commits
+4 -3
View File
@@ -399,7 +399,7 @@ async def rule_candidates(
"""The rules a lesson most resembles, for the writer to judge against. """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 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. 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 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 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". caller can say "candidates unavailable" rather than "nothing resembles".
""" """
from scribe.services.embeddings import ( 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 = {} report: dict = {}
found = await semantic_search_rules( found = await semantic_search_rules(
user_id, query, limit=CANDIDATE_LIMIT, user_id, query, limit=CANDIDATE_LIMIT,