/** * VectorCortexTab.tsx — vector-cortex dashboard tab (VC0A, DASH-0b). * VC0A: reader-only aggregate latency histogram + per-mode sample counts from * GET /api/vector-cortex/evaluation. VC0C (task 5): live safety envelope health * card (breaker state, window/probe/backoff, durable spool frontier/lag) from * GET /api/vector-cortex/health plus an admin "reset cooldown" action. Polls * every 5s via useVectorCortexPoll. * * DASH-0b: delegate-shell. Flag `MEGACOMPACT_DASH_0B` default ON re-groups the * flat 18-card layout under 4 `
` headers (rendered by * `VectorCortexTab/sections.tsx`). Flag-OFF keeps the original flat card list * in this file — byte-identical predecessor layout. No card component file is * edited; only their import grouping moves. * * The client is a browser bundle with no `process` global, so the flag is read * from the server-authoritative `/api/rag-settings` state (the server resolves * `process.env["MEGACOMPACT_DASH_0B"] ?? default` into a boolean SettingState); * see the same pattern in SessionsTab. PREVENT-PI-004: loopback reader calls only. */ import { useState } from "react"; import { useApi } from "../hooks/useApi"; import { fetchSettings } from "../api/client"; import type { SettingsResponse } from "@contracts"; import { resetVectorCortexBreaker, fetchVectorCortexHealth, type VectorCortexHealthCard, } from "../api/vector-cortex"; import { Card, CardContent, CardHeader, CardTitle } from "../components/ui/card"; import { Badge } from "../components/ui/badge"; import { Metric } from "./VectorCortexMetric"; import { useVectorCortexPoll } from "./useVectorCortexPoll"; import { VectorCortexSections } from "./VectorCortexTab/sections"; import { VectorCortexRenderCard } from "./VectorCortexRenderCard"; import { VectorCortexRolloutCard } from "./VectorCortexRolloutCard"; import { VectorCortexClosureCard } from "./VectorCortexClosureCard"; import { VectorCortexRestoreCard } from "./VectorCortexRestoreCard"; import { VectorCortexRepairCard } from "./VectorCortexRepairCard"; import { VectorCortexCrystalsCard } from "./VectorCortexCrystalsCard"; import { VectorCortexEconomicsCard } from "./VectorCortexEconomicsCard"; import { VectorCortexDiagnosticsCard } from "./VectorCortexDiagnosticsCard"; import { VectorCortexOutcomesCard } from "./VectorCortexOutcomesCard"; import { VectorCortexPolicyCard } from "./VectorCortexPolicyCard"; import { VectorCortexPlatformCard } from "./VectorCortexPlatformCard"; import { VectorCortexShardsCard, VectorCortexReconstructCard, } from "./VectorCortexShardsCard"; import { VectorCortexPlansCard } from "./VectorCortexPlansCard"; import { VectorCortexTopologyCard } from "./VectorCortexTopologyCard"; import { VectorCortexLedgerCard } from "./VectorCortexLedgerCard"; import { VcStatusBadge } from "./VcStatusBadge"; import { ModelImprovementCard } from "../components/ModelImprovementCard"; const DASH_0B_KEY = "MEGACOMPACT_DASH_0B"; /** Resolve the DASH-0b flag from the server settings state (false unless confirmed). */ function dash0bEnabled(settings: SettingsResponse | null): boolean { if (!settings) return false; for (const cat of settings.categories) { for (const s of cat.settings) { if (s.key === DASH_0B_KEY && s.type === "boolean") return s.value === true; } } return false; } function ModeChip({ mode, count }: { mode: string; count: number }): React.ReactElement { return (
Mode {mode} {count}
); } export default function VectorCortexTab(): React.ReactElement { const [poll, refetch] = useVectorCortexPoll(); const [resetMsg, setResetMsg] = useState(null); const { data: settingsData } = useApi( () => fetchSettings(), { pollInterval: 0, maxRetries: 0 }, ); const dash0bOn = dash0bEnabled(settingsData); const { loading, error, data, health } = poll; const onReset = () => { resetVectorCortexBreaker("provider") .then((r) => { setResetMsg( `Breaker "${r.subsystem}" ${r.state}; evidence retained: ${r.failures} failures / ${r.attempts} attempts`, ); return fetchVectorCortexHealth(); }) .then((h: VectorCortexHealthCard | null) => { void h; refetch(); }) .catch((e: unknown) => setResetMsg(e instanceof Error ? e.message : String(e)), ); }; if (loading && !data) return
Loading vector-cortex evaluation…
; if (error && !data) return
Error: {error}
; if (!data) return
No evaluation data available.
; const max = Math.max(1, ...data.histogram.cells, data.histogram.overflow); return (

Vector Cortex Evaluation

{data.samples} samples · mode {data.mode}
{dash0bOn ? ( ) : ( <>
Samples
{data.samples}
Latency Histogram (ms, inclusive edges)
{data.histogram.edges.map((edge, i) => { const h = (data.histogram.cells[i] / max) * 140; return (
{data.histogram.cells[i]}
≤{edge}
); })}
{data.histogram.overflow}
>250
Total: {data.histogram.total} · Rejects: {data.rejects.length}
Live Safety Envelope (VC0C)
{health?.stateSource === "ephemeral" && ( EPHEMERAL (non-live) )}
{resetMsg && (
{resetMsg}
)} {!health ? (
Health unavailable (VC0C off).
) : (
)}
{data.ml5dEnabled && ( )} )}
); }