diff --git a/Aetheria.State.Daemon.Smoke/Program.cs b/Aetheria.State.Daemon.Smoke/Program.cs index 202cf096b..a8a79b690 100644 --- a/Aetheria.State.Daemon.Smoke/Program.cs +++ b/Aetheria.State.Daemon.Smoke/Program.cs @@ -49,6 +49,11 @@ else if (args.Contains("--tutorial-materialization", StringComparer.Ordinal)) checks.RunTutorialMaterialization(); Console.WriteLine("Daemon tutorial entity-materialization smoke passed."); } +else if (args.Contains("--tutorial-run", StringComparer.Ordinal)) +{ + checks.RunTutorialRun(); + Console.WriteLine("Daemon persisted tutorial-run smoke passed."); +} else { checks.Run(); @@ -86,6 +91,47 @@ internal sealed class AetheriaDaemonYmirSmokeChecks public void RunZoneBodies() => RunCheck(GeneratedZoneBodiesPreserveFossilHierarchy); public void RunTutorialWorld() => RunCheck(TutorialWorldMaterializesEveryTopologyZone); public void RunTutorialMaterialization() => RunCheck(TutorialPopulationPreservesFossilEntityMechanics); + public void RunTutorialRun() => RunCheck(TutorialRunPersistsCanonicalWorldTruth); + + private static void TutorialRunPersistsCanonicalWorldTruth() + { + var catalog = TutorialPopulationCatalog(out _); + var root = Path.Combine(Path.GetTempPath(), $"aetheria-tutorial-run-{Guid.NewGuid():N}"); + var statePath = Path.Combine(root, "aetheria.cc"); + Directory.CreateDirectory(root); + try + { + using var node = AetheriaStateNode.OpenAsync(statePath).GetAwaiter().GetResult(); + var written = AetheriaDaemonTutorialRunWriter.WriteAsync( + node, catalog, "2026-07-17T00:00:00.0000000Z").GetAwaiter().GetResult(); + var run = node.MutableDocument(new CultRecordKey(written.RunKey)) + .ReadAsync().GetAwaiter().GetResult(); + var settings = node.MutableDocument(AetheriaStateNode.PlayerSettingsKey) + .ReadAsync().GetAwaiter().GetResult(); + Require(run != null && run.IsTutorial && run.ZoneKeys.Length == 64 && + run.EntranceZoneIndex == run.CurrentZoneIndex && run.ExitZoneIndex == -1, + "persisted New Game truth must be the complete authored tutorial graph, not the Terminus witness fixture"); + Require(settings != null && settings.ActiveRunKey == written.RunKey && !settings.TutorialPassed, + "tutorial persistence must select the new run without falsely awarding completion"); + Require(run!.CurrentEntityKey == written.CurrentEntityKey, + "the run and session handoff must share one canonical controlled-entity identity"); + var entrance = node.MutableDocument( + new CultRecordKey(run.ZoneKeys[run.EntranceZoneIndex])) + .ReadAsync().GetAwaiter().GetResult(); + Require(entrance != null && entrance.AdjacentZoneIndices.Length > 0 && + entrance.EntityKeys.Contains(run.CurrentEntityKey, StringComparer.Ordinal) && + entrance.Bodies.Length > 0 && entrance.Orbits.Length >= entrance.Bodies.Length, + "the persisted entrance must contain the starter ship, celestial hierarchy, and derived wormhole adjacency"); + var player = node.MutableDocument(new CultRecordKey(run.CurrentEntityKey)) + .ReadAsync().GetAwaiter().GetResult(); + Require(player != null && player.Kind == "ship" && player.LoadoutGeneration != null, + "the persisted current entity must be a playable daemon-generated ship with loadout provenance"); + } + finally + { + if (Directory.Exists(root)) Directory.Delete(root, recursive: true); + } + } private static void TutorialPopulationPreservesFossilEntityMechanics() { @@ -135,7 +181,10 @@ internal sealed class AetheriaDaemonYmirSmokeChecks var one = new[] { new AetheriaRuntimeShapeCell(0, 0) }; var hullCells = Enumerable.Range(0, 6).SelectMany(y => Enumerable.Range(0, 6) .Select(x => new AetheriaRuntimeShapeCell(x, y))).ToArray(); - var manufacturer = "faction.miss"; + // The recovered tutorial catalog includes allied manufacturers which do + // not own one of the six prelude home zones. Prelude availability must + // retain those authored items without inventing another faction home. + var manufacturer = "manufacturer.common"; AetheriaRuntimeCatalogItem Item(string key, string category, string hardpointType = "", params string[] behaviors) { @@ -184,18 +233,25 @@ internal sealed class AetheriaDaemonYmirSmokeChecks var reactor = Item("tutorial-reactor", AetheriaRuntimeItemCategories.Gear, "Internal", "Reactor"); var capacitor = Item("tutorial-capacitor", AetheriaRuntimeItemCategories.Gear, "Internal", "Capacitor"); var names = new[] { "Miss", "Zhe", "Luc", "Aero", "Finch", "Adras" }; - var corporations = names.Select(name => new AetheriaRuntimeCorporation( + var tutorialCorporations = names.Select(name => new AetheriaRuntimeCorporation( $"faction.{name.ToLowerInvariant()}", name, name, "", $"names.{name}", "", 4, 1, [new AetheriaRuntimeCorporationAllegiance(manufacturer, 1)])).ToArray(); + var corporations = tutorialCorporations.Append(new AetheriaRuntimeCorporation( + manufacturer, "Common Manufacturer", "Common", "", "", "", 0, 0, + Array.Empty())).ToArray(); factions = names.Select((name, index) => new AetheriaDaemonTutorialFactionInput( - corporations[index].CorporationKey, name, name, 4) + tutorialCorporations[index].CorporationKey, name, name, 4) { TrainingNames = Enumerable.Range(0, 128).Select(value => $"{name}{value:D3}").ToArray() }).ToArray(); + var nameFiles = names.Select(name => new AetheriaRuntimeNameFile( + $"names.{name}", name, 128, + Enumerable.Range(0, 8).Select(value => $"{name}{value:D3}").ToArray(), + Enumerable.Range(0, 128).Select(value => $"{name}{value:D3}").ToArray())).ToArray(); return new AetheriaRuntimeCatalogSnapshot( [shipHull, stationHull, cockpit, turret, weapon, cargo, docking, reactor, capacitor], corporations, - []); + nameFiles); } private static void TutorialWorldMaterializesEveryTopologyZone() @@ -268,21 +324,25 @@ internal sealed class AetheriaDaemonYmirSmokeChecks private static void TutorialTopologyIsDeterministicConnectedAndRoleOwned() { - AetheriaDaemonTutorialFactionInput Faction(string shortName, int influence = 2) => - new($"faction.{shortName.ToLowerInvariant()}", shortName, shortName, influence) + AetheriaDaemonTutorialFactionInput Faction( + string selector, + string name, + string shortName, + int influence = 2) => + new($"faction.{selector.ToLowerInvariant()}", name, shortName, influence) { TrainingNames = Enumerable.Range(0, 512).Select(index => - $"{(char)('a' + index % 26)}{(char)('a' + index / 26 % 26)}{(char)('a' + index / 676 % 26)}{shortName.ToLowerInvariant()}") + $"{(char)('a' + index % 26)}{(char)('a' + index / 26 % 26)}{(char)('a' + index / 676 % 26)}{selector.ToLowerInvariant()}") .ToArray() }; var factions = new[] { - Faction("Miss"), - Faction("Zhe"), - Faction("Luc"), - Faction("Aero"), - Faction("Finch"), - Faction("Adras") + Faction("Miss", "Miss Terri's Sugariffic Snack Company", "Miss Terri's"), + Faction("Zhe", "Zhestokost", "Zhestokost"), + Faction("Luc", "Lucent Media", "Lucent"), + Faction("Aero", "Aeronautics Unlimited", "AU"), + Faction("Finch", "Finch Cybernetics", "Finch"), + Faction("Adras", "Adrasteia", "Adrasteia") }; var first = AetheriaDaemonTutorialTopologyGenerator.GenerateFossil(factions, 0xA37E_2026u); var second = AetheriaDaemonTutorialTopologyGenerator.GenerateFossil(factions, 0xA37E_2026u); diff --git a/Aetheria.State.Daemon/AetheriaDaemonLoadoutGenerator.cs b/Aetheria.State.Daemon/AetheriaDaemonLoadoutGenerator.cs index 9943d652a..f2397265d 100644 --- a/Aetheria.State.Daemon/AetheriaDaemonLoadoutGenerator.cs +++ b/Aetheria.State.Daemon/AetheriaDaemonLoadoutGenerator.cs @@ -12,6 +12,7 @@ public sealed class AetheriaDaemonLoadoutGenerator private readonly IReadOnlyDictionary _homeZones; private readonly IReadOnlyDictionary> _adjacency; private readonly double _priceExponent; + private readonly bool _isPrelude; public AetheriaDaemonLoadoutGenerator( AetheriaRuntimeCatalogSnapshot catalog, @@ -19,7 +20,8 @@ public sealed class AetheriaDaemonLoadoutGenerator int zoneIndex, IReadOnlyDictionary homeZones, IReadOnlyDictionary> adjacency, - double priceExponent = 0.5) + double priceExponent = 0.5, + bool isPrelude = false) { _catalog = catalog ?? throw new ArgumentNullException(nameof(catalog)); _seed = seed == 0 ? 1u : seed; @@ -28,6 +30,7 @@ public sealed class AetheriaDaemonLoadoutGenerator _homeZones = homeZones ?? throw new ArgumentNullException(nameof(homeZones)); _adjacency = adjacency ?? throw new ArgumentNullException(nameof(adjacency)); _priceExponent = priceExponent; + _isPrelude = isPrelude; } public AetheriaDaemonLoadout Build( @@ -283,8 +286,10 @@ public sealed class AetheriaDaemonLoadoutGenerator .ToDictionary(value => value.CorporationKey, value => value.Weight, StringComparer.Ordinal); foreach (var item in _catalog.EquipmentItems) { - if (item.Price <= 0 || string.IsNullOrWhiteSpace(item.ManufacturerKey) || - !_homeZones.ContainsKey(item.ManufacturerKey) || !allegiances.ContainsKey(item.ManufacturerKey)) + if (item.Price <= 0 || string.IsNullOrWhiteSpace(item.ManufacturerKey)) + continue; + if (!_isPrelude && + (!_homeZones.ContainsKey(item.ManufacturerKey) || !allegiances.ContainsKey(item.ManufacturerKey))) continue; yield return item; } @@ -293,10 +298,20 @@ public sealed class AetheriaDaemonLoadoutGenerator private double Weight(AetheriaRuntimeCatalogItem item, string factionKey, double sizeExponent) { var faction = _catalog.Corporations.First(value => value.CorporationKey == factionKey); - var allegiance = string.Equals(item.ManufacturerKey, factionKey, StringComparison.Ordinal) - ? 1 - : faction.Allegiances.First(value => value.CorporationKey == item.ManufacturerKey).Weight / - Math.Max(1, Distance(_zoneIndex, _homeZones[item.ManufacturerKey])); + double allegiance; + if (string.Equals(item.ManufacturerKey, factionKey, StringComparison.Ordinal)) + { + allegiance = 1; + } + else + { + var authoredWeight = (faction.Allegiances ?? Array.Empty()) + .FirstOrDefault(value => value.CorporationKey == item.ManufacturerKey)?.Weight ?? 0; + var distance = _homeZones.TryGetValue(item.ManufacturerKey, out var home) + ? Distance(_zoneIndex, home) + : 1; + allegiance = authoredWeight / Math.Max(1, distance); + } return allegiance * Math.Pow(Math.Max(1, item.OccupiedCells), sizeExponent) / Math.Pow(item.Price, _priceExponent) * RarityWeight(item); } diff --git a/Aetheria.State.Daemon/AetheriaDaemonTutorialRunWriter.cs b/Aetheria.State.Daemon/AetheriaDaemonTutorialRunWriter.cs new file mode 100644 index 000000000..8ca1c0dbc --- /dev/null +++ b/Aetheria.State.Daemon/AetheriaDaemonTutorialRunWriter.cs @@ -0,0 +1,110 @@ +using Aetheria.State; +using Aetheria.State.Documents; +using GameCult.Aetheria.State.Verse; +using GameCult.Caching; + +public sealed record AetheriaDaemonWrittenRun( + string RunId, + string RunKey, + string CurrentEntityKey, + bool IsTutorial); + +public static class AetheriaDaemonTutorialRunWriter +{ + public const string RunId = "tutorial"; + public const uint GenerationSeed = 0xA37E_2026u; + + public static async Task WriteAsync( + AetheriaStateNode node, + AetheriaRuntimeCatalogSnapshot catalog, + string now) + { + var factions = AetheriaDaemonTutorialTopologyGenerator.ResolveFossilFactions(catalog); + var world = AetheriaDaemonTutorialWorldGenerator.Generate(factions, GenerationSeed); + var materialized = AetheriaDaemonTutorialWorldMaterializer.Materialize(world, factions, catalog); + var runKey = RunKey(); + var zoneKeys = materialized.Topology.Zones + .OrderBy(zone => zone.ZoneIndex) + .Select(zone => ZoneKey(zone.ZoneIndex)) + .ToArray(); + var corporationIndices = (catalog.Corporations ?? Array.Empty()) + .Select((corporation, index) => (corporation.CorporationKey, index)) + .Where(value => !string.IsNullOrWhiteSpace(value.CorporationKey)) + .ToDictionary(value => value.CorporationKey, value => value.index, StringComparer.Ordinal); + var playerEntityKey = EntityKey(materialized.PlayerZoneIndex, materialized.PlayerEntityIndex); + + foreach (var zone in materialized.Zones.Values.OrderBy(zone => zone.Topology.ZoneIndex)) + { + var entityKeys = Enumerable.Range(0, zone.Entities.Length) + .Select(index => EntityKey(zone.Topology.ZoneIndex, index)) + .ToArray(); + await node.MutableDocument(new CultRecordKey(ZoneKey(zone.Topology.ZoneIndex))) + .ReplaceAsync(new AetheriaZoneState + { + Name = zone.Topology.Name, + Position = new AetheriaVector2 { X = zone.Topology.X, Y = zone.Topology.Y }, + AdjacentZoneIndices = zone.Topology.AdjacentZoneIndices.ToArray(), + FactionIndices = zone.Topology.FactionKeys + .Select(key => corporationIndices[key]) + .ToArray(), + OwnerFactionIndex = string.IsNullOrWhiteSpace(zone.Topology.OwnerFactionKey) + ? -1 + : corporationIndices[zone.Topology.OwnerFactionKey], + EntityKeys = entityKeys, + Orbits = zone.Orbits, + Bodies = zone.CelestialPlan.Bodies, + GravityTerrainRadius = zone.CelestialPlan.Radius, + GravityTerrainDepth = zone.CelestialPlan.GravityTerrainDepth, + GravityTerrainDepthExponent = zone.CelestialPlan.GravityTerrainDepthExponent, + GravityTerrainBoundaryFog = zone.CelestialPlan.GravityTerrainBoundaryFog, + GravityTerrainWaveFrequency = 1, + DroppedPickups = [], + NextPickupIndex = 0 + }).ConfigureAwait(false); + for (var entityIndex = 0; entityIndex < zone.Entities.Length; entityIndex++) + { + await node.MutableDocument(new CultRecordKey(entityKeys[entityIndex])) + .ReplaceAsync(zone.Entities[entityIndex]) + .ConfigureAwait(false); + } + } + + await node.MutableDocument(new CultRecordKey(runKey)).ReplaceAsync(new AetheriaRunState + { + RunId = RunId, + IsTutorial = true, + EntranceZoneIndex = materialized.Topology.EntranceZoneIndex, + ExitZoneIndex = -1, + CurrentZoneIndex = materialized.PlayerZoneIndex, + DiscoveredZoneIndices = materialized.Topology.DiscoveredZoneIndices.ToArray(), + ZoneKeys = zoneKeys, + FactionRelationships = factions.Select(faction => new AetheriaFactionRelationshipState + { + FactionKey = faction.CorporationKey, + Relationship = "Neutral", + Standing = 0 + }).ToArray(), + GenerationSeed = GenerationSeed, + CurrentEntityKey = playerEntityKey, + LifecyclePhase = AetheriaRuntimeRunLifecycle.Active, + TerminalFrameId = -1, + UpdatedAtUtc = now + }).ConfigureAwait(false); + + var settings = await node.MutableDocument(AetheriaStateNode.PlayerSettingsKey) + .ReadAsync().ConfigureAwait(false) ?? new AetheriaPlayerSettings(); + settings.ActiveRunKey = runKey; + settings.PlayerName = string.IsNullOrWhiteSpace(settings.PlayerName) ? "Pilot" : settings.PlayerName; + settings.LastUpdatedAtUtc = now; + await node.MutableDocument(AetheriaStateNode.PlayerSettingsKey) + .ReplaceAsync(settings) + .ConfigureAwait(false); + await node.FlushAsync().ConfigureAwait(false); + return new AetheriaDaemonWrittenRun(RunId, runKey, playerEntityKey, true); + } + + public static string RunKey() => $"global:aetheria.run_state.{RunId}.v1"; + public static string ZoneKey(int zoneIndex) => $"global:aetheria.zone_state.{RunId}.{zoneIndex}.v1"; + public static string EntityKey(int zoneIndex, int entityIndex) => + $"global:aetheria.run_state.{RunId}.zone.{zoneIndex}.entity.{entityIndex}.v1"; +} diff --git a/Aetheria.State.Daemon/AetheriaDaemonTutorialTopologyGenerator.cs b/Aetheria.State.Daemon/AetheriaDaemonTutorialTopologyGenerator.cs index 809685142..22d369aa4 100644 --- a/Aetheria.State.Daemon/AetheriaDaemonTutorialTopologyGenerator.cs +++ b/Aetheria.State.Daemon/AetheriaDaemonTutorialTopologyGenerator.cs @@ -112,13 +112,17 @@ public static class AetheriaDaemonTutorialTopologyGenerator return requested.Select(name => { - var match = (catalog.Corporations ?? Array.Empty()) - .FirstOrDefault(value => - string.Equals(value.ShortName, name, StringComparison.OrdinalIgnoreCase) || - string.Equals(value.Name, name, StringComparison.OrdinalIgnoreCase) || - string.Equals(value.CorporationKey, name, StringComparison.OrdinalIgnoreCase)); - if (match == null || string.IsNullOrWhiteSpace(match.CorporationKey)) + var matches = (catalog.Corporations ?? Array.Empty()) + .Where(value => MatchesAuthoredSelector(value, name)) + .ToArray(); + if (matches.Length == 0) throw new InvalidDataException($"Tutorial generation requires the authored faction '{name}'."); + if (matches.Length > 1) + throw new InvalidDataException( + $"Tutorial faction selector '{name}' is ambiguous: {string.Join(", ", matches.Select(value => value.Name))}."); + var match = matches[0]; + if (string.IsNullOrWhiteSpace(match.CorporationKey)) + throw new InvalidDataException($"Tutorial faction '{name}' has no stable corporation key."); var nameFile = catalog.FindNameFile(match.GeonameFileKey); if (nameFile == null || nameFile.Names.Count == 0) throw new InvalidDataException($"Tutorial faction '{name}' has no typed geoname corpus."); @@ -133,6 +137,17 @@ public static class AetheriaDaemonTutorialTopologyGenerator }).ToArray(); } + private static bool MatchesAuthoredSelector(AetheriaRuntimeCorporation corporation, string selector) + { + return string.Equals(corporation.CorporationKey, selector, StringComparison.OrdinalIgnoreCase) || + StartsWithSelector(corporation.ShortName, selector) || + StartsWithSelector(corporation.Name, selector); + } + + private static bool StartsWithSelector(string? value, string selector) => + !string.IsNullOrWhiteSpace(value) && + value.StartsWith(selector, StringComparison.OrdinalIgnoreCase); + public static AetheriaDaemonTutorialTopology Generate( IReadOnlyList factions, uint seed, @@ -209,11 +224,17 @@ public static class AetheriaDaemonTutorialTopologyGenerator { AetheriaDaemonTutorialFactionInput Resolve(string name) { - return factions.FirstOrDefault(value => - string.Equals(value.ShortName, name, StringComparison.OrdinalIgnoreCase) || - string.Equals(value.Name, name, StringComparison.OrdinalIgnoreCase) || - string.Equals(value.CorporationKey, name, StringComparison.OrdinalIgnoreCase)) - ?? throw new InvalidDataException($"Tutorial topology is missing faction '{name}'."); + var matches = factions.Where(value => + string.Equals(value.CorporationKey, name, StringComparison.OrdinalIgnoreCase) || + StartsWithSelector(value.ShortName, name) || + StartsWithSelector(value.Name, name)) + .ToArray(); + if (matches.Length == 0) + throw new InvalidDataException($"Tutorial topology is missing faction '{name}'."); + if (matches.Length > 1) + throw new InvalidDataException( + $"Tutorial topology faction selector '{name}' is ambiguous: {string.Join(", ", matches.Select(value => value.Name))}."); + return matches[0]; } var protagonist = Resolve(settings.ProtagonistFaction); diff --git a/Aetheria.State.Daemon/AetheriaDaemonTutorialWorldMaterializer.cs b/Aetheria.State.Daemon/AetheriaDaemonTutorialWorldMaterializer.cs index fb715cd7c..8b62db5c4 100644 --- a/Aetheria.State.Daemon/AetheriaDaemonTutorialWorldMaterializer.cs +++ b/Aetheria.State.Daemon/AetheriaDaemonTutorialWorldMaterializer.cs @@ -66,7 +66,8 @@ public static class AetheriaDaemonTutorialWorldMaterializer (uint)random.NextInt(1, int.MaxValue), topology.ZoneIndex, homes, - adjacency); + adjacency, + isPrelude: true); generators.Add(factionKey, generator); } return generator; @@ -148,7 +149,8 @@ public static class AetheriaDaemonTutorialWorldMaterializer world.Topology.GenerationSeed ^ 0x50A7_EA11u, topology.ZoneIndex, homes, - adjacency).Build("ship", protagonist.CorporationKey); + adjacency, + isPrelude: true).Build("ship", protagonist.CorporationKey); localPlayerIndex = entities.Count; entities.Add(AetheriaDaemonGeneratedEntityFactory.Create( "Pilot", diff --git a/Aetheria.State.Daemon/Program.cs b/Aetheria.State.Daemon/Program.cs index 3e7357436..827f8d0c3 100644 --- a/Aetheria.State.Daemon/Program.cs +++ b/Aetheria.State.Daemon/Program.cs @@ -40,7 +40,7 @@ await EnsureWorldDocumentAsync(node).ConfigureAwait(false); await EnsureTradeValuePolicyAsync(node, startedAtUtc).ConfigureAwait(false); await node.FlushAsync().ConfigureAwait(false); await EnsurePlayableRunDocumentsAsync(node, options, startedAtUtc).ConfigureAwait(false); -await EnsureTerminusGameSessionAsync(node, options, startedAtUtc).ConfigureAwait(false); +await EnsureGameSessionAsync(node, options, startedAtUtc).ConfigureAwait(false); var verseHost = await EnsureVerseHostSettingsAsync(node, options, startedAtUtc).ConfigureAwait(false); await EnsureVerseAuthorityPolicyAsync(node, options).ConfigureAwait(false); discoveryHost.Update(verseHost); @@ -186,7 +186,7 @@ static async Task TickAsync( TracePhase("core-ingress"); await AcceptEveCommandsAsync(node, options, ingressState).ConfigureAwait(false); TracePhase("provider-ingress"); - if (await ApplyRequestedTerminusSessionAsync(node, options).ConfigureAwait(false)) + if (await ApplyRequestedNewGameSessionAsync(node, options).ConfigureAwait(false)) { currentFrame = null; ingressState.ControlPlaneInitialized = false; @@ -2474,38 +2474,43 @@ static async Task EnsurePlayableRunDocumentsAsync( if (!string.IsNullOrWhiteSpace(settings?.ActiveRunKey)) { var existingRun = await ReadRuntimeRunCheckpointAsync(node, options.RenderSettings).ConfigureAwait(false); - if (HasPlayableRun(existingRun) && HasTerminusRun(existingRun, options.TerminusScenario)) + if (HasPlayableRun(existingRun)) return; } - await AetheriaDaemonZoneGenerator.WritePlayableRunAsync( - node, - node.RuntimeCatalog().Latest(), - now, - options.TerminusScenario) - .ConfigureAwait(false); + await WriteNewRunAsync(node, options, now).ConfigureAwait(false); } -static async Task EnsureTerminusGameSessionAsync( +static async Task EnsureGameSessionAsync( AetheriaStateNode node, AetheriaDaemonHostOptions options, string now) { + var player = await node.MutableDocument(AetheriaStateNode.PlayerSettingsKey) + .ReadAsync().ConfigureAwait(false); + if (string.IsNullOrWhiteSpace(player?.ActiveRunKey)) + throw new InvalidDataException("Aetheria game session requires an active daemon run."); + var run = await node.MutableDocument(new CultRecordKey(player.ActiveRunKey)) + .ReadAsync().ConfigureAwait(false) + ?? throw new InvalidDataException($"Active Aetheria run is missing: {player.ActiveRunKey}"); + var expectedMode = run.IsTutorial + ? AetheriaGameSessionState.AetheriaMode + : AetheriaGameSessionState.TerminusMode; var existing = await node.MutableDocument(AetheriaStateNode.GameSessionStateKey) .ReadAsync().ConfigureAwait(false); if (existing != null && - string.Equals(existing.Mode, AetheriaGameSessionState.TerminusMode, StringComparison.Ordinal) && - string.Equals(existing.RunId, AetheriaDaemonZoneGenerator.RunIdFor(options.TerminusScenario), StringComparison.Ordinal) && - !string.IsNullOrWhiteSpace(existing.ControlledEntityKey)) + string.Equals(existing.Mode, expectedMode, StringComparison.Ordinal) && + string.Equals(existing.RunId, run.RunId, StringComparison.Ordinal) && + string.Equals(existing.ControlledEntityKey, run.CurrentEntityKey, StringComparison.Ordinal)) return; await node.MutableDocument(AetheriaStateNode.GameSessionStateKey) .ReplaceAsync(new AetheriaGameSessionState { - Mode = AetheriaGameSessionState.TerminusMode, + Mode = expectedMode, SessionId = options.SessionId, - RunId = AetheriaDaemonZoneGenerator.RunIdFor(options.TerminusScenario), - ControlledEntityKey = AetheriaDaemonZoneGenerator.EntityKey(options.TerminusScenario, 0, 1), + RunId = run.RunId, + ControlledEntityKey = run.CurrentEntityKey, EntrySurfaceId = AetheriaRuntimeDaemonGameSurfaceBuilder.PilotSurfaceId, SimulationRate = 1, EffectiveSimulationRate = 1, @@ -2514,7 +2519,7 @@ static async Task EnsureTerminusGameSessionAsync( await node.FlushAsync().ConfigureAwait(false); } -static async Task ApplyRequestedTerminusSessionAsync( +static async Task ApplyRequestedNewGameSessionAsync( AetheriaStateNode node, AetheriaDaemonHostOptions options) { @@ -2531,16 +2536,11 @@ static async Task ApplyRequestedTerminusSessionAsync( return false; var now = DateTimeOffset.UtcNow.ToString("O"); - await AetheriaDaemonZoneGenerator.WritePlayableRunAsync( - node, - node.RuntimeCatalog().Latest(), - now, - options.TerminusScenario) - .ConfigureAwait(false); - session.Mode = AetheriaGameSessionState.TerminusMode; + var written = await WriteNewRunAsync(node, options, now).ConfigureAwait(false); + session.Mode = written.IsTutorial ? AetheriaGameSessionState.AetheriaMode : AetheriaGameSessionState.TerminusMode; session.SessionId = options.SessionId; - session.RunId = AetheriaDaemonZoneGenerator.RunIdFor(options.TerminusScenario); - session.ControlledEntityKey = AetheriaDaemonZoneGenerator.EntityKey(options.TerminusScenario, 0, 1); + session.RunId = written.RunId; + session.ControlledEntityKey = written.CurrentEntityKey; session.EntrySurfaceId = AetheriaRuntimeDaemonGameSurfaceBuilder.PilotSurfaceId; session.SimulationRate = 1; session.EffectiveSimulationRate = 1; @@ -2552,6 +2552,29 @@ static async Task ApplyRequestedTerminusSessionAsync( return true; } +static async Task WriteNewRunAsync( + AetheriaStateNode node, + AetheriaDaemonHostOptions options, + string now) +{ + var settings = await node.MutableDocument(AetheriaStateNode.PlayerSettingsKey) + .ReadAsync().ConfigureAwait(false) ?? new AetheriaPlayerSettings(); + var catalog = node.RuntimeCatalog().Latest(); + if (!settings.TutorialPassed) + return await AetheriaDaemonTutorialRunWriter.WriteAsync(node, catalog, now).ConfigureAwait(false); + + await AetheriaDaemonZoneGenerator.WritePlayableRunAsync( + node, + catalog, + now, + options.TerminusScenario).ConfigureAwait(false); + return new AetheriaDaemonWrittenRun( + AetheriaDaemonZoneGenerator.RunIdFor(options.TerminusScenario), + $"global:aetheria.run_state.{AetheriaDaemonZoneGenerator.RunIdFor(options.TerminusScenario)}.v1", + AetheriaDaemonZoneGenerator.EntityKey(options.TerminusScenario, 0, 1), + false); +} + static async Task EnsureVerseAuthorityPolicyAsync( AetheriaStateNode node, AetheriaDaemonHostOptions options) @@ -2926,27 +2949,6 @@ static bool HasPlayableRun(AetheriaRuntimeRunCheckpointCommit? run) .Any(zone => (zone.Entities ?? Array.Empty()).Count > 0); } -static bool HasTerminusRun(AetheriaRuntimeRunCheckpointCommit? run, string scenario) -{ - var zones = run?.Zones ?? Array.Empty(); - var terminusZone = zones.FirstOrDefault(zone => - string.Equals(zone.Name, "Daemon Generated Terminus", StringComparison.Ordinal)); - var entities = zones.SelectMany(zone => zone.Entities ?? Array.Empty()).ToArray(); - var bodies = zones.SelectMany(zone => zone.Bodies ?? Array.Empty()).ToArray(); - return run?.GenerationSeed == AetheriaDaemonZoneGenerator.GenerationSeed && - string.Equals(run.RunId, AetheriaDaemonZoneGenerator.RunIdFor(scenario), StringComparison.Ordinal) && - terminusZone != null && - terminusZone.GravityTerrainDepth > 0 && - (terminusZone.Bodies ?? Array.Empty()) - .Where(body => body.GravityInfluenceRadius > 0) - .All(body => body.GravityWellDepth > 0) && - entities.Any(entity => string.Equals(entity.Name, "Anchor Station", StringComparison.Ordinal)) && - entities.Count(entity => string.Equals(entity.FactionKey, "player", StringComparison.OrdinalIgnoreCase)) >= 4 && - entities.Count(entity => string.Equals(entity.FactionKey, "raider", StringComparison.OrdinalIgnoreCase)) >= 3 && - bodies.Any(body => string.Equals(body.BodyKey, "local.outer", StringComparison.Ordinal)) && - bodies.Length >= 10; -} - static AetheriaRuntimeLoadoutItemSlotCommit[] ToEntitySlotCommits( IReadOnlyList? slots) { diff --git a/Aetheria.State/Documents/AetheriaGameSessionState.cs b/Aetheria.State/Documents/AetheriaGameSessionState.cs index 87e62e995..2feaa8fdd 100644 --- a/Aetheria.State/Documents/AetheriaGameSessionState.cs +++ b/Aetheria.State/Documents/AetheriaGameSessionState.cs @@ -9,6 +9,7 @@ namespace Aetheria.State.Documents; public sealed class AetheriaGameSessionState { public const string TerminusMode = "terminus"; + public const string AetheriaMode = "aetheria"; [Key(0)] public string Mode { get; set; } = TerminusMode; [Key(1)] public string SessionId { get; set; } = ""; diff --git a/Assets/Scripts/UI/MainMenu.cs b/Assets/Scripts/UI/MainMenu.cs index d99866312..3e6376537 100644 --- a/Assets/Scripts/UI/MainMenu.cs +++ b/Assets/Scripts/UI/MainMenu.cs @@ -22,6 +22,7 @@ public class MainMenu : MonoBehaviour private UIDocument _menuSurfaceDocument; private Func _canOpenRuntimeInputScreen; private Action _openRuntimeInputScreen; + private IDisposable _newGameWait; private readonly List _hoverButtons = new List(); private readonly AetheriaEveUnitySurfaceChrome _menuSurfaceChrome = new AetheriaEveUnitySurfaceChrome { @@ -75,7 +76,7 @@ public class MainMenu : MonoBehaviour ContinueGame(); return; case AetheriaRuntimeMainMenuCommandKind.NewGame: - StartNewGame(); + StartNewGame(request); return; case AetheriaRuntimeMainMenuCommandKind.ShowSettings: ShowSettings(true); @@ -89,12 +90,39 @@ public class MainMenu : MonoBehaviour } } - private void StartNewGame() + private void StartNewGame(EveSurfaceCommandRequest request) { - if (!TryStartDaemonObservedGame("Starting Daemon Run")) + var before = ResolveSectorMap(CurrentStateBoot()); + if (!SendKnownAetheriaEveCommand(request, "new-game")) { ShowMain(false); + return; } + + var publishedBefore = before?.PublishedAtUtc ?? ""; + var generatorState = "Waiting for daemon world generation"; + HideMenuSurface(); + Dialog.Clear(); + Dialog.Title.text = "Generating Aetheria"; + Dialog.AddProperty(() => generatorState); + Dialog.Show(); + _newGameWait?.Dispose(); + _newGameWait = Observable.EveryUpdate() + .Select(_ => ResolveSectorMap(CurrentStateBoot())) + .Where(sectorMap => sectorMap != null && + sectorMap.IsTutorial && + !string.Equals(sectorMap.PublishedAtUtc, publishedBefore, StringComparison.Ordinal)) + .Take(1) + .ObserveOnMainThread() + .Subscribe(sectorMap => + { + generatorState = $"Entering {sectorMap.Zones.Count}-zone tutorial"; + SceneManager.LoadScene("ARPG"); + }, ex => + { + Debug.LogError($"Failed while waiting for daemon New Game state: {ex}"); + ShowMain(false); + }); } private bool TryStartDaemonObservedGame(string title) @@ -670,16 +698,16 @@ public class MainMenu : MonoBehaviour } } - private void SendKnownAetheriaEveCommand( + private bool SendKnownAetheriaEveCommand( EveSurfaceCommandRequest request, string label) { if (request == null) - return; + return false; var stateBoot = CurrentStateBoot(); if (!CanSendLocalEveCommand(stateBoot, label)) - return; + return false; try { @@ -690,10 +718,12 @@ public class MainMenu : MonoBehaviour .GetResult(); Debug.Log($"Submitted Aetheria {label} Eve operation: {submitted.OperationId}"); + return true; } catch (Exception ex) { Debug.LogError($"Failed to send Aetheria {label} Eve command: {ex}"); + return false; } } @@ -713,6 +743,7 @@ public class MainMenu : MonoBehaviour private void OnDestroy() { + _newGameWait?.Dispose(); if (_menuSurfaceDocument != null) { Destroy(_menuSurfaceDocument.gameObject); diff --git a/docs/aetheria-perfect-machine-map.md b/docs/aetheria-perfect-machine-map.md index a774198ec..58c4abaf8 100644 --- a/docs/aetheria-perfect-machine-map.md +++ b/docs/aetheria-perfect-machine-map.md @@ -1126,8 +1126,8 @@ the Terminus proof arena cannot award completion. Unity-compatible simplex semantics, weighted sample elimination, Delaunay graph, connectivity-preserving link pruning, and faction placement owner. - Cut line: a generated Terminus proof arena cannot be relabelled as the - tutorial. The daemon topology exists as a distinct pre-materialization result; - it is not selected as a playable run until daemon zone contents are migrated. + tutorial. New Game selects the daemon-persisted tutorial while completion is + false; Terminus remains a witness fixture. - Verification layer: smoke generates the authored 64-zone graph twice from one seed, proves point/adjacency repeatability, a connected undirected graph, six distinct role homes, an unowned entrance, and discovery containing exactly @@ -1135,6 +1135,29 @@ the Terminus proof arena cannot award completion. implementation against Unity Mathematics vectors and carries the same semantics in HLSL. +### Daemon Tutorial Population And Run Ownership + +- Owner: the daemon tutorial materializer owns station, turret, faction-ship, + starter-ship, orbit, and run persistence decisions. +- Inputs: the immutable tutorial topology, each celestial plan and its exact + post-body CultMath state, typed faction/catalog data, player settings, and the + accepted New Game command. +- Outputs: 64 canonical zone documents, stable entity records, loadout + generation receipts, one controlled entrance ship, tutorial discovery state, + and an Aetheria-mode game session. +- Derived state: wormhole exits derive from adjacency; generic Eve maps, + cameras, scene objects, fog, and HUD state lower the persisted run. +- Forbidden writers: Unity generators, menu callbacks, scene materializers, and + Terminus scenarios cannot create or select gameplay entities for this run. +- Shared paths: fresh daemon boot and accepted New Game use the same tutorial + run writer; the Unity product shell submits the Eve command and waits for a + newer tutorial sector-map publication before entering the scene. +- Cut line: New Game reloading the previous frame without sending its advertised + operation is dead. Celestial-only tutorial graphs are not playable runs. +- Verification layer: focused smokes prove deterministic population, resolved + orbital references, station/turret/agent presence, loadout provenance, all 64 + persisted zones, canonical starter identity, discovery, and adjacency. + ### Daemon Generated Zone Body Ownership - Owner: the daemon zone-body generator owns each generated zone's radius, diff --git a/docs/original-game-migration-matrix.md b/docs/original-game-migration-matrix.md index 100a0bad9..6e8ac7dc5 100644 --- a/docs/original-game-migration-matrix.md +++ b/docs/original-game-migration-matrix.md @@ -15,9 +15,9 @@ validation proves contract shape, not wiring, exclusivity, lowering, or parity. | Organ | Original authority/evidence | Target owner | Eve contract | Runtime lowering | Current status | Required proof | |---|---|---|---|---|---|---| -| Run/session state | `ServerShared`, `ActionGameManager` | Aetheria daemon/CultCache | provider/session advertisement plus run lifecycle bindings | all clients | active/failed lifecycle is daemon-owned and restart-stable: controlled-entity destruction commits the fossil cause, terminal frame, one `run.failed` fact, releases control, rejects later gameplay commands, and freezes the world; Eve receives terminal presentation/input levers without becoming an owner. Terminus keeps persistent requested simulation rate distinct from effective rate: compressed batches inspect authoritative facts after each fixed step, stop at the causal damage/destruction/cargo/thermal/docking/weapon/wormhole/run event, pause effectively without erasing the request, and project the exact cause and executed-step count through Eve. Docked, travelling, fighting, mining, looting, and refitting remain derived world conditions rather than counterfeit durable phases. The distinct tutorial topology is now daemon-owned and deterministic: authored 64-zone weighted sampling, Delaunay/link pruning, six faction roles/homes, influence, unowned entrance, initial discovery, and faction-trained Markov zone names run on Unity-compatible CultMath simplex/random semantics. It is deliberately not selectable yet because fossil zone bodies/entities are not materialized; Terminus generation preserves `TutorialPassed` and cannot impersonate completion | tutorial zone materialization, New Game selection, and a source-backed completion rule (none survived in the fossil); full-daemon death/restart witness, broader attention taxonomy (contact, targeting, readiness, arrival, discovery, and failed orders), and multi-client convergence | +| Run/session state | `ServerShared`, `ActionGameManager` | Aetheria daemon/CultCache | provider/session advertisement plus run lifecycle bindings | all clients | active/failed lifecycle is daemon-owned and restart-stable: controlled-entity destruction commits the fossil cause, terminal frame, one `run.failed` fact, releases control, rejects later gameplay commands, and freezes the world; Eve receives terminal presentation/input levers without becoming an owner. Terminus keeps persistent requested simulation rate distinct from effective rate: compressed batches inspect authoritative facts after each fixed step, stop at the causal damage/destruction/cargo/thermal/docking/weapon/wormhole/run event, pause effectively without erasing the request, and project the exact cause and executed-step count through Eve. Docked, travelling, fighting, mining, looting, and refitting remain derived world conditions rather than counterfeit durable phases. The distinct tutorial is now daemon-owned and selectable: authored 64-zone topology, bodies, post-body station/turret/agent population, starter entry ship, loadout receipts, discovery, and canonical persistence feed an Aetheria-mode session. New Game submits its Eve operation and waits for the new tutorial sector-map publication. Terminus preserves `TutorialPassed` and cannot impersonate completion | source-backed tutorial completion rule (none survived in the fossil); replace the post-tutorial Terminus fallback with the authored regular-sector generator; full-daemon death/restart witness, broader attention taxonomy, and multi-client convergence | | Entity identity/loadout | `ServerShared/Entity*` | daemon | typed entity and inventory surfaces | EveUnity/Electron | daemon-owned hull identity, exact installed placement/rotation and instance state, cargo stacks, weapon membership/held state, equipment wear, executable behavior state, weapon chronology, active-effect state, and loadout-generation provenance survive a hard CultCache close/reopen through the durable latest-frame checkpoint. An advertised generic Eve equip operation now translates into the typed daemon transaction before that checkpoint; its accepted placement survives restart and its consumed station-cargo source does not resurrect. Generic Eve rebuilds weapon and scalar thermostat controls from that restored truth; legacy per-entity documents are bootstrap inputs only when no live frame exists | live client refit witness and multi-client convergence | -| Loadout generation | map/faction availability, item cost, hull hardpoints and role constraints | daemon using canonical galaxy, faction knowledge/economy and typed catalog | generated loadout plus provenance/availability facts | Eve inspection and refit surfaces | daemon now uses the fossil candidate filter and seeded weighted selection: manufacturer must be present and allied, ally weight decays by home-zone graph distance, price uses the authored exponent, and hardpoints require matching semantic type, rotated footprint containment, and controller role; the April 2021 catalog fossil restores the distinct common `Longinus`, rare AetherDrive-compatible `LonginusX`, and `Djinni` rows with their original IDs, shapes, hardpoints, prices, drag, and prefabs, plus missing Thruster rows required to fill their authored mounts; typed `rarity:rare` tags apply a 0.05 generation multiplier to `LonginusX` and AetherDrive equipment; the generator owns one mutable CultMath stream, fixing the readonly-struct defensive-copy bug that restarted every weighted draw; placement rotation survives durable state and reconnect; generation fills the largest compatible footprint before economic weighting; cargo/capacitor plus station docking equipment must fit remaining hull space; stations pack faction-available inventory largest-first; ordinary ships begin without invented scenario cargo; every generated entity persists a source/selection receipt that reaches Eve as `loadout.item` semantics | multi-zone generated-world parity and exact root-to-zone stream sequencing against the fossil | +| Loadout generation | map/faction availability, item cost, hull hardpoints and role constraints | daemon using canonical galaxy, faction knowledge/economy and typed catalog | generated loadout plus provenance/availability facts | Eve inspection and refit surfaces | daemon now uses the fossil candidate filter and seeded weighted selection: manufacturer must be present and allied, ally weight decays by home-zone graph distance, price uses the authored exponent, and hardpoints require matching semantic type, rotated footprint containment, and controller role. Prelude generation retains the fossil exception that allied catalog manufacturers need not own one of the six tutorial home zones; unknown manufacturers remain zero-weight. The April 2021 catalog fossil restores the distinct common `Longinus`, rare AetherDrive-compatible `LonginusX`, and `Djinni` rows with their original IDs, shapes, hardpoints, prices, drag, and prefabs, plus missing Thruster rows required to fill their authored mounts; typed `rarity:rare` tags apply a 0.05 generation multiplier to `LonginusX` and AetherDrive equipment; the generator owns one mutable CultMath stream, fixing the readonly-struct defensive-copy bug that restarted every weighted draw; placement rotation survives durable state and reconnect; generation fills the largest compatible footprint before economic weighting; cargo/capacitor plus station docking equipment must fit remaining hull space; stations pack faction-available inventory largest-first; ordinary ships begin without invented scenario cargo; every generated entity persists a source/selection receipt that reaches Eve as `loadout.item` semantics | multi-zone generated-world parity and exact root-to-zone stream sequencing against the fossil | | Flight intent | `Ship`, `Thruster`, `AetherDrive`, `VelocityConversion`, `VelocityLimit`, input paths | daemon actuator simulation + Ymir integration | analog local helm/look/tractor plus actuator state | generic Eve input and scene lowerers | direct faction-speed velocity ownership is deleted; daemon persists local strafe/forward helm and desired look, allocates ordinary directional thruster banks by authored rotation, derives torque from hull/item placement, compensates lateral torque, gates execution through the shared energy ledger, deposits equipment-cell heat, publishes plume visibility and actuator state, applies hull drag, then runs operational velocity conversion with the fossil exponential damp equation and clamps the result through evaluated velocity limits before giving velocity/direction to Ymir. The evaluated limit remains in durable behavior state for reconnect and Eve inspection. Autonomous tasks translate world travel into the same local helm axes and issue look commands instead of mutating heading. AetherDrive rotor/coupling simulation is additive and explicitly non-default: common `Longinus` and `Djinni` hulls use ordinary thrusters; the rare `LonginusX` replaces those mounts with the single rare `Traction` AetherDrive path | hardpoint-transform direction parity, exact cross-equipment behavior execution ordering, CultMath/float32 parity harness, live production-frequency evidence, generic thrust/turn feedback lowering, and live handling screenshots | | Collision | fossil entity code contains no ship/station collision gameplay callback; shield collision timing is presentation | Ymir | Ymir-owned contact facts for collidable pairs; immutable entity generations for presentation | visual interpolation only | Ymir world stepping owns entity poses, radial fields, ship/pickup Begin contacts, rejection kicks, and persistent physical-payload contacts. Ship and station bodies deliberately share one negative collision group: the fossil had no rigidbody entity response, and invented circle separation would make its 25-unit center-distance docking rule unreachable. Daemon smoke advances an overlapping ship/station pair, proves the ship remains at 24 units, then accepts docking. The released EveUnity scene sink consumes immutable presented generations and has no provider/command-transport dependency; the canonical Unity product contains no Aetheria or ServerShared gameplay assembly | upstream Box3D parity harness for any future solid-body pair and live interpolation timeline under packet delay | | Targeting/contacts | sensors + `ActionGameManager` | daemon | contact/target semantics | target HUD and indicators | daemon-owned selection now preserves the executable fossil exactly, including its oddly misnamed `Target Nearest` action selecting `MaxBy(distance)`, stable visible-contact tie order, and previous-from-no-selection choosing the second-to-last distance row when at least three contacts exist. Generic Eve nearest/next/previous/reticle/clear levers route to that owner; explicit scene targeting preserves both EveUnity's `sourceEntityId` and `targetEntityId` instead of falling back to the frame's current ship. Only daemon-visible contacts can be explicitly selected, and `target-not-visible` survives into the denied Eve receipt without disturbing the prior target. Every authored instant lock behavior evaluates on every daemon step independently of trigger/burst selection, so an idle weapon cannot retain a stale completed lock; acquisition and decay derive from facing, elapsed time, and observer-local contact confidence. Smoke proves progressive acquisition, exact target-transfer loss/start chronology, authored angular decay with one loss crossing, reacquisition without replaying start, invalid-target reset, and generic Eve projection of the prior/current lock values. `weapon.lock.started`, `weapon.lock.acquired`, and `weapon.lock.lost` publish stable one-time chronology with target, weapon identity, reason, and prior/current progress through the generic feedback stream | authored reticle/HUD parity; provider audio/effect binding is visual pull work | @@ -35,7 +35,7 @@ validation proves contract shape, not wiring, exclusivity, lowering, or parity. | Pilot camera | ARPG follow/dock cameras | Eve view semantics + runtime | camera rig and semantic view id | EveUnity camera rig | daemon dock state selects distinct contracts instead of collapsing both fossil cameras: undocked flight advertises the entity-forward `Third Person Rig` framing (distance 30, screen 0.64/0.19, FOV 60, lens 1-4096) and the shared `aim.presentation` convergence point as its look-at; Aetheria translates the fossil Cinemachine top-origin screen Y of `0.81` to Eve's bottom-origin viewport Y of `0.19`; EveUnity solves native pose while preserving both optical aim and advertised entity framing, without provider types; the retained dock projection remains separate | reproduce the dock camera's separate follow/look-at subjects, blend timeline, noise, and reconnect state | | Render channels | Unity layers/culling masks | provider surface policy + runtime asset variant | semantic channel exclusions | EveUnity native layer mapping | wired, exclusive, and lowered: the pilot surface excludes the semantic `map` channel; the Unity asset variant maps `map` to its authored native layer; EveUnity subtracts that layer from the configured camera mask; portable state contains no Unity layer or mask; provider conversion preserves the source icon shader's unlit lighting model; the released witness proves the pilot camera excludes map glyphs while the map camera retains readable white glyphs without a scene light | preserve the channel proof while world presentation and transport continue to evolve | | Minimap/tactical map | `ZoneRenderer`, map cameras | daemon world facts | explicit map projections | Unity and Electron | facts fragmented; generic lowerers absent | same state in both runtimes | -| Celestial world | `ZoneRenderer`, `ZoneGenerator`, `GeneratorPlanet`, body/asteroid prefab scripts | daemon render projection plus provider assets | ordinary generic Eve entity SoA rows | EveUnity generic entity/prefab lowerer | wired, exclusive, projected, and lowered for Terminus; generated-world authority now also exists in the daemon. Each tutorial topology zone deterministically evaluates the authored radius/mass/subzone curves, rosette-or-solar hierarchy, five satellite/binary passes, belt selection, mass normalization, stable orbits/bodies, gravity/wave curves, asteroid rows, and sun/gas-giant visual parameters. A whole-world proof materializes all 64 zones with stellar primaries and belts. Provider packaging extracts only each advertised visual child and strips fossil scripts/physics; released EveUnity `0.3.51` applies semantic scale around provider-authored local scale and contains no celestial or Aetheria branch. The released warm Terminus witness records eleven bodies and eighteen asteroids with provider refs and enabled renderers, including seven celestial instances intersecting the pilot frustum | persist generated tutorial zones with entities and witness their generic lowering; body material/light readability, close-range composition matching the fossil, asteroid variation, and Electron lowering | +| Celestial world | `ZoneRenderer`, `ZoneGenerator`, `GeneratorPlanet`, body/asteroid prefab scripts | daemon render projection plus provider assets | ordinary generic Eve entity SoA rows | EveUnity generic entity/prefab lowerer | wired, exclusive, projected, and lowered for Terminus; generated-world authority now also exists in the daemon. Each tutorial topology zone deterministically evaluates the authored radius/mass/subzone curves, rosette-or-solar hierarchy, five satellite/binary passes, belt selection, mass normalization, stable orbits/bodies, gravity/wave curves, asteroid rows, and sun/gas-giant visual parameters. All 64 zones, their station/turret orbits, faction ships, and starter entry are persisted as canonical daemon state. Provider packaging extracts only each advertised visual child and strips fossil scripts/physics; released EveUnity `0.3.51` applies semantic scale around provider-authored local scale and contains no celestial or Aetheria branch. The released warm Terminus witness records eleven bodies and eighteen asteroids with provider refs and enabled renderers, including seven celestial instances intersecting the pilot frustum | witness generic lowering of the persisted tutorial run; body material/light readability, close-range composition matching the fossil, asteroid variation, and Electron lowering | | Fields/fog/gravity | zone renderer and shaders | daemon/plugin semantics | Fields plugin documents | EveUnity fields lowerer | daemon publishes canonical gravity/fog splat layers through `field.volume3d`; Eve Fields `0.2.3` owns portable `PowerPulse` and `AnimatedRadialCosine` semantics; Aetheria emits the fossil global animated simplex/cellular/ambient stack, body-owned radial waves, and separate negative gameplay `gravity.height` and positive visual `fog.surface_height`; the shared camera-relative lattice spans 1536 world units as 256 six-unit Stardust cells, rasterizes gravity at eight texels per cell into 2048 texels, and snaps the viewport by one six-unit cell; daemon entities follow fossil terrain height plus hull grid offset after Ymir XZ motion; released EveUnity `0.3.58` lowers the authored topology, one shared snapped viewport frame for fog and Stardust, provider shader ABI, pre-postprocess URP pass, provider-requested TAA, provider-material temporal coverage inputs, authoritative flow time, the historical positive-Z Unity shader camera transform, and float32 packed-output diagnostics without provider code. The provider bundle runs the actual Stardust compute shader across X, Y, and diagonal one-cell remaps and proves 705 overlapping world cells remain bit-identical after buffer reassignment; an asymmetric GPU fixture proves positive world X samples positive texture X instead of retaining the deleted fossil gravity camera's two-axis reversal; its source gate rejects replacement of temporal dithering with a fixed alpha threshold. A separate gravity-fog gate requires raymarch and temporal reprojection to share the historical positive-Z camera convention. The flight post-process bundle gate verifies serialized ACES, exposure/contrast, bloom, vignette, and film-grain components | restore readable patch structure, gravity waves, surrounding world geometry, and final luminance/composition parity; visual parity remains explicitly open | | HUD/schematic | ARPG HUD and `SchematicDisplay` | Eve composition from daemon facts | semantic status/components | EveUnity UI | provider-authored transparent cockpit is wired, projected, and lowered through generic UI Toolkit panes, metrics, and progress components for hull, shield, capacitor, temperature, cargo, weapon cooldown/groups, selected target, target lock, target shield, and target hull. The daemon now publishes the original spatial schematic semantics as a generic `ship.schematic` subtree for both self and selected target: explicit occupied hull cells with current/maximum armor, catalog-backed rotated equipment footprints, durability, thermal range/performance, online state, wear, and nested weapon ammo/cooldown/charge/reload facts. Refit, damage, and presentation share the same rotation geometry; Unity objects do not derive schematic truth | generic spatial schematic lowering, warning timelines, dynamic action state, and composited live capture | | Hit/lock/warnings | `ActionGameManager` feedback | daemon event facts | transient feedback stream | VFX/UI/audio | bounded deduplicated game-event ledger and Eve `feedback.stream` wired for pickup outcomes, projectile launch/impact, entity damage, alive-to-dead destruction, thermal-risk crossings, accepted dock/undock transitions, authoritative weapon reload chronology, lock start/acquired/lost chronology, and episode-deduplicated `weapon.fire.refused` facts for insufficient energy or missing ammunition; docking facts retain exact actor/parent/bay identity and rejected operations emit none; every lock transition carries authored weapon identity, target, reason, and prior/current progress, while reconnect priming prevents retained events from replaying as new feedback | broader negative transaction fixtures, provider lock/docking audio and effect roles, and broader runtime effect consumption | diff --git a/docs/renderless-aetheria-architecture.md b/docs/renderless-aetheria-architecture.md index 0d3fc0838..5c652b4a4 100644 --- a/docs/renderless-aetheria-architecture.md +++ b/docs/renderless-aetheria-architecture.md @@ -147,11 +147,18 @@ orbits, gravity curves, and sun/gas-giant presentation parameters. The old process-dependent string/hash seed has been replaced by a stable typed-zone seed; generated saves must reproduce across daemon processes. -The world remains pre-session until station, ship, player-entry, and wormhole -entities are materialized. The daemon must not present a celestial-only graph -or the handcrafted Terminus proof arena as a completed tutorial. Once entity -materialization is complete, New Game may select it from player settings and -Eve may lower its map and entry controls without becoming generation authority. +The daemon continues the exact post-celestial random stream to populate each +zone with the fossil station-count curve, Lagrange station orbits, paired +defensive turrets, and faction ships. The entrance additionally receives the +controlled starter ship. Zone adjacency is the wormhole truth; exits remain a +derived render/interaction query rather than counterfeit wormhole entities. + +New Game now submits its advertised Eve operation, waits for a newly published +daemon sector map, and selects the persisted 64-zone tutorial while +`TutorialPassed` is false. The handcrafted Terminus arena remains a proof +fixture and the fallback for the still-unmigrated post-tutorial sector path. +No surviving source defines tutorial completion, so entering this run does not +change `TutorialPassed`. ## Current Mechanism