diff --git a/Aetheria.State.ApplyPending/Program.cs b/Aetheria.State.ApplyPending/Program.cs index a302ccbb1..30d80f62d 100644 --- a/Aetheria.State.ApplyPending/Program.cs +++ b/Aetheria.State.ApplyPending/Program.cs @@ -17,6 +17,7 @@ var evePendingBefore = CountPendingEveCommands(statePath); var now = DateTimeOffset.UtcNow.ToString("O"); await using var node = await AetheriaStateNode.OpenAsync(statePath, runtimeId); +var verseHostSettings = await EnsureVerseHostSettingsAsync(node, now); await node.PutRuntimeSessionAsync(new AetheriaRuntimeSession { RuntimeId = runtimeId, @@ -67,9 +68,15 @@ var completedSession = new AetheriaRuntimeSession Status = "completed" }; await node.PutRuntimeSessionAsync(completedSession); -await node.PutOperationsSurfaceAsync(AetheriaOperationsSurfaceProjector.Build(commitStatus, eveStatus, completedSession)); +await node.PutOperationsSurfaceAsync( + AetheriaOperationsSurfaceProjector.Build( + commitStatus, + eveStatus, + verseHostSettings, + completedSession)); await PublishPlayerSettingsSurfaceAsync(node, now); -await node.PutProviderAdvertisementAsync(AetheriaProviderAdvertisementProjector.Build(statePath, now)); +await node.PutProviderAdvertisementAsync( + AetheriaProviderAdvertisementProjector.Build(verseHostSettings, statePath, now)); await node.FlushAsync(); Console.WriteLine($"Applied pending Aetheria runtime commits: {statePath}"); @@ -110,3 +117,16 @@ static async Task PublishPlayerSettingsSurfaceAsync(AetheriaStateNode node, stri await node.PutPlayerSettingsSurfaceAsync( AetheriaPlayerSettingsSurfaceProjector.Build(settings, publishedAtUtc)).ConfigureAwait(false); } + +static async Task EnsureVerseHostSettingsAsync(AetheriaStateNode node, string now) +{ + var existing = await node.GetVerseHostSettingsAsync().ConfigureAwait(false); + var normalized = AetheriaVerseHostSettingsNormalizer.Normalize(existing); + if (existing == null || string.IsNullOrWhiteSpace(existing.LastUpdatedAtUtc)) + { + normalized.LastUpdatedAtUtc = now; + await node.PutVerseHostSettingsAsync(normalized).ConfigureAwait(false); + } + + return normalized; +} diff --git a/Aetheria.State.Smoke/Program.cs b/Aetheria.State.Smoke/Program.cs index e1fa9c6c7..c4cab143b 100644 --- a/Aetheria.State.Smoke/Program.cs +++ b/Aetheria.State.Smoke/Program.cs @@ -105,8 +105,15 @@ await using (var node = await AetheriaStateNode.OpenAsync(statePath, "aetheria-s Status = "ok" }; await node.PutRuntimeCommitDrainStatusAsync(drainStatus); - await node.PutOperationsSurfaceAsync(AetheriaOperationsSurfaceProjector.Build(drainStatus)); - await node.PutProviderAdvertisementAsync(AetheriaProviderAdvertisementProjector.Build(statePath, now)); + var verseHostSettings = AetheriaVerseHostSettingsNormalizer.Normalize(new AetheriaVerseHostSettings + { + LastUpdatedAtUtc = now + }); + await node.PutVerseHostSettingsAsync(verseHostSettings); + await node.PutOperationsSurfaceAsync( + AetheriaOperationsSurfaceProjector.Build(drainStatus, verseHostSettings: verseHostSettings)); + await node.PutProviderAdvertisementAsync( + AetheriaProviderAdvertisementProjector.Build(verseHostSettings, statePath, now)); await node.PutRuntimeSessionAsync(new AetheriaRuntimeSession { RuntimeId = "smoke-runtime", @@ -117,6 +124,7 @@ await using (var node = await AetheriaStateNode.OpenAsync(statePath, "aetheria-s }); await node.PutOperationsSurfaceAsync(AetheriaOperationsSurfaceProjector.Build( drainStatus, + verseHostSettings: verseHostSettings, runtimeSession: await node.GetRuntimeSessionAsync("smoke-runtime"))); await node.PutLoadoutTemplateAsync(loadoutKey, new AetheriaLoadoutTemplate @@ -537,7 +545,8 @@ await using (var node = await AetheriaStateNode.OpenAsync(statePath, "aetheria-s await node.PutOperationsSurfaceAsync(AetheriaOperationsSurfaceProjector.Build( drainStatus, eveCommandStatus, - await node.GetRuntimeSessionAsync("smoke-runtime"))); + verseHostSettings: await node.GetVerseHostSettingsAsync(), + runtimeSession: await node.GetRuntimeSessionAsync("smoke-runtime"))); await node.FlushAsync(); } diff --git a/Aetheria.State.Verify/Program.cs b/Aetheria.State.Verify/Program.cs index cdc2a8cb0..e6e4a0b78 100644 --- a/Aetheria.State.Verify/Program.cs +++ b/Aetheria.State.Verify/Program.cs @@ -48,6 +48,7 @@ RequireTradeItemDetailsUseEveSurface(root); RequireInventoryDropdownUseEveSurface(root); RequireNoDeadPopupShells(root); RequirePlayerSettingsEveSurface(root); +RequireVerseHostSettingsAuthority(root); RequireMainMenuContinueRunState(root); RequireDeadPropertiesPanelShellDeleted(root); RequireTypedBehaviorMetadataCoverage(root); @@ -529,6 +530,7 @@ Console.WriteLine("Main-menu Continue authority: Continue selects typed run stat Console.WriteLine("Generic popup inspector shell: PropertiesPanel, PropertiesList, and DropdownMenu are deleted from source and serialized assets"); Console.WriteLine("Typed behavior metadata authority: live heat/mining/thermotoggle payload kinds stay owned by package metadata"); Console.WriteLine("NameTools editor shell: the remaining name helper window lowers through UI Toolkit instead of IMGUI"); +Console.WriteLine("Verse host authority: daemon-owned typed verse host settings now drive provider advertisement and operations telemetry"); Console.WriteLine("Runtime simulation tuning authority: UI writes flow through gameplay checkpoint commits"); Console.WriteLine("Hull conductivity authority: inventory UI toggles flow through gameplay checkpoint commits"); Console.WriteLine("Inventory entity rename authority: UI rename flows through gameplay checkpoint commits"); @@ -3532,6 +3534,169 @@ static void RequirePlayerSettingsEveSurface(string root) } } +static void RequireVerseHostSettingsAuthority(string root) +{ + var settingsPath = Path.Combine(root, "Aetheria.State", "Documents", "AetheriaVerseHostSettings.cs"); + var normalizerPath = Path.Combine(root, "Aetheria.State", "AetheriaVerseHostSettingsNormalizer.cs"); + var registryPath = Path.Combine(root, "Aetheria.State", "AetheriaDocumentRegistry.cs"); + var nodePath = Path.Combine(root, "Aetheria.State", "AetheriaStateNode.cs"); + var providerPath = Path.Combine(root, "Aetheria.State", "AetheriaProviderAdvertisementProjector.cs"); + var operationsPath = Path.Combine(root, "Aetheria.State", "AetheriaOperationsSurfaceProjector.cs"); + var serverPath = Path.Combine(root, "Economy.Server", "Program.cs"); + var serverSettingsPath = Path.Combine(root, "Economy.Server", "appsettings.json"); + var applyPendingPath = Path.Combine(root, "Aetheria.State.ApplyPending", "Program.cs"); + + var requiredFiles = new[] + { + settingsPath, + normalizerPath, + registryPath, + nodePath, + providerPath, + operationsPath, + serverPath, + serverSettingsPath, + applyPendingPath + }; + + var missingFiles = requiredFiles + .Where(path => !File.Exists(path)) + .Select(path => Path.GetRelativePath(root, path)) + .ToArray(); + if (missingFiles.Length > 0) + { + throw new InvalidOperationException( + "Verse host authority cut is incomplete; missing files: " + string.Join(", ", missingFiles)); + } + + var settings = File.ReadAllText(settingsPath); + var normalizer = File.ReadAllText(normalizerPath); + var registry = File.ReadAllText(registryPath); + var node = File.ReadAllText(nodePath); + var provider = File.ReadAllText(providerPath); + var operations = File.ReadAllText(operationsPath); + var server = File.ReadAllText(serverPath); + var serverSettings = File.ReadAllText(serverSettingsPath); + var applyPending = File.ReadAllText(applyPendingPath); + + var requiredSettingsSymbols = new[] + { + "[CultDocument(\"aetheria.verse_host_settings\", \"aetheria.verse_host_settings.v1\")]", + "public sealed class AetheriaVerseHostSettings", + "public string VerseId", + "public string CultMeshAddress", + "public string Visibility" + }; + var missingSettingsSymbols = requiredSettingsSymbols + .Where(symbol => !settings.Contains(symbol, StringComparison.Ordinal)) + .ToArray(); + if (missingSettingsSymbols.Length > 0) + { + throw new InvalidOperationException( + "Typed verse-host settings document is missing required authority fields: " + + string.Join(", ", missingSettingsSymbols)); + } + + if (!normalizer.Contains("public static AetheriaVerseHostSettings Normalize", StringComparison.Ordinal) || + !normalizer.Contains("public static bool Equivalent", StringComparison.Ordinal)) + { + throw new InvalidOperationException( + "Verse-host settings normalizer is missing normalize/equivalence ownership."); + } + + if (!registry.Contains("CultNetDocumentBinding.ForDocument", StringComparison.Ordinal) || + !registry.Contains("typeof(AetheriaVerseHostSettings)", StringComparison.Ordinal)) + { + throw new InvalidOperationException( + "Aetheria document registry does not register typed verse-host settings."); + } + + if (!node.Contains("PutVerseHostSettingsAsync", StringComparison.Ordinal) || + !node.Contains("GetVerseHostSettingsAsync", StringComparison.Ordinal) || + !node.Contains("global:aetheria.verse_host_settings.v1", StringComparison.Ordinal)) + { + throw new InvalidOperationException( + "Aetheria state node does not expose typed verse-host settings get/put ports."); + } + + var forbiddenHardcodedProviderSymbols = new[] + { + "VerseId = \"aetheria.local\"", + "RootVerse = \"asgard\"", + "CanonicalService = \"asgard.aetheria\"", + "LocatedService = \"asgard.local.aetheria\"", + "CultMeshAddress = \"asgard.local.aetheria/eve\"" + }; + var survivingHardcodedProviderSymbols = forbiddenHardcodedProviderSymbols + .Where(symbol => provider.Contains(symbol, StringComparison.Ordinal)) + .ToArray(); + if (survivingHardcodedProviderSymbols.Length > 0) + { + throw new InvalidOperationException( + "Provider advertisement still hardcodes daemon verse identity: " + + string.Join(", ", survivingHardcodedProviderSymbols)); + } + + if (!provider.Contains("AetheriaVerseHostSettings settings", StringComparison.Ordinal) || + !provider.Contains("AetheriaVerseHostSettingsNormalizer.Normalize(settings)", StringComparison.Ordinal)) + { + throw new InvalidOperationException( + "Provider advertisement no longer derives Verse identity from typed daemon settings."); + } + + if (!operations.Contains("AetheriaVerseHostSettings? verseHostSettings = null", StringComparison.Ordinal) || + !operations.Contains("AetheriaVerseHostSettingsNormalizer.Normalize(verseHostSettings)", StringComparison.Ordinal) || + !operations.Contains("\"aetheria.operations.verseHost\"", StringComparison.Ordinal) || + !operations.Contains("Metric(\"verseHost.visibility\"", StringComparison.Ordinal)) + { + throw new InvalidOperationException( + "Operations surface does not expose the typed daemon Verse-host telemetry card."); + } + + var requiredServerSymbols = new[] + { + "EnsureVerseHostSettingsAsync", + "LoadVerseHostOverrides", + "GetVerseHostSettingsAsync", + "PutVerseHostSettingsAsync", + "AetheriaProviderAdvertisementProjector.Build(verseHostSettings, node.StatePath, updatedAtUtc)" + }; + var missingServerSymbols = requiredServerSymbols + .Where(symbol => !server.Contains(symbol, StringComparison.Ordinal)) + .ToArray(); + if (missingServerSymbols.Length > 0) + { + throw new InvalidOperationException( + "Economy.Server is missing typed verse-host startup authority: " + + string.Join(", ", missingServerSymbols)); + } + + var requiredServerSettingsSymbols = new[] + { + "\"Aetheria\"", + "\"VerseHost\"", + "\"VerseId\"", + "\"CultMeshAddress\"", + "\"Visibility\"" + }; + var missingServerSettingsSymbols = requiredServerSettingsSymbols + .Where(symbol => !serverSettings.Contains(symbol, StringComparison.Ordinal)) + .ToArray(); + if (missingServerSettingsSymbols.Length > 0) + { + throw new InvalidOperationException( + "Economy.Server appsettings are missing the daemon Verse-host section: " + + string.Join(", ", missingServerSettingsSymbols)); + } + + if (!applyPending.Contains("EnsureVerseHostSettingsAsync", StringComparison.Ordinal) || + !applyPending.Contains("AetheriaProviderAdvertisementProjector.Build(verseHostSettings, statePath, now)", StringComparison.Ordinal)) + { + throw new InvalidOperationException( + "Aetheria.State.ApplyPending does not preserve typed verse-host projection authority."); + } +} + static void RequireMainMenuContinueRunState(string root) { var mainMenuPath = Path.Combine(root, "Assets", "Scripts", "UI", "MainMenu.cs"); diff --git a/Aetheria.State/AetheriaDocumentRegistry.cs b/Aetheria.State/AetheriaDocumentRegistry.cs index 3bac5a6b8..3fcee08f1 100644 --- a/Aetheria.State/AetheriaDocumentRegistry.cs +++ b/Aetheria.State/AetheriaDocumentRegistry.cs @@ -37,6 +37,7 @@ public static class AetheriaDocumentRegistry CultNetDocumentBinding.ForDocument(registry), CultNetDocumentBinding.ForDocument(registry), CultNetDocumentBinding.ForDocument(registry), + CultNetDocumentBinding.ForDocument(registry), CultNetDocumentBinding.ForDocument(registry), CultNetDocumentBinding.ForDocument(registry), CultNetDocumentBinding.ForDocument(registry), @@ -59,6 +60,7 @@ public static class AetheriaDocumentRegistry typeof(AetheriaRunState), typeof(AetheriaZoneState), typeof(AetheriaEntitySnapshot), + typeof(AetheriaVerseHostSettings), typeof(AetheriaRuntimeCommitDrainStatus), typeof(AetheriaEveCommandDrainStatus), typeof(EveSurfaceState), diff --git a/Aetheria.State/AetheriaEveCommandBridge.cs b/Aetheria.State/AetheriaEveCommandBridge.cs index 51db607ca..7dc3b2fee 100644 --- a/Aetheria.State/AetheriaEveCommandBridge.cs +++ b/Aetheria.State/AetheriaEveCommandBridge.cs @@ -63,8 +63,16 @@ public static class AetheriaEveCommandBridge EmptyCommitDrainStatus(node.StatePath, command.IssuedAtUtc); var eveStatus = await node.GetEveCommandDrainStatusAsync().ConfigureAwait(false) ?? EmptyEveCommandDrainStatus(node.StatePath, command.IssuedAtUtc); + var verseHostSettings = await node.GetVerseHostSettingsAsync().ConfigureAwait(false); + var runtimeSession = string.IsNullOrWhiteSpace(commitStatus.RuntimeId) + ? null + : await node.GetRuntimeSessionAsync(commitStatus.RuntimeId).ConfigureAwait(false); await node.PutOperationsSurfaceAsync( - AetheriaOperationsSurfaceProjector.Build(commitStatus, eveStatus)).ConfigureAwait(false); + AetheriaOperationsSurfaceProjector.Build( + commitStatus, + eveStatus, + verseHostSettings, + runtimeSession)).ConfigureAwait(false); report.AppliedOperationsRefreshes++; break; case GameCult.Aetheria.State.Unity.AetheriaRuntimePlayerSettingsCommands.Refresh: diff --git a/Aetheria.State/AetheriaOperationsSurfaceProjector.cs b/Aetheria.State/AetheriaOperationsSurfaceProjector.cs index e683c1de6..c9635f122 100644 --- a/Aetheria.State/AetheriaOperationsSurfaceProjector.cs +++ b/Aetheria.State/AetheriaOperationsSurfaceProjector.cs @@ -10,12 +10,15 @@ public static class AetheriaOperationsSurfaceProjector public static EveSurfaceState Build( AetheriaRuntimeCommitDrainStatus drainStatus, AetheriaEveCommandDrainStatus? eveCommandStatus = null, + AetheriaVerseHostSettings? verseHostSettings = null, AetheriaRuntimeSession? runtimeSession = null, long version = 1) { + var normalizedVerseHost = AetheriaVerseHostSettingsNormalizer.Normalize(verseHostSettings); var updatedAtUtc = LatestTimestamp( drainStatus.LastPollAtUtc, eveCommandStatus?.LastPollAtUtc, + normalizedVerseHost.LastUpdatedAtUtc, runtimeSession?.LastSeenAtUtc); return new EveSurfaceState { @@ -68,6 +71,19 @@ public static class AetheriaOperationsSurfaceProjector ("lastRejected", eveCommandStatus?.LastRejectedCommand ?? ""), ("rejectedReason", eveCommandStatus?.LastRejectedReason ?? ""), ("error", eveCommandStatus?.LastError ?? ""))), + Node( + "aetheria.operations.verseHost", + "card", + [("title", "Verse Host")], + Metric("verseHost.visibility", "Visibility", normalizedVerseHost.Visibility), + Metric("verseHost.service", "Service", normalizedVerseHost.ServiceId), + Metric("verseHost.verse", "Verse", normalizedVerseHost.VerseId), + Row( + "verseHost.identity", + ("rootVerse", normalizedVerseHost.RootVerse), + ("canonicalService", normalizedVerseHost.CanonicalService), + ("locatedService", normalizedVerseHost.LocatedService), + ("cultMeshAddress", normalizedVerseHost.CultMeshAddress))), Node( "aetheria.operations.runtimeSession", "card", diff --git a/Aetheria.State/AetheriaProviderAdvertisementProjector.cs b/Aetheria.State/AetheriaProviderAdvertisementProjector.cs index 8cee46635..8f75a45cf 100644 --- a/Aetheria.State/AetheriaProviderAdvertisementProjector.cs +++ b/Aetheria.State/AetheriaProviderAdvertisementProjector.cs @@ -7,18 +7,22 @@ public static class AetheriaProviderAdvertisementProjector public const string AdvertisementKey = "eve:provider:aetheria"; public const string ProviderId = "aetheria"; - public static EveProviderAdvertisementState Build(string statePath, string updatedAtUtc) + public static EveProviderAdvertisementState Build( + AetheriaVerseHostSettings settings, + string statePath, + string updatedAtUtc) { + var normalized = AetheriaVerseHostSettingsNormalizer.Normalize(settings); return new EveProviderAdvertisementState { ProviderId = ProviderId, - ServiceId = "aetheria.runtime", - VerseId = "aetheria.local", - RootVerse = "asgard", - CanonicalService = "asgard.aetheria", - LocatedService = "asgard.local.aetheria", - CultMeshAddress = "asgard.local.aetheria/eve", - Title = "Aetheria", + ServiceId = normalized.ServiceId, + VerseId = normalized.VerseId, + RootVerse = normalized.RootVerse, + CanonicalService = normalized.CanonicalService, + LocatedService = normalized.LocatedService, + CultMeshAddress = normalized.CultMeshAddress, + Title = normalized.Title, Kind = "game.runtime", UpdatedAtUtc = updatedAtUtc, Freshness = new EveProviderFreshness @@ -38,6 +42,7 @@ public static class AetheriaProviderAdvertisementProjector "aetheria.run_state.v1", "aetheria.zone_state.v1", "aetheria.entity_snapshot.v1", + "aetheria.verse_host_settings.v1", "aetheria.runtime_session.v1", "aetheria.runtime_commit_drain_status.v1", "aetheria.eve_command_drain_status.v1", diff --git a/Aetheria.State/AetheriaStateNode.cs b/Aetheria.State/AetheriaStateNode.cs index 7f82964be..b7bb8a49c 100644 --- a/Aetheria.State/AetheriaStateNode.cs +++ b/Aetheria.State/AetheriaStateNode.cs @@ -270,6 +270,18 @@ public sealed class AetheriaStateNode : IAsyncDisposable, IDisposable return Database.GetAsync(key); } + public Task> PutVerseHostSettingsAsync( + AetheriaVerseHostSettings settings) + { + return Database.PutAsync(new CultRecordKey("global:aetheria.verse_host_settings.v1"), settings); + } + + public Task GetVerseHostSettingsAsync() + { + return Database.GetAsync( + new CultRecordKey("global:aetheria.verse_host_settings.v1")); + } + public Task> PutRuntimeCommitDrainStatusAsync( AetheriaRuntimeCommitDrainStatus status) { diff --git a/Aetheria.State/AetheriaVerseHostSettingsNormalizer.cs b/Aetheria.State/AetheriaVerseHostSettingsNormalizer.cs new file mode 100644 index 000000000..a1ff7ee30 --- /dev/null +++ b/Aetheria.State/AetheriaVerseHostSettingsNormalizer.cs @@ -0,0 +1,44 @@ +using Aetheria.State.Documents; + +namespace Aetheria.State; + +public static class AetheriaVerseHostSettingsNormalizer +{ + public static AetheriaVerseHostSettings Normalize(AetheriaVerseHostSettings? settings) + { + return new AetheriaVerseHostSettings + { + Schema = NormalizeOrDefault(settings?.Schema, "aetheria.verse_host_settings.v1"), + ServiceId = NormalizeOrDefault(settings?.ServiceId, "aetheria.runtime"), + VerseId = NormalizeOrDefault(settings?.VerseId, "aetheria.local"), + RootVerse = NormalizeOrDefault(settings?.RootVerse, "asgard"), + CanonicalService = NormalizeOrDefault(settings?.CanonicalService, "asgard.aetheria"), + LocatedService = NormalizeOrDefault(settings?.LocatedService, "asgard.local.aetheria"), + CultMeshAddress = NormalizeOrDefault(settings?.CultMeshAddress, "asgard.local.aetheria/eve"), + Title = NormalizeOrDefault(settings?.Title, "Aetheria"), + Visibility = NormalizeOrDefault(settings?.Visibility, "private"), + LastUpdatedAtUtc = settings?.LastUpdatedAtUtc?.Trim() ?? "" + }; + } + + public static bool Equivalent(AetheriaVerseHostSettings? left, AetheriaVerseHostSettings? right) + { + var normalizedLeft = Normalize(left); + var normalizedRight = Normalize(right); + return string.Equals(normalizedLeft.Schema, normalizedRight.Schema, StringComparison.Ordinal) && + string.Equals(normalizedLeft.ServiceId, normalizedRight.ServiceId, StringComparison.Ordinal) && + string.Equals(normalizedLeft.VerseId, normalizedRight.VerseId, StringComparison.Ordinal) && + string.Equals(normalizedLeft.RootVerse, normalizedRight.RootVerse, StringComparison.Ordinal) && + string.Equals(normalizedLeft.CanonicalService, normalizedRight.CanonicalService, StringComparison.Ordinal) && + string.Equals(normalizedLeft.LocatedService, normalizedRight.LocatedService, StringComparison.Ordinal) && + string.Equals(normalizedLeft.CultMeshAddress, normalizedRight.CultMeshAddress, StringComparison.Ordinal) && + string.Equals(normalizedLeft.Title, normalizedRight.Title, StringComparison.Ordinal) && + string.Equals(normalizedLeft.Visibility, normalizedRight.Visibility, StringComparison.Ordinal); + } + + private static string NormalizeOrDefault(string? value, string fallback) + { + var trimmed = value?.Trim(); + return string.IsNullOrWhiteSpace(trimmed) ? fallback : trimmed; + } +} diff --git a/Aetheria.State/Documents/AetheriaVerseHostSettings.cs b/Aetheria.State/Documents/AetheriaVerseHostSettings.cs new file mode 100644 index 000000000..d9a8419cd --- /dev/null +++ b/Aetheria.State/Documents/AetheriaVerseHostSettings.cs @@ -0,0 +1,21 @@ +using GameCult.Caching; +using MessagePack; + +namespace Aetheria.State.Documents; + +[CultDocument("aetheria.verse_host_settings", "aetheria.verse_host_settings.v1")] +[CultGlobal] +[MessagePackObject] +public sealed class AetheriaVerseHostSettings +{ + [Key(0)] public string Schema { get; set; } = "aetheria.verse_host_settings.v1"; + [Key(1)] public string ServiceId { get; set; } = "aetheria.runtime"; + [Key(2)] public string VerseId { get; set; } = "aetheria.local"; + [Key(3)] public string RootVerse { get; set; } = "asgard"; + [Key(4)] public string CanonicalService { get; set; } = "asgard.aetheria"; + [Key(5)] public string LocatedService { get; set; } = "asgard.local.aetheria"; + [Key(6)] public string CultMeshAddress { get; set; } = "asgard.local.aetheria/eve"; + [Key(7)] public string Title { get; set; } = "Aetheria"; + [Key(8)] public string Visibility { get; set; } = "private"; + [Key(9)] public string LastUpdatedAtUtc { get; set; } = ""; +} diff --git a/Aetheria.State/README.md b/Aetheria.State/README.md index 9555c7338..a447842cc 100644 --- a/Aetheria.State/README.md +++ b/Aetheria.State/README.md @@ -389,15 +389,19 @@ The server publishes `AetheriaRuntimeCommitDrainStatus`, typed `aetheria.player_settings` Eve surface after drain attempts, so pending depth, accepted/applied/rejected counts, failures, timestamps, and player settings controls are typed state rather than console-only status. It also -publishes `gamecult.eve.provider_advertisement.v1` for the `aetheria` provider, -advertising the catalog, operations, and player-settings surfaces plus the -typed schemas witnessed by the local `.cc` state file. +persists daemon-owned `aetheria.verse_host_settings.v1`, with boot-time +defaults or overrides for service id, Verse id, visibility, and CultMesh +address. The operations surface and provider advertisement project from that +typed host document instead of hardcoded daemon identity strings. The provider +advertisement still publishes `gamecult.eve.provider_advertisement.v1` for the +`aetheria` provider, advertising the catalog, operations, and player-settings +surfaces plus the typed schemas witnessed by the local `.cc` state file. `Aetheria.State.ApplyPending` is the smaller local operator applicator for queued Unity runtime commits and Eve commands when the server host is not being used. It also republishes the typed drain status, operations surface, -player-settings surface, and provider advertisement after applying pending -files: +player-settings surface, typed `aetheria.verse_host_settings.v1`, and provider +advertisement after applying pending files: ```powershell dotnet run --project .\Aetheria.State.ApplyPending\Aetheria.State.ApplyPending.csproj -- . diff --git a/Economy.Server/Program.cs b/Economy.Server/Program.cs index 0baf75f1d..d1c081102 100644 --- a/Economy.Server/Program.cs +++ b/Economy.Server/Program.cs @@ -1,3 +1,4 @@ +using System.Text.Json; using Aetheria.State; using Aetheria.State.Documents; @@ -17,6 +18,7 @@ internal static class Program runtimeId: RuntimeId, startServer: true).ConfigureAwait(false); + await EnsureVerseHostSettingsAsync(node).ConfigureAwait(false); var startedAtUtc = DateTimeOffset.UtcNow.ToString("O"); await PublishRuntimeSessionAsync(node, startedAtUtc, "starting").ConfigureAwait(false); await EnsureWorldDocumentAsync(node).ConfigureAwait(false); @@ -218,12 +220,20 @@ internal static class Program Status = "idle" }; var eveStatus = await node.GetEveCommandDrainStatusAsync().ConfigureAwait(false); + var verseHostSettings = await node.GetVerseHostSettingsAsync().ConfigureAwait(false) ?? + new AetheriaVerseHostSettings(); var runtimeSession = await node.GetRuntimeSessionAsync(RuntimeId).ConfigureAwait(false); - await node.PutOperationsSurfaceAsync(AetheriaOperationsSurfaceProjector.Build(commitStatus, eveStatus, runtimeSession)) + await node.PutOperationsSurfaceAsync( + AetheriaOperationsSurfaceProjector.Build( + commitStatus, + eveStatus, + verseHostSettings, + runtimeSession)) .ConfigureAwait(false); await PublishPlayerSettingsSurfaceAsync(node, updatedAtUtc).ConfigureAwait(false); await node.PutProviderAdvertisementAsync( - AetheriaProviderAdvertisementProjector.Build(node.StatePath, updatedAtUtc)).ConfigureAwait(false); + AetheriaProviderAdvertisementProjector.Build(verseHostSettings, node.StatePath, updatedAtUtc)) + .ConfigureAwait(false); await node.FlushAsync().ConfigureAwait(false); } @@ -316,4 +326,109 @@ internal static class Program { return args.Any(arg => string.Equals(arg, flag, StringComparison.OrdinalIgnoreCase)); } + + private static async Task EnsureVerseHostSettingsAsync(AetheriaStateNode node) + { + var existing = await node.GetVerseHostSettingsAsync().ConfigureAwait(false); + var candidate = AetheriaVerseHostSettingsNormalizer.Normalize(existing); + ApplyVerseHostOverrides(candidate, LoadVerseHostOverrides()); + + if (existing == null || + string.IsNullOrWhiteSpace(existing.LastUpdatedAtUtc) || + !AetheriaVerseHostSettingsNormalizer.Equivalent(existing, candidate)) + { + candidate.LastUpdatedAtUtc = DateTimeOffset.UtcNow.ToString("O"); + await node.PutVerseHostSettingsAsync(candidate).ConfigureAwait(false); + await node.FlushAsync().ConfigureAwait(false); + } + } + + private static VerseHostOverrides LoadVerseHostOverrides() + { + var candidatePaths = new[] + { + Path.Combine(AppContext.BaseDirectory, "appsettings.json"), + Path.GetFullPath(Path.Combine(AppContext.BaseDirectory, "..", "..", "..", "..", "Economy.Server", "appsettings.json")) + }; + + var settingsPath = candidatePaths.FirstOrDefault(File.Exists); + if (string.IsNullOrWhiteSpace(settingsPath)) + { + return new VerseHostOverrides(); + } + + using var document = JsonDocument.Parse(File.ReadAllText(settingsPath)); + if (!TryGetPropertyIgnoreCase(document.RootElement, "Aetheria", out var aetheriaSection) || + !TryGetPropertyIgnoreCase(aetheriaSection, "VerseHost", out var verseHostSection)) + { + return new VerseHostOverrides(); + } + + return new VerseHostOverrides + { + ServiceId = ReadOptionalString(verseHostSection, "ServiceId"), + VerseId = ReadOptionalString(verseHostSection, "VerseId"), + RootVerse = ReadOptionalString(verseHostSection, "RootVerse"), + CanonicalService = ReadOptionalString(verseHostSection, "CanonicalService"), + LocatedService = ReadOptionalString(verseHostSection, "LocatedService"), + CultMeshAddress = ReadOptionalString(verseHostSection, "CultMeshAddress"), + Title = ReadOptionalString(verseHostSection, "Title"), + Visibility = ReadOptionalString(verseHostSection, "Visibility") + }; + } + + private static void ApplyVerseHostOverrides(AetheriaVerseHostSettings settings, VerseHostOverrides overrides) + { + settings.ServiceId = ChooseOverride(overrides.ServiceId, settings.ServiceId); + settings.VerseId = ChooseOverride(overrides.VerseId, settings.VerseId); + settings.RootVerse = ChooseOverride(overrides.RootVerse, settings.RootVerse); + settings.CanonicalService = ChooseOverride(overrides.CanonicalService, settings.CanonicalService); + settings.LocatedService = ChooseOverride(overrides.LocatedService, settings.LocatedService); + settings.CultMeshAddress = ChooseOverride(overrides.CultMeshAddress, settings.CultMeshAddress); + settings.Title = ChooseOverride(overrides.Title, settings.Title); + settings.Visibility = ChooseOverride(overrides.Visibility, settings.Visibility); + } + + private static string ChooseOverride(string? candidate, string fallback) + { + return string.IsNullOrWhiteSpace(candidate) ? fallback : candidate.Trim(); + } + + private static string ReadOptionalString(JsonElement element, string propertyName) + { + if (!TryGetPropertyIgnoreCase(element, propertyName, out var value) || + value.ValueKind != JsonValueKind.String) + { + return ""; + } + + return value.GetString()?.Trim() ?? ""; + } + + private static bool TryGetPropertyIgnoreCase(JsonElement element, string propertyName, out JsonElement value) + { + foreach (var property in element.EnumerateObject()) + { + if (string.Equals(property.Name, propertyName, StringComparison.OrdinalIgnoreCase)) + { + value = property.Value; + return true; + } + } + + value = default; + return false; + } + + private sealed class VerseHostOverrides + { + public string ServiceId { get; init; } = ""; + public string VerseId { get; init; } = ""; + public string RootVerse { get; init; } = ""; + public string CanonicalService { get; init; } = ""; + public string LocatedService { get; init; } = ""; + public string CultMeshAddress { get; init; } = ""; + public string Title { get; init; } = ""; + public string Visibility { get; init; } = ""; + } } diff --git a/Economy.Server/appsettings.json b/Economy.Server/appsettings.json index 4420c2645..4c09a458e 100644 --- a/Economy.Server/appsettings.json +++ b/Economy.Server/appsettings.json @@ -1,4 +1,16 @@ { + "Aetheria": { + "VerseHost": { + "ServiceId": "aetheria.runtime", + "VerseId": "aetheria.local", + "RootVerse": "asgard", + "CanonicalService": "asgard.aetheria", + "LocatedService": "asgard.local.aetheria", + "CultMeshAddress": "asgard.local.aetheria/eve", + "Title": "Aetheria", + "Visibility": "private" + } + }, "MagicOnion": { "ServerPorts": [ { @@ -15,4 +27,4 @@ "Microsoft": "Information" } } -} \ No newline at end of file +} diff --git a/docs/aetheria-perfect-machine-map.md b/docs/aetheria-perfect-machine-map.md index 9e7604c8b..be36cdcfc 100644 --- a/docs/aetheria-perfect-machine-map.md +++ b/docs/aetheria-perfect-machine-map.md @@ -516,6 +516,11 @@ legacy catalog cache, and legacy UI paths should be migration-only or deleted. - `AetheriaRuntimeCommitDrainStatus` and the `aetheria.operations` Eve surface publish pending-drain health, pending depth, applied counts, failures, and timestamps as typed state. Console logs are notification-only. +- Daemon Verse/service identity now lives in typed + `aetheria.verse_host_settings.v1`, owned by the Aetheria daemon. Provider + advertisement and operations telemetry project from that document, so public + or private Verse exposure and seed-galaxy Verse routing no longer hide in + hardcoded projector strings. - `AetheriaPlayerSettingsSurfaceProjector` now emits a provider-owned `aetheria.player_settings` Eve surface from canonical `AetheriaPlayerSettings` state. Gameplay and graphics settings are exposed as typed read models plus @@ -523,8 +528,9 @@ legacy catalog cache, and legacy UI paths should be migration-only or deleted. - `AetheriaProviderAdvertisementProjector` publishes `gamecult.eve.provider_advertisement.v1` for the `aetheria` provider, advertising the catalog, operations, and player-settings surfaces, command - boundaries, schemas, and `.cc` witness path. This is the discovery map for - Odin/Eve, not a health page. + boundaries, schemas, and `.cc` witness path. Its Verse/service identity now + comes from typed daemon host settings instead of hardcoded projector fields. + This is the discovery map for Odin/Eve, not a health page. - `AetheriaCatalogSurfaceProjector` now emits the first provider-owned Eve surface from typed catalog state. The importer materializes a `gamecult.eve.surface.v1` catalog operator document at @@ -1660,6 +1666,9 @@ First Aetheria surfaces to publish: operations surface. - Done: publish Eve command-drain health as typed CultCache state and include it in the operations surface. + - Done: move daemon Verse/service identity into typed + `aetheria.verse_host_settings.v1`, with provider advertisement and + operations telemetry deriving from that daemon-owned host document. - Done: publish provider-owned player-settings controls as a typed Eve surface and advertise their command boundary through the provider ad. - Done: publish an Eve provider advertisement so Odin/Eve can discover