Refactor Roadmap Step Annotation and Slot Assignment Logic
Deploy Development / deploy (push) Successful in 49s
Test Suite / pytest-backend (push) Successful in 44s
Test Suite / lint-backend (push) Successful in 0s
Test Suite / build-frontend (push) Successful in 14s
Test Suite / k6 /health Baseline (push) Successful in 33s
Test Suite / playwright-tests (push) Successful in 1m12s

- Updated `_annotate_roadmap_step` to change the condition for setting `slot_status` based on `roadmap_match_source`, improving clarity in slot assignment handling.
- Removed the `_try_reconcile_slot_assignment` function to streamline the slot assignment process, as its logic is now integrated into the main flow.
- Enhanced `_match_roadmap_slot` to conditionally preserve slot assignments based on exercise ID, ensuring better handling of existing assignments.
- Improved the handling of semantic scores in `rank_visible_library_hits` to prioritize the best semantic fit, enhancing exercise retrieval accuracy.
- Added tests to validate the new logic for title equivalence and semantic scoring, ensuring robustness in exercise selection processes.
This commit is contained in:
Lars committed 2026-06-11 12:45:53 +02:00
1 parent ca2adbd55e
commit b2fbf6b4af
5 files changed
+91 -129

No files matched your search

+14 -5
View File
@@ -954,6 +954,7 @@ def enrich_brief_with_path_constraints(
_MIN_STAGE_FIT_SEMANTIC = 0.30
_MIN_STAGE_FIT_RELAXED = 0.20
_MIN_TITLE_EQUIV_SEMANTIC = 0.15
def build_stage_match_brief(
@@ -1101,8 +1102,7 @@ def exercise_passes_stage_fit(
if constraints.exclude_phrases and _blob_matches_stage_excludes(blob, constraints.exclude_phrases):
return False
if exercise_title_equivalent_to_stage_goal(title, learning_goal or lg):
return True
title_equiv = exercise_title_equivalent_to_stage_goal(title, learning_goal or lg)
primary_path = (path_primary_topic or "").strip()
if not primary_path and lg:
@@ -1114,7 +1114,7 @@ def exercise_passes_stage_fit(
for item in technique_sibling_excludes(primary_path):
if item not in tech_excludes:
tech_excludes.append(item)
if primary_path and not exercise_passes_technique_path_scope(
if primary_path and not title_equiv and not exercise_passes_technique_path_scope(
primary_topic=primary_path,
title=title,
summary=summary,
@@ -1139,7 +1139,12 @@ def exercise_passes_stage_fit(
step_phase=step_phase,
)
threshold = _MIN_STAGE_FIT_RELAXED if relaxed else min_stage_semantic
if relaxed:
threshold = _MIN_STAGE_FIT_RELAXED
elif title_equiv:
threshold = _MIN_TITLE_EQUIV_SEMANTIC
else:
threshold = min_stage_semantic
return float(stage_sem or 0.0) >= threshold
@@ -1291,7 +1296,11 @@ def pick_best_path_hit(
summary = str(hit.get("summary") or "")
goal_text = str(hit.get("goal") or hit.get("exercise_goal") or "")
sem = float(hit.get("semantic_score") or 0.0)
stage_sem = float(hit.get("stage_semantic_score") or sem)
stage_sem = float(
hit.get("stage_rank_semantic")
or hit.get("stage_semantic_score")
or sem
)
if roadmap_stage_match and stage_goal:
if not exercise_passes_stage_fit(