Publish only submittable daemon surface commands

This commit is contained in:
Meta Vens 2026-06-21 12:46:17 +01:00
commit 56863af694
7 changed files with 158 additions and 61 deletions

View file

@ -2207,13 +2207,12 @@ static void RequireEveRuntimeBootstrap(string root)
var requiredDaemonSurfaceCommandSymbols = new[]
{
"public static class AetheriaRuntimeDaemonSurfaceCommands",
"private const string CommandPrefix = \"aetheria.daemon.commands.\"",
"EveSurfaceCommandRequest request",
"request.ProviderId, \"aetheria.daemon\"",
"AetheriaRuntimeStateReader.TryReadObservedDaemonState(stateFilePath, out var observed)",
"new AetheriaRuntimeDaemonOperationClient(",
"TrySubmitKnownCommand(client, observed, kind, out envelope)",
"AetheriaRuntimeDaemonCommandKinds.SensorPing => client.SensorPing(observed)"
"AetheriaRuntimeDaemonSurfaceCommandCatalog.TrySubmitArgumentless(",
"AetheriaRuntimeDaemonSurfaceCommandCatalog.CommandPrefix"
};
var missingDaemonSurfaceCommandSymbols = requiredDaemonSurfaceCommandSymbols
.Where(symbol => !daemonSurfaceCommands.Contains(symbol, StringComparison.Ordinal))
@ -6111,6 +6110,7 @@ static void RequireDaemonVersePublication(string root)
var daemonSoaDocumentsPath = Path.Combine(root, "Packages", "org.gamecult.aetheria.state", "Runtime", "AetheriaRuntimeDaemonSoaDocuments.cs");
var daemonGameSurfaceBuilderPath = Path.Combine(root, "Packages", "org.gamecult.aetheria.state", "Runtime", "AetheriaRuntimeDaemonGameSurfaceBuilder.cs");
var daemonEditorSurfaceBuilderPath = Path.Combine(root, "Packages", "org.gamecult.aetheria.state", "Runtime", "AetheriaRuntimeDaemonEditorSurfaceBuilder.cs");
var daemonSurfaceCommandCatalogPath = Path.Combine(root, "Packages", "org.gamecult.aetheria.state", "Runtime", "AetheriaRuntimeDaemonSurfaceCommandCatalog.cs");
var daemonHostProjectPath = Path.Combine(root, "Aetheria.State.Daemon", "Aetheria.State.Daemon.csproj");
var daemonHostProgramPath = Path.Combine(root, "Aetheria.State.Daemon", "Program.cs");
var documentRegistryPath = Path.Combine(root, "Aetheria.State", "AetheriaDocumentRegistry.cs");
@ -6131,6 +6131,7 @@ static void RequireDaemonVersePublication(string root)
daemonSoaDocumentsPath,
daemonGameSurfaceBuilderPath,
daemonEditorSurfaceBuilderPath,
daemonSurfaceCommandCatalogPath,
daemonHostProjectPath,
daemonHostProgramPath,
documentRegistryPath,
@ -6160,6 +6161,7 @@ static void RequireDaemonVersePublication(string root)
var daemonSoaDocuments = File.ReadAllText(daemonSoaDocumentsPath);
var daemonGameSurfaceBuilder = File.ReadAllText(daemonGameSurfaceBuilderPath);
var daemonEditorSurfaceBuilder = File.ReadAllText(daemonEditorSurfaceBuilderPath);
var daemonSurfaceCommandCatalog = File.ReadAllText(daemonSurfaceCommandCatalogPath);
var daemonHostProject = File.ReadAllText(daemonHostProjectPath);
var daemonHostProgram = File.ReadAllText(daemonHostProgramPath);
var documentRegistry = File.ReadAllText(documentRegistryPath);
@ -6534,6 +6536,43 @@ static void RequireDaemonVersePublication(string root)
string.Join(", ", missingGameSurfaceSymbols));
}
var requiredSurfaceCommandCatalogSymbols = new[]
{
"public static class AetheriaRuntimeDaemonSurfaceCommandCatalog",
"public const string CommandPrefix = \"aetheria.daemon.commands.\"",
"public static IReadOnlyList<AetheriaRuntimeDaemonCommandKinds> ArgumentlessCommands",
"public static bool IsArgumentlessCommand(",
"public static bool TrySubmitArgumentless(",
"AetheriaRuntimeDaemonCommandKinds.SensorPing => client.SensorPing(observed)"
};
var missingSurfaceCommandCatalogSymbols = requiredSurfaceCommandCatalogSymbols
.Where(symbol => !daemonSurfaceCommandCatalog.Contains(symbol, StringComparison.Ordinal))
.ToArray();
if (missingSurfaceCommandCatalogSymbols.Length > 0)
{
throw new InvalidOperationException(
"Daemon surface command catalog no longer owns the argumentless CultMesh command set: " +
string.Join(", ", missingSurfaceCommandCatalogSymbols));
}
var surfaceCommandTemplateSources = new Dictionary<string, string>
{
["daemon game surface"] = daemonGameSurfaceBuilder,
["daemon editor surface"] = daemonEditorSurfaceBuilder
};
var overBroadSurfaceCommandTemplates = surfaceCommandTemplateSources
.Where(source =>
!source.Value.Contains("AetheriaRuntimeDaemonSurfaceCommandCatalog.IsArgumentlessCommand(entry.Kind)", StringComparison.Ordinal) ||
!source.Value.Contains("AetheriaRuntimeDaemonSurfaceCommandCatalog.CommandName(entry.Kind)", StringComparison.Ordinal))
.Select(source => source.Key)
.ToArray();
if (overBroadSurfaceCommandTemplates.Length > 0)
{
throw new InvalidOperationException(
"Daemon Eve surfaces still advertise command-boundary entries that are not directly submittable surface commands: " +
string.Join(", ", overBroadSurfaceCommandTemplates));
}
var requiredEditorSurfaceSymbols = new[]
{
"public const string SurfaceId = \"aetheria.daemon.editor\"",

View file

@ -291,8 +291,10 @@ public class DaemonRuntimeDocumentTests
"surfaceId",
AetheriaRuntimeStatRecipeCommands.SurfaceId));
Assert.IsTrue(editorSurface.Commands.Any(command =>
command.Command == "aetheria.daemon.commands.TransferCargoItem" &&
command.Command == "aetheria.daemon.commands.SensorPing" &&
command.Transport == "cultmesh"));
Assert.IsFalse(editorSurface.Commands.Any(command =>
command.Command == "aetheria.daemon.commands.TransferCargoItem"));
Assert.IsTrue(AetheriaRuntimeDaemonPublicationStore.TryReadEditorTuiSurface(statePath, out var editorTuiSurface));
Assert.AreEqual("aetheria.daemon", editorTuiSurface.ProviderId);
Assert.AreEqual("editor.daemon", editorTuiSurface.ProviderKind);
@ -317,8 +319,10 @@ public class DaemonRuntimeDocumentTests
Assert.AreEqual(AetheriaRuntimeDaemonEditorSurfaceBuilder.SurfaceId, unityEditorSurface.Surface.Id);
Assert.AreEqual("editor.daemon", unityEditorSurface.ProviderKind);
Assert.IsTrue(unityEditorSurface.Commands.Any(command =>
command.Command == "aetheria.daemon.commands.TransferCargoItem" &&
command.Command == "aetheria.daemon.commands.SensorPing" &&
command.Transport == "cultmesh"));
Assert.IsFalse(unityEditorSurface.Commands.Any(command =>
command.Command == "aetheria.daemon.commands.TransferCargoItem"));
Assert.IsTrue(AetheriaRuntimeStateReader.TryReadDaemonEditorTuiSurface(
statePath,
out var unityEditorTuiSurface));

View file

@ -85,6 +85,7 @@
<Compile Include="Packages\org.gamecult.aetheria.state\Runtime\AetheriaRuntimeDaemonEditorSurfaceBuilder.cs" />
<Compile Include="Packages\org.gamecult.aetheria.state\Runtime\AetheriaRuntimeDaemonOperationClient.cs" />
<Compile Include="Packages\org.gamecult.aetheria.state\Runtime\AetheriaRuntimeCommandPort.cs" />
<Compile Include="Packages\org.gamecult.aetheria.state\Runtime\AetheriaRuntimeDaemonSurfaceCommandCatalog.cs" />
<Compile Include="Packages\org.gamecult.aetheria.state\Runtime\AetheriaRuntimeDaemonSurfaceCommands.cs" />
<Compile Include="Packages\org.gamecult.aetheria.state\Runtime\AetheriaRuntimeDaemonOperations.cs" />
<Compile Include="Packages\org.gamecult.aetheria.state\Runtime\AetheriaRuntimeDaemonIntentState.cs" />

View file

@ -109,9 +109,10 @@ namespace GameCult.Aetheria.State.Verse
.ToArray()))),
Array.Empty<AetheriaRuntimeSurfaceStyleToken>()),
commands: commandBoundary.Commands
.Where(entry => AetheriaRuntimeDaemonSurfaceCommandCatalog.IsArgumentlessCommand(entry.Kind))
.Select(entry => new AetheriaRuntimeSurfaceCommandTemplate(
CommandName(entry.Kind),
entry.Kind.ToString(),
AetheriaRuntimeDaemonSurfaceCommandCatalog.CommandName(entry.Kind),
AetheriaRuntimeDaemonSurfaceCommandCatalog.Label(entry.Kind),
"cultmesh"))
.ToArray());
}
@ -151,7 +152,7 @@ namespace GameCult.Aetheria.State.Verse
private static string CommandName(AetheriaRuntimeDaemonCommandKinds kind)
{
return "aetheria.daemon.commands." + kind;
return AetheriaRuntimeDaemonSurfaceCommandCatalog.CommandName(kind);
}
private static AetheriaRuntimeSurfaceComponent Metric(string id, string label, string value)

View file

@ -84,9 +84,10 @@ namespace GameCult.Aetheria.State.Verse
CommandButton("aetheria.daemon.game.commands.ping", "Sensor Ping", AetheriaRuntimeDaemonCommandKinds.SensorPing)))),
Array.Empty<AetheriaRuntimeSurfaceStyleToken>()),
commands: commandBoundary.Commands
.Where(entry => AetheriaRuntimeDaemonSurfaceCommandCatalog.IsArgumentlessCommand(entry.Kind))
.Select(entry => new AetheriaRuntimeSurfaceCommandTemplate(
CommandName(entry.Kind),
Label(entry.Kind),
AetheriaRuntimeDaemonSurfaceCommandCatalog.CommandName(entry.Kind),
AetheriaRuntimeDaemonSurfaceCommandCatalog.Label(entry.Kind),
"cultmesh"))
.ToArray());
}
@ -159,12 +160,7 @@ namespace GameCult.Aetheria.State.Verse
private static string CommandName(AetheriaRuntimeDaemonCommandKinds kind)
{
return "aetheria.daemon.commands." + kind;
}
private static string Label(AetheriaRuntimeDaemonCommandKinds kind)
{
return kind.ToString();
return AetheriaRuntimeDaemonSurfaceCommandCatalog.CommandName(kind);
}
private static AetheriaRuntimeSurfaceComponent Metric(string id, string label, string value)

View file

@ -0,0 +1,94 @@
using System;
using System.Collections.Generic;
using System.Linq;
#nullable enable
namespace GameCult.Aetheria.State.Verse
{
public static class AetheriaRuntimeDaemonSurfaceCommandCatalog
{
public const string CommandPrefix = "aetheria.daemon.commands.";
private static readonly AetheriaRuntimeDaemonCommandKinds[] ArgumentlessCommandKinds =
{
AetheriaRuntimeDaemonCommandKinds.ClearTarget,
AetheriaRuntimeDaemonCommandKinds.TargetNearest,
AetheriaRuntimeDaemonCommandKinds.TargetNext,
AetheriaRuntimeDaemonCommandKinds.TargetPrevious,
AetheriaRuntimeDaemonCommandKinds.SetMoveVector,
AetheriaRuntimeDaemonCommandKinds.SetLookDirection,
AetheriaRuntimeDaemonCommandKinds.SetTractorPower,
AetheriaRuntimeDaemonCommandKinds.FireWeaponGroup,
AetheriaRuntimeDaemonCommandKinds.SetWeaponGroupActive,
AetheriaRuntimeDaemonCommandKinds.SensorPing,
AetheriaRuntimeDaemonCommandKinds.SetHeatsinksEnabled,
AetheriaRuntimeDaemonCommandKinds.SetOverrideShutdown,
AetheriaRuntimeDaemonCommandKinds.ToggleShieldEnabled,
AetheriaRuntimeDaemonCommandKinds.DockNearest,
AetheriaRuntimeDaemonCommandKinds.Undock
};
public static IReadOnlyList<AetheriaRuntimeDaemonCommandKinds> ArgumentlessCommands => ArgumentlessCommandKinds;
public static IReadOnlyList<AetheriaRuntimeSurfaceCommandTemplate> ArgumentlessSurfaceCommands =>
ArgumentlessCommandKinds
.Select(kind => new AetheriaRuntimeSurfaceCommandTemplate(CommandName(kind), Label(kind), "cultmesh"))
.ToArray();
public static string CommandName(AetheriaRuntimeDaemonCommandKinds kind)
{
return CommandPrefix + kind;
}
public static string Label(AetheriaRuntimeDaemonCommandKinds kind)
{
return kind.ToString();
}
public static bool IsArgumentlessCommand(AetheriaRuntimeDaemonCommandKinds kind)
{
return ArgumentlessCommandKinds.Contains(kind);
}
public static bool TrySubmitArgumentless(
AetheriaRuntimeDaemonOperationClient client,
AetheriaRuntimeObservedDaemonState? observed,
AetheriaRuntimeDaemonCommandKinds kind,
out AetheriaRuntimeDaemonCommandEnvelope? envelope)
{
envelope = null;
if (client == null || !IsArgumentlessCommand(kind))
return false;
try
{
envelope = kind switch
{
AetheriaRuntimeDaemonCommandKinds.ClearTarget => client.ClearTarget(observed),
AetheriaRuntimeDaemonCommandKinds.TargetNearest => client.TargetNearest(observed),
AetheriaRuntimeDaemonCommandKinds.TargetNext => client.TargetNext(observed),
AetheriaRuntimeDaemonCommandKinds.TargetPrevious => client.TargetPrevious(observed),
AetheriaRuntimeDaemonCommandKinds.SetMoveVector => client.SetMoveVector(observed, 0.0, 1.0),
AetheriaRuntimeDaemonCommandKinds.SetLookDirection => client.SetLookDirection(observed, 0.0, 1.0, 0.0),
AetheriaRuntimeDaemonCommandKinds.SetTractorPower => client.SetTractorPower(observed, 1.0),
AetheriaRuntimeDaemonCommandKinds.FireWeaponGroup => client.FireWeaponGroup(observed, 0),
AetheriaRuntimeDaemonCommandKinds.SetWeaponGroupActive => client.SetWeaponGroupActive(observed, 0, true),
AetheriaRuntimeDaemonCommandKinds.SensorPing => client.SensorPing(observed),
AetheriaRuntimeDaemonCommandKinds.SetHeatsinksEnabled => client.SetHeatsinksEnabled(observed, true),
AetheriaRuntimeDaemonCommandKinds.SetOverrideShutdown => client.SetOverrideShutdown(observed, true),
AetheriaRuntimeDaemonCommandKinds.ToggleShieldEnabled => client.ToggleShieldEnabled(observed),
AetheriaRuntimeDaemonCommandKinds.DockNearest => client.DockNearest(observed, 0.0),
AetheriaRuntimeDaemonCommandKinds.Undock => client.Undock(observed),
_ => null
};
return envelope != null;
}
catch (InvalidOperationException)
{
envelope = null;
return false;
}
}
}
}

View file

@ -7,8 +7,6 @@ namespace GameCult.Aetheria.State.Verse
{
public static class AetheriaRuntimeDaemonSurfaceCommands
{
private const string CommandPrefix = "aetheria.daemon.commands.";
public static bool TrySubmit(
string stateFilePath,
EveSurfaceCommandRequest request,
@ -27,55 +25,19 @@ namespace GameCult.Aetheria.State.Verse
stateFilePath,
string.IsNullOrWhiteSpace(request.ClientId) ? "unity-uitoolkit" : request.ClientId,
observed?.Frame.SessionId ?? "local");
return TrySubmitKnownCommand(client, observed, kind, out envelope);
}
private static bool TrySubmitKnownCommand(
AetheriaRuntimeDaemonOperationClient client,
AetheriaRuntimeObservedDaemonState? observed,
AetheriaRuntimeDaemonCommandKinds kind,
out AetheriaRuntimeDaemonCommandEnvelope? envelope)
{
envelope = null;
if (client == null)
return false;
try
{
envelope = kind switch
{
AetheriaRuntimeDaemonCommandKinds.ClearTarget => client.ClearTarget(observed),
AetheriaRuntimeDaemonCommandKinds.TargetNearest => client.TargetNearest(observed),
AetheriaRuntimeDaemonCommandKinds.TargetNext => client.TargetNext(observed),
AetheriaRuntimeDaemonCommandKinds.TargetPrevious => client.TargetPrevious(observed),
AetheriaRuntimeDaemonCommandKinds.SetMoveVector => client.SetMoveVector(observed, 0.0, 1.0),
AetheriaRuntimeDaemonCommandKinds.SetLookDirection => client.SetLookDirection(observed, 0.0, 1.0, 0.0),
AetheriaRuntimeDaemonCommandKinds.SetTractorPower => client.SetTractorPower(observed, 1.0),
AetheriaRuntimeDaemonCommandKinds.FireWeaponGroup => client.FireWeaponGroup(observed, 0),
AetheriaRuntimeDaemonCommandKinds.SetWeaponGroupActive => client.SetWeaponGroupActive(observed, 0, true),
AetheriaRuntimeDaemonCommandKinds.SensorPing => client.SensorPing(observed),
AetheriaRuntimeDaemonCommandKinds.SetHeatsinksEnabled => client.SetHeatsinksEnabled(observed, true),
AetheriaRuntimeDaemonCommandKinds.SetOverrideShutdown => client.SetOverrideShutdown(observed, true),
AetheriaRuntimeDaemonCommandKinds.ToggleShieldEnabled => client.ToggleShieldEnabled(observed),
AetheriaRuntimeDaemonCommandKinds.DockNearest => client.DockNearest(observed, 0.0),
AetheriaRuntimeDaemonCommandKinds.Undock => client.Undock(observed),
_ => null
};
return envelope != null;
}
catch (InvalidOperationException)
{
envelope = null;
return false;
}
return AetheriaRuntimeDaemonSurfaceCommandCatalog.TrySubmitArgumentless(
client,
observed,
kind,
out envelope);
}
private static bool TryResolveKind(EveSurfaceCommandRequest request, out AetheriaRuntimeDaemonCommandKinds kind)
{
kind = AetheriaRuntimeDaemonCommandKinds.None;
var command = request.Command ?? "";
if (command.StartsWith(CommandPrefix, StringComparison.Ordinal))
command = command.Substring(CommandPrefix.Length);
if (command.StartsWith(AetheriaRuntimeDaemonSurfaceCommandCatalog.CommandPrefix, StringComparison.Ordinal))
command = command.Substring(AetheriaRuntimeDaemonSurfaceCommandCatalog.CommandPrefix.Length);
return Enum.TryParse(command, ignoreCase: false, out kind) &&
kind != AetheriaRuntimeDaemonCommandKinds.None;