Implement Primary Topic Resolution in Path Logic
Deploy Development / deploy (push) Successful in 45s
Test Suite / pytest-backend (push) Successful in 43s
Test Suite / lint-backend (push) Successful in 0s
Test Suite / build-frontend (push) Successful in 13s
Test Suite / k6 /health Baseline (push) Successful in 34s
Test Suite / playwright-tests (push) Successful in 1m22s

- Introduced `resolve_path_primary_topic` function to enhance the determination of primary topics from goal queries and semantic briefs, improving exercise relevance.
- Updated `_match_roadmap_slot` and `detect_off_topic_steps` functions to utilize the new primary topic resolution logic, ensuring accurate topic identification.
- Enhanced tests to validate the functionality of primary topic resolution and its impact on exercise selection and off-topic detection.
- Improved handling of primary topics in the `ExerciseProgressionPathBuilder` and related components for better integration with the overall path-building process.
This commit is contained in:
Lars committed 2026-06-11 11:06:38 +02:00
1 parent f63b09fc9c
commit 044ce2ee60
7 files changed
+128 -16

No files matched your search

+33 -1
View File
@@ -180,6 +180,28 @@ def _find_technique_in_text(q_lower: str) -> Optional[Tuple[str, Tuple[str, ...]
return None
def resolve_path_primary_topic(
goal_query: str,
semantic_brief: Optional[PlanningSemanticBrief] = None,
*,
stage_learning_goal: Optional[str] = None,
extra_context: Optional[str] = None,
) -> Optional[str]:
"""
Haupttechnik aus Anfrage, Kontext oder Stufen-Lernziel — nicht nur aus goal_query.
"""
if semantic_brief:
primary = (semantic_brief.primary_topic or "").strip()
if primary:
return primary
parts = [goal_query or "", extra_context or "", stage_learning_goal or ""]
combined = _normalize_phrase(" ".join(p for p in parts if p))
if not combined:
return None
hit = _find_technique_in_text(combined.lower())
return hit[0] if hit else None
def technique_sibling_excludes(primary_topic: str) -> List[str]:
"""Andere Techniken derselben Familie (z. B. Mae/Yoko bei Mawashi) — aus Katalog."""
topic = _normalize_phrase(primary_topic)
@@ -1038,13 +1060,22 @@ def exercise_passes_stage_fit(
return False
primary_path = (path_primary_topic or "").strip()
if not primary_path and lg:
hit = _find_technique_in_text(_normalize_phrase(lg))
if hit:
primary_path = hit[0]
tech_excludes = list(path_technique_excludes or [])
if primary_path:
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(
primary_topic=primary_path,
title=title,
summary=summary,
goal=goal,
learning_goal=lg,
sibling_excludes=path_technique_excludes,
sibling_excludes=tech_excludes,
relaxed=relaxed,
):
return False
@@ -1295,6 +1326,7 @@ __all__ = [
"build_stage_match_brief",
"enrich_brief_with_path_constraints",
"exercise_passes_stage_fit",
"resolve_path_primary_topic",
"resolve_path_anti_patterns",
"exercise_passes_stage_learning_goal_gate",
"merge_semantic_brief_llm",