Publish Gjallar startup respect to Odin

This commit is contained in:
Meta Vens 2026-06-23 23:17:39 +01:00
commit c36b8785d0
5 changed files with 197 additions and 36 deletions

View file

@ -68,19 +68,25 @@ Run against Odin's provider catalog:
/opt/gamecult/gjallar/Gjallar \
--fb /dev/fb0 \
--odin-cultnet-rudp 192.168.1.66:17871 \
--cultcache-path /var/lib/gjallar/gjallar.service.cc \
--refresh-hz 60 \
--stats-path /var/log/gjallar.status
```
In native CultNet/RUDP snapshot mode, Gjallar:
1. requests Odin's accepted provider-state snapshot over `cultnet.transport.rudp.v0`;
2. extracts provider-owned surface roots from Odin's accepted state;
3. builds an in-memory `gjallar.overview` surface;
4. packs panels into weighted pixel regions;
5. chooses a font/cell resolution for each region;
6. draws text, panels, gutters, and marquee;
7. writes one BGRA frame to the framebuffer.
1. writes its typed CultCache witness and publishes its provider advertisement
once to Odin's CultMesh/RUDP document ingress;
2. requests Odin's accepted provider-state snapshot over `cultnet.transport.rudp.v0`;
3. extracts provider-owned surface roots from Odin's accepted state;
4. builds an in-memory `gjallar.overview` surface;
5. packs panels into weighted pixel regions;
6. chooses a font/cell resolution for each region;
7. draws text, panels, gutters, and marquee;
8. writes one BGRA frame to the framebuffer.
`--odin-cultmesh-rudp` may be used when Odin's document ingress differs from
the snapshot endpoint. By default it reuses `--odin-cultnet-rudp`.
The older `--url ws://.../eve/deck` path remains as a compatibility fallback.

View file

@ -16,8 +16,9 @@ regions may use different text resolutions.
font assets, runtime flags, mouse input, Odin's canonical slash-delimited
marquee tape, and Odin's accepted provider-state snapshot over CultNet/RUDP.
- Outputs: `gjallar.overview` composition state, visible framebuffer frames,
cursor presentation, top-tab minimized panel presentation, and renderer
telemetry.
cursor presentation, top-tab minimized panel presentation, renderer
telemetry, a local CultCache witness, and a one-shot provider advertisement
into Odin's CultMesh/RUDP document ingress.
- Derived state: pane weights, pixel rectangles, chosen font sizes, one-row
gutter blocks, an ECS-style structure-of-arrays gutter ribbon, ordered
marquee queue objects, ribbon occupancy, dirty rectangles, glyph runs,
@ -36,7 +37,9 @@ regions may use different text resolutions.
## Current Pipeline
```text
Odin accepted provider-state snapshot over CultNet/RUDP
Gjallar typed CultCache witness
-> one startup provider advertisement to Odin over CultMesh/RUDP
-> Odin accepted provider-state snapshot over CultNet/RUDP
-> display provider selection
-> provider surface extraction
-> canonical marquee tape passthrough

View file

@ -33,29 +33,35 @@ internal sealed record GjallarConfig(
string MousePath,
string SpecimenText,
string CultCachePath,
string OdinCultMeshRudpEndpoint,
string IdunnRudpHealth,
string IdunnDaemon,
string IdunnHealthContract)
{
public static GjallarConfig Parse(IReadOnlyList<string> args) => new(
StringArg(args, "--fb", "/dev/fb0"),
StringArg(args, "--url", "ws://192.168.1.66:8797/eve/deck"),
StringArg(args, "--odin-cultnet-rudp", Environment.GetEnvironmentVariable("GJALLAR_ODIN_CULTNET_RUDP") ?? ""),
StringArg(args, "--provider", ""),
IntArg(args, "--refresh-hz", 2),
IntArg(args, "--catalog-refresh-seconds", 5),
StringArg(args, "--stats-path", "/var/log/gjallar.status"),
StringArg(args, "--frame-dump-path", ""),
IntArg(args, "--frames", 0),
IntArg(args, "--width", 0),
IntArg(args, "--height", 0),
StringArg(args, "--font", ""),
StringArg(args, "--mouse", "/dev/input/mice"),
ResolveSpecimenText(args),
StringArg(args, "--cultcache-path", Environment.GetEnvironmentVariable("GJALLAR_CULTCACHE_PATH") ?? ""),
StringArg(args, "--idunn-rudp-health", Environment.GetEnvironmentVariable("GJALLAR_IDUNN_RUDP_HEALTH") ?? ""),
StringArg(args, "--idunn-daemon", Environment.GetEnvironmentVariable("GJALLAR_IDUNN_DAEMON") ?? "nightwing-gjallar"),
StringArg(args, "--idunn-health-contract", Environment.GetEnvironmentVariable("GJALLAR_IDUNN_HEALTH_CONTRACT") ?? "gjallar.cultnet-rudp-framebuffer-composition-health"));
public static GjallarConfig Parse(IReadOnlyList<string> args)
{
var odinCultNetRudp = StringArg(args, "--odin-cultnet-rudp", Environment.GetEnvironmentVariable("GJALLAR_ODIN_CULTNET_RUDP") ?? "");
return new GjallarConfig(
StringArg(args, "--fb", "/dev/fb0"),
StringArg(args, "--url", "ws://192.168.1.66:8797/eve/deck"),
odinCultNetRudp,
StringArg(args, "--provider", ""),
IntArg(args, "--refresh-hz", 2),
IntArg(args, "--catalog-refresh-seconds", 5),
StringArg(args, "--stats-path", "/var/log/gjallar.status"),
StringArg(args, "--frame-dump-path", ""),
IntArg(args, "--frames", 0),
IntArg(args, "--width", 0),
IntArg(args, "--height", 0),
StringArg(args, "--font", ""),
StringArg(args, "--mouse", "/dev/input/mice"),
ResolveSpecimenText(args),
StringArg(args, "--cultcache-path", Environment.GetEnvironmentVariable("GJALLAR_CULTCACHE_PATH") ?? ""),
StringArg(args, "--odin-cultmesh-rudp", Environment.GetEnvironmentVariable("GJALLAR_ODIN_CULTMESH_RUDP") ?? odinCultNetRudp),
StringArg(args, "--idunn-rudp-health", Environment.GetEnvironmentVariable("GJALLAR_IDUNN_RUDP_HEALTH") ?? ""),
StringArg(args, "--idunn-daemon", Environment.GetEnvironmentVariable("GJALLAR_IDUNN_DAEMON") ?? "nightwing-gjallar"),
StringArg(args, "--idunn-health-contract", Environment.GetEnvironmentVariable("GJALLAR_IDUNN_HEALTH_CONTRACT") ?? "gjallar.cultnet-rudp-framebuffer-composition-health"));
}
public bool UsesOdinCultNetRudp =>
!string.IsNullOrWhiteSpace(OdinCultNetRudpEndpoint);
@ -142,6 +148,12 @@ internal sealed class GjallarRenderer : IDisposable
private string cultCachePublishStatus = "disabled";
private string cultCachePublishError = "";
private string cultCachePublishObservedAt = "";
private readonly object odinStartupRespectLock = new();
private bool odinStartupRespectQueued;
private string odinStartupRespectStatus = "disabled";
private string odinStartupRespectError = "";
private string odinStartupRespectEndpoint = "";
private string odinStartupRespectObservedAt = "";
public GjallarRenderer(GjallarConfig config)
{
@ -1105,6 +1117,13 @@ internal sealed class GjallarRenderer : IDisposable
error = cultCachePublishError,
observedAtUtc = cultCachePublishObservedAt,
},
odinStartupRespect = new
{
endpoint = odinStartupRespectEndpoint,
status = odinStartupRespectStatus,
error = odinStartupRespectError,
observedAtUtc = odinStartupRespectObservedAt,
},
paintMs = Math.Round(paintMs, 2),
timings = new
{
@ -1186,10 +1205,11 @@ internal sealed class GjallarRenderer : IDisposable
try
{
verseRuntime.Publish(pulse);
var providerAdvertisement = verseRuntime.Publish(pulse);
cultCachePublishStatus = "published";
cultCachePublishError = "";
cultCachePublishObservedAt = started.ToString("O", CultureInfo.InvariantCulture);
QueueOdinStartupRespectIfNeeded(providerAdvertisement, started);
}
catch (Exception error)
{
@ -1199,6 +1219,50 @@ internal sealed class GjallarRenderer : IDisposable
}
}
private void QueueOdinStartupRespectIfNeeded(GjallarProviderAdvertisementRecord providerAdvertisement, DateTimeOffset observedAt)
{
if (string.IsNullOrWhiteSpace(config.OdinCultMeshRudpEndpoint))
{
odinStartupRespectStatus = "disabled";
return;
}
lock (odinStartupRespectLock)
{
if (odinStartupRespectQueued)
{
return;
}
odinStartupRespectQueued = true;
odinStartupRespectStatus = "publishing";
odinStartupRespectError = "";
odinStartupRespectEndpoint = config.OdinCultMeshRudpEndpoint;
odinStartupRespectObservedAt = observedAt.ToString("O", CultureInfo.InvariantCulture);
}
_ = Task.Run(() =>
{
try
{
GjallarOdinProviderPublisher.Publish(config.OdinCultMeshRudpEndpoint, config.IdunnDaemon, providerAdvertisement);
lock (odinStartupRespectLock)
{
odinStartupRespectStatus = "published";
odinStartupRespectError = "";
}
}
catch (Exception error)
{
lock (odinStartupRespectLock)
{
odinStartupRespectStatus = "publish-error";
odinStartupRespectError = error.Message;
}
}
});
}
private IdunnDaemonHealthRecord BuildIdunnDaemonHealthRecord(
string status,
int frames,
@ -2792,6 +2856,83 @@ internal static class IdunnRudpHealthPublisher
}
}
internal static class GjallarOdinProviderPublisher
{
private const uint ConnectionId = 0x0d1d0002;
public static void Publish(string endpoint, string runtimeId, GjallarProviderAdvertisementRecord advertisement)
{
var remote = ParseEndpoint(endpoint);
using var socket = new Socket(AddressFamily.InterNetwork, SocketType.Dgram, ProtocolType.Udp);
socket.Bind(new IPEndPoint(IPAddress.Any, 0));
socket.ReceiveTimeout = 100;
using var transport = new CultNetRudpSocketTransportConnection(new CultNetRudpSocketTransportOptions
{
RuntimeId = string.IsNullOrWhiteSpace(runtimeId) ? "nightwing-gjallar" : runtimeId,
Socket = socket,
Mode = CultNetRudpSocketMode.Client,
RemoteEndPoint = remote,
ConnectionId = ConnectionId,
InitialSequence = 1,
ResendDelayMs = 100,
});
if (!transport.ConnectAndWait(Array.Empty<byte>(), TimeSpan.FromSeconds(5), TimeSpan.FromMilliseconds(20)))
{
throw new TimeoutException($"timed out connecting Gjallar Odin provider publisher to {endpoint}");
}
var storedAt = string.IsNullOrWhiteSpace(advertisement.UpdatedAt)
? DateTimeOffset.UtcNow.ToString("O", CultureInfo.InvariantCulture)
: advertisement.UpdatedAt;
var sourceRuntimeId = string.IsNullOrWhiteSpace(runtimeId) ? "nightwing-gjallar" : runtimeId;
var message = new CultNetDocumentPutRawMessage
{
MessageId = $"gjallar-provider:{advertisement.ProviderId}:{storedAt.Replace(':', '-')}",
Document = new CultNetRawDocumentRecord
{
SchemaId = "gamecult.eve.provider_advertisement.v1",
RecordKey = advertisement.ProviderId,
StoredAt = storedAt,
PayloadEncoding = "messagepack",
Payload = MessagePackSerializer.Serialize(advertisement, CultNetSchemaMessageSerialization.Options),
SourceRuntimeId = sourceRuntimeId,
SourceRole = "gjallar.provider",
Tags = ["startup-respect", "odin-verse-discovery"],
},
};
transport.SendSchema(CultNetSchemaMessageSerialization.Serialize(message));
}
private static IPEndPoint ParseEndpoint(string value)
{
var trimmed = value.Trim();
if (trimmed.StartsWith("rudp://", StringComparison.OrdinalIgnoreCase))
{
trimmed = trimmed["rudp://".Length..];
}
var separator = trimmed.LastIndexOf(':');
if (separator <= 0 || separator == trimmed.Length - 1)
{
throw new ArgumentException($"Odin CultMesh/RUDP endpoint must be host:port, got '{value}'.", nameof(value));
}
var host = trimmed[..separator].Trim('[', ']');
var portText = trimmed[(separator + 1)..];
if (!int.TryParse(portText, NumberStyles.Integer, CultureInfo.InvariantCulture, out var port) ||
port <= 0 || port > 65535)
{
throw new ArgumentException($"Odin CultMesh/RUDP endpoint port is invalid: {portText}", nameof(value));
}
var addresses = Dns.GetHostAddresses(host);
var address = addresses.FirstOrDefault(static candidate => candidate.AddressFamily == AddressFamily.InterNetwork) ??
throw new ArgumentException($"Odin CultMesh/RUDP endpoint host has no IPv4 address: {host}", nameof(value));
return new IPEndPoint(address, port);
}
}
internal readonly record struct ColorBgra(byte R, byte G, byte B)
{
public static readonly ColorBgra Black = new(0, 0, 0);

View file

@ -41,11 +41,12 @@ internal sealed class GjallarVerseRuntime : IDisposable
return new GjallarVerseRuntime(config, cache);
}
public void Publish(GjallarVersePulse pulse)
public GjallarProviderAdvertisementRecord Publish(GjallarVersePulse pulse)
{
lock (publishLock)
{
Put(BuildProviderAdvertisement(pulse), ProviderAdvertisementKey);
var providerAdvertisement = BuildProviderAdvertisement(pulse);
Put(providerAdvertisement, ProviderAdvertisementKey);
Put(BuildSurfaceState(pulse), SurfaceStateKey);
Put(BuildRuntimeConfig(pulse), RuntimeConfigKey);
Put(BuildFrameStatus(pulse), FrameStatusKey);
@ -53,6 +54,7 @@ internal sealed class GjallarVerseRuntime : IDisposable
Put(BuildTransportProfile(pulse), TransportProfileKey);
Put(pulse.IdunnHealth, DaemonHealthKey);
cache.FlushAllBackingStores();
return providerAdvertisement;
}
}

View file

@ -1,6 +1,6 @@
# Gjallar State
Last updated: 2026-06-09
Last updated: 2026-06-23
## Identity
@ -26,7 +26,14 @@ surface sources
- GitHub: `https://github.com/GameCult/Gjallar`
- Runtime: `src/Gjallar/Gjallar.csproj`
- Current deployment: Nightwing `gjallar.service`
- Current feed: Odin provider catalog at `ws://192.168.1.66:8797/eve/deck`
- Current feed: Odin accepted provider-state snapshot over CultNet/RUDP at
`192.168.1.66:17871`, with the old Odin Eve deck WebSocket path retained as
compatibility fallback.
- Current CultCache witness: `/var/lib/gjallar/gjallar.service.cc`
- Current startup respect: Gjallar publishes
`gamecult.eve.provider_advertisement.v1` once to Odin's CultMesh/RUDP
document ingress. `--odin-cultmesh-rudp` can override the document endpoint;
otherwise it reuses `--odin-cultnet-rudp`.
- Current status path on Nightwing: `/var/log/gjallar.status`
- Current cursor input: `/dev/input/mice`, rendered as a framebuffer crosshair.
- Current minimized-panel presentation: a top tab row. Clicking a panel title
@ -74,10 +81,12 @@ Observed live status after cursor/minimize cut:
and minimized/restored panel state.
- Inputs: provider catalogs, provider-owned surface trees, display dimensions,
font assets, runtime flags, mouse deltas/buttons, Odin's canonical marquee
tape, and later native CultMesh subscriptions.
tape, Odin's accepted provider-state snapshot over CultNet/RUDP, and later
native CultMesh subscriptions.
- Outputs: `gjallar.overview` composition state, framebuffer frames, sparse
refresh streams, cursor presentation, top-tab minimized panel presentation, and
agent-readable panel captures.
agent-readable panel captures. Gjallar also emits a local CultCache witness
and a one-shot provider advertisement to Odin for Verse discovery.
- Derived state: pane weights, pixel rectangles, selected fonts, one-row gutter
blocks, an ECS-style structure-of-arrays gutter ribbon, ordered marquee queue
objects, ribbon occupancy, dirty rectangles, glyph runs, title-bar hit