Use runtime-neutral daemon client defaults

This commit is contained in:
Meta Vens 2026-06-21 12:51:48 +01:00
commit bd2b491b59
4 changed files with 79 additions and 3 deletions

View file

@ -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<AetheriaRuntimeDaemonOperationClient, AetheriaRuntimeObservedDaemonState, AetheriaRuntimeDaemonCommandEnvelope> 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<string, string>
{
["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(

View file

@ -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<string, string>(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()
{

View file

@ -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;
}

View file

@ -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,