Implement Peer Learning Goals and Stage Fit Enhancements
Deploy Development / deploy (push) Successful in 42s
Test Suite / pytest-backend (push) Successful in 43s
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 1m33s
Deploy Development / deploy (push) Successful in 42s
Test Suite / pytest-backend (push) Successful in 43s
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 1m33s
- Introduced `_peer_stage_learning_goals` to retrieve learning goals from peer stages, enhancing the ability to filter exercises based on cross-slot collisions. - Added `_filter_learning_goal_candidate_ids` to refine candidate selection by incorporating peer learning goals and stage fit criteria, improving exercise relevance in suggestions. - Enhanced `pick_best_path_hit` and `_match_roadmap_slot` to utilize peer learning goals for better exercise selection and to prevent conflicts with titles from other stages. - Updated `stage_refinement_criteria_from_learning_goal` to provide clearer criteria for stage refinement based on learning goals. - Bumped version to 0.8.229 to reflect the new features and improvements.
This commit is contained in:
1 parent
a49987408b
commit
8a4be795f4
5 files changed
+241
-43
No files matched your search
@@ -864,19 +864,48 @@ def stage_focus_phrases_from_learning_goal(learning_goal: str) -> List[str]:
|
||||
return []
|
||||
tokens = _significant_stage_tokens(lg, strip_negated=True)
|
||||
phrases: List[str] = []
|
||||
for tok in tokens:
|
||||
if len(tok) >= 5 and tok not in phrases:
|
||||
phrases.append(tok)
|
||||
norm_lg = _normalize_phrase(lg)
|
||||
if len(norm_lg) >= 8:
|
||||
phrases.append(norm_lg[:120])
|
||||
for i in range(len(tokens) - 1):
|
||||
pair = f"{tokens[i]} {tokens[i + 1]}"
|
||||
if len(pair) >= 8 and pair not in phrases:
|
||||
phrases.append(pair)
|
||||
norm_lg = _normalize_phrase(lg)
|
||||
if len(norm_lg) >= 8 and norm_lg not in phrases:
|
||||
phrases.insert(0, norm_lg[:120])
|
||||
for tok in tokens:
|
||||
if len(tok) >= 6 and tok not in phrases:
|
||||
phrases.append(tok)
|
||||
return phrases[:8]
|
||||
|
||||
|
||||
def stage_refinement_criteria_from_learning_goal(learning_goal: str) -> List[str]:
|
||||
"""Erfolgskriterien für Phase C — nur aussagekräftige Mehrwort-Phrasen."""
|
||||
out: List[str] = []
|
||||
for phrase in stage_focus_phrases_from_learning_goal(learning_goal):
|
||||
p = str(phrase or "").strip()
|
||||
if not p:
|
||||
continue
|
||||
if " " in p or len(p) >= 12:
|
||||
out.append(p[:120])
|
||||
return out[:4]
|
||||
|
||||
|
||||
def exercise_title_matches_peer_stage_goal(
|
||||
title: str,
|
||||
*,
|
||||
current_learning_goal: str,
|
||||
peer_learning_goals: Sequence[str],
|
||||
) -> bool:
|
||||
"""Titel passt zum Lernziel einer anderen Roadmap-Stufe (Cross-Slot-Kollision)."""
|
||||
current = (current_learning_goal or "").strip()
|
||||
for peer in peer_learning_goals or []:
|
||||
plg = (peer or "").strip()
|
||||
if len(plg) < 3 or plg == current:
|
||||
continue
|
||||
if exercise_title_equivalent_to_stage_goal(title, plg):
|
||||
return True
|
||||
return False
|
||||
|
||||
|
||||
def _significant_stage_tokens(learning_goal: str, *, strip_negated: bool = True) -> List[str]:
|
||||
"""Wörter aus Stufen-Lernziel für Text-Match (ohne Füllwörter, ohne Negationssegmente)."""
|
||||
text = _normalize_phrase(learning_goal)
|
||||
@@ -1356,17 +1385,23 @@ def _pick_roadmap_rank_fallback(
|
||||
stage_anti_patterns: Optional[Sequence[str]] = None,
|
||||
path_primary_topic: Optional[str] = None,
|
||||
path_technique_excludes: Optional[Sequence[str]] = None,
|
||||
stage_match_brief: Optional[PlanningSemanticBrief] = None,
|
||||
peer_learning_goals: Optional[Sequence[str]] = None,
|
||||
) -> Optional[Dict[str, Any]]:
|
||||
"""
|
||||
Roadmap-Notfall: bester Treffer nach Stufen-Ranking, wenn striktes Gate leer läuft.
|
||||
|
||||
Filtert weiterhin Ausschlüsse und Technik-Scope (Kumite etc.), aber ohne
|
||||
Mindest-Semantik-Schwelle — so finden auch wortnahe Bibliotheks-Übungen den Slot.
|
||||
Weiterhin mit relaxed stage_fit — kein blindes Ranking ohne Stufen-Passung.
|
||||
"""
|
||||
stage_goal = (stage_learning_goal or "").strip()
|
||||
if not stage_goal or not hits:
|
||||
return None
|
||||
|
||||
stage_brief = stage_match_brief or build_stage_match_brief(
|
||||
learning_goal=stage_goal,
|
||||
anti_patterns=stage_anti_patterns,
|
||||
)
|
||||
|
||||
best: Optional[Dict[str, Any]] = None
|
||||
best_key: Tuple[float, float] = (-1.0, -1.0)
|
||||
for hit in hits:
|
||||
@@ -1379,33 +1414,31 @@ def _pick_roadmap_rank_fallback(
|
||||
title = str(hit.get("title") or "")
|
||||
summary = str(hit.get("summary") or "")
|
||||
goal_text = str(hit.get("goal") or hit.get("exercise_goal") or "")
|
||||
blob = _blob_from_fields(title, summary, goal_text, [])
|
||||
exclude_phrases = merge_stage_exclude_phrases(stage_goal, stage_anti_patterns)
|
||||
if exclude_phrases and _blob_matches_stage_excludes(blob, exclude_phrases):
|
||||
if peer_learning_goals and exercise_title_matches_peer_stage_goal(
|
||||
title,
|
||||
current_learning_goal=stage_goal,
|
||||
peer_learning_goals=peer_learning_goals,
|
||||
):
|
||||
continue
|
||||
title_equiv = exercise_title_equivalent_to_stage_goal(title, stage_goal)
|
||||
primary = (path_primary_topic or "").strip()
|
||||
if primary and not title_equiv:
|
||||
tech_excludes = list(path_technique_excludes or [])
|
||||
for item in technique_sibling_excludes(primary):
|
||||
if item not in tech_excludes:
|
||||
tech_excludes.append(item)
|
||||
if not exercise_passes_technique_path_scope(
|
||||
primary_topic=primary,
|
||||
title=title,
|
||||
summary=summary,
|
||||
goal=goal_text,
|
||||
learning_goal=stage_goal,
|
||||
sibling_excludes=tech_excludes,
|
||||
relaxed=True,
|
||||
):
|
||||
continue
|
||||
rank_sem = float(
|
||||
hit.get("stage_rank_semantic")
|
||||
or hit.get("stage_semantic_score")
|
||||
or hit.get("semantic_score")
|
||||
or 0.0
|
||||
)
|
||||
if not exercise_passes_stage_fit(
|
||||
learning_goal=stage_goal,
|
||||
title=title,
|
||||
summary=summary,
|
||||
goal=goal_text,
|
||||
stage_brief=stage_brief,
|
||||
stage_semantic_score=rank_sem,
|
||||
anti_patterns=stage_anti_patterns,
|
||||
path_primary_topic=path_primary_topic,
|
||||
path_technique_excludes=path_technique_excludes,
|
||||
relaxed=True,
|
||||
):
|
||||
continue
|
||||
score = float(hit.get("score") or 0.0)
|
||||
key = (rank_sem, score)
|
||||
if key > best_key:
|
||||
@@ -1427,6 +1460,7 @@ def pick_best_path_hit(
|
||||
stage_match_brief: Optional[PlanningSemanticBrief] = None,
|
||||
path_primary_topic: Optional[str] = None,
|
||||
path_technique_excludes: Optional[Sequence[str]] = None,
|
||||
peer_learning_goals: Optional[Sequence[str]] = None,
|
||||
) -> Optional[Dict[str, Any]]:
|
||||
"""Gestufte Auswahl: strikt → relaxed → optional Notfall-Fallback."""
|
||||
if not hits:
|
||||
@@ -1451,6 +1485,12 @@ def pick_best_path_hit(
|
||||
title = str(hit.get("title") or "")
|
||||
summary = str(hit.get("summary") or "")
|
||||
goal_text = str(hit.get("goal") or hit.get("exercise_goal") or "")
|
||||
if peer_learning_goals and exercise_title_matches_peer_stage_goal(
|
||||
title,
|
||||
current_learning_goal=stage_goal,
|
||||
peer_learning_goals=peer_learning_goals,
|
||||
):
|
||||
continue
|
||||
sem = float(hit.get("semantic_score") or 0.0)
|
||||
stage_sem = float(
|
||||
hit.get("stage_rank_semantic")
|
||||
@@ -1506,6 +1546,8 @@ def pick_best_path_hit(
|
||||
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,
|
||||
)
|
||||
|
||||
chosen = _scan(strict=False)
|
||||
@@ -1546,6 +1588,7 @@ __all__ = [
|
||||
"build_stage_match_brief",
|
||||
"enrich_brief_with_path_constraints",
|
||||
"exercise_passes_stage_fit",
|
||||
"exercise_title_matches_peer_stage_goal",
|
||||
"exercise_title_equivalent_to_stage_goal",
|
||||
"resolve_path_primary_topic",
|
||||
"resolve_path_anti_patterns",
|
||||
@@ -1555,6 +1598,7 @@ __all__ = [
|
||||
"merge_stage_exclude_phrases",
|
||||
"parse_stage_goal_constraints",
|
||||
"stage_focus_phrases_from_learning_goal",
|
||||
"stage_refinement_criteria_from_learning_goal",
|
||||
"pick_best_path_hit",
|
||||
"exercise_passes_technique_path_scope",
|
||||
"score_exercise_stage_fit",
|
||||
|
||||
Reference in new issue
Block a user