/** Scorecard rendering: severity + launch banner, kinematics, statistics. */ import Box from '@mui/material/Box'; import Chip from '@mui/material/Chip'; import Grid from '@mui/material/Grid'; import Paper from '@mui/material/Paper'; import Typography from '@mui/material/Typography'; import { AlertTriangle, UserCheck } from 'lucide-react'; import type { RetrospectiveScorecard } from '../../types/retro'; import { LAUNCH_COLORS, SEVERITY_COLORS } from './tierTheme'; function Stat({ label, value, mono = true }: { label: string; value: string; mono?: boolean }) { return ( {label} {value} ); } const fmt = (v: number | null | undefined, unit = '', digits = 2) => v === null || v === undefined ? 'UNKNOWN' : `${v.toFixed(digits)}${unit}`; export default function ScorecardView({ scorecard: sc }: { scorecard: RetrospectiveScorecard }) { const sevColor = SEVERITY_COLORS[sc.severity]; const launchColor = LAUNCH_COLORS[sc.launch_recommendation]; return ( {/* severity + launch banner */} {sc.severity_divergence && sc.ai_proposed_severity ? ( } label={`AI proposed ${sc.ai_proposed_severity} — policy override recorded`} sx={{ bgcolor: '#ffb74d22', color: '#ffb74d', fontWeight: 700 }} /> ) : null} {sc.human_review_required ? ( } label={`HUMAN REVIEW: ${sc.human_review_reasons.join(' · ')}`} sx={{ bgcolor: '#e6510022', color: '#ffab73', fontWeight: 700 }} /> ) : null} {sc.launch_rationale.join(' ')} CONTEXT & KINEMATICS (UNKNOWN means absent telemetry — never guessed) {sc.ttc_validity.length ? ( TTC validity: {sc.ttc_validity.join('; ')} ) : null} BEHAVIORAL CONSEQUENCE {sc.behavioral_consequence} {sc.planner_response ? ( observed planner: {JSON.stringify(sc.planner_response)} ) : null} STATISTICS metric_delta: {sc.metric_delta ? JSON.stringify(sc.metric_delta) : 'UNKNOWN'} significance: {sc.statistical_significance ? `${sc.statistical_significance.method} → ${ sc.statistical_significance.significant === null ? 'not evaluable' : sc.statistical_significance.significant ? 'SIGNIFICANT' : 'not significant' } (${sc.statistical_significance.detail})` : 'UNKNOWN'} {sc.distribution_shift ? ( distribution_shift: {JSON.stringify(sc.distribution_shift)} ) : null} {sc.uncertainty.missing_fields.length || sc.uncertainty.unknown_metrics.length ? ( UNCERTAINTY / MISSING EVIDENCE {sc.uncertainty.missing_fields.map((f) => ( missing field: {f} → UNKNOWN ))} {sc.uncertainty.unknown_metrics.map((m) => ( metric not computable: {m} → UNKNOWN ))} {sc.uncertainty.notes.map((n, i) => ( {n} ))} ) : null} {sc.policy_version} · {sc.agent_version} · backend {sc.backend_used} · {sc.created_at} ); }