diff --git a/workbench-ui/src/app/apple-uma/AppleUmaReportRoute.tsx b/workbench-ui/src/app/apple-uma/AppleUmaReportRoute.tsx new file mode 100644 index 00000000..435c42d8 --- /dev/null +++ b/workbench-ui/src/app/apple-uma/AppleUmaReportRoute.tsx @@ -0,0 +1,320 @@ +import { useQuery } from "@tanstack/react-query"; +import { apiFetch, WorkbenchApiError } from "../../api/client"; +import { EmptyState } from "../../design/components/states/EmptyState"; +import { ErrorState } from "../../design/components/states/ErrorState"; +import { LoadingState } from "../../design/components/states/LoadingState"; +import { Panel } from "../../design/components/Panel/Panel"; + +export const APPLE_UMA_LOADING = "Loading Apple UMA report..."; +export const APPLE_UMA_ABSENCE_STATEMENT = "No Apple UMA report projection available."; +export const APPLE_UMA_ABSENCE_ACTION = + "CORE_BACKEND=rust uv run python -m benchmarks.apple_uma_mechanical_sympathy --write-report"; + +type JsonValue = string | number | boolean | null | JsonValue[] | { [key: string]: JsonValue }; + +interface AppleUmaMlxCase { + N: number | null; + top_k: number | null; + p50_ms: number | null; + p95_ms: number | null; + mean_ms: number | null; + rows_per_sec: number | null; + parity: Record; + copy_in_boundary: string | null; + copy_out_boundary: string | null; +} + +interface AppleUmaMlxTrack { + present: boolean; + skipped: boolean; + reason: string | null; + benchmark_only?: boolean; + serving_authorized?: boolean; + semantic_backend?: string | null; + score_computation?: string | null; + top_k_ordering?: string | null; + copy_boundary?: Record | null; + mlx_status?: Record; + case_count: number; + all_cases_parity_pass: boolean; + cases: AppleUmaMlxCase[]; +} + +interface AppleUmaReport { + read_only: boolean; + report_id: string; + source_path: string; + source_digest: string; + benchmark_name: string; + benchmark_version: string; + metadata: Record; + backend_status: Record; + tracks: { + available: string[]; + required: string[]; + missing_required: string[]; + mlx_exact_cga_recall: AppleUmaMlxTrack; + }; + copy_boundaries: Array>; + non_claims: string[]; + claim_safety: { + safe_claims: string[]; + rust_backend_notes: string[]; + known_copy_paths: string[]; + known_zero_copy_input_paths: string[]; + future_work: string[]; + }; +} + +function useAppleUmaReport() { + return useQuery({ + queryKey: ["api", "benchmarks", "apple-uma", "report"], + queryFn: () => apiFetch("/benchmarks/apple-uma/report"), + retry: false, + staleTime: 30_000, + refetchOnWindowFocus: false, + }); +} + +function isAppleUmaReport(value: unknown): value is AppleUmaReport { + if (!value || typeof value !== "object") return false; + const candidate = value as Partial; + return ( + candidate.read_only === true && + candidate.report_id === "apple_uma_mechanical_sympathy_latest" && + typeof candidate.benchmark_name === "string" && + typeof candidate.benchmark_version === "string" && + !!candidate.tracks && + typeof candidate.tracks === "object" + ); +} + +function boolLabel(value: unknown): string { + if (value === true) return "true"; + if (value === false) return "false"; + if (value === null || value === undefined || value === "") return "not declared"; + return String(value); +} + +function numericLabel(value: number | null | undefined): string { + if (typeof value !== "number" || !Number.isFinite(value)) return "n/a"; + return value.toLocaleString(undefined, { maximumFractionDigits: 3 }); +} + +function statusTone(kind: "good" | "warn" | "neutral") { + if (kind === "good") { + return "border-[var(--color-state-success-border)] bg-[var(--color-state-success-bg)] text-[var(--color-state-success-text)]"; + } + if (kind === "warn") { + return "border-[var(--color-state-warning-border)] bg-[var(--color-state-warning-bg)] text-[var(--color-state-warning-text)]"; + } + return "border-[var(--color-border-subtle)] bg-[var(--color-surface-inset)] text-[var(--color-text-secondary)]"; +} + +function StatusPill({ children, kind = "neutral" }: { children: string; kind?: "good" | "warn" | "neutral" }) { + return {children}; +} + +function MetricCard({ label, value, detail }: { label: string; value: string; detail?: string }) { + return ( +
+
{label}
+
{value}
+ {detail ?
{detail}
: null} +
+ ); +} + +function StaleReportNotice({ report }: { report: AppleUmaReport }) { + const missing = report.tracks.missing_required.join(", "); + return ( +
+

Report artifact needs refresh

+

+ The Workbench read-model is functioning, but the committed report is stale and lacks: {missing || "no required tracks"}. + No MLX success is being inferred from absent data. +

+ + {APPLE_UMA_ABSENCE_ACTION} + +
+ ); +} + +function BackendPanel({ report }: { report: AppleUmaReport }) { + const backend = report.backend_status; + return ( + +
+ + + + +
+
+ ); +} + +function TrackInventoryPanel({ report }: { report: AppleUmaReport }) { + return ( + +
+
+

Available tracks

+
+ {report.tracks.available.map((track) => ( + {track} + ))} +
+
+
+

Missing required tracks

+
+ {report.tracks.missing_required.length === 0 ? ( + none + ) : ( + report.tracks.missing_required.map((track) => ( + {track} + )) + )} +
+
+
+
+ ); +} + +function MlxPanel({ report }: { report: AppleUmaReport }) { + const mlx = report.tracks.mlx_exact_cga_recall; + const parityKind = mlx.all_cases_parity_pass ? "good" : "warn"; + return ( + +
+
+ {mlx.present ? "track present" : "track absent"} + {mlx.skipped ? "skipped" : "executed"} + parity {boolLabel(mlx.all_cases_parity_pass)} + serving authorized {boolLabel(mlx.serving_authorized)} +
+ {mlx.reason ?

{mlx.reason}

: null} +
+ + + +
+ {mlx.cases.length > 0 ? ( +
+ + + + + + + + + + + + {mlx.cases.map((entry) => ( + + + + + + + + ))} + +
Np50 msrows/secparitycopy boundary
{entry.N ?? "n/a"}{numericLabel(entry.p50_ms)}{numericLabel(entry.rows_per_sec)}{boolLabel(entry.parity.parity_pass)} +
{entry.copy_in_boundary ?? "copy-in not declared"}
+
{entry.copy_out_boundary ?? "copy-out not declared"}
+
+
+ ) : null} +
+
+ ); +} + +function CopyBoundaryPanel({ report }: { report: AppleUmaReport }) { + return ( + +
+ {report.copy_boundaries.map((row, index) => ( +
+
{boolLabel(row.path)}
+
+ input: {boolLabel(row.input)} + output: {boolLabel(row.output)} + zero-copy input: {boolLabel(row.zero_copy_input)} +
+
+ ))} +
+
+ ); +} + +function NonClaimsPanel({ report }: { report: AppleUmaReport }) { + return ( + +
    + {report.non_claims.map((claim) => ( +
  • {claim}
  • + ))} +
+
+ ); +} + +export function AppleUmaReportRoute() { + const { data, isLoading, isError, error } = useAppleUmaReport(); + + if (isLoading) return ; + + if (isError) { + return ( + + ); + } + + if (!isAppleUmaReport(data)) { + return ( + + ); + } + + const stale = data.tracks.missing_required.includes("mlx_exact_cga_recall"); + + return ( +
+
+
+
+

Apple Silicon / UMA

+

{data.benchmark_name}

+

+ Read-only evidence surface for Python, Rust, and MLX benchmark tracks. This view never runs benchmarks and never upgrades absent evidence into success. +

+
+ read-only {boolLabel(data.read_only)} +
+
+ + {stale ? : null} + + + + + +
+ ); +}