From 131818e924eda5287705af29ffc5034f80a374a4 Mon Sep 17 00:00:00 2001 From: Meta Vens Date: Sun, 28 Jun 2026 04:32:33 +0100 Subject: [PATCH] Publish daemon API docs from tick result --- Aetheria.State.Daemon/Program.cs | 32 ++++----- Aetheria.State.Verify/Program.cs | 35 +++++++++- .../AetheriaRuntimeDaemonTickRunner.cs | 68 ++++++++++++++----- 3 files changed, 98 insertions(+), 37 deletions(-) diff --git a/Aetheria.State.Daemon/Program.cs b/Aetheria.State.Daemon/Program.cs index 87439ae24..3aa7604cf 100644 --- a/Aetheria.State.Daemon/Program.cs +++ b/Aetheria.State.Daemon/Program.cs @@ -757,22 +757,22 @@ static async Task PublishDaemonApiDocumentsAsync( await node.PutDaemonSoaViewAsync(soaView).ConfigureAwait(false); } - if (AetheriaRuntimeDaemonPublicationStore.TryReadProviderAdvertisement(node.StatePath, out var provider)) - await node.PutDaemonProviderAdvertisementAsync(provider).ConfigureAwait(false); - if (AetheriaRuntimeDaemonPublicationStore.TryReadHealth(node.StatePath, out var health)) - await node.PutDaemonHealthAsync(health).ConfigureAwait(false); - if (AetheriaRuntimeDaemonPublicationStore.TryReadCommandBoundary(node.StatePath, out var commandBoundary)) - await node.PutDaemonCommandBoundaryAsync(commandBoundary).ConfigureAwait(false); - if (AetheriaRuntimeDaemonPublicationStore.TryReadStarbridgeSessionSummary(node.StatePath, out var starbridgeSummary)) - await node.PutStarbridgeSessionSummaryAsync(starbridgeSummary).ConfigureAwait(false); - if (AetheriaRuntimeDaemonPublicationStore.TryReadGameSurface(node.StatePath, out var gameSurface)) - await node.PutDaemonGameSurfaceAsync(AetheriaRuntimeEveSurfaceStateProjector.ToState(gameSurface)).ConfigureAwait(false); - if (AetheriaRuntimeDaemonPublicationStore.TryReadGameTuiSurface(node.StatePath, out var gameTuiSurface)) - await node.PutDaemonGameTuiSurfaceAsync(AetheriaRuntimeEveSurfaceStateProjector.ToState(gameTuiSurface)).ConfigureAwait(false); - if (AetheriaRuntimeDaemonPublicationStore.TryReadEditorSurface(node.StatePath, out var editorSurface)) - await node.PutDaemonEditorSurfaceAsync(AetheriaRuntimeEveSurfaceStateProjector.ToState(editorSurface)).ConfigureAwait(false); - if (AetheriaRuntimeDaemonPublicationStore.TryReadEditorTuiSurface(node.StatePath, out var editorTuiSurface)) - await node.PutDaemonEditorTuiSurfaceAsync(AetheriaRuntimeEveSurfaceStateProjector.ToState(editorTuiSurface)).ConfigureAwait(false); + if (result.ProviderAdvertisement != null) + await node.PutDaemonProviderAdvertisementAsync(result.ProviderAdvertisement).ConfigureAwait(false); + if (result.Health != null) + await node.PutDaemonHealthAsync(result.Health).ConfigureAwait(false); + if (result.CommandBoundary != null) + await node.PutDaemonCommandBoundaryAsync(result.CommandBoundary).ConfigureAwait(false); + if (result.StarbridgeSessionSummary != null) + await node.PutStarbridgeSessionSummaryAsync(result.StarbridgeSessionSummary).ConfigureAwait(false); + if (result.GameSurface != null) + await node.PutDaemonGameSurfaceAsync(AetheriaRuntimeEveSurfaceStateProjector.ToState(result.GameSurface)).ConfigureAwait(false); + if (result.GameTuiSurface != null) + await node.PutDaemonGameTuiSurfaceAsync(AetheriaRuntimeEveSurfaceStateProjector.ToState(result.GameTuiSurface)).ConfigureAwait(false); + if (result.EditorSurface != null) + await node.PutDaemonEditorSurfaceAsync(AetheriaRuntimeEveSurfaceStateProjector.ToState(result.EditorSurface)).ConfigureAwait(false); + if (result.EditorTuiSurface != null) + await node.PutDaemonEditorTuiSurfaceAsync(AetheriaRuntimeEveSurfaceStateProjector.ToState(result.EditorTuiSurface)).ConfigureAwait(false); } static async Task AcceptEveCommandsAsync(AetheriaStateNode node, AetheriaDaemonHostOptions options) diff --git a/Aetheria.State.Verify/Program.cs b/Aetheria.State.Verify/Program.cs index d9aeebea3..d732c98c7 100644 --- a/Aetheria.State.Verify/Program.cs +++ b/Aetheria.State.Verify/Program.cs @@ -8882,6 +8882,11 @@ static void RequireDaemonVersePublication(string root) "AetheriaRuntimeDaemonEditorSurfaceBuilder.Build", "AetheriaRuntimeDaemonPublicationStore.PublishEditorSurface", "AetheriaRuntimeDaemonPublicationStore.PublishEditorTuiSurface", + "ProviderAdvertisement = providerAdvertisement", + "Health = health", + "CommandBoundary = commandBoundary", + "StarbridgeSessionSummary = starbridgeSessionSummary", + "GameSurface = gameSurface", "ObservedCommands", "AccountedCommandIds", "frame.AccountedCommandIds = accountedBeforeTick", @@ -8915,9 +8920,12 @@ static void RequireDaemonVersePublication(string root) "discoveryHost.Update(", "PublishDaemonApiDocumentsAsync(node, result)", "PutDaemonFrameAsync(result.Frame)", - "PutStarbridgeSessionSummaryAsync(starbridgeSummary)", - "PutDaemonGameSurfaceAsync(AetheriaRuntimeEveSurfaceStateProjector.ToState(gameSurface))", - "PutDaemonEditorTuiSurfaceAsync(AetheriaRuntimeEveSurfaceStateProjector.ToState(editorTuiSurface))", + "PutDaemonProviderAdvertisementAsync(result.ProviderAdvertisement)", + "PutDaemonHealthAsync(result.Health)", + "PutDaemonCommandBoundaryAsync(result.CommandBoundary)", + "PutStarbridgeSessionSummaryAsync(result.StarbridgeSessionSummary)", + "PutDaemonGameSurfaceAsync(AetheriaRuntimeEveSurfaceStateProjector.ToState(result.GameSurface))", + "PutDaemonEditorTuiSurfaceAsync(AetheriaRuntimeEveSurfaceStateProjector.ToState(result.EditorTuiSurface))", "GetStarbridgeSessionSummaryAsync()", "InjectEveSurfaceSnapshotAsync(", "ReadEveSurfacePublicationAsync(", @@ -8947,6 +8955,27 @@ static void RequireDaemonVersePublication(string root) string.Join(", ", missingDaemonHostSymbols)); } + var apiPublicationStart = daemonHostSource.IndexOf( + "static async Task PublishDaemonApiDocumentsAsync", + StringComparison.Ordinal); + var apiPublicationEnd = apiPublicationStart >= 0 + ? daemonHostSource.IndexOf("static async Task AcceptEveCommandsAsync", apiPublicationStart, StringComparison.Ordinal) + : -1; + var apiPublicationBlock = apiPublicationStart >= 0 && apiPublicationEnd > apiPublicationStart + ? daemonHostSource.Substring(apiPublicationStart, apiPublicationEnd - apiPublicationStart) + : ""; + if (apiPublicationBlock.Contains("AetheriaRuntimeDaemonPublicationStore.TryRead", StringComparison.Ordinal)) + { + throw new InvalidOperationException( + "Daemon API document publication must use typed tick result documents instead of reopening publication-store witness files."); + } + + if (daemonTickRunner.Contains("AetheriaRuntimeDaemonPublicationStore.TryReadHealth(stateFilePath", StringComparison.Ordinal)) + { + throw new InvalidOperationException( + "Daemon tick must pass the typed health document through surface builders instead of reopening its witness file."); + } + var snapshotHandlerStart = daemonHostSource.IndexOf( "server.OnCultNet", StringComparison.Ordinal); diff --git a/Packages/org.gamecult.aetheria.state/Runtime/AetheriaRuntimeDaemonTickRunner.cs b/Packages/org.gamecult.aetheria.state/Runtime/AetheriaRuntimeDaemonTickRunner.cs index 791c76fd6..aae1eb11e 100644 --- a/Packages/org.gamecult.aetheria.state/Runtime/AetheriaRuntimeDaemonTickRunner.cs +++ b/Packages/org.gamecult.aetheria.state/Runtime/AetheriaRuntimeDaemonTickRunner.cs @@ -46,7 +46,15 @@ namespace GameCult.Aetheria.State.Verse string gameSurfacePath, string gameTuiSurfacePath, string editorSurfacePath, - string editorTuiSurfacePath) + string editorTuiSurfacePath, + AetheriaRuntimeDaemonProviderAdvertisementDocument? providerAdvertisement = null, + AetheriaRuntimeDaemonHealthDocument? health = null, + AetheriaRuntimeDaemonCommandBoundaryDocument? commandBoundary = null, + AetheriaRuntimeStarbridgeSessionSummaryDocument? starbridgeSessionSummary = null, + AetheriaRuntimeSurfaceDocument? gameSurface = null, + AetheriaRuntimeSurfaceDocument? gameTuiSurface = null, + AetheriaRuntimeSurfaceDocument? editorSurface = null, + AetheriaRuntimeSurfaceDocument? editorTuiSurface = null) { Run = run ?? new AetheriaRuntimeRunCheckpointCommit(); OperationResult = operationResult ?? new AetheriaRuntimeDaemonOperationResult( @@ -62,6 +70,14 @@ namespace GameCult.Aetheria.State.Verse GameTuiSurfacePath = gameTuiSurfacePath ?? ""; EditorSurfacePath = editorSurfacePath ?? ""; EditorTuiSurfacePath = editorTuiSurfacePath ?? ""; + ProviderAdvertisement = providerAdvertisement; + Health = health; + CommandBoundary = commandBoundary; + StarbridgeSessionSummary = starbridgeSessionSummary; + GameSurface = gameSurface; + GameTuiSurface = gameTuiSurface; + EditorSurface = editorSurface; + EditorTuiSurface = editorTuiSurface; } public AetheriaRuntimeRunCheckpointCommit Run { get; } @@ -75,6 +91,14 @@ namespace GameCult.Aetheria.State.Verse public string GameTuiSurfacePath { get; } public string EditorSurfacePath { get; } public string EditorTuiSurfacePath { get; } + public AetheriaRuntimeDaemonProviderAdvertisementDocument? ProviderAdvertisement { get; } + public AetheriaRuntimeDaemonHealthDocument? Health { get; } + public AetheriaRuntimeDaemonCommandBoundaryDocument? CommandBoundary { get; } + public AetheriaRuntimeStarbridgeSessionSummaryDocument? StarbridgeSessionSummary { get; } + public AetheriaRuntimeSurfaceDocument? GameSurface { get; } + public AetheriaRuntimeSurfaceDocument? GameTuiSurface { get; } + public AetheriaRuntimeSurfaceDocument? EditorSurface { get; } + public AetheriaRuntimeSurfaceDocument? EditorTuiSurface { get; } public AetheriaRuntimeDaemonIntentState Intents => OperationResult.Intents; } @@ -196,24 +220,24 @@ namespace GameCult.Aetheria.State.Verse var providerAdvertisementPath = AetheriaRuntimeDaemonPublicationStore.PublishProviderAdvertisement( stateFilePath, providerAdvertisement); + var health = new AetheriaRuntimeDaemonHealthDocument + { + DaemonId = string.IsNullOrWhiteSpace(options.DaemonId) ? "aetheria-daemon" : options.DaemonId, + VerseId = string.IsNullOrWhiteSpace(options.VerseId) ? "aetheria.local" : options.VerseId, + PublishedAtUtc = DateTime.UtcNow.ToString("O"), + StatePath = stateFilePath, + FrameId = frame.FrameId, + ObservedCommandCount = observedCommands.Length, + AppliedCommandCount = operationResult.AppliedCommandIds.Count, + RejectedCommandCount = operationResult.RejectedCommandIds.Count, + Status = operationResult.RejectedCommandIds.Count == 0 ? "healthy" : "commands-rejected", + PublicationSource = "daemon-published", + Transport = "cultcache-witness", + CommandBoundaryPath = commandBoundaryPath + }; var healthPath = AetheriaRuntimeDaemonPublicationStore.PublishHealth( stateFilePath, - new AetheriaRuntimeDaemonHealthDocument - { - DaemonId = string.IsNullOrWhiteSpace(options.DaemonId) ? "aetheria-daemon" : options.DaemonId, - VerseId = string.IsNullOrWhiteSpace(options.VerseId) ? "aetheria.local" : options.VerseId, - PublishedAtUtc = DateTime.UtcNow.ToString("O"), - StatePath = stateFilePath, - FrameId = frame.FrameId, - ObservedCommandCount = observedCommands.Length, - AppliedCommandCount = operationResult.AppliedCommandIds.Count, - RejectedCommandCount = operationResult.RejectedCommandIds.Count, - Status = operationResult.RejectedCommandIds.Count == 0 ? "healthy" : "commands-rejected", - PublicationSource = "daemon-published", - Transport = "cultcache-witness", - CommandBoundaryPath = commandBoundaryPath - }); - AetheriaRuntimeDaemonPublicationStore.TryReadHealth(stateFilePath, out var health); + health); AetheriaRuntimeDaemonPublicationStore.PublishAssetManifest( stateFilePath, AetheriaRuntimeAssets.ProjectManifest( @@ -266,7 +290,15 @@ namespace GameCult.Aetheria.State.Verse gameSurfacePath, gameTuiSurfacePath, editorSurfacePath, - editorTuiSurfacePath); + editorTuiSurfacePath, + providerAdvertisement, + health, + commandBoundary, + starbridgeSummary, + gameSurface, + gameSurface, + editorSurface, + editorSurface); } private static void StampZoneSimulationTime(