Initial public ModelForge release
This commit is contained in:
commit
7082ab955a
490 files changed
+104252
No files matched your search
@@ -0,0 +1,97 @@
|
||||
import { useCallback, useEffect, useMemo, useState } from "react";
|
||||
import { Activity, AlertTriangle, CheckCircle2, RefreshCw, ShieldCheck, Square } from "lucide-react";
|
||||
|
||||
import { api } from "../lib/api";
|
||||
import type { CompatibilityAssessment, DeploymentCandidate, ExecutionApproval, HardwareState, RuntimeEnvironment, RuntimeProbe, RuntimeProfile } from "../types";
|
||||
|
||||
type RuntimeState = {
|
||||
environments: RuntimeEnvironment[]; profiles: RuntimeProfile[];
|
||||
assessments: CompatibilityAssessment[]; approvals: ExecutionApproval[];
|
||||
probes: RuntimeProbe[]; candidates: DeploymentCandidate[]; hardware: HardwareState;
|
||||
};
|
||||
|
||||
const emptyHardware: HardwareState = { overview: { status: "unknown", inventory_state: "unknown", node_count: 0, accelerator_count: 0 }, nodes: [] };
|
||||
const terminal = new Set(["completed", "failed", "cancelled"]);
|
||||
|
||||
function statusLabel(value: string): string { return value.replaceAll("_", " ").toUpperCase(); }
|
||||
function bytes(value: unknown): string { return typeof value === "number" ? `${(value / 1024 ** 3).toFixed(2)} GiB` : "unknown"; }
|
||||
function milliseconds(value: unknown): string { return typeof value === "number" ? `${value.toFixed(1)} ms` : "unknown"; }
|
||||
function nested(source: Record<string, unknown>, key: string): unknown { return source[key]; }
|
||||
|
||||
export function RuntimeWorkspace() {
|
||||
const [state, setState] = useState<RuntimeState>({ environments: [], profiles: [], assessments: [], approvals: [], probes: [], candidates: [], hardware: emptyHardware });
|
||||
const [selectedProfileId, setSelectedProfileId] = useState("");
|
||||
const [selectedNodeId, setSelectedNodeId] = useState("");
|
||||
const [operator, setOperator] = useState("local-operator");
|
||||
const [reason, setReason] = useState("Reviewed verified artifact provenance for isolated M4 lab execution");
|
||||
const [loading, setLoading] = useState(true);
|
||||
const [working, setWorking] = useState(false);
|
||||
const [error, setError] = useState<string | null>(null);
|
||||
|
||||
const load = useCallback(async (quiet = false) => {
|
||||
if (!quiet) setLoading(true);
|
||||
try {
|
||||
const [environments, profiles, assessments, approvals, probes, candidates, hardware] = await Promise.all([
|
||||
api.runtimeEnvironments(), api.runtimeProfiles(), api.compatibilityAssessments(),
|
||||
api.executionApprovals(), api.runtimeProbes(), api.deploymentCandidates(), api.hardware(),
|
||||
]);
|
||||
setState({ environments, profiles, assessments, approvals, probes, candidates, hardware });
|
||||
setSelectedProfileId((current) => current || profiles[0]?.id || "");
|
||||
setSelectedNodeId((current) => current || hardware.nodes.find((node) => node.lab_eligible)?.id || "");
|
||||
setError(null);
|
||||
} catch (cause) { setError(cause instanceof Error ? cause.message : "Runtime plane unavailable"); }
|
||||
finally { if (!quiet) setLoading(false); }
|
||||
}, []);
|
||||
|
||||
useEffect(() => { void load(); }, [load]);
|
||||
const activeProbe = state.probes.find((probe) => !terminal.has(probe.status));
|
||||
useEffect(() => {
|
||||
if (!activeProbe) return;
|
||||
const interval = window.setInterval(() => void load(true), 2000);
|
||||
return () => window.clearInterval(interval);
|
||||
}, [activeProbe, load]);
|
||||
|
||||
const selectedProfile = state.profiles.find((item) => item.id === selectedProfileId);
|
||||
const selectedEnvironment = state.environments.find((item) => item.id === selectedProfile?.runtime_environment_id);
|
||||
const currentAssessment = useMemo(() => state.assessments.find((item) => item.runtime_profile_id === selectedProfileId && item.compute_node_id === selectedNodeId), [selectedNodeId, selectedProfileId, state.assessments]);
|
||||
const currentApproval = state.approvals.find((item) => item.artifact_set_id === selectedProfile?.artifact_set_id && !item.stale && item.status === "approved");
|
||||
const selectedProbe = state.probes.find((item) => item.runtime_profile_id === selectedProfileId);
|
||||
const currentCandidate = state.candidates.find((item) => item.runtime_profile_id === selectedProfileId);
|
||||
|
||||
async function operate(action: () => Promise<unknown>) {
|
||||
setWorking(true); setError(null);
|
||||
try { await action(); await load(true); }
|
||||
catch (cause) { setError(cause instanceof Error ? cause.message : "Runtime operation failed"); }
|
||||
finally { setWorking(false); }
|
||||
}
|
||||
|
||||
if (loading) return <div className="state-card"><span className="state-spinner" />Loading runtime evidence…</div>;
|
||||
return <div className="runtime-stack">
|
||||
{error ? <div className="error-banner"><strong>Runtime operation blocked</strong><span>{error}</span></div> : null}
|
||||
<article className="panel runtime-boundary"><ShieldCheck size={20} /><div><strong>Technical execution boundary</strong><p>Verified bytes, static compatibility and explicit LAB approval are separate gates. A successful probe may create LAB_READY evidence, never production activation.</p></div><span className="registry-status blocked">PRODUCTION NOT APPROVED</span></article>
|
||||
<section className="runtime-grid">
|
||||
<article className="panel runtime-controls"><span className="eyebrow">REVIEW EXACT COMBINATION</span><h2>Runtime profile</h2>
|
||||
<label>Profile<select aria-label="Runtime profile" value={selectedProfileId} onChange={(event) => setSelectedProfileId(event.target.value)}><option value="">Select a profile</option>{state.profiles.map((item) => <option key={item.id} value={item.id}>{item.name} · v{item.version}</option>)}</select></label>
|
||||
<label>Target node<select aria-label="Target node" value={selectedNodeId} onChange={(event) => setSelectedNodeId(event.target.value)}><option value="">Select a node</option>{state.hardware.nodes.map((item) => <option key={item.id} value={item.id}>{item.display_name} · {item.liveness}</option>)}</select></label>
|
||||
{selectedProfile ? <dl className="runtime-facts"><div><dt>Adapter</dt><dd>{selectedProfile.adapter}@{selectedProfile.runtime_version}</dd></div><div><dt>ArtifactSet</dt><dd><code>{selectedProfile.artifact_set_id}</code></dd></div><div><dt>Mode</dt><dd>{selectedProfile.dtype} · batch {selectedProfile.batch_size} · seq {selectedProfile.max_sequence_length}</dd></div><div><dt>Isolation</dt><dd>remote code off · network off</dd></div><div><dt>Image</dt><dd><code>{selectedProfile.image_digest}</code></dd></div><div><dt>Environment</dt><dd>{selectedEnvironment?.python_version ?? "unknown"} · CUDA {selectedEnvironment?.cuda_runtime_version ?? "unknown"}</dd></div></dl> : <p className="empty">No immutable runtime profiles registered.</p>}
|
||||
<button disabled={working || !selectedProfile || !selectedNodeId} onClick={() => selectedProfile && operate(() => api.assessCompatibility(selectedProfile.artifact_set_id, selectedProfile.id, selectedNodeId))}><RefreshCw size={14} />Run static assessment</button>
|
||||
</article>
|
||||
<article className="panel runtime-controls"><span className="eyebrow">EXECUTION GATES</span><h2>Lab approval & probe</h2>
|
||||
<div className="gate-list"><div><span>Integrity</span><strong>{String(currentAssessment?.artifact_facts.integrity_status ?? "unknown").toUpperCase()}</strong></div><div><span>Static compatibility</span><strong>{currentAssessment ? statusLabel(currentAssessment.stale ? "stale" : currentAssessment.status) : "NOT ASSESSED"}</strong></div><div><span>Execution</span><strong>{currentApproval ? "LAB APPROVED" : "NOT APPROVED"}</strong></div><div><span>Production</span><strong>NOT APPROVED</strong></div></div>
|
||||
{currentAssessment?.blockers.length ? <div className="runtime-blockers"><AlertTriangle size={16} /><div><strong>Probe blocked</strong>{currentAssessment.blockers.map((item) => <span key={item}>{statusLabel(item)}</span>)}</div></div> : null}
|
||||
{currentAssessment?.stale ? <div className="runtime-blockers"><AlertTriangle size={16} /><div><strong>Compatibility evidence is stale</strong><span>{currentAssessment.stale_reason ?? "Evidence changed"}</span></div></div> : null}
|
||||
{!currentApproval && selectedProfile ? <><label>Approved by<input aria-label="Approved by" value={operator} onChange={(event) => setOperator(event.target.value)} /></label><label>Review reason<textarea aria-label="Approval reason" value={reason} onChange={(event) => setReason(event.target.value)} /></label><button disabled={working || reason.length < 8} onClick={() => operate(() => api.approveLabExecution(selectedProfile.artifact_set_id, operator, reason))}><ShieldCheck size={14} />Approve exact ArtifactSet for LAB</button></> : null}
|
||||
<button disabled={working || !currentAssessment || currentAssessment.stale || currentAssessment.blockers.length > 0 || !currentApproval} onClick={() => currentAssessment && currentApproval && operate(() => api.startRuntimeProbe(currentAssessment.id, currentApproval.id))}><Activity size={14} />Start controlled probe</button>
|
||||
</article>
|
||||
</section>
|
||||
<article className="panel"><div className="panel-header"><div><span className="eyebrow">STATIC COMPATIBILITY MATRIX</span><h2>ArtifactSet / runtime / node evidence</h2></div><span>{state.assessments.length} assessment(s)</span></div>
|
||||
<div className="runtime-matrix">{state.assessments.map((item) => <button key={item.id} onClick={() => { setSelectedProfileId(item.runtime_profile_id); setSelectedNodeId(item.compute_node_id); }}><div><strong>{item.adapter}</strong><span>{state.hardware.nodes.find((node) => node.id === item.compute_node_id)?.display_name ?? item.compute_node_id}</span></div><span className={`registry-status ${item.stale ? "blocked" : item.status}`}>{item.stale ? "STALE" : statusLabel(item.status)}</span><small>{item.blockers.length ? item.blockers.map(statusLabel).join(" · ") : "No static blockers"}</small></button>)}</div>
|
||||
</article>
|
||||
{selectedProbe ? <article className="panel probe-detail"><div className="panel-header"><div><span className="eyebrow">RUNTIME PROBE · ATTEMPT {selectedProbe.attempt_count}</span><h2>{statusLabel(selectedProbe.phase ?? selectedProbe.status)}</h2></div><span className={`registry-status ${selectedProbe.status === "completed" ? "verified" : selectedProbe.status}`}>{statusLabel(selectedProbe.status)}</span></div>
|
||||
<div className="probe-timeline">{["preparing", "loading", "healthchecking", "ready", "unloading", "completed"].map((phase) => <span key={phase} className={phase === selectedProbe.phase || selectedProbe.status === "completed" ? "active" : ""}>{statusLabel(phase)}</span>)}</div>
|
||||
<dl className="runtime-facts"><div><dt>Load time</dt><dd>{milliseconds(nested(selectedProbe.load_result, "load_time_ms"))}</dd></div><div><dt>Inference latency</dt><dd>{milliseconds(nested(selectedProbe.inference_result, "latency_ms"))}</dd></div><div><dt>Output shape</dt><dd>{JSON.stringify(nested(selectedProbe.inference_result, "shape") ?? nested(selectedProbe.inference_result, "output_shape") ?? "unknown")}</dd></div><div><dt>Baseline VRAM</dt><dd>{bytes(nested(selectedProbe.measured_resources, "baseline_vram_bytes"))}</dd></div><div><dt>Peak VRAM</dt><dd>{bytes(nested(selectedProbe.measured_resources, "peak_vram_bytes"))}</dd></div><div><dt>Reclaimed VRAM</dt><dd>{bytes(nested(selectedProbe.measured_resources, "reclaimed_vram_bytes"))}</dd></div><div><dt>Environment</dt><dd><code>{selectedProbe.environment_fingerprint}</code></dd></div><div><dt>Failure</dt><dd>{selectedProbe.failure_code ?? "none"}</dd></div></dl>
|
||||
{!terminal.has(selectedProbe.status) ? <button className="danger" onClick={() => operate(() => api.cancelRuntimeProbe(selectedProbe.id))}><Square size={13} />Cancel and reclaim</button> : null}
|
||||
</article> : null}
|
||||
{currentCandidate ? <article className="panel candidate-card"><CheckCircle2 size={22} /><div><span className="eyebrow">DEPLOYMENT CANDIDATE</span><h2>LAB_READY</h2><p>Created only from successful local compatibility evidence and a completed probe. Capability routing and production activation remain disabled.</p><code>{currentCandidate.id}</code></div><span className="registry-status blocked">PRODUCTION: FALSE</span></article> : null}
|
||||
</div>;
|
||||
}
|
||||
Reference in new issue
Block a user