From bd2b491b59b549c10a8c9749fca97e3f08c34fd4 Mon Sep 17 00:00:00 2001 From: Meta Vens Date: Sun, 21 Jun 2026 12:51:48 +0100 Subject: [PATCH] Use runtime-neutral daemon client defaults --- Aetheria.State.Verify/Program.cs | 25 ++++++++++ .../Tests/DaemonRuntimeDocumentTests.cs | 49 +++++++++++++++++++ .../AetheriaRuntimeDaemonOperationClient.cs | 6 ++- .../AetheriaRuntimeDaemonSurfaceCommands.cs | 2 +- 4 files changed, 79 insertions(+), 3 deletions(-) diff --git a/Aetheria.State.Verify/Program.cs b/Aetheria.State.Verify/Program.cs index f75a9b510..39f7cb80a 100644 --- a/Aetheria.State.Verify/Program.cs +++ b/Aetheria.State.Verify/Program.cs @@ -5913,6 +5913,8 @@ static void RequireTypedDaemonCommandPayloads(string root) var requiredClientSymbols = new[] { + "public const string DefaultClientId = \"aetheria-daemon-client\"", + "ClientId = string.IsNullOrWhiteSpace(clientId) ? DefaultClientId : clientId", "private AetheriaRuntimeDaemonCommandEnvelope Send(AetheriaRuntimeDaemonCommandDocument command)", "ReadObservedDaemonCommands()", "Func submit", @@ -6040,6 +6042,29 @@ static void RequireTypedDaemonCommandPayloads(string root) string.Join(", ", clientDocumentBuilderHits)); } + var forbiddenSharedDaemonClientDefaults = new[] + { + "string clientId = \"unity-observer\"", + "? \"unity-observer\" :", + "? \"unity-uitoolkit\" : request.ClientId" + }; + var sharedDaemonDefaultSources = new Dictionary + { + ["daemon operation client"] = daemonClient, + ["daemon surface commands"] = daemonSurfaceCommands + }; + var sharedDaemonDefaultHits = sharedDaemonDefaultSources + .SelectMany(source => forbiddenSharedDaemonClientDefaults + .Where(symbol => source.Value.Contains(symbol, StringComparison.Ordinal)) + .Select(symbol => $"{source.Key}: {symbol}")) + .ToArray(); + if (sharedDaemonDefaultHits.Length > 0) + { + throw new InvalidOperationException( + "Shared daemon command clients still use Unity-specific fallback client ids: " + + string.Join(", ", sharedDaemonDefaultHits)); + } + if (tests.Contains("AetheriaRuntimeDaemonCommandLog.", StringComparison.Ordinal)) { throw new InvalidOperationException( diff --git a/Assets/Scripts/Tests/DaemonRuntimeDocumentTests.cs b/Assets/Scripts/Tests/DaemonRuntimeDocumentTests.cs index 602fd539a..03a978035 100644 --- a/Assets/Scripts/Tests/DaemonRuntimeDocumentTests.cs +++ b/Assets/Scripts/Tests/DaemonRuntimeDocumentTests.cs @@ -999,6 +999,23 @@ public class DaemonRuntimeDocumentTests Assert.IsEmpty(envelope.Path); } + [Test] + public void CommandClientUsesRuntimeNeutralDefaultClientId() + { + var statePath = Path.Combine( + Path.GetTempPath(), + "aetheria-daemon-command-client-tests", + Path.GetRandomFileName(), + "state.cc"); + var observed = ObservedState(frameId: 34, soaGeneration: 45); + var client = new AetheriaRuntimeDaemonOperationClient(statePath, "", "session-default-client"); + + var envelope = client.SensorPing(observed); + + Assert.AreEqual(AetheriaRuntimeDaemonOperationClient.DefaultClientId, envelope.ClientId); + Assert.AreEqual(AetheriaRuntimeDaemonCommandKinds.SensorPing, envelope.Kind); + } + [Test] public void DaemonEveSurfaceCommandSubmitsTypedDaemonOperation() { @@ -1036,6 +1053,38 @@ public class DaemonRuntimeDocumentTests Assert.IsEmpty(envelope.Path); } + [Test] + public void DaemonEveSurfaceCommandUsesRuntimeNeutralDefaultClientId() + { + var statePath = Path.Combine( + Path.GetTempPath(), + "aetheria-daemon-surface-command-tests", + Path.GetRandomFileName(), + "state.cc"); + var frame = AetheriaRuntimeDaemonFrameDocument.Create( + new AetheriaRuntimeRunCheckpointCommit + { + CurrentEntityKey = "entity:surface-player" + }, + "aetheria-daemon", + "session-surface-command", + 79, + 1.5, + 0.02); + AetheriaRuntimeDaemonFrameStore.PublishFrame(statePath, frame); + var request = new EveSurfaceCommandRequest( + "aetheria.daemon", + AetheriaRuntimeDaemonGameSurfaceBuilder.SurfaceId, + "aetheria.daemon.commands.SensorPing", + new Dictionary(StringComparer.Ordinal), + DateTimeOffset.UtcNow, + ""); + + Assert.IsTrue(AetheriaRuntimeDaemonSurfaceCommands.TrySubmit(statePath, request, out var envelope)); + Assert.AreEqual(AetheriaRuntimeDaemonOperationClient.DefaultClientId, envelope.ClientId); + Assert.AreEqual(AetheriaRuntimeDaemonCommandKinds.SensorPing, envelope.Kind); + } + [Test] public void DaemonEveSurfaceCommandRejectsUnsupportedArgumentlessOperation() { diff --git a/Packages/org.gamecult.aetheria.state/Runtime/AetheriaRuntimeDaemonOperationClient.cs b/Packages/org.gamecult.aetheria.state/Runtime/AetheriaRuntimeDaemonOperationClient.cs index f16667f42..d12244601 100644 --- a/Packages/org.gamecult.aetheria.state/Runtime/AetheriaRuntimeDaemonOperationClient.cs +++ b/Packages/org.gamecult.aetheria.state/Runtime/AetheriaRuntimeDaemonOperationClient.cs @@ -6,16 +6,18 @@ namespace GameCult.Aetheria.State.Verse { public sealed class AetheriaRuntimeDaemonOperationClient { + public const string DefaultClientId = "aetheria-daemon-client"; + public AetheriaRuntimeDaemonOperationClient( string stateFilePath, - string clientId = "unity-observer", + string clientId = DefaultClientId, string sessionId = "local") { if (string.IsNullOrWhiteSpace(stateFilePath)) throw new ArgumentException("State file path must be non-empty.", nameof(stateFilePath)); StateFilePath = stateFilePath; - ClientId = string.IsNullOrWhiteSpace(clientId) ? "unity-observer" : clientId; + ClientId = string.IsNullOrWhiteSpace(clientId) ? DefaultClientId : clientId; SessionId = string.IsNullOrWhiteSpace(sessionId) ? "local" : sessionId; } diff --git a/Packages/org.gamecult.aetheria.state/Runtime/AetheriaRuntimeDaemonSurfaceCommands.cs b/Packages/org.gamecult.aetheria.state/Runtime/AetheriaRuntimeDaemonSurfaceCommands.cs index 80748d7ea..f6c935ee5 100644 --- a/Packages/org.gamecult.aetheria.state/Runtime/AetheriaRuntimeDaemonSurfaceCommands.cs +++ b/Packages/org.gamecult.aetheria.state/Runtime/AetheriaRuntimeDaemonSurfaceCommands.cs @@ -23,7 +23,7 @@ namespace GameCult.Aetheria.State.Verse AetheriaRuntimeStateReader.TryReadObservedDaemonState(stateFilePath, out var observed); var client = new AetheriaRuntimeDaemonOperationClient( stateFilePath, - string.IsNullOrWhiteSpace(request.ClientId) ? "unity-uitoolkit" : request.ClientId, + string.IsNullOrWhiteSpace(request.ClientId) ? AetheriaRuntimeDaemonOperationClient.DefaultClientId : request.ClientId, observed?.Frame.SessionId ?? "local"); return AetheriaRuntimeDaemonSurfaceCommandCatalog.TrySubmitArgumentless( client,