Enhance Slot Difference Annotation and Rematch Suggestion Logic
Deploy Development / deploy (push) Successful in 43s
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 34s
Test Suite / playwright-tests (push) Successful in 1m13s

- Introduced `_annotate_slot_diffs` to mark trivial ID swaps in slot differences, improving clarity in comparison results.
- Added `_actionable_slot_diffs` to filter out non-actionable differences, streamlining the evaluation process.
- Implemented `_build_rematch_suggestion_diffs` to generate suggestions based on rematch logs, enhancing the path optimization workflow.
- Updated `_build_progression_compare_response` to incorporate actionable slot differences and rematch suggestions, improving the response structure.
- Enhanced frontend components to display rematch suggestions and handle trivial differences more effectively.
- Bumped version to reflect the new features and improvements.
This commit is contained in:
Lars committed 2026-06-13 07:55:47 +02:00
1 parent e828a5da32
commit dccb065181
11 files changed
+552 -84

No files matched your search

@@ -1,11 +1,14 @@
"""Tests Vergleichs-Diffs (triviale ID-Tausche ausfiltern)."""
"""Tests Vergleichs-Diffs (triviale ID-Tausche markieren, Rematch-Vorschläge)."""
from planning_exercise_path_builder import (
_actionable_slot_diffs,
_annotate_slot_diffs,
_build_progression_compare_response,
_build_progression_slot_diffs,
_filter_trivial_slot_diffs,
_build_rematch_suggestion_diffs,
)
def test_filter_trivial_slot_diffs_same_title_different_id():
def test_annotate_trivial_id_swap():
diffs = [
{
"roadmap_major_step_index": 1,
@@ -15,10 +18,13 @@ def test_filter_trivial_slot_diffs_same_title_different_id():
"proposed_title": "Rhythmuswechsel in der Kumite-Beinarbeit",
}
]
assert _filter_trivial_slot_diffs(diffs) == []
annotated = _annotate_slot_diffs(diffs)
assert len(annotated) == 1
assert annotated[0]["trivial_id_swap"] is True
assert _actionable_slot_diffs(annotated) == []
def test_filter_trivial_slot_diffs_keeps_real_title_change():
def test_annotate_keeps_real_title_change():
diffs = [
{
"roadmap_major_step_index": 1,
@@ -28,12 +34,12 @@ def test_filter_trivial_slot_diffs_keeps_real_title_change():
"proposed_title": "Neu",
}
]
filtered = _filter_trivial_slot_diffs(diffs)
assert len(filtered) == 1
assert filtered[0]["proposed_title"] == "Neu"
annotated = _annotate_slot_diffs(diffs)
assert annotated[0]["trivial_id_swap"] is False
assert len(_actionable_slot_diffs(annotated)) == 1
def test_build_slot_diffs_then_filter():
def test_build_slot_diffs_then_annotate():
baseline = [
{"roadmap_major_step_index": 0, "exercise_id": 1, "title": "A"},
{"roadmap_major_step_index": 1, "exercise_id": 10, "title": "Gleich"},
@@ -43,5 +49,54 @@ def test_build_slot_diffs_then_filter():
{"roadmap_major_step_index": 1, "exercise_id": 77, "title": "Gleich"},
]
raw = _build_progression_slot_diffs(baseline, proposed)
assert len(raw) == 1
assert _filter_trivial_slot_diffs(raw) == []
annotated = _annotate_slot_diffs(raw)
assert len(annotated) == 1
assert annotated[0]["trivial_id_swap"] is True
assert _actionable_slot_diffs(annotated) == []
def test_rematch_suggestion_diffs_when_end_path_matches_baseline():
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,
"action": "replaced",
"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
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