Enhance Gap Fill and Rematch Logic in Progression Path
Deploy Development / deploy (push) Successful in 40s
Test Suite / pytest-backend (push) Successful in 47s
Test Suite / lint-backend (push) Successful in 1s
Test Suite / build-frontend (push) Successful in 14s
Test Suite / k6 /health Baseline (push) Successful in 39s
Test Suite / playwright-tests (push) Successful in 1m22s
Deploy Development / deploy (push) Successful in 40s
Test Suite / pytest-backend (push) Successful in 47s
Test Suite / lint-backend (push) Successful in 1s
Test Suite / build-frontend (push) Successful in 14s
Test Suite / k6 /health Baseline (push) Successful in 39s
Test Suite / playwright-tests (push) Successful in 1m22s
- Introduced `_step_neighbors_at_index` to safely retrieve neighboring steps without causing IndexErrors, improving robustness in gap fill specifications. - Updated `collect_gap_fill_specs` to utilize the new neighbor retrieval function, ensuring safe access to adjacent steps during gap fill processing. - Enhanced rematch logic in `_run_roadmap_rematch_loop` to incorporate `max_rematch_rounds`, allowing for controlled iterations during roadmap rematching. - Improved handling of unfilled roadmap slots in `collect_rematch_slot_indices`, ensuring accurate identification of gaps in the progression path. - Added tests to validate the new gap fill handling and rematch logic, ensuring reliability in path suggestion features.
This commit is contained in:
1 parent
de939481ba
commit
df93da9a03
6 files changed
+217
-53
No files matched your search
@@ -337,6 +337,18 @@ def _spec_dedupe_key(spec: Mapping[str, Any]) -> Tuple[Any, ...]:
|
||||
)
|
||||
|
||||
|
||||
def _step_neighbors_at_index(
|
||||
steps: Sequence[Mapping[str, Any]],
|
||||
idx: int,
|
||||
) -> Tuple[Optional[Mapping[str, Any]], Optional[Mapping[str, Any]]]:
|
||||
"""Vorheriger/nächster Pfadschritt ohne IndexError (Rand-Slots, leere Stufen)."""
|
||||
if idx < 0 or idx >= len(steps):
|
||||
return None, None
|
||||
step_a = steps[idx - 1] if idx > 0 else None
|
||||
step_b = steps[idx + 1] if idx + 1 < len(steps) else None
|
||||
return step_a, step_b
|
||||
|
||||
|
||||
def collect_gap_fill_specs(
|
||||
*,
|
||||
steps: Sequence[Mapping[str, Any]],
|
||||
@@ -364,8 +376,10 @@ def collect_gap_fill_specs(
|
||||
int(gap["from_exercise_id"]),
|
||||
int(gap["to_exercise_id"]),
|
||||
)
|
||||
if idx is None:
|
||||
if idx is None or idx + 1 >= len(steps):
|
||||
continue
|
||||
step_a = steps[idx]
|
||||
step_b = steps[idx + 1]
|
||||
phase = gap.get("expected_phase") or "vertiefung"
|
||||
add(
|
||||
{
|
||||
@@ -377,12 +391,12 @@ def collect_gap_fill_specs(
|
||||
"sketch": _default_sketch(
|
||||
goal_query=goal_query,
|
||||
brief=brief,
|
||||
step_a=steps[idx],
|
||||
step_b=steps[idx + 1],
|
||||
step_a=step_a,
|
||||
step_b=step_b,
|
||||
phase=str(phase),
|
||||
rationale="Bibliothek enthält keine passende Brücke.",
|
||||
),
|
||||
"rationale": "Lücke zwischen benachbarten Schritten — keine passende Bibliotheks-Übung.",
|
||||
"rationale": "Lücke zwischen benachbaren Schritten — keine passende Bibliotheks-Übung.",
|
||||
}
|
||||
)
|
||||
|
||||
@@ -408,6 +422,7 @@ def collect_gap_fill_specs(
|
||||
idx = int(ot.get("step_index") or 0)
|
||||
if idx < 0 or idx >= len(steps):
|
||||
continue
|
||||
step_a, step_b = _step_neighbors_at_index(steps, idx)
|
||||
phase = ot.get("expected_phase") or "vertiefung"
|
||||
insert_after = max(idx - 1, -1)
|
||||
add(
|
||||
@@ -426,8 +441,8 @@ def collect_gap_fill_specs(
|
||||
"sketch": _default_sketch(
|
||||
goal_query=goal_query,
|
||||
brief=brief,
|
||||
step_a=steps[idx - 1],
|
||||
step_b=steps[idx + 1],
|
||||
step_a=step_a,
|
||||
step_b=step_b,
|
||||
phase=str(phase),
|
||||
rationale=f"Ersetzt themenfremden Schritt „{ot.get('title')}“.",
|
||||
),
|
||||
|
||||
Reference in new issue
Block a user