From ee9fa6b114441d5494e859b0ac22be3d83fb92ab Mon Sep 17 00:00:00 2001 From: Meta Vens Date: Sun, 28 Jun 2026 10:31:04 +0100 Subject: [PATCH] Route observed daemon reads through reactive state --- Aetheria.State.Verify/Program.cs | 16 +++++++--- .../AetheriaRuntimeObservedDaemonState.cs | 31 +++---------------- 2 files changed, 16 insertions(+), 31 deletions(-) diff --git a/Aetheria.State.Verify/Program.cs b/Aetheria.State.Verify/Program.cs index bc629115b..8bfdc9f0c 100644 --- a/Aetheria.State.Verify/Program.cs +++ b/Aetheria.State.Verify/Program.cs @@ -7631,8 +7631,8 @@ static void RequireAetheriaManagedStateAccessorsCoverDomainDocuments(string root var observedDaemonState = File.ReadAllText(observedDaemonStatePath); var requiredObservedSymbols = new[] { - "state.LatestDaemonFrameAsync()", - "state.LatestDaemonSoaViewAsync()" + ".ReactiveObservedDaemonAsync()", + "return observed.Current;" }; var missingObservedSymbols = requiredObservedSymbols .Where(symbol => !observedDaemonState.Contains(symbol, StringComparison.Ordinal)) @@ -7644,6 +7644,14 @@ static void RequireAetheriaManagedStateAccessorsCoverDomainDocuments(string root string.Join(", ", missingObservedSymbols)); } + if (observedDaemonState.Contains("state.LatestDaemonFrameAsync()", StringComparison.Ordinal) || + observedDaemonState.Contains("state.LatestDaemonSoaViewAsync()", StringComparison.Ordinal) || + observedDaemonState.Contains("TryReadLatestSoaViewAsync", StringComparison.Ordinal)) + { + throw new InvalidOperationException( + "Observed daemon state ReadAsync still performs one-shot daemon reads instead of sampling the managed reactive observed document."); + } + var checkedSources = new Dictionary { ["DaemonRuntimeDocumentTests.cs"] = File.ReadAllText(daemonRuntimeDocumentTestsPath), @@ -14787,8 +14795,8 @@ static void RequireRuntimeStateReaderOwnsUnityStateAcquisition(string root) { "public static async Task ReadAsync(", "AetheriaClientState state", - "state.LatestDaemonFrameAsync()", - "state.LatestDaemonSoaViewAsync()", + ".ReactiveObservedDaemonAsync()", + "return observed.Current;", "AetheriaRuntimeDaemonSoaViewIndex.Build(soaView)", "public sealed class AetheriaRuntimeReactiveObservedDaemonState", "public static async Task CreateAsync(", diff --git a/Packages/org.gamecult.aetheria.state/Runtime/AetheriaRuntimeObservedDaemonState.cs b/Packages/org.gamecult.aetheria.state/Runtime/AetheriaRuntimeObservedDaemonState.cs index b4ff7b9d5..bf68c0eeb 100644 --- a/Packages/org.gamecult.aetheria.state/Runtime/AetheriaRuntimeObservedDaemonState.cs +++ b/Packages/org.gamecult.aetheria.state/Runtime/AetheriaRuntimeObservedDaemonState.cs @@ -33,33 +33,10 @@ namespace GameCult.Aetheria.State.Verse { if (state == null) throw new ArgumentNullException(nameof(state)); - var frame = await state.LatestDaemonFrameAsync().ConfigureAwait(false); - if (frame == null) - return null; - - var soaView = await TryReadLatestSoaViewAsync(state).ConfigureAwait(false); - if (soaView == null || - !string.Equals(soaView.Schema, AetheriaRuntimeDaemonSchemas.SoaView, StringComparison.Ordinal)) - { - soaView = null; - } - - return new AetheriaRuntimeObservedDaemonState( - frame, - soaView); - } - - private static async Task TryReadLatestSoaViewAsync( - AetheriaClientState state) - { - try - { - return await state.LatestDaemonSoaViewAsync().ConfigureAwait(false); - } - catch (KeyNotFoundException) - { - return null; - } + using var observed = await state + .ReactiveObservedDaemonAsync() + .ConfigureAwait(false); + return observed.Current; } }