const METRICS = [ { key: 'final_action_score', label: 'Final Action Accuracy', weight: '50%', desc: 'Did the agent take the correct terminal action (allow/flag/remove/escalate)?', }, { key: 'classification_score', label: 'Classification Accuracy', weight: '20%', desc: 'Did the agent correctly identify the violation type?', }, { key: 'investigation_score', label: 'Investigation Quality', weight: '15%', desc: 'Did the agent gather all recommended context before deciding?', }, { key: 'efficiency_score', label: 'Efficiency', weight: '15%', desc: 'Did the agent reach a decision without unnecessary extra steps?', }, ] function barColor(v) { if (v >= 0.8) return '#4ade80' if (v >= 0.5) return '#f0a500' return '#f87171' } function Tooltip({ text }) { return ( ? {text} ) } function ScoreBar({ value, animKey }) { const color = barColor(value) return (
) } export default function ScoreCard({ score, animKey }) { if (!score) return null const total = score.total const totalColor = barColor(total) const isCorrect = score.final_action_score === 1.0 return (
{/* Total */}
Total Score
{Math.round(total * 100)} %
{/* Correct / wrong indicator */}
{isCorrect ? '✓ Correct Decision' : '✗ Wrong Decision'}
{score.breakdown?.false_negative_penalty > 0 && (
⚠ false negative −{score.breakdown.false_negative_penalty.toFixed(2)}
)}
{/* Per-metric bars */}
{METRICS.map(({ key, label, weight, desc }) => { const v = score[key] ?? 0 const color = barColor(v) return (
{label} {weight}
{Math.round(v * 100)}%
) })}
) }