Enhance Rematch Suggestion Logic and Progression Path Evaluation
Deploy Development / deploy (push) Successful in 41s
Test Suite / pytest-backend (push) Successful in 45s
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 1m14s

- Introduced `_baseline_slot_accepts_rematch_suggestion` to filter out filled or invalid slots from rematch suggestions, improving the accuracy of rematch logic.
- Updated `_build_rematch_suggestion_diffs` to skip non-eligible baseline slots, streamlining the rematch suggestion process.
- Added `_evaluate_steps_for_compare_qa` to evaluate steps against the current state, enhancing the quality assessment during progression path suggestions.
- Modified `_build_progression_compare_response` to ensure proper handling of slot differences and quality scores, improving response clarity.
- Updated frontend components to reflect changes in rematch handling and evaluation logic.
- Bumped version to reflect the new features and improvements.
This commit is contained in:
Lars committed 2026-06-13 08:02:44 +02:00
1 parent dccb065181
commit 69ce3f6975
4 files changed
+105 -75

No files matched your search

@@ -1,4 +1,4 @@
"""Tests Vergleichs-Diffs (triviale ID-Tausche markieren, Rematch-Vorschläge)."""
"""Tests Vergleichs-Diffs (triviale ID-Tausche markieren, Rematch-Filter)."""
from planning_exercise_path_builder import (
_actionable_slot_diffs,
_annotate_slot_diffs,
@@ -55,12 +55,32 @@ def test_build_slot_diffs_then_annotate():
assert _actionable_slot_diffs(annotated) == []
def test_rematch_suggestion_diffs_when_end_path_matches_baseline():
def test_rematch_suggestion_skips_filled_baseline_slot():
baseline = [
{
"roadmap_major_step_index": 1,
"exercise_id": 5727,
"title": "Einführung von Richtungswechseln",
"slot_status": "preserved",
},
]
rematch_log = [
{
"roadmap_major_step_index": 1,
"action": "replaced",
"round": 3,
"new_exercise_id": 5594,
"new_title": "Kumite Beinarbeit — vertiefung",
"replaced_exercise_id": 5727,
},
]
assert _build_rematch_suggestion_diffs(baseline, rematch_log) == []
def test_rematch_suggestion_keeps_empty_baseline_slot():
baseline = [
{"roadmap_major_step_index": 1, "exercise_id": None, "title": "Lernziel Slot 2"},
{"roadmap_major_step_index": 4, "exercise_id": 50, "title": "Bestehend"},
]
proposed = list(baseline)
rematch_log = [
{
"roadmap_major_step_index": 1,
@@ -68,35 +88,23 @@ def test_rematch_suggestion_diffs_when_end_path_matches_baseline():
"round": 1,
"new_exercise_id": 101,
"new_title": "Rhythmuswechsel in der Kumite-Beinarbeit",
"replaced_exercise_id": None,
"replaced_title": None,
},
{
"roadmap_major_step_index": 1,
"action": "replaced",
"round": 3,
"new_exercise_id": 102,
"new_title": "Kumite Beinarbeit — vertiefung",
"replaced_exercise_id": 101,
"replaced_title": "Rhythmuswechsel in der Kumite-Beinarbeit",
},
]
diffs = _build_rematch_suggestion_diffs(baseline, rematch_log)
assert len(diffs) == 1
assert diffs[0]["proposed_exercise_id"] == 102
assert diffs[0]["from_rematch_log"] is True
assert diffs[0]["proposed_exercise_id"] == 101
compare = _build_progression_compare_response(
{"steps": baseline, "path_qa": {"overall_ok": True, "quality_score": 0.88}},
{
"steps": proposed,
"path_qa": {
"overall_ok": False,
"quality_score": 0.65,
"rematch_log": rematch_log,
},
},
)
assert compare["slot_diffs_source"] == "rematch_log"
assert compare["slot_diff_count"] == 1
assert compare["proposed_steps"][0]["exercise_id"] == 102
def test_compare_response_no_step_diffs_uses_baseline_qa_not_pipeline():
baseline = {
"steps": [{"roadmap_major_step_index": 0, "exercise_id": 1, "title": "A"}],
"path_qa": {"overall_ok": True, "quality_score": 0.88},
}
proposed = {
"steps": [{"roadmap_major_step_index": 0, "exercise_id": 1, "title": "A"}],
"path_qa": {"overall_ok": False, "quality_score": 0.65, "rematch_log": [{"action": "replaced"}]},
}
compare = _build_progression_compare_response(baseline, proposed, proposed_eval=None)
assert compare["slot_diff_count"] == 0
assert compare["slot_diffs_source"] == "steps"
assert compare["proposed_path_qa"]["quality_score"] == 0.65