Serve Odin snapshots and retire Gjallar bridge debt
This commit is contained in:
parent
3bfb80143a
commit
b43d2a3136
7 changed files with 322 additions and 89 deletions
|
|
@ -56,9 +56,11 @@ Idunn is a Rust daemon inside Odin's Cargo workspace. The live local runtime is
|
|||
one long-lived `idunn.exe` process that owns the whole Starfire-local swarm:
|
||||
Odin, local adjunct daemons, the Yggdrasil deploy lanes, and the Nightwing
|
||||
display services. Each target declares a daemon-owned health contract and keeps
|
||||
its own interval and deploy/restart authority. The current shell health
|
||||
commands are compatibility probes until each daemon updates its CultLib
|
||||
dependency and publishes health through CultNet over the shared RUDP transport.
|
||||
its own interval and deploy/restart authority. The shell health commands now
|
||||
exist as compatibility probes and actuators; daemon truth is expected to come
|
||||
first from typed CultNet/RUDP publication and daemon-owned boundary stores, and
|
||||
the local commands only matter when that witness is absent or when an explicit
|
||||
restart/deploy boundary is advertised.
|
||||
The scheduler and continuity witness now belong to one Rust process instead of
|
||||
a PowerShell-herded pile of one-daemon workers.
|
||||
|
||||
|
|
@ -220,61 +222,33 @@ probe. The record must match the daemon id, health contract, RUDP transport,
|
|||
and freshness window; otherwise the compatibility probe remains fallback
|
||||
evidence.
|
||||
|
||||
The current active cut has moved past Raven daemon launcher surgery and into the
|
||||
remaining Yggdrasil deployments, with repixelizer now the explicit next target.
|
||||
Heimdall has crossed the first live transport cut: the Yggdrasil runtime now
|
||||
publishes `heimdall.cultnet-rudp-provider-health`, writes a daemon-owned
|
||||
boundary witness at `/srv/heimdall/cultcache/heimdall.service.cc`, and ships
|
||||
the required `CultLib` snapshot through the source-artifact lane. Heimdall
|
||||
still owes Odin ingestion of that typed store plus the later redacted
|
||||
auth-document witness export, but it is no longer blocked on basic daemon
|
||||
health publication. Vili now publishes RUDP health from Raven
|
||||
through the hidden `GameCult\Vili` scheduled task, and live Idunn accepts
|
||||
`vili.cultnet-rudp-animation-health` from `10.77.0.4`. The Raven repair
|
||||
actuator in [restart-vili.ps1](/E:/Projects/Odin/scripts/restart-vili.ps1)
|
||||
syncs the authoritative Vili runtime plus flattened CultLib node modules before
|
||||
reinstalling the hidden task. Vili also writes a daemon-owned
|
||||
`.vili\vili.service.cc` store with provider advertisement, operator state, Eve
|
||||
surface, command boundary, and transport profile records; Odin local discovery
|
||||
can ingest that typed store. Weksa publishes RUDP health and a daemon-owned
|
||||
provider store containing provider advertisement, operator state, Eve surface,
|
||||
command boundary, and transport profile records; Odin local discovery can ingest
|
||||
that typed store too. Weksa still owes CultNet/RUDP command document ingress
|
||||
for MiMo VoiceDesign before its HTTP command route can become debug-only.
|
||||
Stonks publishes RUDP health and a daemon-owned CultCache store containing
|
||||
provider advertisement, market snapshot, Eve surface, command boundary, and
|
||||
transport profile records; Odin local discovery can ingest that store as
|
||||
provider truth. StreamPixels now publishes a service-owned CultCache boundary
|
||||
store with provider advertisement, command boundary, transport profile, and
|
||||
Idunn health summary; Odin local discovery can ingest that store, and the live
|
||||
Yggdrasil service now publishes daemon health over CultNet/RUDP with
|
||||
`STREAMPIXELS_IDUNN_RUDP_HEALTH=10.77.0.2:17870` and contract
|
||||
`streampixels.cultnet-rudp-service-health` in
|
||||
`/srv/streampixels/env/service.env`. Live Idunn accepts
|
||||
`yggdrasil-streampixels` from `10.77.0.1`, and the service-owned boundary store
|
||||
now lives at
|
||||
`/srv/streampixels/app/.streampixels-data/cultcache/streampixels.service.cc`.
|
||||
The remaining debt is only to demote SSH/systemd/HTTP probes from compatibility
|
||||
proof to deployment/debug witness once Odin consumes the typed store without
|
||||
fallback. Repixelizer is still plain GUI/systemd compatibility debt for now,
|
||||
which makes it the next Yggdrasil surgery target:
|
||||
`repixelizer-gui.service`, `/api/health`, `/api/config`, and nginx routing are
|
||||
still the live witnesses until the runtime publishes internal RUDP health and
|
||||
typed queue/provider state. Raven Muninn task actions are also an explicit ops invariant: Task
|
||||
Scheduler must execute `wscript.exe //B //Nologo` hidden launcher actions
|
||||
directly for `GameCult-Muninn`, `GameCult-Muninn-Activate`, and
|
||||
The active transport cut is no longer "make the daemons speak RUDP at all."
|
||||
Nightwing Gjallar now consumes Odin's accepted
|
||||
`surface:gamecult.network.status` snapshot over CultNet/RUDP, so every active
|
||||
Starfire-local daemon target now publishes daemon-owned RUDP health plus typed
|
||||
boundary state. The remaining debt is deleting or demoting compatibility
|
||||
probes, HTTP/WebSocket/TCP lowerings, and xenos-boundary ingestion shims
|
||||
without letting them reclaim ownership. Weksa still owes CultNet/RUDP command
|
||||
document ingress for MiMo VoiceDesign before its HTTP command route can become
|
||||
debug-only, and Odin still owes removal of hashed-store/C# witness shims once
|
||||
direct interoperable witness publication is ready.
|
||||
|
||||
Raven Muninn task actions are also an explicit ops invariant: Task Scheduler
|
||||
must execute `wscript.exe //B //Nologo` hidden launcher actions directly for
|
||||
`GameCult-Muninn`, `GameCult-Muninn-Activate`, and
|
||||
`GameCult-Muninn-VideoProof`, never raw `.cmd` wrappers, and the hidden VBS
|
||||
layer must call `.ps1` launchers directly instead of `cmdPath` trampolines.
|
||||
Those three live Raven tasks have been repaired and verified. The repair actuator now uploads its
|
||||
Raven PowerShell body with `sftp` and runs a tiny cleanup wrapper, so the
|
||||
hidden-task repair does not hit Windows command-line limits before it can run.
|
||||
The long-running Muninn serve bodies on Raven, Nightwing, and Starfire now also
|
||||
carry their own `--idunn-rudp-health`, `--idunn-daemon`, and
|
||||
`--idunn-health-contract` arguments, and live Idunn accepts those daemon-owned
|
||||
health records directly instead of relying on one-shot health commands for the
|
||||
truth.
|
||||
After those live cuts, continue daemon-by-daemon until compatibility HTTP, TCP,
|
||||
WebSocket, and command probes are fallback witnesses only.
|
||||
Those three live Raven tasks have been repaired and verified. The repair
|
||||
actuator now uploads its Raven PowerShell body with `sftp` and runs a tiny
|
||||
cleanup wrapper, so the hidden-task repair does not hit Windows command-line
|
||||
limits before it can run. The long-running Muninn serve bodies on Raven,
|
||||
Nightwing, and Starfire now also carry their own `--idunn-rudp-health`,
|
||||
`--idunn-daemon`, and `--idunn-health-contract` arguments, and live Idunn
|
||||
accepts those daemon-owned health records directly instead of relying on
|
||||
one-shot health commands for the truth.
|
||||
|
||||
From here on out, the work is not "teach another daemon to speak." It is
|
||||
"delete the witness masks and keep ownership where it belongs."
|
||||
|
||||
Rust no longer gets to claim the transport is imaginary:
|
||||
`vendor/cultnet-rs` includes the canonical CNR0 `cultnet.transport.rudp.v0`
|
||||
|
|
|
|||
|
|
@ -5,6 +5,7 @@ const fs = require("fs");
|
|||
const path = require("path");
|
||||
|
||||
const { buildConfig, loadCultRuntime } = require("./odin/config.cjs");
|
||||
const { createCultNetRudpSurfaceServer } = require("./odin/cultnet-rudp.cjs");
|
||||
const { defineOdinDocuments } = require("./odin/documents.cjs");
|
||||
const { createInterfaceDiscovery } = require("./odin/interfaces.cjs");
|
||||
const { createIdunnRudpHealthPublisher, publishIdunnRudpHealth } = require("./odin/idunn-rudp.cjs");
|
||||
|
|
@ -41,6 +42,7 @@ const stateBuilder = createStateBuilder({
|
|||
});
|
||||
|
||||
let meshNodePromise = null;
|
||||
let cultNetRudpSurfaceServer = null;
|
||||
let currentState = stateBuilder.buildPendingState("Coordinator starting");
|
||||
let lastRefresh = {
|
||||
completedAt: null,
|
||||
|
|
@ -59,6 +61,20 @@ async function main() {
|
|||
if (cultRuntime.CultMesh && documents.surfaceDefinition) {
|
||||
meshNodePromise = createDurableSurfaceNode();
|
||||
}
|
||||
if (config.cultnetRudpBind) {
|
||||
cultNetRudpSurfaceServer = createCultNetRudpSurfaceServer({
|
||||
bind: config.cultnetRudpBind,
|
||||
documents,
|
||||
getCache: async () => {
|
||||
if (!meshNodePromise) {
|
||||
throw new Error("CultMesh runtime is unavailable; Odin cannot serve a CultNet/RUDP snapshot.");
|
||||
}
|
||||
return (await meshNodePromise).cache;
|
||||
},
|
||||
});
|
||||
await cultNetRudpSurfaceServer.start();
|
||||
console.log(`CultNet/RUDP snapshot: ${config.cultnetRudpBind}`);
|
||||
}
|
||||
|
||||
const dashboardServer = createDashboardServer({
|
||||
applyClientCommand: (command) => layoutStore.applyClientCommand(command),
|
||||
|
|
@ -177,6 +193,7 @@ function health(clients) {
|
|||
error: cultRuntime.error?.message || null,
|
||||
},
|
||||
discovery: {
|
||||
cultNetRudpBind: config.cultnetRudpBind || null,
|
||||
seedDeckUrls: config.seedDeckUrls,
|
||||
discoveredDeckUrls: interfaceDiscovery.getDiscoveredDeckUrls(),
|
||||
interfaceBindingStores: config.interfaceBindingStores,
|
||||
|
|
|
|||
|
|
@ -16,6 +16,7 @@ function buildConfig(argv) {
|
|||
const args = parseArgs(argv);
|
||||
const port = Number(args.port || 8797);
|
||||
const host = args.host || "0.0.0.0";
|
||||
const cultnetRudpBind = args["cultnet-rudp-bind"] ? String(args["cultnet-rudp-bind"]) : "";
|
||||
const intervalMs = Number(args.intervalMs || 5000);
|
||||
const stateDir = args.stateDir || path.join(repoRoot, "scratch", "odin");
|
||||
const cachePath = args.cachePath || path.join(stateDir, "odin.ccmp");
|
||||
|
|
@ -57,6 +58,7 @@ function buildConfig(argv) {
|
|||
return {
|
||||
args,
|
||||
cachePath,
|
||||
cultnetRudpBind,
|
||||
gamecultTextDocumentStorePath,
|
||||
host,
|
||||
interfaceBindingStores,
|
||||
|
|
|
|||
229
src/odin/cultnet-rudp.cjs
Normal file
229
src/odin/cultnet-rudp.cjs
Normal file
|
|
@ -0,0 +1,229 @@
|
|||
"use strict";
|
||||
|
||||
const dgram = require("dgram");
|
||||
const path = require("path");
|
||||
const { createRequire } = require("module");
|
||||
|
||||
const requireCultNet = createRequire(path.resolve(
|
||||
__dirname,
|
||||
"..",
|
||||
"..",
|
||||
"..",
|
||||
"CultLib",
|
||||
"packages",
|
||||
"cultnet-ts",
|
||||
"package.json",
|
||||
));
|
||||
|
||||
const {
|
||||
CultNetDocumentRegistry,
|
||||
CultNetRudpSession,
|
||||
cultNetBuiltinSchemaRegistry,
|
||||
decodeRudpPacket,
|
||||
defineCultNetDocumentBinding,
|
||||
encodeCultNetMessageForWire,
|
||||
encodeRudpPacket,
|
||||
parseCultNetMessage,
|
||||
} = requireCultNet("./dist/index.js");
|
||||
const { decode, encode } = requireCultNet("@msgpack/msgpack");
|
||||
|
||||
const ODIN_RUDP_CONNECTION_ID = 0x0d1d0002;
|
||||
const DEFAULT_SESSION_TIMEOUT_MS = 30_000;
|
||||
|
||||
function createCultNetRudpSurfaceServer(options) {
|
||||
if (!options?.bind) return null;
|
||||
if (!options.documents?.surfaceDefinition) {
|
||||
throw new Error("Odin CultNet/RUDP surface server requires a surface document definition.");
|
||||
}
|
||||
if (typeof options.getCache !== "function") {
|
||||
throw new Error("Odin CultNet/RUDP surface server requires an async getCache function.");
|
||||
}
|
||||
|
||||
const bind = parseEndpoint(options.bind);
|
||||
const documentRegistry = new CultNetDocumentRegistry([
|
||||
defineCultNetDocumentBinding({ definition: options.documents.surfaceDefinition }),
|
||||
]);
|
||||
const sessions = new Map();
|
||||
const socket = dgram.createSocket(bind.host.includes(":") ? "udp6" : "udp4");
|
||||
const resendPollMs = Math.max(10, Number(options.resendPollMs || 25));
|
||||
const sessionTimeoutMs = Math.max(1_000, Number(options.sessionTimeoutMs || DEFAULT_SESSION_TIMEOUT_MS));
|
||||
let resendTimer = null;
|
||||
|
||||
socket.on("message", (wire, remote) => {
|
||||
try {
|
||||
const packet = decodeRudpPacket(wire);
|
||||
handlePacket(packet, remote).catch((error) => {
|
||||
logError(options, `CultNet/RUDP packet handling failed for ${remote.address}:${remote.port}`, error);
|
||||
});
|
||||
} catch (error) {
|
||||
logError(options, "CultNet/RUDP packet decode failed", error);
|
||||
}
|
||||
});
|
||||
|
||||
socket.on("error", (error) => {
|
||||
logError(options, "CultNet/RUDP socket error", error);
|
||||
});
|
||||
|
||||
async function start() {
|
||||
await new Promise((resolve, reject) => {
|
||||
socket.once("error", reject);
|
||||
socket.bind(bind.port, bind.host, () => {
|
||||
socket.off("error", reject);
|
||||
resolve();
|
||||
});
|
||||
});
|
||||
resendTimer = setInterval(() => {
|
||||
try {
|
||||
const nowMs = Date.now();
|
||||
for (const [key, record] of sessions) {
|
||||
if (record.session.checkTimeout(nowMs, sessionTimeoutMs)) {
|
||||
sessions.delete(key);
|
||||
continue;
|
||||
}
|
||||
for (const packet of record.session.dueResends(nowMs)) {
|
||||
sendPacket(record.remote, packet);
|
||||
}
|
||||
}
|
||||
} catch (error) {
|
||||
logError(options, "CultNet/RUDP resend loop failed", error);
|
||||
}
|
||||
}, resendPollMs);
|
||||
resendTimer.unref?.();
|
||||
}
|
||||
|
||||
function close() {
|
||||
if (resendTimer) {
|
||||
clearInterval(resendTimer);
|
||||
resendTimer = null;
|
||||
}
|
||||
sessions.clear();
|
||||
socket.close();
|
||||
}
|
||||
|
||||
async function handlePacket(packet, remote) {
|
||||
const key = remoteKey(remote);
|
||||
const nowMs = Date.now();
|
||||
let record = sessions.get(key);
|
||||
|
||||
if (packet.packetType === "connect") {
|
||||
record = {
|
||||
remote: { address: remote.address, family: remote.family, port: remote.port },
|
||||
session: new CultNetRudpSession({
|
||||
connectionId: ODIN_RUDP_CONNECTION_ID,
|
||||
initialSequence: 1,
|
||||
resendDelayMs: 100,
|
||||
}),
|
||||
};
|
||||
sessions.set(key, record);
|
||||
sendPacket(record.remote, record.session.acceptConnect(packet, nowMs, new Uint8Array()));
|
||||
return;
|
||||
}
|
||||
|
||||
if (!record) {
|
||||
return;
|
||||
}
|
||||
|
||||
const result = record.session.receive(packet, nowMs);
|
||||
if (result.reply) {
|
||||
sendPacket(record.remote, result.reply);
|
||||
}
|
||||
for (const frame of result.delivered) {
|
||||
if (frame.channelId !== "schema") {
|
||||
continue;
|
||||
}
|
||||
await handleSchemaFrame(record, frame.payload);
|
||||
}
|
||||
if (result.disconnected) {
|
||||
sessions.delete(key);
|
||||
return;
|
||||
}
|
||||
if (packet.packetType === "accept" || result.delivered.length > 0) {
|
||||
sendPacket(record.remote, record.session.createAck());
|
||||
}
|
||||
}
|
||||
|
||||
async function handleSchemaFrame(record, payload) {
|
||||
const message = parseCultNetMessage(decode(payload), "cultnet.schema.v0");
|
||||
switch (message.schemaVersion) {
|
||||
case "cultnet.snapshot_request.v0": {
|
||||
try {
|
||||
const cache = await options.getCache();
|
||||
const response = documentRegistry.createRawSnapshotResponse(cache, message.messageId, message);
|
||||
sendSchemaMessage(record, response);
|
||||
} catch (error) {
|
||||
sendSchemaMessage(record, {
|
||||
schemaVersion: "cultnet.error.v0",
|
||||
error: error.message,
|
||||
});
|
||||
}
|
||||
return;
|
||||
}
|
||||
case "cultnet.schema_catalog_request.v0":
|
||||
sendSchemaMessage(record, cultNetBuiltinSchemaRegistry.createCatalogResponse(message));
|
||||
return;
|
||||
default:
|
||||
sendSchemaMessage(record, {
|
||||
schemaVersion: "cultnet.error.v0",
|
||||
error: `Unsupported Odin CultNet/RUDP request ${message.schemaVersion}.`,
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
function sendSchemaMessage(record, message) {
|
||||
const payload = encode(encodeCultNetMessageForWire(message, "cultnet.schema.v0"));
|
||||
for (const packet of record.session.sendMany("schema", payload, {
|
||||
reliable: true,
|
||||
ordered: true,
|
||||
nowMs: Date.now(),
|
||||
})) {
|
||||
sendPacket(record.remote, packet);
|
||||
}
|
||||
}
|
||||
|
||||
function sendPacket(remote, packet) {
|
||||
const wire = Buffer.from(encodeRudpPacket(packet));
|
||||
socket.send(wire, remote.port, remote.address);
|
||||
}
|
||||
|
||||
return {
|
||||
bind,
|
||||
start,
|
||||
close,
|
||||
};
|
||||
}
|
||||
|
||||
function parseEndpoint(value) {
|
||||
const text = String(value || "").trim();
|
||||
const ipv6 = text.match(/^\[([^\]]+)\]:(\d+)$/);
|
||||
if (ipv6) return { host: ipv6[1], port: parsePort(ipv6[2]) };
|
||||
const index = text.lastIndexOf(":");
|
||||
if (index <= 0) {
|
||||
throw new Error(`CultNet/RUDP bind must be host:port, got "${value}".`);
|
||||
}
|
||||
return { host: text.slice(0, index), port: parsePort(text.slice(index + 1)) };
|
||||
}
|
||||
|
||||
function parsePort(value) {
|
||||
const port = Number(value);
|
||||
if (!Number.isInteger(port) || port <= 0 || port > 65535) {
|
||||
throw new Error(`CultNet/RUDP port is invalid: ${value}`);
|
||||
}
|
||||
return port;
|
||||
}
|
||||
|
||||
function remoteKey(remote) {
|
||||
return `${remote.address}:${remote.port}`;
|
||||
}
|
||||
|
||||
function logError(options, label, error) {
|
||||
const message = error instanceof Error ? error.message : String(error);
|
||||
if (typeof options?.logError === "function") {
|
||||
options.logError(`${label}: ${message}`);
|
||||
return;
|
||||
}
|
||||
console.error(`${label}: ${message}`);
|
||||
}
|
||||
|
||||
module.exports = {
|
||||
createCultNetRudpSurfaceServer,
|
||||
};
|
||||
Loading…
Reference in a new issue