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
@@ -36,7 +36,9 @@ from planning_exercise_semantics import (
|
||||
brief_to_summary_dict,
|
||||
build_semantic_brief,
|
||||
build_stage_match_brief,
|
||||
enrich_brief_with_path_constraints,
|
||||
enrich_target_with_semantic_expectations,
|
||||
resolve_path_anti_patterns,
|
||||
exercise_passes_path_semantic_gate,
|
||||
pick_best_path_hit,
|
||||
resolve_semantic_skill_weights,
|
||||
@@ -487,6 +489,7 @@ def _annotate_roadmap_step(
|
||||
stage_spec: StageSpecArtifact,
|
||||
major_step: Optional[MajorStep],
|
||||
skill_expectations: Optional[Dict[str, Any]] = None,
|
||||
anti_patterns_override: Optional[List[str]] = None,
|
||||
) -> Dict[str, Any]:
|
||||
reasons = list(step.get("reasons") or [])
|
||||
learning_goal = (stage_spec.learning_goal or "").strip()
|
||||
@@ -508,8 +511,9 @@ def _annotate_roadmap_step(
|
||||
step["roadmap_major_step_index"] = stage_spec.major_step_index
|
||||
step["roadmap_phase"] = major_step.phase if major_step else None
|
||||
step["roadmap_learning_goal"] = learning_goal or None
|
||||
if stage_spec.anti_patterns:
|
||||
step["roadmap_anti_patterns"] = list(stage_spec.anti_patterns)
|
||||
anti = list(anti_patterns_override or stage_spec.anti_patterns or [])
|
||||
if anti:
|
||||
step["roadmap_anti_patterns"] = anti
|
||||
step["roadmap_match_source"] = "stage_spec"
|
||||
if skill_expectations:
|
||||
step["skill_expectations"] = skill_expectations
|
||||
@@ -589,7 +593,6 @@ def _build_steps_roadmap_first(
|
||||
)
|
||||
step_kind = resolve_step_exercise_kind_filter(stage_spec, body.exercise_kind_any)
|
||||
stage_goal = (stage_spec.learning_goal or "").strip()
|
||||
stage_anti = list(stage_spec.anti_patterns or [])
|
||||
path_context_note = None
|
||||
if rs_dump:
|
||||
ctx_parts = [
|
||||
@@ -598,6 +601,12 @@ def _build_steps_roadmap_first(
|
||||
str(rs_dump.get("roadmap_notes") or "").strip()[:120],
|
||||
]
|
||||
path_context_note = " ".join(p for p in ctx_parts if p)[:240] or None
|
||||
path_anti = resolve_path_anti_patterns(
|
||||
goal_query,
|
||||
semantic_brief=semantic_brief,
|
||||
extra_context=path_context_note,
|
||||
)
|
||||
stage_anti = list(dict.fromkeys([*(stage_spec.anti_patterns or []), *path_anti]))
|
||||
stage_match_brief = build_stage_match_brief(
|
||||
learning_goal=stage_goal,
|
||||
anti_patterns=stage_anti,
|
||||
@@ -605,6 +614,7 @@ def _build_steps_roadmap_first(
|
||||
load_profile=list(stage_spec.load_profile or []),
|
||||
phase=major.phase if major else None,
|
||||
path_context_note=path_context_note,
|
||||
path_anti_patterns=path_anti,
|
||||
)
|
||||
|
||||
hits, _, _, _ = _run_path_step_retrieval(
|
||||
@@ -652,6 +662,7 @@ def _build_steps_roadmap_first(
|
||||
stage_spec=stage_spec,
|
||||
major_step=major,
|
||||
skill_expectations=skill_exp_api,
|
||||
anti_patterns_override=stage_anti,
|
||||
)
|
||||
steps.append(step)
|
||||
eid = int(step["exercise_id"])
|
||||
@@ -795,7 +806,13 @@ def _run_evaluate_only_path_qa(
|
||||
bridge_inserts=bridge_inserts,
|
||||
)
|
||||
|
||||
off_topic_steps = detect_off_topic_steps(cur, steps, brief=semantic_brief)
|
||||
off_topic_steps = detect_off_topic_steps(
|
||||
cur,
|
||||
steps,
|
||||
brief=semantic_brief,
|
||||
goal_query=goal_query,
|
||||
)
|
||||
steps, stripped_off_topic = strip_off_topic_steps_from_path(steps, off_topic_steps)
|
||||
llm_gap_specs = parse_llm_suggested_new_exercises(
|
||||
llm_qa,
|
||||
brief=semantic_brief,
|
||||
@@ -807,7 +824,7 @@ def _run_evaluate_only_path_qa(
|
||||
gap_specs = collect_gap_fill_specs(
|
||||
steps=steps,
|
||||
unfilled_gaps=fresh_large_gaps or unfilled_gaps,
|
||||
off_topic_steps=off_topic_steps,
|
||||
off_topic_steps=off_topic_steps if not stripped_off_topic else [],
|
||||
llm_specs=llm_gap_specs,
|
||||
brief=semantic_brief,
|
||||
goal_query=goal_query,
|
||||
@@ -902,6 +919,20 @@ def suggest_progression_path(
|
||||
semantic_brief, semantic_llm_applied = try_enrich_semantic_brief_with_llm(
|
||||
cur, goal_query, semantic_brief
|
||||
)
|
||||
extra_path_ctx = " ".join(
|
||||
p
|
||||
for p in (
|
||||
(body.start_situation or "").strip(),
|
||||
(body.target_state or "").strip(),
|
||||
(body.roadmap_notes or "").strip(),
|
||||
)
|
||||
if p
|
||||
)
|
||||
semantic_brief = enrich_brief_with_path_constraints(
|
||||
semantic_brief,
|
||||
goal_query,
|
||||
extra_context=extra_path_ctx or None,
|
||||
)
|
||||
|
||||
roadmap_first = bool(body.roadmap_first)
|
||||
roadmap_only = bool(body.roadmap_only)
|
||||
@@ -1222,7 +1253,12 @@ def suggest_progression_path(
|
||||
if llm_qa.get("overall_ok") or (q_val is not None and q_val >= 0.45):
|
||||
steps, reorder_applied, reorder_notes = apply_llm_path_reorder(steps, llm_qa)
|
||||
|
||||
off_topic_steps = detect_off_topic_steps(cur, steps, brief=semantic_brief)
|
||||
off_topic_steps = detect_off_topic_steps(
|
||||
cur,
|
||||
steps,
|
||||
brief=semantic_brief,
|
||||
goal_query=goal_query,
|
||||
)
|
||||
steps, stripped_off_topic = strip_off_topic_steps_from_path(steps, off_topic_steps)
|
||||
if stripped_off_topic:
|
||||
off_topic_steps = []
|
||||
|
||||
Reference in new issue
Block a user