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

@@ -8,6 +8,7 @@ from planning_exercise_semantics import (
exercise_passes_technique_path_scope,
pick_best_path_hit,
resolve_path_anti_patterns,
resolve_path_primary_topic,
score_exercise_stage_fit,
semantic_brief_for_stage,
technique_sibling_excludes,
@@ -231,12 +232,13 @@ def test_pick_best_skips_kumite_for_mawashi_athletic_path():
"id": 2,
"title": "Sprungkraft Plyometrie",
"summary": "Absprung und Landung",
"goal": "Sprungkraft für Tritttechnik",
"goal": "Sprungkraft für Mawashi Geri Vorbereitung",
"score": 0.62,
"semantic_score": 0.38,
"stage_semantic_score": 0.38,
},
]
primary = resolve_path_primary_topic(q, brief, stage_learning_goal=stage_goal)
chosen = pick_best_path_hit(
hits,
set(),
@@ -244,6 +246,56 @@ def test_pick_best_skips_kumite_for_mawashi_athletic_path():
stage_anti_patterns=path_anti,
roadmap_stage_match=True,
stage_match_brief=stage_brief,
path_primary_topic=primary,
path_technique_excludes=technique_sibling_excludes(primary or "mawashi geri"),
)
assert chosen is not None
assert int(chosen["id"]) == 2
def test_resolve_path_primary_topic_from_stage_learning_goal():
brief = build_semantic_brief("Trainingsprogression gesprungener Tritt")
primary = resolve_path_primary_topic(
"Trainingsprogression gesprungener Tritt",
brief,
stage_learning_goal="Perfektionierung der statischen Mawashi Geri Technik",
)
assert primary and "mawashi" in primary
def test_pick_rejects_kumite_when_primary_only_in_stage_goal():
brief = build_semantic_brief("Trainingsprogression")
stage_goal = "Perfektionierung der statischen Mawashi Geri Technik"
stage_brief = build_stage_match_brief(learning_goal=stage_goal)
primary = resolve_path_primary_topic("Trainingsprogression", brief, stage_learning_goal=stage_goal)
hits = [
{
"id": 4,
"title": "4 Kumite Reaktions Übungen",
"summary": "Partner",
"goal": "Kumite",
"score": 0.95,
"semantic_score": 0.4,
"stage_semantic_score": 0.35,
},
{
"id": 2,
"title": "Mawashi Geri Standtechnik",
"summary": "Rundtritt",
"goal": "Mawashi Geri Basis",
"score": 0.7,
"semantic_score": 0.5,
"stage_semantic_score": 0.48,
},
]
chosen = pick_best_path_hit(
hits,
set(),
stage_learning_goal=stage_goal,
roadmap_stage_match=True,
stage_match_brief=stage_brief,
path_primary_topic=primary,
path_technique_excludes=technique_sibling_excludes(primary or "mawashi geri"),
)
assert chosen is not None
assert int(chosen["id"]) == 2