Enhance Roadmap Slot Matching and Gap Offer Logic
Deploy Development / deploy (push) Successful in 45s
Test Suite / pytest-backend (push) Successful in 45s
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
Deploy Development / deploy (push) Successful in 45s
Test Suite / pytest-backend (push) Successful in 45s
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
- Introduced `_roadmap_step_passes_post_match_gate` to validate steps after matching, ensuring only relevant steps proceed. - Enhanced `_enrich_roadmap_unfilled_gap_offers` to generate AI gap offers for unfilled roadmap slots, improving exercise suggestions. - Updated `suggest_progression_path` to incorporate new gap offer logic and streamline the handling of roadmap steps. - Refined frontend logic in `applyMatchStepsToSlots` to better manage step assignments and improve clarity in slot handling. - Bumped version to 0.8.231 to reflect the new features and improvements.
This commit is contained in:
1 parent
d448c3191f
commit
63c99b0ec5
5 files changed
+245
-93
No files matched your search
@@ -1272,9 +1272,35 @@ def _match_roadmap_slot(
|
||||
else:
|
||||
step["slot_status"] = "matched"
|
||||
step["roadmap_match_source"] = "stage_spec"
|
||||
if step.get("roadmap_match_source") != "slot_best_match" and not _roadmap_step_passes_post_match_gate(
|
||||
cur,
|
||||
step,
|
||||
goal_query=goal_query,
|
||||
semantic_brief=semantic_brief,
|
||||
):
|
||||
return None, stage_spec
|
||||
return step, None
|
||||
|
||||
|
||||
def _roadmap_step_passes_post_match_gate(
|
||||
cur,
|
||||
step: Dict[str, Any],
|
||||
*,
|
||||
goal_query: str,
|
||||
semantic_brief: PlanningSemanticBrief,
|
||||
) -> bool:
|
||||
"""Abgleich mit Pfad-QA — kein Rematch-Treffer, der sofort wieder stage_mismatch wäre."""
|
||||
if step.get("exercise_id") is None:
|
||||
return False
|
||||
issues = detect_off_topic_steps(
|
||||
cur,
|
||||
[step],
|
||||
brief=semantic_brief,
|
||||
goal_query=goal_query,
|
||||
)
|
||||
return not issues
|
||||
|
||||
|
||||
def _normalize_roadmap_steps_coverage(
|
||||
steps: List[Dict[str, Any]],
|
||||
*,
|
||||
@@ -1394,6 +1420,92 @@ def _purge_stage_mismatch_roadmap_slots(
|
||||
return out, new_unfilled
|
||||
|
||||
|
||||
def _enrich_roadmap_unfilled_gap_offers(
|
||||
cur,
|
||||
*,
|
||||
steps: List[Dict[str, Any]],
|
||||
gap_fill_offers: List[Dict[str, Any]],
|
||||
body: ProgressionPathSuggestRequest,
|
||||
roadmap_ctx: ProgressionRoadmapContext,
|
||||
goal_query: str,
|
||||
semantic_brief: PlanningSemanticBrief,
|
||||
) -> Tuple[List[Dict[str, Any]], List[Dict[str, Any]]]:
|
||||
"""KI-Lücken-Angebote für alle leeren Roadmap-Slots (nach Rematch/Normalize)."""
|
||||
if not body.include_ai_gap_fill:
|
||||
return steps, gap_fill_offers
|
||||
|
||||
seen_offer_ids = {o.get("offer_id") for o in gap_fill_offers if o.get("offer_id")}
|
||||
out_steps: List[Dict[str, Any]] = []
|
||||
offers = list(gap_fill_offers)
|
||||
|
||||
for raw in steps:
|
||||
step = dict(raw)
|
||||
if step.get("exercise_id") is not None:
|
||||
out_steps.append(step)
|
||||
continue
|
||||
try:
|
||||
major_idx = int(step["roadmap_major_step_index"])
|
||||
except (TypeError, ValueError, KeyError):
|
||||
out_steps.append(step)
|
||||
continue
|
||||
if step.get("gap_offer") and step.get("proposal_key"):
|
||||
oid = step["gap_offer"].get("offer_id")
|
||||
if oid and oid not in seen_offer_ids:
|
||||
offers.append(dict(step["gap_offer"]))
|
||||
seen_offer_ids.add(oid)
|
||||
out_steps.append(step)
|
||||
continue
|
||||
stage_spec = next(
|
||||
(
|
||||
s
|
||||
for s in (roadmap_ctx.stage_specs or [])
|
||||
if int(s.major_step_index) == major_idx
|
||||
),
|
||||
None,
|
||||
)
|
||||
learning_goal = (
|
||||
(stage_spec.learning_goal if stage_spec else None)
|
||||
or step.get("roadmap_learning_goal")
|
||||
or step.get("title")
|
||||
or ""
|
||||
).strip()
|
||||
spec = {
|
||||
"source": "roadmap_unfilled",
|
||||
"insert_after_index": max(major_idx - 1, -1),
|
||||
"roadmap_major_step_index": major_idx,
|
||||
"phase": (step.get("roadmap_phase") or "vertiefung").strip().lower(),
|
||||
"title_hint": (learning_goal or f"Slot {major_idx + 1}")[:120],
|
||||
"sketch": learning_goal,
|
||||
"rationale": (
|
||||
f"Slot {major_idx + 1} — keine passende Bibliotheks-Übung; "
|
||||
"KI-Entwurf für diese Stufe."
|
||||
),
|
||||
}
|
||||
offer = build_gap_fill_offer(
|
||||
spec=spec,
|
||||
steps=steps,
|
||||
goal_query=goal_query,
|
||||
brief=semantic_brief,
|
||||
proposal=None,
|
||||
roadmap_snapshot=_roadmap_gap_snapshot_for_spec(
|
||||
cur,
|
||||
roadmap_ctx,
|
||||
spec,
|
||||
goal_query=goal_query,
|
||||
semantic_brief=semantic_brief,
|
||||
),
|
||||
)
|
||||
step["gap_offer"] = offer
|
||||
step["proposal_key"] = offer.get("offer_id")
|
||||
step["slot_status"] = "unfilled"
|
||||
if offer.get("offer_id") and offer.get("offer_id") not in seen_offer_ids:
|
||||
offers.append(offer)
|
||||
seen_offer_ids.add(offer.get("offer_id"))
|
||||
out_steps.append(step)
|
||||
|
||||
return out_steps, offers
|
||||
|
||||
|
||||
def _merge_rematch_unfilled(
|
||||
roadmap_unfilled: List[Tuple[int, StageSpecArtifact]],
|
||||
rematch_new_unfilled: List[Tuple[int, StageSpecArtifact]],
|
||||
@@ -2269,7 +2381,7 @@ def suggest_progression_path(
|
||||
elif gaps and roadmap_first:
|
||||
unfilled_gaps = list(gaps)
|
||||
|
||||
if body.include_llm_path_qa:
|
||||
if body.include_llm_path_qa and not roadmap_first:
|
||||
llm_qa, llm_qa_applied = try_llm_qa_progression_path(
|
||||
cur,
|
||||
goal_query=goal_query,
|
||||
@@ -2348,6 +2460,22 @@ def suggest_progression_path(
|
||||
roadmap_first=roadmap_first,
|
||||
)
|
||||
|
||||
if body.include_llm_path_qa and roadmap_first:
|
||||
gaps = detect_path_gaps(
|
||||
cur,
|
||||
steps,
|
||||
brief=semantic_brief,
|
||||
roadmap_first=roadmap_first,
|
||||
)
|
||||
llm_qa, llm_qa_applied = try_llm_qa_progression_path(
|
||||
cur,
|
||||
goal_query=goal_query,
|
||||
brief=semantic_brief,
|
||||
steps=steps,
|
||||
gaps=gaps,
|
||||
bridge_inserts=bridge_inserts,
|
||||
)
|
||||
|
||||
llm_gap_specs = parse_llm_suggested_new_exercises(
|
||||
llm_qa,
|
||||
brief=semantic_brief,
|
||||
@@ -2397,6 +2525,22 @@ def suggest_progression_path(
|
||||
if offer.get("offer_id") not in seen_offer_ids:
|
||||
gap_fill_offers.append(offer)
|
||||
|
||||
if roadmap_first and roadmap_ctx is not None:
|
||||
steps = _normalize_roadmap_steps_coverage(
|
||||
steps,
|
||||
roadmap_ctx=roadmap_ctx,
|
||||
max_steps=max_steps,
|
||||
)
|
||||
steps, gap_fill_offers = _enrich_roadmap_unfilled_gap_offers(
|
||||
cur,
|
||||
steps=steps,
|
||||
gap_fill_offers=gap_fill_offers,
|
||||
body=body,
|
||||
roadmap_ctx=roadmap_ctx,
|
||||
goal_query=goal_query,
|
||||
semantic_brief=semantic_brief,
|
||||
)
|
||||
|
||||
multistage_qa = run_multistage_path_qa(
|
||||
off_topic_steps=off_topic_steps,
|
||||
stripped_off_topic=stripped_off_topic,
|
||||
@@ -2428,71 +2572,6 @@ def suggest_progression_path(
|
||||
path_qa["refine_log"] = refine_log
|
||||
path_qa["refine_count"] = len(refine_log)
|
||||
|
||||
if roadmap_first and roadmap_ctx is not None:
|
||||
steps = _normalize_roadmap_steps_coverage(
|
||||
steps,
|
||||
roadmap_ctx=roadmap_ctx,
|
||||
max_steps=max_steps,
|
||||
)
|
||||
if body.include_ai_gap_fill:
|
||||
seen_offer_ids = {o.get("offer_id") for o in gap_fill_offers if o.get("offer_id")}
|
||||
for step in steps:
|
||||
if step.get("exercise_id") is not None:
|
||||
continue
|
||||
try:
|
||||
major_idx = int(step["roadmap_major_step_index"])
|
||||
except (TypeError, ValueError, KeyError):
|
||||
continue
|
||||
if step.get("gap_offer") and step.get("proposal_key"):
|
||||
oid = step["gap_offer"].get("offer_id")
|
||||
if oid and oid not in seen_offer_ids:
|
||||
gap_fill_offers.append(dict(step["gap_offer"]))
|
||||
seen_offer_ids.add(oid)
|
||||
continue
|
||||
stage_spec = next(
|
||||
(
|
||||
s
|
||||
for s in (roadmap_ctx.stage_specs or [])
|
||||
if int(s.major_step_index) == major_idx
|
||||
),
|
||||
None,
|
||||
)
|
||||
learning_goal = (
|
||||
(stage_spec.learning_goal if stage_spec else None)
|
||||
or step.get("roadmap_learning_goal")
|
||||
or step.get("title")
|
||||
or ""
|
||||
).strip()
|
||||
spec = {
|
||||
"source": "roadmap_unfilled",
|
||||
"insert_after_index": max(major_idx - 1, -1),
|
||||
"roadmap_major_step_index": major_idx,
|
||||
"phase": (step.get("roadmap_phase") or "vertiefung").strip().lower(),
|
||||
"title_hint": (learning_goal or f"Slot {major_idx + 1}")[:120],
|
||||
"sketch": learning_goal,
|
||||
"rationale": f"Slot {major_idx + 1} — keine passende Bibliotheks-Übung; KI-Entwurf für diese Stufe.",
|
||||
}
|
||||
offer = build_gap_fill_offer(
|
||||
spec=spec,
|
||||
steps=steps,
|
||||
goal_query=goal_query,
|
||||
brief=semantic_brief,
|
||||
proposal=None,
|
||||
roadmap_snapshot=_roadmap_gap_snapshot_for_spec(
|
||||
cur,
|
||||
roadmap_ctx,
|
||||
spec,
|
||||
goal_query=goal_query,
|
||||
semantic_brief=semantic_brief,
|
||||
),
|
||||
)
|
||||
step["gap_offer"] = offer
|
||||
step["proposal_key"] = offer.get("offer_id")
|
||||
step["slot_status"] = "unfilled"
|
||||
if offer.get("offer_id") and offer.get("offer_id") not in seen_offer_ids:
|
||||
gap_fill_offers.append(offer)
|
||||
seen_offer_ids.add(offer.get("offer_id"))
|
||||
|
||||
filled_library_steps = sum(1 for s in steps if s.get("exercise_id") is not None)
|
||||
match_summary = {
|
||||
"roadmap_first": roadmap_first,
|
||||
|
||||
Reference in new issue
Block a user