Enhance Gap Fill Goal Text and Skill Expectations Integration
Deploy Development / deploy (push) Successful in 42s
Test Suite / pytest-backend (push) Successful in 48s
Test Suite / lint-backend (push) Successful in 0s
Test Suite / build-frontend (push) Successful in 13s
Test Suite / k6 /health Baseline (push) Successful in 33s
Test Suite / playwright-tests (push) Successful in 1m22s

- Updated `build_gap_fill_goal_text` to include expected skills in the generated text, improving clarity for users.
- Enhanced `_roadmap_gap_snapshot_for_spec` to incorporate skill expectations from the progression stage, enriching the roadmap context.
- Modified `_annotate_roadmap_step` to append skill expectations to the step reasons, providing additional insights.
- Updated tests to verify the inclusion of expected skills in the gap fill goal text.
- Incremented application version to 0.8.215 to reflect these changes.
This commit is contained in:
Lars committed 2026-06-10 07:09:46 +02:00
1 parent 0adf20c9e1
commit 1e7941f57b
7 files changed
+593 -5

No files matched your search

+102 -4
View File
@@ -51,6 +51,12 @@ from planning_exercise_suggest import (
resolve_planning_exercise_intent,
)
from planning_exercise_form_context import build_progression_gap_snapshot
from planning_skill_expectations import (
apply_expectations_to_target,
build_planning_skill_expectations,
expectation_input_from_progression_path,
expectation_input_from_progression_stage,
)
from planning_progression_roadmap import (
MajorStep,
ProgressionRoadmapContext,
@@ -91,14 +97,17 @@ class ProgressionPathSuggestRequest(BaseModel):
def _roadmap_gap_snapshot_for_spec(
cur,
roadmap_ctx: Optional[ProgressionRoadmapContext],
spec: Mapping[str, Any],
*,
goal_query: str,
semantic_brief: PlanningSemanticBrief,
) -> Dict[str, Any]:
"""Roadmap-Kontext für KI-Lücken-Übung (Start, Ziel, Stufenspec)."""
"""Roadmap-Kontext für KI-Lücken-Übung (Start, Ziel, Stufenspec, Fähigkeiten)."""
major_idx = spec.get("roadmap_major_step_index")
stage_spec_dict: Optional[Dict[str, Any]] = None
major_dict: Optional[Dict[str, Any]] = None
if roadmap_ctx and major_idx is not None:
for s in roadmap_ctx.stage_specs or []:
if int(s.major_step_index) == int(major_idx):
@@ -107,6 +116,7 @@ def _roadmap_gap_snapshot_for_spec(
for m in roadmap_ctx.roadmap.major_steps:
if m.index == int(major_idx):
stage_spec_dict["phase"] = m.phase
major_dict = m.model_dump()
break
break
ga = roadmap_ctx.goal_analysis.model_dump() if roadmap_ctx and roadmap_ctx.goal_analysis else None
@@ -120,12 +130,25 @@ def _roadmap_gap_snapshot_for_spec(
if roadmap_ctx and roadmap_ctx.semantic_brief
else brief_to_summary_dict(semantic_brief)
)
return build_progression_gap_snapshot(
snap = build_progression_gap_snapshot(
goal_analysis=ga,
resolved_structured=rs,
stage_spec=stage_spec_dict,
semantic_brief=brief_summary,
)
inp = expectation_input_from_progression_stage(
goal_query=goal_query,
goal_analysis=ga,
resolved_structured=rs,
stage_spec=stage_spec_dict,
semantic_brief_summary=brief_summary,
major_step=major_dict,
)
exp = build_planning_skill_expectations(cur, inp, semantic_brief=semantic_brief)
if exp.items:
snap["expected_skills"] = exp.to_api_dict()["expected_skills"]
snap["skill_expectation_sources"] = exp.sources
return snap
def _roadmap_structured_from_body(body: ProgressionPathSuggestRequest) -> Optional[RoadmapStructuredInput]:
@@ -244,6 +267,7 @@ def _run_path_step_retrieval(
path_intent: Optional[str] = None,
step_query_override: Optional[str] = None,
step_phase_override: Optional[str] = None,
step_target_profile_override: Optional[PlanningTargetProfile] = None,
) -> Tuple[List[Dict[str, Any]], PlanningTargetProfile, Dict[str, Any], str]:
step_query = step_query_override or step_retrieval_query(
semantic_brief, goal_query, step_index, max_steps
@@ -311,7 +335,11 @@ def _run_path_step_retrieval(
"expectation_mode": "query_only" if step_index == 0 and not planned_ids else "planning_hybrid",
}
if path_target_profile is not None:
if step_target_profile_override is not None:
target_profile = step_target_profile_override
intent = path_intent or resolve_planning_exercise_intent(goal_query, "free_search")
query_intent_summary = {}
elif path_target_profile is not None:
target_profile = path_target_profile
intent = path_intent or resolve_planning_exercise_intent(goal_query, "free_search")
query_intent_summary = {}
@@ -414,6 +442,7 @@ def _annotate_roadmap_step(
*,
stage_spec: StageSpecArtifact,
major_step: Optional[MajorStep],
skill_expectations: Optional[Dict[str, Any]] = None,
) -> Dict[str, Any]:
reasons = list(step.get("reasons") or [])
learning_goal = (stage_spec.learning_goal or "").strip()
@@ -421,11 +450,23 @@ def _annotate_roadmap_step(
roadmap_reason = f"Roadmap: {learning_goal[:120]}"
if roadmap_reason not in reasons:
reasons.insert(0, roadmap_reason)
if skill_expectations and skill_expectations.get("expected_skills"):
names = [
str(s.get("skill_name") or "").strip()
for s in skill_expectations["expected_skills"][:3]
if str(s.get("skill_name") or "").strip()
]
if names:
skill_reason = f"Fähigkeiten: {', '.join(names)}"
if skill_reason not in reasons:
reasons.append(skill_reason)
step["reasons"] = reasons[:4]
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
step["roadmap_match_source"] = "stage_spec"
if skill_expectations:
step["skill_expectations"] = skill_expectations
return step
@@ -463,8 +504,37 @@ def _build_steps_roadmap_first(
anchor_variant_id: Optional[int] = None
unfilled: List[Tuple[int, StageSpecArtifact]] = []
ga_dump = (
roadmap_ctx.goal_analysis.model_dump() if roadmap_ctx.goal_analysis else None
)
rs_dump = (
roadmap_ctx.resolved_structured.model_dump()
if roadmap_ctx.resolved_structured
else None
)
brief_summary = (
roadmap_ctx.semantic_brief
if roadmap_ctx.semantic_brief
else brief_to_summary_dict(semantic_brief)
)
for step_index, stage_spec in enumerate(stage_specs):
major = major_by_index.get(stage_spec.major_step_index)
stage_spec_dict = stage_spec.model_dump()
if major:
stage_spec_dict["phase"] = major.phase
stage_inp = expectation_input_from_progression_stage(
goal_query=goal_query,
goal_analysis=ga_dump,
resolved_structured=rs_dump,
stage_spec=stage_spec_dict,
semantic_brief_summary=brief_summary,
major_step=major.model_dump() if major else None,
)
stage_exp = build_planning_skill_expectations(cur, stage_inp, semantic_brief=semantic_brief)
step_target = apply_expectations_to_target(path_target_profile, stage_exp)
skill_exp_api = stage_exp.to_api_dict() if stage_exp.items else None
step_query = stage_spec_retrieval_query(
semantic_brief=semantic_brief,
goal_query=goal_query,
@@ -490,6 +560,7 @@ def _build_steps_roadmap_first(
path_intent=path_intent,
step_query_override=step_query,
step_phase_override=major.phase if major else None,
step_target_profile_override=step_target,
)
hit = _pick_best_path_hit(hits, used, semantic_brief=semantic_brief)
@@ -511,6 +582,7 @@ def _build_steps_roadmap_first(
path_intent=path_intent,
step_query_override=goal_query,
step_phase_override=major.phase if major else None,
step_target_profile_override=step_target,
)
hit = _pick_best_path_hit(hits, used, semantic_brief=semantic_brief)
@@ -522,6 +594,7 @@ def _build_steps_roadmap_first(
_hit_to_path_step(hit),
stage_spec=stage_spec,
major_step=major,
skill_expectations=skill_exp_api,
)
steps.append(step)
eid = int(step["exercise_id"])
@@ -652,6 +725,26 @@ def suggest_progression_path(
semantic_brief=semantic_brief,
include_llm_intent=body.include_llm_intent,
)
path_skill_expectations: Optional[Dict[str, Any]] = None
if roadmap_ctx and roadmap_ctx.goal_analysis:
path_inp = expectation_input_from_progression_path(
goal_query=goal_query,
goal_analysis=roadmap_ctx.goal_analysis.model_dump(),
resolved_structured=(
roadmap_ctx.resolved_structured.model_dump()
if roadmap_ctx.resolved_structured
else None
),
semantic_brief_summary=(
roadmap_ctx.semantic_brief
if roadmap_ctx.semantic_brief
else brief_to_summary_dict(semantic_brief)
),
)
path_exp = build_planning_skill_expectations(cur, path_inp, semantic_brief=semantic_brief)
if path_exp.items:
path_target_profile = apply_expectations_to_target(path_target_profile, path_exp)
path_skill_expectations = path_exp.to_api_dict()
roadmap_unfilled: List[Tuple[int, StageSpecArtifact]] = []
roadmap_gap_offers: List[Dict[str, Any]] = []
@@ -702,7 +795,11 @@ def suggest_progression_path(
brief=semantic_brief,
proposal=None,
roadmap_snapshot=_roadmap_gap_snapshot_for_spec(
roadmap_ctx, spec, semantic_brief=semantic_brief
cur,
roadmap_ctx,
spec,
goal_query=goal_query,
semantic_brief=semantic_brief,
),
)
)
@@ -927,6 +1024,7 @@ def suggest_progression_path(
"roadmap_only": False,
"roadmap_edited": roadmap_edited,
"roadmap_unfilled_count": len(roadmap_unfilled),
"path_skill_expectations": path_skill_expectations,
"retrieval_phase": "+".join(retrieval_parts),
}