diff --git a/Aetheria.State.AuthoritySmoke/Aetheria.State.AuthoritySmoke.csproj b/Aetheria.State.AuthoritySmoke/Aetheria.State.AuthoritySmoke.csproj index ca788873d..8c34ca0a4 100644 --- a/Aetheria.State.AuthoritySmoke/Aetheria.State.AuthoritySmoke.csproj +++ b/Aetheria.State.AuthoritySmoke/Aetheria.State.AuthoritySmoke.csproj @@ -8,6 +8,6 @@ - + diff --git a/Aetheria.State.AuthoritySmoke/Program.cs b/Aetheria.State.AuthoritySmoke/Program.cs index 8527ba6b8..863918294 100644 --- a/Aetheria.State.AuthoritySmoke/Program.cs +++ b/Aetheria.State.AuthoritySmoke/Program.cs @@ -1,4 +1,6 @@ using Aetheria.State; +using Aetheria.State.Daemon; +using Aetheria.State.Documents; using GameCult.Aetheria.State.Verse; using System.Diagnostics; using System.Net; @@ -221,6 +223,7 @@ internal sealed class AuthoritySmokeChecks private static void PreRejectedCommandsEnterFrameReceipts() { var command = Command("pilot-client", "entity:raven"); + using var physics = new AetheriaYmirWorldPhysics(); var result = AetheriaRuntimeDaemonTickRunner.Tick( Path.Combine(Path.GetTempPath(), "aetheria-authority-smoke.cc"), new AetheriaRuntimeRunCheckpointCommit(), @@ -231,6 +234,7 @@ internal sealed class AuthoritySmokeChecks FrameId = 42, SimulationTimeSeconds = 1, FixedDeltaSeconds = 0.02, + WorldPhysics = physics, ObservedCommands = Array.Empty(), PreRejectedCommandIds = [command.CommandId], BuildPublications = false @@ -547,8 +551,8 @@ internal sealed class AuthoritySmokeChecks }, AetheriaRuntimeDaemonCommandBoundaryDocument.Create("starbridge-daemon"), summary); - RequireSurfaceMetric(gameSurface, "aetheria.daemon.game.starbridge.scenario", "Frontier Fabricator Defense", "daemon game surface starbridge scenario"); - RequireSurfaceMetric(gameSurface, "aetheria.daemon.game.starbridge.base", "Starbridge Base", "daemon game surface starbridge base"); + RequireSurfaceMetric(gameSurface, "aetheria.starbridge.commander.session.scenario", "Frontier Fabricator Defense", "commander surface starbridge scenario"); + RequireSurfaceMetric(gameSurface, "aetheria.starbridge.commander.session.base", "Starbridge Base", "commander surface starbridge base"); RequireSurfaceMetric(gameSurface, "aetheria.daemon.game.starbridge.stock.0.item", "coolant-beam", "daemon game surface starbridge stock"); RequireSurfaceMetric(gameSurface, "aetheria.daemon.game.starbridge.wave.0.name", "Bomber Line", "daemon game surface starbridge wave forecast"); RequireSurfaceMetric(gameSurface, "aetheria.daemon.game.starbridge.role.0.runtime", "commander-client", "daemon game surface starbridge runtime role"); @@ -724,6 +728,7 @@ internal sealed class AuthoritySmokeChecks var clientCultMeshPort = GetFreeUdpPort(); const string runtimeId = "starbridge-daemon-smoke"; + await SeedCanonicalCatalogAsync(statePath, runtimeId).ConfigureAwait(false); await RunDaemonOnceAsync(statePath, runtimeId, clientCultMeshPort).ConfigureAwait(false); using var client = await AetheriaClient @@ -1002,6 +1007,7 @@ internal sealed class AuthoritySmokeChecks private static void TrustedCommittedFactsConvergeLocalRuns() { + using var physics = new AetheriaYmirWorldPhysics(); var smokeId = Guid.NewGuid().ToString("N"); var policy = CoopPolicyWithMetadata(); var ravenKey = EntityKey("coop-smoke", 0, 0); @@ -1033,7 +1039,8 @@ internal sealed class AuthoritySmokeChecks localRuntimeId: "commander-local", daemonId: "commander-local", sessionId: "authority-smoke", - verseId: policy.VerseId); + verseId: policy.VerseId, + worldPhysics: physics); Require(commanderImport.AcceptedFactIds.Contains(ravenMovementFact.FactId), "Commander should accept Raven's committed Raven movement fact"); Require(!commanderImport.RejectedFactIds.Contains(ravenMovementFact.FactId), "Commander should not reject Raven's authorized movement fact"); @@ -1065,7 +1072,8 @@ internal sealed class AuthoritySmokeChecks localRuntimeId: "pilot-local", daemonId: "pilot-local", sessionId: "authority-smoke", - verseId: policy.VerseId); + verseId: policy.VerseId, + worldPhysics: physics); Require(ravenImport.AcceptedFactIds.Contains(hostileRenameFact.FactId), "Raven should accept Commander's hostile metadata fact"); RequireEqual("Commander Marked Hostile", Entity(ravenImport.Run, hostileKey).Name, "Raven local run should converge Commander hostile metadata into local state"); @@ -1090,7 +1098,8 @@ internal sealed class AuthoritySmokeChecks localRuntimeId: "commander-local", daemonId: "commander-local", sessionId: "authority-smoke", - verseId: policy.VerseId); + verseId: policy.VerseId, + worldPhysics: physics); Require(rejectedImport.RejectedFactIds.Contains(unauthorizedFact.FactId), "Commander should reject Raven-authored hostile metadata fact"); RequireEqual("Commander Hostile", Entity(rejectedImport.Run, hostileKey).Name, "Rejected facts should not mutate local state"); @@ -1102,6 +1111,7 @@ internal sealed class AuthoritySmokeChecks AetheriaRuntimeVerseAuthorityPolicyDocument policy, IReadOnlyList commands) { + await SeedCanonicalCatalogAsync(statePath, runtimeId).ConfigureAwait(false); await using var node = await AetheriaStateNode.OpenAsync( statePath, runtimeId, @@ -1127,6 +1137,185 @@ internal sealed class AuthoritySmokeChecks await node.FlushAsync().ConfigureAwait(false); } + private static async Task SeedCanonicalCatalogAsync(string statePath, string runtimeId) + { + await using var node = await AetheriaStateNode.OpenAsync( + statePath, + runtimeId, + startServer: false, + enableDurableShardLogs: false).ConfigureAwait(false); + + const string manufacturerLegacyId = "authority-smoke-player"; + foreach (var corporationLegacyId in new[] + { + manufacturerLegacyId, + "authority-smoke-raider", + "authority-smoke-neutral" + }) + { + await node.MutableDocument( + AetheriaCatalogKeys.CorporationFromLegacyId(corporationLegacyId)) + .ReplaceAsync(new AetheriaCorporation + { + Name = corporationLegacyId, + LegacyId = corporationLegacyId, + ShortName = corporationLegacyId, + InfluenceDistance = 1, + AllegianceCount = 1, + Allegiances = + [ + new AetheriaCorporationAllegiance + { + CorporationLegacyId = manufacturerLegacyId, + Weight = 1 + } + ] + }).ConfigureAwait(false); + } + + foreach (var item in AuthoritySmokeLoadoutItems(manufacturerLegacyId)) + { + await node.MutableDocument( + AetheriaCatalogKeys.ItemDefinitionFromLegacyId(item.LegacyId)) + .ReplaceAsync(item).ConfigureAwait(false); + } + var baseEntityKey = AetheriaRuntimeRunCheckpointCommit.EntityRecordKey("local-terminus", 0, 0); + const string scenarioId = "starbridge.frontier-fabricator"; + await node.MutableDocument( + AetheriaRuntimeVerseRecordKeys.StarbridgeScenarioLatest) + .ReplaceAsync(new AetheriaRuntimeStarbridgeScenarioDocument + { + ScenarioId = scenarioId, + DisplayName = "Frontier Fabricator Defense", + StartingBaseKey = baseEntityKey, + StationStock = + [ + new AetheriaRuntimeStarbridgeStationStockItem + { + ItemKey = "repair-parts", + Quantity = 4, + Quality = 1, + Durability = 1 + } + ], + Waves = + [ + new AetheriaRuntimeStarbridgeWaveDefinition + { + WaveIndex = 0, + DisplayName = "Scout Probe", + AttackerKeys = ["scout"] + } + ], + RuntimeRoles = + [ + new AetheriaRuntimeStarbridgeRuntimeRole { RuntimeId = "commander-client", Role = "commander" }, + new AetheriaRuntimeStarbridgeRuntimeRole + { + RuntimeId = "pilot-client", + Role = "pilot", + EntityKey = AetheriaRuntimeRunCheckpointCommit.EntityRecordKey("local-terminus", 0, 1) + } + ] + }).ConfigureAwait(false); + await node.MutableDocument( + AetheriaRuntimeVerseRecordKeys.StarbridgeSessionLatest) + .ReplaceAsync(new AetheriaRuntimeStarbridgeSessionDocument + { + SessionId = "authority-smoke", + ScenarioId = scenarioId, + RunId = "local-terminus", + BaseEntityKey = baseEntityKey, + StationEntityKey = baseEntityKey, + Phase = "pre-wave" + }).ConfigureAwait(false); + await node.FlushAsync().ConfigureAwait(false); + + var catalog = await node.RuntimeCatalog().LatestAsync().ConfigureAwait(false); + Require(catalog.Corporations.Any(corporation => !string.IsNullOrWhiteSpace(corporation.CorporationKey)), + "daemon fixture must contain a typed corporation key"); + Require(catalog.Items.Any(item => item.HullType == "Ship") && + catalog.Items.Any(item => item.HullType == "Station"), + "daemon fixture must contain typed ship and station hulls"); + } + + private static IReadOnlyList AuthoritySmokeLoadoutItems(string manufacturerLegacyId) + { + static AetheriaShapeCell[] Rectangle(int width, int height) => + Enumerable.Range(0, height) + .SelectMany(y => Enumerable.Range(0, width).Select(x => new AetheriaShapeCell { X = x, Y = y })) + .ToArray(); + + static AetheriaBehaviorPayload Behavior(string kind) => new() + { + Kind = kind, + BehaviorId = "authority-smoke." + kind.ToLowerInvariant() + }; + + AetheriaItemDefinition Item( + string legacyId, + string category, + string hardpointType, + string behaviorKind = "") => new() + { + Name = legacyId, + LegacyId = legacyId, + Category = category, + ManufacturerLegacyId = manufacturerLegacyId, + Price = 10, + Mass = 1, + Volume = 1, + ShapeWidth = 1, + ShapeHeight = 1, + OccupiedCells = 1, + ShapeCells = Rectangle(1, 1), + HardpointType = hardpointType, + BehaviorKinds = string.IsNullOrWhiteSpace(behaviorKind) ? [] : [behaviorKind], + BehaviorCount = string.IsNullOrWhiteSpace(behaviorKind) ? 0 : 1, + BehaviorPayloads = string.IsNullOrWhiteSpace(behaviorKind) ? [] : [Behavior(behaviorKind)] + }; + + AetheriaItemDefinition Hull(string legacyId, string hullType) + { + var hull = Item(legacyId, AetheriaRuntimeItemCategories.Hull, "Hull"); + hull.HullType = hullType; + hull.ShapeWidth = 6; + hull.ShapeHeight = 6; + hull.OccupiedCells = 36; + hull.ShapeCells = Rectangle(6, 6); + hull.Hardpoints = + [ + new AetheriaItemHardpoint + { + Type = "ControlModule", + ShapeWidth = 1, + ShapeHeight = 1, + OccupiedCells = 1, + ShapeCells = Rectangle(1, 1) + } + ]; + return hull; + } + + var cargo = Item("authority-smoke-cargo", AetheriaRuntimeItemCategories.CargoBay, "Internal"); + cargo.InteriorShapeWidth = 3; + cargo.InteriorShapeHeight = 3; + cargo.InteriorOccupiedCells = 9; + cargo.InteriorShapeCells = Rectangle(3, 3); + + return + [ + Hull("authority-smoke-ship", "Ship"), + Hull("authority-smoke-station", "Station"), + Item("authority-smoke-cockpit", AetheriaRuntimeItemCategories.Gear, "ControlModule", "Cockpit"), + Item("authority-smoke-turret-controller", AetheriaRuntimeItemCategories.Gear, "ControlModule", "TurretController"), + cargo, + Item("authority-smoke-docking", AetheriaRuntimeItemCategories.DockingBay, "Internal"), + Item("authority-smoke-reactor", AetheriaRuntimeItemCategories.Gear, "Internal", "Reactor"), + Item("authority-smoke-capacitor", AetheriaRuntimeItemCategories.Gear, "Internal", "Capacitor") + ]; + } + private static async Task RunDaemonOnceAsync( string statePath, string runtimeId, @@ -1509,6 +1698,7 @@ internal sealed class AuthoritySmokeChecks localRuntimeId: daemonId, rejectedCommandIds: rejectedIds); + using var physics = new AetheriaYmirWorldPhysics(); var result = AetheriaRuntimeDaemonTickRunner.Tick( Path.Combine(Path.GetTempPath(), $"aetheria-authority-smoke-{daemonId}.cc"), run, @@ -1520,6 +1710,7 @@ internal sealed class AuthoritySmokeChecks FrameId = 1, SimulationTimeSeconds = 0.02, FixedDeltaSeconds = 0.02, + WorldPhysics = physics, ObservedCommands = authorizedCommands, PreRejectedCommandIds = rejectedIds, BuildPublications = false diff --git a/Aetheria.State.Daemon/Program.cs b/Aetheria.State.Daemon/Program.cs index dcd79ae8a..de38adf03 100644 --- a/Aetheria.State.Daemon/Program.cs +++ b/Aetheria.State.Daemon/Program.cs @@ -21,9 +21,8 @@ var traceClientRudp = string.Equals( StringComparison.Ordinal); Console.WriteLine($"Aetheria Verse daemon starting: {options.StatePath}"); -Console.WriteLine(options.EnableOdinAnnouncements - ? "Aetheria Verse daemon peers: Odin/CultMesh discovery" - : "Aetheria Verse daemon peers: local child-daemon transport"); +Console.WriteLine($"Aetheria Verse daemon direct peers: {options.PeerCultMeshEndpoints.Count} " + + $"[{string.Join(", ", options.PeerCultMeshEndpoints)}]"); if (options.EnableOdinAnnouncements) Console.WriteLine($"Aetheria Odin announcement target: {options.OdinCultMeshUri}"); @@ -317,6 +316,19 @@ static async Task TickAsync( policyRejectedCommandIds).ConfigureAwait(false); TracePhase("command-facts"); + if (options.PeerCultMeshEndpoints.Count > 0) + { + result = await ImportRemoteCommittedFactsAsync( + node, + options, + worldPhysics, + result.Frame, + result, + authorityPolicy, + authorityLeases).ConfigureAwait(false); + TracePhase("peer-facts"); + } + if (buildPublications) { await PublishDaemonApiDocumentsAsync(node, options, soaPublisher, result, publishTopology: true).ConfigureAwait(false); @@ -505,6 +517,98 @@ static async Task PublishCommittedFactAsync( Console.WriteLine($"Eve command receipt command={receipt.CommandId} state={receipt.State} provider={receipt.ProviderId}"); } +static async Task ImportRemoteCommittedFactsAsync( + AetheriaStateNode node, + AetheriaDaemonHostOptions options, + IAetheriaRuntimeWorldPhysics worldPhysics, + AetheriaRuntimeDaemonFrameDocument frame, + AetheriaRuntimeDaemonTickResult currentResult, + AetheriaRuntimeVerseAuthorityPolicyDocument? authorityPolicy, + IReadOnlyList authorityLeases) +{ + var remoteFacts = new List(); + foreach (var endpoint in options.PeerCultMeshEndpoints) + { + try + { + var endpointFacts = await AetheriaVerseReplica + .FetchScopedDocumentsAsync( + endpoint, + schemaIds: [AetheriaRuntimeDaemonSchemas.CommittedCommandFact], + connectTimeout: options.PeerSyncTimeout, + responseTimeout: options.PeerSyncTimeout).ConfigureAwait(false); + remoteFacts.AddRange(endpointFacts); + } + catch (Exception ex) when ( + ex is IOException || + ex is SocketException || + ex is TimeoutException || + ex is InvalidOperationException) + { + Console.WriteLine($"Aetheria direct peer fact sync skipped for {endpoint}: {ex.GetType().Name}: {ex.Message}"); + } + } + + var facts = remoteFacts + .Where(fact => fact != null) + .Where(fact => string.Equals(fact.VerseId, options.VerseId, StringComparison.Ordinal)) + .Where(fact => !string.Equals(fact.SourceDaemonId, options.DaemonId, StringComparison.Ordinal)) + .GroupBy(fact => fact.FactId ?? "", StringComparer.Ordinal) + .Where(group => !string.IsNullOrWhiteSpace(group.Key)) + .Select(group => group.First()) + .ToArray(); + if (facts.Length == 0) + return currentResult; + + var importedFactIds = (frame.CumulativeImportedFactIds ?? Array.Empty()) + .Concat(frame.CumulativeRejectedImportedFactIds ?? Array.Empty()) + .Distinct(StringComparer.Ordinal) + .ToArray(); + var import = AetheriaRuntimeCommittedFactImporter.ImportIntoFrame( + node.StatePath, + frame, + facts, + authorityPolicy, + authorityLeases, + options.DaemonId, + options.DaemonId, + frame.SessionId, + options.VerseId, + worldPhysics, + importedFactIds, + node.RuntimeCatalog().Latest()); + + var importedFrame = import.Frame; + importedFrame.ImportedFactIds = import.AcceptedFactIds; + importedFrame.RejectedImportedFactIds = import.RejectedFactIds; + importedFrame.DuplicateImportedFactIds = import.DuplicateFactIds; + importedFrame.CumulativeImportedFactIds = (frame.CumulativeImportedFactIds ?? Array.Empty()) + .Concat(import.AcceptedFactIds) + .Distinct(StringComparer.Ordinal) + .ToArray(); + importedFrame.CumulativeRejectedImportedFactIds = (frame.CumulativeRejectedImportedFactIds ?? Array.Empty()) + .Concat(import.RejectedFactIds) + .Distinct(StringComparer.Ordinal) + .ToArray(); + importedFrame.CumulativeAppliedCommandIds = (frame.CumulativeAppliedCommandIds ?? Array.Empty()) + .Concat(importedFrame.CumulativeAppliedCommandIds ?? Array.Empty()) + .Distinct(StringComparer.Ordinal) + .ToArray(); + importedFrame.CumulativeRejectedCommandIds = (frame.CumulativeRejectedCommandIds ?? Array.Empty()) + .Concat(importedFrame.CumulativeRejectedCommandIds ?? Array.Empty()) + .Distinct(StringComparer.Ordinal) + .ToArray(); + + if (import.AcceptedFactIds.Count > 0 || import.RejectedFactIds.Count > 0) + { + Console.WriteLine( + $"Aetheria imported direct peer facts: accepted={import.AcceptedFactIds.Count}, " + + $"rejected={import.RejectedFactIds.Count}, duplicates={import.DuplicateFactIds.Count}."); + } + + return import.Tick; +} + static RudpCultNetSchemaServer StartClientCultMeshHost( AetheriaStateNode node, AetheriaDaemonHostOptions options, @@ -2960,8 +3064,10 @@ internal sealed class AetheriaDaemonHostOptions public int ClientCultMeshPort { get; init; } = 3076; public string AetheriaResourcesRoot { get; init; } = ""; public string AssetBundleRoot { get; init; } = ""; - public string OdinCultMeshUri { get; init; } = "cultmesh://odin/rendezvous/provider-catalog"; - public bool EnableOdinAnnouncements { get; init; } = true; + public IReadOnlyList PeerCultMeshEndpoints { get; init; } = Array.Empty(); + public TimeSpan PeerSyncTimeout { get; init; } = TimeSpan.FromMilliseconds(250); + public string OdinCultMeshUri { get; init; } = ""; + public bool EnableOdinAnnouncements { get; init; } public TimeSpan TickInterval { get; init; } = TimeSpan.FromMilliseconds(20); public TimeSpan ApiPublicationInterval { get; init; } = TimeSpan.FromSeconds(1); public double FixedDeltaSeconds { get; init; } = 0.02; @@ -2989,12 +3095,12 @@ internal sealed class AetheriaDaemonHostOptions var aetheriaResourcesRoot = ReadOption(args, "--aetheria-resources-root"); var assetBundleRoot = ReadOption(args, "--asset-bundle-root"); RejectRemovedOption(args, "--rts-cultmesh-port", "--client-cultmesh-port"); - RejectRemovedOption(args, "--peer-cultmesh-endpoint", "Odin-discovered CultMesh peer documents"); + var peerCultMeshEndpoints = ReadOptions(args, "--peer-cultmesh-endpoint"); + var peerSyncTimeoutMs = ReadPositiveInt(args, "--peer-sync-timeout-ms") ?? 250; RejectRemovedOption(args, "--odin-cultmesh-rudp", "--odin-cultmesh-uri"); RejectRemovedOption(args, "--odin-cultnet-rudp", "--odin-cultmesh-uri"); var odinCultMeshUri = ReadOption(args, "--odin-cultmesh-uri"); var noOdinAnnouncements = HasFlag(args, "--no-odin-announcements"); - RejectRemovedOption(args, "--peer-sync-timeout-ms", "Odin-discovered CultMesh peer documents"); var apiPublicationIntervalMs = ReadPositiveInt(args, "--api-publication-interval-ms") ?? 1000; var sessionId = ReadOption(args, "--session-id"); @@ -3020,12 +3126,10 @@ internal sealed class AetheriaDaemonHostOptions AssetBundleRoot = string.IsNullOrWhiteSpace(assetBundleRoot) ? Path.GetFullPath(Path.Combine(root, "Build", "EveAssets")) : Path.GetFullPath(assetBundleRoot), - OdinCultMeshUri = noOdinAnnouncements - ? "" - : string.IsNullOrWhiteSpace(odinCultMeshUri) - ? "cultmesh://odin/rendezvous/provider-catalog" - : odinCultMeshUri, - EnableOdinAnnouncements = !noOdinAnnouncements, + PeerCultMeshEndpoints = peerCultMeshEndpoints, + PeerSyncTimeout = TimeSpan.FromMilliseconds(peerSyncTimeoutMs), + OdinCultMeshUri = noOdinAnnouncements ? "" : odinCultMeshUri, + EnableOdinAnnouncements = !noOdinAnnouncements && !string.IsNullOrWhiteSpace(odinCultMeshUri), TickInterval = TimeSpan.FromMilliseconds(intervalMs), ApiPublicationInterval = TimeSpan.FromMilliseconds(apiPublicationIntervalMs), FixedDeltaSeconds = fixedDeltaMs / 1000.0, diff --git a/Aetheria.State.Verify/Program.cs b/Aetheria.State.Verify/Program.cs index 8323f6651..d65206b86 100644 --- a/Aetheria.State.Verify/Program.cs +++ b/Aetheria.State.Verify/Program.cs @@ -794,7 +794,7 @@ static void RequireSharedEvePackagesImportedFromEveRepo(string root) "\"org.gamecult.cultlib\": \"https://github.com/GameCult/CultLib.git?path=/unity/org.gamecult.cultlib#cultlib-unity-v1.0.14\"", "\"org.gamecult.eve.plugin-fields\": \"https://github.com/GameCult/EvePlugins.git?path=/plugins/eve-plugin-fields/unity/org.gamecult.eve.plugin-fields#eve-plugin-fields-unity-v0.2.3\"", "\"org.gamecult.eve.surface\": \"https://github.com/GameCult/EveUnity.git?path=/packages/org.gamecult.eve.surface#eveunity-surface-v0.2.2\"", - "\"org.gamecult.eve.unity-scene\": \"https://github.com/GameCult/EveUnity.git?path=/packages/org.gamecult.eve.unity-scene#eveunity-scene-v0.3.51\"" + "\"org.gamecult.eve.unity-scene\": \"https://github.com/GameCult/EveUnity.git?path=/packages/org.gamecult.eve.unity-scene#eveunity-scene-v0.3.52\"" }; var missingManifestSymbols = requiredManifestSymbols @@ -813,7 +813,7 @@ static void RequireSharedEvePackagesImportedFromEveRepo(string root) "cultlib-unity-v1.0.14", "eve-plugin-fields-unity-v0.2.3", "eveunity-surface-v0.2.2", - "eveunity-scene-v0.3.51", + "eveunity-scene-v0.3.52", "\"source\": \"git\"" }; diff --git a/Packages/org.gamecult.aetheria.state/Runtime/AetheriaRuntimeCatalogSnapshot.cs b/Packages/org.gamecult.aetheria.state/Runtime/AetheriaRuntimeCatalogSnapshot.cs index f31588aca..6601b0ae6 100644 --- a/Packages/org.gamecult.aetheria.state/Runtime/AetheriaRuntimeCatalogSnapshot.cs +++ b/Packages/org.gamecult.aetheria.state/Runtime/AetheriaRuntimeCatalogSnapshot.cs @@ -9,6 +9,7 @@ using MessagePack; namespace GameCult.Aetheria.State.Verse { [CultDocument("gamecult.aetheria.runtime_catalog", "gamecult.aetheria.runtime_catalog.v1")] + [MessagePackObject] public sealed class AetheriaRuntimeCatalogSnapshot { public const string SchemaId = "gamecult.aetheria.runtime_catalog.v1"; @@ -110,6 +111,7 @@ namespace GameCult.Aetheria.State.Verse } [CultDocument("gamecult.aetheria.loadout_templates", "gamecult.aetheria.loadout_templates.v1")] + [MessagePackObject] public sealed class AetheriaRuntimeLoadoutTemplatesDocument { public const string SchemaId = "gamecult.aetheria.loadout_templates.v1"; diff --git a/Packages/org.gamecult.aetheria.state/Runtime/AetheriaRuntimeCommittedFactImporter.cs b/Packages/org.gamecult.aetheria.state/Runtime/AetheriaRuntimeCommittedFactImporter.cs index 89bdf291f..a1ccb6cb0 100644 --- a/Packages/org.gamecult.aetheria.state/Runtime/AetheriaRuntimeCommittedFactImporter.cs +++ b/Packages/org.gamecult.aetheria.state/Runtime/AetheriaRuntimeCommittedFactImporter.cs @@ -40,9 +40,13 @@ namespace GameCult.Aetheria.State.Verse string daemonId, string sessionId, string verseId, + IAetheriaRuntimeWorldPhysics worldPhysics, IEnumerable? importedFactIds = null, AetheriaRuntimeCatalogSnapshot? catalog = null) { + if (worldPhysics == null) + throw new ArgumentNullException(nameof(worldPhysics)); + currentFrame ??= new AetheriaRuntimeDaemonFrameDocument { Run = new AetheriaRuntimeRunCheckpointCommit(), @@ -113,6 +117,7 @@ namespace GameCult.Aetheria.State.Verse CumulativeAppliedCommandIds = currentFrame.CumulativeAppliedCommandIds, CumulativeRejectedCommandIds = currentFrame.CumulativeRejectedCommandIds, Catalog = catalog ?? EmptyCatalog(), + WorldPhysics = worldPhysics, BuildPublications = false }); diff --git a/Packages/org.gamecult.aetheria.state/Runtime/AetheriaRuntimeDaemonGameSurfaceBuilder.cs b/Packages/org.gamecult.aetheria.state/Runtime/AetheriaRuntimeDaemonGameSurfaceBuilder.cs index 6d1f04a87..32274dc97 100644 --- a/Packages/org.gamecult.aetheria.state/Runtime/AetheriaRuntimeDaemonGameSurfaceBuilder.cs +++ b/Packages/org.gamecult.aetheria.state/Runtime/AetheriaRuntimeDaemonGameSurfaceBuilder.cs @@ -146,6 +146,7 @@ namespace GameCult.Aetheria.State.Verse BuildAgentRoster(run), BuildAgentTaskBoard(run), BuildSurveyKnowledge(run), + BuildStarbridgeSessionCard(starbridge), BuildStarbridgeStationStockCard(starbridge), BuildStarbridgeWaveForecastCard(starbridge), BuildStarbridgeRuntimeRolesCard(starbridge)); @@ -174,6 +175,29 @@ namespace GameCult.Aetheria.State.Verse .ToArray()); } + private static AetheriaRuntimeSurfaceComponent BuildStarbridgeSessionCard( + AetheriaRuntimeStarbridgeSessionSummaryDocument starbridge) + { + starbridge ??= new AetheriaRuntimeStarbridgeSessionSummaryDocument(); + return Node( + "aetheria.starbridge.commander.session", + "card", + new[] { ("title", "Starbridge Session") }, + Metric("aetheria.starbridge.commander.session.scenario", "Scenario", starbridge.ScenarioName), + Metric("aetheria.starbridge.commander.session.id", "Session", starbridge.SessionId), + Metric("aetheria.starbridge.commander.session.phase", "Phase", starbridge.Phase), + Metric("aetheria.starbridge.commander.session.wave", "Wave", + starbridge.CurrentWaveIndex.ToString(CultureInfo.InvariantCulture)), + Metric("aetheria.starbridge.commander.session.zone", "Zone", starbridge.ZoneName), + Metric("aetheria.starbridge.commander.session.base", "Base", starbridge.BaseStatus?.DisplayName ?? ""), + Metric("aetheria.starbridge.commander.session.base_hull", "Base Hull", + FormatNumber(starbridge.BaseStatus?.Hull ?? 0)), + Metric("aetheria.starbridge.commander.session.base_shield", "Base Shield", + FormatNumber(starbridge.BaseStatus?.Shield ?? 0)), + Metric("aetheria.starbridge.commander.session.base_heat", "Base Heat", + FormatNumber(starbridge.BaseStatus?.Heat ?? 0))); + } + private static AetheriaRuntimeSurfaceComponent BuildAgentTaskBoard(AetheriaRuntimeRunCheckpointCommit run) { var tasks = (run.AgentTasks ?? Array.Empty()) diff --git a/docs/aetheria-current-codebase-model.md b/docs/aetheria-current-codebase-model.md index 7162fac76..d7c62ee5a 100644 --- a/docs/aetheria-current-codebase-model.md +++ b/docs/aetheria-current-codebase-model.md @@ -297,10 +297,12 @@ The current UI direction is Eve/CultUI: - Brokkr should be considered just another daemon publishing Unity editor Eve surfaces, not a special Codex socket. -The architectural note in `Aetheria.State/docs/verse-daemon-shape.md` is still -the right boundary: Odin discovers/indexes providers, Bifrost hosts MCP tools -for xeno agents, Eve/CultUI defines presentation, and the daemon owns side -effects. +The architectural note in `Aetheria.State/docs/verse-daemon-shape.md` still +describes optional ecosystem indexing, but it is not the Aetheria session path. +Aetheria clients connect directly to the daemon's advertised CultMesh endpoint; +directly configured daemon peers exchange typed committed facts there as well. +Odin may index the provider only when explicitly enabled. Eve/CultUI defines +presentation, and the daemon owns side effects. Remaining UI debt is not mostly visual. It is resolution semantics: if an Eve surface contains a typed pointer to daemon state, the runtime should resolve it diff --git a/docs/aetheria-perfect-machine-map.md b/docs/aetheria-perfect-machine-map.md index 28e006660..cbd7f00dd 100644 --- a/docs/aetheria-perfect-machine-map.md +++ b/docs/aetheria-perfect-machine-map.md @@ -22,9 +22,11 @@ legacy catalog cache, and legacy UI paths should be migration-only or deleted. `AetheriaVerseDiscoveryHost`, accepts typed Eve command documents, advances authoritative daemon frames through `AetheriaRuntimeDaemonTickRunner`, and publishes provider advertisements, daemon health, command boundaries, and - Eve GUI/TUI witness surfaces. This is the Odin/VoidBot-shaped daemon - contract: the daemon owns the provider state and surfaces; Unity, Codex MCP - tools, and future clients lower or command that provider through CultMesh + Eve GUI/TUI witness surfaces. Aetheria clients connect directly to the + daemon's advertised CultMesh endpoint. Optional external indexes may ingest + the provider advertisement, but they are not on the client, command, state, + or cooperating-daemon path. The daemon owns provider state and surfaces; + Unity and future clients lower or command that provider through CultMesh rather than becoming state owners. - Unity client/runtime lives under `Assets/`. Gameplay now opens the typed runtime catalog from `GameData/aetheria-world.cc` and projects current @@ -778,6 +780,31 @@ legacy catalog cache, and legacy UI paths should be migration-only or deleted. ## Current Authority Map +### Direct CultMesh Session And Peer Transport + +- Owner: each Aetheria daemon owns its advertised client CultMesh endpoint and + its explicitly configured direct daemon-peer endpoints. +- Inputs: typed client sessions, commands, snapshot requests, committed facts, + and optional `--peer-cultmesh-endpoint` routes. Odin publication is disabled + unless an operator explicitly supplies `--odin-cultmesh-uri`. +- Outputs: typed state/surface snapshots, receipts, provider-owned assets, and + policy-filtered committed-fact convergence between directly connected + daemons. +- Derived state: discovery catalogs and external provider indexes may mirror + advertisements, but they do not grant authority or mediate an Aetheria + session. +- Forbidden writers: Odin, Eve lowerers, Unity, and remote peers cannot apply a + fact directly. Imported facts pass the daemon authority policy and execute + through the daemon's required Ymir world-physics owner. +- Shared paths: local commands and accepted remote facts enter the same daemon + command transaction and receipt chronology. +- Cut line: the rejection that forced `--peer-cultmesh-endpoint` through Odin + is deleted. Direct CultMesh is the Aetheria path; Odin is optional external + indexing only. +- Verification layer: `Aetheria.State.AuthoritySmoke` boots real child daemons, + connects replicas directly, proves accepted/rejected policy outcomes, and + proves committed-fact convergence with production Ymir physics injected. + ### Daemon Damage Transaction - Owner: the daemon's canonical damage transaction owns damage-layer ordering