Enhance Slot Difference Annotation and Rematch Suggestion Logic
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 34s
Test Suite / playwright-tests (push) Successful in 1m13s

- Introduced `_annotate_slot_diffs` to mark trivial ID swaps in slot differences, improving clarity in comparison results.
- Added `_actionable_slot_diffs` to filter out non-actionable differences, streamlining the evaluation process.
- Implemented `_build_rematch_suggestion_diffs` to generate suggestions based on rematch logs, enhancing the path optimization workflow.
- Updated `_build_progression_compare_response` to incorporate actionable slot differences and rematch suggestions, improving the response structure.
- Enhanced frontend components to display rematch suggestions and handle trivial differences more effectively.
- Bumped version to reflect the new features and improvements.
This commit is contained in:
Lars committed 2026-06-13 07:55:47 +02:00
1 parent e828a5da32
commit dccb065181
11 files changed
+552 -84

No files matched your search

@@ -26,7 +26,7 @@ function severityStyle(pathQa) {
}
}
function PathQaPipelineDetails({ pathQa, draft, title, compact = false }) {
function PathQaPipelineDetails({ pathQa, fairQa = null, draft, title, compact = false }) {
const { fixHints: optimizationHints } = useMemo(
() => splitPathQaHints(pathQa),
[pathQa],
@@ -34,7 +34,7 @@ function PathQaPipelineDetails({ pathQa, draft, title, compact = false }) {
const rematchLog = Array.isArray(pathQa?.rematch_log) ? pathQa.rematch_log : []
const refineLog = Array.isArray(pathQa?.refine_log) ? pathQa.refine_log : []
const qaTiers = Array.isArray(pathQa?.qa_tiers) ? pathQa.qa_tiers : []
const qualityPct = pathQaQualityPercent(pathQa)
const qualityPct = pathQaQualityPercent(fairQa || pathQa)
const hasContent =
qaTiers.length > 0
|| (pathQa?.rematch_applied && rematchLog.length > 0)
@@ -53,10 +53,17 @@ function PathQaPipelineDetails({ pathQa, draft, title, compact = false }) {
background: 'color-mix(in srgb, var(--accent) 6%, var(--surface2))',
}}
>
<strong style={{ fontSize: compact ? '11px' : '12px' }}>
<strong style={{ fontSize: compact ? '11px' : '12px' }}>
{title}
{qualityPct != null ? ` · ${pathQa.overall_ok ? 'OK' : 'Hinweise'} (${qualityPct} %)` : ''}
{qualityPct != null
? ` · ${(fairQa || pathQa)?.overall_ok ? 'OK' : 'Hinweise'} (${qualityPct} % fair bewertet)`
: ''}
</strong>
{fairQa && pathQa && pathQaQualityPercent(pathQa) !== qualityPct ? (
<p style={{ margin: '4px 0 0', fontSize: '10px', color: 'var(--text3)' }}>
Rematch-Protokoll (Pipeline-Score {pathQaQualityPercent(pathQa) ?? '—'} %) — nur Prozessinfo, nicht Pfad-QS.
</p>
) : null}
{qaTiers.length > 0 ? (
<ul style={{ margin: '6px 0 0', paddingLeft: '16px', color: 'var(--text2)', fontSize: '11px' }}>
{qaTiers.map((tier) => (
@@ -282,6 +289,7 @@ export default function ProgressionFindingsPanel({
onRematchSlots = null,
onOptimizeCompare = null,
optimizationPreviewQa = null,
optimizationPreviewFairQa = null,
canOptimizeCompare = false,
optimizeCompareBusy = false,
rematchBusy = false,
@@ -509,8 +517,9 @@ export default function ProgressionFindingsPanel({
{optimizationPreviewQa ? (
<PathQaPipelineDetails
pathQa={optimizationPreviewQa}
fairQa={optimizationPreviewFairQa}
draft={draft}
title="3-Stufen-Optimierung (Vorschlag nach Match)"
title="3-Stufen-Optimierung (Vorschlag — nur im Vergleichsdialog)"
compact
/>
) : null}
@@ -29,9 +29,9 @@ import {
applyGapOfferToDraft,
applyMatchResponseToDraft,
applySelectedCompareSteps,
compareResponseHasCuratedSlotChanges,
compareResponseHasSlotChanges,
curatedSlotDiffs,
compareResponseHasActionableSlotChanges,
compareResponseHadRematchWithoutActionableDiffs,
compareSlotDiffs,
pathQaQualityPercent,
applyResolvedStructuredToDraft,
buildPlanningArtifactFromDraft,
@@ -505,36 +505,38 @@ export default function ProgressionGraphEditor({ graphId, embedded = false, onSa
setTargetSummary(res?.target_profile_summary || null)
const baselineQa = res?.baseline_path_qa || null
const proposedQa = res?.proposed_path_qa || res?.path_qa || null
const pipelineQa = res?.proposed_path_qa_pipeline || null
setPathQa(baselineQa)
setProposedPathQa(pipelineQa)
const actionableCount =
res?.slot_diff_count ?? compareSlotDiffs(res, { actionableOnly: true }).length
const openCompareDialog = (diffCount, noticePrefix) => {
setComparePayload(res)
setProposedPathQa(res?.proposed_path_qa_pipeline || null)
setCompareOpen(true)
const bPct = pathQaQualityPercent(baselineQa)
const pPct = pathQaQualityPercent(proposedQa)
let notice = `${noticePrefix}${diffCount} Slot-Anpassung(en) — Vergleichsdialog geöffnet.`
let notice = diffCount > 0
? `${noticePrefix}${diffCount} Slot-Anpassung(en) — Vergleichsdialog geöffnet.`
: 'Vergleichsdialog geöffnet — keine übernehmbaren Slot-Änderungen im End-Pfad.'
if (bPct != null && pPct != null && pPct !== bPct) {
notice += ` QS ${bPct} % → ${pPct} %.`
notice += ` Vorschlag fair bewertet: ${bPct} % → ${pPct} %.`
}
setMatchNotice(notice)
}
if (source === 'match') {
if (compareResponseHasCuratedSlotChanges(res)) {
openCompareDialog(curatedSlotDiffs(res).length, 'KI schlägt ')
if (compareResponseHasActionableSlotChanges(res)) {
openCompareDialog(actionableCount, 'KI schlägt ')
return { opened: true, res }
}
setProposedPathQa(null)
setComparePayload(null)
return { opened: false, res }
}
setComparePayload(res)
setCompareOpen(true)
if (compareResponseHasSlotChanges(res)) {
const diffCount = res.slot_diff_count ?? res.slot_diffs?.length ?? 0
openCompareDialog(diffCount, 'KI schlägt ')
}
openCompareDialog(
actionableCount,
compareResponseHasActionableSlotChanges(res) ? 'KI schlägt ' : '',
)
return { opened: true, res }
}
@@ -565,31 +567,25 @@ export default function ProgressionGraphEditor({ graphId, embedded = false, onSa
return
}
const { draft: matched, remainingOffers } = applyMatchResponseToDraft(
{
...synced,
progressionRoadmap: compareRes?.progression_roadmap || synced.progressionRoadmap,
pathSkillExpectations:
compareRes?.path_skill_expectations || synced.pathSkillExpectations,
},
compareRes,
)
const syncedMatched = syncProgressionRoadmapFromSlots(matched)
const evalRes = await fetchPathEvaluate(syncedMatched)
const { draft: evaluated, remainingOffers: evalOffers } = applyEvaluateResult(
syncedMatched,
evalRes,
)
const evalRes = await fetchPathEvaluate(synced)
const { draft: evaluated, remainingOffers } = applyEvaluateResult(synced, evalRes)
setDraft(evaluated)
setGapFillOffers(evalOffers.length ? evalOffers : remainingOffers)
setGapFillOffers(remainingOffers)
setProposedPathQa(null)
setComparePayload(null)
const evalPct = pathQaQualityPercent(evalRes?.path_qa)
const ms = compareRes?.match_summary
if (ms) {
let notice = `Match: ${ms.library_matches ?? 0}/${ms.slot_count ?? '?'} Slots aus Bibliothek, ${ms.gap_fill_offer_count ?? 0} KI-Angebote.`
if (evalPct != null) {
notice += ` Pfad-QS (Bewertung): ${evalPct} %.`
}
setMatchNotice(notice)
if (compareResponseHadRematchWithoutActionableDiffs(compareRes)) {
setMatchNotice(
`Match: Auto-Rematch ohne übernehmbare End-Änderung — dein Pfad bleibt unverändert${
evalPct != null ? ` (Pfad-QS ${evalPct} %).` : '.'
}`,
)
} else {
setMatchNotice(
`Match: Kein inhaltlicher Optimierungsvorschlag — Pfad unverändert${
evalPct != null ? ` (${evalPct} %).` : '.'
}`,
)
}
try {
await saveProgressionGraphDraft(api, graphId, {
@@ -1221,7 +1217,8 @@ export default function ProgressionGraphEditor({ graphId, embedded = false, onSa
onGenerateGapAi={openGapFillPrep}
onRematchSlots={runMatch}
onOptimizeCompare={runOptimizeCompare}
optimizationPreviewQa={proposedPathQa}
optimizationPreviewQa={compareOpen ? proposedPathQa : null}
optimizationPreviewFairQa={compareOpen ? comparePayload?.proposed_path_qa : null}
canOptimizeCompare={draftHasLibrarySlotAssignments(draft)}
optimizeCompareBusy={comparing}
rematchBusy={matching}
@@ -2,7 +2,7 @@
* Gegenüberstellung: bestehender Pfad vs. optimierter Match-Vorschlag.
*/
import React, { useMemo, useState } from 'react'
import { pathQaQualityPercent } from '../utils/progressionGraphDraft'
import { compareSlotDiffs, pathQaQualityPercent } from '../utils/progressionGraphDraft'
function qaLabel(pathQa) {
const pct = pathQaQualityPercent(pathQa)
@@ -18,7 +18,8 @@ export default function ProgressionOptimizeCompareModal({
onApplySelected,
applying = false,
}) {
const slotDiffs = Array.isArray(comparison?.slot_diffs) ? comparison.slot_diffs : []
const slotDiffs = compareSlotDiffs(comparison, { actionableOnly: true })
const trivialDiffs = (comparison?.slot_diffs || []).filter((d) => d?.trivial_id_swap)
const [selected, setSelected] = useState(() => new Set())
const allKeys = useMemo(
@@ -176,6 +177,19 @@ export default function ProgressionOptimizeCompareModal({
</p>
) : null}
{comparison?.slot_diffs_source === 'rematch_log' ? (
<p style={{ fontSize: '11px', color: 'var(--text3)', margin: '0 0 14px', lineHeight: 1.45 }}>
Vorschläge stammen aus dem Auto-Rematch-Protokoll (letzte Runde je Slot), weil der sichtbare
End-Pfad deinem aktuellen Stand entspricht.
</p>
) : null}
{trivialDiffs.length > 0 ? (
<p style={{ fontSize: '11px', color: 'var(--text3)', margin: '0 0 14px', lineHeight: 1.45 }}>
{trivialDiffs.length} reine ID-Tausche (gleicher Titel) — nicht übernehmbar, daher nicht gelistet.
</p>
) : null}
{slotDiffs.length === 0 ? (
<p style={{ fontSize: '12px', color: 'var(--text2)' }}>
Keine inhaltlichen Abweichungen — der End-Stand entspricht deinem Pfad.
+30 -10
View File
@@ -911,16 +911,37 @@ export function draftHasLibrarySlotAssignments(draft) {
return slotsToSlotAssignments(draft).length >= 1
}
/** Diff-Einträge nur für Slots, die vorher schon eine Bibliotheks-Übung hatten. */
export function curatedSlotDiffs(comparison) {
const diffs = comparison?.slot_diffs
if (!Array.isArray(diffs)) return []
return diffs.filter((d) => d?.baseline_exercise_id != null)
/** Alle Slot-Diffs inkl. reiner ID-Tausche (gleicher Titel). */
export function compareSlotDiffs(comparison, { actionableOnly = false } = {}) {
if (actionableOnly && Array.isArray(comparison?.slot_diffs_actionable)) {
return comparison.slot_diffs_actionable
}
return Array.isArray(comparison?.slot_diffs) ? comparison.slot_diffs : []
}
/** Vergleich würde eine bestehende Zuordnung ändern (Dialog bei Match). */
/** Inhaltliche Abweichungen (nicht nur gleicher Titel, andere ID). */
export function compareResponseHasActionableSlotChanges(res) {
const count = res?.slot_diff_count
if (count != null) return Number(count) > 0
return compareSlotDiffs(res, { actionableOnly: true }).length > 0
}
/** Diff-Einträge nur für Slots, die vorher schon eine Bibliotheks-Übung hatten. */
export function curatedSlotDiffs(comparison, { actionableOnly = true } = {}) {
return compareSlotDiffs(comparison, { actionableOnly }).filter(
(d) => d?.baseline_exercise_id != null,
)
}
/** Vergleich würde eine bestehende Zuordnung inhaltlich ändern (Dialog bei Match). */
export function compareResponseHasCuratedSlotChanges(res) {
return curatedSlotDiffs(res).length > 0
return curatedSlotDiffs(res, { actionableOnly: true }).length > 0
}
export function compareResponseHadRematchWithoutActionableDiffs(res) {
if (compareResponseHasActionableSlotChanges(res)) return false
const rematch = res?.proposed_path_qa_pipeline?.rematch_log
return Array.isArray(rematch) && rematch.length > 0
}
/** Alle Graph-Übungs-IDs für Retriever-Boost (Slots + Geschwister + gespeichertes Artefakt). */
@@ -1063,10 +1084,9 @@ export function applyMatchStepsToSlots(draft, apiSteps) {
return syncProgressionRoadmapFromSlots({ ...draft, slots: nextSlots, dirty: true })
}
/** Vergleichs-Antwort: mindestens ein Slot mit anderer Übung als im Ist-Stand. */
/** Vergleichs-Antwort: mindestens ein inhaltlicher Slot-Unterschied. */
export function compareResponseHasSlotChanges(res) {
const count = res?.slot_diff_count ?? res?.slot_diffs?.length ?? 0
return Number(count) > 0
return compareResponseHasActionableSlotChanges(res)
}
/** Nur ausgewählte Slots aus Optimierungs-Vorschlag übernehmen. */