Move daemon observation onto managed documents
This commit is contained in:
parent
ac860dc21c
commit
6f71c4cd16
6 changed files with 89 additions and 34 deletions
|
|
@ -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<TDocument> LatestAsync<TDocument>()",
|
||||
"public Observable<TDocument> Watch<TDocument>()",
|
||||
"public CultMeshReactiveDocument<TDocument> Reactive<TDocument>(",
|
||||
"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<AetheriaRuntimeObservedDaemonState?> 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<AetheriaRuntimePlayerSettingsSnapshot?> PlayerSettingsAsync()",
|
||||
"public async Task<AetheriaRuntimeVerseHostSettingsSnapshot?> VerseHostSettingsAsync()",
|
||||
"public async Task<System.Collections.Generic.IReadOnlyList<AetheriaRuntimeLoadoutTemplateSnapshot>> LoadoutTemplatesAsync()",
|
||||
"public async Task<AetheriaRuntimeObservedDaemonState?> 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) ||
|
||||
|
|
|
|||
|
|
@ -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()
|
||||
|
|
|
|||
|
|
@ -204,7 +204,10 @@ public class DaemonRuntimeDocumentTests
|
|||
.GetResult();
|
||||
using var zoneRenderReactive = client.State
|
||||
.Reactive<AetheriaRuntimeZoneRenderDocument>();
|
||||
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);
|
||||
|
|
|
|||
|
|
@ -128,27 +128,6 @@ namespace GameCult.Aetheria.State.Verse
|
|||
pullOnOpen: pullOnOpen);
|
||||
}
|
||||
|
||||
public async Task<AetheriaRuntimeObservedDaemonState?> 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<AetheriaRuntimeLoadoutTemplateCommit> 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,
|
||||
|
|
|
|||
|
|
@ -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(
|
||||
|
|
|
|||
|
|
@ -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<AetheriaRuntimeObservedDaemonState?> 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));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in a new issue