From 0cff460e91516ff11bae045474a29af615176e96 Mon Sep 17 00:00:00 2001 From: Meta Vens Date: Mon, 29 Jun 2026 00:49:58 +0100 Subject: [PATCH] Use generic Verse record watches --- Aetheria.State.Verify/Program.cs | 35 +++++-- .../Runtime/AetheriaRuntimeVerseClient.cs | 96 ++----------------- docs/aetheria-verse-client-contract.md | 16 +++- 3 files changed, 47 insertions(+), 100 deletions(-) diff --git a/Aetheria.State.Verify/Program.cs b/Aetheria.State.Verify/Program.cs index e55a95d1a..e8d463050 100644 --- a/Aetheria.State.Verify/Program.cs +++ b/Aetheria.State.Verify/Program.cs @@ -11594,11 +11594,8 @@ static void RequireAetheriaRuntimeVerseClientContract(string root) "public static class AetheriaRuntimeVerseContractRegistry", "AetheriaRuntimeVerseContractRegistry.CreateCultCacheRegistry()", "AetheriaRuntimeVerseContractRegistry.CreateCultNetRegistry(registry)", - "WatchLatestFrames()", - "WatchLatestSoaViews()", + "public Observable> WatchRecord(", "WatchRecord", - "WatchRecord", - "WatchVerseAuthorityPolicies()", "CultMeshMutableStatePointer", "CultMeshMutableStatePointer", "CultMeshMutableStatePointer", @@ -11615,8 +11612,6 @@ static void RequireAetheriaRuntimeVerseClientContract(string root) "new CultRecordKey(\"daemon:aetheria.starbridge.session.latest.v1\")", "Document(", "typeof(EveSurfaceState)", - "WatchDaemonGameTuiSurfaces()", - "WatchDaemonEditorTuiSurfaces()", "CultMeshMutableStatePointer", "private AetheriaClientState? _aetheriaState", "private AetheriaRuntimeManagedClientInputs? _managedClientInputs", @@ -11655,6 +11650,32 @@ static void RequireAetheriaRuntimeVerseClientContract(string root) string.Join(", ", missingClientSymbols)); } + var forbiddenNamedWatchHelpers = new[] + { + "WatchProviderAdvertisements(", + "WatchHealth(", + "WatchCommandBoundary(", + "WatchVerseAuthorityPolicies(", + "WatchLatestFrames(", + "WatchLatestSoaViews(", + "WatchStarbridgeScenarios(", + "WatchStarbridgeSessions(", + "WatchStarbridgePlayerSeat(", + "WatchDaemonGameSurfaces(", + "WatchDaemonGameTuiSurfaces(", + "WatchDaemonEditorSurfaces(", + "WatchDaemonEditorTuiSurfaces(" + }; + var survivingNamedWatchHelpers = forbiddenNamedWatchHelpers + .Where(symbol => client.Contains(symbol, StringComparison.Ordinal)) + .ToArray(); + if (survivingNamedWatchHelpers.Length > 0) + { + throw new InvalidOperationException( + "AetheriaRuntimeVerseClient must expose generic WatchRecord(CultRecordKey) instead of named record-watch wrappers: " + + string.Join(", ", survivingNamedWatchHelpers)); + } + var requiredManagedInputSymbols = new[] { "internal sealed class AetheriaRuntimeManagedClientInputs : IDisposable", @@ -11994,7 +12015,7 @@ static void RequireAetheriaRuntimeVerseClientContract(string root) var requiredDocSymbols = new[] { "AetheriaRuntimeVerseClient", - "WatchRecord()", + "WatchRecord(CultRecordKey)", "CultMeshMutableStatePointer", "Unity", "Verse records", diff --git a/Packages/org.gamecult.aetheria.state/Runtime/AetheriaRuntimeVerseClient.cs b/Packages/org.gamecult.aetheria.state/Runtime/AetheriaRuntimeVerseClient.cs index 0f151f8ce..bdd41c995 100644 --- a/Packages/org.gamecult.aetheria.state/Runtime/AetheriaRuntimeVerseClient.cs +++ b/Packages/org.gamecult.aetheria.state/Runtime/AetheriaRuntimeVerseClient.cs @@ -324,95 +324,14 @@ namespace GameCult.Aetheria.State.Verse return Document(key, documentId).ReactiveAsync(options); } - public Observable> - WatchProviderAdvertisements() + public Observable> WatchRecord( + CultRecordKey key) + where TDocument : class { ThrowIfDisposed(); - return Database.WatchRecord( - AetheriaRuntimeVerseRecordKeys.DaemonProviderAdvertisement); - } - - public Observable> WatchHealth() - { - ThrowIfDisposed(); - return Database.WatchRecord( - AetheriaRuntimeVerseRecordKeys.DaemonHealth); - } - - public Observable> - WatchCommandBoundary() - { - ThrowIfDisposed(); - return Database.WatchRecord( - AetheriaRuntimeVerseRecordKeys.DaemonCommandBoundary); - } - - public Observable> - WatchVerseAuthorityPolicies() - { - ThrowIfDisposed(); - return Database.WatchRecord( - AetheriaRuntimeVerseRecordKeys.VerseAuthorityPolicy); - } - - public Observable> WatchLatestFrames() - { - ThrowIfDisposed(); - return Database.WatchRecord( - AetheriaRuntimeVerseRecordKeys.DaemonFrameLatest); - } - - public Observable> WatchLatestSoaViews() - { - ThrowIfDisposed(); - return Database.WatchRecord( - AetheriaRuntimeVerseRecordKeys.DaemonSoaViewLatest); - } - - public Observable> WatchStarbridgeScenarios() - { - ThrowIfDisposed(); - return Database.WatchRecord( - AetheriaRuntimeVerseRecordKeys.StarbridgeScenarioLatest); - } - - public Observable> WatchStarbridgeSessions() - { - ThrowIfDisposed(); - return Database.WatchRecord( - AetheriaRuntimeVerseRecordKeys.StarbridgeSessionLatest); - } - - public Observable> - WatchStarbridgePlayerSeat(string seatId) - { - ThrowIfDisposed(); - return Database.WatchRecord( - AetheriaRuntimeVerseRecordKeys.StarbridgePlayerSeat(seatId)); - } - - public Observable> WatchDaemonGameSurfaces() - { - ThrowIfDisposed(); - return Database.WatchRecord(AetheriaRuntimeVerseRecordKeys.DaemonGameSurface); - } - - public Observable> WatchDaemonGameTuiSurfaces() - { - ThrowIfDisposed(); - return Database.WatchRecord(AetheriaRuntimeVerseRecordKeys.DaemonGameTuiSurface); - } - - public Observable> WatchDaemonEditorSurfaces() - { - ThrowIfDisposed(); - return Database.WatchRecord(AetheriaRuntimeVerseRecordKeys.DaemonEditorSurface); - } - - public Observable> WatchDaemonEditorTuiSurfaces() - { - ThrowIfDisposed(); - return Database.WatchRecord(AetheriaRuntimeVerseRecordKeys.DaemonEditorTuiSurface); + if (string.IsNullOrWhiteSpace(key.Value)) + throw new ArgumentException("Value must be non-empty.", nameof(key)); + return Database.WatchRecord(key); } internal async Task SubmitDaemonCommandAsync( @@ -527,7 +446,8 @@ namespace GameCult.Aetheria.State.Verse private AetheriaClientState CreateAetheriaState() { - var frameChanges = WatchLatestFrames() + var frameChanges = WatchRecord( + AetheriaRuntimeVerseRecordKeys.DaemonFrameLatest) .Where(change => change.Document != null) .Select(change => change.Document!); var catalogDocument = BootstrapCatalogDocument( diff --git a/docs/aetheria-verse-client-contract.md b/docs/aetheria-verse-client-contract.md index 51d8d4974..ef9b79fb6 100644 --- a/docs/aetheria-verse-client-contract.md +++ b/docs/aetheria-verse-client-contract.md @@ -29,8 +29,8 @@ registry and exposes: - current typed reads for provider advertisement, health, command boundary, latest daemon frame, latest SoA view, and daemon game/editor Eve surfaces; -- reactive watches via `WatchRecord()`, including `WatchLatestFrames()` and - `WatchLatestSoaViews()`, plus daemon GUI/TUI surface watches; +- reactive watches via `WatchRecord(CultRecordKey)`, with record identity + passed as data instead of one watch helper per document lane; - `CultMeshMutableStatePointer` handles for transparent reactive POCO presentation, including read, watch, and replace through shared CultMesh Verse context semantics; @@ -44,7 +44,10 @@ using var client = await AetheriaRuntimeVerseClient.OpenAsync( statePath, runtimeId: "unity-render-client"); -using var frames = client.WatchLatestFrames().Subscribe(change => +using var frames = client + .WatchRecord( + AetheriaRuntimeVerseRecordKeys.DaemonFrameLatest) + .Subscribe(change => { var frame = change.Document; if (frame == null) @@ -53,7 +56,10 @@ using var frames = client.WatchLatestFrames().Subscribe(change => // Feed presentation jobs from the authoritative daemon frame. }); -var soa = await client.GetLatestSoaViewAsync(); +var soa = await client + .Document( + AetheriaRuntimeVerseRecordKeys.DaemonSoaViewLatest) + .LatestAsync(); ``` That baseline is not the desired presentation API for gameplay state. Unity @@ -128,7 +134,7 @@ The daemon already publishes game and editor Eve surface records at these keys: `AetheriaRuntimeVerseRecordKeys` exposes those keys and `AetheriaRuntimeVerseClient` exposes typed reads, mutable state pointers, and -`WatchRecord()` subscriptions for all four. The +`WatchRecord(CultRecordKey)` subscriptions for all four. The `EveSurfaceState` document contract lives in the shared runtime package so a Unity client, terminal client, daemon inspector, or later non-C# runtime binding can lower the same published UI surface. The existing Eve Unity runtime host can