From ba5ac54e3217c84ac29dbf2b9ce2e1a742ca74ef Mon Sep 17 00:00:00 2001 From: Meta Vens Date: Mon, 24 Aug 2026 20:51:02 +0200 Subject: [PATCH] Prevent recursive Gjallar aggregates --- docs/architecture.md | 2 +- src/Gjallar/Program.cs | 25 +++++++++++++++++-------- state/gjallar-state.md | 15 +++++++-------- 3 files changed, 25 insertions(+), 17 deletions(-) diff --git a/docs/architecture.md b/docs/architecture.md index 253ac26..9622479 100644 --- a/docs/architecture.md +++ b/docs/architecture.md @@ -34,7 +34,7 @@ agent clients can lower without recreating membership or layout authority. ```text Odin accepted provider-state snapshot on Yggdrasil - -> one startup provider advertisement to Odin over CultMesh/RUDP + -> periodically refreshed provider advertisement and aggregate surface to Odin over CultMesh/RUDP -> Odin accepted provider-state snapshot over CultNet/RUDP -> display provider selection -> provider surface extraction diff --git a/src/Gjallar/Program.cs b/src/Gjallar/Program.cs index f849d1f..d53ccb6 100644 --- a/src/Gjallar/Program.cs +++ b/src/Gjallar/Program.cs @@ -444,6 +444,7 @@ internal sealed class GjallarRenderer : IDisposable while (!token.IsCancellationRequested) { var (catalog, frames) = ReadCultNetSnapshot(transport); + frames.RemoveAll(frame => !IsAggregateInput(frame)); var observedAt = DateTimeOffset.UtcNow; latestCatalogProviders = catalog.Providers.Count; latestComposedProviders = frames.Count; @@ -486,6 +487,7 @@ internal sealed class GjallarRenderer : IDisposable } } + states.RemoveAll(frame => !IsAggregateInput(frame)); AcceptOverview(BuildGjallarOverview(catalog, states)); latestComposedProviders = states.Count; MarkCatalogReceiveSuccess(DateTimeOffset.UtcNow); @@ -793,10 +795,16 @@ internal sealed class GjallarRenderer : IDisposable Volatile.Write(ref latestOverviewSurface, overview.Surface); } + private static bool IsAggregateInput(ProviderFrame frame) => + !string.Equals(frame.Provider.Id, "gjallar.overview", StringComparison.OrdinalIgnoreCase); + private static GjallarOverview BuildGjallarOverview(ProviderCatalog catalog, IReadOnlyList frames) { var observedAt = DateTimeOffset.UtcNow; - var children = frames.Select(frame => new + var aggregateFrames = frames + .Where(frame => !string.Equals(frame.Provider.Id, "gjallar.overview", StringComparison.OrdinalIgnoreCase)) + .ToArray(); + var children = aggregateFrames.Select(frame => new { id = $"gjallar-interface-{StableId(frame.Provider.Id)}", kind = "interface", @@ -837,7 +845,7 @@ internal sealed class GjallarRenderer : IDisposable props = new { title = "Gjallar", - summary = $"{frames.Count} provider surfaces", + summary = $"{aggregateFrames.Length} provider surfaces", marqueeText = catalog.MarqueeText ?? "", }, children, @@ -845,7 +853,7 @@ internal sealed class GjallarRenderer : IDisposable assets = Array.Empty(), }, }; - var componentChildren = frames.Select(frame => new EveSurfaceComponent( + var componentChildren = aggregateFrames.Select(frame => new EveSurfaceComponent( $"gjallar-interface-{StableId(frame.Provider.Id)}", "interface", new Dictionary(StringComparer.Ordinal) @@ -870,7 +878,7 @@ internal sealed class GjallarRenderer : IDisposable new Dictionary(StringComparer.Ordinal) { ["title"] = "Gjallar", - ["summary"] = $"{frames.Count} provider surfaces", + ["summary"] = $"{aggregateFrames.Length} provider surfaces", ["marqueeText"] = catalog.MarqueeText ?? "", }, componentChildren); @@ -1406,10 +1414,11 @@ internal sealed class GjallarRenderer : IDisposable DateTimeOffset observedAt) { var receiveStatus = EffectiveReceiveStatus(observedAt); - var state = string.Equals(status, "rendered", StringComparison.Ordinal) - ? (receiveStatus == "catalog-composed" ? "healthy" : "dependency-unavailable") - : "active"; - var detail = $"Gjallar composition {status}; pulses={frames}; catalogProviders={latestCatalogProviders}; composedProviders={latestComposedProviders}; fps={Math.Round(measuredFps, 2)}; receive={receiveStatus}; attempt={lastReceiveAttemptStatus}; failures={consecutiveCatalogReceiveFailures}; lastSuccess={lastSuccessfulCatalogReceiveObservedAt}"; + var publicationFailed = string.Equals(idunnRudpPublishStatus, "failed", StringComparison.Ordinal); + var state = receiveStatus == "catalog-composed" && !publicationFailed + ? "healthy" + : "dependency-unavailable"; + var detail = $"Gjallar composition {status}; pulses={frames}; catalogProviders={latestCatalogProviders}; composedProviders={latestComposedProviders}; fps={Math.Round(measuredFps, 2)}; receive={receiveStatus}; attempt={lastReceiveAttemptStatus}; failures={consecutiveCatalogReceiveFailures}; lastSuccess={lastSuccessfulCatalogReceiveObservedAt}; healthPublication={idunnRudpPublishStatus}"; return new IdunnDaemonHealthRecord { DaemonId = config.IdunnDaemon, diff --git a/state/gjallar-state.md b/state/gjallar-state.md index cc8ae85..075f9e4 100644 --- a/state/gjallar-state.md +++ b/state/gjallar-state.md @@ -27,14 +27,13 @@ surface sources - Target deployment: Yggdrasil `gjallar-yggdrasil.service`, beside Odin and Idunn. - Feed: Yggdrasil-local Odin accepted provider-state snapshot over CultNet/RUDP. - CultCache witness: `/var/lib/gamecult/gjallar/gjallar.service.cc`. -- Current startup respect: Gjallar publishes - `gamecult.eve.provider_advertisement.v1` once to Odin's CultMesh/RUDP +- Current publication: Gjallar periodically publishes its provider + advertisement and typed `gjallar.overview` surface to Odin's CultMesh/RUDP document ingress. `--odin-cultmesh-rudp` can override the document endpoint; otherwise it reuses `--odin-cultnet-rudp`. - Status path: `/var/lib/gamecult/gjallar/status.json`. -- Current cursor input: `/dev/input/mice`, rendered as a framebuffer crosshair. -- Current minimized-panel presentation: a top tab row. Clicking a panel title - minimizes it; clicking its tab restores it. +- Optional framebuffer lowering can read `/dev/input/mice` and present local + cursor/minimized-panel interactions; the Yggdrasil daemon is headless. - Current marquee input: Odin's provider catalog `marqueeText`, built from the Stonks securities tape interwoven with ordered VoidBot poem lines. Gjallar treats each slash-delimited stonk or poetry line as one ordered marquee queue @@ -137,8 +136,8 @@ Sources: Notcurses has a modern terminal rendering model built around planes, cells, and piles, plus rich terminal graphics and optional pixel protocols such as Sixel and Kitty. It is the closest conceptual neighbor for composited terminal -surfaces. Gjallar differs by treating the framebuffer as the primary body and -by making per-pane text resolution part of the compositor contract. +surfaces. Gjallar differs by publishing a renderer-neutral typed aggregate; +text resolution belongs to optional lowerers rather than the daemon contract. Sources: @@ -168,7 +167,7 @@ Source: `https://en.wikipedia.org/wiki/Linux_framebuffer` - `GjallarRenderer` owns catalog reads, provider fetches, frame loop, and telemetry. -- `BuildGjallarSurface` currently builds the in-memory `gjallar.overview` +- `BuildGjallarOverview` currently builds the typed `gjallar.overview` surface. - `AabbPacker` owns weighted panel region packing. - `FontAtlas.ForTextBox` picks a font per panel based on available pixel area