Require managed client for daemon surface commands

This commit is contained in:
Meta Vens 2026-06-28 04:56:48 +01:00
commit 8e84a98d64
3 changed files with 30 additions and 32 deletions

View file

@ -3226,7 +3226,6 @@ static void RequireEveRuntimeBootstrap(string root)
"EveSurfaceCommandRequest request",
"request.ProviderId, \"aetheria.daemon\"",
"AetheriaClient",
".OpenAsync(",
"ObserveAsync()",
"new AetheriaRuntimeDaemonOperationClient(",
"AetheriaRuntimeDaemonSurfaceCommandCatalog.TrySubmitArgumentless(",
@ -3248,6 +3247,13 @@ static void RequireEveRuntimeBootstrap(string root)
"Daemon Eve surface command routing still reads observed daemon state through the runtime file reader instead of the Verse client.");
}
if (daemonSurfaceCommands.Contains(".OpenAsync(", StringComparison.Ordinal) ||
daemonSurfaceCommands.Contains("string stateFilePath", StringComparison.Ordinal))
{
throw new InvalidOperationException(
"Daemon Eve surface command routing still hides the managed client boundary behind a state-file-path shortcut.");
}
var forbiddenDaemonSurfaceCommandSymbols = new[]
{
"request.Payload.TryGetValue",

View file

@ -2311,7 +2311,12 @@ public class DaemonRuntimeDocumentTests
DateTimeOffset.UtcNow,
"unity-uitoolkit");
Assert.IsTrue(AetheriaRuntimeDaemonSurfaceCommands.TrySubmit(statePath, request, out var envelope));
using var client = AetheriaClient
.OpenAsync(statePath, "unity-uitoolkit", startServer: false, pullOnOpen: true)
.GetAwaiter()
.GetResult();
Assert.IsTrue(AetheriaRuntimeDaemonSurfaceCommands.TrySubmit(client, request, out var envelope));
Assert.AreEqual(AetheriaRuntimeDaemonCommandKinds.FireWeaponGroup, envelope.Kind);
Assert.AreEqual("unity-uitoolkit", envelope.ClientId);
@ -2348,7 +2353,16 @@ public class DaemonRuntimeDocumentTests
DateTimeOffset.UtcNow,
"");
Assert.IsTrue(AetheriaRuntimeDaemonSurfaceCommands.TrySubmit(statePath, request, out var envelope));
using var client = AetheriaClient
.OpenAsync(
statePath,
AetheriaRuntimeDaemonOperationClient.DefaultClientId,
startServer: false,
pullOnOpen: true)
.GetAwaiter()
.GetResult();
Assert.IsTrue(AetheriaRuntimeDaemonSurfaceCommands.TrySubmit(client, request, out var envelope));
Assert.AreEqual(AetheriaRuntimeDaemonOperationClient.DefaultClientId, envelope.ClientId);
Assert.AreEqual(AetheriaRuntimeDaemonCommandKinds.SensorPing, envelope.Kind);
}
@ -2371,7 +2385,7 @@ public class DaemonRuntimeDocumentTests
78,
1.5,
0.02);
AetheriaRuntimeDaemonFrameStore.PublishFrame(statePath, frame);
PublishLatestFrameThroughVerseClient(statePath, frame);
var request = new EveSurfaceCommandRequest(
"aetheria.daemon",
AetheriaRuntimeDaemonGameSurfaceBuilder.SurfaceId,
@ -2380,7 +2394,12 @@ public class DaemonRuntimeDocumentTests
DateTimeOffset.UtcNow,
"unity-uitoolkit");
Assert.IsFalse(AetheriaRuntimeDaemonSurfaceCommands.TrySubmit(statePath, request, out var envelope));
using var client = AetheriaClient
.OpenAsync(statePath, "unity-uitoolkit", startServer: false, pullOnOpen: true)
.GetAwaiter()
.GetResult();
Assert.IsFalse(AetheriaRuntimeDaemonSurfaceCommands.TrySubmit(client, request, out var envelope));
Assert.IsNull(envelope);
}

View file

@ -7,33 +7,6 @@ namespace GameCult.Aetheria.State.Verse
{
public static class AetheriaRuntimeDaemonSurfaceCommands
{
public static bool TrySubmit(
string stateFilePath,
EveSurfaceCommandRequest request,
out AetheriaRuntimeDaemonCommandEnvelope? envelope)
{
envelope = null;
if (request == null ||
!string.Equals(request.ProviderId, "aetheria.daemon", StringComparison.Ordinal) ||
!TryResolveKind(request, out _))
{
return false;
}
using var client = AetheriaClient
.OpenAsync(
stateFilePath,
string.IsNullOrWhiteSpace(request.ClientId)
? AetheriaRuntimeDaemonOperationClient.DefaultClientId
: request.ClientId,
"local",
startServer: false,
pullOnOpen: true)
.GetAwaiter()
.GetResult();
return TrySubmit(client, request, out envelope);
}
public static bool TrySubmit(
AetheriaClient client,
EveSurfaceCommandRequest request,