Enhance Path Exclusion Logic and Semantic Brief Enrichment
Deploy Development / deploy (push) Successful in 44s
Test Suite / pytest-backend (push) Successful in 43s
Test Suite / lint-backend (push) Successful in 1s
Test Suite / build-frontend (push) Successful in 14s
Test Suite / k6 /health Baseline (push) Successful in 34s
Test Suite / playwright-tests (push) Has been cancelled

- Introduced `resolve_path_anti_patterns` to improve handling of path exclusions based on explicit negations and semantic briefs.
- Updated `enrich_brief_with_path_constraints` to incorporate path-specific exclusions into semantic briefs, enhancing exercise relevance.
- Modified roadmap step annotation to allow for anti-pattern overrides, improving flexibility in exercise selection.
- Enhanced tests to validate new path exclusion features and ensure correct functionality against learning goals.
- Incremented application version to reflect these updates.
This commit is contained in:
Lars committed 2026-06-11 08:43:59 +02:00
1 parent 07e147bc76
commit 3c12363b8f
6 files changed
+270 -18

No files matched your search

@@ -1,12 +1,16 @@
"""Tests Roadmap-Stufen-Match — Gate gegen themenfremde Übungen."""
from planning_exercise_semantics import (
build_semantic_brief,
build_stage_match_brief,
enrich_brief_with_path_constraints,
exercise_passes_stage_learning_goal_gate,
exercise_passes_stage_fit,
pick_best_path_hit,
resolve_path_anti_patterns,
score_exercise_stage_fit,
semantic_brief_for_stage,
build_semantic_brief,
)
from planning_exercise_path_qa import strip_off_topic_steps_from_path
def test_stage_gate_accepts_learning_goal_in_title():
@@ -174,6 +178,83 @@ def test_pick_best_rejects_mawashi_tritt_precision_for_coordination_slot():
assert int(chosen["id"]) == 100
def test_path_anti_patterns_from_keine_kumite_anwendung():
q = "gesprungener Mawashi Geri Sprungphase, keine Kumite-Anwendung gewünscht"
brief = enrich_brief_with_path_constraints(build_semantic_brief(q), q)
anti = resolve_path_anti_patterns(q, semantic_brief=brief)
assert any("kumite" in a for a in anti)
def test_stage_fit_rejects_kumite_when_path_excludes_kumite():
q = "gesprungener Mawashi Geri, keine Kumite-Anwendung"
brief = enrich_brief_with_path_constraints(build_semantic_brief(q), q)
path_anti = resolve_path_anti_patterns(q, semantic_brief=brief)
stage_goal = "Sprungkraft und Koordination für gesprungenen Mawashi Geri"
stage_brief = build_stage_match_brief(
learning_goal=stage_goal,
anti_patterns=path_anti,
path_anti_patterns=path_anti,
)
assert not exercise_passes_stage_fit(
learning_goal=stage_goal,
title="Kumite Distanztraining Mawashi",
summary="Partner-Kumite mit Trittanwendung",
goal="Anwendung im freien Kampf",
stage_brief=stage_brief,
anti_patterns=path_anti,
)
def test_pick_best_skips_kumite_for_mawashi_athletic_path():
q = "gesprungener Mawashi Geri Sprungkraft, keine Kumite-Anwendung"
brief = enrich_brief_with_path_constraints(build_semantic_brief(q), q)
path_anti = resolve_path_anti_patterns(q, semantic_brief=brief)
stage_goal = "Athletisches Sprungtraining für Mawashi Geri"
stage_brief = build_stage_match_brief(
learning_goal=stage_goal,
anti_patterns=path_anti,
path_anti_patterns=path_anti,
)
hits = [
{
"id": 1,
"title": "Kumite Mawashi Anwendung",
"summary": "Partner Kumite",
"goal": "Kampfanwendung",
"score": 0.95,
"semantic_score": 0.55,
"stage_semantic_score": 0.55,
},
{
"id": 2,
"title": "Sprungkraft Plyometrie",
"summary": "Absprung und Landung",
"goal": "Sprungkraft für Tritttechnik",
"score": 0.62,
"semantic_score": 0.38,
"stage_semantic_score": 0.38,
},
]
chosen = pick_best_path_hit(
hits,
set(),
stage_learning_goal=stage_goal,
stage_anti_patterns=path_anti,
roadmap_stage_match=True,
stage_match_brief=stage_brief,
)
assert chosen is not None
assert int(chosen["id"]) == 2
def test_strip_off_topic_removes_partial_when_most_steps_bad():
steps = [{"exercise_id": i, "title": f"E{i}"} for i in range(1, 8)]
off_topic = [{"step_index": i, "issue": "path_exclude"} for i in range(5)]
out, removed = strip_off_topic_steps_from_path(steps, off_topic, min_remaining=2)
assert len(out) == 2
assert len(removed) == 5
def test_parse_stage_goal_constraints_extracts_ohne_tritttechnik():
from planning_exercise_semantics import parse_stage_goal_constraints