diff --git a/Aetheria.State.Verify/Program.cs b/Aetheria.State.Verify/Program.cs index 23717dc29..96deb7745 100644 --- a/Aetheria.State.Verify/Program.cs +++ b/Aetheria.State.Verify/Program.cs @@ -3235,7 +3235,8 @@ static void RequireEveRuntimeBootstrap(string root) "EveSurfaceCommandRequest request", "request.ProviderId, \"aetheria.daemon\"", "AetheriaClient", - "ObserveAsync()", + "AetheriaRuntimeObservedDaemonState", + ".ReadAsync(client.State, client.StatePath)", "new AetheriaRuntimeDaemonOperationClient(", "AetheriaRuntimeDaemonSurfaceCommandCatalog.TrySubmitArgumentless(", "AetheriaRuntimeDaemonSurfaceCommandCatalog.CommandPrefix" @@ -3256,6 +3257,12 @@ 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("ObserveAsync()", StringComparison.Ordinal)) + { + throw new InvalidOperationException( + "Daemon Eve surface command routing still reads observed daemon state through the AetheriaClient compatibility helper."); + } + if (daemonSurfaceCommands.Contains(".OpenAsync(", StringComparison.Ordinal) || daemonSurfaceCommands.Contains("string stateFilePath", StringComparison.Ordinal)) { @@ -13288,6 +13295,10 @@ static void RequireRuntimeStateReaderOwnsUnityStateAcquisition(string root) var aetheriaClientState = File.Exists(aetheriaClientStatePath) ? File.ReadAllText(aetheriaClientStatePath) : throw new InvalidOperationException("Cannot verify daemon state acquisition; AetheriaClientState.cs is missing."); + var observedDaemonStatePath = Path.Combine(root, "Packages", "org.gamecult.aetheria.state", "Runtime", "AetheriaRuntimeObservedDaemonState.cs"); + var observedDaemonState = File.Exists(observedDaemonStatePath) + ? File.ReadAllText(observedDaemonStatePath) + : throw new InvalidOperationException("Cannot verify daemon state acquisition; AetheriaRuntimeObservedDaemonState.cs is missing."); var requiredActionGameManagerSymbols = new[] { @@ -13465,8 +13476,7 @@ static void RequireRuntimeStateReaderOwnsUnityStateAcquisition(string root) "public Task LatestAsync()", "public Observable Watch()", "public CultMeshReactiveDocument Reactive(", - "State.Daemon.LatestFrame.LatestAsync()", - "State.Daemon.LatestSoaView.LatestAsync()" + "State.Daemon.LatestFrame.LatestAsync()" }; var missingManagedClientAccessSymbols = requiredManagedClientAccessSymbols .Where(symbol => !aetheriaClient.Contains(symbol, StringComparison.Ordinal)) @@ -13478,6 +13488,26 @@ static void RequireRuntimeStateReaderOwnsUnityStateAcquisition(string root) string.Join(", ", missingManagedClientAccessSymbols)); } + var requiredObservedDaemonStateSymbols = new[] + { + "public static async Task ReadAsync(", + "AetheriaClientState state", + "state.Daemon.LatestFrame.LatestAsync()", + "state.Daemon.LatestSoaView.LatestAsync()", + "AetheriaRuntimeDaemonSoaViewIndex.Build(soaView)", + "AetheriaRuntimeDaemonFrameStore.GetFramePath(statePath)", + "AetheriaRuntimeDaemonSoaViewStore.GetViewPath(statePath)" + }; + var missingObservedDaemonStateSymbols = requiredObservedDaemonStateSymbols + .Where(symbol => !observedDaemonState.Contains(symbol, StringComparison.Ordinal)) + .ToArray(); + if (missingObservedDaemonStateSymbols.Length > 0) + { + throw new InvalidOperationException( + "Observed daemon state must be composed from managed typed daemon documents: " + + string.Join(", ", missingObservedDaemonStateSymbols)); + } + var forbiddenDaemonClientBypassSymbols = new[] { "return _verse.GetObservedDaemonStateAsync();", @@ -13494,6 +13524,7 @@ static void RequireRuntimeStateReaderOwnsUnityStateAcquisition(string root) "public async Task PlayerSettingsAsync()", "public async Task VerseHostSettingsAsync()", "public async Task> LoadoutTemplatesAsync()", + "public async Task ObserveAsync()", "scenario ??= await _verse.GetStarbridgeScenarioAsync()", "session ??= await _verse.GetStarbridgeSessionAsync()", "var frame = await _verse.GetLatestFrameAsync()", @@ -13565,10 +13596,11 @@ static void RequireRuntimeStateReaderOwnsUnityStateAcquisition(string root) if (!daemonObserver.Contains("AetheriaClient", StringComparison.Ordinal) || !daemonObserver.Contains("AetheriaUnityRuntimeClientProvider.ResolveClient(", StringComparison.Ordinal) || !daemonObserver.Contains("AetheriaRuntimeStateBoot.Inspect(AetheriaUnityRuntimePaths.GameDataDirectory)", StringComparison.Ordinal) || - !daemonObserver.Contains("ObserveAsync()", StringComparison.Ordinal)) + !daemonObserver.Contains("AetheriaRuntimeObservedDaemonState", StringComparison.Ordinal) || + !daemonObserver.Contains(".ReadAsync(client.State, client.StatePath)", StringComparison.Ordinal)) { throw new InvalidOperationException( - "AetheriaDaemonObserver no longer routes observed daemon state through the shared Aetheria client facade."); + "AetheriaDaemonObserver no longer composes observed daemon state from managed Aetheria client documents."); } if (daemonObserver.Contains("AetheriaRuntimeStateReader.TryReadObservedDaemonState", StringComparison.Ordinal)) @@ -13577,6 +13609,12 @@ static void RequireRuntimeStateReaderOwnsUnityStateAcquisition(string root) "AetheriaDaemonObserver still spelunks observed daemon state through the runtime file reader instead of the Verse client."); } + if (daemonObserver.Contains("ObserveAsync()", StringComparison.Ordinal)) + { + throw new InvalidOperationException( + "AetheriaDaemonObserver still reads observed daemon state through the AetheriaClient compatibility helper."); + } + if (!mainMenu.Contains("AetheriaClient", StringComparison.Ordinal) || !mainMenu.Contains("LatestSectorMap(AetheriaRuntimeStateBootReport stateBoot)", StringComparison.Ordinal) || !mainMenu.Contains("LatestRuntimeCatalog(AetheriaRuntimeStateBootReport stateBoot)", StringComparison.Ordinal) || diff --git a/Assets/Scripts/Gameplay/AetheriaDaemonObserver.cs b/Assets/Scripts/Gameplay/AetheriaDaemonObserver.cs index 8fe80b908..b84759c0a 100644 --- a/Assets/Scripts/Gameplay/AetheriaDaemonObserver.cs +++ b/Assets/Scripts/Gameplay/AetheriaDaemonObserver.cs @@ -95,7 +95,11 @@ public sealed class AetheriaDaemonObserver : MonoBehaviour private AetheriaRuntimeObservedDaemonState ReadObservedDaemonState() { - return ResolveClient().ObserveAsync().GetAwaiter().GetResult(); + var client = ResolveClient(); + return AetheriaRuntimeObservedDaemonState + .ReadAsync(client.State, client.StatePath) + .GetAwaiter() + .GetResult(); } private AetheriaClient ResolveClient() diff --git a/Assets/Scripts/Tests/DaemonRuntimeDocumentTests.cs b/Assets/Scripts/Tests/DaemonRuntimeDocumentTests.cs index 7fea9b431..150a79c03 100644 --- a/Assets/Scripts/Tests/DaemonRuntimeDocumentTests.cs +++ b/Assets/Scripts/Tests/DaemonRuntimeDocumentTests.cs @@ -204,7 +204,10 @@ public class DaemonRuntimeDocumentTests .GetResult(); using var zoneRenderReactive = client.State .Reactive(); - var legacyObserved = client.ObserveAsync().GetAwaiter().GetResult(); + var observed = AetheriaRuntimeObservedDaemonState + .ReadAsync(client.State, client.StatePath) + .GetAwaiter() + .GetResult(); var observedAuthoritativeFrame = client.State.Daemon.LatestFrame.LatestAsync().GetAwaiter().GetResult(); var gameSurface = client.State.Daemon.GameSurface.LatestAsync().GetAwaiter().GetResult(); var gameTuiSurface = client.State.Daemon.GameTuiSurface.LatestAsync().GetAwaiter().GetResult(); @@ -262,7 +265,7 @@ public class DaemonRuntimeDocumentTests Assert.AreEqual(AetheriaRuntimeDaemonSchemas.Frame, latestFrame.Schema); Assert.AreEqual(frame.FrameId, latestFrame.FrameId); Assert.AreEqual(frame.FrameId, latestFrameByType.FrameId); - Assert.AreEqual(frame.FrameId, legacyObserved.Frame.FrameId); + Assert.AreEqual(frame.FrameId, observed.Frame.FrameId); Assert.AreEqual(frame.FrameId, observedAuthoritativeFrame.FrameId); Assert.IsTrue(observedAuthoritativeFrame.IsAuthoritative); Assert.AreEqual(AetheriaRuntimeDaemonGameSurfaceBuilder.SurfaceId, gameSurface.Surface.Id); @@ -2097,7 +2100,7 @@ public class DaemonRuntimeDocumentTests } [Test] - public void AetheriaClientObservesManagedDaemonStateWithSoaView() + public void ObservedDaemonStateReadsManagedFrameAndSoaDocuments() { var statePath = Path.Combine( Path.GetTempPath(), @@ -2154,7 +2157,10 @@ public class DaemonRuntimeDocumentTests .OpenAsync(statePath, "unity-observer-test", pullOnOpen: true) .GetAwaiter() .GetResult(); - var observed = client.ObserveAsync().GetAwaiter().GetResult(); + var observed = AetheriaRuntimeObservedDaemonState + .ReadAsync(client.State, client.StatePath) + .GetAwaiter() + .GetResult(); Assert.IsNotNull(observed); Assert.IsTrue(observed.IsAuthoritative); diff --git a/Packages/org.gamecult.aetheria.state/Runtime/AetheriaClient.cs b/Packages/org.gamecult.aetheria.state/Runtime/AetheriaClient.cs index e95df742d..6c4c34542 100644 --- a/Packages/org.gamecult.aetheria.state/Runtime/AetheriaClient.cs +++ b/Packages/org.gamecult.aetheria.state/Runtime/AetheriaClient.cs @@ -128,27 +128,6 @@ namespace GameCult.Aetheria.State.Verse pullOnOpen: pullOnOpen); } - public async Task ObserveAsync() - { - ThrowIfDisposed(); - var frame = await State.Daemon.LatestFrame.LatestAsync().ConfigureAwait(false); - if (frame == null) - return null; - - var soaView = await State.Daemon.LatestSoaView.LatestAsync().ConfigureAwait(false); - if (soaView == null || - !string.Equals(soaView.Schema, AetheriaRuntimeDaemonSchemas.SoaView, StringComparison.Ordinal)) - { - soaView = null; - } - - return new AetheriaRuntimeObservedDaemonState( - frame, - soaView, - AetheriaRuntimeDaemonFrameStore.GetFramePath(StatePath), - AetheriaRuntimeDaemonSoaViewStore.GetViewPath(StatePath)); - } - public async Task LoadoutTemplateAsync(string entityKey) { ThrowIfDisposed(); @@ -256,7 +235,10 @@ namespace GameCult.Aetheria.State.Verse ThrowIfDisposed(); if (submit == null) throw new ArgumentNullException(nameof(submit)); - var observed = ObserveAsync().GetAwaiter().GetResult(); + var observed = AetheriaRuntimeObservedDaemonState + .ReadAsync(State, StatePath) + .GetAwaiter() + .GetResult(); var operationClient = new AetheriaRuntimeDaemonOperationClient( StatePath, _clientId, diff --git a/Packages/org.gamecult.aetheria.state/Runtime/AetheriaRuntimeDaemonSurfaceCommands.cs b/Packages/org.gamecult.aetheria.state/Runtime/AetheriaRuntimeDaemonSurfaceCommands.cs index 0e75e89d9..d1bbf8c40 100644 --- a/Packages/org.gamecult.aetheria.state/Runtime/AetheriaRuntimeDaemonSurfaceCommands.cs +++ b/Packages/org.gamecult.aetheria.state/Runtime/AetheriaRuntimeDaemonSurfaceCommands.cs @@ -21,8 +21,8 @@ namespace GameCult.Aetheria.State.Verse return false; } - var observed = client - .ObserveAsync() + var observed = AetheriaRuntimeObservedDaemonState + .ReadAsync(client.State, client.StatePath) .GetAwaiter() .GetResult(); var operationClient = new AetheriaRuntimeDaemonOperationClient( diff --git a/Packages/org.gamecult.aetheria.state/Runtime/AetheriaRuntimeObservedDaemonState.cs b/Packages/org.gamecult.aetheria.state/Runtime/AetheriaRuntimeObservedDaemonState.cs index fe32a5ee1..1dbdde0aa 100644 --- a/Packages/org.gamecult.aetheria.state/Runtime/AetheriaRuntimeObservedDaemonState.cs +++ b/Packages/org.gamecult.aetheria.state/Runtime/AetheriaRuntimeObservedDaemonState.cs @@ -1,4 +1,5 @@ using System; +using System.Threading.Tasks; #nullable enable @@ -27,5 +28,29 @@ namespace GameCult.Aetheria.State.Verse public bool HasSoaView => SoaView != null && SoaIndex.IsValid; public bool IsAuthoritative => Frame.IsAuthoritative; public AetheriaRuntimeRunCheckpointCommit Run => Frame.Run; + + public static async Task ReadAsync( + AetheriaClientState state, + string statePath) + { + if (state == null) throw new ArgumentNullException(nameof(state)); + + var frame = await state.Daemon.LatestFrame.LatestAsync().ConfigureAwait(false); + if (frame == null) + return null; + + var soaView = await state.Daemon.LatestSoaView.LatestAsync().ConfigureAwait(false); + if (soaView == null || + !string.Equals(soaView.Schema, AetheriaRuntimeDaemonSchemas.SoaView, StringComparison.Ordinal)) + { + soaView = null; + } + + return new AetheriaRuntimeObservedDaemonState( + frame, + soaView, + AetheriaRuntimeDaemonFrameStore.GetFramePath(statePath), + AetheriaRuntimeDaemonSoaViewStore.GetViewPath(statePath)); + } } }