diff --git a/Aetheria.State.Verify/Program.cs b/Aetheria.State.Verify/Program.cs index 932d0d3db..8c080806e 100644 --- a/Aetheria.State.Verify/Program.cs +++ b/Aetheria.State.Verify/Program.cs @@ -9476,12 +9476,13 @@ static void RequireCatalogSurfaceUsesManagedRuntimeCatalog(string root) static void RequireAetheriaRuntimeVerseClientContract(string root) { var clientPath = Path.Combine(root, "Packages", "org.gamecult.aetheria.state", "Runtime", "AetheriaRuntimeVerseClient.cs"); + var clientStatePath = Path.Combine(root, "Packages", "org.gamecult.aetheria.state", "Runtime", "AetheriaClientState.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 stateRefResolverPath = Path.Combine(root, "Packages", "org.gamecult.aetheria.state", "Runtime", "AetheriaRuntimeStateRefResolver.cs"); var docPath = Path.Combine(root, "docs", "aetheria-verse-client-contract.md"); - var requiredFiles = new[] { clientPath, surfaceStatePath, stateRefResolverPath, docPath }; + var requiredFiles = new[] { clientPath, clientStatePath, surfaceStatePath, stateRefResolverPath, docPath }; var missingFiles = requiredFiles .Where(path => !File.Exists(path)) .Select(path => Path.GetRelativePath(root, path)) @@ -9494,6 +9495,7 @@ static void RequireAetheriaRuntimeVerseClientContract(string root) } var client = File.ReadAllText(clientPath); + var clientState = File.ReadAllText(clientStatePath); var surfaceState = File.ReadAllText(surfaceStatePath); var stateRefResolver = File.ReadAllText(stateRefResolverPath); var doc = File.ReadAllText(docPath); @@ -9532,11 +9534,6 @@ static void RequireAetheriaRuntimeVerseClientContract(string root) "CultMeshMutableStatePointer", "private AetheriaClientState? _aetheriaState", "return _aetheriaState ??= CreateAetheriaStateFacade();", - "var state = Aetheria();", - "() => state.Catalog.Latest()", - "state.Daemon.LatestFrame.LatestAsync()", - "state.Daemon.Health.LatestAsync()", - "state.Daemon.CommandBoundary.LatestAsync()", "AetheriaRuntimeLoadoutTemplatesDocument", "ProjectStarbridgeSummaryAsync", "var catalog = await catalogDocument.LatestAsync().ConfigureAwait(false);", @@ -9544,8 +9541,6 @@ static void RequireAetheriaRuntimeVerseClientContract(string root) "ReadLoadoutTemplatesDocument()", "ReadPlayerSettingsDocument()", "ReadVerseHostSettingsDocument()", - "public Func CreateEveSurfaceStateRefResolver()", - "AetheriaRuntimeStateRefResolver.CreateEveSurfaceCultMeshStateRefResolver(", "SubmitDaemonCommandAsync(", "SubmitEveCommandAsync(", "AetheriaRuntimeVerseRecordKeys.DaemonCommand(command.CommandId)", @@ -9563,6 +9558,27 @@ static void RequireAetheriaRuntimeVerseClientContract(string root) string.Join(", ", missingClientSymbols)); } + var requiredClientStateSymbols = new[] + { + "public Func CreateEveSurfaceStateRefResolver()", + "public CultMeshStateRefResolver CreateEveSurfaceCultMeshStateRefResolver()", + "public async Task CreateEveSurfaceCultMeshStateRefResolverAsync()", + "Daemon.LatestFrame.LatestAsync()", + "Daemon.Health.LatestAsync()", + "Daemon.CommandBoundary.LatestAsync()", + "() => Catalog.Latest()", + "AetheriaRuntimeStateRefResolver.CreateEveSurfaceCultMeshStateRefResolver(" + }; + var missingClientStateSymbols = requiredClientStateSymbols + .Where(symbol => !clientState.Contains(symbol, StringComparison.Ordinal)) + .ToArray(); + if (missingClientStateSymbols.Length > 0) + { + throw new InvalidOperationException( + "AetheriaClientState must own Eve state-ref resolver creation through managed typed documents: " + + string.Join(", ", missingClientStateSymbols)); + } + var requiredStateRefResolverSymbols = new[] { "public static class AetheriaRuntimeStateRefResolver", @@ -9592,6 +9608,13 @@ static void RequireAetheriaRuntimeVerseClientContract(string root) "AetheriaRuntimeVerseClient still routes Eve state-ref resolution through the file-backed compatibility reader."); } + if (client.Contains("public Func CreateEveSurfaceStateRefResolver()", StringComparison.Ordinal) || + client.Contains("public CultMeshStateRefResolver CreateEveSurfaceCultMeshStateRefResolver()", StringComparison.Ordinal)) + { + throw new InvalidOperationException( + "AetheriaRuntimeVerseClient still exposes Eve state-ref resolver compatibility factories; use AetheriaClientState managed documents."); + } + if (client.Contains("GetObservedDaemonStateAsync()", StringComparison.Ordinal) || client.Contains("GetLatestAuthoritativeRunFrameAsync()", StringComparison.Ordinal)) { @@ -13551,7 +13574,9 @@ static void RequireRuntimeStateReaderOwnsUnityStateAcquisition(string root) "public async Task DaemonGameSurfaceAsync()", "public async Task DaemonGameTuiSurfaceAsync()", "public async Task DaemonEditorSurfaceAsync()", - "public async Task DaemonEditorTuiSurfaceAsync()" + "public async Task DaemonEditorTuiSurfaceAsync()", + "public Func CreateEveSurfaceStateRefResolver()", + "public CultMeshStateRefResolver CreateEveSurfaceCultMeshStateRefResolver()" }; var daemonClientBypassHits = forbiddenDaemonClientBypassSymbols .Where(symbol => aetheriaClient.Contains(symbol, StringComparison.Ordinal)) @@ -13661,11 +13686,11 @@ static void RequireRuntimeStateReaderOwnsUnityStateAcquisition(string root) "Aetheria Eve surface presenter no longer routes daemon surface lookup through the shared AetheriaClient facade."); } - if (!eveSurfacePresenter.Contains("client.CreateEveSurfaceStateRefResolver()", StringComparison.Ordinal) || - !eveSurfacePresenter.Contains("ResolveClient(statePath).CreateEveSurfaceStateRefResolver()", StringComparison.Ordinal)) + if (!eveSurfacePresenter.Contains("client.State.CreateEveSurfaceStateRefResolver()", StringComparison.Ordinal) || + !eveSurfacePresenter.Contains("ResolveClient(statePath).State.CreateEveSurfaceStateRefResolver()", StringComparison.Ordinal)) { throw new InvalidOperationException( - "Aetheria Eve surface presenter no longer resolves provider state refs through the shared AetheriaClient facade."); + "Aetheria Eve surface presenter no longer resolves provider state refs through managed AetheriaClientState documents."); } if (eveSurfacePresenter.Contains("AetheriaRuntimeStateReader.CreateEveSurfaceStateRefResolver", StringComparison.Ordinal)) @@ -13680,22 +13705,17 @@ static void RequireRuntimeStateReaderOwnsUnityStateAcquisition(string root) "Unity Eve surface host still resolves default state refs through the file reader instead of the managed runtime client provider."); } - var runtimeVerseClientPath = Path.Combine(root, "Packages", "org.gamecult.aetheria.state", "Runtime", "AetheriaRuntimeVerseClient.cs"); - var runtimeVerseClient = File.Exists(runtimeVerseClientPath) - ? File.ReadAllText(runtimeVerseClientPath) - : throw new InvalidOperationException("Cannot verify managed state-ref resolver ownership; AetheriaRuntimeVerseClient.cs is missing."); - - if (!runtimeVerseClient.Contains("AetheriaRuntimeStateRefResolver.CreateEveSurfaceCultMeshStateRefResolver(", StringComparison.Ordinal)) + if (!aetheriaClientState.Contains("AetheriaRuntimeStateRefResolver.CreateEveSurfaceCultMeshStateRefResolver(", StringComparison.Ordinal)) { throw new InvalidOperationException( - "Managed Verse client no longer resolves Eve state refs through the typed runtime state-ref resolver."); + "Managed client state no longer resolves Eve state refs through the typed runtime state-ref resolver."); } - if (runtimeVerseClient.Contains("AetheriaRuntimeStateReader.CreateEveSurfaceCultMeshStateRefResolver", StringComparison.Ordinal) || - runtimeVerseClient.Contains("AetheriaRuntimeStateReader.CreateEveSurfaceStateRefResolver", StringComparison.Ordinal)) + if (aetheriaClientState.Contains("AetheriaRuntimeStateReader.CreateEveSurfaceCultMeshStateRefResolver", StringComparison.Ordinal) || + aetheriaClientState.Contains("AetheriaRuntimeStateReader.CreateEveSurfaceStateRefResolver", StringComparison.Ordinal)) { throw new InvalidOperationException( - "Managed Verse client still routes Eve state-ref resolution through the file-backed compatibility reader."); + "Managed client state still routes Eve state-ref resolution through the file-backed compatibility reader."); } var forbiddenDirectStoreSymbols = new Dictionary diff --git a/Aetheria.State/docs/cultmesh-cross-runtime-primitives.md b/Aetheria.State/docs/cultmesh-cross-runtime-primitives.md index 43a9b97bd..193a060a1 100644 --- a/Aetheria.State/docs/cultmesh-cross-runtime-primitives.md +++ b/Aetheria.State/docs/cultmesh-cross-runtime-primitives.md @@ -134,8 +134,9 @@ Queries are derived-state surfaces, not bespoke HTTP endpoints or local projecti Current leak: ```csharp -var resolver = AetheriaRuntimeVerseClient.CreateEveSurfaceStateRefResolver(statePath, runtimeId); -var selected = await resolver.ResolveAsync(surface.StateRef); +using var client = await AetheriaClient.OpenAsync(statePath, runtimeId); +var resolver = client.State.CreateEveSurfaceStateRefResolver(); +var selected = resolver(surface.StateRef); ``` Desired shape: diff --git a/Aetheria.State/docs/daemon-code-map-for-rust-port.md b/Aetheria.State/docs/daemon-code-map-for-rust-port.md index 1da3244b7..91f990d28 100644 --- a/Aetheria.State/docs/daemon-code-map-for-rust-port.md +++ b/Aetheria.State/docs/daemon-code-map-for-rust-port.md @@ -387,7 +387,8 @@ let hits = verse Current Eve surface state-ref resolution: ```csharp -var resolver = AetheriaRuntimeVerseClient.CreateEveSurfaceStateRefResolver(statePath, runtimeId); +using var client = await AetheriaClient.OpenAsync(statePath, runtimeId); +var resolver = client.State.CreateEveSurfaceStateRefResolver(); var label = resolver("aetheria.daemon/frame/currentEntity/name"); ``` diff --git a/Assets/Scripts/Tests/DaemonRuntimeDocumentTests.cs b/Assets/Scripts/Tests/DaemonRuntimeDocumentTests.cs index 150a79c03..c09ecf121 100644 --- a/Assets/Scripts/Tests/DaemonRuntimeDocumentTests.cs +++ b/Assets/Scripts/Tests/DaemonRuntimeDocumentTests.cs @@ -562,7 +562,7 @@ public class DaemonRuntimeDocumentTests var unityGameTuiSurfaceState = client.State.Daemon.GameTuiSurface.LatestAsync().GetAwaiter().GetResult(); var unityEditorSurfaceState = client.State.Daemon.EditorSurface.LatestAsync().GetAwaiter().GetResult(); var unityEditorTuiSurfaceState = client.State.Daemon.EditorTuiSurface.LatestAsync().GetAwaiter().GetResult(); - var surfaceResolver = client.CreateEveSurfaceStateRefResolver(); + var surfaceResolver = client.State.CreateEveSurfaceStateRefResolver(); var unityGameSurface = AetheriaRuntimeEveSurfaceAdapter.ToEveSurfaceDocument( unityGameSurfaceState, surfaceResolver); diff --git a/Packages/org.gamecult.aetheria.eve-runtime/Runtime/AetheriaEveSurfacePresenter.cs b/Packages/org.gamecult.aetheria.eve-runtime/Runtime/AetheriaEveSurfacePresenter.cs index ac5d85e7f..4a38ddeb3 100644 --- a/Packages/org.gamecult.aetheria.eve-runtime/Runtime/AetheriaEveSurfacePresenter.cs +++ b/Packages/org.gamecult.aetheria.eve-runtime/Runtime/AetheriaEveSurfacePresenter.cs @@ -126,7 +126,7 @@ namespace GameCult.Aetheria.EveRuntime ? null : AetheriaRuntimeEveSurfaceAdapter.ToEveSurfaceDocument( surface, - client.CreateEveSurfaceStateRefResolver()); + client.State.CreateEveSurfaceStateRefResolver()); } private global::Aetheria.State.Documents.EveSurfaceState? ReadDaemonSurfaceState(AetheriaClient client) @@ -194,7 +194,7 @@ namespace GameCult.Aetheria.EveRuntime surface, request => EmitCommand(statePath, request), RootOnlyChrome, - ResolveClient(statePath).CreateEveSurfaceStateRefResolver()); + ResolveClient(statePath).State.CreateEveSurfaceStateRefResolver()); _mountedStatePath = statePath; _mountedSurfaceId = surface.Surface.Id; _mountedSurfaceVersion = surface.Version; diff --git a/Packages/org.gamecult.aetheria.eve-runtime/Runtime/AetheriaEveUnitySurfaceHost.cs b/Packages/org.gamecult.aetheria.eve-runtime/Runtime/AetheriaEveUnitySurfaceHost.cs index fa4f78793..b6af78dbe 100644 --- a/Packages/org.gamecult.aetheria.eve-runtime/Runtime/AetheriaEveUnitySurfaceHost.cs +++ b/Packages/org.gamecult.aetheria.eve-runtime/Runtime/AetheriaEveUnitySurfaceHost.cs @@ -227,6 +227,7 @@ namespace GameCult.Aetheria.EveRuntime return AetheriaUnityRuntimeClientProvider .ResolveClient(stateBoot, "unity-eve-surface-host") + .State .CreateEveSurfaceStateRefResolver(); } diff --git a/Packages/org.gamecult.aetheria.state/Runtime/AetheriaClient.cs b/Packages/org.gamecult.aetheria.state/Runtime/AetheriaClient.cs index cd4993d6a..8c8e61644 100644 --- a/Packages/org.gamecult.aetheria.state/Runtime/AetheriaClient.cs +++ b/Packages/org.gamecult.aetheria.state/Runtime/AetheriaClient.cs @@ -127,18 +127,6 @@ namespace GameCult.Aetheria.State.Verse pullOnOpen: pullOnOpen); } - public Func CreateEveSurfaceStateRefResolver() - { - ThrowIfDisposed(); - return _verse.CreateEveSurfaceStateRefResolver(); - } - - public CultMeshStateRefResolver CreateEveSurfaceCultMeshStateRefResolver() - { - ThrowIfDisposed(); - return _verse.CreateEveSurfaceCultMeshStateRefResolver(); - } - internal Task SubmitInputSettingsCommandAsync( AetheriaRuntimeEveCommandKind command, AetheriaRuntimeInputSettingsCommandBody body, diff --git a/Packages/org.gamecult.aetheria.state/Runtime/AetheriaClientState.cs b/Packages/org.gamecult.aetheria.state/Runtime/AetheriaClientState.cs index 3d5fe3b81..547bb8d20 100644 --- a/Packages/org.gamecult.aetheria.state/Runtime/AetheriaClientState.cs +++ b/Packages/org.gamecult.aetheria.state/Runtime/AetheriaClientState.cs @@ -209,6 +209,31 @@ namespace GameCult.Aetheria.State.Verse { return Document().Reactive(options); } + + public Func CreateEveSurfaceStateRefResolver() + { + return CreateEveSurfaceCultMeshStateRefResolver().AsFunc(); + } + + public CultMeshStateRefResolver CreateEveSurfaceCultMeshStateRefResolver() + { + return CreateEveSurfaceCultMeshStateRefResolverAsync().ConfigureAwait(false).GetAwaiter().GetResult(); + } + + public async Task CreateEveSurfaceCultMeshStateRefResolverAsync() + { + var frameTask = Daemon.LatestFrame.LatestAsync(); + var healthTask = Daemon.Health.LatestAsync(); + var commandBoundaryTask = Daemon.CommandBoundary.LatestAsync(); + + await Task.WhenAll(frameTask, healthTask, commandBoundaryTask).ConfigureAwait(false); + + return AetheriaRuntimeStateRefResolver.CreateEveSurfaceCultMeshStateRefResolver( + frameTask.Result, + healthTask.Result, + commandBoundaryTask.Result, + () => Catalog.Latest()); + } } public sealed class AetheriaClientDaemonState diff --git a/Packages/org.gamecult.aetheria.state/Runtime/AetheriaRuntimeVerseClient.cs b/Packages/org.gamecult.aetheria.state/Runtime/AetheriaRuntimeVerseClient.cs index 0b1c152c2..66868c3cd 100644 --- a/Packages/org.gamecult.aetheria.state/Runtime/AetheriaRuntimeVerseClient.cs +++ b/Packages/org.gamecult.aetheria.state/Runtime/AetheriaRuntimeVerseClient.cs @@ -200,34 +200,6 @@ namespace GameCult.Aetheria.State.Verse return _aetheriaState ??= CreateAetheriaStateFacade(); } - public Func CreateEveSurfaceStateRefResolver() - { - return CreateEveSurfaceCultMeshStateRefResolver().AsFunc(); - } - - public CultMeshStateRefResolver CreateEveSurfaceCultMeshStateRefResolver() - { - return CreateEveSurfaceCultMeshStateRefResolverAsync().ConfigureAwait(false).GetAwaiter().GetResult(); - } - - public async Task CreateEveSurfaceCultMeshStateRefResolverAsync() - { - ThrowIfDisposed(); - - var state = Aetheria(); - var frameTask = state.Daemon.LatestFrame.LatestAsync(); - var healthTask = state.Daemon.Health.LatestAsync(); - var commandBoundaryTask = state.Daemon.CommandBoundary.LatestAsync(); - - await Task.WhenAll(frameTask, healthTask, commandBoundaryTask).ConfigureAwait(false); - - return AetheriaRuntimeStateRefResolver.CreateEveSurfaceCultMeshStateRefResolver( - frameTask.Result, - healthTask.Result, - commandBoundaryTask.Result, - () => state.Catalog.Latest()); - } - public CultMeshMutableStatePointer ProviderAdvertisement() { ThrowIfDisposed();