### Install OpenJev from GitHub Source: https://github.com/heman10x-ngu/verdict-open-jev/blob/main/README.md Clones the repository, installs the package in editable mode, and downloads required artifacts. Requires Python 3.10+. ```bash git clone https://github.com/Heman10x-NGU/Verdict-open-jev.git cd Verdict-open-jev pip install -e . python scripts/download_artifacts.py ``` -------------------------------- ### Start local HTTP server Source: https://github.com/heman10x-ngu/verdict-open-jev/blob/main/README.md Starts a Python HTTP server on port 8080 to serve the web demo locally. Requires Python 3. ```bash python3 -m http.server 8080 ``` -------------------------------- ### Reset Evaluation State Source: https://github.com/heman10x-ngu/verdict-open-jev/blob/main/webgpu-demo/index.html Resets the evaluation state, clearing candidate probabilities and resetting UI badges and status text. Used when starting a new inference or resetting the demo. ```javascript function resetEvaluationState(reasonText = "Click 'Run Inference' or press ⌘ ↵ to evaluate") { latestReceipt = null; activeCandidates.forEach(c => { c.prob = undefined; }); // Reset candidate DOM cards to clean input state const items = candidateList.querySelectorAll(".candidate-item"); items.forEach(item => { item.classList.remove("winner"); const candId = item.getAttribute("data-cand-id"); if (candId) { const safeId = CSS.escape(candId); const badge = item.querySelector(`[data-badge-id="${safeId}"]`); const bar = item.querySelector(`[data-bar-id="${safeId}"]`); if (badge) badge.textContent = "--%"; if (bar) bar.style.width = "0%"; } }); // Reset Route Badge to STANDBY routeBadge.className = "route-badge standby"; routeMainText.textContent = "STANDBY (Awaiting Inference)"; routeSubText.textContent = reasonText; // Reset Latency Badge and status line so a stale timing never survives a state change latencyBadge.textContent = isWorkerReady ? "Ready" : "-- ms"; if (isWorkerReady) { statusText.textContent = IDLE_STATUS_TEXT; } } ``` -------------------------------- ### Navigate to web demo directory Source: https://github.com/heman10x-ngu/verdict-open-jev/blob/main/README.md Changes the current directory to the webgpu-demo folder, which contains the static web playground files. ```bash cd webgpu-demo ``` -------------------------------- ### Synchronous Initial Boot Source: https://github.com/heman10x-ngu/verdict-open-jev/blob/main/webgpu-demo/index.html Loads a preset configuration synchronously during initial boot to populate candidate cards and calibrated baseline in the DOM. ```javascript loadPreset("card_arrival", false); ``` -------------------------------- ### Evaluate a query with DecisionEngine Source: https://github.com/heman10x-ngu/verdict-open-jev/blob/main/README.md Creates a DecisionEngine, builds a Choice with options, and evaluates a context. Prints the selected option ID, confidence, and abstention probability from the result. ```python from rlcd import DecisionEngine, Choice, Option engine = DecisionEngine() query = Choice( question="What is the primary customer inquiry?", options=[ Option(id="card_lost", description="Reporting a lost or stolen card"), Option(id="dispute_charge", description="Disputing an unrecognized charge"), Option(id="pin_reset", description="Requesting a PIN reminder or reset"), ] ) result = engine.evaluate( context="I lost my wallet yesterday and need to stop my debit card immediately.", queries=[query] ) print(f"Selected: {result.results[0].selected_option_id}") print(f"Confidence: {result.results[0].confidence:.4f}") print(f"Abstention probability: {result.results[0].p_abstain:.4f}") ``` -------------------------------- ### Load Preset and Add Option Listener Source: https://github.com/heman10x-ngu/verdict-open-jev/blob/main/webgpu-demo/index.html Loads preset configurations, sets active candidates, and adds a new candidate option via button click. Handles insertion before abstention and resets evaluation state. ```javascript function loadPreset(key) { presetPills.forEach(p => p.classList.toggle("active", p.dataset.preset === key)); const p = PRESETS[key] || CANONICAL_PRESETS.card_arrival; if (!p) return; currentQuestion = p.question || CANONICAL_PRESETS.card_arrival.question; contextInput.value = p.text; activeCandidates = JSON.parse(JSON.stringify(p.candidates)); renderCandidates(); resetEvaluationState("Click 'Run Inference' or press ⌘ ↵ to evaluate"); } // Preset pill click listeners presetPills.forEach(pill => { pill.addEventListener("click", () => { loadPreset(pill.dataset.preset); }); }); // Context typing listeners contextInput.addEventListener("input", () => { if (latestReceipt) { resetEvaluationState("Context modified • Click 'Run Inference' to re-evaluate"); } }); // Add Option (Explicitly finds abstention rather than blindly popping) btnAddCand.addEventListener("click", () => { if (activeCandidates.length >= 25) { alert("Maximum supported capacity is 25 options."); return; } const newIdx = activeCandidates.length + 1; const newId = "custom_option_" + Date.now().toString(36); const newCand = { id: newId, desc: "New candidate action " + newIdx }; // Insert right before abstention if present, otherwise append const abstainIdx = activeCandidates.findIndex(c => c.id === "__insufficient_evidence__"); if (abstainIdx !== -1) { activeCandidates.splice(abstainIdx, 0, newCand); } else { activeCandidates.push(newCand); } renderCandidates(); resetEvaluationState("Option added • Click 'Run Inference' to evaluate"); // Focus the newly added input const item = candidateList.querySelector(`[data-cand-id="${CSS.escape(newId)}"]`); if (item) { const input = item.querySelector(".cand-edit-input"); if (input) { input.focus(); input.select(); } } }); ``` -------------------------------- ### Load ONNX model with onnxruntime Source: https://github.com/heman10x-ngu/verdict-open-jev/blob/main/README.md Downloads the model.onnx file from Hugging Face Hub and creates an ONNX Runtime inference session using the CPU execution provider. ```python import onnxruntime as ort from huggingface_hub import hf_hub_download model_path = hf_hub_download(repo_id="heman10x/rlcd-modernbert-151m", filename="model.onnx") session = ort.InferenceSession(model_path, providers=["CPUExecutionProvider"]) ``` -------------------------------- ### Run Inference button click handler Source: https://github.com/heman10x-ngu/verdict-open-jev/blob/main/webgpu-demo/index.html When the engine is not ready, queues the inference and shows a message. Otherwise triggers the inference directly. ```javascript btnRunInfer.addEventListener("click", () => { if (!isWorkerReady) { pendingInference = true; btnRunInfer.innerHTML = `Queued (Waiting for engine)...⌘ ↵`; statusText.textContent = "Inference queued — will execute automatically as soon as model finishes compiling..."; return; } triggerInference(); }); ``` -------------------------------- ### Render Candidates and Add Option Source: https://github.com/heman10x-ngu/verdict-open-jev/blob/main/webgpu-demo/index.html Renders candidate items with editable descriptions, probability badges, and bars. Handles adding new candidates, inserting before abstention, and resetting evaluation state on modifications. ```javascript const probDisplay = cand.prob !== undefined && cand.prob !== null ? `${(cand.prob * 100).toFixed(1)}%` : "--%"; const barWidth = cand.prob !== undefined && cand.prob !== null ? `${(cand.prob * 100).toFixed(1)}%` : "0%"; const item = document.createElement("div"); item.className = `candidate-item ${isAbstain ? "abstention" : ""} ${isWinner ? "winner" : ""}`.trim(); item.setAttribute("data-cand-id", cand.id); item.innerHTML = `
${isAbstain ? "Abstention" : escapeHtml(cand.id)} ${probDisplay} ${!isAbstain ? `` : ``}
`; // Inline edit const input = item.querySelector(".cand-edit-input"); input.addEventListener("input", (e) => { cand.desc = e.target.value; if (latestReceipt) { resetEvaluationState("Options modified • Click 'Run Inference' to re-evaluate"); } }); // Delete option if (!isAbstain) { const delBtn = item.querySelector(".btn-del-cand"); delBtn.addEventListener("click", (e) => { e.stopPropagation(); const targetId = cand.id; const targetIdx = activeCandidates.findIndex(c => c.id === targetId); if (targetIdx !== -1) { activeCandidates.splice(targetIdx, 1); renderCandidates(); resetEvaluationState("Option deleted • Click 'Run Inference' to evaluate"); } }); } candidateList.appendChild(item); }); } ``` -------------------------------- ### Canonical Presets Configuration Source: https://github.com/heman10x-ngu/verdict-open-jev/blob/main/webgpu-demo/index.html JavaScript object defining canonical presets with verified domain questions and calibrated baselines. Includes a card arrival preset with candidate options and a compromised card preset with a question and text. ```javascript // ------------------------------------------------------------- // Canonical Presets with Verified Domain Questions & Calibrated Baselines // Verified from ModernBERT checkpoint & evaluation_report_v2.json // ------------------------------------------------------------- const CANONICAL_PRESETS = { "card_arrival": { "key": "card_arrival", "question": "What is the primary customer inquiry or banking request?", "text": "I ordered my new card two weeks ago but haven't received it in the mail yet. Can you check delivery?", "candidates": [ { "id": "card_arrival", "desc": "Inquire about whether a newly ordered debit or credit card has arrived or when it will arrive in the mail" }, { "id": "lost_or_stolen_card", "desc": "Report a physically lost, stolen, or misplaced card requiring immediate permanent block or cancellation" }, { "id": "compromised_card", "desc": "Report suspected unauthorized card cloning, skimmed magnetic stripe, or fraudulent card transactions" }, { "id": "__insufficient_evidence__", "desc": "insufficient evidence" } ] }, "lost_or_stolen_card": { "key": "lost_or_stolen_card", "question": "What is the primary customer inquiry or banking request?", "text": "Someone snatched my purse with my debit card inside while I was at the train station!", "candidates": [ { "id": "lost_or_stolen_card", "desc": "Report a physically lost, stolen, or misplaced card requiring immediate permanent block or cancellation" }, { "id": "card_arrival", "desc": "Inquire about whether a newly ordered debit or credit card has arrived or when it will arrive in the mail" }, { "id": "pin_blocked", "desc": "Unblock or reset a card PIN after multiple incorrect entry attempts at an ATM or terminal" }, { "id": "__insufficient_evidence__", "desc": "insufficient evidence" } ] }, "compromised_card": { "key": "compromised_card", "question": "What is the primary customer inquiry or banking request?", "text": "There are two charges for $240 from an electronics shop in another country that I never visited.", "candidates": [ { "id": "compromised_card", "desc": "Report suspected unauthorized card cloning, skimmed magnetic stripe, or fraudulent card transactions" }, { "id": "lost_or_stolen_card", "desc": "Report a physically lost, stolen, or misplaced card requiring immediate permanent block or cancellation" }, { "id": "exchange_rate", "desc": "Check current foreign exchange rates, conversion spreads, or weekend currency trading markup" }, { "id": "__insufficient_evidence__", "desc": "insufficient evidence" } ] } } ``` -------------------------------- ### App Title and Badge Styles Source: https://github.com/heman10x-ngu/verdict-open-jev/blob/main/webgpu-demo/index.html Styles for the application title and the GPU/WASM/speed badges, including their color-coded borders and backgrounds. ```css .app-title { font-size: 14px; font-weight: 700; letter-spacing: -0.02em; color: #fff; } .badge { display: inline-flex; align-items: center; gap: 5px; padding: 3px 8px; border-radius: 4px; font-size: 11px; font-family: var(--font-mono); font-weight: 600; font-variant-numeric: tabular-nums; background: var(--surface-2); border: 1px solid var(--hairline); color: var(--ink-subtle); } .badge.gpu { border-color: rgba(16, 185, 129, 0.4); color: var(--emerald); background: var(--emerald-subtle); } .badge.wasm { border-color: rgba(245, 158, 11, 0.4); color: var(--amber); background: var(--amber-subtle); } .badge.speed { color: #fff; border-color: rgba(94, 106, 210, 0.4); } ``` -------------------------------- ### Render Candidate List Source: https://github.com/heman10x-ngu/verdict-open-jev/blob/main/webgpu-demo/index.html Renders the candidate list with probabilities, highlighting the winner and handling abstention. Cleans inputs until 'Run Inference' is pressed. ```javascript function renderCandidates() { candidateList.innerHTML = ""; candCountLabel.textContent = `${activeCandidates.length} options (max 25)`; const maxProb = Math.max(...activeCandidates.map(c => (typeof c.prob === "number" ? c.prob : -1))); activeCandidates.forEach((cand) => { const isAbstain = cand.id === "__insufficient_evidence__"; const isWinner = typeof cand.prob === "number" && cand.prob === maxProb && cand.prob > ``` -------------------------------- ### OpenJev Architecture Diagram Source: https://github.com/heman10x-ngu/verdict-open-jev/blob/main/README.md ASCII diagram showing the data flow from input document and candidate labels through joint tokenization, ModernBERT encoding, bi-encoder head, softmax, and final typed JSON output. ```text Input Document ────────┐ ├─► [ Joint Tokenizer ] ─► [ ModernBERT Encoder ] ─► [ Bi-Encoder Head ] ─► Logits Candidate Labels List ─┘ │ ▼ [ Softmax + ECE ] │ ▼ Python Dict Assembly ◄────────────────────────────────────────────────────────────────────── Typed JSON ``` -------------------------------- ### Top Progress Bar and Status Banner Styles Source: https://github.com/heman10x-ngu/verdict-open-jev/blob/main/webgpu-demo/index.html Styles for the top progress bar that indicates model download progress, and the status banner that displays status information. ```css /* Top Progress Bar for Model Download */ .top-progress { position: absolute; bottom: 0; left: 0; width: 100%; height: 2px; background: transparent; } .top-progress-fill { height: 100%; width: 0%; background: linear-gradient(90deg, var(--accent), var(--emerald)); transition: width 0.2s ease-out, opacity 0.3s ease; } /* Status Banner */ .status-banner { font-family: var(--font-mono); font-size: 11px; color: var(--ink-tertiary); padding: 0 4px; display: flex; justify-content: space-between; align-items: center; font-variant-numeric: tabular-nums; } ``` -------------------------------- ### WebWorker Initialization and Error Handling Source: https://github.com/heman10x-ngu/verdict-open-jev/blob/main/webgpu-demo/index.html Initializes a WebWorker with a module script and posts an INIT message. Handles worker errors by updating the UI with error details, including a special message for file:// protocol. ```javascript try { worker = new Worker("worker.js", { type: "module" }); worker.postMessage({ type: "INIT", payload: { basePath: activeCheckpoint } }); worker.onerror = (err) => { console.error("Worker runtime error:", err); statusDot.className = "status-dot error"; statusDot.title = "Engine failure"; hardwareBadge.textContent = "● Engine Failed"; hardwareBadge.className = "badge"; hardwareBadge.style.borderColor = "rgba(239, 68, 68, 0.4)"; hardwareBadge.style.color = "var(--rose)"; hardwareBadge.style.background = "var(--rose-subtle)"; let detail = err.message || (err.filename ? `Error in ${err.filename}:${err.lineno}` : "WebWorker execution failed"); if (location.protocol === "file:") { detail = "ES module workers require an HTTP server (e.g."; } }; } ``` -------------------------------- ### showCopyFeedback function Source: https://github.com/heman10x-ngu/verdict-open-jev/blob/main/webgpu-demo/index.html Displays a 'Copied!' feedback on the copy button for 1.5 seconds. ```javascript function showCopyFeedback() { btnCopyReceipt.innerHTML = "✓Copied!"; setTimeout(() => { btnCopyReceipt.innerHTML = `${ICON_CLIPBOARD}Copy Verifiable JSON Receipt`; }, 1500); } ``` -------------------------------- ### switchCheckpoint function Source: https://github.com/heman10x-ngu/verdict-open-jev/blob/main/webgpu-demo/index.html Resets the worker readiness, updates status UI, and posts an INIT message to the worker with the new checkpoint base path. ```javascript function switchCheckpoint() { isWorkerReady = false; statusDot.className = "status-dot downloading"; statusText.textContent = `Loading ${activeCheckpoint}...`; hardwareBadge.textContent = "● Reloading..."; topProgressFill.style.opacity = "1"; topProgressFill.style.width = "25%"; resetEvaluationState(`Switched to ${activeCheckpoint} • Click 'Run Inference' to evaluate`); if (worker) { worker.postMessage({ type: "INIT", payload: { basePath: activeCheckpoint } }); } } ``` -------------------------------- ### Deterministic application policy routing with threshold Source: https://github.com/heman10x-ngu/verdict-open-jev/blob/main/README.md Applies a confidence threshold (0.85) to route decisions: abstain to fallback, high confidence to workflow dispatch, otherwise to human review. At 0.85 threshold on held-out test split, achieves 84.60% coverage with 1.18% selective risk (10 errors among 846 accepted predictions). ```python # Deterministic application policy THRESHOLD_AUTO = 0.85 decision = result.results[0] if decision.is_abstention: route_to_fallback("Model signaled insufficient evidence") elif decision.confidence >= THRESHOLD_AUTO: dispatch_workflow(action=decision.selected_option_id) else: route_to_human_review(reason="Confidence below automated threshold", score=decision.confidence) ``` -------------------------------- ### Action Toolbar CSS Source: https://github.com/heman10x-ngu/verdict-open-jev/blob/main/webgpu-demo/index.html Styles for the action toolbar, run button, keyboard hint, and receipt button. Defines layout, colors, hover states, and disabled states. ```css .action-toolbar { display: flex; justify-content: space-between; align-items: center; gap: 10px; flex-wrap: wrap; } .btn-run { background: var(--accent); border: none; color: #fff; font-weight: 700; font-size: 13px; padding: 10px 18px; border-radius: 6px; cursor: pointer; display: inline-flex; align-items: center; gap: 8px; transition: all 0.15s ease; box-shadow: 0 1px 8px rgba(94, 106, 210, 0.3); } .btn-run:hover:not(:disabled) { background: var(--accent-hover); box-shadow: 0 2px 14px rgba(94, 106, 210, 0.5); } .btn-run:disabled { opacity: 0.45; cursor: not-allowed; box-shadow: none; } .kbd-hint { background: rgba(0, 0, 0, 0.3); border: 1px solid rgba(255, 255, 255, 0.2); border-radius: 3px; padding: 1px 5px; font-size: 10px; font-family: var(--font-mono); } .btn-receipt { background: var(--surface-1); border: 1px solid var(--hairline); color: var(--ink); font-weight: 600; font-size: 12.5px; padding: 10px 16px; border-radius: 6px; cursor: pointer; display: inline-flex; align-items: center; gap: 6px; transition: all 0.15s ease; } .btn-receipt:hover { border-color: var(--hairline-strong); background: var(--surface-2); } ``` -------------------------------- ### Header Bar and Status Dot Styles Source: https://github.com/heman10x-ngu/verdict-open-jev/blob/main/webgpu-demo/index.html Styles for the header bar, logo lockup, and status dot indicators that reflect model loading states (active, downloading, error) with a pulse animation. ```css header { background: var(--surface-1); border: 1px solid var(--hairline); border-radius: var(--radius); padding: 12px 18px; display: flex; justify-content: space-between; align-items: center; flex-wrap: wrap; gap: 12px; box-shadow: var(--top-bezel); position: relative; overflow: hidden; } .header-left { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; } .logo-lockup { display: flex; align-items: center; gap: 8px; } .status-dot { width: 8px; height: 8px; border-radius: 50%; background: var(--amber); box-shadow: 0 0 8px var(--amber); transition: all 0.3s ease; } .status-dot.active { background: var(--emerald); box-shadow: 0 0 8px var(--emerald); } .status-dot.downloading { background: var(--accent); box-shadow: 0 0 8px var(--accent); animation: pulse-dot 1.2s infinite ease-in-out; } .status-dot.error { background: var(--rose); box-shadow: 0 0 8px var(--rose); animation: none; } @keyframes pulse-dot { 0%, 100% { opacity: 0.5; transform: scale(0.9); } 50% { opacity: 1; transform: scale(1.25); } } ``` -------------------------------- ### flashReceiptHint function Source: https://github.com/heman10x-ngu/verdict-open-jev/blob/main/webgpu-demo/index.html Shows an alert message on the copy button for 1.5 seconds, then restores the original content. ```javascript function flashReceiptHint(msg = "Run inference first") { const originalHtml = btnCopyReceipt.innerHTML; btnCopyReceipt.innerHTML = `${ICON_ALERT}${msg}`; setTimeout(() => { btnCopyReceipt.innerHTML = originalHtml; }, 1500); } ``` -------------------------------- ### fallbackCopy function Source: https://github.com/heman10x-ngu/verdict-open-jev/blob/main/webgpu-demo/index.html Copies text using a temporary textarea and document.execCommand, with fallback feedback. ```javascript function fallbackCopy(text) { const ta = document.createElement("textarea"); ta.value = text; ta.style.position = "fixed"; ta.style.opacity = "0"; document.body.appendChild(ta); ta.focus(); ta.select(); try { document.execCommand("copy"); showCopyFeedback(); } catch (e) { flashReceiptHint("Copy failed (see console)"); console.log(text); } document.body.removeChild(ta); } ``` -------------------------------- ### Checkpoint switching button handlers Source: https://github.com/heman10x-ngu/verdict-open-jev/blob/main/webgpu-demo/index.html Handlers for switching between v1 and v2 checkpoints, updating the active state and calling switchCheckpoint. ```javascript btnCpV2.addEventListener("click", () => { if (activeCheckpoint === "artifacts_v2") return; activeCheckpoint = "artifacts_v2"; btnCpV2.classList.add("active"); btnCpV1.classList.remove("active"); switchCheckpoint(); }); ``` ```javascript btnCpV1.addEventListener("click", () => { if (activeCheckpoint === "artifacts") return; activeCheckpoint = "artifacts"; btnCpV1.classList.add("active"); btnCpV2.classList.remove("active"); switchCheckpoint(); }); ``` -------------------------------- ### triggerInference function Source: https://github.com/heman10x-ngu/verdict-open-jev/blob/main/webgpu-demo/index.html Checks worker readiness; if not ready, queues the inference. Otherwise, updates status UI and posts INFER message with a threshold and generated id. ```javascript function triggerInference() { if (!isWorkerReady) { pendingInference = true; btnRunInfer.innerHTML = `Queued (Waiting for engine)...⌘ ↵`; statusText.textContent = "Model compiling in WebGPU memory (will run automatically)..."; return; } statusDot.className = "status-dot downloading"; statusText.textContent = `Executing ${activeBackendName} forward pass (median of 3)...`; btnRunInfer.innerHTML = `Evaluating...⌘ ↵`; const threshold = parseFloat(thresholdSlider.value); worker.postMessage({ type: "INFER", payload: { id: "verdict_query_" + Date.now(), threshold: threshold } }); } ``` -------------------------------- ### Copy JSON Receipt button click handler Source: https://github.com/heman10x-ngu/verdict-open-jev/blob/main/webgpu-demo/index.html Copies the latest receipt as formatted JSON to the clipboard. Flashes a hint if there is no receipt yet, and falls back to a textarea method if the Clipboard API is unavailable. ```javascript btnCopyReceipt.addEventListener("click", () => { let receiptToCopy = latestReceipt; if (!receiptToCopy) { flashReceiptHint("Run inference first"); return; } const jsonStr = JSON.stringify(receiptToCopy, null, 2); if (navigator.clipboard && navigator.clipboard.writeText) { navigator.clipboard.writeText(jsonStr).then(() => { showCopyFeedback(); }).catch(() => { fallbackCopy(jsonStr); }); } else { fallbackCopy(jsonStr); } }); ``` -------------------------------- ### Checkpoint Toggle and Button Styles Source: https://github.com/heman10x-ngu/verdict-open-jev/blob/main/webgpu-demo/index.html Styles for the checkpoint toggle control and its buttons, including the active state and hover effects. ```css .header-right { display: flex; align-items: center; gap: 10px; } .checkpoint-toggle { display: inline-flex; background: var(--surface-input); border: 1px solid var(--hairline); border-radius: 6px; padding: 2px; gap: 2px; } .checkpoint-btn { background: none; border: none; color: var(--ink-subtle); font-family: var(--font-mono); font-size: 11px; font-weight: 600; padding: 4px 10px; border-radius: 4px; cursor: pointer; transition: all 0.15s ease; } .checkpoint-btn.active { background: var(--surface-2); color: #fff; border: 1px solid var(--hairline); } .checkpoint-btn:hover:not(.active) { color: var(--ink); } ``` -------------------------------- ### Render Results with CSS.escape Source: https://github.com/heman10x-ngu/verdict-open-jev/blob/main/webgpu-demo/index.html Updates the candidate list and policy display based on inference results. Uses CSS.escape for secure DOM queries and updates the status dot, latency badge, and telemetry summary. ```javascript function renderResults(candidates, selected, selectedProb, isAbstention, isAutonomous, policyAction, timings, receipt) { latestReceipt = receipt; statusDot.className = "status-dot active"; latencyBadge.textContent = `${timings.total_end_to_end.toFixed(1)}ms`; statusText.textContent = formatTimingLabel(timings, receipt); telemetrySummary.textContent = `Tokens: ${receipt.input_token_count} • T: ${receipt.calibration.temperature.toFixed(2)}`; // Keyed update of candidate rows using CSS.escape const items = candidateList.querySelectorAll(".candidate-item"); items.forEach(item => { const candId = item.getAttribute("data-cand-id"); const candData = candidates.find(c => c.id === candId); if (candData) { const isTop = candId === selected.id; const pct = (candData.prob * 100).toFixed(1); item.classList.toggle("winner", isTop); const safeId = CSS.escape(candId); const badge = item.querySelector(`[data-badge-id="${safeId}"]`); const bar = item.querySelector(`[data-bar-id="${safeId}"]`); if (badge) badge.textContent = `${pct}%`; if (bar) bar.style.width = `${pct}%`; } }); const threshold = parseFloat(thresholdSlider.value); updatePolicyDisplay(selected, selectedProb, isAbstention, threshold); } ``` -------------------------------- ### CSS Design Tokens and Base Styles Source: https://github.com/heman10x-ngu/verdict-open-jev/blob/main/webgpu-demo/index.html Defines the Linear Design System tokens (colors, fonts, radii) and base element styles for the page, including body layout, selection color, and the playground container. ```css :root { --canvas: #010102; --surface-1: #0f1011; --surface-2: #141516; --surface-3: #18191a; --surface-input: #0a0b0d; --hairline: #23252a; --hairline-strong: #34343a; --hairline-focus: #5e6ad2; --ink: #f7f8f8; --ink-muted: #d0d6e0; --ink-subtle: #8a8f98; --ink-tertiary: #62666d; --accent: #5e6ad2; --accent-hover: #717de6; --accent-subtle: rgba(94, 106, 210, 0.14); --emerald: #10b981; --emerald-subtle: rgba(16, 185, 129, 0.12); --amber: #f59e0b; --amber-subtle: rgba(245, 158, 11, 0.12); --rose: #ef4444; --rose-subtle: rgba(239, 68, 68, 0.12); --font-sans: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif; --font-mono: 'JetBrains Mono', 'SF Mono', Menlo, Consolas, monospace; --radius: 8px; --radius-sm: 5px; --top-bezel: inset 0 1px 0 0 rgba(255, 255, 255, 0.05); } * { box-sizing: border-box; margin: 0; padding: 0; } ::selection { background: var(--accent); color: #fff; } body { background-color: var(--canvas); color: var(--ink); font-family: var(--font-sans); font-size: 13.5px; line-height: 1.5; min-height: 100vh; display: flex; justify-content: center; padding: 24px 16px 48px; -webkit-font-smoothing: antialiased; -moz-osx-font-smoothing: grayscale; } .playground { width: 100%; max-width: 920px; display: flex; flex-direction: column; gap: 14px; } ``` -------------------------------- ### Keyboard shortcut: Cmd+Enter Source: https://github.com/heman10x-ngu/verdict-open-jev/blob/main/webgpu-demo/index.html Triggers inference when Cmd+Enter (or Ctrl+Enter) is pressed. ```javascript window.addEventListener("keydown", (e) => { if ((e.metaKey || e.ctrlKey) && e.key === "Enter") { e.preventDefault(); triggerInference(); } }); ``` -------------------------------- ### Format Timing Label Source: https://github.com/heman10x-ngu/verdict-open-jev/blob/main/webgpu-demo/index.html Formats a timing label for the forward pass, including backend, precision, median, and range. Used in the status line to show performance metrics. ```javascript function formatTimingLabel(timings, receipt) { const backend = receipt.execution_backend || "unknown backend"; const precision = receipt.model_precision || "unknown precision"; const median = typeof timings.p50_ms === "number" ? timings.p50_ms : timings.forward_readback; const runs = timings.runs || 1; let label = `Forward pass ${median.toFixed(1)}ms median of ${runs} (${backend}, ${precision})`; if (typeof timings.min_ms === "number" && typeof timings.max_ms === "number") { label += ` · ${timings.min_ms.toFixed(1)} to ${timings.max_ms.toFixed(1)}ms`; } return label; } ``` -------------------------------- ### Slider input handler for policy threshold Source: https://github.com/heman10x-ngu/verdict-open-jev/blob/main/webgpu-demo/index.html Handles changes to the threshold slider, updating the latest receipt's policy properties and setting the route subtext. Shows a deterministic gate message when no receipt exists yet. ```javascript latestReceipt.selected.probability, latestReceipt.selected.is_abstention, val); if (latestReceipt.policy) { latestReceipt.policy.threshold = val; latestReceipt.policy.is_autonomous = !latestReceipt.selected.is_abstention && latestReceipt.selected.probability >= val; latestReceipt.policy.action = latestReceipt.selected.is_abstention ? "route_tier1_support" : (latestReceipt.policy.is_autonomous ? `execute_${latestReceipt.selected.id}` : "escalate_supervisor_review"); } } else { routeSubText.textContent = `Deterministic policy gate set to τ = ${val.toFixed(2)} • Click 'Run Inference' to evaluate`; } }); ``` -------------------------------- ### SVG icon constants Source: https://github.com/heman10x-ngu/verdict-open-jev/blob/main/webgpu-demo/index.html Defines inline SVG icon strings for alert and clipboard icons used in the copy feedback. ```javascript const ICON_ALERT = ''; ``` ```javascript const ICON_CLIPBOARD = ''; ``` -------------------------------- ### Threshold Slider Input Handler Source: https://github.com/heman10x-ngu/verdict-open-jev/blob/main/webgpu-demo/index.html Listens to threshold slider input, updates readout, and triggers policy display update if evaluation receipt exists. ```javascript thresholdSlider.addEventListener("input", (e) => { const val = parseFloat(e.target.value); thresholdReadout.textContent = val.toFixed(2); if (latestReceipt && latestReceipt.selected) { updatePolicyDisplay(latestReceipt.selected, ``` -------------------------------- ### Shuffle Candidate Order Source: https://github.com/heman10x-ngu/verdict-open-jev/blob/main/webgpu-demo/index.html Shuffles non-abstention candidates using Fisher-Yates, preserving abstention position. Resets evaluation state to demonstrate order invariance. ```javascript btnShuffleCand.addEventListener("click", () => { if (activeCandidates.length <= 2) return; // Find abstention candidate explicitly const abstainIdx = activeCandidates.findIndex(c => c.id === "__insufficient_evidence__"); let abstainCand = null; let nonAbstain = [...activeCandidates]; if (abstainIdx !== -1) { abstainCand = nonAbstain.splice(abstainIdx, 1)[0]; } // Fisher-Yates shuffle on non-abstention candidates for (let i = nonAbstain.length - 1; i > 0; i--) { const j = Math.floor(Math.random() * (i + 1)); [nonAbstain[i], nonAbstain[j]] = [nonAbstain[j], nonAbstain[i]]; } if (abstainCand) { nonAbstain.push(abstainCand); } activeCandidates = nonAbstain; renderCandidates(); if (latestReceipt) { resetEvaluationState("Candidate order shuffled • Click 'Run Inference' to verify order invariance"); } }); ``` -------------------------------- ### Update Policy Display Source: https://github.com/heman10x-ngu/verdict-open-jev/blob/main/webgpu-demo/index.html Updates the route badge and text based on whether the model abstained, met the threshold, or fell below it. Handles three cases: explicit abstention, auto-execute, and human-review escalation. ```javascript function updatePolicyDisplay(selected, selectedProb, isAbstention, threshold) { const selectedPct = (selectedProb * 100).toFixed(1); const threshPct = (threshold * 100).toFixed(0); if (isAbstention) { routeBadge.className = "route-badge fallback"; routeMainText.textContent = "ROUTE-TO-FALLBACK"; routeSubText.textContent = `Explicit Abstention (${selectedPct}%) → Dispatched to Triage Queue`; } else if (selectedProb >= threshold) { routeBadge.className = "route-badge auto"; routeMainText.textContent = `AUTO-EXECUTE (Action: ${selected.id})`; routeSubText.textContent = `Calibrated confidence ${selectedPct}% ≥ ${threshPct}% policy gate`; } else { routeBadge.className = "route-badge escalate"; routeMainText.textContent = `HUMAN-REVIEW / ESCALATE`; routeSubText.textContent = `Confidence ${selectedPct}% < ${threshPct}% threshold → Reviewer Queue`; } } ``` -------------------------------- ### WebWorker Message Handling for Inference Source: https://github.com/heman10x-ngu/verdict-open-jev/blob/main/webgpu-demo/index.html Handles worker messages for progress, ready, result, and error states. Updates UI elements like status text, progress bar, and buttons. Executes pending inference when the engine is ready. ```javascript worker.onmessage = (e) => { const { type, backend, message, stage, percent, candidates, selected, selectedProb, isAbstention, isAutonomous, policyAction, timings, receipt } = e.data; if (type === "PROGRESS") { statusText.textContent = message; statusDot.className = "status-dot downloading"; if (percent !== undefined && percent !== null) { topProgressFill.style.width = `${percent}%`; } if (!isWorkerReady && !pendingInference) { const actionText = stage === "downloading_weights" ? "Downloading weights..." : "Compiling shaders..."; btnRunInfer.innerHTML = `${escapeHtml(actionText)}⌘ ↵`; } } else if (type === "READY") { isWorkerReady = true; activeBackendName = backend || activeBackendName; hardwareBadge.textContent = backend === "WebGPU" ? "● WebGPU Active" : "● WASM Active"; hardwareBadge.className = backend === "WebGPU" ? "badge gpu" : "badge wasm"; statusDot.className = "status-dot active"; statusText.textContent = IDLE_STATUS_TEXT; topProgressFill.style.width = "100%"; setTimeout(() => { topProgressFill.style.opacity = "0"; }, 600); btnRunInfer.innerHTML = `Run Inference⌘ ↵`; latencyBadge.textContent = "Ready"; // Execute inference ONLY if explicitly queued by user while engine was compiling if (pendingInference) { pendingInference = false; triggerInference(); } } else if (type === "RESULT") { btnRunInfer.innerHTML = `Run Inference⌘ ↵`; renderResults(candidates, selected, selectedProb, isAbstention, isAutonomous, policyAction, timings, receipt); } else if (type === "ERROR" || type === "INFER_ERROR") { btnRunInfer.innerHTML = `Run Inference⌘ ↵`; statusDot.className = "status-dot error"; statusText.textContent = "Engine notice: " + message; console.warn("Worker error:", message); } }; ``` -------------------------------- ### WebWorker Construction Error Handling Source: https://github.com/heman10x-ngu/verdict-open-jev/blob/main/webgpu-demo/index.html Catches errors during worker construction, typically when the page is not served over HTTP. Updates the UI to indicate the HTTP requirement and shows an error status. ```javascript } catch (err) { console.error("Worker construction failed:", err); statusDot.className = "status-dot error"; statusText.textContent = "WebWorker requires HTTP origin (e.g. npx serve or python3 -m http.server)."; hardwareBadge.textContent = "● HTTP Required"; hardwareBadge.className = "badge"; hardwareBadge.style.borderColor = "rgba(239, 68, 68, 0.4)"; hardwareBadge.style.color = "var(--rose)"; hardwareBadge.style.background = "var(--rose-subtle)"; } ``` === COMPLETE CONTENT === This response contains all available snippets from this library. No additional content exists. Do not make further requests.