diff --git a/README.md b/README.md index 2742f3f..5b7bf65 100644 --- a/README.md +++ b/README.md @@ -42,8 +42,8 @@ The first executable is deliberately narrow: - publishes provider `odin.allseer`; - writes the latest surface to `scratch/odin/latest-surface.json`; - persists the same document through local CultMesh/CultCache when `CultLib` packages are available at `E:\Projects\CultLib\packages`; -- observes Starfire Docker, Periwinkle ADB, Nightwing, Raven, EVE, and Yggdrasil reachability; +- observes Starfire Docker, Periwinkle ADB, Nightwing services/GPU, Raven, EVE, and Yggdrasil reachability; - exposes Yggdrasil service status when the local SSH alias can reach it. +- publishes explicit `verse` and `service` nodes for compact Eve/CultUI lowerers. The next real cut is to replace static host probes with CultNet schema discovery and CultMesh Verse peer exchange. The probe layer is an input adapter. It must not become the architecture. - diff --git a/docs/architecture.md b/docs/architecture.md index 6c1047c..5224f7d 100644 --- a/docs/architecture.md +++ b/docs/architecture.md @@ -9,6 +9,7 @@ Odin is the central all-seer node for GameCult's CultMesh world: every Verse can ```text host / device / service probes -> Odin observation cycle + -> Verse-owned service records -> Odin state document -> CultMesh/CultCache persistence -> Eve dashboard state @@ -34,6 +35,20 @@ Verse announcement - Translation paths must name source schema, target schema, lossiness, authority, and version. - Renderers lower surfaces only. If a renderer fixes network truth, the machine is split-brained. - CultCache is the durable state substrate; CultNet is the wire vocabulary; CultMesh is the Verse and peer-consensus layer. +- The Eve surface carries explicit `verse` and `service` nodes. Compact renderers may derive visual facets from those nodes, but may not invent observation truth. + +## Current Service Surface + +Odin currently publishes service squares for: + +- Starfire: Odin, Docker, ADB, Odin CultCache, and running Docker containers. +- Nightwing: SSH, Eve broker, Eve browser reference, visible TUI, Docker unit state, and NVIDIA GPU state. +- EVE: SSH/native Eve reachability. +- Periwinkle: ADB reachability. +- Raven: SSH reachability. +- Yggdrasil: SSH/HTTP/HTTPS reachability plus nginx, StreamPixels, Heimdall, Repixelizer, and Bifrost systemd state. + +The compact Nightwing TUI lowers these into dense cells and fills surplus screen space with derived schema, route, owner, and probe facets from the same Odin-owned service records. ## First Translation Model @@ -47,4 +62,3 @@ Odin's translation registry should start as data, not magic: - `notes` No regex tribunals for meaning. Natural-language schema interpretation can be assisted by models later, but accepted translation routes must be inspectable typed state. - diff --git a/scripts/stop-odin.ps1 b/scripts/stop-odin.ps1 index 3b04071..cca0a5f 100644 --- a/scripts/stop-odin.ps1 +++ b/scripts/stop-odin.ps1 @@ -10,12 +10,12 @@ if (-not (Test-Path $pidPath)) { exit 0 } -$pid = (Get-Content -Raw $pidPath).Trim() -if ($pid -match "^\d+$") { - $process = Get-Process -Id ([int] $pid) -ErrorAction SilentlyContinue +$odinPid = (Get-Content -Raw $pidPath).Trim() +if ($odinPid -match "^\d+$") { + $process = Get-Process -Id ([int] $odinPid) -ErrorAction SilentlyContinue if ($process) { Stop-Process -Id $process.Id - Write-Host "Stopped Odin PID $pid." + Write-Host "Stopped Odin PID $odinPid." } } diff --git a/src/odin-coordinator.cjs b/src/odin-coordinator.cjs index 55919ba..3f4c64e 100644 --- a/src/odin-coordinator.cjs +++ b/src/odin-coordinator.cjs @@ -202,20 +202,37 @@ function sendFrame(socket, opcode, payload) { async function buildState() { version += 1; const observedAt = new Date().toISOString(); - const [docker, adb, hosts, yggdrasilServices] = await Promise.all([ + const [docker, adb, hosts, yggdrasilServices, nightwingServices, nightwingGpu] = await Promise.all([ dockerSnapshot(), adbSnapshot(), hostChecks(), remoteServices("ygg", ["nginx", "streampixels-web", "streampixels-service", "heimdall", "repixelizer-gui", "bifrost"]), + remoteServices("nightwing", ["ssh", "nightwing-eve-dashboard", "nightwing-eve-browser-reference", "gamecult-visible-ops", "docker"]), + remoteGpu("nightwing"), ]); const verses = [ - verse("starfire.local", "Starfire", "coordinator", "active", ["docker", "adb", "eve-provider"]), - verse("nightwing.local", "Nightwing", "dashboard-renderer", hostState(hosts.Nightwing), ["eve-tui", "gpu-worker"]), - verse("eve.ipad", "EVE", "ios-client", hostState(hosts.EVE), ["ssh", "native-eve"]), - verse("periwinkle.android", "Periwinkle", "android-client", adb.devices.length ? "connected" : "waiting", ["adb", "sensor-edge"]), - verse("raven.local", "Raven", "local-peer", hostState(hosts.Raven), ["ssh"]), - verse("yggdrasil.ops", "Yggdrasil", "ops-host", hostState(hosts.Yggdrasil), ["ssh", "https", "services"]), + verse("starfire.local", "Starfire", "coordinator", "active", ["docker", "adb", "eve-provider"], [ + service("odin", "Odin all-seer", "active", "ws://0.0.0.0:8797/eve/deck"), + service("docker", "Docker", docker.state === "ok" ? "active" : "warn", `${docker.containers.length} running`), + service("adb", "Periwinkle ADB", adb.devices.length ? "active" : "waiting", adb.devices.map((device) => `${device.serial}:${device.state}`).join(", ") || adb.error || "no devices"), + service("cultcache", "Odin CultCache", fs.existsSync(cachePath) ? "active" : "waiting", path.basename(cachePath)), + ...docker.containers.map((container) => service(`docker-${container.name}`, container.name, "active", container.image)), + ]), + verse("nightwing.local", "Nightwing", "dashboard-renderer", hostState(hosts.Nightwing), ["eve-tui", "gpu-worker"], [ + ...hostServices("Nightwing", hosts.Nightwing), + ...nightwingServices.map((entry) => service(`systemd-${entry.name}`, entry.name, systemdState(entry.state), entry.state)), + service("gpu", "GTX 860M", nightwingGpu.state, nightwingGpu.detail), + ]), + verse("eve.ipad", "EVE", "ios-client", hostState(hosts.EVE), ["ssh", "native-eve"], hostServices("EVE", hosts.EVE)), + verse("periwinkle.android", "Periwinkle", "android-client", adb.devices.length ? "connected" : "waiting", ["adb", "sensor-edge"], [ + service("adb-device", "ADB device", adb.devices.length ? "active" : "waiting", adb.devices.map((device) => `${device.serial}:${device.state}`).join(", ") || adb.error || "no devices"), + ]), + verse("raven.local", "Raven", "local-peer", hostState(hosts.Raven), ["ssh"], hostServices("Raven", hosts.Raven)), + verse("yggdrasil.ops", "Yggdrasil", "ops-host", hostState(hosts.Yggdrasil), ["ssh", "https", "services"], [ + ...hostServices("Yggdrasil", hosts.Yggdrasil), + ...yggdrasilServices.map((entry) => service(`systemd-${entry.name}`, entry.name, systemdState(entry.state), entry.state)), + ]), ]; return { @@ -274,8 +291,12 @@ function buildSurface({ observedAt, docker, adb, hosts, yggdrasilServices, verse title: "Odin", root: { id: "network-root", - kind: "stack", - props: { title: "GameCult Network" }, + kind: "dashboard", + props: { + title: "Odin All-Seer", + observedAt, + summary: `${verses.length} Verses / ${verses.reduce((sum, entry) => sum + entry.services.length, 0)} service squares`, + }, children: [ pane("Coordinator", [ text("observed", `observed ${observedAt}`), @@ -283,6 +304,24 @@ function buildSurface({ observedAt, docker, adb, hosts, yggdrasilServices, verse metric("docker-count", "Docker containers", docker.containers.length, docker.state === "ok" ? "ok" : "warn"), metric("adb-count", "ADB devices", adb.devices.length, adb.devices.length ? "ok" : "warn"), ]), + ...verses.map((entry) => ({ + id: `verse-${entry.verseId}`, + kind: "verse", + props: { + title: entry.name, + verseId: entry.verseId, + role: entry.role, + status: entry.status, + capabilities: entry.capabilities, + services: entry.services, + }, + children: entry.services.map((item) => ({ + id: `service-${entry.verseId}-${item.id}`, + kind: "service", + props: item, + children: [], + })), + })), pane("Verses", verses.map((entry) => card(`verse-card-${entry.verseId}`, [ text(`verse-title-${entry.verseId}`, `${entry.name} :: ${entry.verseId}`), @@ -331,8 +370,25 @@ function metric(id, label, value, tone) { return { id, kind: "metric", props: { label, text: `${label}: ${value}`, value, tone }, children: [] }; } -function verse(verseId, name, role, status, capabilities) { - return { verseId, name, role, status, capabilities }; +function verse(verseId, name, role, status, capabilities, services = []) { + return { verseId, name, role, status, capabilities, services }; +} + +function service(id, name, state, detail = "") { + return { id: stableId(id), name, state, detail: String(detail || "") }; +} + +function hostServices(hostName, checks) { + return (checks || []).map((check) => + service(`${hostName}-${check.name}`, `${hostName} ${check.name}`, check.state === "open" || check.state === "ok" ? "active" : check.state, check.detail), + ); +} + +function systemdState(state) { + if (state === "active") return "active"; + if (state === "inactive") return "inactive"; + if (state === "failed") return "failed"; + return state.startsWith("unknown") ? "unknown" : "warn"; } function hostState(checks) { @@ -424,6 +480,21 @@ async function remoteServices(target, services) { } } +async function remoteGpu(target) { + try { + const { stdout } = await execFileAsync("ssh", [ + "-o", "BatchMode=yes", + "-o", "ConnectTimeout=3", + target, + "nvidia-smi --query-gpu=name,driver_version,memory.total,utilization.gpu --format=csv,noheader,nounits 2>/dev/null | head -n 1", + ], { timeout: 6000 }); + const detail = stdout.trim(); + return detail ? { state: "active", detail } : { state: "unknown", detail: "nvidia-smi returned no GPU" }; + } catch (error) { + return { state: "unknown", detail: error.message }; + } +} + function stableId(value) { return value.toLowerCase().replace(/[^a-z0-9]+/g, "-").replace(/^-|-$/g, ""); }