From 4f8d7df8aec3ae465905840d8adf1a649ed47e4e Mon Sep 17 00:00:00 2001 From: Shay Date: Wed, 24 Jun 2026 15:21:19 -0700 Subject: [PATCH] feat(workbench-ui): wire Apple UMA report card into route registry --- workbench-ui/src/app/App.tsx | 1 - .../apple-uma/AppleUmaReportRoute.test.tsx | 174 ++++++++++++++++++ .../src/app/apple-uma/AppleUmaReportRoute.tsx | 3 +- .../src/app/routeConformance.test.tsx | 15 ++ workbench-ui/src/app/routes.ts | 13 ++ 5 files changed, 204 insertions(+), 2 deletions(-) create mode 100644 workbench-ui/src/app/apple-uma/AppleUmaReportRoute.test.tsx diff --git a/workbench-ui/src/app/App.tsx b/workbench-ui/src/app/App.tsx index accd0a93..2fa443ed 100644 --- a/workbench-ui/src/app/App.tsx +++ b/workbench-ui/src/app/App.tsx @@ -122,7 +122,6 @@ export function App() { element={ROUTE_ELEMENTS[route.id]} /> ))} - )} /> diff --git a/workbench-ui/src/app/apple-uma/AppleUmaReportRoute.test.tsx b/workbench-ui/src/app/apple-uma/AppleUmaReportRoute.test.tsx new file mode 100644 index 00000000..4f7a4ea3 --- /dev/null +++ b/workbench-ui/src/app/apple-uma/AppleUmaReportRoute.test.tsx @@ -0,0 +1,174 @@ +import { render, screen } from "@testing-library/react"; +import { QueryClientProvider } from "@tanstack/react-query"; +import { MemoryRouter } from "react-router-dom"; +import { afterEach, describe, expect, it, vi } from "vitest"; +import { createTestQueryClient } from "../../test/createTestQueryClient"; +import { + AppleUmaReportRoute, + APPLE_UMA_LOADING, + APPLE_UMA_ABSENCE_STATEMENT, + APPLE_UMA_ABSENCE_ACTION, +} from "./AppleUmaReportRoute"; + +const GENERATED_AT = "2026-06-14T00:00:00Z"; + +function stubFetch(data: unknown) { + vi.stubGlobal( + "fetch", + vi.fn(() => + Promise.resolve({ + json: async () => ({ ok: true, generated_at: GENERATED_AT, data }), + }), + ), + ); +} + +function stubFetchPending() { + vi.stubGlobal( + "fetch", + vi.fn(() => new Promise(() => {})), + ); +} + +function renderRoute() { + return render( + + + + + , + ); +} + +const STALE_REPORT = { + read_only: true, + report_id: "apple_uma_mechanical_sympathy_latest", + source_path: "reports/apple_uma.json", + source_digest: "sha256:1234567890abcdef", + benchmark_name: "Apple Silicon UMA Mechanical Sympathy", + benchmark_version: "1.0.0", + metadata: {}, + backend_status: { native_status: false, using_rust: true }, + tracks: { + available: ["rust"], + required: ["mlx_exact_cga_recall"], + missing_required: ["mlx_exact_cga_recall"], + mlx_exact_cga_recall: { + present: false, + skipped: true, + reason: "No MLX semantic-backend claim.", + serving_authorized: false, + case_count: 0, + all_cases_parity_pass: false, + cases: [], + }, + }, + copy_boundaries: [], + non_claims: ["No MLX semantic-backend claim."], + claim_safety: { + safe_claims: [], + rust_backend_notes: [], + known_copy_paths: [], + known_zero_copy_input_paths: [], + future_work: [], + }, +}; + +const MLX_PRESENT_REPORT = { + read_only: true, + report_id: "apple_uma_mechanical_sympathy_latest", + source_path: "reports/apple_uma.json", + source_digest: "sha256:1234567890abcdef", + benchmark_name: "Apple Silicon UMA Mechanical Sympathy", + benchmark_version: "1.0.0", + metadata: {}, + backend_status: { native_status: true, using_rust: true }, + tracks: { + available: ["rust", "mlx_exact_cga_recall"], + required: ["mlx_exact_cga_recall"], + missing_required: [], + mlx_exact_cga_recall: { + present: true, + skipped: false, + reason: null, + serving_authorized: true, + case_count: 1, + all_cases_parity_pass: true, + cases: [ + { + N: 128, + top_k: 5, + p50_ms: 0.977, + p95_ms: 1.2, + mean_ms: 1.0, + rows_per_sec: 1024, + parity: { parity_pass: true }, + copy_in_boundary: "copy-in zero borrow", + copy_out_boundary: "copy-out zero borrow", + }, + ], + }, + }, + copy_boundaries: [ + { + path: "test-path", + input: true, + output: true, + zero_copy_input: true, + }, + ], + non_claims: ["No MLX semantic-backend claim."], + claim_safety: { + safe_claims: [], + rust_backend_notes: [], + known_copy_paths: [], + known_zero_copy_input_paths: [], + future_work: [], + }, +}; + +afterEach(() => { + vi.unstubAllGlobals(); +}); + +describe("AppleUmaReportRoute", () => { + it("loading state shows APPLE_UMA_LOADING and never 'Thinking'", async () => { + stubFetchPending(); + renderRoute(); + expect(await screen.findByText(APPLE_UMA_LOADING)).toBeInTheDocument(); + expect(screen.queryByText(/thinking/i)).not.toBeInTheDocument(); + }); + + it("malformed/empty API shape renders APPLE_UMA_ABSENCE_STATEMENT and APPLE_UMA_ABSENCE_ACTION", async () => { + stubFetch({}); + renderRoute(); + expect(await screen.findByText(APPLE_UMA_ABSENCE_STATEMENT)).toBeInTheDocument(); + expect(screen.getByText(APPLE_UMA_ABSENCE_ACTION)).toBeInTheDocument(); + }); + + it("stale committed-report shape renders expected labels", async () => { + stubFetch(STALE_REPORT); + renderRoute(); + + expect(await screen.findByText("Report artifact needs refresh")).toBeInTheDocument(); + expect(screen.getByText(/No MLX success is being inferred/)).toBeInTheDocument(); + expect(screen.getByText("track absent")).toBeInTheDocument(); + expect(screen.getByText("parity false")).toBeInTheDocument(); + expect(screen.getByText("serving authorized false")).toBeInTheDocument(); + expect(screen.getAllByText("No MLX semantic-backend claim.").length).toBeGreaterThan(0); + }); + + it("MLX-present shape renders expected metrics and copy boundaries", async () => { + stubFetch(MLX_PRESENT_REPORT); + renderRoute(); + + expect(await screen.findByText("track present")).toBeInTheDocument(); + expect(screen.getByText("executed")).toBeInTheDocument(); + expect(screen.getByText("parity true")).toBeInTheDocument(); + expect(screen.getByText("serving authorized true")).toBeInTheDocument(); + expect(screen.getByText("128")).toBeInTheDocument(); + expect(screen.getByText("0.977")).toBeInTheDocument(); + expect(screen.getByText("copy-in zero borrow")).toBeInTheDocument(); + expect(screen.getByText("copy-out zero borrow")).toBeInTheDocument(); + }); +}); diff --git a/workbench-ui/src/app/apple-uma/AppleUmaReportRoute.tsx b/workbench-ui/src/app/apple-uma/AppleUmaReportRoute.tsx index 435c42d8..4559afd7 100644 --- a/workbench-ui/src/app/apple-uma/AppleUmaReportRoute.tsx +++ b/workbench-ui/src/app/apple-uma/AppleUmaReportRoute.tsx @@ -4,6 +4,7 @@ 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"; +import { type ReactNode } from "react"; export const APPLE_UMA_LOADING = "Loading Apple UMA report..."; export const APPLE_UMA_ABSENCE_STATEMENT = "No Apple UMA report projection available."; @@ -111,7 +112,7 @@ function statusTone(kind: "good" | "warn" | "neutral") { 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" }) { +function StatusPill({ children, kind = "neutral" }: { children: ReactNode; kind?: "good" | "warn" | "neutral" }) { return {children}; } diff --git a/workbench-ui/src/app/routeConformance.test.tsx b/workbench-ui/src/app/routeConformance.test.tsx index a6839912..67ab4517 100644 --- a/workbench-ui/src/app/routeConformance.test.tsx +++ b/workbench-ui/src/app/routeConformance.test.tsx @@ -26,6 +26,12 @@ import { LogosRoute } from "./logos/LogosRoute"; import { VaultRoute, VAULT_ABSENCE_STATEMENT, VAULT_ABSENCE_ACTION } from "./vault/VaultRoute"; import { CalibrationRoute } from "./calibration/CalibrationRoute"; import { SettingsRoute } from "./settings/SettingsRoute"; +import { + AppleUmaReportRoute, + APPLE_UMA_LOADING, + APPLE_UMA_ABSENCE_STATEMENT, + APPLE_UMA_ABSENCE_ACTION, +} from "./apple-uma/AppleUmaReportRoute"; /** * ADR-0162 §6 route conformance — executable, not aspirational. @@ -243,6 +249,15 @@ const MOUNT_ROUTES: MountRouteSpec[] = [ "No calibration evidence yet. The per-class arena ledger is populated by the sealed practice lane (ADR-0175).", emptyCommand: "core eval math-contemplation", }, + { + name: "Apple UMA", + element: , + path: "/apple-uma", + initialEntry: "/apple-uma", + loadingLabel: APPLE_UMA_LOADING, + emptyStatement: APPLE_UMA_ABSENCE_STATEMENT, + emptyCommand: APPLE_UMA_ABSENCE_ACTION, + }, ]; describe.each(MOUNT_ROUTES)("route conformance: $name", (spec) => { diff --git a/workbench-ui/src/app/routes.ts b/workbench-ui/src/app/routes.ts index 4c72f098..1b78f6b6 100644 --- a/workbench-ui/src/app/routes.ts +++ b/workbench-ui/src/app/routes.ts @@ -261,6 +261,19 @@ export const WORKBENCH_ROUTES: readonly WorkbenchRoute[] = [ keyboardDigit: null, routeConformanceRequired: true, }, + { + id: "apple-uma", + path: "/apple-uma", + routePattern: "apple-uma", + label: "Apple UMA", + description: "Inspect the Apple Silicon mechanical-sympathy benchmark report.", + section: "Substrate", + leftNavVisible: true, + commandPaletteVisible: true, + landingRouteAllowed: true, + keyboardDigit: null, + routeConformanceRequired: true, + }, { id: "settings", path: "/settings",