Enhance Stage Mismatch Handling and Roadmap Slot Purging
Deploy Development / deploy (push) Successful in 45s
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 33s
Test Suite / playwright-tests (push) Successful in 1m15s

- Introduced `_purge_stage_mismatch_roadmap_slots` to clear slots with persistent stage mismatches, improving the relevance of exercise suggestions.
- Updated `collect_gap_fill_specs` to handle stage mismatch issues more effectively, providing clearer rationale and title hints for off-topic exercises.
- Modified `_filter_learning_goal_candidate_ids` to enforce stricter filtering criteria, ensuring only relevant candidates are considered.
- Enhanced `rematch_roadmap_slots` to incorporate slot assignment history, preventing conflicts with previously assigned exercises.
- Bumped version to 0.8.230 to reflect the new features and improvements.
This commit is contained in:
Lars committed 2026-06-12 07:57:19 +02:00
1 parent 8a4be795f4
commit d448c3191f
6 files changed
+201 -35

No files matched your search

+56 -26
View File
@@ -865,6 +865,11 @@ def stage_focus_phrases_from_learning_goal(learning_goal: str) -> List[str]:
tokens = _significant_stage_tokens(lg, strip_negated=True)
phrases: List[str] = []
norm_lg = _normalize_phrase(lg)
tech_hit = _find_technique_in_text(norm_lg)
if tech_hit:
primary = tech_hit[0]
if primary not in phrases:
phrases.append(primary)
if len(norm_lg) >= 8:
phrases.append(norm_lg[:120])
for i in range(len(tokens) - 1):
@@ -879,14 +884,22 @@ def stage_focus_phrases_from_learning_goal(learning_goal: str) -> List[str]:
def stage_refinement_criteria_from_learning_goal(learning_goal: str) -> List[str]:
"""Erfolgskriterien für Phase C — nur aussagekräftige Mehrwort-Phrasen."""
lg = (learning_goal or "").strip()
if len(lg) < 3:
return []
norm_lg = _normalize_phrase(lg)
out: List[str] = []
for phrase in stage_focus_phrases_from_learning_goal(learning_goal):
p = str(phrase or "").strip()
if not p:
if len(norm_lg) >= 15:
out.append(norm_lg[:120])
tokens = _significant_stage_tokens(lg, strip_negated=True)
for i in range(len(tokens) - 1):
a, b = tokens[i], tokens[i + 1]
if len(a) < 5 or len(b) < 5:
continue
if " " in p or len(p) >= 12:
out.append(p[:120])
return out[:4]
pair = f"{a} {b}"
if len(pair) >= 12 and pair not in out:
out.append(pair)
return out[:3]
def exercise_title_matches_peer_stage_goal(
@@ -1095,6 +1108,9 @@ def build_stage_match_brief(
constraints = parse_stage_goal_constraints(lg)
must: List[str] = []
norm_lg = _normalize_phrase(lg)
tech_hit = _find_technique_in_text(norm_lg)
if tech_hit and tech_hit[0] not in must:
must.insert(0, tech_hit[0])
if primary_path and primary_path not in must:
must.insert(0, primary_path[:120])
for token in constraints.positive_tokens:
@@ -1165,12 +1181,15 @@ def score_exercise_stage_fit(
if part.lower().startswith("lernziel:"):
lg_hint = part.split(":", 1)[-1].strip()
break
if not lg_hint:
lg_hint = (stage_brief.retrieval_query or "").split("|")[0].strip()
if not lg_hint:
for mp in stage_brief.must_phrases or []:
if mp and len(_normalize_phrase(mp)) >= 8:
lg_hint = mp
break
focus_phrases = stage_focus_phrases_from_learning_goal(lg_hint) if lg_hint else []
tech_hit = _find_technique_in_text(_normalize_phrase(lg_hint)) if lg_hint else None
if not focus_phrases:
focus_phrases = [
t
@@ -1185,6 +1204,16 @@ def score_exercise_stage_fit(
score = min(1.0, score + bonus)
if hits >= max(1, len(focus_phrases) // 2):
reasons = ["Stufen-Schwerpunkte im Übungstext", *reasons]
non_tech = [
p
for p in focus_phrases
if not tech_hit or _normalize_phrase(p) != tech_hit[0]
]
specific_hits = sum(1 for p in non_tech if _phrase_in_blob(p, blob))
if tech_hit and _phrase_in_blob(tech_hit[0], blob) and specific_hits == 0:
score = min(score, 0.16)
if "Nur Technik-Bezug" not in reasons:
reasons = ["Nur Technik-Bezug, Stufen-Schwerpunkte fehlen", *reasons]
learning_goal_for_equiv = lg_hint or (stage_brief.must_phrases[0] if stage_brief.must_phrases else "")
if learning_goal_for_equiv and exercise_title_equivalent_to_stage_goal(title, learning_goal_for_equiv):
score = max(score, 0.42)
@@ -1246,15 +1275,13 @@ def exercise_passes_stage_fit(
learning_goal=lg,
anti_patterns=anti_patterns,
)
stage_sem = stage_semantic_score
if stage_sem is None:
stage_sem, _ = score_exercise_stage_fit(
title=title,
summary=summary,
goal=goal,
stage_brief=brief,
step_phase=step_phase,
)
stage_sem, _ = score_exercise_stage_fit(
title=title,
summary=summary,
goal=goal,
stage_brief=brief,
step_phase=step_phase,
)
if relaxed:
threshold = _MIN_STAGE_FIT_RELAXED
@@ -1262,7 +1289,19 @@ def exercise_passes_stage_fit(
threshold = _MIN_TITLE_EQUIV_SEMANTIC
else:
threshold = min_stage_semantic
return float(stage_sem or 0.0) >= threshold
if float(stage_sem or 0.0) >= threshold:
return True
if relaxed and not title_equiv:
focus = stage_focus_phrases_from_learning_goal(lg)
tech = _find_technique_in_text(_normalize_phrase(lg))
non_tech = [p for p in focus if not tech or _normalize_phrase(p) != tech[0]]
specific_hits = sum(1 for p in non_tech if _phrase_in_blob(p, blob))
if specific_hits >= 2 and float(stage_sem or 0.0) >= 0.14:
return True
return False
def apply_stage_match_retrieval_weights(brief: PlanningSemanticBrief) -> Dict[str, float]:
@@ -1539,16 +1578,7 @@ def pick_best_path_hit(
chosen = _scan(strict=False)
if chosen:
return chosen
return _pick_roadmap_rank_fallback(
hits,
used_exercise_ids,
stage_learning_goal=stage_goal,
stage_anti_patterns=stage_anti_patterns,
path_primary_topic=path_primary_topic,
path_technique_excludes=path_technique_excludes,
stage_match_brief=stage_brief,
peer_learning_goals=peer_learning_goals,
)
return None
chosen = _scan(strict=False)
if chosen: