diff --git a/crates/idunn-daemon/src/main.rs b/crates/idunn-daemon/src/main.rs index 8c00b68..3884e6d 100644 --- a/crates/idunn-daemon/src/main.rs +++ b/crates/idunn-daemon/src/main.rs @@ -926,11 +926,11 @@ fn swarm_surgery_plan( "5. Delete or demote compatibility probes once every target has daemon-owned publication and advertised lifecycle authority.".to_string(), ], current_phase: - "Phase 22: every Muninn body now publishes daemon-owned provider advertisement, command_boundary, and transport_profile records from its live telemetry store; Odin remains the next compatibility cut until provider discovery stops depending on xenos-boundary catalog shims." + "Phase 23: Odin now ingests remote Vili and Nightwing Gjallar provider witnesses live, and /eve/deck/nightwing-gjallar reports honest missing-surface debt instead of silently omitting the daemon; Gjallar is the next cut until its daemon-owned witness publishes a provider-owned Eve surface." .to_string(), next_target: next_target.to_string(), cut_line: - "Muninn, Vili, Idunn, Odin, Stonks, Weksa, VoidBot, Nightwing Gjallar, Mimir Eve dashboard, Nightwing Eve dashboard, Nightwing Eve browser reference, yggdrasil-streampixels, yggdrasil-heimdall, and yggdrasil-repixelizer now exercise daemon-owned RUDP health. Raven GameCult\\Vili has been refreshed from Odin, the hidden scheduled task now launches start-vili-daemon.ps1 with Idunn RUDP arguments, and live Idunn accepts vili.cultnet-rudp-animation-health from 10.77.0.4. VoidBot now publishes a daemon-owned provider catalog, provider advertisements, command_boundary, and transport_profile records from E:\\Projects\\VoidBot\\.voidbot\\status\\cultmesh\\voidbot-swarm-state.cc while health-voidbot.cmd is demoted to a fast compatibility witness. Raven Muninn now publishes provider advertisement, command_boundary, and transport_profile records from C:\\Meta\\Odin\\state\\muninn.telemetry.cc, Starfire Muninn now publishes the same daemon-owned witness records from C:\\Meta\\Odin\\state\\starfire.muninn.telemetry.cc, Nightwing Muninn now publishes the same daemon-owned witness records from /home/metacrat/.local/state/gamecult/muninn/muninn.telemetry.cc, and live Idunn accepts muninn from 10.77.0.4, starfire-muninn from 127.0.0.1, and nightwing-muninn from 10.77.0.3. Raven's GameCult-Muninn, GameCult-Muninn-Activate, and GameCult-Muninn-VideoProof tasks now execute wscript.exe actions whose hidden VBS launchers call noninteractive hidden PowerShell entrypoints directly; .cmd wrappers, where present, are manual compatibility entrypoints only. Live yggdrasil-streampixels publishes streampixels.cultnet-rudp-service-health from 10.77.0.1, live yggdrasil-heimdall publishes heimdall.cultnet-rudp-provider-health from 10.77.0.1 with a boundary store at /srv/heimdall/cultcache/heimdall.service.cc, live yggdrasil-repixelizer publishes repixelizer.cultnet-rudp-service-health from 10.77.0.1 with a boundary store at /srv/repixelizer/cultcache/repixelizer.service.cc, live Nightwing Gjallar publishes a boundary store at /var/lib/gamecult/gjallar/cultcache/gjallar.service.cc, live Mimir Eve dashboard now publishes CultMesh state at /var/lib/gamecult/eve-dashboard/cultmesh/eve-dashboard.ccmp plus a boundary store at /var/lib/gamecult/eve-dashboard/cultcache/eve-dashboard.service.cc, and live Nightwing Eve browser reference now publishes a boundary store at /var/lib/gamecult/eve-browser-reference/cultcache/eve-browser-reference.service.cc. Odin remains the next compatibility debt until provider discovery stops treating local store visibility as the only ingestion path." + "Muninn, Vili, Idunn, Odin, Stonks, Weksa, VoidBot, Nightwing Gjallar, Mimir Eve dashboard, Nightwing Eve dashboard, Nightwing Eve browser reference, yggdrasil-streampixels, yggdrasil-heimdall, and yggdrasil-repixelizer now exercise daemon-owned RUDP health. Raven GameCult\\Vili has been refreshed from Odin, the hidden scheduled task now launches start-vili-daemon.ps1 with Idunn RUDP arguments, and live Idunn accepts vili.cultnet-rudp-animation-health from 10.77.0.4. VoidBot now publishes a daemon-owned provider catalog, provider advertisements, command_boundary, and transport_profile records from E:\\Projects\\VoidBot\\.voidbot\\status\\cultmesh\\voidbot-swarm-state.cc while health-voidbot.cmd is demoted to a fast compatibility witness. Raven Muninn now publishes provider advertisement, command_boundary, and transport_profile records from C:\\Meta\\Odin\\state\\muninn.telemetry.cc, Starfire Muninn now publishes the same daemon-owned witness records from C:\\Meta\\Odin\\state\\starfire.muninn.telemetry.cc, Nightwing Muninn now publishes the same daemon-owned witness records from /home/metacrat/.local/state/gamecult/muninn/muninn.telemetry.cc, and live Idunn accepts muninn from 10.77.0.4, starfire-muninn from 127.0.0.1, and nightwing-muninn from 10.77.0.3. Raven's GameCult-Muninn, GameCult-Muninn-Activate, and GameCult-Muninn-VideoProof tasks now execute wscript.exe actions whose hidden VBS launchers call noninteractive hidden PowerShell entrypoints directly; .cmd wrappers, where present, are manual compatibility entrypoints only. Live yggdrasil-streampixels publishes streampixels.cultnet-rudp-service-health from 10.77.0.1, live yggdrasil-heimdall publishes heimdall.cultnet-rudp-provider-health from 10.77.0.1 with a boundary store at /srv/heimdall/cultcache/heimdall.service.cc, live yggdrasil-repixelizer publishes repixelizer.cultnet-rudp-service-health from 10.77.0.1 with a boundary store at /srv/repixelizer/cultcache/repixelizer.service.cc, live Nightwing Gjallar publishes a boundary store at /var/lib/gamecult/gjallar/cultcache/gjallar.service.cc, live Odin now ingests remote Raven Vili and Nightwing Gjallar witness stores into the accepted provider catalog, and /eve/deck/nightwing-gjallar now reports that the provider advertisement is live while the provider-owned Eve surface is still missing. Live Mimir Eve dashboard now publishes CultMesh state at /var/lib/gamecult/eve-dashboard/cultmesh/eve-dashboard.ccmp plus a boundary store at /var/lib/gamecult/eve-dashboard/cultcache/eve-dashboard.service.cc, and live Nightwing Eve browser reference now publishes a boundary store at /var/lib/gamecult/eve-browser-reference/cultcache/eve-browser-reference.service.cc. Gjallar remains the next compatibility debt until its daemon-owned witness publishes gamecult.eve.surface_state and the Nightwing panel stops lowering an unavailable placeholder." .to_string(), verification_layer: "CultMesh keepalive store records plus live Idunn decision cycles, not process exit codes or chat summaries." @@ -957,6 +957,7 @@ fn preferred_next_target<'a>( targets .iter() .filter(|target| target.enabled) + .filter(|target| target.daemon_id != "idunn-swarm-deployment-coverage") .filter_map(|target| { let status = *plan_by_daemon.get(target.daemon_id.as_str())?; Some((target.daemon_id.as_str(), status, priority(status))) @@ -1141,39 +1142,41 @@ fn daemon_surgery_plan(target: &DaemonTarget, updated_at: &str) -> IdunnDaemonSu match target.daemon_id.as_str() { "odin" => { + status = "partial-rudp-health-and-provider-store-live"; severity = "critical"; owner = "Odin core"; current_mechanism = - "Odin still exposes local health and Eve deck compatibility surfaces over HTTP/WebSocket while Idunn verifies liveness through a command probe." + "Odin now ingests remote Raven Vili, Raven Muninn, Starfire Muninn, Nightwing Muninn, and Nightwing Gjallar witness stores into the accepted provider catalog while still exposing compatibility HTTP/WebSocket lowerings and relying on xenos-boundary hashed-store inspection for C# witness bodies." .to_string(); intended_authority = "Odin owns accepted Verse discovery and provider catalog truth as typed CultMesh/CultNet records over cultnet.transport.rudp.v0." .to_string(); cut_line = - "HTTP/WebSocket deck and health endpoints become browser/lowering bridges only; they no longer decide daemon health, discovery, or provider truth." + "HTTP/WebSocket deck and health endpoints become browser/lowering bridges only; Odin's remaining compatibility debt is deleting hashed-store inspection shims once remote daemon runtimes publish directly interoperable provider surfaces and records." .to_string(); steps[2] = "Make Odin ingest RUDP provider advertisements directly into its accepted service/catalog surface." .to_string(); } "nightwing-gjallar" => { - status = "partial-rudp-health-and-provider-store-live"; + status = "catalog-coherence-probe"; severity = "critical"; owner = "Gjallar C# runtime plus Odin provider feed"; current_mechanism = - "Nightwing Gjallar publishes gjallar.cultnet-rudp-framebuffer-composition-health over CultNet/RUDP from the C# runtime, and the daemon-owned boundary store at /var/lib/gamecult/gjallar/cultcache/gjallar.service.cc now contains provider advertisement, runtime_config, frame_status, command_boundary, transport_profile, and daemon-health summary records. The compatibility health script still verifies deployment and local witnesses while Odin WebSocket deck input remains the explicit transport debt." + "Nightwing Gjallar publishes gjallar.cultnet-rudp-framebuffer-composition-health over CultNet/RUDP from the C# runtime, and the daemon-owned boundary store at /var/lib/gamecult/gjallar/cultcache/gjallar.service.cc now contains provider advertisement, runtime_config, frame_status, command_boundary, transport_profile, and daemon-health summary records. Live Odin now ingests that witness store and exposes /eve/deck/nightwing-gjallar, but the route still lowers an unavailable placeholder because Gjallar does not yet publish a provider-owned Eve surface." .to_string(); intended_authority = - "Gjallar subscribes to Odin/provider deck state over CultNet/RUDP and publishes framebuffer composition health, provider advertisement, runtime config, command boundary, and transport profile as typed CultMesh/CultNet state." + "Gjallar subscribes to Odin/provider deck state over CultNet/RUDP and publishes framebuffer composition health, provider advertisement, provider-owned Eve surface, runtime config, command boundary, and transport profile as typed CultMesh/CultNet state." .to_string(); cut_line = - "Keep the service/status probe as fallback only until Gjallar's native CultMesh/RUDP input path replaces the Odin WebSocket deck bridge; the daemon-owned boundary store already owns provider advertisement, command_boundary, and transport_profile truth." + "Keep the service/status probe as fallback only until Gjallar's native CultMesh/RUDP input path replaces the Odin WebSocket deck bridge; the daemon-owned witness already owns provider advertisement, command_boundary, and transport_profile truth, but it must also publish gamecult.eve.surface_state before Odin can proxy a real Nightwing Gjallar panel." .to_string(); steps = vec![ "Keep live gjallar.cultnet-rudp-framebuffer-composition-health publication running from Nightwing's Gjallar service.".to_string(), "Keep Gjallar's daemon-owned boundary store at /var/lib/gamecult/gjallar/cultcache/gjallar.service.cc publishing provider advertisement, runtime_config, frame_status, command_boundary, transport_profile, and daemon-health summary records.".to_string(), + "Publish a daemon-owned gamecult.eve.surface_state witness for provider id nightwing-gjallar so Odin can proxy a real panel instead of an unavailable placeholder.".to_string(), "Replace Odin WebSocket deck consumption with a native C# CultMesh/RUDP input path when the deck contract is ready.".to_string(), - "Teach Odin to prefer Gjallar's daemon-owned boundary store and future native RUDP compositor records over service/status compatibility ingestion.".to_string(), + "Keep Odin's hashed-store ingestion shim strictly as a xenos-boundary bridge until Gjallar publishes an interoperable provider-owned Eve surface.".to_string(), "Delete or demote health-nightwing-gjallar.cmd to a manual deployment witness with no lifecycle truth.".to_string(), ]; } @@ -2442,8 +2445,8 @@ mod tests { assert_eq!(plan.plan_id, "swarm-surgery:starfire-local"); assert_eq!(plan.status, "active-transport-migration"); - assert_eq!(plan.next_target, "odin"); - assert!(plan.current_phase.contains("every Muninn body now publishes")); + assert_eq!(plan.next_target, "nightwing-gjallar"); + assert!(plan.current_phase.contains("Odin now ingests remote Vili and Nightwing Gjallar provider witnesses live")); assert!( plan.cut_line .contains("live yggdrasil-heimdall publishes heimdall.cultnet-rudp-provider-health") @@ -2468,12 +2471,12 @@ mod tests { assert!(plan.cut_line.contains("/srv/repixelizer/cultcache/repixelizer.service.cc")); assert!(plan.cut_line.contains("live Nightwing Gjallar publishes a boundary store")); assert!(plan.cut_line.contains("/var/lib/gamecult/gjallar/cultcache/gjallar.service.cc")); - assert!(plan.cut_line.contains("live Mimir Eve dashboard now publishes CultMesh state")); + assert!(plan.cut_line.contains("Live Mimir Eve dashboard now publishes CultMesh state")); assert!(plan.cut_line.contains("/var/lib/gamecult/eve-dashboard/cultmesh/eve-dashboard.ccmp")); assert!(plan.cut_line.contains("/var/lib/gamecult/eve-dashboard/cultcache/eve-dashboard.service.cc")); assert!(plan.cut_line.contains("live Nightwing Eve browser reference now publishes a boundary store")); assert!(plan.cut_line.contains("/var/lib/gamecult/eve-browser-reference/cultcache/eve-browser-reference.service.cc")); - assert!(plan.cut_line.contains("Odin remains the next compatibility debt")); + assert!(plan.cut_line.contains("Gjallar remains the next compatibility debt")); assert!(plan.verification_layer.contains("CultMesh keepalive store")); assert!( plan.invariants @@ -2576,7 +2579,7 @@ mod tests { ); let gjallar_plan = daemon_surgery_plan(&nightwing_gjallar, "unix:100"); - assert_eq!(gjallar_plan.status, "partial-rudp-health-and-provider-store-live"); + assert_eq!(gjallar_plan.status, "catalog-coherence-probe"); assert!( gjallar_plan .current_mechanism @@ -2585,7 +2588,7 @@ mod tests { assert!( gjallar_plan .cut_line - .contains("service/status probe as fallback") + .contains("gamecult.eve.surface_state") ); let nightwing_eve_dashboard_plan = diff --git a/src/odin/config.cjs b/src/odin/config.cjs index bb81c3a..461d529 100644 --- a/src/odin/config.cjs +++ b/src/odin/config.cjs @@ -38,12 +38,13 @@ function buildConfig(argv) { path.join(repoRoot, "..", "VoidBot", ".voidbot", "status", "cultmesh", "voidbot-swarm-state.cc"), path.join(repoRoot, "..", "Bifrost", ".bifrost", "provider-advertisement.cc"), path.join(repoRoot, "..", "weksa", ".weksa", "provider-advertisement-store.cc"), - path.join(repoRoot, "..", "Vili", ".vili", "vili.service.cc"), + "sftp://raven/E:/Projects/Vili/.vili/vili.service.cc", path.join(repoRoot, "..", "Stonks", "scratch", "stonks", "stonks-state.cc"), path.join(repoRoot, "..", "StreamPixels", ".streampixels-data", "cultcache", "streampixels.service.cc"), "sftp://raven/C:/Meta/Odin/state/muninn.telemetry.cc", "C:\\Meta\\Odin\\state\\starfire.muninn.telemetry.cc", "sftp://nightwing/home/metacrat/.local/state/gamecult/muninn/muninn.telemetry.cc", + "sftp://nightwing/var/lib/gamecult/gjallar/cultcache/gjallar.service.cc", ].join(","); const interfaceBindingStores = String( args.interfaceBindingStore || diff --git a/src/odin/interfaces.cjs b/src/odin/interfaces.cjs index 8f938ac..f52281b 100644 --- a/src/odin/interfaces.cjs +++ b/src/odin/interfaces.cjs @@ -2,12 +2,18 @@ const childProcess = require("child_process"); const fs = require("fs"); +const { createRequire } = require("module"); const os = require("os"); const path = require("path"); const { httpGet, stableId } = require("./utils.cjs"); const { openWebSocket, readServerTextFrame, sendClientFrame } = require("./websocket.cjs"); const { tcpCheck } = require("./probes.cjs"); +const requireCultCacheInspection = createRequire( + path.resolve(__dirname, "..", "..", "..", "CultLib", "packages", "cultcache-ts", "package.json"), +); +const { inspectCultCacheBytes } = requireCultCacheInspection("./dist/cult-cache-inspector.js"); + function createInterfaceDiscovery({ CultMesh, documents, @@ -87,8 +93,9 @@ function createInterfaceDiscovery({ const providers = []; for (const storeSpec of interfaceBindingStores) { + let resolvedStore = null; try { - const resolvedStore = resolveInterfaceBindingStore(storeSpec); + resolvedStore = resolveInterfaceBindingStore(storeSpec); if (!resolvedStore) { continue; } @@ -179,6 +186,12 @@ function createInterfaceDiscovery({ } catch { // Provider advertisements are optional discovery hints; broken stores // are still surfaced through interface discovery when possible. + if (resolvedStore?.localPath && fs.existsSync(resolvedStore.localPath)) { + providers.push(...inspectProviderAdvertisementsFromStore( + resolvedStore.localPath, + resolvedStore.sourceId, + )); + } } } @@ -220,8 +233,9 @@ function createInterfaceDiscovery({ } const interfaces = []; for (const storeSpec of interfaceBindingStores) { + let resolvedStore = null; try { - const resolvedStore = resolveInterfaceBindingStore(storeSpec); + resolvedStore = resolveInterfaceBindingStore(storeSpec); if (!resolvedStore) { continue; } @@ -324,6 +338,16 @@ function createInterfaceDiscovery({ }); } } catch (error) { + if (resolvedStore?.localPath && fs.existsSync(resolvedStore.localPath)) { + const fallbackInterfaces = inspectCultMeshInterfacesFromStore( + resolvedStore.localPath, + resolvedStore.sourceId, + ); + if (fallbackInterfaces.length > 0) { + interfaces.push(...fallbackInterfaces); + continue; + } + } interfaces.push(dashboardUnavailable(`cultmesh:${storeSpec}`, `cultmesh:${storeSpec}`, error.message)); } } @@ -426,6 +450,309 @@ function providerRecordKeys(advertisement) { return [...new Set(keys.filter(Boolean).map(String))]; } +function inspectProviderAdvertisementsFromStore(storePath, sourceId) { + const inspection = inspectCultCacheBytes(storePath, fs.readFileSync(storePath)); + const records = inspection.records || []; + return records + .filter((record) => record.schemaName === "gamecult.eve.provider_advertisement") + .map((record) => buildInspectedProviderAdvertisement(record, records, sourceId)) + .filter(Boolean); +} + +function buildInspectedProviderAdvertisement(record, records, sourceId) { + const advertisement = normalizeInspectedProviderAdvertisement(record?.payloadPreview); + const providerId = advertisement?.providerId; + if (!providerId) { + return null; + } + const commandBoundary = inspectProviderCommandBoundary(providerId, records); + const transportProfile = inspectProviderTransportProfile(providerId, records); + const endpoints = normalizeInspectedEndpoints(advertisement.endpoints); + return { + id: providerId, + title: advertisement.title || providerId, + description: advertisement.description || "Provider-owned CultMesh advertisement.", + version: String(advertisement.version || 0), + endpoint: advertisement.cultMeshAddress || endpoints[0]?.address || `cultmesh:${sourceId}`, + canonicalService: advertisement.canonicalService || null, + locatedService: advertisement.locatedService || null, + cultMeshAddress: advertisement.cultMeshAddress || null, + endpoints, + routes: normalizeInspectedRoutes(advertisement), + transportEndpoint: advertisement.cultMeshAddress || endpoints.find((entry) => String(entry.address || "").startsWith("ws://"))?.address || endpoints[0]?.address || `cultmesh:${sourceId}`, + capabilities: advertisement.capabilities || [], + operatorState: null, + commandBoundary, + transportProfile, + usesCultMesh: true, + transport: "CultMesh provider advertisement", + status: advertisement.status || "unknown", + updatedAt: advertisement.updatedAt || new Date().toISOString(), + source: `cultmesh:${sourceId}`, + commandSurface: advertisement.commandSurface || null, + }; +} + +function inspectCultMeshInterfacesFromStore(storePath, sourceId) { + const inspection = inspectCultCacheBytes(storePath, fs.readFileSync(storePath)); + const records = inspection.records || []; + const providersById = new Map( + records + .filter((record) => record.schemaName === "gamecult.eve.provider_advertisement") + .map((record) => buildInspectedProviderAdvertisement(record, records, sourceId)) + .filter(Boolean) + .map((provider) => [provider.id, provider]), + ); + return records + .filter((record) => record.schemaName === "gamecult.eve.surface_state") + .map((record) => buildInspectedInterfaceFromSurfaceRecord( + record, + providersById, + sourceId, + records, + )) + .filter(Boolean); +} + +function buildInspectedInterfaceFromSurfaceRecord(record, providersById, sourceId, records) { + const state = normalizeInspectedSurfaceState(record?.payloadPreview); + if (!state?.providerId || !state.surface?.root) { + return null; + } + const provider = providersById.get(state.providerId) || null; + return { + providerId: state.providerId, + title: state.title || provider?.title || state.providerId, + state: "active", + detail: `${state.surface.root.kind || "surface"} ${countSurfaceNodes(state.surface)} nodes via CultMesh witness inspection`, + version: state.version || 0, + updatedAt: state.updatedAt || provider?.updatedAt || new Date().toISOString(), + source: `cultmesh:${sourceId}`, + manifest: provider ? { + providerId: provider.id, + title: provider.title, + description: provider.description, + canonicalService: provider.canonicalService, + locatedService: provider.locatedService, + cultMeshAddress: provider.cultMeshAddress, + endpoints: provider.endpoints, + routes: provider.routes, + } : null, + canonicalService: provider?.canonicalService || null, + locatedService: provider?.locatedService || null, + cultMeshAddress: provider?.cultMeshAddress || null, + endpoints: provider?.endpoints || [], + routes: provider?.routes || [], + operatorState: null, + commandBoundary: provider?.commandBoundary || inspectProviderCommandBoundary(state.providerId, records), + transportProfile: provider?.transportProfile || inspectProviderTransportProfile(state.providerId, records), + surface: state.surface, + }; +} + +function normalizeInspectedProviderAdvertisement(preview) { + if (Array.isArray(preview) && preview.length === 1 && preview[0] && typeof preview[0] === "object" && !Array.isArray(preview[0])) { + const value = preview[0]; + return { + providerId: value.providerId || value.ProviderId || null, + title: value.title || value.Title || null, + description: value.description || value.Description || null, + canonicalService: value.canonicalService || value.CanonicalService || null, + locatedService: value.locatedService || value.LocatedService || null, + cultMeshAddress: value.cultMeshAddress || value.CultMeshAddress || null, + status: value.status || value.Status || null, + updatedAt: value.updatedAt || value.UpdatedAt || null, + capabilities: value.capabilities || value.CapabilityIds || [], + endpoints: value.endpoints || value.Endpoints || [], + commandSurface: value.commandSurface || value.CommandSurface || null, + }; + } + if (!Array.isArray(preview) || preview.length < 11) { + return null; + } + return { + providerId: preview[1] || null, + serviceId: preview[2] || null, + verseId: preview[3] || null, + title: preview[4] || null, + description: preview[5] || null, + canonicalService: preview[6] || null, + locatedService: preview[7] || null, + cultMeshAddress: preview[8] || null, + status: preview[9] || null, + updatedAt: preview[10] || null, + capabilities: Array.isArray(preview[11]) ? preview[11] : [], + endpoints: Array.isArray(preview[12]) ? preview[12] : [], + schemas: Array.isArray(preview[13]) ? preview[13] : [], + witnesses: Array.isArray(preview[14]) ? preview[14] : [], + surfaces: Array.isArray(preview[15]) ? preview[15] : [], + }; +} + +function normalizeInspectedSurfaceState(preview) { + if (Array.isArray(preview) && preview.length === 1 && preview[0] && typeof preview[0] === "object" && !Array.isArray(preview[0])) { + const value = preview[0]; + return { + providerId: value.providerId || value.ProviderId || null, + title: value.title || value.Title || null, + version: Number(value.version || value.Version || 0), + updatedAt: value.updatedAt || value.UpdatedAt || null, + surface: normalizeInspectedSurface(value.surface || value.Surface || null), + }; + } + if (!Array.isArray(preview) || preview.length < 5) { + return null; + } + if (preview.length >= 6) { + return { + providerId: preview[1] || null, + title: preview[2] || null, + version: Number(preview[3] || 0), + updatedAt: preview[4] || null, + surface: normalizeInspectedSurface(preview[5]), + }; + } + return { + providerId: preview[0] || null, + title: preview[1] || null, + version: Number(preview[2] || 0), + updatedAt: preview[3] || null, + surface: normalizeInspectedSurface(preview[4]), + }; +} + +function normalizeInspectedSurface(preview) { + if (!preview) { + return null; + } + if (!Array.isArray(preview) && typeof preview === "object") { + return { + ...preview, + root: normalizeInspectedSurfaceNode(preview.root), + assets: Array.isArray(preview.assets) ? preview.assets : [], + }; + } + if (!Array.isArray(preview) || preview.length < 4) { + return null; + } + return { + schema: preview[0] || "gamecult.eve.surface.v1", + id: preview[1] || "surface", + title: preview[2] || "", + root: normalizeInspectedSurfaceNode(preview[3]), + assets: Array.isArray(preview[4]) ? preview[4] : [], + }; +} + +function normalizeInspectedSurfaceNode(preview) { + if (!preview) { + return null; + } + if (!Array.isArray(preview) && typeof preview === "object") { + return { + ...preview, + props: normalizeInspectedSurfaceProps(preview.props), + children: Array.isArray(preview.children) + ? preview.children.map((child) => normalizeInspectedSurfaceNode(child)).filter(Boolean) + : [], + }; + } + if (!Array.isArray(preview) || preview.length < 3) { + return null; + } + return { + id: preview[0] || "node", + kind: preview[1] || "group", + props: normalizeInspectedSurfaceProps(preview[2]), + children: Array.isArray(preview[3]) + ? preview[3].map((child) => normalizeInspectedSurfaceNode(child)).filter(Boolean) + : [], + }; +} + +function normalizeInspectedSurfaceProps(preview) { + if (!preview) { + return {}; + } + if (!Array.isArray(preview) && typeof preview === "object") { + return preview; + } + if (!Array.isArray(preview)) { + return {}; + } + return { + title: preview[0] || "", + text: preview[1] || "", + label: preview[2] || "", + value: preview[3] || "", + status: preview[4] || "", + summary: preview[5] || "", + detail: preview[6] || "", + }; +} + +function inspectProviderCommandBoundary(providerId, records) { + if (providerId !== "nightwing-gjallar") { + return null; + } + const record = records.find((entry) => entry.schemaName === "gjallar.command_boundary"); + if (!record || !Array.isArray(record.payloadPreview)) { + return null; + } + return { + boundary_id: record.payloadPreview[0] || null, + daemon_id: record.payloadPreview[1] || null, + owner: record.payloadPreview[2] || null, + lifecycle_authority: record.payloadPreview[5] || null, + updated_at: record.payloadPreview[8] || null, + }; +} + +function inspectProviderTransportProfile(providerId, records) { + if (providerId !== "nightwing-gjallar") { + return null; + } + const record = records.find((entry) => entry.schemaName === "gjallar.transport_profile"); + if (!record || !Array.isArray(record.payloadPreview)) { + return null; + } + return { + profile_id: record.payloadPreview[0] || null, + daemon_id: record.payloadPreview[1] || null, + state: record.payloadPreview[2] || null, + compatibility_transport: record.payloadPreview[3] || null, + current_transport: record.payloadPreview[4] || null, + health_contract: record.payloadPreview[5] || null, + cut_line: record.payloadPreview[9] || null, + updated_at: record.payloadPreview[10] || null, + }; +} + +function normalizeInspectedEndpoints(endpoints) { + if (!Array.isArray(endpoints)) { + return []; + } + return endpoints.map((entry) => { + if (entry && typeof entry === "object" && !Array.isArray(entry)) { + return entry; + } + return { + transport: String(entry || "").startsWith("ws://") ? "compatibility-eve-deck" : "witness", + address: String(entry || ""), + }; + }); +} + +function normalizeInspectedRoutes(advertisement) { + if (Array.isArray(advertisement?.routes)) { + return advertisement.routes; + } + if (Array.isArray(advertisement?.endpoints)) { + return normalizeInspectedEndpoints(advertisement.endpoints); + } + return []; +} + function resolveInterfaceBindingStore(storeSpec) { if (typeof storeSpec !== "string" || !storeSpec.trim()) { return null; diff --git a/src/odin/websocket.cjs b/src/odin/websocket.cjs index 82fa4d2..022fed7 100644 --- a/src/odin/websocket.cjs +++ b/src/odin/websocket.cjs @@ -145,7 +145,18 @@ function stateForRequest(currentState, requestUrl) { return odinCatalogState(currentState); } const providerState = providerStateFromCurrentState(currentState, providerId); - return providerState || unavailableProviderState(providerId, "provider not present in Odin catalog"); + if (providerState) { + return providerState; + } + const provider = providerCatalogFromState(currentState).find((entry) => entry.id === providerId); + if (provider) { + return unavailableProviderState( + providerId, + "provider advertisement is live, but no provider-owned Eve surface is published yet", + provider.title, + ); + } + return unavailableProviderState(providerId, "provider not present in Odin catalog"); } function providerIdFromDeckUrl(requestUrl) { @@ -230,23 +241,23 @@ function providerInterfaceChild(currentState, providerId) { return children.find((child) => child?.kind === "interface" && String(child.props?.providerId || "") === providerId); } -function unavailableProviderState(providerId, detail) { +function unavailableProviderState(providerId, detail, title = null) { return { type: "dashboard-state", schema: "gamecult.eve.provider_surface_proxy.v1", providerId, - title: providerId, + title: title || providerId, version: 0, updatedAt: new Date().toISOString(), surface: { schema: "gamecult.eve.surface.v1", id: `unavailable-${stableSurfaceId(providerId)}`, - title: providerId, + title: title || providerId, root: { id: `unavailable-${stableSurfaceId(providerId)}-root`, kind: "pane", props: { - title: providerId, + title: title || providerId, status: "unavailable", }, children: [{