From f5af83c54df2fdfc2aa0812fbb489a4090e8bc8b Mon Sep 17 00:00:00 2001 From: Meta Vens Date: Sun, 28 Jun 2026 04:41:12 +0100 Subject: [PATCH] Remove file-backed observed daemon reader --- Aetheria.State.Verify/Program.cs | 14 ++++++ .../Tests/DaemonRuntimeDocumentTests.cs | 47 ++++++++++--------- .../Runtime/AetheriaRuntimeStateReader.cs | 28 ----------- 3 files changed, 39 insertions(+), 50 deletions(-) diff --git a/Aetheria.State.Verify/Program.cs b/Aetheria.State.Verify/Program.cs index 56cf88e2c..44ae424a5 100644 --- a/Aetheria.State.Verify/Program.cs +++ b/Aetheria.State.Verify/Program.cs @@ -9536,6 +9536,13 @@ static void RequireAetheriaRuntimeVerseClientContract(string root) "AetheriaRuntimeVerseClient still routes Eve state-ref resolution through the file-backed compatibility reader."); } + if (stateReader.Contains("TryReadObservedDaemonState", StringComparison.Ordinal) || + stateReader.Contains("TryReadDaemonSoaView(", StringComparison.Ordinal)) + { + throw new InvalidOperationException( + "AetheriaRuntimeStateReader still exposes observed daemon frame/SoA acquisition that belongs on managed AetheriaClient documents."); + } + var starbridgeSummaryStart = client.IndexOf( "async Task ProjectStarbridgeSummaryAsync", StringComparison.Ordinal); @@ -13061,6 +13068,13 @@ static void RequireRuntimeStateReaderOwnsUnityStateAcquisition(string root) "Shared runtime state reader still exposes file-backed entity snapshot reads; use daemon zone-render EntitySnapshots documents."); } + if (runtimeStateReader.Contains("TryReadObservedDaemonState", StringComparison.Ordinal) || + runtimeStateReader.Contains("TryReadDaemonSoaView(", StringComparison.Ordinal)) + { + throw new InvalidOperationException( + "Shared runtime state reader still exposes observed daemon frame/SoA file reads; use AetheriaClient.ObserveAsync and managed typed documents."); + } + if (runtimeStateReader.Contains("ReadRunStates", StringComparison.Ordinal) || runtimeStateReader.Contains("ReadZoneStates", StringComparison.Ordinal)) { diff --git a/Assets/Scripts/Tests/DaemonRuntimeDocumentTests.cs b/Assets/Scripts/Tests/DaemonRuntimeDocumentTests.cs index c4ce86538..0ca47fc89 100644 --- a/Assets/Scripts/Tests/DaemonRuntimeDocumentTests.cs +++ b/Assets/Scripts/Tests/DaemonRuntimeDocumentTests.cs @@ -2123,7 +2123,7 @@ public class DaemonRuntimeDocumentTests } [Test] - public void StateReaderReadsObservedDaemonStateWithSoaView() + public void AetheriaClientObservesManagedDaemonStateWithSoaView() { var statePath = Path.Combine( Path.GetTempPath(), @@ -2174,11 +2174,15 @@ public class DaemonRuntimeDocumentTests }); PublishLatestFrameThroughVerseClient(statePath, frame); - AetheriaRuntimeDaemonSoaViewStore.PublishView(statePath, soaView); + PublishLatestSoaViewThroughVerseClient(statePath, soaView); - var read = AetheriaRuntimeStateReader.TryReadObservedDaemonState(statePath, out var observed); + using var client = AetheriaClient + .OpenAsync(statePath, "unity-observer-test", pullOnOpen: true) + .GetAwaiter() + .GetResult(); + var observed = client.ObserveAsync().GetAwaiter().GetResult(); - Assert.IsTrue(read); + Assert.IsNotNull(observed); Assert.IsTrue(observed.IsAuthoritative); Assert.IsTrue(observed.HasSoaView); Assert.AreEqual("daemon-run", observed.Run.RunId); @@ -2190,24 +2194,6 @@ public class DaemonRuntimeDocumentTests Assert.IsFalse(observed.SoaView.Buffers[0].ObserverWritable); } - [Test] - public void StateReaderReportsMissingObservedDaemonState() - { - var statePath = Path.Combine( - Path.GetTempPath(), - "aetheria-observed-daemon-state-tests", - Path.GetRandomFileName(), - "missing-state.cc"); - - var read = AetheriaRuntimeStateReader.TryReadObservedDaemonState(statePath, out var observed); - - Assert.IsFalse(read); - Assert.IsFalse(observed.IsAuthoritative); - Assert.IsFalse(observed.HasSoaView); - Assert.AreEqual("missing", observed.Frame.StateSource); - Assert.AreEqual(AetheriaRuntimeStateBoundary.GetDaemonFramePath(statePath), observed.FramePath); - } - [Test] public void ObservationCursorTracksFrameAndSoaGenerationChanges() { @@ -4166,6 +4152,23 @@ public class DaemonRuntimeDocumentTests .GetResult(); } + private static void PublishLatestSoaViewThroughVerseClient( + string statePath, + AetheriaRuntimeDaemonSoaViewDocument soaView) + { + using var client = AetheriaRuntimeVerseClient + .OpenAsync(statePath, "daemon-soa-view-test", startServer: false, pullOnOpen: true) + .GetAwaiter() + .GetResult(); + client.LatestSoaView() + .ReplaceAsync(soaView) + .GetAwaiter() + .GetResult(); + client.FlushAsync() + .GetAwaiter() + .GetResult(); + } + private static void PublishVerseAuthorityPolicyThroughVerseClient( string statePath, AetheriaRuntimeVerseAuthorityPolicyDocument policy) diff --git a/Packages/org.gamecult.aetheria.state/Runtime/AetheriaRuntimeStateReader.cs b/Packages/org.gamecult.aetheria.state/Runtime/AetheriaRuntimeStateReader.cs index 32fa94924..cfd7cdb68 100644 --- a/Packages/org.gamecult.aetheria.state/Runtime/AetheriaRuntimeStateReader.cs +++ b/Packages/org.gamecult.aetheria.state/Runtime/AetheriaRuntimeStateReader.cs @@ -22,34 +22,6 @@ namespace GameCult.Aetheria.State.Verse return AetheriaRuntimeDaemonFrameStore.TryReadFrame(stateFilePath, out frame); } - public static bool TryReadDaemonSoaView(string stateFilePath, out AetheriaRuntimeDaemonSoaViewDocument view) - { - return AetheriaRuntimeDaemonSoaViewStore.TryReadView(stateFilePath, out view); - } - - public static bool TryReadObservedDaemonState( - string stateFilePath, - out AetheriaRuntimeObservedDaemonState observed) - { - if (!AetheriaRuntimeDaemonFrameStore.TryReadFrame(stateFilePath, out var frame)) - { - observed = new AetheriaRuntimeObservedDaemonState( - new AetheriaRuntimeDaemonFrameDocument { IsAuthoritative = false, StateSource = "missing" }, - null, - AetheriaRuntimeDaemonFrameStore.GetFramePath(stateFilePath), - AetheriaRuntimeDaemonSoaViewStore.GetViewPath(stateFilePath)); - return false; - } - - AetheriaRuntimeDaemonSoaViewStore.TryReadView(stateFilePath, out var soaView); - observed = new AetheriaRuntimeObservedDaemonState( - frame, - string.Equals(soaView.Schema, AetheriaRuntimeDaemonSchemas.SoaView, StringComparison.Ordinal) ? soaView : null, - AetheriaRuntimeDaemonFrameStore.GetFramePath(stateFilePath), - AetheriaRuntimeDaemonSoaViewStore.GetViewPath(stateFilePath)); - return true; - } - public static EveSurfaceDocument? ReadEveSurface(string stateFilePath, string surfaceId) { if (string.Equals(surfaceId, AetheriaRuntimeDaemonGameSurfaceBuilder.SurfaceId, StringComparison.Ordinal) &&