Remove ad-hoc command port layer
This commit is contained in:
parent
6e2460962f
commit
c9cc3adf62
9 changed files with 89 additions and 346 deletions
|
|
@ -139,10 +139,12 @@ await using (var node = await AetheriaStateNode.OpenAsync(statePath, "aetheria-s
|
|||
await node.PutDaemonProviderAdvertisementAsync(daemonProvider);
|
||||
await node.PutDaemonHealthAsync(daemonHealth);
|
||||
await node.PutDaemonCommandBoundaryAsync(daemonCommandBoundary);
|
||||
using var daemonCommandPort = await AetheriaCommandPort.OpenAsync(
|
||||
using var daemonCommandClient = await AetheriaRuntimeVerseClient.OpenAsync(
|
||||
statePath,
|
||||
"aetheria-state-smoke-command-client");
|
||||
var daemonSubmitEnvelope = await daemonCommandPort.SubmitDaemonCommandAsync(
|
||||
"aetheria-state-smoke-command-client",
|
||||
startServer: false,
|
||||
pullOnOpen: true);
|
||||
var daemonSubmitEnvelope = await daemonCommandClient.SubmitDaemonCommandAsync(
|
||||
AetheriaRuntimeDaemonCommandDocument.Create(
|
||||
AetheriaRuntimeDaemonCommandKinds.SensorPing,
|
||||
"aetheria-state-smoke",
|
||||
|
|
@ -155,7 +157,7 @@ await using (var node = await AetheriaStateNode.OpenAsync(statePath, "aetheria-s
|
|||
"aetheria-state-smoke-command-check"))
|
||||
{
|
||||
if (commandVerifyNode.ReadObservedDaemonCommands().All(command => command.CommandId != daemonSubmitEnvelope!.CommandId))
|
||||
throw new InvalidOperationException("Runtime command port daemon submission did not appear as a typed state record.");
|
||||
throw new InvalidOperationException("Verse client daemon submission did not appear as a typed state record.");
|
||||
}
|
||||
await node.PutDaemonFrameAsync(daemonFrame);
|
||||
await node.PutDaemonGameSurfaceAsync(AetheriaRuntimeEveSurfaceStateProjector.ToState(daemonGameSurface));
|
||||
|
|
@ -532,10 +534,12 @@ await using (var node = await AetheriaStateNode.OpenAsync(statePath, "aetheria-s
|
|||
await node.GetPlayerSettingsAsync(),
|
||||
now));
|
||||
|
||||
using var eveCommandPort = await AetheriaCommandPort.OpenAsync(
|
||||
using var eveCommandClient = await AetheriaRuntimeVerseClient.OpenAsync(
|
||||
statePath,
|
||||
"aetheria-state-smoke-eve-command-client");
|
||||
var eveSubmitEnvelope = await eveCommandPort.SubmitEveCommandAsync(
|
||||
"aetheria-state-smoke-eve-command-client",
|
||||
startServer: false,
|
||||
pullOnOpen: true);
|
||||
var eveSubmitEnvelope = await eveCommandClient.SubmitEveCommandAsync(
|
||||
AetheriaRuntimeEveCommandClient.ToDocument(
|
||||
AetheriaRuntimeEveCommands.SubmitCatalogCommand(
|
||||
statePath,
|
||||
|
|
@ -546,7 +550,7 @@ await using (var node = await AetheriaStateNode.OpenAsync(statePath, "aetheria-s
|
|||
"aetheria-state-smoke-eve-command-check"))
|
||||
{
|
||||
if (commandVerifyNode.ReadObservedEveCommands().All(command => command.CommandId != eveSubmitEnvelope!.CommandId))
|
||||
throw new InvalidOperationException("Runtime command port Eve submission did not appear as a typed state record.");
|
||||
throw new InvalidOperationException("Verse client Eve submission did not appear as a typed state record.");
|
||||
}
|
||||
await node.SubmitEveCommandAsync(AetheriaRuntimeEveCommandClient.ToDocument(
|
||||
AetheriaRuntimeEveCommands.SubmitCatalogCommand(
|
||||
|
|
|
|||
|
|
@ -799,7 +799,6 @@ static void RequirePackageSerializerBoundary(string root)
|
|||
"AetheriaRuntimeCatalogStore.cs",
|
||||
"AetheriaRuntimeClientTargetStore.cs",
|
||||
"AetheriaRuntimeCultCacheDocumentStore.cs",
|
||||
"AetheriaRuntimeCommandPort.cs",
|
||||
"AetheriaRuntimeVerseClient.cs",
|
||||
"AetheriaRuntimeSnapshotDocuments.cs",
|
||||
"AetheriaRuntimeEveCommandDocument.cs",
|
||||
|
|
@ -8013,9 +8012,9 @@ static void RequireDaemonVersePublication(string root)
|
|||
"PutDaemonProviderAdvertisementAsync(daemonProvider)",
|
||||
"PutDaemonHealthAsync(daemonHealth)",
|
||||
"PutDaemonCommandBoundaryAsync(daemonCommandBoundary)",
|
||||
"AetheriaCommandPort.OpenAsync(",
|
||||
"daemonCommandPort.SubmitDaemonCommandAsync(",
|
||||
"eveCommandPort.SubmitEveCommandAsync(",
|
||||
"AetheriaRuntimeVerseClient.OpenAsync(",
|
||||
"daemonCommandClient.SubmitDaemonCommandAsync(",
|
||||
"eveCommandClient.SubmitEveCommandAsync(",
|
||||
"PutDaemonFrameAsync(daemonFrame)",
|
||||
"PutDaemonGameSurfaceAsync(AetheriaRuntimeEveSurfaceStateProjector.ToState(daemonGameSurface))",
|
||||
"GetDaemonProviderAdvertisementAsync()",
|
||||
|
|
@ -8062,8 +8061,8 @@ static void RequireDaemonVersePublication(string root)
|
|||
"Long term, Odin should discover the daemon-owned provider advertisement and interface bindings directly",
|
||||
"Queues are an implementation detail.",
|
||||
"Eve commands and daemon commands are typed `gamecult.eve.command.v1` and `gamecult.aetheria.daemon_command.v1` records in the Aetheria state graph",
|
||||
"`AetheriaCommandPort` is the neutral command submission implementation for typed command records.",
|
||||
"Client-side command lowerers may use typed runtime clients over that same port.",
|
||||
"`AetheriaRuntimeVerseClient` is the only shared submission boundary for typed command records.",
|
||||
"Do not add command ports, cached submitters, mailboxes, or queue-like buses between clients and the typed Verse graph.",
|
||||
"`CommandLog`, `Inbox`, `mailbox`, `.eve.commands`, `.daemon.commands`, `.cc.pending`, or `" + "Pending" + "CultCacheStore` in Unity-facing daemon/Eve command code",
|
||||
"Do not add a private HTTP dashboard, Unity-only inspector, JSON status blob, or agent-specific daemon wrapper as canonical truth."
|
||||
};
|
||||
|
|
@ -8083,10 +8082,9 @@ static void RequireAetheriaRuntimeVerseClientContract(string root)
|
|||
var clientPath = Path.Combine(root, "Packages", "org.gamecult.aetheria.state", "Runtime", "AetheriaRuntimeVerseClient.cs");
|
||||
var surfaceStatePath = Path.Combine(root, "Packages", "org.gamecult.aetheria.state", "Runtime", "AetheriaRuntimeEveSurfaceState.cs");
|
||||
var oldSurfaceStatePath = Path.Combine(root, "Aetheria.State", "Documents", "EveSurfaceState.cs");
|
||||
var commandPortPath = Path.Combine(root, "Packages", "org.gamecult.aetheria.state", "Runtime", "AetheriaRuntimeCommandPort.cs");
|
||||
var docPath = Path.Combine(root, "docs", "aetheria-verse-client-contract.md");
|
||||
|
||||
var requiredFiles = new[] { clientPath, surfaceStatePath, commandPortPath, docPath };
|
||||
var requiredFiles = new[] { clientPath, surfaceStatePath, docPath };
|
||||
var missingFiles = requiredFiles
|
||||
.Where(path => !File.Exists(path))
|
||||
.Select(path => Path.GetRelativePath(root, path))
|
||||
|
|
@ -8100,7 +8098,6 @@ static void RequireAetheriaRuntimeVerseClientContract(string root)
|
|||
|
||||
var client = File.ReadAllText(clientPath);
|
||||
var surfaceState = File.ReadAllText(surfaceStatePath);
|
||||
var commandPort = File.ReadAllText(commandPortPath);
|
||||
var doc = File.ReadAllText(docPath);
|
||||
|
||||
if (File.Exists(oldSurfaceStatePath))
|
||||
|
|
@ -8134,7 +8131,9 @@ static void RequireAetheriaRuntimeVerseClientContract(string root)
|
|||
"GetVerseHostSettingsAsync()",
|
||||
"GetLoadoutTemplatesAsync()",
|
||||
"SubmitDaemonCommandAsync(",
|
||||
"SubmitEveCommandAsync(",
|
||||
"AetheriaRuntimeVerseRecordKeys.DaemonCommand(command.CommandId)",
|
||||
"AetheriaRuntimeVerseRecordKeys.EveCommand(command.CommandId)",
|
||||
"DaemonGameTuiSurface { get; }",
|
||||
"DaemonEditorTuiSurface { get; }"
|
||||
};
|
||||
|
|
@ -8167,30 +8166,11 @@ static void RequireAetheriaRuntimeVerseClientContract(string root)
|
|||
string.Join(", ", missingSurfaceSymbols));
|
||||
}
|
||||
|
||||
if (!commandPort.Contains("AetheriaRuntimeVerseContractRegistry.CreateCultCacheRegistry()", StringComparison.Ordinal) ||
|
||||
!commandPort.Contains("AetheriaRuntimeVerseContractRegistry.CreateCultNetRegistry(registry)", StringComparison.Ordinal) ||
|
||||
!commandPort.Contains("AetheriaRuntimeVerseRecordKeys.DaemonCommand(commandId)", StringComparison.Ordinal) ||
|
||||
!commandPort.Contains("AetheriaRuntimeVerseRecordKeys.EveCommand(commandId)", StringComparison.Ordinal))
|
||||
var deletedCommandPortPath = Path.Combine(root, "Packages", "org.gamecult.aetheria.state", "Runtime", "AetheriaRuntimeCommandPort.cs");
|
||||
if (File.Exists(deletedCommandPortPath))
|
||||
{
|
||||
throw new InvalidOperationException(
|
||||
"Runtime command port must share AetheriaRuntimeVerseClient contract registry and record keys.");
|
||||
}
|
||||
|
||||
var forbiddenCommandPortRegistrySymbols = new[]
|
||||
{
|
||||
"private static CultDocumentRegistry CreateCultCacheRegistry",
|
||||
"private static CultNetDocumentRegistry CreateCultNetRegistry",
|
||||
"daemon:commands:{StableToken(commandId)}",
|
||||
"eve:commands:{StableToken(commandId)}"
|
||||
};
|
||||
var forbiddenCommandPortHits = forbiddenCommandPortRegistrySymbols
|
||||
.Where(symbol => commandPort.Contains(symbol, StringComparison.Ordinal))
|
||||
.ToArray();
|
||||
if (forbiddenCommandPortHits.Length > 0)
|
||||
{
|
||||
throw new InvalidOperationException(
|
||||
"Runtime command port still owns a duplicate Verse contract boundary: " +
|
||||
string.Join(", ", forbiddenCommandPortHits));
|
||||
"AetheriaRuntimeCommandPort.cs has returned. Submit typed commands through AetheriaRuntimeVerseClient.");
|
||||
}
|
||||
|
||||
var requiredDocSymbols = new[]
|
||||
|
|
@ -8227,7 +8207,7 @@ static void RequireTypedEveCommandBodies(string root)
|
|||
var mainMenuPath = Path.Combine(root, "Assets", "Scripts", "UI", "MainMenu.cs");
|
||||
var evePresenterPath = Path.Combine(root, "Packages", "org.gamecult.aetheria.eve-runtime", "Runtime", "AetheriaEveSurfacePresenter.cs");
|
||||
|
||||
var requiredFiles = new[] { eveCommandDocumentPath, eveCommandClientPath, verseClientPath, runtimeCommandPortPath, eveCommandBridgePath, stateNodePath, documentRegistryPath, actionGameManagerPath, mainMenuPath, evePresenterPath };
|
||||
var requiredFiles = new[] { eveCommandDocumentPath, eveCommandClientPath, verseClientPath, eveCommandBridgePath, stateNodePath, documentRegistryPath, actionGameManagerPath, mainMenuPath, evePresenterPath };
|
||||
var missingFiles = requiredFiles
|
||||
.Where(path => !File.Exists(path))
|
||||
.Select(path => Path.GetRelativePath(root, path))
|
||||
|
|
@ -8243,7 +8223,6 @@ static void RequireTypedEveCommandBodies(string root)
|
|||
var eveCommandClient = File.ReadAllText(eveCommandClientPath);
|
||||
var verseClient = File.ReadAllText(verseClientPath);
|
||||
var normalizedEveCommandClient = eveCommandClient.Replace("\r\n", "\n", StringComparison.Ordinal);
|
||||
var runtimeCommandPort = File.ReadAllText(runtimeCommandPortPath);
|
||||
var eveCommandBridge = File.ReadAllText(eveCommandBridgePath);
|
||||
var stateNode = File.ReadAllText(stateNodePath);
|
||||
var documentRegistry = File.ReadAllText(documentRegistryPath);
|
||||
|
|
@ -8292,20 +8271,10 @@ static void RequireTypedEveCommandBodies(string root)
|
|||
{
|
||||
"public static class AetheriaRuntimeEveCommands",
|
||||
"public static class AetheriaRuntimeEveCommandClient",
|
||||
"public sealed class AetheriaRuntimeCommandPort",
|
||||
"public sealed class AetheriaCommandPort",
|
||||
"namespace Aetheria.State",
|
||||
"namespace GameCult.Aetheria.State.Verse",
|
||||
"global::Aetheria.State.AetheriaCommandPort",
|
||||
"public const string DefaultRuntimeId = \"aetheria-command-client\"",
|
||||
"string.IsNullOrWhiteSpace(runtimeId) ? DefaultRuntimeId : runtimeId",
|
||||
"internal Task<AetheriaRuntimeDaemonCommandEnvelope> SubmitDaemonCommandAsync(",
|
||||
"internal Task<AetheriaRuntimeEveCommandEnvelope> SubmitEveCommandAsync(",
|
||||
"internal static class AetheriaRuntimeCommandSubmitter",
|
||||
"internal static bool TrySubmitEveCommand(",
|
||||
"internal static bool TrySubmitDaemonCommand(",
|
||||
"TrySubmitEveCommand(",
|
||||
"TrySubmitDaemonCommand(",
|
||||
"AetheriaRuntimeVerseClient.OpenAsync(",
|
||||
"Task<AetheriaRuntimeDaemonCommandEnvelope> SubmitDaemonCommandAsync(",
|
||||
"Task<AetheriaRuntimeEveCommandEnvelope> SubmitEveCommandAsync(",
|
||||
"CreatePlayerSettingsCommand(",
|
||||
"CreateInputSettingsCommand(",
|
||||
"CreateCatalogCommand(",
|
||||
|
|
@ -8340,7 +8309,7 @@ static void RequireTypedEveCommandBodies(string root)
|
|||
"SubmitKnownSurfaceCommandAsync("
|
||||
};
|
||||
var mainMenu = File.ReadAllText(mainMenuPath);
|
||||
var typedCommandSources = eveCommandClient + "\n" + verseClient + "\n" + runtimeCommandPort + "\n" + eveCommandBridge + "\n" + stateNode + "\n" + documentRegistry + "\n" + actionGameManager + "\n" + mainMenu + "\n" + evePresenter;
|
||||
var typedCommandSources = eveCommandClient + "\n" + verseClient + "\n" + eveCommandBridge + "\n" + stateNode + "\n" + documentRegistry + "\n" + actionGameManager + "\n" + mainMenu + "\n" + evePresenter;
|
||||
if (typedCommandSources.Contains("DeleteEveCommandAsync(", StringComparison.Ordinal))
|
||||
{
|
||||
throw new InvalidOperationException(
|
||||
|
|
@ -8416,13 +8385,19 @@ static void RequireTypedEveCommandBodies(string root)
|
|||
string.Join(", ", unityNamedRuntimeHits));
|
||||
}
|
||||
|
||||
if (File.Exists(runtimeCommandPortPath))
|
||||
{
|
||||
throw new InvalidOperationException(
|
||||
"AetheriaRuntimeCommandPort.cs has returned. Submit typed command documents through AetheriaRuntimeVerseClient.");
|
||||
}
|
||||
|
||||
var forbiddenSharedCommandRuntimeIds = new[]
|
||||
{
|
||||
"string runtimeId = \"unity-input-provider\"",
|
||||
"? \"unity-input-provider\" : runtimeId"
|
||||
};
|
||||
var sharedCommandRuntimeIdHits = forbiddenSharedCommandRuntimeIds
|
||||
.Where(symbol => runtimeCommandPort.Contains(symbol, StringComparison.Ordinal))
|
||||
.Where(symbol => typedCommandSources.Contains(symbol, StringComparison.Ordinal))
|
||||
.ToArray();
|
||||
if (sharedCommandRuntimeIdHits.Length > 0)
|
||||
{
|
||||
|
|
@ -8431,40 +8406,10 @@ static void RequireTypedEveCommandBodies(string root)
|
|||
string.Join(", ", sharedCommandRuntimeIdHits));
|
||||
}
|
||||
|
||||
if (runtimeCommandPort.Contains("public static class AetheriaRuntimeCommandSubmitter", StringComparison.Ordinal))
|
||||
if (typedCommandSources.Contains("AetheriaRuntimeCommandSubmitter", StringComparison.Ordinal))
|
||||
{
|
||||
throw new InvalidOperationException(
|
||||
"Shared command runtime still exposes the generic transport submitter publicly instead of routing callers through typed clients.");
|
||||
}
|
||||
|
||||
var forbiddenRuntimePortSubmitMethods = new[]
|
||||
{
|
||||
"public Task<AetheriaRuntimeDaemonCommandEnvelope> SubmitDaemonCommandAsync(",
|
||||
"public Task<AetheriaRuntimeEveCommandEnvelope> SubmitEveCommandAsync("
|
||||
};
|
||||
var publicRuntimePortSubmitHits = forbiddenRuntimePortSubmitMethods
|
||||
.Where(symbol => runtimeCommandPort.Contains(symbol, StringComparison.Ordinal))
|
||||
.ToArray();
|
||||
if (publicRuntimePortSubmitHits.Length > 0)
|
||||
{
|
||||
throw new InvalidOperationException(
|
||||
"Runtime command port still exposes raw document submission publicly instead of routing callers through typed clients: " +
|
||||
string.Join(", ", publicRuntimePortSubmitHits));
|
||||
}
|
||||
|
||||
var forbiddenPublicSubmitterMethods = new[]
|
||||
{
|
||||
"public static bool TrySubmitDaemonCommand(",
|
||||
"public static bool TrySubmitEveCommand("
|
||||
};
|
||||
var publicSubmitterMethodHits = forbiddenPublicSubmitterMethods
|
||||
.Where(symbol => runtimeCommandPort.Contains(symbol, StringComparison.Ordinal))
|
||||
.ToArray();
|
||||
if (publicSubmitterMethodHits.Length > 0)
|
||||
{
|
||||
throw new InvalidOperationException(
|
||||
"Runtime command submitter still marks generic submit helpers public instead of keeping them internal: " +
|
||||
string.Join(", ", publicSubmitterMethodHits));
|
||||
"Shared command runtime still preserves the cached command submitter instead of routing typed clients through AetheriaRuntimeVerseClient.");
|
||||
}
|
||||
|
||||
var forbiddenUnitySubmitterSymbols = new[]
|
||||
|
|
@ -8584,7 +8529,7 @@ static void RequireTypedEveCommandBodies(string root)
|
|||
if (rendererLogHits.Length > 0)
|
||||
{
|
||||
throw new InvalidOperationException(
|
||||
"Renderer code still speaks to the Eve mailbox log instead of the typed command port: " +
|
||||
"Renderer code still speaks to the Eve mailbox log instead of the typed Verse client path: " +
|
||||
string.Join(", ", rendererLogHits));
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -50,10 +50,10 @@ renderer-side commit authority.
|
|||
publishes `starting`, `running`, and `stopping` states through `Aetheria.State`;
|
||||
legacy outbox status remains operation telemetry, not daemon-session ownership.
|
||||
Unity Eve surfaces construct typed `gamecult.eve.command.v1` command documents.
|
||||
The neutral `AetheriaCommandPort` owns command submission for headless and
|
||||
non-Unity clients; Unity input providers reach the same records through the
|
||||
`AetheriaRuntimeCommandPort` facade. The Verse daemon uses `AetheriaStateNode`
|
||||
to observe and accept those CultNet records in the Aetheria state graph.
|
||||
`AetheriaRuntimeVerseClient` is the shared CultMesh client boundary for
|
||||
headless, Unity, and non-Unity runtimes. Typed command clients submit directly
|
||||
to the same Verse records; there is no command-port facade or cached submitter
|
||||
between client code and the Aetheria state graph.
|
||||
`AetheriaEveCommandBridge` is the provider-owned command acceptor for those
|
||||
records: it validates the provider, surface, and command template before
|
||||
running the narrow refresh handlers for the catalog and operations surfaces
|
||||
|
|
|
|||
|
|
@ -39,9 +39,9 @@ The bridge layer must point at daemon-owned witnesses instead of becoming a seco
|
|||
|
||||
## Queues
|
||||
|
||||
Queues are an implementation detail. Eve commands and daemon commands are typed `gamecult.eve.command.v1` and `gamecult.aetheria.daemon_command.v1` records in the Aetheria state graph; the old `.pending` runtime commit outbox is gone. None of those folders are the public API, daemon identity, or a substitute for CultNet/CultMesh command ports. Anything still named `Queue*`, `CommandLog`, `Inbox`, `mailbox`, `.eve.commands`, `.daemon.commands`, `.cc.pending`, or `PendingCultCacheStore` in Unity-facing daemon/Eve command code should lower to typed command documents and be demoted behind typed operation methods as the CultNet command boundaries come online.
|
||||
Queues are an implementation detail. Eve commands and daemon commands are typed `gamecult.eve.command.v1` and `gamecult.aetheria.daemon_command.v1` records in the Aetheria state graph; the old `.pending` runtime commit outbox is gone. None of those folders are the public API, daemon identity, or a substitute for CultNet/CultMesh typed records. Anything still named `Queue*`, `CommandLog`, `Inbox`, `mailbox`, `.eve.commands`, `.daemon.commands`, `.cc.pending`, or `PendingCultCacheStore` in Unity-facing daemon/Eve command code should lower to typed command documents and be demoted behind typed operation methods as the CultNet command boundaries come online.
|
||||
|
||||
`AetheriaCommandPort` is the neutral command submission implementation for typed command records. Client-side command lowerers may use typed runtime clients over that same port. They must not drain those records or mutate state in response; ownership stays with the daemon Verse member.
|
||||
`AetheriaRuntimeVerseClient` is the only shared submission boundary for typed command records. Client-side command lowerers may use typed runtime clients over that same Verse client. Do not add command ports, cached submitters, mailboxes, or queue-like buses between clients and the typed Verse graph. They must not drain those records or mutate state in response; ownership stays with the daemon Verse member.
|
||||
|
||||
Migration rule: do not expose string command names and payload maps as public Aetheria APIs. Compatibility adapters may decode external Eve requests at the edge, but persisted Aetheria command documents and Unity gameplay calls should use typed command bodies and typed operation methods.
|
||||
|
||||
|
|
|
|||
|
|
@ -87,7 +87,6 @@
|
|||
<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\AetheriaRuntimeVerseClient.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" />
|
||||
|
|
|
|||
|
|
@ -1,237 +0,0 @@
|
|||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.IO;
|
||||
using System.Linq;
|
||||
using System.Threading.Tasks;
|
||||
using GameCult.Caching;
|
||||
using GameCult.Caching.MessagePack;
|
||||
using GameCult.Mesh;
|
||||
using GameCult.Networking;
|
||||
using GameCult.Aetheria.State.Verse;
|
||||
|
||||
#nullable enable
|
||||
|
||||
namespace Aetheria.State
|
||||
{
|
||||
public sealed class AetheriaCommandPort : IDisposable
|
||||
{
|
||||
private readonly CultMeshNode _node;
|
||||
|
||||
private AetheriaCommandPort(string stateFilePath, CultMeshNode node)
|
||||
{
|
||||
StateFilePath = stateFilePath;
|
||||
_node = node;
|
||||
}
|
||||
|
||||
public string StateFilePath { get; }
|
||||
|
||||
public static async Task<AetheriaCommandPort> OpenAsync(
|
||||
string stateFilePath,
|
||||
string runtimeId = "aetheria-command-client")
|
||||
{
|
||||
if (string.IsNullOrWhiteSpace(stateFilePath))
|
||||
throw new ArgumentException("State file path must be non-empty.", nameof(stateFilePath));
|
||||
|
||||
var fullPath = Path.GetFullPath(stateFilePath);
|
||||
var registry = AetheriaRuntimeVerseContractRegistry.CreateCultCacheRegistry();
|
||||
var node = await CultMesh.CreateNodeAsync(
|
||||
fullPath,
|
||||
new CultMeshNodeOptions
|
||||
{
|
||||
StartServer = false,
|
||||
EnableDurableShardLogs = true,
|
||||
CacheOptions = new CultCacheOpenOptions
|
||||
{
|
||||
Registry = registry,
|
||||
PullOnOpen = false,
|
||||
StoreFlushOnDispose = true,
|
||||
UseDirectoryStore = true
|
||||
},
|
||||
DatabaseOptions = new CultNetDatabaseOptions
|
||||
{
|
||||
RuntimeId = string.IsNullOrWhiteSpace(runtimeId) ? "aetheria-command-client" : runtimeId,
|
||||
DocumentRegistry = AetheriaRuntimeVerseContractRegistry.CreateCultNetRegistry(registry)
|
||||
}
|
||||
})
|
||||
.ConfigureAwait(false);
|
||||
|
||||
return new AetheriaCommandPort(fullPath, node);
|
||||
}
|
||||
|
||||
public async Task<AetheriaRuntimeDaemonCommandEnvelope> SubmitDaemonCommandAsync(
|
||||
AetheriaRuntimeDaemonCommandDocument command)
|
||||
{
|
||||
if (command == null) throw new ArgumentNullException(nameof(command));
|
||||
|
||||
command.Schema = AetheriaRuntimeDaemonSchemas.Command;
|
||||
if (string.IsNullOrWhiteSpace(command.CommandId))
|
||||
command.CommandId = Guid.NewGuid().ToString("N");
|
||||
if (string.IsNullOrWhiteSpace(command.IssuedAtUtc))
|
||||
command.IssuedAtUtc = DateTime.UtcNow.ToString("O");
|
||||
|
||||
await _node.Database.PutAsync(DaemonCommandKey(command.CommandId), command).ConfigureAwait(false);
|
||||
await _node.FlushAsync().ConfigureAwait(false);
|
||||
return AetheriaRuntimeDaemonOperationClient.ToEnvelope(command);
|
||||
}
|
||||
|
||||
public async Task<AetheriaRuntimeEveCommandEnvelope> SubmitEveCommandAsync(
|
||||
AetheriaRuntimeEveCommandDocument command)
|
||||
{
|
||||
if (command == null) throw new ArgumentNullException(nameof(command));
|
||||
|
||||
AetheriaRuntimeEveCommandClient.NormalizeDocument(command);
|
||||
command.Schema = AetheriaRuntimeEveCommandDocument.SchemaId;
|
||||
if (string.IsNullOrWhiteSpace(command.CommandId))
|
||||
command.CommandId = Guid.NewGuid().ToString("N");
|
||||
if (string.IsNullOrWhiteSpace(command.IssuedAtUtc))
|
||||
command.IssuedAtUtc = DateTime.UtcNow.ToString("O");
|
||||
|
||||
await _node.Database.PutAsync(EveCommandKey(command.CommandId), command).ConfigureAwait(false);
|
||||
await _node.FlushAsync().ConfigureAwait(false);
|
||||
return AetheriaRuntimeEveCommandClient.ToEnvelope(command);
|
||||
}
|
||||
|
||||
private static CultRecordKey DaemonCommandKey(string commandId)
|
||||
{
|
||||
return AetheriaRuntimeVerseRecordKeys.DaemonCommand(commandId);
|
||||
}
|
||||
|
||||
private static CultRecordKey EveCommandKey(string commandId)
|
||||
{
|
||||
return AetheriaRuntimeVerseRecordKeys.EveCommand(commandId);
|
||||
}
|
||||
|
||||
public void Dispose()
|
||||
{
|
||||
_node.Dispose();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
namespace GameCult.Aetheria.State.Verse
|
||||
{
|
||||
public sealed class AetheriaRuntimeCommandPort : IDisposable
|
||||
{
|
||||
public const string DefaultRuntimeId = "aetheria-command-client";
|
||||
|
||||
private readonly global::Aetheria.State.AetheriaCommandPort _port;
|
||||
|
||||
private AetheriaRuntimeCommandPort(global::Aetheria.State.AetheriaCommandPort port)
|
||||
{
|
||||
_port = port ?? throw new ArgumentNullException(nameof(port));
|
||||
}
|
||||
|
||||
public string StateFilePath => _port.StateFilePath;
|
||||
|
||||
public static async Task<AetheriaRuntimeCommandPort> OpenAsync(
|
||||
string stateFilePath,
|
||||
string runtimeId = DefaultRuntimeId)
|
||||
{
|
||||
var port = await global::Aetheria.State.AetheriaCommandPort.OpenAsync(
|
||||
stateFilePath,
|
||||
string.IsNullOrWhiteSpace(runtimeId) ? DefaultRuntimeId : runtimeId)
|
||||
.ConfigureAwait(false);
|
||||
return new AetheriaRuntimeCommandPort(port);
|
||||
}
|
||||
|
||||
internal Task<AetheriaRuntimeDaemonCommandEnvelope> SubmitDaemonCommandAsync(
|
||||
AetheriaRuntimeDaemonCommandDocument command)
|
||||
{
|
||||
return _port.SubmitDaemonCommandAsync(command);
|
||||
}
|
||||
|
||||
internal Task<AetheriaRuntimeEveCommandEnvelope> SubmitEveCommandAsync(
|
||||
AetheriaRuntimeEveCommandDocument command)
|
||||
{
|
||||
return _port.SubmitEveCommandAsync(command);
|
||||
}
|
||||
|
||||
public void Dispose()
|
||||
{
|
||||
_port.Dispose();
|
||||
}
|
||||
}
|
||||
|
||||
internal static class AetheriaRuntimeCommandSubmitter
|
||||
{
|
||||
private static readonly object Sync = new object();
|
||||
private static readonly Dictionary<string, AetheriaRuntimeCommandPort> Ports =
|
||||
new Dictionary<string, AetheriaRuntimeCommandPort>(StringComparer.OrdinalIgnoreCase);
|
||||
|
||||
internal static bool TrySubmitDaemonCommand(
|
||||
string stateFilePath,
|
||||
AetheriaRuntimeDaemonCommandDocument command,
|
||||
string runtimeId,
|
||||
out AetheriaRuntimeDaemonCommandEnvelope? envelope,
|
||||
out string error)
|
||||
{
|
||||
envelope = null;
|
||||
error = "";
|
||||
|
||||
try
|
||||
{
|
||||
envelope = GetOrOpen(stateFilePath, runtimeId)
|
||||
.SubmitDaemonCommandAsync(command)
|
||||
.GetAwaiter()
|
||||
.GetResult();
|
||||
return true;
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
error = ex.ToString();
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
internal static bool TrySubmitEveCommand(
|
||||
string stateFilePath,
|
||||
AetheriaRuntimeEveCommandDocument command,
|
||||
string runtimeId,
|
||||
out AetheriaRuntimeEveCommandEnvelope? envelope,
|
||||
out string error)
|
||||
{
|
||||
envelope = null;
|
||||
error = "";
|
||||
|
||||
try
|
||||
{
|
||||
envelope = GetOrOpen(stateFilePath, runtimeId)
|
||||
.SubmitEveCommandAsync(command)
|
||||
.GetAwaiter()
|
||||
.GetResult();
|
||||
return true;
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
error = ex.ToString();
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
private static AetheriaRuntimeCommandPort GetOrOpen(string stateFilePath, string runtimeId)
|
||||
{
|
||||
var fullPath = Path.GetFullPath(stateFilePath ?? "");
|
||||
var key = $"{fullPath}|{(string.IsNullOrWhiteSpace(runtimeId) ? AetheriaRuntimeCommandPort.DefaultRuntimeId : runtimeId)}";
|
||||
lock (Sync)
|
||||
{
|
||||
if (Ports.TryGetValue(key, out var existing))
|
||||
return existing;
|
||||
}
|
||||
|
||||
var created = AetheriaRuntimeCommandPort.OpenAsync(fullPath, runtimeId)
|
||||
.GetAwaiter()
|
||||
.GetResult();
|
||||
lock (Sync)
|
||||
{
|
||||
if (Ports.TryGetValue(key, out var existing))
|
||||
{
|
||||
created.Dispose();
|
||||
return existing;
|
||||
}
|
||||
|
||||
Ports.Add(key, created);
|
||||
return created;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -41,12 +41,26 @@ namespace GameCult.Aetheria.State.Verse
|
|||
out AetheriaRuntimeDaemonCommandEnvelope? envelope,
|
||||
out string error)
|
||||
{
|
||||
return AetheriaRuntimeCommandSubmitter.TrySubmitDaemonCommand(
|
||||
StateFilePath,
|
||||
command,
|
||||
ClientId,
|
||||
out envelope,
|
||||
out error);
|
||||
envelope = null;
|
||||
error = "";
|
||||
|
||||
try
|
||||
{
|
||||
using var client = AetheriaRuntimeVerseClient
|
||||
.OpenAsync(StateFilePath, ClientId, startServer: false, pullOnOpen: true)
|
||||
.GetAwaiter()
|
||||
.GetResult();
|
||||
envelope = client
|
||||
.SubmitDaemonCommandAsync(command)
|
||||
.GetAwaiter()
|
||||
.GetResult();
|
||||
return true;
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
error = ex.ToString();
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
private AetheriaRuntimeDaemonCommandDocument Create(
|
||||
|
|
|
|||
|
|
@ -171,12 +171,30 @@ namespace GameCult.Aetheria.State.Verse
|
|||
out AetheriaRuntimeEveCommandEnvelope? envelope,
|
||||
out string error)
|
||||
{
|
||||
return AetheriaRuntimeCommandSubmitter.TrySubmitEveCommand(
|
||||
stateFilePath,
|
||||
AetheriaRuntimeEveCommandClient.ToDocument(commandEnvelope),
|
||||
string.IsNullOrWhiteSpace(clientId) ? "aetheria-eve-client" : clientId,
|
||||
out envelope,
|
||||
out error);
|
||||
envelope = null;
|
||||
error = "";
|
||||
|
||||
try
|
||||
{
|
||||
using var client = AetheriaRuntimeVerseClient
|
||||
.OpenAsync(
|
||||
stateFilePath,
|
||||
string.IsNullOrWhiteSpace(clientId) ? "aetheria-eve-client" : clientId,
|
||||
startServer: false,
|
||||
pullOnOpen: true)
|
||||
.GetAwaiter()
|
||||
.GetResult();
|
||||
envelope = client
|
||||
.SubmitEveCommandAsync(AetheriaRuntimeEveCommandClient.ToDocument(commandEnvelope))
|
||||
.GetAwaiter()
|
||||
.GetResult();
|
||||
return true;
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
error = ex.ToString();
|
||||
return false;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -505,7 +505,7 @@ legacy catalog cache, and legacy UI paths should be migration-only or deleted.
|
|||
command records after publishing typed documents. Run checkpoint documents now
|
||||
carry current-zone and entity snapshots so the old `.zone` file path has a
|
||||
live typed runtime projection path.
|
||||
- `AetheriaRuntimeEveCommands` is the renderer-facing typed command port. The
|
||||
- `AetheriaRuntimeEveCommands` is the renderer-facing typed command helper. The
|
||||
internal Eve command path persists typed `AetheriaRuntimeEveCommandDocument`
|
||||
records; `AetheriaEveCommandBridge` consumes the same shared document type,
|
||||
validates provider/surface/command authority, and deletes accounted command
|
||||
|
|
|
|||
Loading…
Reference in a new issue