Publish canonical Stonks poetry marquee
This commit is contained in:
parent
49f75f85df
commit
2518dc0b10
9 changed files with 167 additions and 42 deletions
|
|
@ -27,8 +27,9 @@ consumes Odin's published Eve/CultUI deck and renders the live display.
|
|||
Gjallar is the herald display daemon that runs on Nightwing. Odin sees the
|
||||
Verses, accepts provider surfaces, and publishes the `odin.providers` catalog.
|
||||
Gjallar talks to Odin, enumerates active providers, composes the multi-scale
|
||||
tiled dashboard, owns the marquee and dense character-level update behavior,
|
||||
and writes the visible framebuffer.
|
||||
tiled dashboard, lowers Odin's canonical marquee tape into continuous gutter
|
||||
text, owns dense character-level update behavior, and writes the visible
|
||||
framebuffer.
|
||||
|
||||
Local package surfaces:
|
||||
|
||||
|
|
|
|||
|
|
@ -67,6 +67,7 @@ Odin's executable body is split by ownership:
|
|||
- `src/odin/observations.cjs`: Mimir observation ledger tailing and dashboard-ready stream projection.
|
||||
- `src/odin/interfaces.cjs`: Eve provider manifest discovery, provider WebSocket fetches, provider advertisements, and CultMesh interface bindings.
|
||||
- `src/odin/layout.cjs`: `odin.interface_layout.v1` read/write and merge policy.
|
||||
- `src/odin/marquee.cjs`: canonical marquee tape assembly from Stonks securities and ordered VoidBot poem lines.
|
||||
- `src/odin/surface.cjs`: `gamecult.eve.surface.v1` tree projection.
|
||||
- `src/odin/state.cjs`: one refresh's input records into Odin's provider catalog/proxy state.
|
||||
- `src/odin/websocket.cjs`: Eve deck HTTP/WebSocket serving and client WebSocket helpers.
|
||||
|
|
@ -76,9 +77,10 @@ The entrypoint is not allowed to grow new probe, surface, provider, layout, or r
|
|||
Gjallar is the Nightwing-resident terminal compositor for what Odin can show.
|
||||
Its runtime lives in `E:\Projects\Gjallar` and consumes Odin's Eve deck
|
||||
directly.
|
||||
Gjallar owns provider enumeration for display, panel packing, marquee behavior,
|
||||
glyph/color/framebuffer lowering, frame stats, and the multi-scale terminal
|
||||
product. It must not own the underlying registry, probe, provider truth, or
|
||||
Odin owns canonical marquee content; Gjallar owns provider enumeration for
|
||||
display, panel packing, marquee lowering, glyph/color/framebuffer lowering,
|
||||
frame stats, and the multi-scale terminal product. It must not own the
|
||||
underlying registry, probe, provider truth, canonical marquee content, or
|
||||
translation decisions.
|
||||
|
||||
Idunn is the named keepalive organ for daemon continuity. Its current Rust
|
||||
|
|
|
|||
|
|
@ -13,15 +13,17 @@ body they are being lowered into.
|
|||
|
||||
## Authority Map
|
||||
|
||||
- Owner: Gjallar owns Nightwing dashboard composition, tiling, marquee, visual
|
||||
density, framebuffer presentation, and character-level refresh behavior.
|
||||
- Owner: Gjallar owns Nightwing dashboard composition, tiling, marquee lowering,
|
||||
visual density, framebuffer presentation, and character-level refresh
|
||||
behavior.
|
||||
- Inputs: Odin's Eve/CultUI deck endpoint, provider ids, provider-owned surface
|
||||
graphs, display constraints, font choices, and operator runtime flags.
|
||||
graphs, Odin's canonical marquee tape, display constraints, font choices, and
|
||||
operator runtime flags.
|
||||
- Outputs: the visible Nightwing framebuffer and compact Gjallar frame/status
|
||||
telemetry.
|
||||
- Derived state: panel packing, visual weight, tile position, gutter cells,
|
||||
marquee tape, glyph size, and frame timing are derived from Odin/provider
|
||||
surfaces plus display constraints.
|
||||
marquee glyph positions, glyph size, and frame timing are derived from
|
||||
Odin/provider surfaces plus display constraints.
|
||||
- Forbidden writers: Gjallar does not probe hosts, accept Verse truth, mutate
|
||||
provider-owned dashboards, invent schema translation routes, or replace Odin's
|
||||
provider registry.
|
||||
|
|
@ -62,7 +64,8 @@ dotnet publish E:\Projects\Gjallar\src\Gjallar\Gjallar.csproj -c Release -r linu
|
|||
```text
|
||||
provider-owned Eve/CultUI surfaces
|
||||
-> Odin discovery and provider catalog/proxy surfaces
|
||||
-> Gjallar provider enumeration, packing, marquee, and framebuffer lowering
|
||||
-> Odin canonical Stonks/poetry marquee tape
|
||||
-> Gjallar provider enumeration, packing, marquee lowering, and framebuffer lowering
|
||||
-> Nightwing visible display
|
||||
```
|
||||
|
||||
|
|
@ -74,6 +77,9 @@ the accepted discovery/provider view. Each daemon owns its own surface truth.
|
|||
- Odin remains the accepted owner of all-seer discovery and provider indexing.
|
||||
- Gjallar owns display composition, not discovery truth.
|
||||
- Provider surfaces are lowered, not rewritten into status summaries.
|
||||
- Marquee content is not provider-boundary status noise. Odin publishes the
|
||||
canonical tape; Gjallar renders it as one continuous stream across gutter
|
||||
rows.
|
||||
- Missing or invalid provider surfaces disappear or render as unavailable; they
|
||||
do not become invented truth.
|
||||
- Frame/status telemetry observes Gjallar's rendering behavior only.
|
||||
|
|
|
|||
|
|
@ -29,10 +29,12 @@ const interfaceDiscovery = createInterfaceDiscovery({
|
|||
});
|
||||
const stateBuilder = createStateBuilder({
|
||||
cachePath: config.cachePath,
|
||||
gamecultTextDocumentStorePath: config.gamecultTextDocumentStorePath,
|
||||
interfaceDiscovery,
|
||||
layoutStore,
|
||||
observationFreshSeconds: config.observationFreshSeconds,
|
||||
observationLogPath: config.observationLogPath,
|
||||
stonksStateUrl: config.stonksStateUrl,
|
||||
});
|
||||
|
||||
let meshNodePromise = null;
|
||||
|
|
|
|||
|
|
@ -26,6 +26,8 @@ function buildConfig(argv) {
|
|||
.filter(Boolean);
|
||||
const observationLogPath = args.observationLogPath || path.join(repoRoot, "..", "Mimir", "artifacts", "runtime", "periwinkle-cultmesh-sensors.out.log");
|
||||
const observationFreshSeconds = Number(args.observationFreshSeconds || 120);
|
||||
const gamecultTextDocumentStorePath = args.gamecultTextDocumentStorePath || path.join(repoRoot, "..", "VoidBot", ".voidbot", "private", "gamecult-text-documents.cc");
|
||||
const stonksStateUrl = args.stonksStateUrl || "http://127.0.0.1:8802/market/state";
|
||||
const defaultInterfaceBindingStores = [
|
||||
path.join(repoRoot, "..", "VoidBot", ".voidbot", "status", "cultmesh", "voidbot-swarm-state.cc"),
|
||||
path.join(repoRoot, "..", "Bifrost", ".bifrost", "provider-advertisement.cc"),
|
||||
|
|
@ -41,6 +43,7 @@ function buildConfig(argv) {
|
|||
return {
|
||||
args,
|
||||
cachePath,
|
||||
gamecultTextDocumentStorePath,
|
||||
host,
|
||||
interfaceBindingStores,
|
||||
intervalMs,
|
||||
|
|
@ -51,6 +54,7 @@ function buildConfig(argv) {
|
|||
repoRoot,
|
||||
seedDeckUrls,
|
||||
stateDir,
|
||||
stonksStateUrl,
|
||||
surfaceKey: "surface:gamecult.network.status",
|
||||
};
|
||||
}
|
||||
|
|
|
|||
133
src/odin/marquee.cjs
Normal file
133
src/odin/marquee.cjs
Normal file
|
|
@ -0,0 +1,133 @@
|
|||
"use strict";
|
||||
|
||||
const fs = require("fs");
|
||||
const {
|
||||
CultCache,
|
||||
SingleFileMessagePackBackingStore,
|
||||
defineDocumentRegistry,
|
||||
defineDocumentType,
|
||||
} = require("cultcache-ts");
|
||||
const { httpGet } = require("./utils.cjs");
|
||||
|
||||
const textDocumentSetDefinition = defineDocumentType({
|
||||
type: "gamecult.text_document_set",
|
||||
global: true,
|
||||
schema: {
|
||||
parse(value) {
|
||||
if (!value || typeof value !== "object") {
|
||||
throw new Error("gamecult.text_document_set must be an object");
|
||||
}
|
||||
return value;
|
||||
},
|
||||
},
|
||||
});
|
||||
|
||||
async function buildMarqueeText({ interfaces, textDocumentStorePath, stonksStateUrl }) {
|
||||
const [securities, poetry] = await Promise.all([
|
||||
stonksSegments({ interfaces, stonksStateUrl }),
|
||||
poetrySegments(textDocumentStorePath),
|
||||
]);
|
||||
return interweave(securities, poetry).join(" / ");
|
||||
}
|
||||
|
||||
async function stonksSegments({ interfaces, stonksStateUrl }) {
|
||||
const fromInterface = stonksSegmentsFromInterfaces(interfaces);
|
||||
if (fromInterface.length) return fromInterface;
|
||||
return stonksSegmentsFromSnapshot(stonksStateUrl);
|
||||
}
|
||||
|
||||
function stonksSegmentsFromInterfaces(interfaces) {
|
||||
const stonks = interfaces.find((entry) => String(entry.providerId || "").toLowerCase() === "stonks.market");
|
||||
const explicit = String(stonks?.surface?.root?.props?.marqueeText || "").trim();
|
||||
return splitSegments(explicit).slice(0, 16);
|
||||
}
|
||||
|
||||
async function stonksSegmentsFromSnapshot(stonksStateUrl) {
|
||||
if (!stonksStateUrl) return [];
|
||||
try {
|
||||
const snapshot = JSON.parse(await httpGet(stonksStateUrl, 1200));
|
||||
const quotes = [...array(snapshot.crypto), ...array(snapshot.equities)]
|
||||
.slice(0, 16)
|
||||
.map(quoteText)
|
||||
.filter(Boolean);
|
||||
const warnings = [
|
||||
snapshot?.sources?.equities?.ok === false ? "EQUITIES SOURCE ERROR" : "",
|
||||
snapshot?.sources?.crypto?.ok === false ? "CRYPTO SOURCE ERROR" : "",
|
||||
].filter(Boolean);
|
||||
return [...quotes, ...warnings];
|
||||
} catch {
|
||||
return [];
|
||||
}
|
||||
}
|
||||
|
||||
async function poetrySegments(textDocumentStorePath) {
|
||||
if (!textDocumentStorePath || !fs.existsSync(textDocumentStorePath)) return [];
|
||||
try {
|
||||
const cache = CultCache.builder()
|
||||
.withRegistry(defineDocumentRegistry(textDocumentSetDefinition))
|
||||
.withGenericStore(new SingleFileMessagePackBackingStore(textDocumentStorePath))
|
||||
.build();
|
||||
await cache.pullAllBackingStores();
|
||||
const documentSet = cache.getGlobal(textDocumentSetDefinition);
|
||||
return array(documentSet?.documents)
|
||||
.flatMap((document) => array(document.lines))
|
||||
.filter((line) => !isStanzaMarker(line))
|
||||
.map((line) => array(line).join(" / ").replace(/\s+/g, " ").trim())
|
||||
.filter(Boolean);
|
||||
} catch {
|
||||
return [];
|
||||
}
|
||||
}
|
||||
|
||||
function interweave(securities, poetry) {
|
||||
const output = [];
|
||||
const count = Math.max(securities.length, poetry.length);
|
||||
for (let index = 0; index < count; index += 1) {
|
||||
if (securities[index]) output.push(securities[index]);
|
||||
if (poetry[index]) output.push(poetry[index]);
|
||||
}
|
||||
return output;
|
||||
}
|
||||
|
||||
function splitSegments(text) {
|
||||
return String(text || "")
|
||||
.split(/\s+\/\s+/)
|
||||
.map((segment) => segment.replace(/\s+/g, " ").trim())
|
||||
.filter(Boolean);
|
||||
}
|
||||
|
||||
function quoteText(item) {
|
||||
if (!item?.symbol) return "";
|
||||
const price = item.price == null ? "N/D" : `$${formatNumber(item.price)}`;
|
||||
const change = item.change24h == null ? "" : ` ${item.change24h >= 0 ? "+" : ""}${Number(item.change24h).toFixed(2)}%`;
|
||||
const volume = item.volume24h ?? item.volume;
|
||||
const volumeText = volume == null ? "" : ` vol ${formatCompact(volume)}`;
|
||||
return `${item.symbol} ${price}${change}${volumeText}`;
|
||||
}
|
||||
|
||||
function formatNumber(value) {
|
||||
const number = Number(value);
|
||||
if (!Number.isFinite(number)) return "N/D";
|
||||
if (Math.abs(number) >= 1000) return number.toFixed(0);
|
||||
if (Math.abs(number) >= 1) return number.toFixed(2);
|
||||
return number.toFixed(4);
|
||||
}
|
||||
|
||||
function formatCompact(value) {
|
||||
const number = Number(value);
|
||||
if (!Number.isFinite(number)) return "N/D";
|
||||
return Intl.NumberFormat("en", { notation: "compact", maximumFractionDigits: 1 }).format(number);
|
||||
}
|
||||
|
||||
function isStanzaMarker(line) {
|
||||
const parts = array(line);
|
||||
return parts.length === 1 && String(parts[0]).trim().toLowerCase() === "[stanza]";
|
||||
}
|
||||
|
||||
function array(value) {
|
||||
return Array.isArray(value) ? value : [];
|
||||
}
|
||||
|
||||
module.exports = {
|
||||
buildMarqueeText,
|
||||
};
|
||||
|
|
@ -13,10 +13,11 @@ const {
|
|||
remoteServices,
|
||||
systemdState,
|
||||
} = require("./probes.cjs");
|
||||
const { buildMarqueeText } = require("./marquee.cjs");
|
||||
const { buildPendingSurface, buildSurface } = require("./surface.cjs");
|
||||
const { stableId } = require("./utils.cjs");
|
||||
|
||||
function createStateBuilder({ cachePath, interfaceDiscovery, layoutStore, observationFreshSeconds, observationLogPath }) {
|
||||
function createStateBuilder({ cachePath, gamecultTextDocumentStorePath, interfaceDiscovery, layoutStore, observationFreshSeconds, observationLogPath, stonksStateUrl }) {
|
||||
let version = 0;
|
||||
|
||||
function buildPendingState(message) {
|
||||
|
|
@ -51,6 +52,7 @@ function createStateBuilder({ cachePath, interfaceDiscovery, layoutStore, observ
|
|||
]);
|
||||
const interfaceById = new Map(discoveredInterfaces.map((entry) => [entry.providerId, entry]));
|
||||
const interfaces = [...interfaceById.values()];
|
||||
const marqueeText = await buildMarqueeText({ interfaces, textDocumentStorePath: gamecultTextDocumentStorePath, stonksStateUrl });
|
||||
const interfaceSummary = interfaces.map((entry) => `${entry.providerId}:${entry.state}`).join(", ");
|
||||
const voidBotDashboard = interfaceById.get("voidbot.swarm") || dashboardUnavailable("voidbot.swarm", "discovery", "not discovered");
|
||||
const mimirLiveStats = interfaceById.get("mimir.live.stats") || dashboardUnavailable("mimir.live.stats", "discovery", "not discovered");
|
||||
|
|
@ -110,7 +112,7 @@ function createStateBuilder({ cachePath, interfaceDiscovery, layoutStore, observ
|
|||
detail: entry.capabilities.join(", "),
|
||||
})),
|
||||
providerCatalog: providerAdvertisements,
|
||||
surface: buildSurface({ observedAt, docker, adb, hosts, yggdrasilServices, verses, interfaces, observations, layout: layoutStore.readLayout() }),
|
||||
surface: buildSurface({ observedAt, docker, adb, hosts, yggdrasilServices, verses, interfaces, observations, layout: layoutStore.readLayout(), marqueeText }),
|
||||
};
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -4,7 +4,7 @@ const { analyzeElementTree, fullscreenLayoutIntent, mergeLayoutIntent } = requir
|
|||
const { observationPane } = require("./observations.cjs");
|
||||
const { stableId } = require("./utils.cjs");
|
||||
|
||||
function buildSurface({ observedAt, docker, adb, hosts, yggdrasilServices, verses, interfaces, observations, layout }) {
|
||||
function buildSurface({ observedAt, docker, adb, hosts, yggdrasilServices, verses, interfaces, observations, layout, marqueeText = "" }) {
|
||||
const activeInterfaces = interfaces.filter((entry) => entry?.surface?.root);
|
||||
const activeObservationStreams = observations.streams.filter((entry) => entry.state === "active");
|
||||
return {
|
||||
|
|
@ -18,7 +18,7 @@ function buildSurface({ observedAt, docker, adb, hosts, yggdrasilServices, verse
|
|||
title: "Odin Provider Catalog",
|
||||
observedAt,
|
||||
summary: `${activeInterfaces.length} Eve surfaces / ${activeObservationStreams.length} live streams`,
|
||||
marqueeText: marketMarqueeText(interfaces),
|
||||
marqueeText,
|
||||
layout: fullscreenLayoutIntent("odin.providers", -100),
|
||||
presentation: {
|
||||
theme: "bifrost-pride",
|
||||
|
|
@ -92,33 +92,6 @@ function stonksHasOverviewSignal(root, text) {
|
|||
return /\b(Market pulse|BITCOIN|ETHEREUM|SOLANA|DOGECOIN|equities|crypto|vol|request traffic|source health)\b/i.test(text);
|
||||
}
|
||||
|
||||
function marketMarqueeText(interfaces) {
|
||||
const stonks = interfaces.find((entry) => String(entry.providerId || "").toLowerCase() === "stonks.market");
|
||||
const root = stonks?.surface?.root;
|
||||
if (!root) return generalMarqueeText(interfaces);
|
||||
const explicit = String(root.props?.marqueeText || "").trim();
|
||||
if (explicit) return explicit;
|
||||
return surfaceText(root)
|
||||
.split(/\r?\n/)
|
||||
.map((line) => line.trim())
|
||||
.filter((line) => /\b(BITCOIN|ETHEREUM|SOLANA|DOGECOIN|[A-Z0-9.]{2,}\s+\$|vol|request|equities|crypto|Stooq|CoinGecko)\b/i.test(line))
|
||||
.slice(0, 24)
|
||||
.join(" / ");
|
||||
}
|
||||
|
||||
function generalMarqueeText(interfaces) {
|
||||
return interfaces
|
||||
.filter((entry) => entry?.surface?.root && entry.state === "active")
|
||||
.flatMap((entry) => surfaceText(entry.surface.root)
|
||||
.split(/\r?\n/)
|
||||
.map((line) => line.trim())
|
||||
.filter(Boolean)
|
||||
.map((line) => `${entry.title || entry.providerId}: ${line}`))
|
||||
.filter((line) => !/\b(unavailable|not discovered|playing:\s*none|queue:\s*empty)\b/i.test(line))
|
||||
.slice(0, 24)
|
||||
.join(" / ");
|
||||
}
|
||||
|
||||
function spotiverseHasOverviewSignal(root, text) {
|
||||
const status = String(root.props?.status || "").toLowerCase();
|
||||
if (status === "warn" && /\brate limit\b/i.test(text)) return false;
|
||||
|
|
|
|||
|
|
@ -25,6 +25,7 @@ function handleHttp(req, res, getCurrentState, getHealth) {
|
|||
if (req.url === "/eve/deck/providers") {
|
||||
res.writeHead(200, { "content-type": "application/json" });
|
||||
res.end(JSON.stringify({
|
||||
marqueeText: String(currentState?.surface?.root?.props?.marqueeText || ""),
|
||||
providers: providerCatalogFromState(currentState),
|
||||
}));
|
||||
return;
|
||||
|
|
@ -179,6 +180,7 @@ function odinCatalogState(currentState) {
|
|||
props: {
|
||||
title: "Odin Providers",
|
||||
summary: `${providers.length} provider surfaces discovered`,
|
||||
marqueeText: String(currentState?.surface?.root?.props?.marqueeText || ""),
|
||||
},
|
||||
children: providers.map((provider) => ({
|
||||
id: `provider-${stableSurfaceId(provider.id)}`,
|
||||
|
|
|
|||
Loading…
Reference in a new issue