Enhance Path Exclusion Logic and Semantic Brief Enrichment
Deploy Development / deploy (push) Successful in 44s
Test Suite / pytest-backend (push) Successful in 43s
Test Suite / lint-backend (push) Successful in 1s
Test Suite / build-frontend (push) Successful in 14s
Test Suite / k6 /health Baseline (push) Successful in 34s
Test Suite / playwright-tests (push) Has been cancelled
Deploy Development / deploy (push) Successful in 44s
Test Suite / pytest-backend (push) Successful in 43s
Test Suite / lint-backend (push) Successful in 1s
Test Suite / build-frontend (push) Successful in 14s
Test Suite / k6 /health Baseline (push) Successful in 34s
Test Suite / playwright-tests (push) Has been cancelled
- Introduced `resolve_path_anti_patterns` to improve handling of path exclusions based on explicit negations and semantic briefs. - Updated `enrich_brief_with_path_constraints` to incorporate path-specific exclusions into semantic briefs, enhancing exercise relevance. - Modified roadmap step annotation to allow for anti-pattern overrides, improving flexibility in exercise selection. - Enhanced tests to validate new path exclusion features and ensure correct functionality against learning goals. - Incremented application version to reflect these updates.
This commit is contained in:
1 parent
07e147bc76
commit
3c12363b8f
6 files changed
+270
-18
No files matched your search
@@ -18,9 +18,12 @@ from openrouter_chat import (
|
||||
|
||||
from planning_exercise_semantics import (
|
||||
PlanningSemanticBrief,
|
||||
_blob_from_fields,
|
||||
_blob_matches_stage_excludes,
|
||||
brief_to_summary_dict,
|
||||
exercise_passes_path_semantic_gate,
|
||||
exercise_passes_stage_learning_goal_gate,
|
||||
resolve_path_anti_patterns,
|
||||
score_exercise_semantic_relevance,
|
||||
semantic_brief_for_stage,
|
||||
step_phase_for_index,
|
||||
@@ -398,17 +401,39 @@ def detect_off_topic_steps(
|
||||
steps: Sequence[Mapping[str, Any]],
|
||||
*,
|
||||
brief: PlanningSemanticBrief,
|
||||
goal_query: Optional[str] = None,
|
||||
) -> List[Dict[str, Any]]:
|
||||
"""Schritte ohne Bezug zum Pfad-Thema (z. B. reine Kraftübungen bei Mae Geri)."""
|
||||
if brief.semantic_strength < 0.55 or len(steps) < 2:
|
||||
return []
|
||||
|
||||
path_anti = resolve_path_anti_patterns(goal_query or "", semantic_brief=brief)
|
||||
off_topic: List[Dict[str, Any]] = []
|
||||
total = len(steps)
|
||||
for idx, step in enumerate(steps):
|
||||
if step.get("is_ai_proposal") or step.get("exercise_id") is None:
|
||||
continue
|
||||
bundle = _load_exercise_text_bundle(cur, int(step["exercise_id"]))
|
||||
blob = _blob_from_fields(
|
||||
bundle["title"],
|
||||
bundle["summary"],
|
||||
bundle["goal"],
|
||||
bundle["variant_names"],
|
||||
)
|
||||
step_anti = list(step.get("roadmap_anti_patterns") or []) + path_anti
|
||||
if step_anti and _blob_matches_stage_excludes(blob, step_anti):
|
||||
off_topic.append(
|
||||
{
|
||||
"step_index": idx,
|
||||
"exercise_id": int(step["exercise_id"]),
|
||||
"title": step.get("title") or bundle["title"],
|
||||
"semantic_score": 0.0,
|
||||
"expected_phase": (step.get("roadmap_phase") or "").strip().lower() or None,
|
||||
"issue": "path_exclude",
|
||||
"reasons": ["Widerspricht Pfad-Ausschlüssen (z. B. Kumite)"],
|
||||
}
|
||||
)
|
||||
continue
|
||||
stage_goal = (step.get("roadmap_learning_goal") or "").strip()
|
||||
phase = (step.get("roadmap_phase") or "").strip().lower() or step_phase_for_index(
|
||||
brief, idx, total
|
||||
@@ -529,9 +554,10 @@ def strip_off_topic_steps_from_path(
|
||||
return steps, []
|
||||
|
||||
by_index = {int(o["step_index"]): dict(o) for o in off_topic_steps if o.get("step_index") is not None}
|
||||
indices = sorted(by_index.keys(), reverse=True)
|
||||
if len(steps) - len(indices) < min_remaining:
|
||||
max_remove = max(0, len(steps) - min_remaining)
|
||||
if max_remove <= 0:
|
||||
return steps, []
|
||||
indices = sorted(by_index.keys(), reverse=True)[:max_remove]
|
||||
|
||||
out = list(steps)
|
||||
removed: List[Dict[str, Any]] = []
|
||||
|
||||
Reference in new issue
Block a user