diff --git a/README.md b/README.md
index ea36a38..7928569 100644
--- a/README.md
+++ b/README.md
@@ -1,5 +1,9 @@
# NetGuardian — Network Diagnostics & Evidence-Based Troubleshooting Platform
+Explore the fictional hotel dashboard on the web app home page after starting NetGuardian. It
+requires no workspace token and uses only simulated observations. See
+[Hospitality IT Operations](docs/product/HOSPITALITY_OPERATIONS.md).
+
**English** · [简体中文](README.zh-CN.md)
NetGuardian helps IT teams investigate why a service is unreachable by checking
@@ -92,7 +96,7 @@ $workspaceToken
uv run --locked python -m scripts.run_windows --migrate
```
-Open [the local dashboard](http://127.0.0.1:3000), enter the test workspace token printed
+Open [the local workspace](http://127.0.0.1:3000/workspace) and enter the test workspace token printed
in PowerShell. The empty origin list lets you explore the UI
without enabling probes. Use a fresh checkout or back up an existing database
before migration. Keep a stable Worker location ID when retaining observations
diff --git a/README.zh-CN.md b/README.zh-CN.md
index ca027d8..2413a3c 100644
--- a/README.zh-CN.md
+++ b/README.zh-CN.md
@@ -84,7 +84,7 @@ $workspaceToken
uv run --locked python -m scripts.run_windows --migrate
```
-打开[本地控制台](http://127.0.0.1:3000),输入 PowerShell 显示的测试工作区令牌。目标白名单为空时可以浏览界面。请使用全新检出目录,或在迁移前备份现有数据库。如果要跨会话保留观测并进行比较,请保持 Worker 位置标识稳定。
+打开[本地工作区](http://127.0.0.1:3000/workspace),输入 PowerShell 显示的测试工作区令牌。目标白名单为空时可以浏览界面。请使用全新检出目录,或在迁移前备份现有数据库。如果要跨会话保留观测并进行比较,请保持 Worker 位置标识稳定。
[本地开发与 Agent 注册指南](docs/operations/LOCAL_DEVELOPMENT.md) · [就绪检查、备份与故障排查手册](docs/operations/RUNBOOK.md)
diff --git a/docs/operations/LOCAL_DEVELOPMENT.md b/docs/operations/LOCAL_DEVELOPMENT.md
index 77d3d35..11b7cb8 100644
--- a/docs/operations/LOCAL_DEVELOPMENT.md
+++ b/docs/operations/LOCAL_DEVELOPMENT.md
@@ -59,7 +59,7 @@ pnpm install --frozen-lockfile
pnpm dev
```
-Open [the local interface](http://127.0.0.1:3000) and enter the workspace token.
+Open [the local workspace](http://127.0.0.1:3000/workspace) and enter the workspace token.
The Web proxy uses `http://127.0.0.1:8000` by default. Override `NETGUARDIAN_API_URL`
only with a trusted API origin. Browser users cannot select the proxy destination.
The API buffers at most 64 KiB per request before JSON parsing, with a 10-second
diff --git a/docs/operations/RUNBOOK.md b/docs/operations/RUNBOOK.md
index cb0edc8..fcfda7b 100644
--- a/docs/operations/RUNBOOK.md
+++ b/docs/operations/RUNBOOK.md
@@ -11,7 +11,7 @@ PostgreSQL password or percent-encode URL-reserved characters in the connection
Run `docker compose config --quiet`, then `docker compose up --build -d`.
The migration service completes before API startup; worker and web wait for API health.
-Open http://127.0.0.1:3000 and enter a configured workspace token. PostgreSQL has no host
+Open http://127.0.0.1:3000/workspace and enter a configured workspace token. PostgreSQL has no host
port. `docker compose down` stops services while retaining the database volume.
Do not use `down -v` unless intentionally deleting all stored data.
diff --git a/docs/product/HOSPITALITY_OPERATIONS.md b/docs/product/HOSPITALITY_OPERATIONS.md
new file mode 100644
index 0000000..b6c63d2
--- /dev/null
+++ b/docs/product/HOSPITALITY_OPERATIONS.md
@@ -0,0 +1,47 @@
+# Hospitality IT operations UI
+
+Open the home page (or /demo) to explore Aster Quay Hotel without a token. Every asset, connection,
+incident and observation on that route is simulated. The route uses a checked-in
+fixture and has no API client, credential state, or control actions. The /workspace
+route is the authenticated workspace. Credentials stay in its component memory,
+and navigating away aborts its in-flight requests.
+
+## Data and display
+
+- The workspace overview uses the existing monitor and incident list endpoints.
+ Trends use the selected monitor's existing runs endpoint on request. A probe
+ outcome is current only if its run matches the latest job ID in a current
+ collection snapshot. An earlier point remains historical evidence.
+- Device online status is unknown because there is no device uptime telemetry.
+ Probe completion, endpoint response and collection freshness are independent.
+ HEAD 2xx–3xx describes endpoint response, while business workflow availability
+ remains unknown without a representative transaction check. A received 503 can
+ coexist with a successful transport probe and current collection.
+- The charts use server job creation time in the workspace and sample timestamps
+ in the demo. No observation is plotted as a gap. A 0% sample is an observed
+ HTTP response outside the configured success range. The samples do not estimate
+ full-period uptime. HTTP duration and ICMP RTT have separate metric labels.
+- The demo's React Flow map depicts configured logical links. A keyboard asset
+ selector provides access to the same details as pointer selection.
+- Layered diagnostics read the existing Measurement contract. The existing
+ monitor history, investigation and evidence report views remain available.
+ Generic errors are not assigned to a particular network layer. Raw evidence
+ stays available alongside hypotheses and next checks.
+
+## Connecting an authorized property
+
+Start with an operator-approved list of targets and probe types. Configure exact
+allowed origins for the workspace and enroll an Agent only if the target can
+also be authorized by the Agent's local policy. Keep credentials out of UI code
+and public data. Verify collection from the intended vantage before creating
+schedules. Current target restrictions still apply, including restrictions on
+private and special addresses. Do not widen them to make private hotel targets
+work. A future private-network design should define isolated and explicitly
+scoped Agent policy, audit and egress controls before enabling such targets.
+
+For real topology, add a private, authenticated asset configuration tied to the
+workspace, with explicit monitor-to-asset mappings and reviewed logical links.
+Keep the public scenario separate. Device uptime and business transaction checks
+need their own contracts, sampling policies and permission reviews. Avoid
+sending guest data, payment records or real infrastructure identifiers to the
+demo or model.
diff --git a/packaging/source-files.txt b/packaging/source-files.txt
index 4acfd67..1729484 100644
--- a/packaging/source-files.txt
+++ b/packaging/source-files.txt
@@ -98,3 +98,15 @@ packaging/README.md
docs/product/ACCEPTANCE_MATRIX.md
legacy_v2.py
.streamlit/config.toml
+web/app/demo/page.tsx
+web/app/demo/hospitality-dashboard.tsx
+web/app/workspace/page.tsx
+web/app/demo/scenario.ts
+web/app/demo/topology.tsx
+web/app/operations.css
+web/app/operations/diagnostic-layers.tsx
+web/app/operations/theme.tsx
+web/app/operations/trend.tsx
+web/app/operations/workspace-dashboard.tsx
+web/lib/operations.ts
+docs/product/HOSPITALITY_OPERATIONS.md
diff --git a/web/app/demo/hospitality-dashboard.tsx b/web/app/demo/hospitality-dashboard.tsx
new file mode 100644
index 0000000..2b3e4f2
--- /dev/null
+++ b/web/app/demo/hospitality-dashboard.tsx
@@ -0,0 +1,79 @@
+import Link from "next/link";
+import {formatUtc} from "../../lib/time.mjs";
+import {endpointStatus, observationStatus} from "../../lib/operations";
+import DiagnosticLayers from "../operations/diagnostic-layers";
+import ThemeControl from "../operations/theme";
+import Trend from "../operations/trend";
+import Topology from "./topology";
+import {assets, diagnostic, incidents, property, runs, snapshot} from "./scenario";
+import "@xyflow/react/dist/style.css";
+
+const services = [
+ {name: "Guest Wi-Fi portal", zone: "Guest network", probe: "Succeeded", endpoint: "Responding", freshness: "Current"},
+ {name: "Front desk system", zone: "Front office", probe: "Succeeded", endpoint: "Responding", freshness: "Current"},
+ {name: "POS endpoint", zone: "Food & beverage", probe: observationStatus(runs.at(-1)), endpoint: endpointStatus(runs.at(-1)), freshness: "Current"},
+ {name: "Office services", zone: "Back office", probe: "Unknown", endpoint: "Unknown", freshness: "Stale"},
+];
+
+export default function HospitalityDashboard() {
+ return
+
+
+
+ DEMO / SIMULATED Fictional property and assets · Snapshot {formatUtc(snapshot)}
+
+ Monitored devices / services {assets.filter(asset => asset.monitor !== "Unmonitored").length} Configured sample assets
+ Active incidents {incidents.filter(incident => incident.state === "Open").length} POS endpoint HTTP 503
+ Current collection {assets.filter(asset => asset.monitor === "Current").length} 1 stale monitored segment
+ Device online status Unknown No device uptime telemetry
+
+
+ ({
+ id: run.id, time: run.created_at, value: run.http_status == null ? null : run.http_status < 400 ? 100 : 0,
+ detail: run.http_status == null ? undefined : `HTTP ${run.http_status}`,
+ }))}/>
+ ({
+ id: run.id, time: run.created_at, value: run.timings.http_total_ms ?? null,
+ detail: run.http_status == null ? undefined : `HTTP ${run.http_status}`,
+ }))}/>
+
+ Business Service Health
+ Endpoint checks measure the HEAD response. Business workflow availability: Unknown (no transaction checks).
+ Service Zone Probe Endpoint Collection
+ {services.map(service => {service.name} {service.zone}
+ {service.probe} {service.endpoint} {service.freshness} )}
+
+
+
+ Recent Incident Timeline
+ {incidents.map(incident =>
+ {incident.state}
+
{incident.title} {incident.id} · {formatUtc(incident.time)}
+ {incident.asset === "pos" && Inspect evidence }
+ )}
+
+ POS troubleshooting
+ SIMULATED · POS endpoint · {formatUtc(snapshot)}
+
+
+ NetGuardian · Hospitality IT Operations Demo
+
+
;
+}
diff --git a/web/app/demo/page.tsx b/web/app/demo/page.tsx
new file mode 100644
index 0000000..0a4def4
--- /dev/null
+++ b/web/app/demo/page.tsx
@@ -0,0 +1 @@
+export {default} from "./hospitality-dashboard";
diff --git a/web/app/demo/scenario.ts b/web/app/demo/scenario.ts
new file mode 100644
index 0000000..12e27ef
--- /dev/null
+++ b/web/app/demo/scenario.ts
@@ -0,0 +1,44 @@
+import type {LayerInput, Observation} from "../../lib/operations";
+
+export const property = "Aster Quay Hotel";
+export const snapshot = "2026-10-14T10:45:00Z";
+
+export const assets = [
+ {id: "internet", name: "Internet uplink", type: "External service", zone: "WAN", x: 230, y: 0, monitor: "Unmonitored"},
+ {id: "gateway", parent: "internet", name: "Gateway / Firewall", type: "Firewall", zone: "Edge", x: 230, y: 75, monitor: "Current"},
+ {id: "core", parent: "gateway", name: "Core switch", type: "Switch", zone: "Distribution", x: 230, y: 150, monitor: "Current"},
+ {id: "access", parent: "core", name: "Access network", type: "Logical segment", zone: "Access", x: 230, y: 225, monitor: "Unmonitored"},
+ {id: "guest", parent: "access", name: "Guest Wi-Fi", type: "Wireless service", zone: "Guest", x: 0, y: 310, monitor: "Current"},
+ {id: "desk", parent: "access", name: "Front desk", type: "Business service", zone: "Front office", x: 155, y: 310, monitor: "Current"},
+ {id: "pos", parent: "access", name: "POS terminals", type: "Business service", zone: "Food & beverage", x: 310, y: 310, monitor: "Current"},
+ {id: "office", parent: "access", name: "Office LAN", type: "Logical segment", zone: "Back office", x: 465, y: 310, monitor: "Stale"},
+];
+
+export const incidents = [
+ {id: "DEMO-104", asset: "pos", state: "Open", title: "POS endpoint returns HTTP 503", time: "2026-10-14T10:15:00Z"},
+ {id: "DEMO-103", asset: "guest", state: "Resolved", title: "Guest portal endpoint recovered", time: "2026-10-14T08:30:00Z"},
+];
+
+const elapsed = [74, 83, 78, 96, 82, 91, 86, 79, 93, 85, 118, 153, 161, 137, 148, 152];
+export const runs: Observation[] = elapsed.map((ms, index) => ({
+ id: `demo-run-${index}`,
+ created_at: new Date(Date.parse(snapshot) - (elapsed.length - 1 - index) * 300000).toISOString(),
+ status: index === 6 ? null : "success",
+ http_status: index === 6 ? null : index >= 9 ? 503 : 204,
+ timings: {http_total_ms: index === 6 ? null : ms, tcp_connect_ms: index === 6 ? null : 8 + index % 5},
+}));
+
+export const diagnostic: LayerInput = {
+ kind: "http", target: "https://pos.aster-quay.example", connected_ip: "192.0.2.10",
+ timings: {dns_lookup_ms: 7, tcp_connect_ms: 8, tls_handshake_ms: 31, http_total_ms: 152},
+ dns: {used_dns: true, answers: [{record_type: "A", addresses: ["192.0.2.10"],
+ ttl_seconds: 60, canonical_name: "pos.aster-quay.example"}]},
+ tls: {protocol: "TLSv1.3", cipher: "TLS_AES_128_GCM_SHA256", cipher_bits: 128,
+ hostname_verified: true, leaf_sha256: "0".repeat(64), not_before: "2026-10-01T00:00:00Z", not_after: "2027-01-01T00:00:00Z"},
+ http_status: 503,
+};
+
+export function assetObservation(id: string) {
+ if (id === "office") return "2026-10-14T07:00:00Z";
+ return assets.find(asset => asset.id === id)?.monitor === "Current" ? snapshot : null;
+}
diff --git a/web/app/demo/topology.tsx b/web/app/demo/topology.tsx
new file mode 100644
index 0000000..608de54
--- /dev/null
+++ b/web/app/demo/topology.tsx
@@ -0,0 +1,59 @@
+"use client";
+import {useState} from "react";
+import {Background, Controls, ReactFlow, type Node, type NodeProps, Handle, Position} from "@xyflow/react";
+import {formatUtc} from "../../lib/time.mjs";
+import {assets, assetObservation, incidents} from "./scenario";
+
+type AssetNode = Node<{label: string; monitoring: string}, "asset">;
+
+function Asset({data, selected}: NodeProps) {
+ return
+
+ {data.label} {data.monitoring}
+
+
;
+}
+
+const nodeTypes = {asset: Asset};
+const edges = assets.flatMap(asset => asset.parent
+ ? [{id: `${asset.parent}-${asset.id}`, source: asset.parent, target: asset.id, type: "smoothstep"}] : []);
+
+export default function Topology() {
+ const [id, setId] = useState("pos");
+ const selected = assets.find(asset => asset.id === id)!;
+ const observed = assetObservation(id);
+ const related = incidents.filter(incident => incident.asset === id);
+ const nodes: AssetNode[] = assets.map(asset => ({
+ id: asset.id, type: "asset", position: {x: asset.x, y: asset.y},
+ data: {label: asset.name, monitoring: asset.monitor},
+ ariaLabel: `${asset.name}, ${asset.monitor}`, selected: asset.id === id,
+ }));
+ return
+ Network topology
+ SIMULATED · Configured logical links
+
+
+ setId(node.id)} zoomOnScroll={false} panOnScroll={false}
+ colorMode="system">
+
+
+
+
+
Inspect asset setId(event.target.value)}>
+ {assets.map(asset => {asset.name} )}
+
+
+ Asset name {selected.name}
+ Asset type {selected.type}
+ Zone {selected.zone}
+ Monitoring status {selected.monitor}
+ Last observation {observed ? formatUtc(observed) : "No Data"}
+ Related incidents {related.length ? related.map(incident =>
+ {incident.id} · {incident.state} ) : "None recorded"}
+
+
+
+ ;
+}
diff --git a/web/app/layout.tsx b/web/app/layout.tsx
index 938dd3e..c605d47 100644
--- a/web/app/layout.tsx
+++ b/web/app/layout.tsx
@@ -1,5 +1,6 @@
import type { Metadata } from "next";
import "./globals.css";
+import "./operations.css";
export const metadata: Metadata = { title: "NetGuardian — Network observability", description: "Evidence-based network diagnostics" };
export default function Layout({children}: Readonly<{children: React.ReactNode}>) {
return {children};
diff --git a/web/app/monitor-history.tsx b/web/app/monitor-history.tsx
index e4321e4..35fbc97 100644
--- a/web/app/monitor-history.tsx
+++ b/web/app/monitor-history.tsx
@@ -3,9 +3,10 @@ import {formatUtc,formatUtcTime} from "../lib/time.mjs";
import {useState} from "react";
export type MonitorHistory = {monitor_id:string;name:string;runs:{id:string;created_at:string;state:string;status:string|null;http_status:number|null;timings:Record}[]};
-const metrics = ["dns_lookup_ms", "tcp_connect_ms", "tls_handshake_ms", "http_ttfb_ms", "http_total_ms", "icmp_rtt_ms"];
+import {metricLabels} from "../lib/operations";
+const metrics = Object.keys(metricLabels) as (keyof typeof metricLabels)[];
export default function MonitorHistoryPanel({history,onClose,onInspect}:{history:MonitorHistory;onClose:()=>void;onInspect:(id:string)=>void}) {
- const [metric,setMetric]=useState("http_total_ms");
+ const [metric,setMetric]=useState("http_total_ms");
const runs=history.runs;
const points=runs.flatMap(run=>{
const value=run.timings[metric];const time=Date.parse(run.created_at);
@@ -16,14 +17,14 @@ export default function MonitorHistoryPanel({history,onClose,onInspect}:{history
const maximum=Math.max(1,...points.map(p=>p.value));
return
Monitor history: {history.name} Close history
Latest 100 scheduled runs. Time axis uses server job creation time. Missing values are absent, never zero; points are not joined across gaps.
- Timing metricsetMetric(e.target.value)}>{metrics.map(m=>{m.replaceAll("_"," ")} )}
- {points.length?<>
+ Timing metricsetMetric(e.target.value as keyof typeof metricLabels)}>{metrics.map(m=>{metricLabels[m]} )}
+ {points.length?<>
{maximum.toFixed(1)} ms 0 ms
{points.map(p=>{formatUtc(p.time)}: {p.value} ms · {p.run.status} )}
{formatUtcTime(start)} {formatUtcTime(end)}
Timing is not a health verdict; failed requests may have partial timing evidence.
>:No recorded values for this metric.
}
- Created Job / outcome HTTP {metric.replaceAll("_"," ")} Evidence {runs.map(run=>{formatUtc(run.created_at)} {run.state} / {run.status??"No measurement"} {run.http_status??"—"} {run.timings[metric] == null?"Missing":`${run.timings[metric]} ms`} onInspect(run.id)}>Inspect )}
+ Created Job / outcome HTTP {metricLabels[metric]} Evidence {runs.map(run=>{formatUtc(run.created_at)} {run.state} / {run.status??"No measurement"} {run.http_status??"—"} {run.timings[metric] == null?"Missing":`${run.timings[metric]} ms`} onInspect(run.id)}>Inspect )}
{!runs.length&&No scheduled runs yet.
}
;
}
diff --git a/web/app/operations.css b/web/app/operations.css
new file mode 100644
index 0000000..0bd43d9
--- /dev/null
+++ b/web/app/operations.css
@@ -0,0 +1,134 @@
+/* Shared surface, text and status tokens for both application modes. */
+:root {
+ color-scheme: light;
+ --canvas: #eef3f8;
+ --surface: #fff;
+ --subtle: #f6f8fc;
+ --ink: #172841;
+ --muted: #50647e;
+ --line: #d4deeb;
+ --accent: #176765;
+ --chart: #25847f;
+ --good-bg: #e3f5ee;
+ --good-ink: #1c644d;
+ --bad-bg: #fbe8e7;
+ --bad-ink: #8a322d;
+ --warn-bg: #ffefcd;
+ --warn-ink: #6b450c;
+}
+
+@media (prefers-color-scheme: dark) {
+ :root:not([data-theme="light"]) {
+ color-scheme: dark;
+ --canvas: #0d1726; --surface: #142235; --subtle: #192b41; --ink: #edf4ff;
+ --muted: #b0c0d6; --line: #344762; --accent: #72dbce; --chart: #58c5b6;
+ --good-bg: #173a34; --good-ink: #9ce6cc; --bad-bg: #48292f; --bad-ink: #ffc0bd;
+ --warn-bg: #47351f; --warn-ink: #ffdc99;
+ }
+}
+
+:root[data-theme="dark"] {
+ color-scheme: dark;
+ --canvas: #0d1726; --surface: #142235; --subtle: #192b41; --ink: #edf4ff;
+ --muted: #b0c0d6; --line: #344762; --accent: #72dbce; --chart: #58c5b6;
+ --good-bg: #173a34; --good-ink: #9ce6cc; --bad-bg: #48292f; --bad-ink: #ffc0bd;
+ --warn-bg: #47351f; --warn-ink: #ffdc99;
+}
+
+body {background: var(--canvas); color: var(--ink); font-family: Inter, "Segoe UI", Arial, sans-serif}
+a {color: var(--accent); text-underline-offset: 3px}
+a:focus-visible, summary:focus-visible, button:focus-visible, input:focus, select:focus {
+ outline: 2px solid var(--accent); outline-offset: 3px
+}
+header, th, td, .record {border-color: var(--line)}
+button, input, select, .panel, .stats section {background: var(--surface); color: var(--ink); border-color: var(--line)}
+.primary {background: #146660; color: #fff; border-color: #146660}
+th, .badge {background: var(--subtle); color: var(--ink)}
+.hint, .empty, footer, .stats span, .stats small, .toolbar, .record p,
+.login p, .timings span, header .eyebrow, .ops-muted {color: var(--muted)}
+.error {background: var(--bad-bg); color: var(--bad-ink)}
+svg text {fill: currentColor}
+.ops-theme {align-self: center; color: var(--muted)}
+.ops-theme select {min-width: 0; padding: 5px 8px}
+.ops-shell aside {background: #101f34; overflow: auto}
+.ops-shell aside a {color: #c8daed}
+.ops-shell aside .eyebrow {color: #a0b5ce}
+.ops-shell nav a {display: block; padding: 9px 12px; margin: 3px 0; border-radius: 6px; text-decoration: none}
+.ops-shell nav a.active, .ops-shell nav a:hover {background: #243b55; color: #e9fffc}
+.ops-shell aside a:focus-visible {outline-color: #83decb}
+.ops-main {padding-top: 24px}
+.ops-main header h1 {font-size: clamp(25px, 4vw, 38px)}
+.ops-main header p {margin-bottom: 0}
+.ops-demo-banner {display: flex; flex-wrap: wrap; align-items: center; gap: 6px 14px; margin: 16px 0; padding: 9px 12px; background: var(--warn-bg); color: var(--warn-ink); border-radius: 8px}
+.ops-demo-banner strong {font-size: 12px; letter-spacing: .06em}
+.ops-kpis, .ops-grid {display: grid; gap: 14px; margin: 14px 0}
+.ops-kpis {grid-template-columns: repeat(4, minmax(0, 1fr))}
+.ops-grid {grid-template-columns: repeat(2, minmax(0, 1fr))}
+.ops-card {min-width: 0; background: var(--surface); border: 1px solid var(--line); border-radius: 10px; padding: 17px; margin: 14px 0}
+.ops-kpis .ops-card, .ops-grid .ops-card {margin: 0}
+.ops-kpis strong {display: block; font-size: 30px; line-height: 1.3; margin: 4px 0}
+.ops-kpis .ops-kpi-text {font-size: 22px; margin-top: 11px}
+.ops-kpis small, .ops-incident small, .ops-target {color: var(--muted)}
+.ops-target {display: block; overflow-wrap: anywhere}
+.ops-card h2, .ops-workspace h2 {margin: 0 0 4px}
+.ops-card > p {margin: 0 0 12px}
+.ops-empty {color: var(--muted); padding: 18px 0}
+.ops-plot {display: flex; gap: 8px; height: 117px}
+.ops-scale {font-size: 11px; color: var(--muted); display: grid; align-content: space-between; white-space: nowrap}
+.ops-bars {display: flex; flex: 1; gap: 3px; border-bottom: 1px solid var(--line); background: repeating-linear-gradient(to top, var(--line) 0 1px, transparent 1px 33.33%); min-width: 0}
+.ops-bars button {min-width: 0; flex: 1; display: flex; align-items: end; background: transparent; padding: 0; border: 0; border-radius: 2px}
+.ops-bars span {width: 100%; display: block; background: var(--chart); border-radius: 3px 3px 0 0; pointer-events: none}
+.ops-bars .ops-bar-failed span {background: var(--bad-ink)}
+.ops-bars button[aria-pressed="true"] {box-shadow: inset 0 0 0 1px var(--accent); background: var(--subtle)}
+.ops-axis {display: flex; justify-content: space-between; color: var(--muted); font-size: 11px; padding-top: 5px}
+.ops-trend .ops-point {margin: 10px 0 0; font-size: 12px; min-height: 2lh}
+.ops-chip {display: inline-block; padding: 3px 8px; border-radius: 5px; background: var(--subtle); white-space: nowrap}
+.ops-critical {color: var(--bad-ink); background: var(--bad-bg)}
+.ops-positive {color: var(--good-ink); background: var(--good-bg)}
+.ops-topology {display: grid; grid-template-columns: minmax(0, 3fr) minmax(170px, 1fr); gap: 14px}
+.ops-flow {height: 400px; min-width: 0; border: 1px solid var(--line); border-radius: 8px; background: var(--subtle); overflow: hidden}
+.ops-flow .react-flow {--xy-edge-stroke-default: var(--muted); --xy-background-pattern-dots-color-default: var(--line)}
+.ops-node {width: 132px; padding: 8px 5px; text-align: center; background: var(--surface); color: var(--ink); border: 1px solid var(--line); border-radius: 6px; font-size: 12px}
+.ops-node small, .ops-layers span {display: block; color: var(--muted)}
+.ops-node-selected {border: 2px solid var(--accent)}
+.ops-node-detail, .ops-layers > div {background: var(--subtle); border: 1px solid var(--line); border-radius: 8px; padding: 12px; min-width: 0}
+.ops-node-detail select {width: 100%; min-width: 0}
+.ops-node-detail dd, .ops-facts dd {margin: 0 0 8px; overflow-wrap: anywhere}
+.ops-node-detail dt, .ops-facts dt {font-weight: 600}
+.ops-node-detail dd a {display: block}
+.ops-incident {display: flex; align-items: center; flex-wrap: wrap; gap: 10px; padding: 10px 0; border-bottom: 1px solid var(--line)}
+.ops-incident a {margin-left: auto}
+.ops-workspace > .ops-card:last-child > button {margin-top: 12px}
+.ops-diagnosis {margin: 12px 0}
+.ops-layers {display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 8px; margin-top: 8px}
+.ops-layers small {overflow-wrap: anywhere; color: var(--bad-ink)}
+summary {cursor: pointer}
+@media (max-width: 1050px) {.ops-kpis {grid-template-columns: repeat(2, minmax(0, 1fr))}}
+@media (max-width: 660px) {
+ .ops-grid, .ops-topology {grid-template-columns: minmax(0, 1fr)}
+ .ops-flow {height: 330px}
+ .ops-layers {grid-template-columns: repeat(2, minmax(0, 1fr))}
+ .ops-shell .aside-bottom {display: block; margin-top: 8px}
+ header {gap: 8px}
+ .probe-form label:first-child {min-width: min(240px, 100%)}
+ input, select {max-width: 100%}
+}
+@media (max-width: 375px) {
+ .ops-kpis {gap: 8px}
+ .ops-card {padding: 12px}
+}
+
+.ops-scale > span {display: block}
+.ops-shell nav button[aria-current="page"] {font-weight: 700}
+.ops-flow .react-flow__controls-button {background: var(--surface); color: var(--ink); border-color: var(--line)}
+.ops-flow .react-flow__controls-button:hover {background: var(--subtle)}
+.ops-flow .react-flow__attribution {background: var(--surface)}
+.ops-flow .react-flow__attribution a {color: var(--muted)}
+@media (max-width: 900px) {.ops-shell .aside-bottom {display: block; margin-top: 8px}}
+.ops-header-actions {display: flex; align-items: end; gap: 10px; flex-wrap: wrap}
+.ops-workspace-link {display: inline-block; padding: 5px 10px; border: 1px solid var(--accent); border-radius: 5px; font-weight: 600; text-decoration: none}
+.ops-workspace-link:hover {background: var(--subtle)}
+@media (max-width: 540px) {
+ .ops-main header:has(.ops-header-actions) {flex-wrap: wrap}
+ .ops-header-actions {width: 100%; justify-content: space-between}
+}
diff --git a/web/app/operations/diagnostic-layers.tsx b/web/app/operations/diagnostic-layers.tsx
new file mode 100644
index 0000000..18c3ff8
--- /dev/null
+++ b/web/app/operations/diagnostic-layers.tsx
@@ -0,0 +1,27 @@
+import {diagnosticGuidance, diagnosticLayers, type LayerInput} from "../../lib/operations";
+
+export default function DiagnosticLayers({result, raw = result}: {result: LayerInput; raw?: unknown}) {
+ const layers = diagnosticLayers(result);
+ if (!layers.length) return null;
+ const guidance = diagnosticGuidance(result);
+ const next = layers.find(layer => layer.error)
+ ?? (result.error ? undefined : layers.find(layer => layer.status === "No evidence"));
+ return
+ Layered diagnostic evidence
+ {layers.map(layer =>
+ {layer.name} {layer.status}
+ {layer.duration == null ? "No timing" : `${layer.duration.toFixed(2)} ms`}
+ {layer.error && {layer.error.replaceAll("_", " ")} }
+
)}
+
+ Observed facts {result.error
+ ? `${result.error.code.replaceAll("_", " ")}: ${result.error.message}`
+ : result.http_status != null ? `HTTP ${result.http_status} received.` : "See recorded layer evidence."}
+ Possible explanation {guidance ?? "No fault hypothesis from this observation."}
+ Suggested next check {next?.suggestion ?? (result.error
+ ? "Review the recorded probe outcome and repeat only from an authorized vantage."
+ : "Compare with another authorized observation if symptoms persist.")}
+
+ Raw probe evidence (JSON) {JSON.stringify(raw, null, 2)}
+ ;
+}
diff --git a/web/app/operations/theme.tsx b/web/app/operations/theme.tsx
new file mode 100644
index 0000000..4daab0a
--- /dev/null
+++ b/web/app/operations/theme.tsx
@@ -0,0 +1,16 @@
+"use client";
+import {useEffect, useState} from "react";
+
+export default function ThemeControl() {
+ const [theme, setTheme] = useState("system");
+ useEffect(() => setTheme(document.documentElement.dataset.theme ?? 'system'), []);
+ return Theme
+ {
+ const next = event.target.value;
+ setTheme(next);
+ document.documentElement.dataset.theme = next;
+ }}>
+ System Light Dark
+
+ ;
+}
diff --git a/web/app/operations/trend.tsx b/web/app/operations/trend.tsx
new file mode 100644
index 0000000..a0d84d2
--- /dev/null
+++ b/web/app/operations/trend.tsx
@@ -0,0 +1,34 @@
+"use client";
+import {useState} from "react";
+import {formatUtc, formatUtcTime} from "../../lib/time.mjs";
+
+export type Point = {id: string; time: string; value: number | null; detail?: string};
+
+export default function Trend({title, points, unit, ceiling}: {
+ title: string; points: Point[]; unit: string; ceiling?: number;
+}) {
+ const [selected, setSelected] = useState();
+ const visible = points.slice(-24);
+ const max = ceiling ?? Math.max(1, ...visible.map(point => point.value ?? 0));
+ const active = visible.find(point => point.id === selected) ?? visible.at(-1);
+ return
+ {title}
+ {unit === "%" ? "One value per scheduled run" : "Recorded values"} · {visible.length} recent runs
+ {visible.some(point => point.value !== null) ? <>
+
+
{Number(max.toFixed(1))}{unit} 0{unit}
+
+ {visible.map(point => setSelected(point.id)}
+ onClick={() => setSelected(point.id)}
+ className={point.value === 0 && unit === "%" ? "ops-bar-failed" : ""}>
+
+ )}
+
+
+ {formatUtcTime(visible[0].time)} {formatUtcTime(visible.at(-1)!.time)}
+ {active && `${formatUtc(active.time)} · ${active.value == null ? "No data" : `${Number(active.value.toFixed(2))}${unit}`}${active.detail ? ` · ${active.detail}` : ""}`}
+ > : No Data
}
+ ;
+}
diff --git a/web/app/operations/workspace-dashboard.tsx b/web/app/operations/workspace-dashboard.tsx
new file mode 100644
index 0000000..043bd9d
--- /dev/null
+++ b/web/app/operations/workspace-dashboard.tsx
@@ -0,0 +1,85 @@
+"use client";
+import {useState} from "react";
+import {formatUtc} from "../../lib/time.mjs";
+import {currentObservation, endpointStatus, metricLabels, observationStatus} from "../../lib/operations";
+import type {MonitorHistory} from "../monitor-history";
+import Trend from "./trend";
+
+export type DashboardMonitor = {
+ id: string; name: string; target: string; kind: string; enabled: boolean;
+ telemetry: {state: string; latest_job_id: string | null};
+};
+export type DashboardIncident = {
+ id: string; monitor_id: string; state: string; opened_at: string; recovered_at?: string | null;
+};
+
+export default function WorkspaceDashboard({monitors, incidents, history, snapshot, busy, onLoad, onIncidents}: {
+ monitors: DashboardMonitor[]; incidents: DashboardIncident[];
+ history: MonitorHistory | null; snapshot: string | null; busy: boolean;
+ onLoad: (id: string) => void; onIncidents: () => void;
+}) {
+ const [selected, setSelected] = useState("");
+ const [metric, setMetric] = useState("http_total_ms");
+ const runs = selected && history?.monitor_id === selected ? history.runs : [];
+ const active = incidents.filter(incident => incident.state === "open");
+ const totals = [
+ ["Monitored targets / services", snapshot ? new Set(monitors.map(monitor => monitor.target)).size : "Unknown", "Distinct configured origins"],
+ ["Active incidents", snapshot ? active.length : "Unknown", "Among the latest 100 incidents"],
+ ["Current collection", snapshot ? monitors.filter(monitor => monitor.telemetry.state === "current").length : "Unknown", "Current monitor observations"],
+ ["Device online status", "Unknown", "No device uptime telemetry"],
+ ] as const;
+ return
+
Infrastructure Health Overview
+
{snapshot ? `Workspace snapshot · ${formatUtc(snapshot)}` : "No current workspace snapshot."}
+
{totals.map(([label, value, description]) =>
+ {label}
+ {value} {description}
+ )}
+
+ Business Service Health
+ Business workflow availability: Unknown. HEAD checks describe only the configured endpoint. Load a monitor’s history to see its latest matching probe outcome.
+ {!monitors.length ? No Data · No monitors loaded
:
+
Monitor Probe result Endpoint Collection
+ {monitors.map(monitor => {
+ const current = snapshot && selected === monitor.id ? currentObservation(monitor.telemetry, runs) : undefined;
+ return
+ {monitor.name}{monitor.target} · {monitor.kind.toUpperCase()}
+ {observationStatus(current)} {endpointStatus(current)}
+ {snapshot ? monitor.telemetry.state.replaceAll("_", " ") : "Unknown"}
+ ;
+ })}
+
}
+
+
+ Trend scope
+
+ Availability samples show HTTP 2xx–3xx as 100% and other recorded HTTP responses as 0%. Missing responses have no value. Times are job creation times.
+
+
+ ({id: run.id, time: run.created_at,
+ value: run.http_status == null ? null : run.http_status >= 200 && run.http_status < 400 ? 100 : 0,
+ detail: run.http_status == null ? undefined : `HTTP ${run.http_status}`}))}/>
+ ({id: run.id, time: run.created_at, value: run.timings[metric] ?? null}))}/>
+
+
Recent Incident Timeline
+ {!incidents.length ? No recorded incidents in this view.
:
+ incidents.slice(0, 8).map(incident =>
+ {incident.state}
+
{monitors.find(monitor => monitor.id === incident.monitor_id)?.name ?? "Monitor incident"}
+ Opened {formatUtc(incident.opened_at)}{incident.recovered_at && ` · Resolved ${formatUtc(incident.recovered_at)}`}
+ )}
+ Open incident evidence
+
+
;
+}
diff --git a/web/app/page.tsx b/web/app/page.tsx
index 9a91296..9b9fdc6 100644
--- a/web/app/page.tsx
+++ b/web/app/page.tsx
@@ -1,128 +1 @@
-"use client";
-import InvestigationPanel, {type Investigation} from "./investigation-panel";
-import {createDiagnosticClient,type DiagnosticClient,type CreateJob,type JobSummary,type JobDetail} from "../lib/diagnostic-client";
-import {formatUtc} from "../lib/time.mjs";
-import EvidenceReportBody, {type EvidenceReport} from "./evidence-report";
-import MonitorHistoryPanel, {type MonitorHistory} from "./monitor-history";
-import {useCallback, useEffect, useRef, useState} from "react";
-
-type DiagnosticPair = {id:string;cloud_job_id:string;agent_job_id:string;created_at:string};
-type SavedReport = {id:string;incident_id:string;created_at:string;content_hash:string};
-type AuditEvent = {id:string;created_at:string;action:string;resource_id:string;actor_kind:string};
-type InvestigationSummary = {id:string;report_id:string;created_at:string;model:string;status:string};
-type Agent = {id:string;name:string;revoked:boolean;last_seen:string|null};
-type Job = JobSummary;
-type Monitor = {id:string;name:string;target:string;enabled:boolean;interval_seconds:number;failure_count:number;agent_id:string|null;telemetry:{state:string;latest_job_id:string|null}};
-type IncidentHistory = {id:string;after:number;previous:number[];items:{position:number;job_id:string}[];next_after:number|null;limitations:string[]};
-type Incident = {id:string;state:string;opened_at:string;evidence:string[]};
-type Detail = JobDetail;
-export default function Home() {
- const [sessionId,setSessionId]=useState(0);
- return setSessionId(id=>id+1)}/>;
-}
-
-function Workspace({disconnect}:{disconnect:()=>void}) {
- // A new component instance owns every workspace value after disconnect.
- // Late responses can never populate the next session's state.
- const active=useRef(true);
- const pending=useRef(new Set());
- useEffect(()=>{
- active.current=true;
- const requests=pending.current;
- return ()=>{active.current=false;for(const controller of requests)controller.abort();requests.clear()};
- },[]);
- const [incidentHistory,setIncidentHistory]=useState(null);
- const [monitorHistory,setMonitorHistory]=useState(null);
- const [pairs,setPairs]=useState([]);
- const [savedReports,setSavedReports]=useState([]);
- const [auditEvents,setAuditEvents]=useState([]);
- const [investigations,setInvestigations]=useState([]);
- const [agents,setAgents]=useState([]); const [agentId,setAgentId]=useState("");
- const selectedAgentUnavailable=Boolean(agentId)&&!agents.some(a=>a.id===agentId&&!a.revoked);
- const [agentName,setAgentName]=useState(""); const [enrollment,setEnrollment]=useState("");
- const [leftJob,setLeftJob]=useState(""); const [rightJob,setRightJob]=useState("");
- const [comparison,setComparison]=useState(null);
- const [credential,setCredential]=useState(""); const [token,setToken]=useState("");
- const [tab,setTab]=useState("Diagnostics"); const [origins,setOrigins]=useState([]);
- const [target,setTarget]=useState(""); const [kind,setKind]=useState("http");
- const [jobs,setJobs]=useState([]); const [monitors,setMonitors]=useState([]);
- const [incidents,setIncidents]=useState([]); const [detail,setDetail]=useState(null);
- const [error,setError]=useState(""); const [busy,setBusy]=useState(false);
- const [report,setReport]=useState(null);
- const [investigation,setInvestigation]=useState(null);
- const [name,setName]=useState(""); const [interval,setIntervalValue]=useState(60);
- const api=useCallback(async (path:string,method="GET",body?:unknown,raw=false)=>{
- if(!active.current)throw new Error("Workspace disconnected");
- const controller=new AbortController();pending.current.add(controller);
- try {
- const response=await fetch(`/api/backend/${path}`,{method,signal:controller.signal,headers:{Authorization:`Bearer ${token}`,"Content-Type":"application/json"},body:body?JSON.stringify(body):undefined});
- if(!active.current)throw new Error("Workspace disconnected");
- if(response.status===204)return null;
- if(raw&&response.ok){
- const blob=await response.blob();
- if(!active.current)throw new Error("Workspace disconnected");
- return blob;
- }
- const data=await response.json();
- if(!active.current)throw new Error("Workspace disconnected");
- if(!response.ok)throw new Error(typeof data.detail==="string"?data.detail:"Request rejected");
- return data;
- } finally {pending.current.delete(controller)}
- },[token]);
- const diagnosticRequest=useCallback(async (run:(client:DiagnosticClient)=>Promise<{data?:T;error?:unknown;response:Response}>):Promise=>{
- if(!active.current)throw new Error("Workspace disconnected");
- const controller=new AbortController();pending.current.add(controller);
- try {
- const {data,error,response}=await run(createDiagnosticClient(token,controller.signal));
- if(!active.current)throw new Error("Workspace disconnected");
- if(!response.ok){
- const detail=error&&typeof error==="object"&&"detail" in error?error.detail:null;
- throw new Error(typeof detail==="string"?detail:"Request rejected");
- }
- if(data===undefined)throw new Error("Missing diagnostic response");
- return data;
- } finally {pending.current.delete(controller)}
- },[token]);
- const refresh=useCallback(async()=>{
- const [targets,j,m,i,a,investigations,audit,reports,pairs]=await Promise.all([api("targets"),diagnosticRequest(client=>client.GET("/jobs")),api("monitors"),api("incidents"),api("agents"),api("investigations"),api("audit-events"),api("reports"),api("diagnostic-pairs")]);
- if(!active.current)return;
- setOrigins(targets.origins.map(([host,port,scheme]:[string,number,string])=>`${scheme}://${host.includes(":")?`[${host}]`:host}:${port}`));
- setJobs(j);setMonitors(m);setIncidents(i);setAgents(a);setInvestigations(investigations);setAuditEvents(audit);setSavedReports(reports);setPairs(pairs);
- },[api,diagnosticRequest]);
- useEffect(()=>{if(!token)return; let active=true;let refreshing=false;
- const update=async()=>{if(refreshing)return;refreshing=true;try{await refresh()}catch(e){if(active)setError(e instanceof Error?e.message:"Refresh failed")}finally{refreshing=false}};
- void update();const timer=setInterval(update,5000);return()=>{active=false;clearInterval(timer)};
- },[token,refresh]);
- async function loadIncidentHistory(id:string,after=0,previous:number[]=[]) {
- const page=await api(`incidents/${id}/evidence?after=${after}&limit=100`);
- setIncidentHistory({...page,id,after,previous});
- }
- async function action(run:()=>Promise){setBusy(true);setError("");try{await run();await refresh()}catch(e){setError(e instanceof Error?e.message:"Request failed")}finally{setBusy(false)}}
- return
-
- {!token?Connect your workspace Enter an administrator-issued access token. It stays in memory and is cleared when this page closes.
:<>
- Measurements describe the selected probe location, which may differ from your browser.
{active.current=false;for(const controller of pending.current)controller.abort();disconnect()}}>Disconnect
- {error&&{error}
}
- Recent diagnostics {jobs.length} Latest 100 jobs Active monitors {monitors.filter(m=>m.enabled).length} Browser-independent schedules Open incidents {incidents.filter(i=>i.state==="open").length} Within latest 100 incidents
- {(tab==="Diagnostics"||tab==="Monitors")&&{tab==="Diagnostics"?"Run a diagnostic":"Create a monitor"} {!origins.length&&No authorized targets. Configure the administrator origin policy before probing.
}HTTP uses HEAD, does not follow redirects, and measures request duration separately from ICMP RTT.
}
- {tab==="Diagnostics"&&Diagnostic history {!jobs.length?No diagnostic records yet.
:Target Probe State Created Evidence {jobs.map(j=>{j.target} {j.kind.toUpperCase()} {j.state} {formatUtc(j.created_at)} void action(async()=>setDetail(await diagnosticRequest(client=>client.GET("/jobs/{job_id}",{params:{path:{job_id:j.id}}}))))}>Inspect )}
} }
- {tab==="Monitors"&&Continuous monitoring Pausing stops new scheduled jobs; already queued or running jobs may finish. Resuming starts a fresh schedule without replaying missed intervals.
{!monitors.length?No monitors configured.
:monitors.map(m=>{m.name} {m.target} · Every {m.interval_seconds}s · {m.failure_count} consecutive failures
Vantage: {m.agent_id?(agents.find(a=>a.id===m.agent_id)?.name||m.agent_id):"Cloud worker"}
Collection: {m.telemetry.state.replaceAll("_"," ")} (not target health)
void action(async()=>{setMonitorHistory(await api(`monitors/${m.id}/runs`))})}>View history void action(async()=>{await api(`monitors/${m.id}`,"PATCH",{enabled:!m.enabled})})}>{m.enabled?"Pause":"Resume"} )} }
- {tab==="Incidents"&&Incident timeline {!incidents.length?No recorded incidents. This is not proof that every target is healthy.
:incidents.map(i=>{i.state.toUpperCase()} {formatUtc(i.opened_at)}
{i.evidence.length} observations in the latest summary
void action(()=>loadIncidentHistory(i.id))}>Browse retained history void action(async()=>{const created=await api("reports","POST",{incident_id:i.id});setReport(await api(`reports/${created.id}`))})}>Create evidence report void action(async()=>{const latest=i.evidence.at(-1);if(latest)setDetail(await diagnosticRequest(client=>client.GET("/jobs/{job_id}",{params:{path:{job_id:latest}}})))})}>{i.evidence.length?"Inspect latest evidence":"No linked evidence"} )} }
- {tab==="Agents"&&Local agents Agents connect over outbound HTTPS and enforce their own local target policy.
{enrollment&&Single-use token · expires in 10 minutes. Enter it in the agent enrollment prompt.
{enrollment}setEnrollment("")}>Hide token
}{!agents.length?No agents enrolled yet.
:agents.map(a=>{a.name} {a.revoked?"Revoked":a.last_seen?`Last seen ${formatUtc(a.last_seen)}`:"Not yet connected"}
void action(async()=>{await api(`agents/${a.id}`,"DELETE")})}>Revoke )} }
- {tab==="Compare"&&Start cloud and local diagnostics Both tasks use the same target and probe configuration. Execution is asynchronous; results more than 30 seconds apart cannot be compared.
}
- {tab==="Compare"&&Saved diagnostic pairs Latest 100 pairs. Membership is preserved across reloads; it does not guarantee comparable results.
{pairs.length===0?No recorded pairs yet.
:pairs.map(pair=>{formatUtc(pair.created_at)} Cloud {pair.cloud_job_id} · Agent {pair.agent_job_id}
void action(async()=>{setLeftJob(pair.cloud_job_id);setRightJob(pair.agent_job_id);setComparison(null);setComparison(await api("comparisons","POST",{left_job_id:pair.cloud_job_id,right_job_id:pair.agent_job_id}))})}>Compare pair )} }
- {tab==="Compare"&&Compare recorded observations Choose measurements from distinct vantages. Incompatible observations show explicit limitations.
{comparison!==null&&{JSON.stringify(comparison,null,2)} } }
- {tab==="Reports"&&Saved evidence reports Latest 100 immutable snapshots. Opening a report verifies its checksum; listing its stored digest does not verify content.
{!savedReports.length?No saved reports. Create one from the incident timeline.
:savedReports.map(item=>{formatUtc(item.created_at)} Incident {item.incident_id}
SHA-256 {item.content_hash}
void action(async()=>{setReport(await api(`reports/${item.id}`))})}>Open report )} }
- {tab==="Audit"&&Operator audit history Latest 100 recorded operations. Roles do not identify individual people. This log is not a tamper-proof ledger.
{!auditEvents.length?No audited operations recorded.
:auditEvents.map(event=>{event.action} {formatUtc(event.created_at)} · {event.actor_kind.replaceAll("_"," ")}
Resource {event.resource_id}
)} }
- {tab==="Investigations"&&Investigation history Latest 100 saved investigations. Reopening a record does not call the model again.
{!investigations.length?No saved investigations. Create an evidence report from an incident to start.
:investigations.map(item=>{item.status.replaceAll("_"," ")} {item.model} · {formatUtc(item.created_at)}
Report {item.report_id}
void action(async()=>{setInvestigation(await api(`investigations/${item.id}`))})}>View investigation void action(async()=>{setReport(await api(`reports/${item.report_id}`))})}>View source report )} }
- {monitorHistory&&setMonitorHistory(null)} onInspect={id=>void action(async()=>setDetail(await diagnosticRequest(client=>client.GET("/jobs/{job_id}",{params:{path:{job_id:id}}}))))}/>}
- {incidentHistory&&
Retained incident history setIncidentHistory(null)}>Close history Incident {incidentHistory.id}
Up to 100 links per page, oldest first. A link may have no available measurement.
{incidentHistory.limitations.map(text=>{text}
)}{incidentHistory.items.length===0?No retained links on this page.
:incidentHistory.items.map(item=>#{item.position} · {item.job_id}
void action(async()=>{setDetail(null);setDetail(await diagnosticRequest(client=>client.GET("/jobs/{job_id}",{params:{path:{job_id:item.job_id}}})))})}>Inspect observation )}void action(()=>loadIncidentHistory(incidentHistory.id,incidentHistory.previous.at(-1)!,incidentHistory.previous.slice(0,-1)))}>Previous page void action(()=>loadIncidentHistory(incidentHistory.id,incidentHistory.next_after!,[...incidentHistory.previous,incidentHistory.after]))}>Next page
}
- {detail&&
Recorded evidence setDetail(null)}>Close Job {detail.id} · {detail.state}
{detail.result?<>{detail.result.target} · {detail.result.status}
Observed: {formatUtc(detail.result.observed_at)} · Probe location: {detail.result.vantage_id}
Received by server: {detail.result.received_at?formatUtc(detail.result.received_at):"Not recorded"}. Observation and server clocks may differ; this is not a network latency measurement.
Probe version: {detail.result.probe_version} · Attempt: {detail.result.attempt} · Schema: {detail.result.schema_version}
Measurement identity Policy version: {detail.result.policy_version}
Configuration SHA-256: {detail.result.configuration_hash}
{detail.result.error&&{detail.result.error.code.replaceAll("_"," ")} : {detail.result.error.message}{detail.result.error.tls_verify_code!=null&&<> · TLS verification code: {detail.result.error.tls_verify_code}>}
}{Object.entries(detail.result.timings??{}).filter(([,v])=>typeof v==="number").map(([k,v])=>
{k.replaceAll("_"," ")} {v?.toFixed(2)} ms
)}
{detail.result.dns&&DNS evidence {!detail.result.dns.used_dns?
IP literal: no DNS query was performed.
:<>
Resolver cache state is unknown; TTL is the value observed in the response.
{detail.result.dns.answers.map(a=>
{a.record_type} {a.addresses.join(", ")}
Canonical name: {a.canonical_name} · TTL: {a.ttl_seconds} seconds
Resolver: {a.resolver??"Not recorded"} · Port: {a.resolver_port??"Not recorded"}
)}>}
}{detail.result.tls&&TLS evidence {detail.result.tls.protocol} · {detail.result.tls.cipher} · {detail.result.tls.cipher_bits} bits
Certificate validity: {formatUtc(detail.result.tls.not_before)} — {formatUtc(detail.result.tls.not_after)}
Hostname and trust verified by the probe runtime.
Leaf SHA-256: {detail.result.tls.leaf_sha256}
}{detail.result.system_probe&&Method: {detail.result.system_probe.method} · Destination reached: {detail.result.system_probe.destination_reached?"Yes":"Not established"}
{detail.result.system_probe.rtt_samples.map((r,index)=>
ICMP RTT: {r.upper_bound?"<":""}{r.milliseconds} ms
)}{detail.result.system_probe.hops.length>0&&
Hop Addresses RTT samples Missing replies {detail.result.system_probe.hops.map(h=>{h.hop} {h.addresses.join(", ")||"Unknown"} {h.rtt_samples.map(r=>`${r.upper_bound?"<":""}${r.milliseconds} ms`).join(", ")||"No response"} {h.missing_replies} )}
}
}Connected IP: {detail.result.connected_ip||"Not connected"} · HTTP status: {detail.result.http_status??"Not applicable"}
>:{["queued","running"].includes(detail.state)?"Waiting for the assigned probe to return a measurement. Use Inspect again to refresh.":"No measurement is available for this task. Its task state does not establish target health."}
} }
- {report!==null&&Evidence report Stored snapshot checksum: {report.integrity}. This is not a digital signature or proof of measurement accuracy.
void action(async()=>{setInvestigation(await api("investigations","POST",{report_id:report.id}))})}>Investigate with AI void action(async()=>{const blob=await api(`reports/${report.id}`,"GET",undefined,true);const url=URL.createObjectURL(blob);const link=document.createElement("a");link.href=url;link.download="netguardian-report.json";document.body.appendChild(link);link.click();link.remove();setTimeout(()=>URL.revokeObjectURL(url),1000)})}>Download JSON setReport(null)}>Close }
- {investigation!==null&&setInvestigation(null)} onSource={()=>void action(async()=>setReport(await api(`reports/${investigation.report_id}`)))}/>}
- >}NetGuardian · Recorded evidence, explicit limitations. ;
-}
+export {default} from "./demo/hospitality-dashboard";
diff --git a/web/app/workspace/page.tsx b/web/app/workspace/page.tsx
new file mode 100644
index 0000000..cb6e0a3
--- /dev/null
+++ b/web/app/workspace/page.tsx
@@ -0,0 +1,134 @@
+"use client";
+import Link from "next/link";
+import DiagnosticLayers from "../operations/diagnostic-layers";
+import ThemeControl from "../operations/theme";
+import WorkspaceDashboard, {type DashboardMonitor,type DashboardIncident} from "../operations/workspace-dashboard";
+import InvestigationPanel, {type Investigation} from "../investigation-panel";
+import {createDiagnosticClient,type DiagnosticClient,type CreateJob,type JobSummary,type JobDetail} from "../../lib/diagnostic-client";
+import {formatUtc} from "../../lib/time.mjs";
+import EvidenceReportBody, {type EvidenceReport} from "../evidence-report";
+import MonitorHistoryPanel, {type MonitorHistory} from "../monitor-history";
+import {useCallback, useEffect, useRef, useState} from "react";
+
+type DiagnosticPair = {id:string;cloud_job_id:string;agent_job_id:string;created_at:string};
+type SavedReport = {id:string;incident_id:string;created_at:string;content_hash:string};
+type AuditEvent = {id:string;created_at:string;action:string;resource_id:string;actor_kind:string};
+type InvestigationSummary = {id:string;report_id:string;created_at:string;model:string;status:string};
+type Agent = {id:string;name:string;revoked:boolean;last_seen:string|null};
+type Job = JobSummary;
+type Monitor = DashboardMonitor & {interval_seconds:number;failure_count:number;agent_id:string|null};
+type IncidentHistory = {id:string;after:number;previous:number[];items:{position:number;job_id:string}[];next_after:number|null;limitations:string[]};
+type Incident = DashboardIncident & {evidence:string[]};
+type Detail = JobDetail;
+export default function Home() {
+ const [sessionId,setSessionId]=useState(0);
+ return setSessionId(id=>id+1)}/>;
+}
+
+function Workspace({disconnect}:{disconnect:()=>void}) {
+ // A new component instance owns every workspace value after disconnect.
+ // Late responses can never populate the next session's state.
+ const active=useRef(true);
+ const pending=useRef(new Set());
+ useEffect(()=>{
+ active.current=true;
+ const requests=pending.current;
+ return ()=>{active.current=false;for(const controller of requests)controller.abort();requests.clear()};
+ },[]);
+ const [incidentHistory,setIncidentHistory]=useState(null);
+ const [monitorHistory,setMonitorHistory]=useState(null);
+ const [pairs,setPairs]=useState([]);
+ const [savedReports,setSavedReports]=useState([]);
+ const [auditEvents,setAuditEvents]=useState([]);
+ const [investigations,setInvestigations]=useState([]);
+ const [agents,setAgents]=useState([]); const [agentId,setAgentId]=useState("");
+ const selectedAgentUnavailable=Boolean(agentId)&&!agents.some(a=>a.id===agentId&&!a.revoked);
+ const [agentName,setAgentName]=useState(""); const [enrollment,setEnrollment]=useState("");
+ const [leftJob,setLeftJob]=useState(""); const [rightJob,setRightJob]=useState("");
+ const [comparison,setComparison]=useState(null);
+ const [credential,setCredential]=useState(""); const [token,setToken]=useState("");
+ const [snapshot,setSnapshot]=useState(null);
+ const [trendHistory,setTrendHistory]=useState(null);
+ const [tab,setTab]=useState("Overview"); const [origins,setOrigins]=useState([]);
+ const [target,setTarget]=useState(""); const [kind,setKind]=useState("http");
+ const [jobs,setJobs]=useState([]); const [monitors,setMonitors]=useState([]);
+ const [incidents,setIncidents]=useState([]); const [detail,setDetail]=useState(null);
+ const [error,setError]=useState(""); const [busy,setBusy]=useState(false);
+ const [report,setReport]=useState(null);
+ const [investigation,setInvestigation]=useState(null);
+ const [name,setName]=useState(""); const [interval,setIntervalValue]=useState(60);
+ const api=useCallback(async (path:string,method="GET",body?:unknown,raw=false)=>{
+ if(!active.current)throw new Error("Workspace disconnected");
+ const controller=new AbortController();pending.current.add(controller);
+ try {
+ const response=await fetch(`/api/backend/${path}`,{method,signal:controller.signal,headers:{Authorization:`Bearer ${token}`,"Content-Type":"application/json"},body:body?JSON.stringify(body):undefined});
+ if(!active.current)throw new Error("Workspace disconnected");
+ if(response.status===204)return null;
+ if(raw&&response.ok){
+ const blob=await response.blob();
+ if(!active.current)throw new Error("Workspace disconnected");
+ return blob;
+ }
+ const data=await response.json();
+ if(!active.current)throw new Error("Workspace disconnected");
+ if(!response.ok)throw new Error(typeof data.detail==="string"?data.detail:"Request rejected");
+ return data;
+ } finally {pending.current.delete(controller)}
+ },[token]);
+ const diagnosticRequest=useCallback(async (run:(client:DiagnosticClient)=>Promise<{data?:T;error?:unknown;response:Response}>):Promise=>{
+ if(!active.current)throw new Error("Workspace disconnected");
+ const controller=new AbortController();pending.current.add(controller);
+ try {
+ const {data,error,response}=await run(createDiagnosticClient(token,controller.signal));
+ if(!active.current)throw new Error("Workspace disconnected");
+ if(!response.ok){
+ const detail=error&&typeof error==="object"&&"detail" in error?error.detail:null;
+ throw new Error(typeof detail==="string"?detail:"Request rejected");
+ }
+ if(data===undefined)throw new Error("Missing diagnostic response");
+ return data;
+ } finally {pending.current.delete(controller)}
+ },[token]);
+ const refresh=useCallback(async()=>{
+ const [targets,j,m,i,a,investigations,audit,reports,pairs]=await Promise.all([api("targets"),diagnosticRequest(client=>client.GET("/jobs")),api("monitors"),api("incidents"),api("agents"),api("investigations"),api("audit-events"),api("reports"),api("diagnostic-pairs")]);
+ if(!active.current)return;
+ setOrigins(targets.origins.map(([host,port,scheme]:[string,number,string])=>`${scheme}://${host.includes(":")?`[${host}]`:host}:${port}`));
+ setSnapshot(new Date().toISOString());setJobs(j);setMonitors(m);setIncidents(i);setAgents(a);setInvestigations(investigations);setAuditEvents(audit);setSavedReports(reports);setPairs(pairs);
+ },[api,diagnosticRequest]);
+ useEffect(()=>{if(!token)return; let active=true;let refreshing=false;
+ const update=async()=>{if(refreshing)return;refreshing=true;try{await refresh()}catch(e){if(active){setSnapshot(null);setError(e instanceof Error?e.message:"Refresh failed")}}finally{refreshing=false}};
+ void update();const timer=setInterval(update,5000);return()=>{active=false;clearInterval(timer)};
+ },[token,refresh]);
+ async function loadIncidentHistory(id:string,after=0,previous:number[]=[]) {
+ const page=await api(`incidents/${id}/evidence?after=${after}&limit=100`);
+ setIncidentHistory({...page,id,after,previous});
+ }
+ async function action(run:()=>Promise){setBusy(true);setError("");try{await run();await refresh()}catch(e){setError(e instanceof Error?e.message:"Request failed")}finally{setBusy(false)}}
+ return
+
+ {!token?Connect your workspace Explore the hospitality demo · No token required
Enter an administrator-issued access token. It stays in memory and is cleared when this page closes.
:<>
+ Measurements describe the selected probe location, which may differ from your browser.
{active.current=false;for(const controller of pending.current)controller.abort();disconnect()}}>Disconnect
+ {error&&{error}
}
+ {tab==="Overview"?void action(async()=>setTrendHistory(await api(`monitors/${id}/runs`)))} onIncidents={()=>setTab("Incidents")}/>:Recent diagnostics {jobs.length} Latest 100 jobs Active monitors {monitors.filter(m=>m.enabled).length} Browser-independent schedules Open incidents {incidents.filter(i=>i.state==="open").length} Within latest 100 incidents
}
+ {(tab==="Diagnostics"||tab==="Monitors")&&{tab==="Diagnostics"?"Run a diagnostic":"Create a monitor"} {!origins.length&&No authorized targets. Configure the administrator origin policy before probing.
}HTTP uses HEAD, does not follow redirects, and measures request duration separately from ICMP RTT.
}
+ {tab==="Diagnostics"&&Diagnostic history {!jobs.length?No diagnostic records yet.
:Target Probe State Created Evidence {jobs.map(j=>{j.target} {j.kind.toUpperCase()} {j.state} {formatUtc(j.created_at)} void action(async()=>setDetail(await diagnosticRequest(client=>client.GET("/jobs/{job_id}",{params:{path:{job_id:j.id}}}))))}>Inspect )}
} }
+ {tab==="Monitors"&&Continuous monitoring Pausing stops new scheduled jobs; already queued or running jobs may finish. Resuming starts a fresh schedule without replaying missed intervals.
{!monitors.length?No monitors configured.
:monitors.map(m=>{m.name} {m.target} · Every {m.interval_seconds}s · {m.failure_count} consecutive failures
Vantage: {m.agent_id?(agents.find(a=>a.id===m.agent_id)?.name||m.agent_id):"Cloud worker"}
Collection: {m.telemetry.state.replaceAll("_"," ")} (not target health)
void action(async()=>{setMonitorHistory(await api(`monitors/${m.id}/runs`))})}>View history void action(async()=>{await api(`monitors/${m.id}`,"PATCH",{enabled:!m.enabled})})}>{m.enabled?"Pause":"Resume"} )} }
+ {tab==="Incidents"&&Incident timeline {!incidents.length?No recorded incidents. This is not proof that every target is healthy.
:incidents.map(i=>{i.state.toUpperCase()} {formatUtc(i.opened_at)}
{i.evidence.length} observations in the latest summary
void action(()=>loadIncidentHistory(i.id))}>Browse retained history void action(async()=>{const created=await api("reports","POST",{incident_id:i.id});setReport(await api(`reports/${created.id}`))})}>Create evidence report void action(async()=>{const latest=i.evidence.at(-1);if(latest)setDetail(await diagnosticRequest(client=>client.GET("/jobs/{job_id}",{params:{path:{job_id:latest}}})))})}>{i.evidence.length?"Inspect latest evidence":"No linked evidence"} )} }
+ {tab==="Agents"&&Local agents Agents connect over outbound HTTPS and enforce their own local target policy.
{enrollment&&Single-use token · expires in 10 minutes. Enter it in the agent enrollment prompt.
{enrollment}setEnrollment("")}>Hide token
}{!agents.length?No agents enrolled yet.
:agents.map(a=>{a.name} {a.revoked?"Revoked":a.last_seen?`Last seen ${formatUtc(a.last_seen)}`:"Not yet connected"}
void action(async()=>{await api(`agents/${a.id}`,"DELETE")})}>Revoke )} }
+ {tab==="Compare"&&Start cloud and local diagnostics Both tasks use the same target and probe configuration. Execution is asynchronous; results more than 30 seconds apart cannot be compared.
}
+ {tab==="Compare"&&Saved diagnostic pairs Latest 100 pairs. Membership is preserved across reloads; it does not guarantee comparable results.
{pairs.length===0?No recorded pairs yet.
:pairs.map(pair=>{formatUtc(pair.created_at)} Cloud {pair.cloud_job_id} · Agent {pair.agent_job_id}
void action(async()=>{setLeftJob(pair.cloud_job_id);setRightJob(pair.agent_job_id);setComparison(null);setComparison(await api("comparisons","POST",{left_job_id:pair.cloud_job_id,right_job_id:pair.agent_job_id}))})}>Compare pair )} }
+ {tab==="Compare"&&Compare recorded observations Choose measurements from distinct vantages. Incompatible observations show explicit limitations.
{comparison!==null&&{JSON.stringify(comparison,null,2)} } }
+ {tab==="Reports"&&Saved evidence reports Latest 100 immutable snapshots. Opening a report verifies its checksum; listing its stored digest does not verify content.
{!savedReports.length?No saved reports. Create one from the incident timeline.
:savedReports.map(item=>{formatUtc(item.created_at)} Incident {item.incident_id}
SHA-256 {item.content_hash}
void action(async()=>{setReport(await api(`reports/${item.id}`))})}>Open report )} }
+ {tab==="Audit"&&Operator audit history Latest 100 recorded operations. Roles do not identify individual people. This log is not a tamper-proof ledger.
{!auditEvents.length?No audited operations recorded.
:auditEvents.map(event=>{event.action} {formatUtc(event.created_at)} · {event.actor_kind.replaceAll("_"," ")}
Resource {event.resource_id}
)} }
+ {tab==="Investigations"&&Investigation history Latest 100 saved investigations. Reopening a record does not call the model again.
{!investigations.length?No saved investigations. Create an evidence report from an incident to start.
:investigations.map(item=>{item.status.replaceAll("_"," ")} {item.model} · {formatUtc(item.created_at)}
Report {item.report_id}
void action(async()=>{setInvestigation(await api(`investigations/${item.id}`))})}>View investigation void action(async()=>{setReport(await api(`reports/${item.report_id}`))})}>View source report )} }
+ {monitorHistory&&setMonitorHistory(null)} onInspect={id=>void action(async()=>setDetail(await diagnosticRequest(client=>client.GET("/jobs/{job_id}",{params:{path:{job_id:id}}}))))}/>}
+ {incidentHistory&&
Retained incident history setIncidentHistory(null)}>Close history Incident {incidentHistory.id}
Up to 100 links per page, oldest first. A link may have no available measurement.
{incidentHistory.limitations.map(text=>{text}
)}{incidentHistory.items.length===0?No retained links on this page.
:incidentHistory.items.map(item=>#{item.position} · {item.job_id}
void action(async()=>{setDetail(null);setDetail(await diagnosticRequest(client=>client.GET("/jobs/{job_id}",{params:{path:{job_id:item.job_id}}})))})}>Inspect observation )}void action(()=>loadIncidentHistory(incidentHistory.id,incidentHistory.previous.at(-1)!,incidentHistory.previous.slice(0,-1)))}>Previous page void action(()=>loadIncidentHistory(incidentHistory.id,incidentHistory.next_after!,[...incidentHistory.previous,incidentHistory.after]))}>Next page
}
+ {detail&&
Recorded evidence setDetail(null)}>Close Job {detail.id} · {detail.state}
{detail.result?<>{detail.result.target} · {detail.result.status}
Observed: {formatUtc(detail.result.observed_at)} · Probe location: {detail.result.vantage_id}
Received by server: {detail.result.received_at?formatUtc(detail.result.received_at):"Not recorded"}. Observation and server clocks may differ; this is not a network latency measurement.
Probe version: {detail.result.probe_version} · Attempt: {detail.result.attempt} · Schema: {detail.result.schema_version}
Measurement identity Policy version: {detail.result.policy_version}
Configuration SHA-256: {detail.result.configuration_hash}
{detail.result.error&&{detail.result.error.code.replaceAll("_"," ")} : {detail.result.error.message}{detail.result.error.tls_verify_code!=null&&<> · TLS verification code: {detail.result.error.tls_verify_code}>}
}{Object.entries(detail.result.timings??{}).filter(([,v])=>typeof v==="number").map(([k,v])=>
{k.replaceAll("_"," ")} {v?.toFixed(2)} ms
)}
{detail.result.dns&&DNS evidence {!detail.result.dns.used_dns?
IP literal: no DNS query was performed.
:<>
Resolver cache state is unknown; TTL is the value observed in the response.
{detail.result.dns.answers.map(a=>
{a.record_type} {a.addresses.join(", ")}
Canonical name: {a.canonical_name} · TTL: {a.ttl_seconds} seconds
Resolver: {a.resolver??"Not recorded"} · Port: {a.resolver_port??"Not recorded"}
)}>}
}{detail.result.tls&&TLS evidence {detail.result.tls.protocol} · {detail.result.tls.cipher} · {detail.result.tls.cipher_bits} bits
Certificate validity: {formatUtc(detail.result.tls.not_before)} — {formatUtc(detail.result.tls.not_after)}
Hostname and trust verified by the probe runtime.
Leaf SHA-256: {detail.result.tls.leaf_sha256}
}{detail.result.system_probe&&Method: {detail.result.system_probe.method} · Destination reached: {detail.result.system_probe.destination_reached?"Yes":"Not established"}
{detail.result.system_probe.rtt_samples.map((r,index)=>
ICMP RTT: {r.upper_bound?"<":""}{r.milliseconds} ms
)}{detail.result.system_probe.hops.length>0&&
Hop Addresses RTT samples Missing replies {detail.result.system_probe.hops.map(h=>{h.hop} {h.addresses.join(", ")||"Unknown"} {h.rtt_samples.map(r=>`${r.upper_bound?"<":""}${r.milliseconds} ms`).join(", ")||"No response"} {h.missing_replies} )}
}
}Connected IP: {detail.result.connected_ip||"Not connected"} · HTTP status: {detail.result.http_status??"Not applicable"}
>:{["queued","running"].includes(detail.state)?"Waiting for the assigned probe to return a measurement. Use Inspect again to refresh.":"No measurement is available for this task. Its task state does not establish target health."}
} }
+ {report!==null&&Evidence report Stored snapshot checksum: {report.integrity}. This is not a digital signature or proof of measurement accuracy.
void action(async()=>{setInvestigation(await api("investigations","POST",{report_id:report.id}))})}>Investigate with AI void action(async()=>{const blob=await api(`reports/${report.id}`,"GET",undefined,true);const url=URL.createObjectURL(blob);const link=document.createElement("a");link.href=url;link.download="netguardian-report.json";document.body.appendChild(link);link.click();link.remove();setTimeout(()=>URL.revokeObjectURL(url),1000)})}>Download JSON setReport(null)}>Close }
+ {investigation!==null&&setInvestigation(null)} onSource={()=>void action(async()=>setReport(await api(`reports/${investigation.report_id}`)))}/>}
+ >}NetGuardian · Recorded evidence, explicit limitations. ;
+}
diff --git a/web/lib/operations.ts b/web/lib/operations.ts
new file mode 100644
index 0000000..b515ba3
--- /dev/null
+++ b/web/lib/operations.ts
@@ -0,0 +1,97 @@
+import type {JobDetail} from "./diagnostic-client";
+
+export type Observation = {
+ id: string;
+ created_at: string;
+ status: string | null;
+ http_status: number | null;
+ timings: Record;
+};
+
+export function observationStatus(run: Observation | undefined) {
+ if (!run?.status || !["success", "error", "timeout"].includes(run.status)) return "Unknown";
+ return run.status === "success" ? "Succeeded" : "Failed";
+}
+
+export function endpointStatus(run: Observation | undefined) {
+ if (!run || run.status !== "success" || run.http_status == null) return "Unknown";
+ return run.http_status >= 200 && run.http_status < 400 ? "Responding" : "HTTP failure";
+}
+
+export function currentObservation(
+ telemetry: {state: string; latest_job_id: string | null},
+ runs: Observation[],
+) {
+ return telemetry.state === "current"
+ ? runs.find(run => run.id === telemetry.latest_job_id)
+ : undefined;
+}
+
+export const metricLabels = {
+ dns_lookup_ms: "DNS lookup",
+ tcp_connect_ms: "TCP connect",
+ tls_handshake_ms: "TLS handshake",
+ http_ttfb_ms: "HTTP time to first byte",
+ http_total_ms: "HTTP total request",
+ icmp_rtt_ms: "ICMP round-trip time",
+};
+
+export type LayerInput = Pick,
+ "target" | "kind" | "dns" | "tls" | "timings" | "connected_ip" | "http_status" | "error">;
+
+const checks = [
+ {name: "DNS", metric: "dns_lookup_ms", suggestion: "Check resolver reachability and compare A and AAAA answers from the same probe location."},
+ {name: "TCP", metric: "tcp_connect_ms", suggestion: "Verify the service is listening on the approved port and review firewall rules from this probe location."},
+ {name: "TLS", metric: "tls_handshake_ms", suggestion: "Check certificate hostname, validity, trust chain and probe clock."},
+ {name: "HTTP", metric: "http_total_ms", suggestion: "Compare the HEAD response with an authorized application check and review service logs."},
+] as const;
+
+export function diagnosticLayers(result: LayerInput) {
+ const requested = ["dns", "tcp", "tls", "http"].indexOf(result.kind);
+ if (requested < 0) return [];
+ const timing = result.timings;
+ const skipped = [
+ result.dns?.used_dns === false,
+ false,
+ result.kind === "http" && result.target.startsWith("http://"),
+ false,
+ ];
+ const evidence = [
+ Boolean(result.dns?.answers.length || timing?.dns_lookup_ms != null),
+ Boolean(result.connected_ip || timing?.tcp_connect_ms != null),
+ Boolean(result.tls),
+ result.http_status != null,
+ ];
+ const explicitError = result.error?.code === "resolution_failed" ? 0
+ : result.error?.code === "tls_verification_failed" ? 2 : -1;
+ return checks.map((check, index) => {
+ const httpFailure = index === 3 && result.http_status != null && result.http_status >= 400;
+ const status = index > requested ? "Not requested" : skipped[index] ? "Skipped"
+ : index === explicitError ? "Failed" : httpFailure ? "HTTP failure"
+ : evidence[index] ? "Observed" : "No evidence";
+ return {
+ ...check,
+ status,
+ duration: timing?.[check.metric],
+ error: index === explicitError ? result.error?.code
+ : httpFailure ? `HTTP ${result.http_status}` : undefined,
+ };
+ });
+}
+
+export function diagnosticGuidance(result: LayerInput) {
+ switch (result.error?.code) {
+ case "resolution_failed": return "Resolver reachability or a missing DNS record may explain the failed lookup.";
+ case "tls_verification_failed": return "A hostname mismatch, expired certificate or trust-chain issue may explain the verification failure.";
+ case "timeout":
+ case "transport_error": return "Routing, filtering or an unresponsive service may explain the interruption. The error does not identify a specific layer.";
+ case "policy_denied": return "The target or its resolved address may be outside the approved policy. Review the authorization and recorded addresses before retrying.";
+ case "unsupported":
+ case "cancelled": return "Probe execution did not establish a network or service fault.";
+ }
+ if (result.http_status != null && result.http_status >= 500)
+ return "The application or an upstream dependency may be failing. The HTTP response alone does not identify which component.";
+ if (result.http_status != null && result.http_status >= 400)
+ return "The endpoint may reject HEAD, require credentials or have a route mismatch.";
+ return null;
+}
diff --git a/web/package.json b/web/package.json
index ef3737e..b53ddc3 100644
--- a/web/package.json
+++ b/web/package.json
@@ -11,6 +11,7 @@
"generate:api": "openapi-typescript openapi.json -o lib/api-schema.d.ts"
},
"dependencies": {
+ "@xyflow/react": "12.12.1",
"next": "^16.0.0",
"openapi-fetch": "0.17.0",
"react": "^19.0.0",
diff --git a/web/pnpm-lock.yaml b/web/pnpm-lock.yaml
index e6f27d9..ac98084 100644
--- a/web/pnpm-lock.yaml
+++ b/web/pnpm-lock.yaml
@@ -8,6 +8,9 @@ importers:
.:
dependencies:
+ '@xyflow/react':
+ specifier: 12.12.1
+ version: 12.12.1(@types/react-dom@19.3.0(@types/react@19.3.0))(@types/react@19.3.0)(react-dom@19.3.1(react@19.3.1))(react@19.3.1)
next:
specifier: ^16.0.0
version: 16.4.4(@types/node@22.20.5)(react-dom@19.3.1(react@19.3.1))(react@19.3.1)
@@ -280,6 +283,24 @@ packages:
'@swc/helpers@0.5.23':
resolution: {integrity: sha512-5lSsMOTXURePglDfvuAQUqkGek9Hg2kksOYay2m0+XR++b2NWYL/4sWyuvVBIs8oKnJaxkdi9whaL/sqN13afw==}
+ '@types/d3-color@3.1.3':
+ resolution: {integrity: sha512-iO90scth9WAbmgv7ogoq57O9YpKmFBbmoEoCHDB2xMBY0+/KVrqAaCDyCE16dUspeOvIxFFRI+0sEtqDqy2b4A==}
+
+ '@types/d3-drag@3.0.7':
+ resolution: {integrity: sha512-HE3jVKlzU9AaMazNufooRJ5ZpWmLIoc90A37WU2JMmeq28w1FQqCZswHZ3xR+SuxYftzHq6WU6KJHvqxKzTxxQ==}
+
+ '@types/d3-interpolate@3.0.4':
+ resolution: {integrity: sha512-mgLPETlrpVV1YRJIglr4Ez47g7Yxjl1lj7YKsiMCb27VJH9W8NVM6Bb9d8kkpG/uAQS5AmbA48q2IAolKKo1MA==}
+
+ '@types/d3-selection@3.0.12':
+ resolution: {integrity: sha512-Qe/KWYhEiIIxGs7HrAAjMfShxKldx19SJtr5zu53f3afPsdZNz7HHtdTLXo/kqeiWNXVycI24kSnfzBYkTzpgw==}
+
+ '@types/d3-transition@3.0.9':
+ resolution: {integrity: sha512-uZS5shfxzO3rGlu0cC3bjmMFKsXv+SmZZcgp0KD22ts4uGXp5EVYGzu/0YdwZeKmddhcAccYtREJKkPfXkZuCg==}
+
+ '@types/d3-zoom@3.0.9':
+ resolution: {integrity: sha512-0sE1406XBYJGiqD3AusTl9ZqC//2mIXix51tbom25gDCA8ri4xnSZg28CaSE8Srl6FClqABUKfsn0qghgdepMA==}
+
'@types/node@22.20.5':
resolution: {integrity: sha512-U2+DNr+wSjpsTS/wZGYHq7GcwfuSmKiKvoPvK22zwTlRhU91yOniN4qRR5KhIjvif7ysw/dz/hKmfDH0Ris4aA==}
@@ -291,6 +312,22 @@ packages:
'@types/react@19.3.0':
resolution: {integrity: sha512-N0rFCuH9YoxG9/m61l9MfpJKfmLOVU0em7ipIz6TRgSSkvReLB9vL85GB+yr8Bs5leqpvg96JSwF4ZS1s4viQg==}
+ '@xyflow/react@12.12.1':
+ resolution: {integrity: sha512-g41OHmP+GL5wDBQKpgYt8AF6RlB4CrABtiStXhCMqdItK6gPdSpsuDk8V0YtdyvIvMPTjDJvkuLkz0JbSYu5Cw==}
+ peerDependencies:
+ '@types/react': '>=17'
+ '@types/react-dom': '>=17'
+ react: '>=17'
+ react-dom: '>=17'
+ peerDependenciesMeta:
+ '@types/react':
+ optional: true
+ '@types/react-dom':
+ optional: true
+
+ '@xyflow/system@0.0.84':
+ resolution: {integrity: sha512-96zfGFjH3oZ3T0MRdH4gJ0SlXuCIxbBuHVevZ4xry5UTxqjzjt010+LRdholgepq7jhrcaz1JNtzrETscwnkEA==}
+
agent-base@7.1.4:
resolution: {integrity: sha512-MnA+YT8fwfJPgBx3m60MNqakm30XOkyIoH1y6huTQvC0PwZG7ki8NacLBcrPbNoo8vEZy7Jpuk7+jMO+CUovTQ==}
engines: {node: '>= 14'}
@@ -319,6 +356,9 @@ packages:
change-case@5.4.4:
resolution: {integrity: sha512-HRQyTk2/YPEkt9TnUPbOpr64Uw3KOicFWPVBb+xiHvd6eBx/qPr9xqfBFDT8P2vWsvvz4jbEkfDe71W3VyNu2w==}
+ classcat@5.0.5:
+ resolution: {integrity: sha512-JhZUT7JFcQy/EzW605k/ktHtncoo9vnyW/2GspNYwFlN1C/WmjuV/xtS04e9SOkL2sTdw0VAZ2UGCcQ9lR6p6w==}
+
client-only@0.0.1:
resolution: {integrity: sha512-IV3Ou0jSMzZrd3pZ48nLkT9DA7Ag1pnPzaiQhpW7c3RbcqqzvzzVu+L8gfqMp/8IM2MQtSiqaCxrrcfu8I8rMA==}
@@ -328,6 +368,44 @@ packages:
csstype@3.2.3:
resolution: {integrity: sha512-z1HGKcYy2xA8AGQfwrn0PAy+PB7X/GSj3UVJW9qKyn43xWa+gl5nXmU4qqLMRzWVLFC8KusUX8T/0kCiOYpAIQ==}
+ d3-color@3.1.1:
+ resolution: {integrity: sha512-lfab8x0Bj0UO7SNsY8dZSbNIA6ipbkE3X0NG9nqjCu6CfCHZseuDnOSJY7hidKrjpP++i1M2qT+FlAdPKYRilA==}
+ engines: {node: '>=12'}
+
+ d3-dispatch@3.0.2:
+ resolution: {integrity: sha512-sAzH4Y4nsLo8eSqw5jKiZt+LU2wZmL/qS+OkxQGjhwazB/D7TY34R/QK1eshfGr7cZEKymKZ/Haem7m+lu98Sg==}
+ engines: {node: '>=12'}
+
+ d3-drag@3.0.1:
+ resolution: {integrity: sha512-OWeoayCq8J69hUIjvL+Mb6Q6Oaj/fyHV5XaXByEUAG+JUjIfTGDnk3qGpcXrD3VmQ3BSV96fcbM6fqq7C0tbPA==}
+ engines: {node: '>=12'}
+
+ d3-ease@3.0.2:
+ resolution: {integrity: sha512-B5znKqRmKROAN4oHWQ50W/qisVjA9GXh2WMsVKdFVp4DxWmcrOsweqgUOUVsv5th96kwaZlokU6SlV4J3gak1w==}
+ engines: {node: '>=12'}
+
+ d3-interpolate@3.0.2:
+ resolution: {integrity: sha512-IRzGU62DtxhvsnSTWMQIdnoZ6gA+BCWwBon1EJI6SjoN595799b6z/QRBzXfFhE8iupUPp3042yBNo0STPqnzQ==}
+ engines: {node: '>=12'}
+
+ d3-selection@3.0.1:
+ resolution: {integrity: sha512-ODSf35vqCrlCfp7hrm0eZjvOosSXSYLjqvIlhMBV9q9VOx7EBJG6pc+uXBswEZNJgCGJ+qnKYcWutbZDIxe/Xg==}
+ engines: {node: '>=12'}
+
+ d3-timer@3.0.2:
+ resolution: {integrity: sha512-1Il1aliroVSErrv5aulRBxAY+7+DnaoLIWGd1C6SsBTWDeobWiP/V69vwb8vT6abR1kKwaNe1196pmaQ1fK90A==}
+ engines: {node: '>=12'}
+
+ d3-transition@3.0.2:
+ resolution: {integrity: sha512-RcjCsdFgyFoDB+QXLC5m60ZkTN0k9zH+ovoLlTdJnDS1AbfbcuowiM4pCKSTOclNibS4f4J4cbv2m7O7y8NTOQ==}
+ engines: {node: '>=12'}
+ peerDependencies:
+ d3-selection: 2 - 3
+
+ d3-zoom@3.0.1:
+ resolution: {integrity: sha512-kfjD3BDQu/FOatpZ6JdMSyIoDwTxIpI29ySTI2J5ZlDaH1WbuJGQJ2Q9oJkWTEZEW98j6idezoomSD3Cn2zwiw==}
+ engines: {node: '>=12'}
+
debug@4.4.3:
resolution: {integrity: sha512-RGwwWnwQvkVfavKVt22FGLw+xYSdzARwm0ru6DhTVA3umU5hZc28V3kO4stgYryrTlLpuvgI9GiijltAjNbcqA==}
engines: {node: '>=6.0'}
@@ -495,6 +573,11 @@ packages:
uri-js-replace@1.0.2:
resolution: {integrity: sha512-VeBBt/nMxedczht3KDL2yBBMJqIxpCQLMZp3UJ1otcWwUHdQW4IiyHpJivExzSK+FdxTowRfGL4FmwDqH9+S8Q==}
+ use-sync-external-store@1.7.0:
+ resolution: {integrity: sha512-6L+EeigHMQhdaIPNIFUKwfWJSwWFQ8gJbJ2DLOs5sDIegTwR9fRxvnM3uciHKjIZhFz+KAv2emhWMRvDmMcY8A==}
+ peerDependencies:
+ react: ^16.8.0 || ^17.0.0 || ^18.0.0 || ^19.0.0
+
yaml-ast-parser@0.0.43:
resolution: {integrity: sha512-2PTINUwsRqSd+s8XxKaJWQlUuEMHJQyEuh2edBbW8KNJz0SJPwUSD2zRWqezFEdN7IzAgeuYHFUCF7o8zRdZ0A==}
@@ -502,6 +585,21 @@ packages:
resolution: {integrity: sha512-tVpsJW7DdjecAiFpbIB1e3qxIQsE6NoPc5/eTdrbbIC4h0LVsWhnoa3g+m2HclBIujHzsxZ4VJVA+GUuc2/LBw==}
engines: {node: '>=12'}
+ zustand@4.5.7:
+ resolution: {integrity: sha512-CHOUy7mu3lbD6o6LJLfllpjkzhHXSBlX8B9+qPddUsIfeF5S/UZ5q0kmCsnRqT1UHFQZchNFDDzMbQsuesHWlw==}
+ engines: {node: '>=12.7.0'}
+ peerDependencies:
+ '@types/react': '>=16.8'
+ immer: '>=9.0.6'
+ react: '>=16.8'
+ peerDependenciesMeta:
+ '@types/react':
+ optional: true
+ immer:
+ optional: true
+ react:
+ optional: true
+
snapshots:
'@babel/code-frame@7.29.7':
@@ -677,6 +775,27 @@ snapshots:
dependencies:
tslib: 2.9.1
+ '@types/d3-color@3.1.3': {}
+
+ '@types/d3-drag@3.0.7':
+ dependencies:
+ '@types/d3-selection': 3.0.12
+
+ '@types/d3-interpolate@3.0.4':
+ dependencies:
+ '@types/d3-color': 3.1.3
+
+ '@types/d3-selection@3.0.12': {}
+
+ '@types/d3-transition@3.0.9':
+ dependencies:
+ '@types/d3-selection': 3.0.12
+
+ '@types/d3-zoom@3.0.9':
+ dependencies:
+ '@types/d3-interpolate': 3.0.4
+ '@types/d3-selection': 3.0.12
+
'@types/node@22.20.5':
dependencies:
undici-types: 6.21.0
@@ -689,6 +808,31 @@ snapshots:
dependencies:
csstype: 3.2.3
+ '@xyflow/react@12.12.1(@types/react-dom@19.3.0(@types/react@19.3.0))(@types/react@19.3.0)(react-dom@19.3.1(react@19.3.1))(react@19.3.1)':
+ dependencies:
+ '@xyflow/system': 0.0.84
+ classcat: 5.0.5
+ react: 19.3.1
+ react-dom: 19.3.1(react@19.3.1)
+ zustand: 4.5.7(@types/react@19.3.0)(react@19.3.1)
+ optionalDependencies:
+ '@types/react': 19.3.0
+ '@types/react-dom': 19.3.0(@types/react@19.3.0)
+ transitivePeerDependencies:
+ - immer
+
+ '@xyflow/system@0.0.84':
+ dependencies:
+ '@types/d3-drag': 3.0.7
+ '@types/d3-interpolate': 3.0.4
+ '@types/d3-selection': 3.0.12
+ '@types/d3-transition': 3.0.9
+ '@types/d3-zoom': 3.0.9
+ d3-drag: 3.0.1
+ d3-interpolate: 3.0.2
+ d3-selection: 3.0.1
+ d3-zoom: 3.0.1
+
agent-base@7.1.4: {}
ansi-colors@4.1.3: {}
@@ -707,12 +851,50 @@ snapshots:
change-case@5.4.4: {}
+ classcat@5.0.5: {}
+
client-only@0.0.1: {}
colorette@1.4.0: {}
csstype@3.2.3: {}
+ d3-color@3.1.1: {}
+
+ d3-dispatch@3.0.2: {}
+
+ d3-drag@3.0.1:
+ dependencies:
+ d3-dispatch: 3.0.2
+ d3-selection: 3.0.1
+
+ d3-ease@3.0.2: {}
+
+ d3-interpolate@3.0.2:
+ dependencies:
+ d3-color: 3.1.1
+
+ d3-selection@3.0.1: {}
+
+ d3-timer@3.0.2: {}
+
+ d3-transition@3.0.2(d3-selection@3.0.1):
+ dependencies:
+ d3-color: 3.1.1
+ d3-dispatch: 3.0.2
+ d3-ease: 3.0.2
+ d3-interpolate: 3.0.2
+ d3-selection: 3.0.1
+ d3-timer: 3.0.2
+
+ d3-zoom@3.0.1:
+ dependencies:
+ d3-dispatch: 3.0.2
+ d3-drag: 3.0.1
+ d3-interpolate: 3.0.2
+ d3-selection: 3.0.1
+ d3-transition: 3.0.2(d3-selection@3.0.1)
+
debug@4.4.3(supports-color@10.2.2):
dependencies:
ms: 2.1.3
@@ -875,6 +1057,17 @@ snapshots:
uri-js-replace@1.0.2: {}
+ use-sync-external-store@1.7.0(react@19.3.1):
+ dependencies:
+ react: 19.3.1
+
yaml-ast-parser@0.0.43: {}
yargs-parser@21.1.1: {}
+
+ zustand@4.5.7(@types/react@19.3.0)(react@19.3.1):
+ dependencies:
+ use-sync-external-store: 1.7.0(react@19.3.1)
+ optionalDependencies:
+ '@types/react': 19.3.0
+ react: 19.3.1
diff --git a/web/tests/operations.test.mjs b/web/tests/operations.test.mjs
new file mode 100644
index 0000000..5cfab88
--- /dev/null
+++ b/web/tests/operations.test.mjs
@@ -0,0 +1,53 @@
+import {test} from "node:test";
+import assert from "node:assert/strict";
+import {currentObservation, diagnosticGuidance, diagnosticLayers, endpointStatus, observationStatus} from "../lib/operations.ts";
+import {assets, assetObservation, diagnostic, incidents, runs} from "../app/demo/scenario.ts";
+
+test("collection, probe completion and endpoint health remain independent", () => {
+ const run = runs.at(-1);
+ assert.equal(observationStatus(run), "Succeeded");
+ assert.equal(endpointStatus(run), "HTTP failure");
+ assert.equal(currentObservation({state: "stale", latest_job_id: run.id}, runs), undefined);
+ assert.equal(currentObservation({state: "current", latest_job_id: "missing"}, runs), undefined);
+ assert.equal(currentObservation({state: "current", latest_job_id: run.id}, runs), run);
+ const missing = runs.find(run => run.status === null);
+ assert.equal(observationStatus(missing), "Unknown");
+ assert.equal(endpointStatus(missing), "Unknown");
+ assert.equal(missing.timings.http_total_ms ?? null, null);
+});
+
+test("a received HTTP 503 is evidence, not a failed TCP or TLS handshake", () => {
+ const layers = diagnosticLayers(diagnostic);
+ assert.deepEqual(layers.map(layer => layer.status), ["Observed", "Observed", "Observed", "HTTP failure"]);
+ assert.equal(layers[3].error, "HTTP 503");
+ assert.equal(layers[3].duration, 152);
+ assert.match(diagnosticGuidance(diagnostic), /may be failing/);
+});
+
+test("a generic timeout leaves the unobserved layer unknown", () => {
+ const result = {...diagnostic, http_status: null, tls: null, timings: {tcp_connect_ms: 8},
+ error: {code: "timeout", message: "Probe deadline exceeded"}};
+ assert.deepEqual(diagnosticLayers(result).map(layer => layer.status), ["Observed", "Observed", "No evidence", "No evidence"]);
+ assert.ok(diagnosticLayers(result).every(layer => layer.error === undefined));
+ assert.match(diagnosticGuidance(result), /does not identify a specific layer/);
+});
+
+test("DNS literal and plain HTTP do not fabricate DNS or TLS measurements", () => {
+ const result = {...diagnostic, target: "http://192.0.2.10", dns: {used_dns: false, answers: []},
+ tls: null, timings: {tcp_connect_ms: 8}, http_status: 204};
+ assert.deepEqual(diagnosticLayers(result).map(layer => layer.status), ["Skipped", "Observed", "Skipped", "Observed"]);
+ assert.deepEqual(diagnosticLayers({...result, kind: "dns"}).map(layer => layer.status),
+ ["Skipped", "Not requested", "Not requested", "Not requested"]);
+});
+
+test("the simulated topology links only known assets and marks missing observations", () => {
+ const ids = new Set(assets.map(asset => asset.id));
+ assert.equal(ids.size, assets.length);
+ assert.equal(assets.filter(asset => !asset.parent).length, 1);
+ assert.ok(assets.every(asset => !asset.parent || ids.has(asset.parent)));
+ assert.ok(incidents.every(incident => ids.has(incident.asset)));
+ assert.equal(assetObservation("internet"), null);
+ assert.ok(incidents.every(incident => incident.id.startsWith("DEMO-")));
+ assert.match(diagnostic.target, /^https:\/\/[^/]+\.example$/);
+ assert.match(diagnostic.connected_ip, /^192\.0\.2\./);
+});