Enhance Path QA and Stage Matching 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 1m14s
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 1m14s
- Introduced multistage path quality assurance (QA) functionality to improve exercise relevance and feedback through structured tiers and optimization hints. - Updated stage specifications to include `start_state` and `target_state` for better contextualization in roadmap matching. - Enhanced semantic brief construction with technique sibling exclusions to refine exercise selection based on primary topics. - Improved path retrieval logic to incorporate new parameters for nuanced matching against learning goals. - Incremented application version to reflect these updates.
This commit is contained in:
1 parent
4ef3f00e6b
commit
a152218c45
13 files changed
+760
-6
No files matched your search
@@ -180,6 +180,51 @@ def _find_technique_in_text(q_lower: str) -> Optional[Tuple[str, Tuple[str, ...]
|
||||
return None
|
||||
|
||||
|
||||
def technique_sibling_excludes(primary_topic: str) -> List[str]:
|
||||
"""Andere Techniken derselben Familie (z. B. Mae/Yoko bei Mawashi) — aus Katalog."""
|
||||
topic = _normalize_phrase(primary_topic)
|
||||
if not topic:
|
||||
return []
|
||||
hit = _find_technique_in_text(topic)
|
||||
if not hit:
|
||||
return []
|
||||
out: List[str] = []
|
||||
for raw in hit[1]:
|
||||
for expanded in _expand_stage_exclude_phrase(raw):
|
||||
if expanded and expanded not in out:
|
||||
out.append(expanded)
|
||||
return out[:16]
|
||||
|
||||
|
||||
def exercise_passes_technique_path_scope(
|
||||
*,
|
||||
primary_topic: str,
|
||||
title: str,
|
||||
summary: str = "",
|
||||
goal: str = "",
|
||||
learning_goal: str = "",
|
||||
sibling_excludes: Optional[Sequence[str]] = None,
|
||||
relaxed: bool = False,
|
||||
) -> bool:
|
||||
"""
|
||||
Technik-Pfad: keine Geschwister-Technik; Haupttechnik im Übungstext oder Stufen-Lernziel.
|
||||
"""
|
||||
primary = _normalize_phrase(primary_topic)
|
||||
if not primary:
|
||||
return True
|
||||
|
||||
blob = _blob_from_fields(title, summary, goal, [])
|
||||
excludes = list(sibling_excludes or technique_sibling_excludes(primary))
|
||||
if excludes and _blob_matches_stage_excludes(blob, excludes):
|
||||
return False
|
||||
|
||||
in_exercise = _phrase_in_blob(primary, blob)
|
||||
in_stage = _phrase_in_blob(primary, _blob_from_fields("", "", learning_goal, []))
|
||||
if in_exercise or in_stage:
|
||||
return True
|
||||
return relaxed
|
||||
|
||||
|
||||
def _detect_development_arc(q_lower: str) -> List[str]:
|
||||
found: List[str] = []
|
||||
for phase, markers in _ARC_PHASES:
|
||||
@@ -850,13 +895,19 @@ def build_stage_match_brief(
|
||||
phase: Optional[str] = None,
|
||||
path_context_note: Optional[str] = None,
|
||||
path_anti_patterns: Optional[Sequence[str]] = None,
|
||||
path_primary_topic: Optional[str] = None,
|
||||
path_technique_excludes: Optional[Sequence[str]] = None,
|
||||
stage_start_state: Optional[str] = None,
|
||||
stage_target_state: Optional[str] = None,
|
||||
path_target_state: Optional[str] = None,
|
||||
contextualized_learning_goal: Optional[str] = None,
|
||||
) -> PlanningSemanticBrief:
|
||||
"""
|
||||
Stufen-zentrierter Semantik-Brief — unabhängig vom Gesamt-Pfad-Thema.
|
||||
|
||||
Primär für Roadmap-Match: Bewertung gegen Titel + Kurzbeschreibung + Übungsziel.
|
||||
"""
|
||||
lg = (learning_goal or "").strip()
|
||||
lg = (contextualized_learning_goal or learning_goal or "").strip()
|
||||
if len(lg) < 3:
|
||||
return PlanningSemanticBrief(semantic_strength=0.0)
|
||||
|
||||
@@ -865,9 +916,20 @@ def build_stage_match_brief(
|
||||
s = str(raw or "").strip()
|
||||
if s and s not in merged_anti:
|
||||
merged_anti.append(s)
|
||||
primary_path = _normalize_phrase(path_primary_topic or "")
|
||||
if primary_path:
|
||||
for item in technique_sibling_excludes(primary_path):
|
||||
if item not in merged_anti:
|
||||
merged_anti.append(item)
|
||||
for raw in path_technique_excludes or []:
|
||||
for expanded in _expand_stage_exclude_phrase(str(raw or "")):
|
||||
if expanded and expanded not in merged_anti:
|
||||
merged_anti.append(expanded)
|
||||
constraints = parse_stage_goal_constraints(lg, merged_anti)
|
||||
must: List[str] = []
|
||||
norm_lg = _normalize_phrase(lg)
|
||||
if primary_path and primary_path not in must:
|
||||
must.insert(0, primary_path[:120])
|
||||
for token in constraints.positive_tokens:
|
||||
if token not in must:
|
||||
must.append(token)
|
||||
@@ -883,6 +945,10 @@ def build_stage_match_brief(
|
||||
must.append(s[:60])
|
||||
|
||||
retrieval_parts = [norm_lg]
|
||||
for raw in (stage_start_state, stage_target_state, path_target_state):
|
||||
s = _normalize_phrase(str(raw or ""))[:200]
|
||||
if s and s not in retrieval_parts:
|
||||
retrieval_parts.append(s)
|
||||
if path_context_note:
|
||||
note = _normalize_phrase(path_context_note)[:200]
|
||||
if note:
|
||||
@@ -950,12 +1016,14 @@ def exercise_passes_stage_fit(
|
||||
stage_semantic_score: Optional[float] = None,
|
||||
anti_patterns: Optional[Sequence[str]] = None,
|
||||
step_phase: Optional[str] = None,
|
||||
path_primary_topic: Optional[str] = None,
|
||||
path_technique_excludes: Optional[Sequence[str]] = None,
|
||||
min_stage_semantic: float = _MIN_STAGE_FIT_SEMANTIC,
|
||||
relaxed: bool = False,
|
||||
) -> bool:
|
||||
"""Allgemeines Stufen-Fit-Gate: voller Übungstext vs. Stufen-Brief."""
|
||||
lg = (learning_goal or "").strip()
|
||||
if len(lg) < 3:
|
||||
if len(lg) < 3 and not (path_primary_topic or "").strip():
|
||||
return True
|
||||
|
||||
blob = _blob_from_fields(title, summary, goal, [])
|
||||
@@ -963,6 +1031,18 @@ def exercise_passes_stage_fit(
|
||||
if constraints.exclude_phrases and _blob_matches_stage_excludes(blob, constraints.exclude_phrases):
|
||||
return False
|
||||
|
||||
primary_path = (path_primary_topic or "").strip()
|
||||
if primary_path and not exercise_passes_technique_path_scope(
|
||||
primary_topic=primary_path,
|
||||
title=title,
|
||||
summary=summary,
|
||||
goal=goal,
|
||||
learning_goal=lg,
|
||||
sibling_excludes=path_technique_excludes,
|
||||
relaxed=relaxed,
|
||||
):
|
||||
return False
|
||||
|
||||
brief = stage_brief or build_stage_match_brief(
|
||||
learning_goal=lg,
|
||||
anti_patterns=anti_patterns,
|
||||
@@ -1102,6 +1182,8 @@ def pick_best_path_hit(
|
||||
stage_anti_patterns: Optional[Sequence[str]] = None,
|
||||
roadmap_stage_match: bool = False,
|
||||
stage_match_brief: Optional[PlanningSemanticBrief] = None,
|
||||
path_primary_topic: Optional[str] = None,
|
||||
path_technique_excludes: Optional[Sequence[str]] = None,
|
||||
) -> Optional[Dict[str, Any]]:
|
||||
"""Gestufte Auswahl: strikt → relaxed → optional Notfall-Fallback."""
|
||||
if not hits:
|
||||
@@ -1138,6 +1220,8 @@ def pick_best_path_hit(
|
||||
stage_brief=stage_brief,
|
||||
stage_semantic_score=stage_sem,
|
||||
anti_patterns=stage_anti_patterns,
|
||||
path_primary_topic=path_primary_topic,
|
||||
path_technique_excludes=path_technique_excludes,
|
||||
relaxed=not strict,
|
||||
):
|
||||
continue
|
||||
@@ -1209,8 +1293,10 @@ __all__ = [
|
||||
"merge_semantic_brief_llm",
|
||||
"parse_stage_goal_constraints",
|
||||
"pick_best_path_hit",
|
||||
"exercise_passes_technique_path_scope",
|
||||
"score_exercise_stage_fit",
|
||||
"semantic_brief_for_stage",
|
||||
"technique_sibling_excludes",
|
||||
"resolve_semantic_skill_weights",
|
||||
"score_exercise_semantic_relevance",
|
||||
"semantic_core_phrases",
|
||||
|
||||
Reference in new issue
Block a user