Enhance Progression Path Comparison and Slot Evaluation Features
Deploy Development / deploy (push) Successful in 43s
Test Suite / pytest-backend (push) Successful in 44s
Test Suite / lint-backend (push) Successful in 0s
Test Suite / build-frontend (push) Successful in 14s
Test Suite / k6 /health Baseline (push) Successful in 33s
Test Suite / playwright-tests (push) Successful in 1m12s
Deploy Development / deploy (push) Successful in 43s
Test Suite / pytest-backend (push) Successful in 44s
Test Suite / lint-backend (push) Successful in 0s
Test Suite / build-frontend (push) Successful in 14s
Test Suite / k6 /health Baseline (push) Successful in 33s
Test Suite / playwright-tests (push) Successful in 1m12s
- Introduced new fields in `ProgressionPathSuggestRequest` for baseline evaluation and incremental scoring, improving the assessment of proposed paths. - Implemented `_apply_slot_diff_to_steps` and `_score_incremental_slot_diffs` functions to manage slot differences and evaluate their impact on quality scores. - Updated `ProgressionGraphEditor` to streamline the match comparison flow, integrating new evaluation parameters and improving user notifications. - Enhanced `ProgressionOptimizeCompareModal` to better display proposed path suggestions, including pro/con evaluations and quality delta metrics. - Refactored utility functions for clearer handling of slot differences and improved overall data management in the progression graph editor.
This commit is contained in:
1 parent
19bbcdaf50
commit
85fccdd093
5 files changed
+1098
-282
No files matched your search
@@ -997,6 +997,12 @@ export function compareDiffKind(diff) {
|
||||
return 'skip'
|
||||
}
|
||||
|
||||
export function qualityDeltaPercent(diff) {
|
||||
const delta = diff?.quality_delta
|
||||
if (delta == null || !Number.isFinite(Number(delta))) return null
|
||||
return Math.round(Number(delta) * 100)
|
||||
}
|
||||
|
||||
export function annotateCompareDiffKinds(diffs) {
|
||||
return (diffs || []).map((d) => ({
|
||||
...d,
|
||||
@@ -1004,20 +1010,57 @@ export function annotateCompareDiffKinds(diffs) {
|
||||
}))
|
||||
}
|
||||
|
||||
/** Nur übernehmbare Bibliotheks-Diffs (kein reines Titel-/Gap-Geplänkel). */
|
||||
/** Nur übernehmbare Verbesserungsvorschläge (Bibliothek oder KI-Angebot). */
|
||||
export function compareDiffsForDialog(comparison) {
|
||||
const fromSuggestions = (comparison?.slot_suggestions || []).filter((s) => s?.improves_path)
|
||||
if (fromSuggestions.length > 0) {
|
||||
return fromSuggestions
|
||||
.map((s) => ({ ...s, diff_kind: suggestionDiffKind(s) }))
|
||||
.filter(
|
||||
(d) =>
|
||||
d.proposed_exercise_id != null
|
||||
|| (d.suggestion_type === 'ai_gap' && d.gap_offer),
|
||||
)
|
||||
}
|
||||
if (Array.isArray(comparison?.slot_diffs_improving)) {
|
||||
return comparison.slot_diffs_improving.filter(
|
||||
(d) => d?.proposed_exercise_id != null && !d?.trivial_id_swap,
|
||||
)
|
||||
}
|
||||
const diffs = annotateCompareDiffKinds(
|
||||
compareSlotDiffs(comparison, { actionableOnly: true }),
|
||||
)
|
||||
return diffs.filter((d) => d.diff_kind === 'fill' || d.diff_kind === 'replace')
|
||||
return diffs.filter(
|
||||
(d) =>
|
||||
(d.diff_kind === 'fill' || d.diff_kind === 'replace')
|
||||
&& d.proposed_exercise_id != null,
|
||||
)
|
||||
}
|
||||
|
||||
export function suggestionDiffKind(suggestion) {
|
||||
if (!suggestion) return 'skip'
|
||||
if (suggestion.suggestion_type === 'ai_gap') return 'ai_gap'
|
||||
if (suggestion.baseline_exercise_id == null && suggestion.proposed_exercise_id != null) {
|
||||
return 'fill'
|
||||
}
|
||||
if (suggestion.baseline_exercise_id != null && suggestion.proposed_exercise_id != null) {
|
||||
return 'replace'
|
||||
}
|
||||
return 'skip'
|
||||
}
|
||||
|
||||
export function recommendedCompareDiffs(comparison) {
|
||||
return compareDiffsForDialog(comparison).filter((d) => d.diff_kind === 'fill')
|
||||
return compareDiffsForDialog(comparison)
|
||||
}
|
||||
|
||||
export function optionalReplaceCompareDiffs(comparison) {
|
||||
return compareDiffsForDialog(comparison).filter((d) => d.diff_kind === 'replace')
|
||||
return []
|
||||
}
|
||||
|
||||
export function rejectedCompareDiffs(comparison) {
|
||||
return Array.isArray(comparison?.slot_diffs_rejected)
|
||||
? comparison.slot_diffs_rejected
|
||||
: []
|
||||
}
|
||||
|
||||
export function gapOnlyCompareDiffs(comparison) {
|
||||
@@ -1027,7 +1070,7 @@ export function gapOnlyCompareDiffs(comparison) {
|
||||
}
|
||||
|
||||
export function defaultSelectedCompareDiffs(comparison) {
|
||||
return recommendedCompareDiffs(comparison).map((d) => Number(d.roadmap_major_step_index))
|
||||
return compareDiffsForDialog(comparison).map((d) => Number(d.roadmap_major_step_index))
|
||||
}
|
||||
|
||||
function mergeGapFillOffersFromSteps(steps, offers) {
|
||||
@@ -1044,29 +1087,43 @@ function mergeGapFillOffersFromSteps(steps, offers) {
|
||||
}
|
||||
|
||||
/**
|
||||
* Vergleich aus zwei kaskadierten Antworten (Evaluate → Match) — spiegelt Backend-Compare.
|
||||
* Vergleich aus unified_slot_review oder kaskadierten Antworten (Evaluate → Match).
|
||||
*/
|
||||
export function buildProgressionComparePayload(baselineRes, proposedRes) {
|
||||
if (proposedRes?.unified_slot_review) {
|
||||
return buildUnifiedSlotReviewComparePayload(proposedRes)
|
||||
}
|
||||
|
||||
const baselineSteps = Array.isArray(baselineRes?.steps) ? baselineRes.steps : []
|
||||
const proposedSteps = Array.isArray(proposedRes?.steps) ? proposedRes.steps : []
|
||||
const baselineQa = baselineRes?.path_qa || null
|
||||
const pipelineQa = proposedRes?.path_qa || null
|
||||
const slotDiffs = annotateCompareDiffKinds(
|
||||
const scoring = proposedRes?.slot_diff_scoring
|
||||
const rawDiffs = annotateCompareDiffKinds(
|
||||
annotateCompareSlotDiffs(
|
||||
buildProgressionSlotDiffs(baselineSteps, proposedSteps),
|
||||
),
|
||||
)
|
||||
const actionableDiffs = actionableCompareSlotDiffs(slotDiffs)
|
||||
const dialogDiffs = actionableDiffs.filter(
|
||||
(d) => d.diff_kind === 'fill' || d.diff_kind === 'replace',
|
||||
const improvingDiffs = annotateCompareDiffKinds(
|
||||
(scoring?.improvement_diffs || []).filter((d) => d?.proposed_exercise_id != null),
|
||||
)
|
||||
const recommendedDiffs = dialogDiffs.filter((d) => d.diff_kind === 'fill')
|
||||
const rejectedDiffs = annotateCompareDiffKinds(scoring?.rejected_diffs || [])
|
||||
const dialogDiffs = improvingDiffs.length > 0
|
||||
? improvingDiffs
|
||||
: rawDiffs.filter(
|
||||
(d) =>
|
||||
!d.trivial_id_swap
|
||||
&& (d.diff_kind === 'fill' || d.diff_kind === 'replace')
|
||||
&& d.proposed_exercise_id != null
|
||||
&& d.improves_path !== false,
|
||||
)
|
||||
const actionableDiffs = dialogDiffs
|
||||
const gapFillOffers = mergeGapFillOffersFromSteps(
|
||||
proposedSteps,
|
||||
proposedRes?.gap_fill_offers || [],
|
||||
)
|
||||
const proposedQa =
|
||||
actionableDiffs.length === 0 && baselineQa ? baselineQa : pipelineQa
|
||||
const baselineScore = scoring?.baseline_quality_score ?? baselineQa?.quality_score
|
||||
const proposedQa = baselineQa
|
||||
|
||||
return {
|
||||
...proposedRes,
|
||||
@@ -1078,19 +1135,110 @@ export function buildProgressionComparePayload(baselineRes, proposedRes) {
|
||||
proposed_path_qa: proposedQa,
|
||||
proposed_path_qa_pipeline: pipelineQa,
|
||||
gap_fill_offers: gapFillOffers,
|
||||
slot_diffs: slotDiffs,
|
||||
slot_diffs: rawDiffs,
|
||||
slot_diffs_actionable: actionableDiffs,
|
||||
slot_diffs_improving: improvingDiffs,
|
||||
slot_diffs_rejected: rejectedDiffs,
|
||||
slot_diffs_dialog: dialogDiffs,
|
||||
slot_diffs_recommended: recommendedDiffs,
|
||||
slot_diffs_recommended: dialogDiffs,
|
||||
slot_diff_count: dialogDiffs.length,
|
||||
slot_diff_count_recommended: recommendedDiffs.length,
|
||||
slot_diff_count_including_trivial: slotDiffs.length,
|
||||
slot_diffs_source: 'steps',
|
||||
slot_diff_count_recommended: dialogDiffs.length,
|
||||
slot_diff_count_rejected: rejectedDiffs.length,
|
||||
slot_diff_count_including_trivial: rawDiffs.length,
|
||||
slot_diffs_source: scoring ? 'incremental_scoring' : 'steps',
|
||||
slot_diff_scoring: scoring,
|
||||
baseline_quality_score: baselineScore,
|
||||
path_qa: proposedQa,
|
||||
steps: proposedSteps,
|
||||
}
|
||||
}
|
||||
|
||||
/** Einheitlicher Match-Review (Bewertung + Slot-Vorschläge in einem Lauf). */
|
||||
export function buildUnifiedSlotReviewComparePayload(res) {
|
||||
const baselineSteps = Array.isArray(res?.baseline_steps) ? res.baseline_steps : (res?.steps || [])
|
||||
const baselineQa = res?.baseline_path_qa || res?.path_qa || null
|
||||
const scoring = res?.slot_diff_scoring
|
||||
const suggestions = Array.isArray(res?.slot_suggestions) ? res.slot_suggestions : []
|
||||
const improving = suggestions.filter((s) => s?.improves_path)
|
||||
const rejected = Array.isArray(scoring?.rejected_diffs) ? scoring.rejected_diffs : []
|
||||
const proposedSteps = improving.map(suggestionToApplyStep).filter(Boolean)
|
||||
const gapFillOffers = Array.isArray(res?.gap_fill_offers) ? res.gap_fill_offers : []
|
||||
|
||||
return {
|
||||
...res,
|
||||
comparison_mode: true,
|
||||
unified_slot_review: true,
|
||||
baseline_steps: baselineSteps,
|
||||
baseline_path_qa: baselineQa,
|
||||
proposed_steps: proposedSteps,
|
||||
proposed_steps_pipeline: proposedSteps,
|
||||
proposed_path_qa: baselineQa,
|
||||
proposed_path_qa_pipeline: null,
|
||||
gap_fill_offers: gapFillOffers,
|
||||
slot_suggestions: suggestions,
|
||||
slot_diffs: improving,
|
||||
slot_diffs_improving: improving,
|
||||
slot_diffs_rejected: rejected,
|
||||
slot_diffs_dialog: improving,
|
||||
slot_diffs_recommended: improving,
|
||||
slot_diff_count: improving.length,
|
||||
slot_diff_count_recommended: improving.length,
|
||||
slot_diff_count_rejected: rejected.length,
|
||||
slot_diffs_source: 'unified_slot_review',
|
||||
slot_diff_scoring: scoring,
|
||||
baseline_quality_score: scoring?.baseline_quality_score ?? baselineQa?.quality_score,
|
||||
path_qa: baselineQa,
|
||||
steps: baselineSteps,
|
||||
}
|
||||
}
|
||||
|
||||
function suggestionToApplyStep(suggestion) {
|
||||
if (!suggestion || suggestion.roadmap_major_step_index == null) return null
|
||||
const midx = Number(suggestion.roadmap_major_step_index)
|
||||
if (suggestion.suggestion_type === 'ai_gap' && suggestion.gap_offer) {
|
||||
const offer = suggestion.gap_offer
|
||||
return {
|
||||
roadmap_major_step_index: midx,
|
||||
exercise_id: null,
|
||||
title: offer.title_hint || suggestion.proposed_title || `Slot ${midx + 1}`,
|
||||
is_ai_proposal: true,
|
||||
proposal_key: offer.offer_id || `roadmap-unfilled-${midx}`,
|
||||
gap_offer: offer,
|
||||
slot_status: 'ai_proposal',
|
||||
}
|
||||
}
|
||||
if (suggestion.proposed_exercise_id == null) return null
|
||||
return {
|
||||
roadmap_major_step_index: midx,
|
||||
exercise_id: suggestion.proposed_exercise_id,
|
||||
title: suggestion.proposed_title,
|
||||
slot_status: suggestion.proposed_slot_status || 'matched',
|
||||
is_ai_proposal: false,
|
||||
}
|
||||
}
|
||||
|
||||
/** Ausgewählte Slot-Vorschläge aus unified review übernehmen. */
|
||||
export function applySelectedSlotSuggestions(draft, comparison, selectedMajorIndices) {
|
||||
const selected = new Set(
|
||||
(selectedMajorIndices || [])
|
||||
.map((x) => Number(x))
|
||||
.filter((x) => Number.isFinite(x)),
|
||||
)
|
||||
if (!selected.size) return draft
|
||||
const steps = (comparison?.slot_suggestions || [])
|
||||
.filter((s) => selected.has(Number(s.roadmap_major_step_index)))
|
||||
.map(suggestionToApplyStep)
|
||||
.filter(Boolean)
|
||||
if (!steps.length) {
|
||||
return applySelectedCompareSteps(
|
||||
draft,
|
||||
comparison?.proposed_steps || comparison?.steps,
|
||||
selectedMajorIndices,
|
||||
)
|
||||
}
|
||||
return applyMatchStepsToSlots(draft, steps)
|
||||
}
|
||||
|
||||
/** Alle Slot-Diffs inkl. reiner ID-Tausche (gleicher Titel). */
|
||||
export function compareSlotDiffs(comparison, { actionableOnly = false } = {}) {
|
||||
if (actionableOnly && Array.isArray(comparison?.slot_diffs_actionable)) {
|
||||
|
||||
Reference in new issue
Block a user